mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
dhcp: shorten code a bit
This commit is contained in:
parent
36f1955da8
commit
d70c78131d
@ -172,7 +172,6 @@ int dhcp_network_bind_udp_socket(int ifindex, be32_t address, uint16_t port, int
|
|||||||
r = setsockopt_int(s, IPPROTO_IP, IP_TOS, ip_service_type);
|
r = setsockopt_int(s, IPPROTO_IP, IP_TOS, ip_service_type);
|
||||||
else
|
else
|
||||||
r = setsockopt_int(s, IPPROTO_IP, IP_TOS, IPTOS_CLASS_CS6);
|
r = setsockopt_int(s, IPPROTO_IP, IP_TOS, IPTOS_CLASS_CS6);
|
||||||
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
@ -204,8 +203,7 @@ int dhcp_network_bind_udp_socket(int ifindex, be32_t address, uint16_t port, int
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = bind(s, &src.sa, sizeof(src.in));
|
if (bind(s, &src.sa, sizeof(src.in)) < 0)
|
||||||
if (r < 0)
|
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
return TAKE_FD(s);
|
return TAKE_FD(s);
|
||||||
@ -213,14 +211,12 @@ int dhcp_network_bind_udp_socket(int ifindex, be32_t address, uint16_t port, int
|
|||||||
|
|
||||||
int dhcp_network_send_raw_socket(int s, const union sockaddr_union *link,
|
int dhcp_network_send_raw_socket(int s, const union sockaddr_union *link,
|
||||||
const void *packet, size_t len) {
|
const void *packet, size_t len) {
|
||||||
int r;
|
|
||||||
|
|
||||||
assert(link);
|
assert(link);
|
||||||
assert(packet);
|
assert(packet);
|
||||||
assert(len);
|
assert(len);
|
||||||
|
|
||||||
r = sendto(s, packet, len, 0, &link->sa, SOCKADDR_LL_LEN(link->ll));
|
if (sendto(s, packet, len, 0, &link->sa, SOCKADDR_LL_LEN(link->ll)) < 0)
|
||||||
if (r < 0)
|
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -233,14 +229,12 @@ int dhcp_network_send_udp_socket(int s, be32_t address, uint16_t port,
|
|||||||
.in.sin_port = htobe16(port),
|
.in.sin_port = htobe16(port),
|
||||||
.in.sin_addr.s_addr = address,
|
.in.sin_addr.s_addr = address,
|
||||||
};
|
};
|
||||||
int r;
|
|
||||||
|
|
||||||
assert(s >= 0);
|
assert(s >= 0);
|
||||||
assert(packet);
|
assert(packet);
|
||||||
assert(len);
|
assert(len);
|
||||||
|
|
||||||
r = sendto(s, packet, len, 0, &dest.sa, sizeof(dest.in));
|
if (sendto(s, packet, len, 0, &dest.sa, sizeof(dest.in)) < 0)
|
||||||
if (r < 0)
|
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user