FD.io VPP  v20.09-64-g4f7b92f0a
Vector Packet Processing
cdp_protocol.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2018 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef __included_cdp_protocol_h__
16 #define __included_cdp_protocol_h__
17 
18 #include <vnet/ethernet/ethernet.h> /* for ethernet_header_t */
19 #include <vnet/llc/llc.h>
20 #include <vnet/snap/snap.h>
21 #include <vnet/srp/packet.h>
22 
23 typedef CLIB_PACKED (struct
24  {
25  u8 version;
26  u8 ttl;
27  u16 checksum; /* 1's complement of the 1's complement sum */
28  u8 data[0];
29  }) cdp_hdr_t;
30 
31 typedef struct
32 {
33  u8 dst_address[6];
37 
38 typedef CLIB_PACKED (struct
39  {
40  ethernet_802_3_header_t ethernet;
41  llc_header_t llc; snap_header_t snap; cdp_hdr_t cdp;
42  }) ethernet_llc_snap_and_cdp_header_t;
43 
44 typedef CLIB_PACKED (struct
45  {
46  hdlc_header_t hdlc; cdp_hdr_t cdp;
47  }) hdlc_and_cdp_header_t;
48 
49 typedef CLIB_PACKED (struct
50  {
51  srp_header_t srp;
52  ethernet_header_t ethernet; cdp_hdr_t cdp;
53  }) srp_and_cdp_header_t;
54 
55 typedef CLIB_PACKED (struct
56  {
57  u16 t;
58  u16 l;
59  u8 v[0];
60  }) cdp_tlv_t;
61 
62 /*
63  * TLV codes.
64  */
65 #define foreach_cdp_tlv_type \
66 _(unused) \
67 _(device_name) /* uniquely identifies the device */ \
68 _(address) /* list of addresses this device has */ \
69 _(port_id) /* port CDP packet was sent out on */ \
70 _(capabilities) /* funct. capabilities of the device */ \
71 _(version) /* version */ \
72 _(platform) /* hardware platform of this device */ \
73 _(ipprefix) /* An IP network prefix */ \
74 _(hello) /* Pprotocol piggyback hello msg */ \
75 _(vtp_domain) /* VTP management domain */ \
76 _(native_vlan) /* Native VLAN number */ \
77 _(duplex) /* The interface duplex mode */ \
78 _(appl_vlan) /* Appliance VLAN-ID TLV */ \
79 _(trigger) /* For sending trigger TLV msgs. */ \
80 _(power) /* Power consumption of that device */ \
81 _(mtu) /* MTU defined for sending intf. */ \
82 _(trust) /* Extended trust TLV */ \
83 _(cos) /* COS for Untrusted Port TLV */ \
84 _(sysname) /* System name (FQDN of device) */ \
85 _(sysobject) /* OID of sysObjectID MIB object */ \
86 _(mgmt_addr) /* SNMP manageable addrs. of device */ \
87 _(physical_loc) /* Physical Location of the device */ \
88 _(mgmt_addr2) /* External Port-ID */ \
89 _(power_requested) \
90 _(power_available) \
91 _(port_unidirectional) \
92 _(unknown_28) \
93 _(energywise) \
94 _(unknown_30) \
95 _(spare_poe)
96 
97 typedef enum
98 {
99 #define _(t) CDP_TLV_##t,
101 #undef _
103 
104 /*
105  The address TLV looks as follows:
106 
107  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
108  | Number of addresses |
109  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
110  | IDRP encoded address |
111  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
112 
113  An address is encoded in IDRP format:
114 
115  0 1 2 3
116  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
117  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
118  | PT | PT Length | Protocol (variable) ...
119  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
120  | Address length | Address (variable) ...
121  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
122 
123  PT: Protocol type
124  1 = NLPID format
125  2 = 802.2 format
126 
127  PT Length:
128  Length of protocol field, 1 for PT = 1, and either 3 or 8 for
129  802.2 format depending if SNAP is used for PT = 2.
130 
131  The encodings for the other protocols have the following format:
132 
133  field: <SSAP><DSAP><CTRL><-------OUI------><protocl_TYPE>
134  | | | | | | | | |
135  bytes: 0 1 2 3 4 5 6 7 8
136 
137  where the first 3 bytes are 0xAAAA03 for SNAP encoded addresses.
138  The OUI is 000000 for ethernet and <protocl_TYPE>
139  is the assigned Ethernet type code for the particular protocol.
140  e.g. for DECnet the encoding is AAAA03 000000 6003.
141  for IPv6 the encoding is AAAA03 000000 86DD
142 */
143 
144 /*
145  * Capabilities.
146  */
147 
148 #define CDP_ROUTER_DEVICE 0x0001
149 #define CDP_TB_DEVICE 0x0002
150 #define CDP_SRB_DEVICE 0x0004
151 #define CDP_SWITCH_DEVICE 0x0008
152 #define CDP_HOST_DEVICE 0x0010
153 #define CDP_IGMP_DEVICE 0x0020
154 #define CDP_REPEATER_DEVICE 0x0040
155 
156 /*
157  The protocol-hello TLV looks as follows:
158 
159  0 1 2 3
160  012345678901234567890123456789012345678
161  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
162  | Type | Length |
163  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
164  | OUI |
165  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
166  | Protocol ID |
167  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
168  | up to 27 bytes of message |
169  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
170 */
171 
172 /*
173  * These macros define the valid values for the Duplex TLV.
174  */
175 #define CDP_DUPLEX_TLV_HALF 0x0
176 #define CDP_DUPLEX_TLV_FULL 0x1
177 
178 #endif /* __included_cdp_protocol_h__ */
179 
180 /*
181  * fd.io coding-style-patch-verification: ON
182  *
183  * Local Variables:
184  * eval: (c-set-style "gnu")
185  * End:
186  */
#define foreach_cdp_tlv_type
Definition: cdp_protocol.h:65
option version
Definition: sample.api:19
cdp_tlv_code_t
Definition: cdp_protocol.h:97
unsigned char u8
Definition: types.h:56
u8 data[128]
Definition: ipsec_types.api:89
unsigned short u16
Definition: types.h:57
vl_api_address_union_t src_address
Definition: ip_types.api:111
u8 ttl
Definition: fib_types.api:26
typedef CLIB_PACKED(struct { u8 version;u8 ttl;u16 checksum;u8 data[0];}) cdp_hdr_t