sd-dhcp-server.c revision bd57b45029ff25067704c9538e79f31e71c10045
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering This file is part of systemd.
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering Copyright (C) 2013 Intel Corporation. All rights reserved.
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering Copyright (C) 2014 Tom Gundersen
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering systemd is free software; you can redistribute it and/or modify it
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering under the terms of the GNU Lesser General Public License as published by
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering (at your option) any later version.
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering systemd is distributed in the hope that it will be useful, but
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering Lesser General Public License for more details.
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering You should have received a copy of the GNU Lesser General Public License
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poetteringint sd_dhcp_server_set_lease_pool(sd_dhcp_server *server, struct in_addr *address,
ae97089d49d1795a35a443b7b830ee666028e733Zbigniew Jędrzejewski-Szmek assert_return(address, -EINVAL);
ae97089d49d1795a35a443b7b830ee666028e733Zbigniew Jędrzejewski-Szmek assert_return(address->s_addr, -EINVAL);
ae97089d49d1795a35a443b7b830ee666028e733Zbigniew Jędrzejewski-Szmek assert_return(server->pool_start == htobe32(INADDR_ANY), -EBUSY);
ae97089d49d1795a35a443b7b830ee666028e733Zbigniew Jędrzejewski-Szmek assert_return(!server->pool_size, -EBUSY);
ae97089d49d1795a35a443b7b830ee666028e733Zbigniew Jędrzejewski-Szmek server->pool_start = address->s_addr;
ae97089d49d1795a35a443b7b830ee666028e733Zbigniew Jędrzejewski-Szmekint sd_dhcp_server_set_address(sd_dhcp_server *server, struct in_addr *address) {
ae97089d49d1795a35a443b7b830ee666028e733Zbigniew Jędrzejewski-Szmek assert_return(address, -EINVAL);
ae97089d49d1795a35a443b7b830ee666028e733Zbigniew Jędrzejewski-Szmek assert_return(address->s_addr, -EINVAL);
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering assert_return(server->address == htobe32(INADDR_ANY), -EBUSY);
if (server)
return server;
return NULL;
if (!server)
return -ENOMEM;
if (event)
return -errno;
if (!packet)
return -ENOMEM;
void *user_data) {
switch(code) {
if (!data)
return -ENOMEM;
- sizeof(DHCPPacket);
if (!req)
if (!data)
return -ENOMEM;
int type, r;
if (!req)
return -ENOMEM;
if (type < 0)
switch(type) {
case DHCP_DISCOVER:
strerror(-r));
return DHCP_OFFER;
case DHCP_REQUEST:
bool init_reboot = false;
init_reboot = true;
strerror(-r));
return DHCP_ACK;
} else if (init_reboot) {
strerror(-r));
return DHCP_NAK;
if (buflen < 0)
return -EIO;
if (!message)
return -ENOMEM;
r = -errno;