misc: remove GNU Indent directives
[vpp.git] / src / plugins / lldp / lldp_protocol.h
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,
49   foreach_lldp_tlv_type (F)
50 #undef F
51 } lldp_tlv_code_t;
52
53 struct lldp_tlv_head
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 typedef CLIB_PACKED (struct {
60   struct lldp_tlv_head head;
61   u8 v[0];
62 }) lldp_tlv_t;
63
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);
68
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")
78
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)
82
83 typedef enum
84 {
85 #define F(n, t, s) LLDP_CHASS_ID_SUBTYPE_NAME (t) = n,
86   foreach_chassis_id_subtype (F)
87 #undef F
88 } lldp_chassis_id_subtype_t;
89
90 typedef CLIB_PACKED (struct {
91   struct lldp_tlv_head head;
92   u8 subtype;
93   u8 id[0];
94 }) lldp_chassis_id_tlv_t;
95
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")
105
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)
109
110 typedef enum
111 {
112 #define F(n, t, s) LLDP_PORT_ID_SUBTYPE_NAME (t) = n,
113   foreach_port_id_subtype (F)
114 #undef F
115 } lldp_port_id_subtype_t;
116
117 typedef CLIB_PACKED (struct {
118   struct lldp_tlv_head head;
119   u8 subtype;
120   u8 id[0];
121 }) lldp_port_id_tlv_t;
122
123 typedef CLIB_PACKED (struct {
124   struct lldp_tlv_head head;
125   u16 ttl;
126 }) lldp_ttl_tlv_t;
127
128 #endif /* __included_lldp_protocol_h__ */
129
130 /*
131  * fd.io coding-style-patch-verification: ON
132  *
133  * Local Variables:
134  * eval: (c-set-style "gnu")
135  * End:
136  */