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 */
59 typedef CLIB_PACKED (struct {
60 struct lldp_tlv_head head;
64 lldp_tlv_code_t lldp_tlv_get_code (const lldp_tlv_t * tlv);
65 void lldp_tlv_set_code (lldp_tlv_t * tlv, lldp_tlv_code_t code);
66 u16 lldp_tlv_get_length (const lldp_tlv_t * tlv);
67 void lldp_tlv_set_length (lldp_tlv_t * tlv, u16 length);
69 #define foreach_chassis_id_subtype(F) \
70 F (0, reserved, "Reserved") \
71 F (1, chassis_comp, "Chassis component") \
72 F (2, intf_alias, "Interface alias") \
73 F (3, port_comp, "Port component") \
74 F (4, mac_addr, "MAC address") \
75 F (5, net_addr, "Network address") \
76 F (6, intf_name, "Interface name") \
77 F (7, local, "Locally assigned")
79 #define LLDP_CHASS_ID_SUBTYPE_NAME(t) LLDP_CHASS_ID_SUBTYPE_##t
80 #define LLDP_MIN_CHASS_ID_LEN (1)
81 #define LLDP_MAX_CHASS_ID_LEN (255)
85 #define F(n, t, s) LLDP_CHASS_ID_SUBTYPE_NAME (t) = n,
86 foreach_chassis_id_subtype (F)
88 } lldp_chassis_id_subtype_t;
90 typedef CLIB_PACKED (struct {
91 struct lldp_tlv_head head;
94 }) lldp_chassis_id_tlv_t;
96 #define foreach_port_id_subtype(F) \
97 F (0, reserved, "Reserved") \
98 F (1, intf_alias, "Interface alias") \
99 F (2, port_comp, "Port component") \
100 F (3, mac_addr, "MAC address") \
101 F (4, net_addr, "Network address") \
102 F (5, intf_name, "Interface name") \
103 F (6, agent_circuit_id, "Agent circuit ID") \
104 F (7, local, "Locally assigned")
106 #define LLDP_PORT_ID_SUBTYPE_NAME(t) LLDP_PORT_ID_SUBTYPE_##t
107 #define LLDP_MIN_PORT_ID_LEN (1)
108 #define LLDP_MAX_PORT_ID_LEN (255)
112 #define F(n, t, s) LLDP_PORT_ID_SUBTYPE_NAME (t) = n,
113 foreach_port_id_subtype (F)
115 } lldp_port_id_subtype_t;
117 typedef CLIB_PACKED (struct {
118 struct lldp_tlv_head head;
121 }) lldp_port_id_tlv_t;
123 typedef CLIB_PACKED (struct {
124 struct lldp_tlv_head head;
128 #endif /* __included_lldp_protocol_h__ */
131 * fd.io coding-style-patch-verification: ON
134 * eval: (c-set-style "gnu")