FD.io VPP  v18.07-rc0-415-g6c78436
Vector Packet Processing
mactime.h
Go to the documentation of this file.
1 
2 /*
3  * mactime.h - time-based src mac address filtration
4  *
5  * Copyright (c) <current-year> <your-organization>
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at:
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 #ifndef __included_mactime_h__
19 #define __included_mactime_h__
20 
21 #include <vnet/vnet.h>
22 #include <vnet/ip/ip.h>
23 #include <vnet/ethernet/ethernet.h>
25 #include <vlib/counter.h>
26 
27 #include <vppinfra/hash.h>
28 #include <vppinfra/error.h>
29 #include <vppinfra/time_range.h>
30 #include <vppinfra/bihash_8_8.h>
31 
32 #define MACTIME_RANGE_TYPE_DROP 0
33 #define MACTIME_RANGE_TYPE_ALLOW 1
34 
35 typedef struct
36 {
38  u8 mac_address[6];
42 
43 /** Always drop packets from this device */
44 #define MACTIME_DEVICE_FLAG_STATIC_DROP (1<<0)
45 #define MACTIME_DEVICE_FLAG_STATIC_ALLOW (1<<1)
46 #define MACTIME_DEVICE_FLAG_DYNAMIC_DROP (1<<2)
47 #define MACTIME_DEVICE_FLAG_DYNAMIC_ALLOW (1<<3)
48 
49 typedef struct
50 {
51  union
52  {
53  u8 mac_address[6];
55  };
57 
58 typedef struct
59 {
60  /* API message ID base */
62 
63  /* Timebase */
65 
66  /* cached sunday midnight */
68 
69  /* Lookup table */
70  clib_bihash_8_8_t lookup_table;
71 
72  /* Device table */
74 
75  /* Counters */
78 
79  /* config parameters */
83 
84  /* Once-only data structure create flag */
86 
87  /* arp cache copy, for "show mactime" */
89 
90  /* convenience */
95 
96 /* size for an hgw use-case */
97 #define MACTIME_NUM_BUCKETS 128
98 #define MACTIME_MEMORY_SIZE (256<<10)
99 
101 
104 
105 void mactime_send_create_entry_message (u8 * mac_address);
106 
107 static inline u8 *
108 format_mac_address (u8 * s, va_list * args)
109 {
110  u8 *a = va_arg (*args, u8 *);
111  return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
112  a[0], a[1], a[2], a[3], a[4], a[5]);
113 }
114 
115 /* Periodic function events */
116 #define MACTIME_EVENT1 1
117 #define MACTIME_EVENT2 2
118 #define MACTIME_EVENT_PERIODIC_ENABLE_DISABLE 3
119 
120 #endif /* __included_mactime_h__ */
121 
122 /*
123  * fd.io coding-style-patch-verification: ON
124  *
125  * Local Variables:
126  * eval: (c-set-style "gnu")
127  * End:
128  */
vlib_combined_counter_main_t drop_counters
Definition: mactime.h:77
vlib_node_registration_t mactime_node
(constructor) VLIB_REGISTER_NODE (mactime_node)
Definition: node.c:282
a
Definition: bitmap.h:537
u16 msg_id_base
Definition: mactime.h:61
unsigned long u64
Definition: types.h:89
clib_timebase_t timebase
Definition: mactime.h:64
mactime_main_t mactime_main
Definition: mactime.c:53
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
unsigned char u8
Definition: types.h:56
double f64
Definition: types.h:142
clib_timebase_range_t * ranges
Definition: mactime.h:40
vlib_main_t * vlib_main
Definition: mactime.h:91
unsigned int u32
Definition: types.h:88
ethernet_main_t * ethernet_main
Definition: mactime.h:93
ethernet_arp_ip4_entry_t * arp_cache_copy
Definition: mactime.h:88
vlib_combined_counter_main_t allow_counters
Definition: mactime.h:76
unsigned short u16
Definition: types.h:57
u32 lookup_table_num_buckets
Definition: mactime.h:80
uword lookup_table_memory_size
Definition: mactime.h:81
Optimized thread-safe counters.
f64 sunday_midnight
Definition: mactime.h:67
mactime_device_t * devices
Definition: mactime.h:73
signed int i32
Definition: types.h:81
static u8 * format_mac_address(u8 *s, va_list *args)
Definition: mactime.h:108
u64 as_u64
Definition: mactime.h:54
vlib_node_registration_t mactime_tx_node
(constructor) VLIB_REGISTER_NODE (mactime_tx_node)
Definition: node.c:312
clib_bihash_8_8_t lookup_table
Definition: mactime.h:70
struct _vlib_node_registration vlib_node_registration_t
u64 uword
Definition: types.h:112
int feature_initialized
Definition: mactime.h:85
A collection of combined counters.
Definition: counter.h:181
u8 * device_name
Definition: mactime.h:37
vnet_main_t * vnet_main
Definition: mactime.h:92
i32 timezone_offset
Definition: mactime.h:82
Definition: arp_packet.h:150
void mactime_send_create_entry_message(u8 *mac_address)
Create a lookup table entry for the indicated mac address.
Definition: mactime.c:189