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,
52 * DHCPv6 options types
56 DHCPV6_OPTION_CLIENTID = 1,
57 DHCPV6_OPTION_SERVERID = 2,
58 DHCPV6_OPTION_IA_NA = 3,
59 DHCPV6_OPTION_IA_TA = 4,
60 DHCPV6_OPTION_IAADDR = 5,
61 DHCPV6_OPTION_ORO = 6,
62 DHCPV6_OPTION_PREFERENCE = 7,
63 DHCPV6_OPTION_ELAPSED_TIME = 8,
64 DHCPV6_OPTION_RELAY_MSG = 9,
65 DHCPV6_OPTION_AUTH = 11,
66 DHCPV6_OPTION_UNICAST = 12,
67 DHCPV6_OPTION_STATUS_CODE = 13,
68 DHCPV6_OPTION_RAPID_COMMIT = 14,
69 DHCPV6_OPTION_USER_CLASS = 15,
70 DHCPV6_OPTION_VENDOR_CLASS = 16,
71 DHCPV6_OPTION_VENDOR_OPTS = 17,
72 DHCPV6_OPTION_INTERFACE_ID = 18, // relay agent fills this
73 DHCPV6_OPTION_RECONF_MSG = 19,
74 DHCPV6_OPTION_RECONF_ACCEPT = 20,
75 DHCPV6_OPTION_REMOTEID = 37, // relay agent fills this
76 DHCPV6_OPTION_VSS = 68, // relay agent fills this
77 DHCPV6_OPTION_CLIENT_LINK_LAYER_ADDRESS = 79,
86 DHCPV6_STATUS_SUCCESS = 0,
87 DHCPV6_STATUS_UNSPEC_FAIL = 1,
88 DHCPV6_STATUS_NOADDRS_AVAIL = 2,
89 DHCPV6_STATUS_NO_BINDING = 3,
90 DHCPV6_STATUS_NOT_ONLINK = 4,
91 DHCPV6_STATUS_USE_MULTICAST = 5,
99 DHCPV6_DUID_LLT = 1, /* DUID Based on Link-layer Address Plus Time */
100 DHCPV6_DUID_EN = 2, /* DUID Based on Enterprise Number */
101 DHCPV6_DUID_LL = 3, /* DUID Based on Link-layer Address */
104 //Structure for DHCPv6 payload from client
105 typedef struct dhcpv6_hdr_
109 u8 msg_type; //DHCP msg type
110 u32 xid; // transaction id
118 typedef CLIB_PACKED (struct dhcpv6_relay_ctx_ {
119 dhcpv6_header_t *pkt;
121 u32 dhcpv6_len; //DHCPv6 payload load
127 }) dhcpv6_relay_ctx_t;
130 //Structure for DHCPv6 RELAY-FORWARD and DHCPv6 RELAY-REPLY pkts
132 typedef CLIB_PACKED (struct dhcpv6_relay_hdr_ {
135 ip6_address_t link_addr;
136 ip6_address_t peer_addr;
138 }) dhcpv6_relay_hdr_t;
141 typedef enum dhcp_stats_action_type_
143 DHCP_STATS_ACTION_FORWARDED = 1,
144 DHCP_STATS_ACTION_RECEIVED,
145 DHCP_STATS_ACTION_DROPPED
146 } dhcp_stats_action_type_t;
147 //Generic counters for a packet
148 typedef struct dhcp_stats_counters_
150 u64 rx_pkts; //counter for received pkts
151 u64 tx_pkts; //counter for forwarded pkts
152 u64 drops; //counter for dropped pkts
153 } dhcp_stats_counters_t;
156 typedef enum dhcpv6_stats_drop_reason_
158 DHCPV6_RELAY_PKT_DROP_RELAYDISABLE = 1,
159 DHCPV6_RELAY_PKT_DROP_MAX_HOPS,
160 DHCPV6_RELAY_PKT_DROP_VALIDATION_FAIL,
161 DHCPV6_RELAY_PKT_DROP_UNKNOWN_OP_INTF,
162 DHCPV6_RELAY_PKT_DROP_BAD_CONTEXT,
163 DHCPV6_RELAY_PKT_DROP_OPT_INSERT_FAIL,
164 DHCPV6_RELAY_PKT_DROP_REPLY_FROM_CLIENT,
165 } dhcpv6_stats_drop_reason_t;
168 typedef CLIB_PACKED (struct {
176 typedef CLIB_PACKED (struct {
183 typedef CLIB_PACKED (struct {
191 typedef CLIB_PACKED (struct {
199 typedef CLIB_PACKED (struct {
202 u8 data[6]; // data[0]:data[5]: MAC address
203 }) dhcpv6_client_mac_t;
207 #endif /* included_vnet_dhcp6_packet_h */
210 * fd.io coding-style-patch-verification: ON
213 * eval: (c-set-style "gnu")