]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/systemd/sd-dhcp-client.h
Merge pull request #2240 from hgwalles/coredump-delete-bug
[thirdparty/systemd.git] / src / systemd / sd-dhcp-client.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #ifndef foosddhcpclienthfoo
4 #define foosddhcpclienthfoo
5
6 /***
7 This file is part of systemd.
8
9 Copyright (C) 2013 Intel Corporation. All rights reserved.
10
11 systemd is free software; you can redistribute it and/or modify it
12 under the terms of the GNU Lesser General Public License as published by
13 the Free Software Foundation; either version 2.1 of the License, or
14 (at your option) any later version.
15
16 systemd is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Lesser General Public License for more details.
20
21 You should have received a copy of the GNU Lesser General Public License
22 along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 ***/
24
25 #include <inttypes.h>
26 #include <net/ethernet.h>
27 #include <netinet/in.h>
28 #include <sys/types.h>
29
30 #include "sd-dhcp-lease.h"
31 #include "sd-event.h"
32
33 #include "_sd-common.h"
34
35 _SD_BEGIN_DECLARATIONS;
36
37 enum {
38 SD_DHCP_CLIENT_EVENT_STOP = 0,
39 SD_DHCP_CLIENT_EVENT_IP_ACQUIRE = 1,
40 SD_DHCP_CLIENT_EVENT_IP_CHANGE = 2,
41 SD_DHCP_CLIENT_EVENT_EXPIRED = 3,
42 SD_DHCP_CLIENT_EVENT_RENEW = 4,
43 };
44
45 enum {
46 SD_DHCP_OPTION_PAD = 0,
47 SD_DHCP_OPTION_SUBNET_MASK = 1,
48 SD_DHCP_OPTION_TIME_OFFSET = 2,
49 SD_DHCP_OPTION_ROUTER = 3,
50 SD_DHCP_OPTION_DOMAIN_NAME_SERVER = 6,
51 SD_DHCP_OPTION_HOST_NAME = 12,
52 SD_DHCP_OPTION_BOOT_FILE_SIZE = 13,
53 SD_DHCP_OPTION_DOMAIN_NAME = 15,
54 SD_DHCP_OPTION_ROOT_PATH = 17,
55 SD_DHCP_OPTION_ENABLE_IP_FORWARDING = 19,
56 SD_DHCP_OPTION_ENABLE_IP_FORWARDING_NL = 20,
57 SD_DHCP_OPTION_POLICY_FILTER = 21,
58 SD_DHCP_OPTION_INTERFACE_MDR = 22,
59 SD_DHCP_OPTION_INTERFACE_TTL = 23,
60 SD_DHCP_OPTION_INTERFACE_MTU_AGING_TIMEOUT = 24,
61 SD_DHCP_OPTION_INTERFACE_MTU = 26,
62 SD_DHCP_OPTION_BROADCAST = 28,
63 SD_DHCP_OPTION_STATIC_ROUTE = 33,
64 SD_DHCP_OPTION_NTP_SERVER = 42,
65 SD_DHCP_OPTION_VENDOR_SPECIFIC = 43,
66 SD_DHCP_OPTION_REQUESTED_IP_ADDRESS = 50,
67 SD_DHCP_OPTION_IP_ADDRESS_LEASE_TIME = 51,
68 SD_DHCP_OPTION_OVERLOAD = 52,
69 SD_DHCP_OPTION_MESSAGE_TYPE = 53,
70 SD_DHCP_OPTION_SERVER_IDENTIFIER = 54,
71 SD_DHCP_OPTION_PARAMETER_REQUEST_LIST = 55,
72 SD_DHCP_OPTION_ERROR_MESSAGE = 56,
73 SD_DHCP_OPTION_MAXIMUM_MESSAGE_SIZE = 57,
74 SD_DHCP_OPTION_RENEWAL_T1_TIME = 58,
75 SD_DHCP_OPTION_REBINDING_T2_TIME = 59,
76 SD_DHCP_OPTION_VENDOR_CLASS_IDENTIFIER = 60,
77 SD_DHCP_OPTION_CLIENT_IDENTIFIER = 61,
78 SD_DHCP_OPTION_FQDN = 81,
79 SD_DHCP_OPTION_NEW_POSIX_TIMEZONE = 100,
80 SD_DHCP_OPTION_NEW_TZDB_TIMEZONE = 101,
81 SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE = 121,
82 SD_DHCP_OPTION_PRIVATE_BASE = 224,
83 SD_DHCP_OPTION_PRIVATE_LAST = 254,
84 SD_DHCP_OPTION_END = 255,
85 };
86
87 typedef struct sd_dhcp_client sd_dhcp_client;
88
89 typedef void (*sd_dhcp_client_cb_t)(sd_dhcp_client *client, int event,
90 void *userdata);
91 int sd_dhcp_client_set_callback(sd_dhcp_client *client, sd_dhcp_client_cb_t cb,
92 void *userdata);
93
94 int sd_dhcp_client_set_request_option(sd_dhcp_client *client, uint8_t option);
95 int sd_dhcp_client_set_request_address(sd_dhcp_client *client,
96 const struct in_addr *last_address);
97 int sd_dhcp_client_set_request_broadcast(sd_dhcp_client *client, int broadcast);
98 int sd_dhcp_client_set_index(sd_dhcp_client *client, int interface_index);
99 int sd_dhcp_client_set_mac(sd_dhcp_client *client, const uint8_t *addr,
100 size_t addr_len, uint16_t arp_type);
101 int sd_dhcp_client_set_client_id(sd_dhcp_client *client, uint8_t type,
102 const uint8_t *data, size_t data_len);
103 int sd_dhcp_client_get_client_id(sd_dhcp_client *client, uint8_t *type,
104 const uint8_t **data, size_t *data_len);
105 int sd_dhcp_client_set_mtu(sd_dhcp_client *client, uint32_t mtu);
106 int sd_dhcp_client_set_hostname(sd_dhcp_client *client, const char *hostname);
107 int sd_dhcp_client_set_vendor_class_identifier(sd_dhcp_client *client, const char *vci);
108 int sd_dhcp_client_get_lease(sd_dhcp_client *client, sd_dhcp_lease **ret);
109
110 int sd_dhcp_client_stop(sd_dhcp_client *client);
111 int sd_dhcp_client_start(sd_dhcp_client *client);
112
113 sd_dhcp_client *sd_dhcp_client_ref(sd_dhcp_client *client);
114 sd_dhcp_client *sd_dhcp_client_unref(sd_dhcp_client *client);
115
116 int sd_dhcp_client_new(sd_dhcp_client **ret);
117
118 int sd_dhcp_client_attach_event(sd_dhcp_client *client, sd_event *event, int priority);
119 int sd_dhcp_client_detach_event(sd_dhcp_client *client);
120 sd_event *sd_dhcp_client_get_event(sd_dhcp_client *client);
121
122 _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_dhcp_client, sd_dhcp_client_unref);
123
124 _SD_END_DECLARATIONS;
125
126 #endif