FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
ip_neighbor_types.c
Go to the documentation of this file.
1 /*
2  * ip_neighboor.h: ip neighbor generic services
3  *
4  * Copyright (c) 2018 Cisco and/or its affiliates.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
19 
20 void
22 {
23  clib_memcpy (clone, ipn, sizeof (*ipn));
24 
25  clone->ipn_key = clib_mem_alloc (sizeof (ip_neighbor_key_t));
26  clib_memcpy (clone->ipn_key, ipn->ipn_key, sizeof (ip_neighbor_key_t));
27 }
28 
29 void
31 {
32  clib_mem_free (ipn->ipn_key);
33 }
34 
35 u8 *
36 format_ip_neighbor_flags (u8 * s, va_list * args)
37 {
38  ip_neighbor_flags_t flags = va_arg (*args, int);
39 
40 #define _(a,b,c,d) \
41  if (flags & IP_NEIGHBOR_FLAG_##a) \
42  s = format (s, "%s", d);
44 #undef _
45  return s;
46 }
47 
48 u8 *
49 format_ip_neighbor_key (u8 * s, va_list * va)
50 {
51  ip_neighbor_key_t *key = va_arg (*va, ip_neighbor_key_t *);
52 
53  return (format (s, "[%U, %U]",
55  key->ipnk_sw_if_index, format_ip_address, &key->ipnk_ip));
56 }
57 
58 u8 *
59 format_ip_neighbor_watcher (u8 * s, va_list * va)
60 {
61  ip_neighbor_watcher_t *watcher = va_arg (*va, ip_neighbor_watcher_t *);
62 
63  return (format (s, "[pid:%d, client:%d]",
64  clib_host_to_net_u32 (watcher->ipw_pid),
65  clib_host_to_net_u32 (watcher->ipw_client)));
66 }
67 
68 u8 *
69 format_ip_neighbor (u8 * s, va_list * va)
70 {
71  index_t ipni = va_arg (*va, index_t);
72  ip_neighbor_t *ipn;
73 
74  ipn = ip_neighbor_get (ipni);
75 
76  return (format (s, "%=12U%=40U%=6U%=20U%U",
83  ipn->ipn_key->ipnk_sw_if_index));
84 }
85 
86 /*
87  * fd.io coding-style-patch-verification: ON
88  *
89  * Local Variables:
90  * eval: (c-set-style "gnu")
91  * End:
92  */
ip_neighbor_t_
A representation of an IP neighbour/peer.
Definition: ip_neighbor_types.h:59
ip_neighbor_free
void ip_neighbor_free(ip_neighbor_t *ipn)
Definition: ip_neighbor_types.c:30
clib_memcpy
#define clib_memcpy(d, s, n)
Definition: string.h:197
ip_neighbor_get
ip_neighbor_t * ip_neighbor_get(index_t ipni)
Definition: ip_neighbor.c:89
clib_mem_free
static void clib_mem_free(void *p)
Definition: mem.h:314
ip_neighbor_watcher_t_
Definition: ip_neighbor_types.h:40
ip_neighbor_clone
void ip_neighbor_clone(const ip_neighbor_t *ipn, ip_neighbor_t *clone)
Definition: ip_neighbor_types.c:21
format_ip_neighbor
u8 * format_ip_neighbor(u8 *s, va_list *va)
Definition: ip_neighbor_types.c:69
format_ip_neighbor_key
u8 * format_ip_neighbor_key(u8 *s, va_list *va)
Definition: ip_neighbor_types.c:49
ip_neighbor_types.h
key
typedef key
Definition: ipsec_types.api:91
ip_neighbor_t_::ipn_flags
ip_neighbor_flags_t ipn_flags
Falgs for this object.
Definition: ip_neighbor_types.h:74
ip_neighbor_watcher_t_::ipw_client
u32 ipw_client
Definition: ip_neighbor_types.h:43
ip_neighbor_key_t_
Definition: ip_neighbor_types.h:49
format_vlib_time
format_function_t format_vlib_time
Definition: node_funcs.h:1239
ip_neighbor_t_::ipn_key
ip_neighbor_key_t * ipn_key
The idempotent key.
Definition: ip_neighbor_types.h:64
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
format_mac_address_t
u8 * format_mac_address_t(u8 *s, va_list *args)
Definition: mac_address.c:27
index_t
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
Definition: dpo.h:43
format_ip_address
u8 * format_ip_address(u8 *s, va_list *args)
Definition: ip_types.c:21
ip_neighbor_key_t_::ipnk_ip
ip_address_t ipnk_ip
Definition: ip_neighbor_types.h:51
ip_neighbor_t_::ipn_time_last_updated
f64 ipn_time_last_updated
Aging related data.
Definition: ip_neighbor_types.h:81
foreach_ip_neighbor_flag
@ foreach_ip_neighbor_flag
Definition: ip_neighbor_types.h:36
ip_neighbor_watcher_t_::ipw_pid
u32 ipw_pid
Definition: ip_neighbor_types.h:42
format_vnet_sw_if_index_name
format_function_t format_vnet_sw_if_index_name
Definition: interface_funcs.h:458
ip_neighbor_flags_t
enum ip_neighbor_flags_t_ ip_neighbor_flags_t
format
description fragment has unexpected format
Definition: map.api:433
format_ip_neighbor_watcher
u8 * format_ip_neighbor_watcher(u8 *s, va_list *va)
Definition: ip_neighbor_types.c:59
format_ip_neighbor_flags
u8 * format_ip_neighbor_flags(u8 *s, va_list *args)
Definition: ip_neighbor_types.c:36
vlib_get_main
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:38
u8
unsigned char u8
Definition: types.h:56
ip_neighbor_key_t_::ipnk_sw_if_index
u32 ipnk_sw_if_index
Definition: ip_neighbor_types.h:53
ip_neighbor_t_::ipn_mac
mac_address_t ipn_mac
The learned MAC address of the neighbour.
Definition: ip_neighbor_types.h:69
clib_mem_alloc
static void * clib_mem_alloc(uword size)
Definition: mem.h:256
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105