]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
0ef6f454 LP |
2 | #pragma once |
3 | ||
b44cd882 | 4 | /*** |
810adae9 | 5 | Copyright © 2013 Intel Corporation. All rights reserved. |
b44cd882 TG |
6 | ***/ |
7 | ||
b44cd882 | 8 | #include "sd-dhcp-server.h" |
71d35b6b | 9 | #include "sd-event.h" |
b44cd882 | 10 | |
71d35b6b | 11 | #include "dhcp-internal.h" |
87322b3a | 12 | #include "hashmap.h" |
b44cd882 | 13 | #include "log.h" |
ca78ad1d | 14 | #include "time-util.h" |
be077570 | 15 | |
87322b3a TG |
16 | typedef struct DHCPClientId { |
17 | size_t length; | |
9a0f246f | 18 | void *data; |
87322b3a TG |
19 | } DHCPClientId; |
20 | ||
21 | typedef struct DHCPLease { | |
22 | DHCPClientId client_id; | |
23 | ||
24 | be32_t address; | |
52750344 TG |
25 | be32_t gateway; |
26 | uint8_t chaddr[16]; | |
87322b3a TG |
27 | usec_t expiration; |
28 | } DHCPLease; | |
29 | ||
b44cd882 | 30 | struct sd_dhcp_server { |
3733eec3 | 31 | unsigned n_ref; |
b44cd882 TG |
32 | |
33 | sd_event *event; | |
34 | int event_priority; | |
ff734080 TG |
35 | sd_event_source *receive_message; |
36 | int fd; | |
8de4a226 | 37 | int fd_raw; |
3a864fe4 | 38 | |
b3ec603c | 39 | int ifindex; |
20af7091 | 40 | be32_t address; |
59b8f6b6 | 41 | be32_t netmask; |
99634696 TG |
42 | be32_t subnet; |
43 | uint32_t pool_offset; | |
44 | uint32_t pool_size; | |
b44cd882 | 45 | |
8eb9058d LP |
46 | char *timezone; |
47 | ||
1a04db0f LP |
48 | struct in_addr *ntp, *dns; |
49 | unsigned n_ntp, n_dns; | |
50 | ||
77ff6022 CG |
51 | bool emit_router; |
52 | ||
87322b3a TG |
53 | Hashmap *leases_by_client_id; |
54 | DHCPLease **bound_leases; | |
99634696 | 55 | DHCPLease invalid_lease; |
586ac6f7 LP |
56 | |
57 | uint32_t max_lease_time, default_lease_time; | |
87322b3a | 58 | }; |
816e2e7a TG |
59 | |
60 | typedef struct DHCPRequest { | |
61 | /* received message */ | |
62 | DHCPMessage *message; | |
63 | ||
64 | /* options */ | |
65 | DHCPClientId client_id; | |
66 | size_t max_optlen; | |
67 | be32_t server_id; | |
2dead812 | 68 | be32_t requested_ip; |
586ac6f7 | 69 | uint32_t lifetime; |
816e2e7a TG |
70 | } DHCPRequest; |
71 | ||
79008bdd | 72 | #define log_dhcp_server(client, fmt, ...) log_internal(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "DHCP SERVER: " fmt, ##__VA_ARGS__) |
6e741541 | 73 | #define log_dhcp_server_errno(client, error, fmt, ...) log_internal(LOG_DEBUG, error, __FILE__, __LINE__, __func__, "DHCP SERVER: " fmt, ##__VA_ARGS__) |
be077570 TG |
74 | |
75 | int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message, | |
76 | size_t length); | |
969b009d TG |
77 | int dhcp_server_send_packet(sd_dhcp_server *server, |
78 | DHCPRequest *req, DHCPPacket *packet, | |
79 | int type, size_t optoffset); | |
87322b3a | 80 | |
7a08d314 YW |
81 | void client_id_hash_func(const DHCPClientId *p, struct siphash *state); |
82 | int client_id_compare_func(const DHCPClientId *a, const DHCPClientId *b); |