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