-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathoptions.h
170 lines (140 loc) · 4.27 KB
/
options.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#ifndef OPTIONS_H
#define OPTIONS_H
#include <stdint.h>
#include <time.h>
#include "queue.h"
/*
* Code ID of DHCP and BOOTP options
* as defined in RFC 2132
*/
enum dhcp_msg_type {
DHCP_DISCOVER = 1,
DHCP_OFFER = 2,
DHCP_REQUEST = 3,
DHCP_DECLINE = 4,
DHCP_ACK = 5,
DHCP_NAK = 6,
DHCP_RELEASE = 7,
DHCP_INFORM = 8,
};
enum {
/* RFC 1497 Vendor Extensions */
PAD = 0,
END = 255,
SUBNET_MASK = 1,
TIME_OFFSET = 2,
ROUTER = 3,
TIME_SERVER = 4,
NAME_SERVER = 5,
DOMAIN_NAME_SERVER = 6,
LOG_SERVER = 7,
COOKIE_SERVER = 8,
LPR_SERVER = 9,
IMPRESS_SERVER = 10,
RESOURCE_LOCATION_SERVER = 11,
HOST_NAME = 12,
BOOT_FILE_SIZE = 13,
MERIT_DUMP_FILE = 14,
DOMAIN_NAME = 15,
SWAP_SERVER = 16,
ROOT_PATH = 17,
EXTENSIONS_PATH = 18,
/* IP Layer Parameters per Host */
IP_FORWARDING = 19,
NON_LOCAL_SOURCE_ROUTING = 20,
POLICY_FILTER = 21,
MAXIMUM_DATAGRAM_REASSEMBLY_SIZE = 22,
DEFAULT_IP_TIME_TO_LIVE = 23,
PATH_MTU_AGING_TIMEOUT = 24,
PATH_MTU_PLATEAU_TABLE = 25,
/* IP Layer Parameters per Interface */
INTERFACE_MTU = 26,
ALL_SUBNETS_ARE_LOCAL = 27,
BROADCAST_ADDRESS = 28,
PERFORM_MASK_DISCOVERY = 29,
MASK_SUPPLIER = 30,
PERFORM_ROUTER_DISCOVERY = 31,
ROUTER_SOLICITATION_ADDRESS = 32,
STATIC_ROUTE = 33,
/* Link Layer Parameters per Interface */
TRAILER_ENCAPSULATION = 34,
ARP_CACHE_TIMEOUT = 35,
ETHERNET_ENCAPSULATION = 36,
/* TCP Parameters */
TCP_DEFAULT_TTL = 37,
TCP_KEEPALIVE_INTERVAL = 38,
TCP_KEEPALIVE_GARBAGE = 39,
/* Application and Service Parameters */
NETWORK_INFORMATION_SERVICE_DOMAIN = 40,
NETWORK_INFORMATION_SERVERS = 41,
NETWORK_TIME_PROTOCOL_SERVERS = 42,
VENDOR_SPECIFIC_INFORMATION = 43,
NETBIOS_OVER_TCP_IP_NAME_SERVER = 44,
NETBIOS_OVER_TCP_IP_DATAGRAM_DISTRIBUTION_SERVER = 4,
NETBIOS_OVER_TCP_IP_NODE_TYPE = 46,
NETBIOS_OVER_TCP_IP_SCOPE = 47,
X_WINDOW_SYSTEM_FONT_SERVER = 48,
X_WINDOW_SYSTEM_DISPLAY_MANAGER = 49,
NETWORK_INFORMATION_SERVICE_PLUS_DOMAIN = 64,
NETWORK_INFORMATION_SERVICE_PLUS_SERVERS = 65,
MOBILE_IP_HOME_AGENT = 68,
SMTP_SERVER = 69,
POP3_SERVER = 70,
NNTP_SERVER = 71,
DEFAULT_WWW_SERVER = 72,
DEFAULT_FINGER_SERVER = 73,
DEFAULT_IRC_SERVER = 74,
STREETTALK_SERVER = 75,
STREETTALK_DIRECTORY_ASSISTANCE_SERVER = 76,
/* DHCP Extensions */
REQUESTED_IP_ADDRESS = 50,
IP_ADDRESS_LEASE_TIME = 51,
OPTION_OVERLOAD = 52,
TFTP_SERVER_NAME = 66,
BOOTFILE_NAME = 67,
DHCP_MESSAGE_TYPE = 53,
SERVER_IDENTIFIER = 54,
PARAMETER_REQUEST_LIST = 55,
MESSAGE = 56,
MAXIMUM_DHCP_MESSAGE_SIZE = 57,
RENEWAL_T1_TIME_VALUE = 58,
REBINDING_T2_TIME_VALUE = 59,
VENDOR_CLASS_IDENTIFIER = 60,
CLIENT_IDENTIFIER = 61
};
struct dhcp_option {
uint8_t id; // option id
uint8_t len; // option length
uint8_t data[256]; // option data
TAILQ_ENTRY(dhcp_option) pointers; // pointers, see queue(3)
};
typedef struct dhcp_option dhcp_option;
typedef TAILQ_HEAD(dhcp_option_list_, dhcp_option) DHCP_OPTION_LIST;
typedef struct dhcp_option_list_ dhcp_option_list;
/* Value parsing functions:
*
* Parse the string pointed by s, and allocate the
* pointer p to contain the parsed data.
*
* On success return the size of the parsed data,
* on error return zero.
*/
int parse_byte (char *s, void **p);
int parse_byte_list (char *s, void **p);
int parse_short (char *s, void **p);
int parse_short_list (char *s, void **p);
int parse_long (char *s, void **p);
int parse_string (char *s, void **p);
int parse_ip (char *s, void **p);
int parse_ip_list (char *s, void **p);
int parse_mac (char *s, void **p);
/* Other prototypes */
void init_option_list (dhcp_option_list *list);
uint8_t parse_option (dhcp_option *option, char *name, char *value);
dhcp_option * search_option (dhcp_option_list *list, uint8_t id);
void print_options (dhcp_option_list *list);
void append_option (dhcp_option_list *list, dhcp_option *opt);
int parse_options_to_list (dhcp_option_list *list, dhcp_option *opts, size_t len);
size_t serialize_option_list (dhcp_option_list *list, uint8_t *buf, size_t len);
void delete_option_list (dhcp_option_list *list);
#endif