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 * srp/packet.h: srp packet format.
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_srp_packet_h
41 #define included_srp_packet_h
43 #include <vppinfra/byte_order.h>
44 #include <vppinfra/bitops.h>
45 #include <vnet/ethernet/packet.h>
49 #define foreach_srp_mode \
54 _ (control_pass_to_host) \
55 _ (control_locally_buffered_for_host) \
60 #define _(f) SRP_MODE_##f,
67 /* For computing parity bit. */
73 #if CLIB_ARCH_IS_BIG_ENDIAN
79 #if CLIB_ARCH_IS_LITTLE_ENDIAN
89 srp_header_compute_parity (srp_header_t * h)
92 h->parity = count_set_bits (h->as_u16) ^ 1; /* odd parity */
97 ethernet_header_t ethernet;
98 } srp_and_ethernet_header_t;
100 #define foreach_srp_control_packet_type \
106 #define _(f) SRP_CONTROL_PACKET_TYPE_##f,
107 foreach_srp_control_packet_type
109 SRP_N_CONTROL_PACKET_TYPE,
110 } srp_control_packet_type_t;
112 typedef CLIB_PACKED (struct {
116 srp_control_packet_type_t type : 8;
118 /* IP4-like checksum of packet starting with start of control header. */
122 }) srp_control_header_t;
126 ethernet_header_t ethernet;
127 srp_control_header_t control;
128 } srp_generic_control_header_t;
132 #define SRP_TOPOLOGY_MAC_BINDING_FLAG_IS_INNER_RING (1 << 6)
133 #define SRP_TOPOLOGY_MAC_BINDING_FLAG_IS_WRAPPED (1 << 5)
137 } srp_topology_mac_binding_t;
139 typedef CLIB_PACKED (struct {
141 ethernet_header_t ethernet;
142 srp_control_header_t control;
144 /* Length in bytes of data that follows. */
145 u16 n_bytes_of_data_that_follows;
147 /* MAC address of originator of this topology request. */
148 u8 originator_address[6];
150 /* Bindings follow. */
151 srp_topology_mac_binding_t bindings[0];
152 }) srp_topology_header_t;
154 #define foreach_srp_ips_request_type \
156 _ (wait_to_restore, 0x5) \
157 _ (manual_switch, 0x6) \
158 _ (signal_degrade, 0x8) \
159 _ (signal_fail, 0xb) \
160 _ (forced_switch, 0xd)
163 #define _(f,n) SRP_IPS_REQUEST_##f = n,
164 foreach_srp_ips_request_type
166 } srp_ips_request_type_t;
168 #define foreach_srp_ips_status \
173 #define _(f,n) SRP_IPS_STATUS_##f = n,
174 foreach_srp_ips_status
180 ethernet_header_t ethernet;
181 srp_control_header_t control;
182 u8 originator_address[6];
188 #if CLIB_ARCH_IS_BIG_ENDIAN
193 #if CLIB_ARCH_IS_LITTLE_ENDIAN
204 #endif /* included_srp_packet_h */