Systemd/src/systemd/sd-dhcp-client.h
Tom Gundersen b25ef18b33 sd-dhcp-client: refactor client_{free,new}
Make them more simiar to sd_bus and friends. Also factor out the event attachment. In the future,
we will likely want to support external main-loops, so this is a first step. For the time being,
we are still requiring an sd_event to be attached though.
2014-01-18 19:32:45 +01:00

72 lines
2.9 KiB
C

/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
#ifndef foosddhcpclienthfoo
#define foosddhcpclienthfoo
/***
This file is part of systemd.
Copyright (C) 2013 Intel Corporation. All rights reserved.
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <netinet/in.h>
#include <net/ethernet.h>
#include "sd-event.h"
enum {
DHCP_EVENT_STOP = 0,
DHCP_EVENT_NO_LEASE = 1,
DHCP_EVENT_IP_ACQUIRE = 2,
DHCP_EVENT_IP_CHANGE = 3,
DHCP_EVENT_EXPIRED = 4,
};
typedef struct sd_dhcp_client sd_dhcp_client;
typedef void (*sd_dhcp_client_cb_t)(sd_dhcp_client *client, int event,
void *userdata);
int sd_dhcp_client_set_callback(sd_dhcp_client *client, sd_dhcp_client_cb_t cb,
void *userdata);
int sd_dhcp_client_set_request_option(sd_dhcp_client *client, uint8_t option);
int sd_dhcp_client_set_request_address(sd_dhcp_client *client,
const struct in_addr *last_address);
int sd_dhcp_client_set_index(sd_dhcp_client *client, int interface_index);
int sd_dhcp_client_set_mac(sd_dhcp_client *client,
const struct ether_addr *addr);
int sd_dhcp_client_get_address(sd_dhcp_client *client, struct in_addr *addr);
int sd_dhcp_client_get_netmask(sd_dhcp_client *client, struct in_addr *addr);
int sd_dhcp_client_prefixlen(const struct in_addr *addr);
int sd_dhcp_client_get_router(sd_dhcp_client *client, struct in_addr *addr);
int sd_dhcp_client_get_dns(sd_dhcp_client *client, struct in_addr **addr, size_t *addr_size);
int sd_dhcp_client_get_mtu(sd_dhcp_client *client, uint16_t *mtu);
int sd_dhcp_client_get_domainname(sd_dhcp_client *client, const char **domainname);
int sd_dhcp_client_get_hostname(sd_dhcp_client *client, const char **hostname);
int sd_dhcp_client_stop(sd_dhcp_client *client);
int sd_dhcp_client_start(sd_dhcp_client *client);
void sd_dhcp_client_free(sd_dhcp_client *client);
int sd_dhcp_client_new(sd_dhcp_client **ret);
int sd_dhcp_client_attach_event(sd_dhcp_client *client, sd_event *event, int priority);
int sd_dhcp_client_detach_event(sd_dhcp_client *client);
sd_event *sd_dhcp_client_get_event(sd_dhcp_client *client);
#endif