FD.io VPP  v17.01.1-3-gc6833f8
Vector Packet Processing
adj_rewrite.c
Go to the documentation of this file.
1 /*
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 #include <vnet/adj/adj.h>
17 #include <vnet/adj/adj_internal.h>
18 
19 /**
20  * adj_rewrite_add_and_lock
21  *
22  * A rewrite sub-type has the rewrite string provided, but no key
23  */
26  vnet_link_t link_type,
27  u32 sw_if_index,
28  u8 *rewrite)
29 {
30  ip_adjacency_t *adj;
31 
32  adj = adj_alloc(nh_proto);
33 
35  memset(&adj->sub_type.nbr.next_hop, 0, sizeof(adj->sub_type.nbr.next_hop));
36  adj->ia_link = link_type;
37  adj->ia_nh_proto = nh_proto;
38  adj->rewrite_header.sw_if_index = sw_if_index;
39 
40  ASSERT(NULL != rewrite);
41 
43  link_type,
44  adj->rewrite_header.sw_if_index,
45  adj_get_rewrite_node(link_type),
46  rewrite,
47  &adj->rewrite_header,
48  sizeof (adj->rewrite_data));
49 
50  adj_lock(adj_get_index(adj));
51 
52  return (adj_get_index(adj));
53 }
void adj_lock(adj_index_t adj_index)
An adjacency is a representation of an attached L3 peer.
Definition: adj.c:192
adj_index_t adj_rewrite_add_and_lock(fib_protocol_t nh_proto, vnet_link_t link_type, u32 sw_if_index, u8 *rewrite)
adj_rewrite_add_and_lock
Definition: adj_rewrite.c:25
#define NULL
Definition: clib.h:55
IP unicast adjacency.
Definition: lookup.h:188
void vnet_rewrite_for_sw_interface(vnet_main_t *vnm, vnet_link_t link_type, u32 sw_if_index, u32 node_index, void *dst_address, vnet_rewrite_header_t *rw, u32 max_rewrite_bytes)
Deprecated.
Definition: rewrite.c:207
union ip_adjacency_t_::@175 sub_type
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
vnet_link_t ia_link
Definition: lookup.h:215
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
static adj_index_t adj_get_index(ip_adjacency_t *adj)
Get a pointer to an adjacency object from its index.
Definition: adj_internal.h:83
struct ip_adjacency_t_::@175::@176 nbr
IP_LOOKUP_NEXT_ARP/IP_LOOKUP_NEXT_REWRITE.
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
static u32 adj_get_rewrite_node(vnet_link_t linkt)
Definition: adj_internal.h:45
unsigned char u8
Definition: types.h:56
ip_lookup_next_t lookup_next_index
Definition: lookup.h:199
ip_adjacency_t * adj_alloc(fib_protocol_t proto)
Definition: adj.c:47
This packet is to be rewritten and forwarded to the next processing node.
Definition: lookup.h:83