-
Notifications
You must be signed in to change notification settings - Fork 564
/
dr_cb.h
123 lines (98 loc) · 3.44 KB
/
dr_cb.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/**
*
* drouting module callbacks header
*
* Copyright (C) 2014-2106 OpenSIPS Foundation
*
* This file is part of opensips, a free SIP server.
*
* opensips is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version
*
* opensips is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _DR_CB_H_
#define _DR_CB_H_
/* parameters needed for the registration of a gw */
struct dr_reg_param {
void *rule;
int n_dst; /* the index of the destination within the rule */
void *cr_or_gw;
};
/* callback types used on top of DRouting */
enum drcb_types {
DRCB_REG_CREATE_PARTS_LIST /* create a partitions list */,
/* params: */
DRCB_REG_INIT_RULE,
DRCB_REG_GW,
DRCB_REG_CR,
DRCB_REG_ADD_RULE,
DRCB_REG_MARK_AS_RULE_LIST,
DRCB_REG_LINK_LISTS,
DRCB_REG_FREE_LIST,
DRCB_ACC_CALL,
DRCB_SORT_DST,
DRCB_SET_PROFILE,
DRCB_MAX /*keep this at the end*/
};
struct dr_acc_call_params {
void *rule; /* qr_handler/rule */
int cr_id; /* destination id */
int gw_id; /* in the case the destination is a carrier */
struct sip_msg *msg;
};
struct dr_sort_params {
pgw_list_t *pgwl; /* gws/cr to be sorted */
int size; /* the size of pgwl */
unsigned short *sorted_dst; /* returns an array with the indexes of the sorted dest */
int rc; /* return code for the funciton */
};
#include "prefix_tree.h"
#include "dr_sorting_cbs.h"
#define POINTER_CLOSED_MARKER ((void *)(-1))
struct dr_cb_params {
void **param; /* parameter passed at callback registration*/
};
/* callback function prototype */
typedef void (dr_cb) (void *param);
/* function to free callback param */
typedef void(dr_param_free_cb) (void *param);
/* register callback function protoype */
typedef int (*register_drcb_f)(enum drcb_types, dr_cb f, void *param,
dr_param_free_cb ff);
typedef int (*register_drcb_to_array_f)(enum drcb_types, dr_cb f,
void *param, dr_param_free_cb ff);
struct dr_callback {
dr_cb* callback;
void *param;
dr_param_free_cb* callback_param_free;
struct dr_callback * next;
};
/* TODO: should i have a different structure for sort_callbacks */
/* sorting related data */
/* if new callbacks are added you must increase the N_MAX_SORT_CBS
* constant accordingly, add the letter which will be provided in the db
* to the sort_algs array, add the corresponding sorting algorithm id to the
* enum an register the callback to the dr_sort_cbs in the appropriate position*/
/* The maximum number of sorting functions provided by dr */
#define N_MAX_SORT_CBS 4
typedef enum { NO_SORT = 1, WEIGHT_BASED_SORT = 2, QR_BASED_SORT = 3}
sort_cb_type;
/* used for mapping the db information (sort_alg = a letter) to an index
* in the sort_cb_type enum */
extern unsigned char sort_algs[N_MAX_SORT_CBS];
int register_dr_cb(enum drcb_types type, dr_cb f, void *param,
dr_param_free_cb ff);
int run_dr_cbs(enum drcb_types type, void *params);
int run_dr_sort_cbs( sort_cb_type type, void *params);
void destroy_dr_cbs(void);
#endif