Browse code

usrloc: fixed wrong comments related to the flags fields in ucontact_t

Daniel-Constantin Mierla authored on 27/03/2020 16:52:53
Showing 1 changed files
... ...
@@ -82,8 +82,8 @@ typedef struct ucontact {
82 82
 	str callid;             /*!< Call-ID header field of registration */
83 83
 	int cseq;               /*!< CSeq value */
84 84
 	cstate_t state;         /*!< State of the contact (\ref cstate) */
85
-	unsigned int flags;     /*!< Various flags (NAT, ping type, etc) */
86
-	unsigned int cflags;    /*!< Custom contact flags (from script) */
85
+	unsigned int flags;     /*!< Various internal flags (sync, etc) */
86
+	unsigned int cflags;    /*!< Custom contact flags (from script - bflags) */
87 87
 	str user_agent;         /*!< User-Agent header field */
88 88
 	str uniq;               /*!< Uniq header field */
89 89
 	struct socket_info *sock; /*!< received socket */
Browse code

usrloc: store keepalive roundtrip in contact structure

Daniel-Constantin Mierla authored on 26/03/2020 20:57:08
Showing 1 changed files
... ...
@@ -88,7 +88,8 @@ typedef struct ucontact {
88 88
 	str uniq;               /*!< Uniq header field */
89 89
 	struct socket_info *sock; /*!< received socket */
90 90
 	time_t last_modified;   /*!< When the record was last modified */
91
-	time_t last_keepalive;  /*!< last keepalive timestamp */
91
+	time_t last_keepalive;  /*!< Last keepalive timestamp */
92
+	unsigned int ka_roundtrip; /*!< Keepalive roundtrip in microseconds */
92 93
 	unsigned int methods;   /*!< Supported methods */
93 94
 	str instance;           /*!< SIP instance value - gruu */
94 95
 	unsigned int reg_id;    /*!< reg-id parameters */
... ...
@@ -192,6 +193,8 @@ int ul_set_keepalive_timeout(int _to);
192 193
 typedef int (*ul_refresh_keepalive_t)(unsigned int _aorhash, str *_ruid);
193 194
 int ul_refresh_keepalive(unsigned int _aorhash, str *_ruid);
194 195
 
196
+int ul_update_keepalive(unsigned int _aorhash, str *_ruid, time_t tval,
197
+		unsigned int rtrip);
195 198
 
196 199
 typedef void (*ul_set_max_partition_t)(unsigned int m);
197 200
 
Browse code

p_usrloc: add new update function

Add also new "uniq" column.
The new update function will use this new column.

Stefan Mititelu authored on 16/03/2020 13:56:43 • Stefan Mititelu committed on 16/03/2020 14:51:10
Showing 1 changed files
... ...
@@ -85,6 +85,7 @@ typedef struct ucontact {
85 85
 	unsigned int flags;     /*!< Various flags (NAT, ping type, etc) */
86 86
 	unsigned int cflags;    /*!< Custom contact flags (from script) */
87 87
 	str user_agent;         /*!< User-Agent header field */
88
+	str uniq;               /*!< Uniq header field */
88 89
 	struct socket_info *sock; /*!< received socket */
89 90
 	time_t last_modified;   /*!< When the record was last modified */
90 91
 	time_t last_keepalive;  /*!< last keepalive timestamp */
Browse code

usrloc: removed ifdefs for WITH_XAVP

Daniel-Constantin Mierla authored on 18/04/2019 12:02:33
Showing 1 changed files
... ...
@@ -30,9 +30,7 @@
30 30
 #include "ul_callback.h"
31 31
 #include "../../core/qvalue.h"
32 32
 #include "../../core/str.h"
33
-#ifdef WITH_XAVP
34 33
 #include "../../core/xavp.h"
35
-#endif
36 34
 
37 35
 #define NO_DB         0
38 36
 #define WRITE_THROUGH 1
... ...
@@ -96,9 +94,7 @@ typedef struct ucontact {
96 94
 	int server_id;          /*!< server id */
97 95
 	int tcpconn_id;         /*!< unique tcp connection id */
98 96
 	int keepalive;          /*!< keepalive */
99
-#ifdef WITH_XAVP
100 97
 	sr_xavp_t * xavp;       /*!< per contact xavps */
101
-#endif
102 98
 	struct ucontact* next;  /*!< Next contact in the linked list */
103 99
 	struct ucontact* prev;  /*!< Previous contact in the linked list */
104 100
 } ucontact_t;
... ...
@@ -124,9 +120,7 @@ typedef struct ucontact_info {
124 120
 	int server_id;            /*!< server id */
125 121
 	int tcpconn_id;           /*!< connection id */
126 122
 	int keepalive;            /*!< keepalive */
127
-#ifdef WITH_XAVP
128 123
 	sr_xavp_t * xavp;         /*!< per contact xavps */
129
-#endif
130 124
 	time_t last_modified;     /*!< last modified */
131 125
 } ucontact_info_t;
132 126
 
Browse code

usrloc: new parameter rm_expired_delay

- set how many seconds to delay the removal of an expired record
- for now works only in DB_ONLY mode

Daniel-Constantin Mierla authored on 19/01/2018 10:05:31
Showing 1 changed files
... ...
@@ -62,6 +62,7 @@ typedef enum flags {
62 62
 	FL_NONE        = 0,          /*!< No flags set */
63 63
 	FL_MEM         = 1 << 0,     /*!< Update memory only */
64 64
 	FL_DMQRPL      = 1 << 1,     /*!< DMQ replication */
65
+	FL_EXPCLB      = 1 << 2,     /*!< Expired callback executed */
65 66
 	FL_ALL         = (int)0xFFFFFFFF  /*!< All flags set */
66 67
 } flags_t;
67 68
 
Browse code

usrloc: renamed dmq specific flag from FL_RPL to FL_DMQRPL

Daniel-Constantin Mierla authored on 19/01/2018 09:32:24
Showing 1 changed files
... ...
@@ -61,7 +61,7 @@ typedef enum cstate {
61 61
 typedef enum flags {
62 62
 	FL_NONE        = 0,          /*!< No flags set */
63 63
 	FL_MEM         = 1 << 0,     /*!< Update memory only */
64
-	FL_RPL         = 1 << 1,     /*!< DMQ replication */
64
+	FL_DMQRPL      = 1 << 1,     /*!< DMQ replication */
65 65
 	FL_ALL         = (int)0xFFFFFFFF  /*!< All flags set */
66 66
 } flags_t;
67 67
 
Browse code

usrloc: renamed main files to match module name

Daniel-Constantin Mierla authored on 21/12/2016 20:40:24
Showing 1 changed files
... ...
@@ -13,8 +13,8 @@
13 13
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 14
  * GNU General Public License for more details.
15 15
  *
16
- * You should have received a copy of the GNU General Public License 
17
- * along with this program; if not, write to the Free Software 
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program; if not, write to the Free Software
18 18
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19 19
  */
20 20
 
Browse code

core, lib, modules: updated include paths for header files

Daniel-Constantin Mierla authored on 07/12/2016 11:07:22
Showing 1 changed files
... ...
@@ -28,10 +28,10 @@
28 28
 
29 29
 #include <time.h>
30 30
 #include "ul_callback.h"
31
-#include "../../qvalue.h"
32
-#include "../../str.h"
31
+#include "../../core/qvalue.h"
32
+#include "../../core/str.h"
33 33
 #ifdef WITH_XAVP
34
-#include "../../xavp.h"
34
+#include "../../core/xavp.h"
35 35
 #endif
36 36
 
37 37
 #define NO_DB         0
Browse code

core, lib, modules: restructured source code tree

- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,241 @@
1
+/*
2
+ * Copyright (C) 2001-2003 FhG Fokus
3
+ *
4
+ * This file is part of Kamailio, a free SIP server.
5
+ *
6
+ * Kamailio is free software; you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation; either version 2 of the License, or
9
+ * (at your option) any later version
10
+ *
11
+ * Kamailio is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License 
17
+ * along with this program; if not, write to the Free Software 
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19
+ */
20
+
21
+/*! \file
22
+ *  \brief USRLOC - module API exports interface
23
+ *  \ingroup usrloc
24
+ */
25
+
26
+#ifndef USRLOC_H
27
+#define USRLOC_H
28
+
29
+#include <time.h>
30
+#include "ul_callback.h"
31
+#include "../../qvalue.h"
32
+#include "../../str.h"
33
+#ifdef WITH_XAVP
34
+#include "../../xavp.h"
35
+#endif
36
+
37
+#define NO_DB         0
38
+#define WRITE_THROUGH 1
39
+#define WRITE_BACK    2
40
+#define DB_ONLY       3
41
+#define DB_READONLY   4
42
+
43
+#define GAU_OPT_SERVER_ID  (1<<0)  /* filter query by server_id */
44
+
45
+/*forward declaration necessary for udomain*/
46
+
47
+struct udomain;
48
+typedef struct udomain udomain_t;
49
+
50
+/*!
51
+ * \brief States for in-memory contacts in regards to contact storage handler (db, in-memory, ldap etc)
52
+ */
53
+typedef enum cstate {
54
+	CS_NEW,        /*!< New contact - not flushed yet */
55
+	CS_SYNC,       /*!< Synchronized contact with the database */
56
+	CS_DIRTY       /*!< Update contact - not flushed yet */
57
+} cstate_t;
58
+
59
+
60
+/*! \brief Flags that can be associated with a Contact */
61
+typedef enum flags {
62
+	FL_NONE        = 0,          /*!< No flags set */
63
+	FL_MEM         = 1 << 0,     /*!< Update memory only */
64
+	FL_RPL         = 1 << 1,     /*!< DMQ replication */
65
+	FL_ALL         = (int)0xFFFFFFFF  /*!< All flags set */
66
+} flags_t;
67
+
68
+/*! \brief Valid contact is a contact that either didn't expire yet or is permanent */
69
+#define VALID_CONTACT(c, t)   ((c->expires>t) || (c->expires==0))
70
+
71
+struct hslot; /*!< Hash table slot */
72
+struct socket_info;
73
+/*! \brief Main structure for handling of registered Contact data */
74
+typedef struct ucontact {
75
+	str* domain;            /*!< Pointer to domain name (NULL terminated) */
76
+	str ruid;               /*!< Pointer to record internal unique id */
77
+	str* aor;               /*!< Pointer to the AOR string in record structure*/
78
+	str c;                  /*!< Contact address */
79
+	str received;           /*!< IP+port+protocol we received the REGISTER from */
80
+	str path;               /*!< Path header */
81
+	time_t expires;         /*!< Expires parameter */
82
+	qvalue_t q;             /*!< q parameter */
83
+	str callid;             /*!< Call-ID header field of registration */
84
+	int cseq;               /*!< CSeq value */
85
+	cstate_t state;         /*!< State of the contact (\ref cstate) */
86
+	unsigned int flags;     /*!< Various flags (NAT, ping type, etc) */
87
+	unsigned int cflags;    /*!< Custom contact flags (from script) */
88
+	str user_agent;         /*!< User-Agent header field */
89
+	struct socket_info *sock; /*!< received socket */
90
+	time_t last_modified;   /*!< When the record was last modified */
91
+	time_t last_keepalive;  /*!< last keepalive timestamp */
92
+	unsigned int methods;   /*!< Supported methods */
93
+	str instance;           /*!< SIP instance value - gruu */
94
+	unsigned int reg_id;    /*!< reg-id parameters */
95
+	int server_id;          /*!< server id */
96
+	int tcpconn_id;         /*!< unique tcp connection id */
97
+	int keepalive;          /*!< keepalive */
98
+#ifdef WITH_XAVP
99
+	sr_xavp_t * xavp;       /*!< per contact xavps */
100
+#endif
101
+	struct ucontact* next;  /*!< Next contact in the linked list */
102
+	struct ucontact* prev;  /*!< Previous contact in the linked list */
103
+} ucontact_t;
104
+
105
+
106
+/*! \brief Informations related to a contact */
107
+typedef struct ucontact_info {
108
+	str ruid;                 /*!< Pointer to record internal unique id */
109
+	str *c;                   /*!< Contact address */
110
+	str received;             /*!< Received interface */
111
+	str* path;                /*!< Path informations */
112
+	time_t expires;           /*!< Contact expires */
113
+	qvalue_t q;               /*!< Q-value */
114
+	str* callid;              /*!< call-ID */
115
+	int cseq;                 /*!< CSEQ number */
116
+	unsigned int flags;       /*!< message flags */
117
+	unsigned int cflags;      /*!< contact flags */
118
+	str *user_agent;          /*!< user agent header */
119
+	struct socket_info *sock; /*!< socket informations */
120
+	unsigned int methods;     /*!< supported methods */
121
+	str instance;             /*!< SIP instance value - gruu */
122
+	unsigned int reg_id;      /*!< reg-id parameters */
123
+	int server_id;            /*!< server id */
124
+	int tcpconn_id;           /*!< connection id */
125
+	int keepalive;            /*!< keepalive */
126
+#ifdef WITH_XAVP
127
+	sr_xavp_t * xavp;         /*!< per contact xavps */
128
+#endif
129
+	time_t last_modified;     /*!< last modified */
130
+} ucontact_info_t;
131
+
132
+typedef struct udomain_head{
133
+    str* name;
134
+} udomain_head_t;
135
+
136
+/*! \brief
137
+ * Basic hash table element
138
+ */
139
+typedef struct urecord {
140
+	str* domain;                   /*!< Pointer to domain we belong to
141
+                                    * ( null terminated string) */
142
+	str aor;                       /*!< Address of record */
143
+	unsigned int aorhash;          /*!< Hash over address of record */
144
+	ucontact_t* contacts;          /*!< One or more contact fields */
145
+
146
+	struct hslot* slot;            /*!< Collision slot in the hash table
147
+                                    * array we belong to */
148
+	struct urecord* prev;          /*!< Next item in the hash entry */
149
+	struct urecord* next;          /*!< Previous item in the hash entry */
150
+} urecord_t;
151
+
152
+typedef int (*insert_urecord_t)(struct udomain* _d, str* _aor, struct urecord** _r);
153
+
154
+typedef int (*get_urecord_t)(struct udomain* _d, str* _aor, struct urecord** _r);
155
+
156
+typedef int (*get_urecord_by_ruid_t)(udomain_t* _d, unsigned int _aorhash,
157
+		str *_ruid, struct urecord** _r, struct ucontact** _c);
158
+
159
+typedef int  (*delete_urecord_t)(struct udomain* _d, str* _aor, struct urecord* _r);
160
+
161
+typedef int  (*delete_urecord_by_ruid_t)(struct udomain* _d, str* _ruid);
162
+
163
+typedef int (*update_ucontact_t)(struct urecord* _r, struct ucontact* _c,
164
+		struct ucontact_info* _ci);
165
+typedef void (*release_urecord_t)(struct urecord* _r);
166
+
167
+typedef int (*insert_ucontact_t)(struct urecord* _r, str* _contact,
168
+		struct ucontact_info* _ci, struct ucontact** _c);
169
+
170
+typedef int (*delete_ucontact_t)(struct urecord* _r, struct ucontact* _c);
171
+
172
+typedef int (*get_ucontact_t)(struct urecord* _r, str* _c, str* _callid,
173
+		str* _path, int _cseq,
174
+		struct ucontact** _co);
175
+
176
+typedef int (*get_ucontact_by_instance_t)(struct urecord* _r, str* _c,
177
+		ucontact_info_t* _ci, ucontact_t** _co);
178
+
179
+typedef void (*lock_udomain_t)(struct udomain* _d, str *_aor);
180
+
181
+typedef void (*unlock_udomain_t)(struct udomain* _d, str *_aor);
182
+
183
+typedef int (*register_udomain_t)(const char* _n, struct udomain** _d);
184
+
185
+typedef int  (*get_all_ucontacts_t) (void* buf, int len, unsigned int flags,
186
+		unsigned int part_idx, unsigned int part_max, int options);
187
+
188
+typedef int (*get_udomain_t)(const char* _n, udomain_t** _d);
189
+
190
+typedef unsigned int (*ul_get_aorhash_t)(str *_aor);
191
+unsigned int ul_get_aorhash(str *_aor);
192
+
193
+typedef int (*ul_set_keepalive_timeout_t)(int _to);
194
+int ul_set_keepalive_timeout(int _to);
195
+
196
+typedef int (*ul_refresh_keepalive_t)(unsigned int _aorhash, str *_ruid);
197
+int ul_refresh_keepalive(unsigned int _aorhash, str *_ruid);
198
+
199
+
200
+typedef void (*ul_set_max_partition_t)(unsigned int m);
201
+
202
+/*! usrloc API export structure */
203
+typedef struct usrloc_api {
204
+	int           use_domain; /*! use_domain module parameter */
205
+	int           db_mode;    /*! db_mode module parameter */
206
+	unsigned int  nat_flag;   /*! nat_flag module parameter */
207
+
208
+	register_udomain_t   register_udomain;
209
+	get_udomain_t        get_udomain;
210
+	get_all_ucontacts_t  get_all_ucontacts;
211
+
212
+	insert_urecord_t     insert_urecord;
213
+	delete_urecord_t     delete_urecord;
214
+	delete_urecord_by_ruid_t     delete_urecord_by_ruid;
215
+	get_urecord_t        get_urecord;
216
+	lock_udomain_t       lock_udomain;
217
+	unlock_udomain_t     unlock_udomain;
218
+
219
+	release_urecord_t    release_urecord;
220
+	insert_ucontact_t    insert_ucontact;
221
+	delete_ucontact_t    delete_ucontact;
222
+	get_ucontact_t       get_ucontact;
223
+
224
+	get_urecord_by_ruid_t       get_urecord_by_ruid;
225
+	get_ucontact_by_instance_t  get_ucontact_by_instance;
226
+
227
+	update_ucontact_t    update_ucontact;
228
+
229
+	register_ulcb_t      register_ulcb;
230
+	ul_get_aorhash_t     get_aorhash;
231
+
232
+	ul_set_keepalive_timeout_t set_keepalive_timeout;
233
+	ul_refresh_keepalive_t     refresh_keepalive;
234
+	ul_set_max_partition_t     set_max_partition;
235
+} usrloc_api_t;
236
+
237
+
238
+/*! usrloc API export bind function */
239
+typedef int (*bind_usrloc_t)(usrloc_api_t* api);
240
+
241
+#endif