Initial commit of vpp code.
[vpp.git] / vpp / oam / oam.h
1 /*
2  * Copyright (c) 2015 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 #ifndef __included_oam_h__
16 #define __included_oam_h__
17
18 #include <vlib/vlib.h>
19 #include <vnet/vnet.h>
20 #include <vnet/ip/ip.h>
21 #include <vnet/interface.h>
22
23 /* 36 octets, make a note of it... */
24 typedef CLIB_PACKED(struct {
25     ip4_header_t ip4;
26     icmp46_header_t icmp;
27     u16 id;
28     u16 seq;
29     u8 data[8];
30 }) oam_template_t;
31
32 typedef CLIB_PACKED(struct {
33     u64 v8[4];
34     u32 v4;
35 }) oam_template_copy_t;
36
37 typedef enum {
38     OAM_STATE_UNKNOWN = 0,
39     OAM_STATE_ALIVE,
40     OAM_STATE_DEAD,
41 } oam_state_t;
42
43 typedef struct {
44     ip4_address_t src_address;
45     ip4_address_t dst_address;
46     u32 fib_id;
47     u32 fib_index;
48     f64 last_heard_time;
49     u16 seq;
50     u16 last_heard_seq;
51     u16 id;
52     u8 state;
53     oam_template_t * template;
54 } oam_target_t;
55
56 typedef struct {
57     /* OAM targets */
58     oam_target_t * targets;
59     uword * target_by_address_and_fib_id;
60
61     /* Config parameters */
62     f64 interval;
63     u32 misses_allowed;
64
65     /* random number seed */
66     u32 random_seed;
67     u16 icmp_id;
68
69     /* oam packet template */
70     vlib_packet_template_t packet_template;
71
72     /* convenience */
73     vlib_main_t * vlib_main;
74     vnet_main_t * vnet_main;
75 } oam_main_t;
76
77 int vpe_oam_add_del_target (ip4_address_t *src_address, 
78                             ip4_address_t *dst_address, 
79                             u32 fib_id, int is_add);
80
81 #endif /* __included_oam_h__ */