18
18
19
19
20
20
/**
21
- * DHCP message types
21
+ * DHCPv4 message types
22
22
**/
23
23
typedef enum
24
24
{
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 ;
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 ;
36
58
37
59
/** packet direction */
38
60
typedef enum
@@ -60,26 +82,42 @@ typedef enum
60
82
DHCP_MON_STATUS_INDETERMINATE , /** DHCP relay health could not be determined */
61
83
} dhcp_mon_status_t ;
62
84
85
+ /** dhcp type */
86
+ typedef enum
87
+ {
88
+ DHCPv4_TYPE ,
89
+ DHCPv6_TYPE ,
90
+ } dhcp_type_t ;
91
+
63
92
/** dhcp check type */
64
93
typedef enum
65
94
{
66
95
DHCP_MON_CHECK_NEGATIVE , /** Presence of relayed DHCP packets activity is flagged as unhealthy state */
67
96
DHCP_MON_CHECK_POSITIVE , /** Validate that received DORA packets are relayed */
68
97
} dhcp_mon_check_t ;
69
98
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
+
70
107
/** DHCP device (interface) context */
71
108
typedef struct
72
109
{
73
110
int sock ; /** Raw socket associated with this device/interface */
74
- in_addr_t ip ; /** network address of 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) */
75
113
uint8_t mac [ETHER_ADDR_LEN ]; /** hardware address of this device (interface) */
76
- in_addr_t giaddr_ip ; /** Gateway IP address */
114
+ in_addr_t giaddr_ip ; /** Gateway IPv4 address */
115
+ struct in6_addr v6_vlan_ip ; /** Vlan IPv6 address */
77
116
uint8_t is_uplink ; /** north interface? */
78
117
char intf [IF_NAMESIZE ]; /** device (interface) name */
79
118
uint8_t * buffer ; /** buffer used to read socket data */
80
119
size_t snaplen ; /** snap length or buffer size */
81
- uint64_t counters [DHCP_COUNTERS_COUNT ][DHCP_DIR_COUNT ][DHCP_MESSAGE_TYPE_COUNT ];
82
- /** current/snapshot counters of DHCP packets */
120
+ counters_t counters ; /** counters for DHCPv4/6 packets */
83
121
} dhcp_device_context_t ;
84
122
85
123
/**
@@ -94,16 +132,28 @@ typedef struct
94
132
int initialize_intf_mac_and_ip_addr (dhcp_device_context_t * context );
95
133
96
134
/**
97
- * @code dhcp_device_get_ip(context, ip);
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);
98
148
*
99
149
* @brief Accessor method
100
150
*
101
151
* @param context pointer to device (interface) context
102
- * @param ip(out) pointer to device IP
152
+ * @param ip(out) pointer to device IPv6
103
153
*
104
154
* @return 0 on success, otherwise for failure
105
155
*/
106
- int dhcp_device_get_ip (dhcp_device_context_t * context , in_addr_t * ip );
156
+ int dhcp_device_get_ipv6 (dhcp_device_context_t * context , struct in6_addr * ip );
107
157
108
158
/**
109
159
* @code dhcp_device_get_aggregate_context();
@@ -130,21 +180,23 @@ int dhcp_device_init(dhcp_device_context_t **context,
130
180
uint8_t is_uplink );
131
181
132
182
/**
133
- * @code dhcp_device_start_capture(context, snaplen, base, giaddr_ip);
183
+ * @code dhcp_device_start_capture(context, snaplen, base, giaddr_ip, v6_vlan_ip );
134
184
*
135
185
* @brief starts packet capture on this interface
136
186
*
137
187
* @param context pointer to device (interface) context
138
188
* @param snaplen length of packet capture
139
189
* @param base pointer to libevent base
140
190
* @param giaddr_ip gateway IP address
191
+ * @param v6_vlan_ip vlan IPv6 address
141
192
*
142
193
* @return 0 on success, otherwise for failure
143
194
*/
144
195
int dhcp_device_start_capture (dhcp_device_context_t * context ,
145
196
size_t snaplen ,
146
197
struct event_base * base ,
147
- in_addr_t giaddr_ip );
198
+ in_addr_t giaddr_ip ,
199
+ struct in6_addr v6_vlan_ip );
148
200
149
201
/**
150
202
* @code dhcp_device_shutdown(context);
@@ -158,17 +210,18 @@ int dhcp_device_start_capture(dhcp_device_context_t *context,
158
210
void dhcp_device_shutdown (dhcp_device_context_t * context );
159
211
160
212
/**
161
- * @code dhcp_device_get_status(check_type, context);
213
+ * @code dhcp_device_get_status(check_type, context, type );
162
214
*
163
215
* @brief collects DHCP relay status info for a given interface. If context is null, it will report aggregate
164
216
* status
165
217
*
166
218
* @param check_type Type of validation
167
219
* @param context Device (interface) context
220
+ * @param type DHCP type
168
221
*
169
222
* @return DHCP_MON_STATUS_HEALTHY, DHCP_MON_STATUS_UNHEALTHY, or DHCP_MON_STATUS_INDETERMINATE
170
223
*/
171
- dhcp_mon_status_t dhcp_device_get_status (dhcp_mon_check_t check_type , dhcp_device_context_t * context );
224
+ dhcp_mon_status_t dhcp_device_get_status (dhcp_mon_check_t check_type , dhcp_device_context_t * context , dhcp_type_t type );
172
225
173
226
/**
174
227
* @code dhcp_device_update_snapshot(context);
@@ -185,10 +238,21 @@ void dhcp_device_update_snapshot(dhcp_device_context_t *context);
185
238
* @brief prints status counters to syslog. If context is null, it will print aggregate status
186
239
*
187
240
* @param context Device (interface) context
188
- * @param counters_type Counter type to be printed
241
+ * @param type Counter type to be printed
189
242
*
190
243
* @return none
191
244
*/
192
245
void dhcp_device_print_status (dhcp_device_context_t * context , dhcp_counters_type_t type );
193
246
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 );
194
258
#endif /* DHCP_DEVICE_H_ */
0 commit comments