1 #ifndef included_vnet_dhcp6_packet_h
2 #define included_vnet_dhcp6_packet_h
7 * Copyright (c) 2013 Cisco and/or its affiliates.
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at:
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
20 #include <vnet/ip/ip6_packet.h>
22 // #define DHCP_VRF_NAME_MAX_LEN L3VM_MAX_NAME_STR_LEN
23 // #define DHCPV6_MAX_VRF_NAME_LEN L3VM_MAX_NAME_STR_LEN
24 #define DHCP_MAX_RELAY_ADDR 16
26 #define DHCPV6_CLIENT_PORT 546
27 #define DHCPV6_SERVER_PORT 547
28 #define HOP_COUNT_LIMIT 32
29 #define DHCPV6_CISCO_ENT_NUM 9
32 * DHCPv6 message types
34 typedef enum dhcpv6_msg_type_
36 DHCPV6_MSG_SOLICIT = 1,
37 DHCPV6_MSG_ADVERTISE = 2,
38 DHCPV6_MSG_REQUEST = 3,
39 DHCPV6_MSG_CONFIRM = 4,
41 DHCPV6_MSG_REBIND = 6,
43 DHCPV6_MSG_RELEASE = 8,
44 DHCPV6_MSG_DECLINE = 9,
45 DHCPV6_MSG_RECONFIGURE = 10,
46 DHCPV6_MSG_INFORMATION_REQUEST = 11,
47 DHCPV6_MSG_RELAY_FORW = 12,
48 DHCPV6_MSG_RELAY_REPL = 13,
51 /* Name, code, min payload length */
52 #define dhcpv6_foreach_option \
53 _(CLIENTID , 1 , 4 ) \
54 _(SERVERID , 2 , 4 ) \
59 _(PREFERENCE , 7 , 1 ) \
60 _(ELAPSED_TIME , 8 , 2 ) \
61 _(RELAY_MSG , 9 , 0 ) \
63 _(UNICAST , 12 , 16) \
64 _(STATUS_CODE , 13 , 2 ) \
65 _(RAPID_COMMIT , 14 , 0 ) \
66 _(USER_CLASS , 15 , 0 ) \
67 _(VENDOR_CLASS , 16 , 4 ) \
68 _(VENDOR_OPTS , 17 , 4 ) \
69 _(INTERFACE_ID , 18 , 0 ) \
70 _(RECONF_MSG , 19 , 1 ) \
71 _(RECONF_ACCEPT , 20 , 0 ) \
72 _(DNS_SEARCH , 24 , 0 ) \
74 _(IAPREFIX , 26 , 25) \
75 _(REMOTEID , 37 , 4 ) \
77 _(CLIENT_LINK_LAYER_ADDRESS, 79 , 2 )
80 * DHCPv6 options types
84 #define _(a,b,c) DHCPV6_OPTION_##a = b,
95 DHCPV6_STATUS_SUCCESS = 0,
96 DHCPV6_STATUS_UNSPEC_FAIL = 1,
97 DHCPV6_STATUS_NOADDRS_AVAIL = 2,
98 DHCPV6_STATUS_NO_BINDING = 3,
99 DHCPV6_STATUS_NOT_ONLINK = 4,
100 DHCPV6_STATUS_USE_MULTICAST = 5,
101 DHCPV6_STATUS_NOPREFIX_AVAIL = 6,
109 DHCPV6_DUID_LLT = 1, /* DUID Based on Link-layer Address Plus Time */
110 DHCPV6_DUID_EN = 2, /* DUID Based on Enterprise Number */
111 DHCPV6_DUID_LL = 3, /* DUID Based on Link-layer Address */
114 //Structure for DHCPv6 payload from client
115 typedef struct dhcpv6_hdr_
117 u8 msg_type; //DHCP msg type
118 u8 xid[3]; //Transaction id
122 typedef CLIB_PACKED (struct dhcpv6_relay_ctx_ {
123 dhcpv6_header_t *pkt;
125 u32 dhcpv6_len; //DHCPv6 payload load
131 }) dhcpv6_relay_ctx_t;
133 //Structure for DHCPv6 RELAY-FORWARD and DHCPv6 RELAY-REPLY pkts
134 typedef CLIB_PACKED (struct dhcpv6_relay_hdr_ {
137 ip6_address_t link_addr;
138 ip6_address_t peer_addr;
140 }) dhcpv6_relay_hdr_t;
142 typedef enum dhcp_stats_action_type_
144 DHCP_STATS_ACTION_FORWARDED = 1,
145 DHCP_STATS_ACTION_RECEIVED,
146 DHCP_STATS_ACTION_DROPPED
147 } dhcp_stats_action_type_t;
148 //Generic counters for a packet
149 typedef struct dhcp_stats_counters_
151 u64 rx_pkts; //counter for received pkts
152 u64 tx_pkts; //counter for forwarded pkts
153 u64 drops; //counter for dropped pkts
154 } dhcp_stats_counters_t;
157 typedef enum dhcpv6_stats_drop_reason_
159 DHCPV6_RELAY_PKT_DROP_RELAYDISABLE = 1,
160 DHCPV6_RELAY_PKT_DROP_MAX_HOPS,
161 DHCPV6_RELAY_PKT_DROP_VALIDATION_FAIL,
162 DHCPV6_RELAY_PKT_DROP_UNKNOWN_OP_INTF,
163 DHCPV6_RELAY_PKT_DROP_BAD_CONTEXT,
164 DHCPV6_RELAY_PKT_DROP_OPT_INSERT_FAIL,
165 DHCPV6_RELAY_PKT_DROP_REPLY_FROM_CLIENT,
166 } dhcpv6_stats_drop_reason_t;
168 #define dhcpv6_optlen(opt) clib_net_to_host_u16((opt)->length)
170 typedef CLIB_PACKED (struct {
176 typedef CLIB_PACKED (struct {
179 }) dhcpv6_status_code_t;
181 typedef CLIB_PACKED (struct {
186 typedef CLIB_PACKED (struct {
192 typedef CLIB_PACKED (struct {
198 typedef CLIB_PACKED (struct {
201 u8 data[6]; // data[0]:data[5]: MAC address
202 }) dhcpv6_client_mac_t;
204 typedef CLIB_PACKED (struct
206 dhcpv6_option_t opt; u32 iaid; u32 t1;
209 }) dhcpv6_ia_header_t;
211 typedef CLIB_PACKED (struct
213 dhcpv6_option_t opt; u32 preferred; u32 valid; u8 prefix;
215 }) dhcpv6_ia_opt_pd_t;
217 typedef CLIB_PACKED (struct
219 dhcpv6_option_t opt; ip6_address_t addr; u32 preferred;
221 }) dhcpv6_ia_opt_addr_t;
223 typedef CLIB_PACKED (struct
229 typedef CLIB_PACKED (struct
231 dhcpv6_option_t opt; u16 elapsed_10ms;
234 typedef CLIB_PACKED (struct
236 dhcpv6_option_t opt; u16 duid_type;
240 typedef CLIB_PACKED (struct
242 dhcpv6_option_t opt; u16 status_code;
247 #endif /* included_vnet_dhcp6_packet_h */
250 * fd.io coding-style-patch-verification: ON
253 * eval: (c-set-style "gnu")