1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

arp-util: make arp_send_{probe,announcement}() inline

This commit is contained in:
Yu Watanabe 2021-06-18 15:40:38 +09:00
parent 28ba416c99
commit e1a3915b41
3 changed files with 35 additions and 45 deletions

View File

@ -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);
}

View File

@ -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);
}

View File

@ -42,42 +42,26 @@ 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)
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 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);
assert_se(ifindex > 0);
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);
return arp_network_send_raw_socket(fd, ifindex, &ea);
}
int arp_network_bind_raw_socket(int ifindex, be32_t address, const struct ether_addr *eth_mac) {
if (socketpair(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, test_fd) < 0)
return -errno;