forked from sargon/ddhcpd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dhcp.h
91 lines (76 loc) · 2.57 KB
/
dhcp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifndef _DHCP_H
#define _DHCP_H
/**
* DHCP Structures
*/
#include "types.h"
#include "dhcp_packet.h"
/**
* DHCP Process Packet
*/
ATTR_NONNULL_ALL int dhcp_process(uint8_t* buffer, ssize_t len, ddhcp_config* config);
/**
* DHCP Discover
* Performs a search for a available, not already offered address in the
* available block. When the block has no further available addresses 0 is returned,
* otherwise the then reserved address. Will set a lease_timout on the lease.
*
* In a second step a dhcp_packet is created an send back.
*/
ATTR_NONNULL_ALL int dhcp_hdl_discover(int socket, dhcp_packet* discover, ddhcp_config* config);
/**
* DHCP Request
* Performs on base of de
*/
ATTR_NONNULL_ALL int dhcp_hdl_request(int socket, struct dhcp_packet* request, ddhcp_config* config);
/**
* DDHCP Remote Request (Renew)
*/
ATTR_NONNULL_ALL int dhcp_rhdl_request(uint32_t* address, ddhcp_config* config);
/**
* DDHCP Remote Answer (Ack)
*/
ATTR_NONNULL_ALL int dhcp_rhdl_ack(int socket, struct dhcp_packet* request, ddhcp_config* config);
/**
* DHCP Release
*/
ATTR_NONNULL_ALL void dhcp_hdl_release(dhcp_packet* packet, ddhcp_config* config);
/**
* DHCP Inform
*/
ATTR_NONNULL_ALL void dhcp_hdl_inform(int socket, dhcp_packet* packet, ddhcp_config* config);
ATTR_NONNULL_ALL int dhcp_nack(int socket, dhcp_packet* from_client, ddhcp_config* config);
ATTR_NONNULL_ALL int dhcp_ack(int socket, dhcp_packet* request, ddhcp_block* lease_block, uint32_t lease_index, ddhcp_config* config);
/**
* DHCP Lease Available
* Determan iff there is a free lease in block.
*/
ATTR_NONNULL_ALL int dhcp_has_free(struct ddhcp_block* block);
/**
* DHCP num Leases Available
* Enumerate the free leases in a block
*/
ATTR_NONNULL_ALL uint32_t dhcp_num_free(struct ddhcp_block* block);
/**
* Number of leases offered to clients.
*/
ATTR_NONNULL_ALL uint32_t dhcp_num_offered(struct ddhcp_block* block);
/**
* Find first free lease in lease block and return its index.
* This function asserts that there is a free lease, otherwise
* it returns the value of block_subnet_len.
*/
ATTR_NONNULL_ALL uint32_t dhcp_get_free_lease(ddhcp_block* block);
/**
* Find lease for given address and mark it as free.
* When no address is found no return value is given,
* since there is no reply to a dhcp release packet
* no further internal handling is needed.
*/
ATTR_NONNULL_ALL void dhcp_release_lease(uint32_t address, ddhcp_config* config);
/**
* HouseKeeping: Check for timed out leases.
* Return the number of free leases in the block.
*/
ATTR_NONNULL_ALL int dhcp_check_timeouts(ddhcp_block* block);
#endif