1 /* SPDX-License-Identifier: LGPL-2.1-or-later */ 2 #pragma once 3 4 /*** 5 Copyright © 2013 Intel Corporation. All rights reserved. 6 ***/ 7 8 #include "sd-dhcp-client.h" 9 10 #include "dhcp-internal.h" 11 #include "dhcp-protocol.h" 12 #include "list.h" 13 #include "util.h" 14 15 struct sd_dhcp_route { 16 struct in_addr dst_addr; 17 struct in_addr gw_addr; 18 unsigned char dst_prefixlen; 19 }; 20 21 struct sd_dhcp_raw_option { 22 LIST_FIELDS(struct sd_dhcp_raw_option, options); 23 24 uint8_t tag; 25 uint8_t length; 26 void *data; 27 }; 28 29 struct sd_dhcp_lease { 30 unsigned n_ref; 31 32 /* each 0 if unset */ 33 uint32_t t1; 34 uint32_t t2; 35 uint32_t lifetime; 36 37 /* each 0 if unset */ 38 be32_t address; 39 be32_t server_address; 40 be32_t next_server; 41 42 bool have_subnet_mask; 43 be32_t subnet_mask; 44 45 bool have_broadcast; 46 be32_t broadcast; 47 48 struct in_addr *router; 49 size_t router_size; 50 51 DHCPServerData servers[_SD_DHCP_LEASE_SERVER_TYPE_MAX]; 52 53 struct sd_dhcp_route *static_routes; 54 size_t n_static_routes; 55 struct sd_dhcp_route *classless_routes; 56 size_t n_classless_routes; 57 58 uint16_t mtu; /* 0 if unset */ 59 60 char *domainname; 61 char **search_domains; 62 char *hostname; 63 char *root_path; 64 65 void *client_id; 66 size_t client_id_len; 67 68 void *vendor_specific; 69 size_t vendor_specific_len; 70 71 char *timezone; 72 73 uint8_t sixrd_ipv4masklen; 74 uint8_t sixrd_prefixlen; 75 struct in6_addr sixrd_prefix; 76 struct in_addr *sixrd_br_addresses; 77 size_t sixrd_n_br_addresses; 78 79 LIST_HEAD(struct sd_dhcp_raw_option, private_options); 80 }; 81 82 int dhcp_lease_new(sd_dhcp_lease **ret); 83 84 int dhcp_lease_parse_options(uint8_t code, uint8_t len, const void *option, void *userdata); 85 int dhcp_lease_parse_search_domains(const uint8_t *option, size_t len, char ***domains); 86 int dhcp_lease_insert_private_option(sd_dhcp_lease *lease, uint8_t tag, const void *data, uint8_t len); 87 88 int dhcp_lease_set_default_subnet_mask(sd_dhcp_lease *lease); 89 90 int dhcp_lease_set_client_id(sd_dhcp_lease *lease, const void *client_id, size_t client_id_len); 91