diff options
-rw-r--r-- | src/libsystemd-network/arp-util.c | 12 | ||||
-rw-r--r-- | src/libsystemd-network/arp-util.h | 24 | ||||
-rw-r--r-- | src/libsystemd-network/test-ipv4ll.c | 34 |
3 files changed, 30 insertions, 40 deletions
diff --git a/src/libsystemd-network/arp-util.c b/src/libsystemd-network/arp-util.c index 251a7a7989..149479fc07 100644 --- a/src/libsystemd-network/arp-util.c +++ b/src/libsystemd-network/arp-util.c @@ -89,7 +89,7 @@ int arp_network_bind_raw_socket(int ifindex, be32_t address, const struct ether_ return TAKE_FD(s); } -static int arp_send_packet( +int arp_send_packet( int fd, int ifindex, be32_t pa, @@ -132,13 +132,3 @@ static int arp_send_packet( return 0; } - -int arp_send_probe(int fd, int ifindex, - be32_t pa, const struct ether_addr *ha) { - return arp_send_packet(fd, ifindex, pa, ha, false); -} - -int arp_send_announcement(int fd, int ifindex, - be32_t pa, const struct ether_addr *ha) { - return arp_send_packet(fd, ifindex, pa, ha, true); -} diff --git a/src/libsystemd-network/arp-util.h b/src/libsystemd-network/arp-util.h index 2dac8cfbaa..db4afec6fa 100644 --- a/src/libsystemd-network/arp-util.h +++ b/src/libsystemd-network/arp-util.h @@ -12,7 +12,23 @@ int arp_network_bind_raw_socket(int index, be32_t address, const struct ether_addr *eth_mac); -int arp_send_probe(int fd, int ifindex, - be32_t pa, const struct ether_addr *ha); -int arp_send_announcement(int fd, int ifindex, - be32_t pa, const struct ether_addr *ha); +int arp_send_packet( + int fd, + int ifindex, + be32_t pa, + const struct ether_addr *ha, + bool announce); +static inline int arp_send_probe( + int fd, + int ifindex, + be32_t pa, + const struct ether_addr *ha) { + return arp_send_packet(fd, ifindex, pa, ha, false); +} +static inline int arp_send_announcement( + int fd, + int ifindex, + be32_t pa, + const struct ether_addr *ha) { + return arp_send_packet(fd, ifindex, pa, ha, true); +} diff --git a/src/libsystemd-network/test-ipv4ll.c b/src/libsystemd-network/test-ipv4ll.c index 768595969b..c08039f3bb 100644 --- a/src/libsystemd-network/test-ipv4ll.c +++ b/src/libsystemd-network/test-ipv4ll.c @@ -42,20 +42,13 @@ static void basic_request_handler(sd_ipv4ll *ll, int event, void *userdata) { } } -static int arp_network_send_raw_socket(int fd, int ifindex, - const struct ether_arp *arp) { - assert_se(arp); - assert_se(ifindex > 0); - assert_se(fd >= 0); +int arp_send_packet( + int fd, + int ifindex, + be32_t pa, + const struct ether_addr *ha, + bool announce) { - if (send(fd, arp, sizeof(struct ether_arp), 0) < 0) - return -errno; - - return 0; -} - -int arp_send_probe(int fd, int ifindex, - be32_t pa, const struct ether_addr *ha) { struct ether_arp ea = {}; assert_se(fd >= 0); @@ -63,19 +56,10 @@ int arp_send_probe(int fd, int ifindex, assert_se(pa != 0); assert_se(ha); - return arp_network_send_raw_socket(fd, ifindex, &ea); -} - -int arp_send_announcement(int fd, int ifindex, - be32_t pa, const struct ether_addr *ha) { - struct ether_arp ea = {}; - - assert_se(fd >= 0); - assert_se(ifindex > 0); - assert_se(pa != 0); - assert_se(ha); + if (send(fd, &ea, sizeof(struct ether_arp), 0) < 0) + return -errno; - return arp_network_send_raw_socket(fd, ifindex, &ea); + return 0; } int arp_network_bind_raw_socket(int ifindex, be32_t address, const struct ether_addr *eth_mac) { |