/
ul_mod.h
145 lines (120 loc) · 3.59 KB
/
ul_mod.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
* User location module interface
*
* Copyright (C) 2001-2003 FhG Fokus
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* History:
* ---------
*/
/*! \file
* \brief USRLOC - Usrloc module interface
* \ingroup usrloc
*/
#ifndef UL_MOD_H
#define UL_MOD_H
#include "../../db/db.h"
#include "../../str.h"
#include "../../cachedb/cachedb.h"
#include "usrloc.h"
extern enum ul_cluster_mode cluster_mode;
extern enum ul_rr_persist rr_persist;
extern enum ul_sql_write_mode sql_wmode;
/* manner in which node data should be restored (or not) following a restart */
enum ul_rr_persist {
RRP_NONE,
RRP_LOAD_FROM_SQL,
RRP_SYNC_FROM_CLUSTER,
} ul_rr_persist_t;
#define bad_rr_persist(rrp) ((rrp) < RRP_NONE || (rrp) > RRP_SYNC_FROM_CLUSTER)
/* if using SQL for restart persistency,
* should runtime SQL blocking writes be performed eagerly or lazily? */
enum ul_sql_write_mode {
SQL_NO_WRITE,
SQL_WRITE_THROUGH,
SQL_WRITE_BACK,
} ul_sql_write_mode_t;
#define bad_sql_write_mode(wm) ((wm) < SQL_NO_WRITE || (wm) > SQL_WRITE_BACK)
#define bad_cluster_mode(mode) ((mode) < CM_NONE || (mode) > CM_SQL_ONLY)
/* TODO: rewrite/optimize these 4 checks at mod init */
#define have_db_conns() \
(cluster_mode == CM_SQL_ONLY || rr_persist == RRP_LOAD_FROM_SQL)
#define have_cdb_conns() \
(cluster_mode == CM_FEDERATION_CACHEDB || \
cluster_mode == CM_FULL_SHARING_CACHEDB)
static inline int have_mem_storage(void)
{
return cluster_mode == CM_NONE ||
cluster_mode == CM_FEDERATION ||
cluster_mode == CM_FEDERATION_CACHEDB ||
cluster_mode == CM_FULL_SHARING;
}
#define have_data_replication() \
(cluster_mode == CM_FEDERATION_CACHEDB || \
cluster_mode == CM_FEDERATION || \
cluster_mode == CM_FULL_SHARING)
/*
* Module parameters
*/
#define UL_TABLE_VERSION 1013
#define UL_COLS 19
extern str contactid_col;
extern str user_col;
extern str domain_col;
extern str contact_col;
extern str expires_col;
extern str q_col;
extern str callid_col;
extern str cseq_col;
extern str flags_col;
extern str cflags_col;
extern str user_agent_col;
extern str received_col;
extern str path_col;
extern str sock_col;
extern str methods_col;
extern str kv_store_col;
extern str attr_col;
extern str last_mod_col;
extern str sip_instance_col;
extern str db_url;
extern int timer_interval;
extern enum usrloc_modes db_mode;
extern int skip_replicated_db_ops;
extern int use_domain;
extern int desc_time_order;
extern int cseq_delay;
extern int ul_hash_size;
extern int latency_event_min_us_delta;
extern int latency_event_min_us;
extern int shared_pinging;
extern db_con_t* ul_dbh; /* Database connection handle */
extern db_func_t ul_dbf;
extern cachedb_funcs cdbf;
extern cachedb_con *cdbc;
/*
* Matching algorithms
*/
#define CONTACT_ONLY (0)
#define CONTACT_CALLID (1)
extern int matching_mode;
/*! \brief
* Initialize event structures
*/
int ul_event_init(void);
#endif /* UL_MOD_H */