2 * Copyright (c) 2011-2016 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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
15 #ifndef __included_cdp_protocol_h__
16 #define __included_cdp_protocol_h__
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>
23 typedef CLIB_PACKED (struct
27 u16 checksum; /* 1's complement of the 1's complement sum */
36 } ethernet_802_3_header_t;
38 typedef CLIB_PACKED (struct
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;
44 typedef CLIB_PACKED (struct
46 hdlc_header_t hdlc; cdp_hdr_t cdp;
47 }) hdlc_and_cdp_header_t;
49 typedef CLIB_PACKED (struct
52 ethernet_header_t ethernet; cdp_hdr_t cdp;
53 }) srp_and_cdp_header_t;
55 typedef CLIB_PACKED (struct
65 #define foreach_cdp_tlv_type \
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 */ \
91 _(port_unidirectional) \
99 #define _(t) CDP_TLV_##t,
105 The address TLV looks as follows:
107 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
108 | Number of addresses |
109 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
110 | IDRP encoded address |
111 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
113 An address is encoded in IDRP format:
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
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.
131 The encodings for the other protocols have the following format:
133 field: <SSAP><DSAP><CTRL><-------OUI------><protocl_TYPE>
135 bytes: 0 1 2 3 4 5 6 7 8
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
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
157 The protocol-hello TLV looks as follows:
160 012345678901234567890123456789012345678
161 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
163 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
165 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
167 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
168 | up to 27 bytes of message |
169 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
173 * These macros define the valid values for the Duplex TLV.
175 #define CDP_DUPLEX_TLV_HALF 0x0
176 #define CDP_DUPLEX_TLV_FULL 0x1
178 #endif /* __included_cdp_protocol_h__ */
181 * fd.io coding-style-patch-verification: ON
184 * eval: (c-set-style "gnu")