FD.io VPP  v18.07-rc0-415-g6c78436
Vector Packet Processing
lldp_protocol.h
Go to the documentation of this file.
1 /*
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:
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_lldp_protocol_h__
16 #define __included_lldp_protocol_h__
17 /**
18  * @file
19  * @brief LLDP protocol declarations
20  */
21 #include <vnet/srp/packet.h>
22 
23 /*
24  * optional TLV codes.
25  */
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")
33 
34 /*
35  * all TLV codes.
36  */
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)
43 
44 #define LLDP_TLV_NAME(t) LLDP_TLV_##t
45 
46 typedef enum
47 {
48 #define F(n, t, s) LLDP_TLV_NAME (t) = n,
50 #undef F
52 
54 {
55  u8 byte1; /* contains TLV code in the upper 7 bits + MSB of length */
56  u8 byte2; /* contains the lower bits of length */
57 };
58 
59 /* *INDENT-OFF* */
60 typedef CLIB_PACKED (struct {
61  struct lldp_tlv_head head;
62  u8 v[0];
63 }) lldp_tlv_t;
64 /* *INDENT-ON* */
65 
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);
70 
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")
80 
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)
84 
85 typedef enum
86 {
87 #define F(n, t, s) LLDP_CHASS_ID_SUBTYPE_NAME (t) = n,
89 #undef F
91 
92 /* *INDENT-OFF* */
93 typedef CLIB_PACKED (struct {
94  struct lldp_tlv_head head;
95  u8 subtype;
96  u8 id[0];
97 }) lldp_chassis_id_tlv_t;
98 /* *INDENT-ON* */
99 
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")
109 
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)
113 
114 typedef enum
115 {
116 #define F(n, t, s) LLDP_PORT_ID_SUBTYPE_NAME (t) = n,
118 #undef F
120 
121 /* *INDENT-OFF* */
122 typedef CLIB_PACKED (struct {
123  struct lldp_tlv_head head;
124  u8 subtype;
125  u8 id[0];
126 }) lldp_port_id_tlv_t;
127 
128 typedef CLIB_PACKED (struct {
129  struct lldp_tlv_head head;
130  u16 ttl;
131 }) lldp_ttl_tlv_t;
132 /* *INDENT-ON* */
133 
134 #endif /* __included_lldp_protocol_h__ */
135 
136 /*
137  * fd.io coding-style-patch-verification: ON
138  *
139  * Local Variables:
140  * eval: (c-set-style "gnu")
141  * End:
142  */
lldp_chassis_id_subtype_t
Definition: lldp_protocol.h:85
#define foreach_lldp_tlv_type(F)
Definition: lldp_protocol.h:37
lldp_tlv_code_t lldp_tlv_get_code(const lldp_tlv_t *tlv)
Definition: lldp_input.c:86
unsigned char u8
Definition: types.h:56
typedef CLIB_PACKED(struct{struct lldp_tlv_head head;u8 v[0];}) lldp_tlv_t
#define v
Definition: acl.c:491
unsigned short u16
Definition: types.h:57
void lldp_tlv_set_code(lldp_tlv_t *tlv, lldp_tlv_code_t code)
Definition: lldp_input.c:92
#define foreach_port_id_subtype(F)
u16 lldp_tlv_get_length(const lldp_tlv_t *tlv)
Definition: lldp_input.c:98
lldp_port_id_subtype_t
#define foreach_chassis_id_subtype(F)
Definition: lldp_protocol.h:71
#define F(n, t, s)
lldp_tlv_code_t
Definition: lldp_protocol.h:46
void lldp_tlv_set_length(lldp_tlv_t *tlv, u16 length)
Definition: lldp_input.c:104