test: ip4 vrf instances multi-context test (CSIT-492)
[vpp.git] / plugins / vcgn-plugin / vcgn / cnat_log_common.h
1 /*
2  *------------------------------------------------------------------
3  * cnat_log_common.h
4  * Contains macros and definitions that are common to both syslog and nfv9
5  * Copyright (c) 2011-2012 Cisco and/or its affiliates.
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  */
19
20 #ifndef __CNAT_LOG_COMMON_H__ 
21 #define __CNAT_LOG_COMMON_H__
22
23 #include <stdio.h>
24 #include <vlib/vlib.h>
25 #include <vnet/vnet.h>
26
27 #include "cnat_db.h"
28 #include "nat64_db.h"
29 #include "spp_timers.h"
30 #include "spp_ctx.h"
31
32 /*
33  * This corresponds to the length of the IMETRO SHIM Header for RODDICK
34  * For non-roddick cases, introduce an Ethernet header as well
35  */
36 #if 0
37    #if defined(TARGET_RODDICK)
38    #define CNAT_NFV9_SHIM_HDR_OFFSET   8
39    #define CNAT_NFV9_L2_ENCAPS_OFFSET  0
40    #else
41    #define CNAT_NFV9_SHIM_HDR_OFFSET   0
42    #define CNAT_NFV9_L2_ENCAPS_OFFSET 16
43    #endif
44 #endif
45
46    #define CNAT_NFV9_IP_HDR_OFFSET 0
47
48    #define CNAT_NFV9_UDP_HDR_OFFSET \
49         (CNAT_NFV9_IP_HDR_OFFSET + sizeof(ipv4_header))
50
51    #define CNAT_NFV9_HDR_OFFSET \
52         (CNAT_NFV9_UDP_HDR_OFFSET + sizeof(udp_hdr_type_t))
53
54 u32 cnat_get_sys_up_time_in_ms(void);
55 u32 cnat_get_unix_time_in_seconds(void);
56 void cnat_dump_time_change_logs(void);
57 void cnat_handle_sys_time_change (time_t current_unix_time);
58 /*
59  * Maximum number of time log changes we maintain
60  */
61
62 #define MAX_TIME_CHANGE_LOGS (8)
63
64 typedef struct {
65     /*
66      * A timer structure to periodically send NFv9 & syslog logging packets
67      * that have been waiting to be full for a long time.  This will
68      * ensure add/delete events don't get delayed too much before they
69      * are sent to the collector.
70      */
71      spp_timer_t log_timer;
72      
73      /*
74       * Whether we have initialized the NFv9 information
75       */
76      u8 cnat_log_init_done;
77 } cnat_log_global_info_t;
78
79 #endif /* __CNAT_LOG_COMMON_H__ */