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:
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.
16 * llc.h: LLC definitions
18 * Copyright (c) 2008 Eliot Dresselhaus
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:
28 * The above copyright notice and this permission notice shall be
29 * included in all copies or substantial portions of the Software.
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.
40 #ifndef included_llc_h
41 #define included_llc_h
43 #include <vnet/vnet.h>
45 /* Protocol (SSAP/DSAP) types. */
46 #define foreach_llc_protocol \
49 _ (sna_path_control, 0x4) \
54 _ (proway_lan, 0x0e) \
57 _ (osi_layer1, 0x14) \
58 _ (osi_layer2, 0x20) \
59 _ (osi_layer3, 0x34) \
60 _ (osi_layer4, 0x54) \
61 _ (osi_layer5, 0xfe) \
72 #define _(f,n) LLC_PROTOCOL_##f = n,
79 #define LLC_DST_SAP_IS_GROUP (1 << 0)
80 #define LLC_SRC_SAP_IS_RESPONSE (1 << 0)
84 [0] 1 => supervisory 0 => information
85 [1] unnumbered frame. */
88 /* Only present if (control & 3) != 3. */
89 u8 extended_control[0];
93 llc_header_get_control (llc_header_t * h)
96 return r | ((((r & 3) != 3) ? h->extended_control[0] : 0) << 8);
100 llc_header_length (llc_header_t * h)
102 return ((h->control & 3) != 3 ? 4 : 3);
107 /* Name (a c string). */
110 /* LLC protocol (SAP type). */
111 llc_protocol_t protocol;
113 /* Node which handles this type. */
116 /* Next index for this type. */
118 } llc_protocol_info_t;
120 #define foreach_llc_error \
121 _ (NONE, "no error") \
122 _ (UNKNOWN_PROTOCOL, "unknown llc ssap/dsap") \
123 _ (UNKNOWN_CONTROL, "control != 0x3")
127 #define _(f,s) LLC_ERROR_##f,
135 vlib_main_t *vlib_main;
137 llc_protocol_info_t *protocol_infos;
139 /* Hash tables mapping name/protocol to protocol info index. */
140 uword *protocol_info_by_name, *protocol_info_by_protocol;
142 /* llc-input next index indexed by protocol. */
143 u8 input_next_by_protocol[256];
146 always_inline llc_protocol_info_t *
147 llc_get_protocol_info (llc_main_t * m, llc_protocol_t protocol)
149 uword *p = hash_get (m->protocol_info_by_protocol, protocol);
150 return p ? vec_elt_at_index (m->protocol_infos, p[0]) : 0;
153 extern llc_main_t llc_main;
155 /* Register given node index to take input for given llc type. */
157 llc_register_input_protocol (vlib_main_t * vm,
158 llc_protocol_t protocol, u32 node_index);
160 format_function_t format_llc_protocol;
161 format_function_t format_llc_header;
162 format_function_t format_llc_header_with_length;
164 /* Parse llc protocol as 0xXXXX or protocol name. */
165 unformat_function_t unformat_llc_protocol;
167 /* Parse llc header. */
168 unformat_function_t unformat_llc_header;
169 unformat_function_t unformat_pg_llc_header;
171 #endif /* included_llc_h */
174 * fd.io coding-style-patch-verification: ON
177 * eval: (c-set-style "gnu")