blob: 55e2ec03d090997f20c5bcf6d41ab7538f65ee15 [file] [log] [blame]
Neale Ranns32e1c012016-11-22 17:07:28 +00001/*
2 * Copyright (c) 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
16/**
17 * @brief Mcast Adjacency
18 *
19 * The multicast adjacency forwards IP traffic on an interface toward a multicast
20 * group address. This is a different type of adjacency to a unicast adjacency
21 * since the application of the MAC header is different, and so the VLIB node
22 * visited is also different. DPO types have different VLIB nodes.
23 */
24
25#ifndef __ADJ_MCAST_H__
26#define __ADJ_MCAST_H__
27
28#include <vnet/adj/adj_types.h>
Neale Ranns0f26c5a2017-03-01 15:12:11 -080029#include <vnet/adj/adj_midchain.h>
Neale Ranns32e1c012016-11-22 17:07:28 +000030
31/**
32 * @brief
33 * Add (and lock) a new or lock an existing mcast adjacency
34 *
35 * @param proto
36 * The protocol for the neighbours that we wish to mcast
37 *
38 * @param link_type
39 * A description of the protocol of the packets that will forward
40 * through this adj. On an ethernet interface this is the MAC header's
41 * ether-type
42 *
43 * @param sw_if_index
44 * The interface on which to mcast
45 */
46extern adj_index_t adj_mcast_add_or_lock(fib_protocol_t proto,
47 vnet_link_t link_type,
48 u32 sw_if_index);
49
50/**
51 * @brief
52 * Update the rewrite string for an existing adjacecny.
53 *
54 * @param
55 * The index of the adj to update
56 *
57 * @param
58 * The new rewrite
Neale Ranns2e7fbcc2017-03-15 04:22:25 -070059 *
60 * @param
61 * The offset in the rewrite a which to write in packet's
62 * IP Address
63 *
64 * @param
65 * The mask to apply to the packet berfore the rewrite.
Neale Ranns32e1c012016-11-22 17:07:28 +000066 */
67extern void adj_mcast_update_rewrite(adj_index_t adj_index,
Neale Ranns2e7fbcc2017-03-15 04:22:25 -070068 u8 *rewrite,
69 u8 offset,
70 u32 mask);
Neale Ranns32e1c012016-11-22 17:07:28 +000071
72/**
Neale Ranns0f26c5a2017-03-01 15:12:11 -080073 * @brief
74 * Update the rewrite string for an existing adjacecny and
75 * Convert the adjacency into a midchain
76 *
77 * @param
78 * The index of the adj to update
79 *
Neale Rannsdb14f5a2018-01-29 10:43:33 -080080 * @param fixup
81 * The function that will be invoked at paket switch time to 'fixup'
82 * the rewrite applied with necessary per-packet info (i.e. length, checksums).
83 * @param fixup_data
84 * Context data set by the caller that is provided as an argument in the
85 * fixup function.
86 *
87 * @param flags
88 * Flags controlling the adjacency behaviour
89 *
Neale Ranns0f26c5a2017-03-01 15:12:11 -080090 * @param
91 * The new rewrite
92 */
93extern void adj_mcast_midchain_update_rewrite(adj_index_t adj_index,
94 adj_midchain_fixup_t fixup,
Neale Rannsdb14f5a2018-01-29 10:43:33 -080095 const void *fixup_data,
Neale Ranns0f26c5a2017-03-01 15:12:11 -080096 adj_flags_t flags,
97 u8 *rewrite,
98 u8 offset,
99 u32 mask);
100/**
101 * @brief Walk the multicast Adjacencies on a given interface
102 */
103extern void adj_mcast_walk (u32 sw_if_index,
104 fib_protocol_t adj_nh_proto,
105 adj_walk_cb_t cb,
106 void *ctx);
107
108/**
Neale Ranns32e1c012016-11-22 17:07:28 +0000109 * @brief Format/display a mcast adjacency.
110 */
111extern u8* format_adj_mcast(u8* s, va_list *ap);
Neale Ranns0f26c5a2017-03-01 15:12:11 -0800112extern u8* format_adj_mcast_midchain(u8* s, va_list *ap);
Neale Ranns32e1c012016-11-22 17:07:28 +0000113
114/**
115 * @brief Get the sze of the mcast adj DB. Test purposes only.
116 */
117extern u32 adj_mcast_db_size(void);
118
119/**
120 * @brief
121 * Module initialisation
122 */
123extern void adj_mcast_module_init(void);
124
125#endif