OpenSDN source code
gmpx_environment.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Juniper Networks, Inc. All rights reserved.
3  * Copyright Contributors to the OpenSDN project
4  */
5 
6 #ifndef gmpx_environment_h
7 #define gmpx_environment_h
8 
9 #include "bvx_environment.h"
10 
11 /* Pick up the patricia stuff directly. */
12 
13 #define gmpx_patnode patnode
14 #define gmpx_patroot patroot
15 #define GMPX_PATNODE_TO_STRUCT PATNODE_TO_STRUCT
16 #define gmpx_patricia_lookup_least patricia_lookup_least
17 #define gmpx_patricia_lookup_geq patricia_lookup_geq
18 #define gmpx_patroot_init(keylen, offset) \
19  patricia_root_init(NULL, FALSE, (keylen), (offset))
20 #define GMPX_PATRICIA_OFFSET STRUCT_OFFSET
21 #define gmpx_patricia_add patricia_add
22 #define gmpx_patroot_destroy patricia_root_delete
23 #define gmpx_patricia_get_next patricia_get_next
24 #define gmpx_patricia_lookup patricia_lookup
25 #define gmpx_patricia_delete patricia_delete
26 
27 /* Interface index. */
28 
30 #define GMPX_MANY_INTFS 50 /* Intf count before changing
31  * general query strategy
32  */
33 
34 /* Memory stuff. */
35 
36 #define gmpx_block_tag block_t
37 #define gmpx_malloc_block task_block_alloc
38 #define gmpx_free_block task_block_free
39 #define gmpx_malloc_block_create task_block_init
40 
41 /* Checksum */
42 
43 #define gmpx_calculate_cksum inet_cksum
44 
45 /* Assert. */
46 
47 #define gmpx_assert assert
48 
49 #define GMPX_UNUSED UNUSED
50 
51 #define GMPX_MAX_RTR_CLIENTS 2 /* Should be enough */
52 
53 /*
54  * Packet attribute. For now it's just a boolean, with TRUE meaning that
55  * the packet represents statically defined groups.
56  */
57 typedef boolean gmpx_packet_attr; /* Packet attribute */
58 
59 /* Tracing */
60 
61 extern void gmpx_trace(void *context, const char *parms, ...);
62 
63 typedef enum {
69 
70 /* Event */
71 extern void gmpx_post_event(void *context, gmpx_event_type ev,
72  const void *parms, ...);
73 
74 /*
75  * Timer entry
76  *
77  * This consists of a timer embedded in an outer structure so that we can
78  * adapt rpd's timers to GMP's expectations.
79  */
80 typedef struct gmpx_timer_ gmpx_timer;
81 typedef void (*gmpx_timer_callback)(gmpx_timer *timer, void *context);
82 
83 struct gmpx_timer_ {
84  task_timer *gmpxt_timer; /* rpd's timer */
85  void *gmpxt_context; /* timer context */
86  gmpx_timer_callback gmpxt_callback; /* Callback address */
87  gmp_timer_group gmpxt_group; /* Timer group */
88  gmp_proto gmpxt_proto; /* Associated protocol */
89 };
90 
91 
92 /* gmpx_environment.c */
93 
94 extern void gmpx_start_timer(gmpx_timer *timer, uint32_t ivl,
95  uint32_t jitter_pct);
96 extern gmpx_timer *gmpx_create_timer(void *inst_context, const char *name,
98  void *timer_context);
100  void *inst_context,
101  const char *name,
103  void *timer_context);
104 extern void gmpx_destroy_timer(gmpx_timer *timer);
105 extern uint32_t gmpx_timer_time_remaining(gmpx_timer *timer);
106 extern boolean gmpx_timer_running(gmpx_timer *timer);
107 extern void gmpx_stop_timer(gmpx_timer *timer);
108 extern void gmpx_smear_timer_group(gmp_proto proto, gmp_timer_group group);
109 
110 #endif /* gmpx_environment_h */
gmp_timer_group
Definition: gmp.h:142
gmp_proto
Definition: gmp.h:46
gmpx_event_type
@ GMP_GROUP_LIMIT_BELOW
@ GMP_GROUP_LIMIT_EXCEED
@ GMP_GROUP_THRESHOLD_EXCEED
@ GMP_VERSION_MISMATCH
boolean gmpx_timer_running(gmpx_timer *timer)
void gmpx_destroy_timer(gmpx_timer *timer)
uint32_t gmpx_timer_time_remaining(gmpx_timer *timer)
gmpx_timer * gmpx_create_timer(void *inst_context, const char *name, gmpx_timer_callback callback, void *timer_context)
struct gmp_intf_handle_ * gmpx_intf_id
gmpx_timer * gmpx_create_grouped_timer(gmp_timer_group group, void *inst_context, const char *name, gmpx_timer_callback callback, void *timer_context)
void(* gmpx_timer_callback)(gmpx_timer *timer, void *context)
void gmpx_post_event(void *context, gmpx_event_type ev, const void *parms,...)
Definition: gmp_map.cc:565
void gmpx_stop_timer(gmpx_timer *timer)
void gmpx_trace(void *context, const char *parms,...)
Definition: gmp_map.cc:549
boolean gmpx_packet_attr
void gmpx_smear_timer_group(gmp_proto proto, gmp_timer_group group)
void gmpx_start_timer(gmpx_timer *timer, uint32_t ivl, uint32_t jitter_pct)
task_timer * gmpxt_timer
void * gmpxt_context
gmp_proto gmpxt_proto
gmpx_timer_callback gmpxt_callback
gmp_timer_group gmpxt_group