Skip to content

Commit 107b6fa

Browse files
committed
usrloc: Fully document the module API
1 parent 8880b5f commit 107b6fa

12 files changed

+423
-170
lines changed

modules/usrloc/dlist.c

+4-25
Original file line numberDiff line numberDiff line change
@@ -798,29 +798,8 @@ get_domain_mem_ucontacts(udomain_t *d,void *buf, int *len, unsigned int flags,
798798

799799
/*! \brief
800800
* Return list of all contacts for all currently registered
801-
* users in all domains. Caller must provide a buffer of
802-
* sufficient length to fit all those contacts. If the buffer
803-
* is exhausted, the function returns the estimated amount
804-
* of additional space needed. In this case the caller is
805-
* expected to repeat the call using this value as the hint.
806-
*
807-
* Information is packed into the buffer as follows:
808-
*
809-
* +------------+----------+---------+-------+------------+--------+--------+---------------+
810-
* |int |char[] |int |char[] |socket_info*|unsigned|proxy_l |uint64 |
811-
* +============+==========+=========+=======+============+========+========+===============+
812-
* |contact1.len|contact1.s|path1.len|path1.s|sock1 |dbflags |next_hop|contact_coords1|
813-
* +------------+----------+---------+-------+------------+--------+--------+---------------+
814-
* |contact2.len|contact2.s|path2.len|path2.s|sock2 |dbflags |next_hop|contact_coords2|
815-
* +------------+----------+---------+-------+------------+--------+--------+---------------+
816-
* |........................................................................................|
817-
* +------------+----------+---------+-------+------------+--------+--------+---------------+
818-
* |contactN.len|contactN.s|pathN.len|pathN.s|sockN |dbflags |next_hop|contact_coordsN|
819-
* +------------+----------+---------+-------+------------+--------+--------+---------------+
820-
* |000000000000|
821-
* +------------+
822-
*
823-
* if @pack_coords is false, all "contact_coordsX" parts will be omitted
801+
* users in all currently defined domains. The packed data format is identical
802+
* to @get_domain_ucontacts.
824803
*/
825804
int get_all_ucontacts(void *buf, int len, unsigned int flags,
826805
unsigned int part_idx, unsigned int part_max, int pack_coords)
@@ -1192,7 +1171,7 @@ int cdb_delete_ucontact_coords(ucontact_sip_coords *sip_key)
11921171
}
11931172

11941173
int delete_ucontact_from_coords(udomain_t *d, ucontact_coords ct_coords,
1195-
char is_replicated)
1174+
char skip_replication)
11961175
{
11971176
ucontact_t *c, virt_c;
11981177
urecord_t *r;
@@ -1225,7 +1204,7 @@ int delete_ucontact_from_coords(udomain_t *d, ucontact_coords ct_coords,
12251204
return 0;
12261205
}
12271206

1228-
if (!is_replicated && location_cluster)
1207+
if (!skip_replication && location_cluster)
12291208
replicate_ucontact_delete(r, c);
12301209

12311210
if (exists_ulcb_type(UL_CONTACT_DELETE)) {

modules/usrloc/dlist.h

+2-13
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ extern dlist_t* root;
5959
* will be returned, otherwise a new domain will be
6060
* created
6161
*/
62-
typedef int (*register_udomain_t)(const char* _n, udomain_t** _d);
6362
int register_udomain(const char* _n, udomain_t** _d);
6463

6564

@@ -78,17 +77,12 @@ int _synchronize_all_udomains(void);
7877
/*! \brief
7978
* Get contacts to all registered users
8079
*/
81-
typedef int (*get_all_ucontacts_t) (void* buf, int len, unsigned int flags,
82-
unsigned int part_idx, unsigned int part_max, int pack_cid);
8380
int get_all_ucontacts(void *, int, unsigned int,
8481
unsigned int part_idx, unsigned int part_max, int pack_cid);
8582

8683
/*! \brief
8784
* Get contacts structures to all registered users
8885
*/
89-
typedef int (*get_domain_ucontacts_t) (udomain_t *d, void* buf, int len,
90-
unsigned int flags, unsigned int part_idx, unsigned int part_max,
91-
int pack_cid);
9286
int get_domain_ucontacts(udomain_t *d,void *buf, int len, unsigned int flags,
9387
unsigned int part_idx, unsigned int part_max, int pack_cid);
9488

@@ -107,7 +101,6 @@ int find_domain(str* _d, udomain_t** _p);
107101
/*! \brief
108102
* Returnes the next udomain, following the given one (as param)
109103
*/
110-
typedef udomain_t* (*get_next_udomain_t) (udomain_t* _d);
111104
udomain_t* get_next_udomain(udomain_t *_d);
112105

113106
/* when using various DBs (SQL/NoSQL) in order to store AoR hashes, it's best
@@ -146,16 +139,12 @@ unpack_indexes(uint64_t v,
146139
*aorhash = (v >> 46);
147140
}
148141

149-
typedef int (*delete_ucontact_from_coords_t)(udomain_t *d,
150-
ucontact_coords ct_coords, char is_replicated);
151142
int delete_ucontact_from_coords(udomain_t *d,
152-
ucontact_coords ct_coords, char is_replicated);
143+
ucontact_coords ct_coords, char skip_replication);
153144

154145
/*
155-
* update sipping latancy
146+
* update sipping latency
156147
*/
157-
typedef int (*update_sipping_latency_t)(udomain_t *d,
158-
ucontact_coords ct_coords, int sipping_latency);
159148
int update_sipping_latency(udomain_t *d, ucontact_coords ct_coords,
160149
int sipping_latency);
161150

modules/usrloc/ucontact.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ static inline void update_contact_pos(struct urecord* _r, ucontact_t* _c)
966966
* Update ucontact with new values
967967
*/
968968
int update_ucontact(struct urecord* _r, ucontact_t* _c, ucontact_info_t* _ci,
969-
char is_replicated)
969+
char skip_replication)
970970
{
971971
int ret, persist_kv_store = 1;
972972

@@ -977,10 +977,10 @@ int update_ucontact(struct urecord* _r, ucontact_t* _c, ucontact_info_t* _ci,
977977
return -1;
978978
}
979979

980-
if (is_replicated && _c->kv_storage)
980+
if (skip_replication && _c->kv_storage)
981981
restore_urecord_kv_store(_r, _c);
982982

983-
if (!is_replicated && have_data_replication()) {
983+
if (!skip_replication && have_data_replication()) {
984984
if (persist_urecord_kv_store(_r) != 0)
985985
LM_ERR("failed to persist latest urecord K/V storage\n");
986986
else

modules/usrloc/ucontact.h

+1-9
Original file line numberDiff line numberDiff line change
@@ -299,20 +299,15 @@ struct urecord;
299299
/*! \brief
300300
* Update ucontact with new values
301301
*/
302-
typedef int (*update_ucontact_t)(struct urecord* _r, ucontact_t* _c,
303-
ucontact_info_t* _ci, char is_replicated);
304-
305302
int update_ucontact(struct urecord* _r, ucontact_t* _c, ucontact_info_t* _ci,
306-
char is_replicated);
303+
char skip_replication);
307304

308305
/*! \brief
309306
* Fetch a key from the contact-level storage
310307
* NOTE: assumes the corresponding udomain lock is properly acquired
311308
*
312309
* Returns: NULL on error/key not found, value pointer otherwise
313310
*/
314-
typedef int_str_t *(*get_ucontact_key_t)(ucontact_t* _ct, const str* _key);
315-
316311
int_str_t *get_ucontact_key(ucontact_t* _ct, const str* _key);
317312

318313
/*! \brief
@@ -323,9 +318,6 @@ int_str_t *get_ucontact_key(ucontact_t* _ct, const str* _key);
323318
*
324319
* Returns: NULL on error, new value pointer otherwise
325320
*/
326-
typedef int_str_t *(*put_ucontact_key_t)(ucontact_t* _ct,
327-
const str* _key, const int_str_t* _val);
328-
329321
int_str_t *put_ucontact_key(ucontact_t* _ct, const str* _key,
330322
const int_str_t* _val);
331323

modules/usrloc/udomain.c

+7-9
Original file line numberDiff line numberDiff line change
@@ -1352,19 +1352,17 @@ int cdb_update_urecord_metadata(const str *_aor, int unpublish)
13521352

13531353
/*! \brief
13541354
* Create and insert a new record
1355-
* after inserting and urecord one must populate the
1356-
* label field outside this function
13571355
*/
13581356
int insert_urecord(udomain_t* _d, str* _aor, struct urecord** _r,
1359-
char is_replicated)
1357+
char skip_replication)
13601358
{
13611359
if (have_mem_storage()) {
13621360
if (mem_insert_urecord(_d, _aor, _r) < 0) {
13631361
LM_ERR("inserting record failed\n");
13641362
return -1;
13651363
}
13661364

1367-
if (!is_replicated) {
1365+
if (!skip_replication) {
13681366
init_urecord_labels(*_r, _d);
13691367

13701368
if (cluster_mode == CM_FEDERATION_CACHEDB
@@ -1481,7 +1479,7 @@ int get_global_urecord(udomain_t* _d, str* _aor, struct urecord** _r)
14811479
* Delete a urecord from domain
14821480
*/
14831481
int delete_urecord(udomain_t* _d, str* _aor, struct urecord* _r,
1484-
char is_replicated)
1482+
char skip_replication)
14851483
{
14861484
struct ucontact* c, *t;
14871485

@@ -1507,7 +1505,7 @@ int delete_urecord(udomain_t* _d, str* _aor, struct urecord* _r,
15071505
return 0;
15081506

15091507
case CM_FEDERATION_CACHEDB:
1510-
if (!is_replicated && cdb_update_urecord_metadata(_aor, 1) != 0)
1508+
if (!skip_replication && cdb_update_urecord_metadata(_aor, 1) != 0)
15111509
LM_ERR("failed to delete metadata, aor: %.*s\n",
15121510
_aor->len, _aor->s);
15131511
break;
@@ -1526,7 +1524,7 @@ int delete_urecord(udomain_t* _d, str* _aor, struct urecord* _r,
15261524
while(c) {
15271525
t = c;
15281526
c = c->next;
1529-
if (delete_ucontact(_r, t, is_replicated) < 0) {
1527+
if (delete_ucontact(_r, t, skip_replication) < 0) {
15301528
LM_ERR("deleting contact failed\n");
15311529
return -1;
15321530
}
@@ -1535,10 +1533,10 @@ int delete_urecord(udomain_t* _d, str* _aor, struct urecord* _r,
15351533
if (_r->no_clear_ref > 0)
15361534
return 0;
15371535

1538-
if (!is_replicated && location_cluster)
1536+
if (!skip_replication && location_cluster)
15391537
replicate_urecord_delete(_r);
15401538

1541-
release_urecord(_r, is_replicated);
1539+
release_urecord(_r, skip_replication);
15421540
return 0;
15431541
}
15441542

modules/usrloc/udomain.h

+2-13
Original file line numberDiff line numberDiff line change
@@ -120,29 +120,25 @@ void mem_delete_urecord(udomain_t* _d, struct urecord* _r);
120120
/*! \brief
121121
* Locks the domain hash entrie corresponding to AOR
122122
*/
123-
typedef void (*lock_udomain_t)(udomain_t* _d, str *_aor);
124123
void lock_udomain(udomain_t* _d, str *_aor);
125124

126125

127126
/*! \brief
128127
* Unlocks the domain hash entrie corresponding to AOR
129128
*/
130-
typedef void (*unlock_udomain_t)(udomain_t* _d, str *_aor);
131129
void unlock_udomain(udomain_t* _d, str *_aor);
132130

133131
struct ucontact* get_ucontact_from_id(udomain_t *d, uint64_t contact_id, struct urecord **_r);
134132

135133
/*! \brief
136134
* Locks the specific domain hash entrie
137135
*/
138-
typedef void (*lock_ulslot_t)(udomain_t* _d, int slot);
139136
void lock_ulslot(udomain_t* _d, int slot);
140137

141138

142139
/*! \brief
143140
* Unlocks the specific domain hash entrie
144141
*/
145-
typedef void (*unlock_ulslot_t)(udomain_t* _d, int slot);
146142
void unlock_ulslot(udomain_t* _d, int slot);
147143
#define _unlock_ulslot(domain, contact_id) \
148144
do { \
@@ -158,23 +154,18 @@ void unlock_ulslot(udomain_t* _d, int slot);
158154
/*! \brief
159155
* Create and insert a new record
160156
*/
161-
typedef int (*insert_urecord_t)(udomain_t* _d, str* _aor, struct urecord** _r,
162-
char is_replicated);
163157
int insert_urecord(udomain_t* _d, str* _aor, struct urecord** _r,
164-
char is_replicated);
158+
char skip_replication);
165159

166160
/*! \brief
167161
* Obtain a urecord pointer if the urecord exists in domain
168162
*/
169-
typedef int (*get_urecord_t)(udomain_t* _d, str* _a, struct urecord** _r);
170163
int get_urecord(udomain_t* _d, str* _aor, struct urecord** _r);
171164

172165
/*! \brief
173166
* Only relevant in a federation @cluster_mode.
174167
* Obtain urecord pointer if AoR exists in at least one location.
175168
*/
176-
typedef int
177-
(*get_global_urecord_t)(udomain_t* _d, str* _a, struct urecord** _r);
178169
int get_global_urecord(udomain_t* _d, str* _aor, struct urecord** _r);
179170

180171
int cdb_update_urecord_metadata(const str *_aor, int unpublish);
@@ -183,9 +174,7 @@ int cdb_update_urecord_metadata(const str *_aor, int unpublish);
183174
/*! \brief
184175
* Delete a urecord from domain
185176
*/
186-
typedef int (*delete_urecord_t)(udomain_t* _d, str* _a, struct urecord* _r,
187-
char is_replicated);
188177
int delete_urecord(udomain_t* _d, str* _aor, struct urecord* _r,
189-
char is_replicated);
178+
char skip_replication);
190179

191180
#endif /* UDOMAIN_H */

modules/usrloc/ul_callback.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,5 @@ int register_ulcb(ul_cb_type types, ul_cb f)
113113

114114
cbp->types = types;
115115

116-
return 1;
116+
return 0;
117117
}

modules/usrloc/ul_callback.h

-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ typedef enum ul_cb_types {
6161
* @type: type of the callback
6262
*/
6363
typedef void (ul_cb) (void *binding, ul_cb_type type);
64-
/*! \brief register callback function prototype */
65-
typedef int (*register_ulcb_t)(ul_cb_type types, ul_cb f);
6664

6765

6866
struct ul_callback {

modules/usrloc/urecord.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ static int cdb_build_ucontact_key(str* _ct, ucontact_info_t* _ci)
808808
* Release urecord previously obtained
809809
* through get_urecord
810810
*/
811-
void release_urecord(urecord_t* _r, char is_replicated)
811+
void release_urecord(urecord_t* _r, char skip_replication)
812812
{
813813
switch (cluster_mode) {
814814
case CM_SQL_ONLY:
@@ -830,7 +830,7 @@ void release_urecord(urecord_t* _r, char is_replicated)
830830
if (exists_ulcb_type(UL_AOR_DELETE))
831831
run_ul_callbacks(UL_AOR_DELETE, _r);
832832

833-
if (!is_replicated && location_cluster) {
833+
if (!skip_replication && location_cluster) {
834834
if (cluster_mode == CM_FEDERATION_CACHEDB &&
835835
cdb_update_urecord_metadata(&_r->aor, 1) != 0)
836836
LM_ERR("failed to delete metadata, aor: %.*s\n",
@@ -849,7 +849,7 @@ void release_urecord(urecord_t* _r, char is_replicated)
849849
* into urecord
850850
*/
851851
int insert_ucontact(urecord_t* _r, str* _contact, ucontact_info_t* _ci,
852-
ucontact_t** _c, char is_replicated)
852+
ucontact_t** _c, char skip_replication)
853853
{
854854
int first_contact = !_r->contacts;
855855

@@ -874,7 +874,7 @@ int insert_ucontact(urecord_t* _r, str* _contact, ucontact_info_t* _ci,
874874
return -1;
875875
}
876876

877-
if (!is_replicated && have_data_replication())
877+
if (!skip_replication && have_data_replication())
878878
replicate_ucontact_insert(_r, _contact, *_c);
879879

880880
if (exists_ulcb_type(UL_CONTACT_INSERT))
@@ -901,9 +901,9 @@ int insert_ucontact(urecord_t* _r, str* _contact, ucontact_info_t* _ci,
901901
/*! \brief
902902
* Delete ucontact from urecord
903903
*/
904-
int delete_ucontact(urecord_t* _r, struct ucontact* _c, char is_replicated)
904+
int delete_ucontact(urecord_t* _r, struct ucontact* _c, char skip_replication)
905905
{
906-
if (!is_replicated && have_data_replication())
906+
if (!skip_replication && have_data_replication())
907907
replicate_ucontact_delete(_r, _c);
908908

909909
if (exists_ulcb_type(UL_CONTACT_DELETE))

0 commit comments

Comments
 (0)