diff options
Diffstat (limited to 'src/libsystemd-network')
-rw-r--r-- | src/libsystemd-network/dhcp-internal.h | 6 | ||||
-rw-r--r-- | src/libsystemd-network/dhcp-lease-internal.h | 22 | ||||
-rw-r--r-- | src/libsystemd-network/dhcp-server-internal.h | 3 | ||||
-rw-r--r-- | src/libsystemd-network/sd-dhcp-lease.c | 176 | ||||
-rw-r--r-- | src/libsystemd-network/sd-dhcp-server.c | 145 | ||||
-rw-r--r-- | src/libsystemd-network/test-dhcp-client.c | 3 | ||||
-rw-r--r-- | src/libsystemd-network/test-dhcp-option.c | 3 | ||||
-rw-r--r-- | src/libsystemd-network/test-dhcp-server.c | 1 |
8 files changed, 115 insertions, 244 deletions
diff --git a/src/libsystemd-network/dhcp-internal.h b/src/libsystemd-network/dhcp-internal.h index 6a803d7b05..7e8149487a 100644 --- a/src/libsystemd-network/dhcp-internal.h +++ b/src/libsystemd-network/dhcp-internal.h @@ -7,7 +7,6 @@ #include <linux/if_packet.h> #include <net/ethernet.h> -#include <net/if_arp.h> #include <stdint.h> #include "sd-dhcp-client.h" @@ -23,6 +22,11 @@ typedef struct sd_dhcp_option { size_t length; } sd_dhcp_option; +typedef struct DHCPServerData { + struct in_addr *addr; + size_t size; +} DHCPServerData; + extern const struct hash_ops dhcp_option_hash_ops; int dhcp_network_bind_raw_socket(int ifindex, union sockaddr_union *link, diff --git a/src/libsystemd-network/dhcp-lease-internal.h b/src/libsystemd-network/dhcp-lease-internal.h index 67a77eb098..aed30d6118 100644 --- a/src/libsystemd-network/dhcp-lease-internal.h +++ b/src/libsystemd-network/dhcp-lease-internal.h @@ -5,11 +5,9 @@ Copyright © 2013 Intel Corporation. All rights reserved. ***/ -#include <stdint.h> -#include <linux/if_packet.h> - #include "sd-dhcp-client.h" +#include "dhcp-internal.h" #include "dhcp-protocol.h" #include "list.h" #include "util.h" @@ -52,23 +50,7 @@ struct sd_dhcp_lease { struct in_addr *router; size_t router_size; - struct in_addr *dns; - size_t dns_size; - - struct in_addr *ntp; - size_t ntp_size; - - struct in_addr *sip; - size_t sip_size; - - struct in_addr *pop3_server; - size_t pop3_server_size; - - struct in_addr *smtp_server; - size_t smtp_server_size; - - struct in_addr *lpr_server; - size_t lpr_server_size; + DHCPServerData servers[_SD_DHCP_LEASE_SERVER_TYPE_MAX]; struct sd_dhcp_route *static_route; size_t static_route_size, static_route_allocated; diff --git a/src/libsystemd-network/dhcp-server-internal.h b/src/libsystemd-network/dhcp-server-internal.h index fb42f2f80c..39899680a5 100644 --- a/src/libsystemd-network/dhcp-server-internal.h +++ b/src/libsystemd-network/dhcp-server-internal.h @@ -56,8 +56,7 @@ struct sd_dhcp_server { char *timezone; - struct in_addr *ntp, *dns, *sip, *pop3_server, *smtp_server, *lpr_server; - size_t n_ntp, n_dns, n_sip, n_pop3_server, n_smtp_server, n_lpr_server; + DHCPServerData servers[_SD_DHCP_LEASE_SERVER_TYPE_MAX]; OrderedHashmap *extra_options; OrderedHashmap *vendor_options; diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c index 3b02530e24..8582302cb4 100644 --- a/src/libsystemd-network/sd-dhcp-lease.c +++ b/src/libsystemd-network/sd-dhcp-lease.c @@ -98,78 +98,38 @@ int sd_dhcp_lease_get_mtu(sd_dhcp_lease *lease, uint16_t *mtu) { int sd_dhcp_lease_get_servers( sd_dhcp_lease *lease, - sd_dhcp_lease_info what, + sd_dhcp_lease_server_type what, const struct in_addr **addr) { assert_return(lease, -EINVAL); + assert_return(what >= 0, -EINVAL); + assert_return(what < _SD_DHCP_LEASE_SERVER_TYPE_MAX, -EINVAL); assert_return(addr, -EINVAL); - switch (what) { - case SD_DHCP_LEASE_DNS_SERVERS: - if (lease->dns_size <= 0) - return -ENODATA; - - *addr = lease->dns; - return (int) lease->dns_size; - - case SD_DHCP_LEASE_NTP_SERVERS: - if (lease->ntp_size <= 0) - return -ENODATA; - - *addr = lease->ntp; - return (int) lease->ntp_size; - - case SD_DHCP_LEASE_SIP_SERVERS: - if (lease->sip_size <= 0) - return -ENODATA; - - *addr = lease->sip; - return (int) lease->sip_size; - - case SD_DHCP_LEASE_POP3_SERVERS: - if (lease->pop3_server_size <= 0) - return -ENODATA; - - *addr = lease->pop3_server; - return (int) lease->pop3_server_size; - - case SD_DHCP_LEASE_SMTP_SERVERS: - if (lease->smtp_server_size <= 0) - return -ENODATA; - - *addr = lease->smtp_server; - return (int) lease->smtp_server_size; - - case SD_DHCP_LEASE_LPR_SERVERS: - if (lease->lpr_server_size <= 0) - return -ENODATA; - - *addr = lease->lpr_server; - return (int) lease->lpr_server_size; + if (lease->servers[what].size <= 0) + return -ENODATA; - default: - return log_debug_errno(SYNTHETIC_ERRNO(ENXIO), - "Unknown DHCP lease info item %d.", what); - } + *addr = lease->servers[what].addr; + return (int) lease->servers[what].size; } int sd_dhcp_lease_get_dns(sd_dhcp_lease *lease, const struct in_addr **addr) { - return sd_dhcp_lease_get_servers(lease, SD_DHCP_LEASE_DNS_SERVERS, addr); + return sd_dhcp_lease_get_servers(lease, SD_DHCP_LEASE_DNS, addr); } int sd_dhcp_lease_get_ntp(sd_dhcp_lease *lease, const struct in_addr **addr) { - return sd_dhcp_lease_get_servers(lease, SD_DHCP_LEASE_NTP_SERVERS, addr); + return sd_dhcp_lease_get_servers(lease, SD_DHCP_LEASE_NTP, addr); } int sd_dhcp_lease_get_sip(sd_dhcp_lease *lease, const struct in_addr **addr) { - return sd_dhcp_lease_get_servers(lease, SD_DHCP_LEASE_SIP_SERVERS, addr); + return sd_dhcp_lease_get_servers(lease, SD_DHCP_LEASE_SIP, addr); } -int sd_dhcp_lease_get_pop3_server(sd_dhcp_lease *lease, const struct in_addr **addr) { - return sd_dhcp_lease_get_servers(lease, SD_DHCP_LEASE_POP3_SERVERS, addr); +int sd_dhcp_lease_get_pop3(sd_dhcp_lease *lease, const struct in_addr **addr) { + return sd_dhcp_lease_get_servers(lease, SD_DHCP_LEASE_POP3, addr); } -int sd_dhcp_lease_get_smtp_server(sd_dhcp_lease *lease, const struct in_addr **addr) { - return sd_dhcp_lease_get_servers(lease, SD_DHCP_LEASE_SMTP_SERVERS, addr); +int sd_dhcp_lease_get_smtp(sd_dhcp_lease *lease, const struct in_addr **addr) { + return sd_dhcp_lease_get_servers(lease, SD_DHCP_LEASE_SMTP, addr); } -int sd_dhcp_lease_get_lpr_servers(sd_dhcp_lease *lease, const struct in_addr **addr) { - return sd_dhcp_lease_get_servers(lease, SD_DHCP_LEASE_LPR_SERVERS, addr); +int sd_dhcp_lease_get_lpr(sd_dhcp_lease *lease, const struct in_addr **addr) { + return sd_dhcp_lease_get_servers(lease, SD_DHCP_LEASE_LPR, addr); } int sd_dhcp_lease_get_domainname(sd_dhcp_lease *lease, const char **domainname) { @@ -319,12 +279,10 @@ static sd_dhcp_lease *dhcp_lease_free(sd_dhcp_lease *lease) { free(lease->timezone); free(lease->hostname); free(lease->domainname); - free(lease->dns); - free(lease->ntp); - free(lease->sip); - free(lease->pop3_server); - free(lease->smtp_server); - free(lease->lpr_server); + + for (sd_dhcp_lease_server_type i = 0; i < _SD_DHCP_LEASE_SERVER_TYPE_MAX; i++) + free(lease->servers[i].addr); + free(lease->static_route); free(lease->client_id); free(lease->vendor_specific); @@ -430,7 +388,7 @@ static int lease_parse_domain(const uint8_t *option, size_t len, char **ret) { } static int lease_parse_in_addrs(const uint8_t *option, size_t len, struct in_addr **ret, size_t *n_ret) { - assert(option); + assert(option || len == 0); assert(ret); assert(n_ret); @@ -459,33 +417,24 @@ static int lease_parse_in_addrs(const uint8_t *option, size_t len, struct in_add } static int lease_parse_sip_server(const uint8_t *option, size_t len, struct in_addr **ret, size_t *n_ret) { - assert(option); + assert(option || len == 0); assert(ret); assert(n_ret); - if (len <= 0) { - *ret = mfree(*ret); - *n_ret = 0; - } else { - size_t n_addresses; - struct in_addr *addresses; - int l = len - 1; - - if (l % 4 != 0) - return -EINVAL; + if (len <= 0) + return -EINVAL; - n_addresses = l / 4; + /* The SIP record is like the other, regular server records, but prefixed with a single "encoding" + * byte that is either 0 or 1. We only support it to be 1 for now. Let's drop it and parse it like + * the other fields */ - addresses = newdup(struct in_addr, option + 1, n_addresses); - if (!addresses) - return -ENOMEM; - - free(*ret); - *ret = addresses; - *n_ret = n_addresses; + if (option[0] != 1) { /* We only support IP address encoding for now */ + *ret = mfree(*ret); + *n_ret = 0; + return 0; } - return 0; + return lease_parse_in_addrs(option + 1, len - 1, ret, n_ret); } static int lease_parse_routes( @@ -630,37 +579,37 @@ int dhcp_lease_parse_options(uint8_t code, uint8_t len, const void *option, void break; case SD_DHCP_OPTION_DOMAIN_NAME_SERVER: - r = lease_parse_in_addrs(option, len, &lease->dns, &lease->dns_size); + r = lease_parse_in_addrs(option, len, &lease->servers[SD_DHCP_LEASE_DNS].addr, &lease->servers[SD_DHCP_LEASE_DNS].size); if (r < 0) log_debug_errno(r, "Failed to parse DNS server, ignoring: %m"); break; case SD_DHCP_OPTION_NTP_SERVER: - r = lease_parse_in_addrs(option, len, &lease->ntp, &lease->ntp_size); + r = lease_parse_in_addrs(option, len, &lease->servers[SD_DHCP_LEASE_NTP].addr, &lease->servers[SD_DHCP_LEASE_NTP].size); if (r < 0) log_debug_errno(r, "Failed to parse NTP server, ignoring: %m"); break; case SD_DHCP_OPTION_SIP_SERVER: - r = lease_parse_sip_server(option, len, &lease->sip, &lease->sip_size); + r = lease_parse_sip_server(option, len, &lease->servers[SD_DHCP_LEASE_SIP].addr, &lease->servers[SD_DHCP_LEASE_SIP].size); if (r < 0) log_debug_errno(r, "Failed to parse SIP server, ignoring: %m"); break; case SD_DHCP_OPTION_POP3_SERVER: - r = lease_parse_in_addrs(option, len, &lease->pop3_server, &lease->pop3_server_size); + r = lease_parse_in_addrs(option, len, &lease->servers[SD_DHCP_LEASE_POP3].addr, &lease->servers[SD_DHCP_LEASE_POP3].size); if (r < 0) log_debug_errno(r, "Failed to parse POP3 server, ignoring: %m"); break; case SD_DHCP_OPTION_SMTP_SERVER: - r = lease_parse_in_addrs(option, len, &lease->smtp_server, &lease->smtp_server_size); + r = lease_parse_in_addrs(option, len, &lease->servers[SD_DHCP_LEASE_SMTP].addr, &lease->servers[SD_DHCP_LEASE_SMTP].size); if (r < 0) log_debug_errno(r, "Failed to parse SMTP server, ignoring: %m"); break; case SD_DHCP_OPTION_LPR_SERVER: - r = lease_parse_in_addrs(option, len, &lease->lpr_server, &lease->lpr_server_size); + r = lease_parse_in_addrs(option, len, &lease->servers[SD_DHCP_LEASE_LPR].addr, &lease->servers[SD_DHCP_LEASE_LPR].size); if (r < 0) log_debug_errno(r, "Failed to parse LPR server, ignoring: %m"); break; @@ -1101,9 +1050,9 @@ int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) { *dns = NULL, *ntp = NULL, *sip = NULL, - *pop3_server = NULL, - *smtp_server = NULL, - *lpr_server = NULL, + *pop3 = NULL, + *smtp = NULL, + *lpr = NULL, *mtu = NULL, *routes = NULL, *domains = NULL, @@ -1133,9 +1082,9 @@ int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) { "DNS", &dns, "NTP", &ntp, "SIP", &sip, - "POP3_SERVERS", &pop3_server, - "SMTP_SERVERS", &smtp_server, - "LPR_SERVERS", &lpr_server, + "POP3", &pop3, + "SMTP", &smtp, + "LPR", &lpr, "MTU", &mtu, "DOMAINNAME", &lease->domainname, "HOSTNAME", &lease->hostname, @@ -1225,54 +1174,53 @@ int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) { } if (dns) { - r = deserialize_in_addrs(&lease->dns, dns); + r = deserialize_in_addrs(&lease->servers[SD_DHCP_LEASE_DNS].addr, dns); if (r < 0) log_debug_errno(r, "Failed to deserialize DNS servers %s, ignoring: %m", dns); else - lease->dns_size = r; + lease->servers[SD_DHCP_LEASE_DNS].size = r; } if (ntp) { - r = deserialize_in_addrs(&lease->ntp, ntp); + r = deserialize_in_addrs(&lease->servers[SD_DHCP_LEASE_NTP].addr, ntp); if (r < 0) log_debug_errno(r, "Failed to deserialize NTP servers %s, ignoring: %m", ntp); else - lease->ntp_size = r; + lease->servers[SD_DHCP_LEASE_NTP].size = r; } if (sip) { - r = deserialize_in_addrs(&lease->sip, sip); + r = deserialize_in_addrs(&lease->servers[SD_DHCP_LEASE_SIP].addr, sip); if (r < 0) log_debug_errno(r, "Failed to deserialize SIP servers %s, ignoring: %m", sip); else - lease->sip_size = r; + lease->servers[SD_DHCP_LEASE_SIP].size = r; } - if (pop3_server) { - r = deserialize_in_addrs(&lease->pop3_server, pop3_server); + if (pop3) { + r = deserialize_in_addrs(&lease->servers[SD_DHCP_LEASE_POP3].addr, pop3); if (r < 0) - log_debug_errno(r, "Failed to deserialize POP3 server %s, ignoring: %m", pop3_server); + log_debug_errno(r, "Failed to deserialize POP3 server %s, ignoring: %m", pop3); else - lease->pop3_server_size = r; + lease->servers[SD_DHCP_LEASE_POP3].size = r; } - if (smtp_server) { - r = deserialize_in_addrs(&lease->smtp_server, smtp_server); + if (smtp) { + r = deserialize_in_addrs(&lease->servers[SD_DHCP_LEASE_SMTP].addr, smtp); if (r < 0) - log_debug_errno(r, "Failed to deserialize SMTP server %s, ignoring: %m", smtp_server); + log_debug_errno(r, "Failed to deserialize SMTP server %s, ignoring: %m", smtp); else - lease->smtp_server_size = r; + lease->servers[SD_DHCP_LEASE_SMTP].size = r; } - if (lpr_server) { - r = deserialize_in_addrs(&lease->lpr_server, lpr_server); + if (lpr) { + r = deserialize_in_addrs(&lease->servers[SD_DHCP_LEASE_LPR].addr, lpr); if (r < 0) - log_debug_errno(r, "Failed to deserialize LPR server %s, ignoring: %m", lpr_server); + log_debug_errno(r, "Failed to deserialize LPR server %s, ignoring: %m", lpr); else - lease->lpr_server_size = r; + lease->servers[SD_DHCP_LEASE_LPR].size = r; } - if (mtu) { r = safe_atou16(mtu, &lease->mtu); if (r < 0) diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c index 9db583a7a8..dce68aeb26 100644 --- a/src/libsystemd-network/sd-dhcp-server.c +++ b/src/libsystemd-network/sd-dhcp-server.c @@ -3,6 +3,7 @@ Copyright © 2013 Intel Corporation. All rights reserved. ***/ +#include <net/if_arp.h> #include <sys/ioctl.h> #include "sd-dhcp-server.h" @@ -143,12 +144,9 @@ static sd_dhcp_server *dhcp_server_free(sd_dhcp_server *server) { sd_event_unref(server->event); free(server->timezone); - free(server->dns); - free(server->ntp); - free(server->sip); - free(server->pop3_server); - free(server->smtp_server); - free(server->lpr_server); + + for (sd_dhcp_lease_server_type i = 0; i < _SD_DHCP_LEASE_SERVER_TYPE_MAX; i++) + free(server->servers[i].addr); hashmap_free(server->leases_by_client_id); @@ -461,8 +459,20 @@ static int server_send_offer(sd_dhcp_server *server, DHCPRequest *req, return 0; } -static int server_send_ack(sd_dhcp_server *server, DHCPRequest *req, - be32_t address) { +static int server_send_ack( + sd_dhcp_server *server, + DHCPRequest *req, + be32_t address) { + + static const uint8_t option_map[_SD_DHCP_LEASE_SERVER_TYPE_MAX] = { + [SD_DHCP_LEASE_DNS] = SD_DHCP_OPTION_DOMAIN_NAME_SERVER, + [SD_DHCP_LEASE_NTP] = SD_DHCP_OPTION_NTP_SERVER, + [SD_DHCP_LEASE_SIP] = SD_DHCP_OPTION_SIP_SERVER, + [SD_DHCP_LEASE_POP3] = SD_DHCP_OPTION_POP3_SERVER, + [SD_DHCP_LEASE_SMTP] = SD_DHCP_OPTION_SMTP_SERVER, + [SD_DHCP_LEASE_LPR] = SD_DHCP_OPTION_LPR_SERVER, + }; + _cleanup_free_ DHCPPacket *packet = NULL; be32_t lease_time; sd_dhcp_option *j; @@ -495,59 +505,19 @@ static int server_send_ack(sd_dhcp_server *server, DHCPRequest *req, return r; } - if (server->n_dns > 0) { - r = dhcp_option_append( - &packet->dhcp, req->max_optlen, &offset, 0, - SD_DHCP_OPTION_DOMAIN_NAME_SERVER, - sizeof(struct in_addr) * server->n_dns, server->dns); - if (r < 0) - return r; - } - - if (server->n_ntp > 0) { - r = dhcp_option_append( - &packet->dhcp, req->max_optlen, &offset, 0, - SD_DHCP_OPTION_NTP_SERVER, - sizeof(struct in_addr) * server->n_ntp, server->ntp); - if (r < 0) - return r; - } - - if (server->n_sip > 0) { - r = dhcp_option_append( - &packet->dhcp, req->max_optlen, &offset, 0, - SD_DHCP_OPTION_SIP_SERVER, - sizeof(struct in_addr) * server->n_sip, server->sip); - if (r < 0) - return r; - } + for (sd_dhcp_lease_server_type k = 0; k < _SD_DHCP_LEASE_SERVER_TYPE_MAX; k++) { - if (server->n_pop3_server > 0) { - r = dhcp_option_append( - &packet->dhcp, req->max_optlen, &offset, 0, - SD_DHCP_OPTION_POP3_SERVER, - sizeof(struct in_addr) * server->n_pop3_server, server->pop3_server); - if (r < 0) - return r; - } + if (server->servers[k].size <= 0) + continue; - if (server->n_smtp_server > 0) { r = dhcp_option_append( &packet->dhcp, req->max_optlen, &offset, 0, - SD_DHCP_OPTION_SMTP_SERVER, - sizeof(struct in_addr) * server->n_smtp_server, server->smtp_server); + option_map[k], + sizeof(struct in_addr) * server->servers[k].size, server->servers[k].addr); if (r < 0) return r; } - if (server->n_lpr_server > 0) { - r = dhcp_option_append( - &packet->dhcp, req->max_optlen, &offset, 0, - SD_DHCP_OPTION_LPR_SERVER, - sizeof(struct in_addr) * server->n_lpr_server, server->lpr_server); - if (r < 0) - return r; - } if (server->timezone) { r = dhcp_option_append( @@ -1139,87 +1109,50 @@ int sd_dhcp_server_set_default_lease_time(sd_dhcp_server *server, uint32_t t) { int sd_dhcp_server_set_servers( sd_dhcp_server *server, - sd_dhcp_lease_info what, + sd_dhcp_lease_server_type what, const struct in_addr addresses[], size_t n_addresses) { + struct in_addr *c = NULL; + assert_return(server, -EINVAL); assert_return(addresses || n_addresses == 0, -EINVAL); + assert_return(what >= 0, -EINVAL); + assert_return(what < _SD_DHCP_LEASE_SERVER_TYPE_MAX, -EINVAL); - struct in_addr **a; - size_t *n_a; - - switch (what) { - case SD_DHCP_LEASE_DNS_SERVERS: - a = &server->dns; - n_a = &server->n_dns; - break; - - case SD_DHCP_LEASE_NTP_SERVERS: - a = &server->ntp; - n_a = &server->n_ntp; - break; - - case SD_DHCP_LEASE_SIP_SERVERS: - a = &server->sip; - n_a = &server->n_sip; - break; - - case SD_DHCP_LEASE_POP3_SERVERS: - a = &server->pop3_server; - n_a = &server->n_pop3_server; - break; - - case SD_DHCP_LEASE_SMTP_SERVERS: - a = &server->smtp_server; - n_a = &server->n_smtp_server; - break; - - case SD_DHCP_LEASE_LPR_SERVERS: - a = &server->lpr_server; - n_a = &server->n_lpr_server; - break; - - default: - return log_debug_errno(SYNTHETIC_ERRNO(ENXIO), - "Unknown DHCP lease info item %d.", what); - } - - if (*n_a == n_addresses && - memcmp(*a, addresses, sizeof(struct in_addr) * n_addresses) == 0) + if (server->servers[what].size == n_addresses && + memcmp(server->servers[what].addr, addresses, sizeof(struct in_addr) * n_addresses) == 0) return 0; - struct in_addr *c = NULL; - if (n_addresses > 0) { c = newdup(struct in_addr, addresses, n_addresses); if (!c) return -ENOMEM; } - free(*a); - *a = c; - *n_a = n_addresses; + free(server->servers[what].addr); + server->servers[what].addr = c; + server->servers[what].size = n_addresses; return 1; } int sd_dhcp_server_set_dns(sd_dhcp_server *server, const struct in_addr dns[], size_t n) { - return sd_dhcp_server_set_servers(server, SD_DHCP_LEASE_DNS_SERVERS, dns, n); + return sd_dhcp_server_set_servers(server, SD_DHCP_LEASE_DNS, dns, n); } int sd_dhcp_server_set_ntp(sd_dhcp_server *server, const struct in_addr ntp[], size_t n) { - return sd_dhcp_server_set_servers(server, SD_DHCP_LEASE_NTP_SERVERS, ntp, n); + return sd_dhcp_server_set_servers(server, SD_DHCP_LEASE_NTP, ntp, n); } int sd_dhcp_server_set_sip(sd_dhcp_server *server, const struct in_addr sip[], size_t n) { - return sd_dhcp_server_set_servers(server, SD_DHCP_LEASE_SIP_SERVERS, sip, n); + return sd_dhcp_server_set_servers(server, SD_DHCP_LEASE_SIP, sip, n); } int sd_dhcp_server_set_pop3(sd_dhcp_server *server, const struct in_addr pop3[], size_t n) { - return sd_dhcp_server_set_servers(server, SD_DHCP_LEASE_POP3_SERVERS, pop3, n); + return sd_dhcp_server_set_servers(server, SD_DHCP_LEASE_POP3, pop3, n); } int sd_dhcp_server_set_smtp(sd_dhcp_server *server, const struct in_addr smtp[], size_t n) { - return sd_dhcp_server_set_servers(server, SD_DHCP_LEASE_SMTP_SERVERS, smtp, n); + return sd_dhcp_server_set_servers(server, SD_DHCP_LEASE_SMTP, smtp, n); } int sd_dhcp_server_set_lpr(sd_dhcp_server *server, const struct in_addr lpr[], size_t n) { - return sd_dhcp_server_set_servers(server, SD_DHCP_LEASE_LPR_SERVERS, lpr, n); + return sd_dhcp_server_set_servers(server, SD_DHCP_LEASE_LPR, lpr, n); } int sd_dhcp_server_set_emit_router(sd_dhcp_server *server, int enabled) { diff --git a/src/libsystemd-network/test-dhcp-client.c b/src/libsystemd-network/test-dhcp-client.c index 4e9b388a45..80a8566194 100644 --- a/src/libsystemd-network/test-dhcp-client.c +++ b/src/libsystemd-network/test-dhcp-client.c @@ -4,10 +4,11 @@ ***/ #include <errno.h> +#include <net/if.h> +#include <net/if_arp.h> #include <stdio.h> #include <sys/socket.h> #include <unistd.h> -#include <net/if.h> #include "sd-dhcp-client.h" #include "sd-event.h" diff --git a/src/libsystemd-network/test-dhcp-option.c b/src/libsystemd-network/test-dhcp-option.c index 56bd690cb0..086f8b5fd9 100644 --- a/src/libsystemd-network/test-dhcp-option.c +++ b/src/libsystemd-network/test-dhcp-option.c @@ -1,4 +1,7 @@ +/* SPDX-License-Identifier: LGPL-2.1+ */ + #include <errno.h> +#include <net/if_arp.h> #include <stdbool.h> #include <stdio.h> #include <string.h> diff --git a/src/libsystemd-network/test-dhcp-server.c b/src/libsystemd-network/test-dhcp-server.c index ea998939bc..a45d98f669 100644 --- a/src/libsystemd-network/test-dhcp-server.c +++ b/src/libsystemd-network/test-dhcp-server.c @@ -4,6 +4,7 @@ ***/ #include <errno.h> +#include <net/if_arp.h> #include "sd-dhcp-server.h" #include "sd-event.h" |