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/clib.h>
44 #include <vnet/ethernet/packet.h>
48 #define foreach_srp_mode \
53 _ (control_pass_to_host) \
54 _ (control_locally_buffered_for_host) \
59 #define _(f) SRP_MODE_##f,
66 /* For computing parity bit. */
72 #if CLIB_ARCH_IS_BIG_ENDIAN
78 #if CLIB_ARCH_IS_LITTLE_ENDIAN
88 srp_header_compute_parity (srp_header_t * h)
91 h->parity = count_set_bits (h->as_u16) ^ 1; /* odd parity */
96 ethernet_header_t ethernet;
97 } srp_and_ethernet_header_t;
99 #define foreach_srp_control_packet_type \
105 #define _(f) SRP_CONTROL_PACKET_TYPE_##f,
106 foreach_srp_control_packet_type
108 SRP_N_CONTROL_PACKET_TYPE,
109 } srp_control_packet_type_t;
111 typedef CLIB_PACKED (struct {
115 srp_control_packet_type_t type : 8;
117 /* IP4-like checksum of packet starting with start of control header. */
121 }) srp_control_header_t;
125 ethernet_header_t ethernet;
126 srp_control_header_t control;
127 } srp_generic_control_header_t;
131 #define SRP_TOPOLOGY_MAC_BINDING_FLAG_IS_INNER_RING (1 << 6)
132 #define SRP_TOPOLOGY_MAC_BINDING_FLAG_IS_WRAPPED (1 << 5)
136 } srp_topology_mac_binding_t;
138 typedef CLIB_PACKED (struct {
140 ethernet_header_t ethernet;
141 srp_control_header_t control;
143 /* Length in bytes of data that follows. */
144 u16 n_bytes_of_data_that_follows;
146 /* MAC address of originator of this topology request. */
147 u8 originator_address[6];
149 /* Bindings follow. */
150 srp_topology_mac_binding_t bindings[0];
151 }) srp_topology_header_t;
153 #define foreach_srp_ips_request_type \
155 _ (wait_to_restore, 0x5) \
156 _ (manual_switch, 0x6) \
157 _ (signal_degrade, 0x8) \
158 _ (signal_fail, 0xb) \
159 _ (forced_switch, 0xd)
162 #define _(f,n) SRP_IPS_REQUEST_##f = n,
163 foreach_srp_ips_request_type
165 } srp_ips_request_type_t;
167 #define foreach_srp_ips_status \
172 #define _(f,n) SRP_IPS_STATUS_##f = n,
173 foreach_srp_ips_status
179 ethernet_header_t ethernet;
180 srp_control_header_t control;
181 u8 originator_address[6];
187 #if CLIB_ARCH_IS_BIG_ENDIAN
192 #if CLIB_ARCH_IS_LITTLE_ENDIAN
203 #endif /* included_srp_packet_h */