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_lldp_protocol_h__
16 #define __included_lldp_protocol_h__
19 * @brief LLDP protocol declarations
21 #include <vnet/srp/packet.h>
26 #define foreach_lldp_optional_tlv_type(F) \
27 F (4, port_desc, "Port Description") \
28 F (5, sys_name, "System name") \
29 F (6, sys_desc, "System Description") \
30 F (7, sys_caps, "System Capabilities") \
31 F (8, mgmt_addr, "Management Address") \
32 F (127, org_spec, "Organizationally Specific TLV")
37 #define foreach_lldp_tlv_type(F) \
38 F (0, pdu_end, "End of LLDPDU") \
39 F (1, chassis_id, "Chassis ID") \
40 F (2, port_id, "Port ID") \
41 F (3, ttl, "Time To Live") \
42 foreach_lldp_optional_tlv_type (F)
44 #define LLDP_TLV_NAME(t) LLDP_TLV_##t
48 #define F(n, t, s) LLDP_TLV_NAME (t) = n,
49 foreach_lldp_tlv_type (F)
55 u8 byte1; /* contains TLV code in the upper 7 bits + MSB of length */
56 u8 byte2; /* contains the lower bits of length */
60 typedef CLIB_PACKED (struct {
61 struct lldp_tlv_head head;
66 lldp_tlv_code_t lldp_tlv_get_code (const lldp_tlv_t * tlv);
67 void lldp_tlv_set_code (lldp_tlv_t * tlv, lldp_tlv_code_t code);
68 u16 lldp_tlv_get_length (const lldp_tlv_t * tlv);
69 void lldp_tlv_set_length (lldp_tlv_t * tlv, u16 length);
71 #define foreach_chassis_id_subtype(F) \
72 F (0, reserved, "Reserved") \
73 F (1, chassis_comp, "Chassis component") \
74 F (2, intf_alias, "Interface alias") \
75 F (3, port_comp, "Port component") \
76 F (4, mac_addr, "MAC address") \
77 F (5, net_addr, "Network address") \
78 F (6, intf_name, "Interface name") \
79 F (7, local, "Locally assigned")
81 #define LLDP_CHASS_ID_SUBTYPE_NAME(t) LLDP_CHASS_ID_SUBTYPE_##t
82 #define LLDP_MIN_CHASS_ID_LEN (1)
83 #define LLDP_MAX_CHASS_ID_LEN (255)
87 #define F(n, t, s) LLDP_CHASS_ID_SUBTYPE_NAME (t) = n,
88 foreach_chassis_id_subtype (F)
90 } lldp_chassis_id_subtype_t;
93 typedef CLIB_PACKED (struct {
94 struct lldp_tlv_head head;
97 }) lldp_chassis_id_tlv_t;
100 #define foreach_port_id_subtype(F) \
101 F (0, reserved, "Reserved") \
102 F (1, intf_alias, "Interface alias") \
103 F (2, port_comp, "Port component") \
104 F (3, mac_addr, "MAC address") \
105 F (4, net_addr, "Network address") \
106 F (5, intf_name, "Interface name") \
107 F (6, agent_circuit_id, "Agent circuit ID") \
108 F (7, local, "Locally assigned")
110 #define LLDP_PORT_ID_SUBTYPE_NAME(t) LLDP_PORT_ID_SUBTYPE_##t
111 #define LLDP_MIN_PORT_ID_LEN (1)
112 #define LLDP_MAX_PORT_ID_LEN (255)
116 #define F(n, t, s) LLDP_PORT_ID_SUBTYPE_NAME (t) = n,
117 foreach_port_id_subtype (F)
119 } lldp_port_id_subtype_t;
122 typedef CLIB_PACKED (struct {
123 struct lldp_tlv_head head;
126 }) lldp_port_id_tlv_t;
128 typedef CLIB_PACKED (struct {
129 struct lldp_tlv_head head;
134 #endif /* __included_lldp_protocol_h__ */
137 * fd.io coding-style-patch-verification: ON
140 * eval: (c-set-style "gnu")