18
18
19
19
20
20
/**
21
- * DHCPv4 message types
21
+ * DHCP message types
22
22
**/
23
23
typedef enum
24
24
{
25
- DHCPv4_MESSAGE_TYPE_DISCOVER = 1 ,
26
- DHCPv4_MESSAGE_TYPE_OFFER = 2 ,
27
- DHCPv4_MESSAGE_TYPE_REQUEST = 3 ,
28
- DHCPv4_MESSAGE_TYPE_DECLINE = 4 ,
29
- DHCPv4_MESSAGE_TYPE_ACK = 5 ,
30
- DHCPv4_MESSAGE_TYPE_NAK = 6 ,
31
- DHCPv4_MESSAGE_TYPE_RELEASE = 7 ,
32
- DHCPv4_MESSAGE_TYPE_INFORM = 8 ,
33
-
34
- DHCPv4_MESSAGE_TYPE_COUNT
35
- } dhcpv4_message_type_t ;
36
-
37
- /**
38
- * DHCPv6 message types
39
- **/
40
- typedef enum
41
- {
42
- DHCPv6_MESSAGE_TYPE_SOLICIT = 1 ,
43
- DHCPv6_MESSAGE_TYPE_ADVERTISE = 2 ,
44
- DHCPv6_MESSAGE_TYPE_REQUEST = 3 ,
45
- DHCPv6_MESSAGE_TYPE_CONFIRM = 4 ,
46
- DHCPv6_MESSAGE_TYPE_RENEW = 5 ,
47
- DHCPv6_MESSAGE_TYPE_REBIND = 6 ,
48
- DHCPv6_MESSAGE_TYPE_REPLY = 7 ,
49
- DHCPv6_MESSAGE_TYPE_RELEASE = 8 ,
50
- DHCPv6_MESSAGE_TYPE_DECLINE = 9 ,
51
- DHCPv6_MESSAGE_TYPE_RECONFIGURE = 10 ,
52
- DHCPv6_MESSAGE_TYPE_INFORMATION_REQUEST = 11 ,
53
- DHCPv6_MESSAGE_TYPE_RELAY_FORWARD = 12 ,
54
- DHCPv6_MESSAGE_TYPE_RELAY_REPLY = 13 ,
55
-
56
- DHCPv6_MESSAGE_TYPE_COUNT
57
- } dhcpv6_message_type_t ;
25
+ DHCP_MESSAGE_TYPE_DISCOVER = 1 ,
26
+ DHCP_MESSAGE_TYPE_OFFER = 2 ,
27
+ DHCP_MESSAGE_TYPE_REQUEST = 3 ,
28
+ DHCP_MESSAGE_TYPE_DECLINE = 4 ,
29
+ DHCP_MESSAGE_TYPE_ACK = 5 ,
30
+ DHCP_MESSAGE_TYPE_NAK = 6 ,
31
+ DHCP_MESSAGE_TYPE_RELEASE = 7 ,
32
+ DHCP_MESSAGE_TYPE_INFORM = 8 ,
33
+
34
+ DHCP_MESSAGE_TYPE_COUNT
35
+ } dhcp_message_type_t ;
58
36
59
37
/** packet direction */
60
38
typedef enum
@@ -82,42 +60,26 @@ typedef enum
82
60
DHCP_MON_STATUS_INDETERMINATE , /** DHCP relay health could not be determined */
83
61
} dhcp_mon_status_t ;
84
62
85
- /** dhcp type */
86
- typedef enum
87
- {
88
- DHCPv4_TYPE ,
89
- DHCPv6_TYPE ,
90
- } dhcp_type_t ;
91
-
92
63
/** dhcp check type */
93
64
typedef enum
94
65
{
95
66
DHCP_MON_CHECK_NEGATIVE , /** Presence of relayed DHCP packets activity is flagged as unhealthy state */
96
67
DHCP_MON_CHECK_POSITIVE , /** Validate that received DORA packets are relayed */
97
68
} dhcp_mon_check_t ;
98
69
99
- typedef struct
100
- {
101
- uint64_t v4counters [DHCP_COUNTERS_COUNT ][DHCP_DIR_COUNT ][DHCPv4_MESSAGE_TYPE_COUNT ];
102
- /** current/snapshot counters of DHCPv4 packets */
103
- uint64_t v6counters [DHCP_COUNTERS_COUNT ][DHCP_DIR_COUNT ][DHCPv6_MESSAGE_TYPE_COUNT ];
104
- /** current/snapshot counters of DHCPv6 packets */
105
- } counters_t ;
106
-
107
70
/** DHCP device (interface) context */
108
71
typedef struct
109
72
{
110
73
int sock ; /** Raw socket associated with this device/interface */
111
- in_addr_t ipv4 ; /** ipv4 network address of this device (interface) */
112
- struct in6_addr ipv6 ; /** ipv6 network address of this device (interface) */
74
+ in_addr_t ip ; /** network address of this device (interface) */
113
75
uint8_t mac [ETHER_ADDR_LEN ]; /** hardware address of this device (interface) */
114
- in_addr_t giaddr_ip ; /** Gateway IPv4 address */
115
- struct in6_addr v6_vlan_ip ; /** Vlan IPv6 address */
76
+ in_addr_t giaddr_ip ; /** Gateway IP address */
116
77
uint8_t is_uplink ; /** north interface? */
117
78
char intf [IF_NAMESIZE ]; /** device (interface) name */
118
79
uint8_t * buffer ; /** buffer used to read socket data */
119
80
size_t snaplen ; /** snap length or buffer size */
120
- counters_t counters ; /** counters for DHCPv4/6 packets */
81
+ uint64_t counters [DHCP_COUNTERS_COUNT ][DHCP_DIR_COUNT ][DHCP_MESSAGE_TYPE_COUNT ];
82
+ /** current/snapshot counters of DHCP packets */
121
83
} dhcp_device_context_t ;
122
84
123
85
/**
@@ -132,28 +94,16 @@ typedef struct
132
94
int initialize_intf_mac_and_ip_addr (dhcp_device_context_t * context );
133
95
134
96
/**
135
- * @code dhcp_device_get_ipv4(context, ip);
136
- *
137
- * @brief Accessor method
138
- *
139
- * @param context pointer to device (interface) context
140
- * @param ip(out) pointer to device IPv4
141
- *
142
- * @return 0 on success, otherwise for failure
143
- */
144
- int dhcp_device_get_ipv4 (dhcp_device_context_t * context , in_addr_t * ip );
145
-
146
- /**
147
- * @code dhcp_device_get_ipv6(context, ip);
97
+ * @code dhcp_device_get_ip(context, ip);
148
98
*
149
99
* @brief Accessor method
150
100
*
151
101
* @param context pointer to device (interface) context
152
- * @param ip(out) pointer to device IPv6
102
+ * @param ip(out) pointer to device IP
153
103
*
154
104
* @return 0 on success, otherwise for failure
155
105
*/
156
- int dhcp_device_get_ipv6 (dhcp_device_context_t * context , struct in6_addr * ip );
106
+ int dhcp_device_get_ip (dhcp_device_context_t * context , in_addr_t * ip );
157
107
158
108
/**
159
109
* @code dhcp_device_get_aggregate_context();
@@ -180,23 +130,21 @@ int dhcp_device_init(dhcp_device_context_t **context,
180
130
uint8_t is_uplink );
181
131
182
132
/**
183
- * @code dhcp_device_start_capture(context, snaplen, base, giaddr_ip, v6_vlan_ip );
133
+ * @code dhcp_device_start_capture(context, snaplen, base, giaddr_ip);
184
134
*
185
135
* @brief starts packet capture on this interface
186
136
*
187
137
* @param context pointer to device (interface) context
188
138
* @param snaplen length of packet capture
189
139
* @param base pointer to libevent base
190
140
* @param giaddr_ip gateway IP address
191
- * @param v6_vlan_ip vlan IPv6 address
192
141
*
193
142
* @return 0 on success, otherwise for failure
194
143
*/
195
144
int dhcp_device_start_capture (dhcp_device_context_t * context ,
196
145
size_t snaplen ,
197
146
struct event_base * base ,
198
- in_addr_t giaddr_ip ,
199
- struct in6_addr v6_vlan_ip );
147
+ in_addr_t giaddr_ip );
200
148
201
149
/**
202
150
* @code dhcp_device_shutdown(context);
@@ -210,18 +158,17 @@ int dhcp_device_start_capture(dhcp_device_context_t *context,
210
158
void dhcp_device_shutdown (dhcp_device_context_t * context );
211
159
212
160
/**
213
- * @code dhcp_device_get_status(check_type, context, type );
161
+ * @code dhcp_device_get_status(check_type, context);
214
162
*
215
163
* @brief collects DHCP relay status info for a given interface. If context is null, it will report aggregate
216
164
* status
217
165
*
218
166
* @param check_type Type of validation
219
167
* @param context Device (interface) context
220
- * @param type DHCP type
221
168
*
222
169
* @return DHCP_MON_STATUS_HEALTHY, DHCP_MON_STATUS_UNHEALTHY, or DHCP_MON_STATUS_INDETERMINATE
223
170
*/
224
- dhcp_mon_status_t dhcp_device_get_status (dhcp_mon_check_t check_type , dhcp_device_context_t * context , dhcp_type_t type );
171
+ dhcp_mon_status_t dhcp_device_get_status (dhcp_mon_check_t check_type , dhcp_device_context_t * context );
225
172
226
173
/**
227
174
* @code dhcp_device_update_snapshot(context);
@@ -238,21 +185,10 @@ void dhcp_device_update_snapshot(dhcp_device_context_t *context);
238
185
* @brief prints status counters to syslog. If context is null, it will print aggregate status
239
186
*
240
187
* @param context Device (interface) context
241
- * @param type Counter type to be printed
188
+ * @param counters_type Counter type to be printed
242
189
*
243
190
* @return none
244
191
*/
245
192
void dhcp_device_print_status (dhcp_device_context_t * context , dhcp_counters_type_t type );
246
193
247
- /**
248
- * @code dhcp_device_active_types(dhcpv4, dhcpv6);
249
- *
250
- * @brief update local variables with active protocols
251
- *
252
- * @param dhcpv4 DHCPv4 enable flag
253
- * @param dhcpv6 DHCPv6 enable flag
254
- *
255
- * @return none
256
- */
257
- void dhcp_device_active_types (bool dhcpv4 , bool dhcpv6 );
258
194
#endif /* DHCP_DEVICE_H_ */
0 commit comments