FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
mfib_api.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 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/vnet.h>
17 #include <vlibmemory/api.h>
18 #include <vnet/mfib/mfib_api.h>
19 #include <vnet/mfib/mfib_table.h>
20 #include <vnet/fib/fib_api.h>
21 #include <vnet/ip/ip_types_api.h>
22 
23 static vl_api_mfib_itf_flags_t
25 {
26  vl_api_mfib_itf_flags_t out = MFIB_API_ITF_FLAG_NONE;
27 
28  switch (flags)
29  {
30  case MFIB_ITF_FLAG_NONE:
32  break;
35  break;
38  break;
41  break;
44  break;
47  break;
48  }
49  return (ntohl(out));
50 }
51 
52 void
54  vl_api_mfib_path_t *out)
55 {
56  out->itf_flags = mfib_api_path_itf_flags_encode(in->frp_mitf_flags);
57 
58  fib_api_path_encode(in, &out->path);
59 }
60 
61 static void
62 mfib_api_path_itf_flags_decode (vl_api_mfib_itf_flags_t in,
63  mfib_itf_flags_t *out)
64 {
65  in = clib_net_to_host_u32(in);
66 
69  if (in & MFIB_API_ITF_FLAG_ACCEPT)
70  *out |= MFIB_ITF_FLAG_ACCEPT;
72  *out |= MFIB_ITF_FLAG_FORWARD;
77 }
78 
80 mfib_api_path_entry_flags_decode (vl_api_mfib_entry_flags_t in)
81 {
83 
85  in = clib_net_to_host_u32(in);
86 
89  if (in & MFIB_API_ENTRY_FLAG_DROP)
90  out |= MFIB_ENTRY_FLAG_DROP;
95 
96  return (out);
97 }
98 
99 int
100 mfib_api_path_decode (vl_api_mfib_path_t *in,
101  fib_route_path_t *out)
102 {
103  mfib_api_path_itf_flags_decode(in->itf_flags, &out->frp_mitf_flags);
104 
105  return (fib_api_path_decode(&in->path, out));
106 }
107 
108 int
110  u32 table_id,
111  u32 *fib_index)
112 {
113  *fib_index = mfib_table_find(fproto, table_id);
114 
115  if (INDEX_INVALID == *fib_index)
116  {
117  return VNET_API_ERROR_NO_SUCH_FIB;
118  }
119 
120  return (0);
121 }
MFIB_API_ITF_FLAG_FORWARD
@ MFIB_API_ITF_FLAG_FORWARD
Definition: mfib_types.api:34
api.h
MFIB_ENTRY_FLAG_NONE
@ MFIB_ENTRY_FLAG_NONE
Definition: mfib_types.h:107
fib_route_path_t_::frp_mitf_flags
u32 frp_mitf_flags
MFIB interface flags.
Definition: fib_types.h:568
mfib_api_path_entry_flags_decode
mfib_entry_flags_t mfib_api_path_entry_flags_decode(vl_api_mfib_entry_flags_t in)
Definition: mfib_api.c:80
MFIB_API_ITF_FLAG_NONE
@ MFIB_API_ITF_FLAG_NONE
Definition: mfib_types.api:31
MFIB_ITF_FLAG_ACCEPT
@ MFIB_ITF_FLAG_ACCEPT
Definition: mfib_types.h:152
mfib_api_path_decode
int mfib_api_path_decode(vl_api_mfib_path_t *in, fib_route_path_t *out)
Definition: mfib_api.c:100
MFIB_ITF_FLAG_NONE
@ MFIB_ITF_FLAG_NONE
Definition: mfib_types.h:150
MFIB_API_ENTRY_FLAG_ACCEPT_ALL_ITF
@ MFIB_API_ENTRY_FLAG_ACCEPT_ALL_ITF
Definition: mfib_types.api:26
mfib_entry_flags_t
enum mfib_entry_flags_t_ mfib_entry_flags_t
mfib_api_path_itf_flags_decode
static void mfib_api_path_itf_flags_decode(vl_api_mfib_itf_flags_t in, mfib_itf_flags_t *out)
Definition: mfib_api.c:62
MFIB_API_ITF_FLAG_SIGNAL_PRESENT
@ MFIB_API_ITF_FLAG_SIGNAL_PRESENT
Definition: mfib_types.api:35
fib_api_path_encode
void fib_api_path_encode(const fib_route_path_t *rpath, vl_api_fib_path_t *out)
Encode and decode functions from the API types to internal types.
Definition: fib_api.c:349
MFIB_ENTRY_FLAG_SIGNAL
@ MFIB_ENTRY_FLAG_SIGNAL
Definition: mfib_types.h:108
mfib_api_table_id_decode
int mfib_api_table_id_decode(fib_protocol_t fproto, u32 table_id, u32 *fib_index)
Definition: mfib_api.c:109
mfib_itf_flags_t
enum mfib_itf_flags_t_ mfib_itf_flags_t
fib_protocol_t
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
MFIB_API_ITF_FLAG_ACCEPT
@ MFIB_API_ITF_FLAG_ACCEPT
Definition: mfib_types.api:33
mfib_table.h
MFIB_ENTRY_FLAG_ACCEPT_ALL_ITF
@ MFIB_ENTRY_FLAG_ACCEPT_ALL_ITF
Definition: mfib_types.h:111
fib_api.h
mfib_api_path_encode
void mfib_api_path_encode(const fib_route_path_t *in, vl_api_mfib_path_t *out)
Encode and decode functions from the API types to internal types.
Definition: mfib_api.c:53
MFIB_ITF_FLAG_DONT_PRESERVE
@ MFIB_ITF_FLAG_DONT_PRESERVE
Definition: mfib_types.h:155
MFIB_API_ENTRY_FLAG_CONNECTED
@ MFIB_API_ENTRY_FLAG_CONNECTED
Definition: mfib_types.api:25
mfib_table_find
u32 mfib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
Definition: mfib_table.c:555
u32
unsigned int u32
Definition: types.h:88
MFIB_API_ENTRY_FLAG_DROP
@ MFIB_API_ENTRY_FLAG_DROP
Definition: mfib_types.api:24
table_id
u32 table_id
Definition: wireguard.api:102
fib_route_path_t_
A representation of a path as described by a route producer.
Definition: fib_types.h:500
MFIB_ITF_FLAG_SIGNAL_PRESENT
@ MFIB_ITF_FLAG_SIGNAL_PRESENT
Definition: mfib_types.h:154
MFIB_API_ITF_FLAG_NEGATE_SIGNAL
@ MFIB_API_ITF_FLAG_NEGATE_SIGNAL
Definition: mfib_types.api:32
MFIB_ENTRY_FLAG_DROP
@ MFIB_ENTRY_FLAG_DROP
Definition: mfib_types.h:109
MFIB_API_ENTRY_FLAG_SIGNAL
@ MFIB_API_ENTRY_FLAG_SIGNAL
Definition: mfib_types.api:23
MFIB_API_ITF_FLAG_DONT_PRESERVE
@ MFIB_API_ITF_FLAG_DONT_PRESERVE
Definition: mfib_types.api:36
MFIB_ITF_FLAG_FORWARD
@ MFIB_ITF_FLAG_FORWARD
Definition: mfib_types.h:153
mfib_api.h
vnet.h
INDEX_INVALID
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
Definition: dpo.h:49
fib_api_path_decode
int fib_api_path_decode(vl_api_fib_path_t *in, fib_route_path_t *out)
Definition: fib_api.c:141
ip_types_api.h
mfib_api_path_itf_flags_encode
static vl_api_mfib_itf_flags_t mfib_api_path_itf_flags_encode(mfib_itf_flags_t flags)
Definition: mfib_api.c:24
MFIB_ENTRY_FLAG_CONNECTED
@ MFIB_ENTRY_FLAG_CONNECTED
Definition: mfib_types.h:110
MFIB_ITF_FLAG_NEGATE_SIGNAL
@ MFIB_ITF_FLAG_NEGATE_SIGNAL
Definition: mfib_types.h:151
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105