diff options
author | Tom Gundersen <teg@jklm.no> | 2014-05-25 00:29:13 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-06-13 17:07:19 +0200 |
commit | 20af7091de0cdf92bf299addfc3f96c3ef805bd8 (patch) | |
tree | ec3d865eee312619cd8a3f00336474489cd966d9 /src/libsystemd-network/sd-dhcp-server.c | |
parent | 8de4a226c71ef43e652274b33b5d19211a44ac7b (diff) |
sd-dhcp-server: add support for setting the server address
Diffstat (limited to 'src/libsystemd-network/sd-dhcp-server.c')
-rw-r--r-- | src/libsystemd-network/sd-dhcp-server.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c index ecdc15dff7..37f81588c3 100644 --- a/src/libsystemd-network/sd-dhcp-server.c +++ b/src/libsystemd-network/sd-dhcp-server.c @@ -27,6 +27,17 @@ #include "dhcp-server-internal.h" #include "dhcp-internal.h" +int sd_dhcp_server_set_address(sd_dhcp_server *server, struct in_addr *address) { + assert_return(server, -EINVAL); + assert_return(address, -EINVAL); + assert_return(address->s_addr, -EINVAL); + assert_return(server->address == htobe32(INADDR_ANY), -EBUSY); + + server->address = address->s_addr; + + return 0; +} + sd_dhcp_server *sd_dhcp_server_ref(sd_dhcp_server *server) { if (server) assert_se(REFCNT_INC(server->n_ref) >= 2); @@ -60,6 +71,7 @@ int sd_dhcp_server_new(sd_dhcp_server **ret, int ifindex) { server->n_ref = REFCNT_INIT; server->fd_raw = -1; server->fd = -1; + server->address = htobe32(INADDR_ANY); server->index = ifindex; *ret = server; @@ -281,6 +293,7 @@ int sd_dhcp_server_start(sd_dhcp_server *server) { assert_return(!server->receive_message, -EBUSY); assert_return(server->fd_raw == -1, -EBUSY); assert_return(server->fd == -1, -EBUSY); + assert_return(server->address != htobe32(INADDR_ANY), -EUNATCH); r = socket(AF_PACKET, SOCK_DGRAM | SOCK_NONBLOCK, 0); if (r < 0) { |