FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
llc.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015 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
/*
16
* llc.h: LLC definitions
17
*
18
* Copyright (c) 2008 Eliot Dresselhaus
19
*
20
* Permission is hereby granted, free of charge, to any person obtaining
21
* a copy of this software and associated documentation files (the
22
* "Software"), to deal in the Software without restriction, including
23
* without limitation the rights to use, copy, modify, merge, publish,
24
* distribute, sublicense, and/or sell copies of the Software, and to
25
* permit persons to whom the Software is furnished to do so, subject to
26
* the following conditions:
27
*
28
* The above copyright notice and this permission notice shall be
29
* included in all copies or substantial portions of the Software.
30
*
31
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
35
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
36
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
37
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38
*/
39
40
#ifndef included_llc_h
41
#define included_llc_h
42
43
#include <
vnet/vnet.h
>
44
45
/* Protocol (SSAP/DSAP) types. */
46
#define foreach_llc_protocol \
47
_ (null, 0x0) \
48
_ (sublayer, 0x2) \
49
_ (sna_path_control, 0x4) \
50
_ (ip4, 0x6) \
51
_ (sna1, 0x8) \
52
_ (sna2, 0xc) \
53
_ (sna3, 0x40) \
54
_ (proway_lan, 0x0e) \
55
_ (netware1, 0x10) \
56
_ (netware2, 0xe0) \
57
_ (osi_layer1, 0x14) \
58
_ (osi_layer2, 0x20) \
59
_ (osi_layer3, 0x34) \
60
_ (osi_layer4, 0x54) \
61
_ (osi_layer5, 0xfe) \
62
_ (bpdu, 0x42) \
63
_ (arp, 0x98) \
64
_ (snap, 0xaa) \
65
_ (vines1, 0xba) \
66
_ (vines2, 0xbc) \
67
_ (netbios, 0xf0) \
68
_ (global_dsap, 0xff)
69
70
typedef
enum
71
{
72
#define _(f,n) LLC_PROTOCOL_##f = n,
73
foreach_llc_protocol
74
#undef _
75
}
llc_protocol_t
;
76
77
typedef
struct
78
{
79
#define LLC_DST_SAP_IS_GROUP (1 << 0)
80
#define LLC_SRC_SAP_IS_RESPONSE (1 << 0)
81
u8
dst_sap,
src_sap
;
82
83
/* Control byte.
84
[0] 1 => supervisory 0 => information
85
[1] unnumbered frame. */
86
u8
control
;
87
88
/* Only present if (control & 3) != 3. */
89
u8
extended_control[0];
90
}
llc_header_t
;
91
92
always_inline
u16
93
llc_header_get_control
(
llc_header_t
*
h
)
94
{
95
u16
r
=
h
->control;
96
return
r
| ((((
r
& 3) != 3) ?
h
->extended_control[0] : 0) << 8);
97
}
98
99
always_inline
u8
100
llc_header_length
(
llc_header_t
*
h
)
101
{
102
return
((
h
->control & 3) != 3 ? 4 : 3);
103
}
104
105
typedef
struct
106
{
107
/* Name (a c string). */
108
char
*
name
;
109
110
/* LLC protocol (SAP type). */
111
llc_protocol_t
protocol
;
112
113
/* Node which handles this type. */
114
u32
node_index
;
115
116
/* Next index for this type. */
117
u32
next_index
;
118
}
llc_protocol_info_t
;
119
120
#define foreach_llc_error \
121
_ (NONE, "no error") \
122
_ (UNKNOWN_PROTOCOL, "unknown llc ssap/dsap") \
123
_ (UNKNOWN_CONTROL, "control != 0x3")
124
125
typedef
enum
126
{
127
#define _(f,s) LLC_ERROR_##f,
128
foreach_llc_error
129
#undef _
130
LLC_N_ERROR
,
131
}
llc_error_t
;
132
133
typedef
struct
134
{
135
vlib_main_t
*
vlib_main
;
136
137
llc_protocol_info_t
*
protocol_infos
;
138
139
/* Hash tables mapping name/protocol to protocol info index. */
140
uword
*protocol_info_by_name, *
protocol_info_by_protocol
;
141
142
/* llc-input next index indexed by protocol. */
143
u8
input_next_by_protocol[256];
144
}
llc_main_t
;
145
146
always_inline
llc_protocol_info_t
*
147
llc_get_protocol_info
(
llc_main_t
* m,
llc_protocol_t
protocol
)
148
{
149
uword
*p =
hash_get
(m->
protocol_info_by_protocol
,
protocol
);
150
return
p ?
vec_elt_at_index
(m->
protocol_infos
, p[0]) : 0;
151
}
152
153
extern
llc_main_t
llc_main
;
154
155
/* Register given node index to take input for given llc type. */
156
void
157
llc_register_input_protocol
(
vlib_main_t
*
vm
,
158
llc_protocol_t
protocol
,
u32
node_index
);
159
160
format_function_t
format_llc_protocol
;
161
format_function_t
format_llc_header
;
162
format_function_t
format_llc_header_with_length
;
163
164
/* Parse llc protocol as 0xXXXX or protocol name. */
165
unformat_function_t
unformat_llc_protocol
;
166
167
/* Parse llc header. */
168
unformat_function_t
unformat_llc_header
;
169
unformat_function_t
unformat_pg_llc_header
;
170
171
#endif
/* included_llc_h */
172
173
/*
174
* fd.io coding-style-patch-verification: ON
175
*
176
* Local Variables:
177
* eval: (c-set-style "gnu")
178
* End:
179
*/
llc_header_length
static u8 llc_header_length(llc_header_t *h)
Definition:
llc.h:100
format_llc_header
format_function_t format_llc_header
Definition:
llc.h:161
llc_main_t
Definition:
llc.h:133
foreach_llc_error
#define foreach_llc_error
Definition:
llc.h:120
llc_header_get_control
static u16 llc_header_get_control(llc_header_t *h)
Definition:
llc.h:93
llc_main_t::protocol_infos
llc_protocol_info_t * protocol_infos
Definition:
llc.h:137
llc_get_protocol_info
static llc_protocol_info_t * llc_get_protocol_info(llc_main_t *m, llc_protocol_t protocol)
Definition:
llc.h:147
foreach_llc_protocol
#define foreach_llc_protocol
Definition:
llc.h:46
llc_header_t::control
u8 control
Definition:
llc.h:86
u16
unsigned short u16
Definition:
types.h:57
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition:
nat44_ei.c:3047
node_index
node node_index
Definition:
interface_output.c:440
llc_register_input_protocol
void llc_register_input_protocol(vlib_main_t *vm, llc_protocol_t protocol, u32 node_index)
Definition:
node.c:308
r
vnet_hw_if_output_node_runtime_t * r
Definition:
interface_output.c:1089
h
h
Definition:
flowhash_template.h:372
llc_protocol_info_t
Definition:
llc.h:105
format_llc_protocol
format_function_t format_llc_protocol
Definition:
llc.h:160
vec_elt_at_index
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Definition:
vec_bootstrap.h:203
llc_protocol_info_t::node_index
u32 node_index
Definition:
llc.h:114
format_llc_header_with_length
format_function_t format_llc_header_with_length
Definition:
llc.h:162
hash_get
#define hash_get(h, key)
Definition:
hash.h:249
llc_header_t
Definition:
llc.h:77
unformat_llc_header
unformat_function_t unformat_llc_header
Definition:
llc.h:168
uword
u64 uword
Definition:
types.h:112
unformat_llc_protocol
unformat_function_t unformat_llc_protocol
Definition:
llc.h:165
format_function_t
u8 *() format_function_t(u8 *s, va_list *args)
Definition:
format.h:48
LLC_N_ERROR
@ LLC_N_ERROR
Definition:
llc.h:130
always_inline
#define always_inline
Definition:
rdma_mlx5dv.h:23
llc_error_t
llc_error_t
Definition:
llc.h:125
llc_main_t::vlib_main
vlib_main_t * vlib_main
Definition:
llc.h:135
u32
unsigned int u32
Definition:
types.h:88
llc_main
llc_main_t llc_main
Definition:
llc.c:44
protocol
vl_api_ip_proto_t protocol
Definition:
lb_types.api:72
llc_main_t::protocol_info_by_protocol
uword * protocol_info_by_protocol
Definition:
llc.h:140
unformat_pg_llc_header
unformat_function_t unformat_pg_llc_header
Definition:
llc.h:169
unformat_function_t
uword() unformat_function_t(unformat_input_t *input, va_list *args)
Definition:
format.h:225
llc_protocol_info_t::protocol
llc_protocol_t protocol
Definition:
llc.h:111
vlib_main_t
Definition:
main.h:102
u8
unsigned char u8
Definition:
types.h:56
vnet.h
llc_header_t::src_sap
u8 src_sap
Definition:
llc.h:81
llc_protocol_info_t::name
char * name
Definition:
llc.h:108
llc_protocol_info_t::next_index
u32 next_index
Definition:
llc.h:117
llc_protocol_t
llc_protocol_t
Definition:
llc.h:70
src
vnet
llc
llc.h
Generated on Sat Jan 8 2022 10:36:49 for FD.io VPP by
1.8.17