-
Notifications
You must be signed in to change notification settings - Fork 908
/
dlist.c
806 lines (694 loc) · 18.1 KB
/
dlist.c
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
/*
* Copyright (C) 2001-2003 FhG Fokus
*
* This file is part of Kamailio, a free SIP server.
*
* Kamailio 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
*
* Kamailio 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
*
*/
/*! \file
* \brief USRLOC - List of registered domains
* \ingroup usrloc
*
* - Module: \ref usrloc
*/
#include "dlist.h"
#include <stdlib.h> /* abort */
#include <string.h> /* strlen, memcmp */
#include <stdio.h> /* printf */
#include "../../core/ut.h"
#include "../../lib/srdb1/db_ut.h"
#include "../../core/mem/shm_mem.h"
#include "../../core/dprint.h"
#include "../../core/ip_addr.h"
#include "../../core/socket_info.h"
#include "udomain.h" /* new_udomain, free_udomain */
#include "usrloc.h"
#include "utime.h"
#include "usrloc_mod.h"
extern int ul_version_table;
/*! \brief Global list of all registered domains */
dlist_t* root = 0;
unsigned int _ul_max_partition = 0;
void ul_set_max_partition(unsigned int m)
{
_ul_max_partition = m;
}
/*!
* \brief Find domain with the given name
* \param _n domain name
* \param _d pointer to domain
* \return 0 if the domain was found and 1 of not
*/
static inline int find_dlist(str* _n, dlist_t** _d)
{
dlist_t* ptr;
ptr = root;
while(ptr) {
if ((_n->len == ptr->name.len) &&
!memcmp(_n->s, ptr->name.s, _n->len)) {
*_d = ptr;
return 0;
}
ptr = ptr->next;
}
return 1;
}
/*!
* \brief Get all contacts from the database, in partitions if wanted
* \see get_all_ucontacts
* \param buf target buffer
* \param len length of buffer
* \param flags contact flags
* \param part_idx part index
* \param part_max maximal part
* \param options options
* \return 0 on success, positive if buffer size was not sufficient, negative on failure
*/
static inline int get_all_db_ucontacts(void *buf, int len, unsigned int flags,
unsigned int part_idx, unsigned int part_max,
int options)
{
struct socket_info *sock;
unsigned int dbflags;
db1_res_t* res = NULL;
db_row_t *row;
dlist_t *dom;
int port, proto;
char *p;
str addr;
str recv;
str path;
str ruid;
str host;
unsigned int aorhash;
int i;
void *cp;
int shortage, needed;
db_key_t keys1[4]; /* where */
db_val_t vals1[4];
db_op_t ops1[4];
db_key_t keys2[6]; /* select */
int n[2] = {2,6}; /* number of dynamic values used on key1/key2 */
cp = buf;
shortage = 0;
/* Reserve space for terminating 0000 */
len -= sizeof(addr.len);
aorhash = 0;
/* select fields */
keys2[0] = &received_col;
keys2[1] = &contact_col;
keys2[2] = &sock_col;
keys2[3] = &cflags_col;
keys2[4] = &path_col;
keys2[5] = &ruid_col;
/* where fields */
keys1[0] = &expires_col;
ops1[0] = OP_GT;
vals1[0].nul = 0;
UL_DB_EXPIRES_SET(&vals1[0], time(0));
keys1[1] = &partition_col;
ops1[1] = OP_EQ;
vals1[1].type = DB1_INT;
vals1[1].nul = 0;
if(_ul_max_partition>0)
vals1[1].val.int_val = part_idx;
else
vals1[1].val.int_val = 0;
if (flags & nat_bflag) {
keys1[n[0]] = &keepalive_col;
ops1[n[0]] = OP_EQ;
vals1[n[0]].type = DB1_INT;
vals1[n[0]].nul = 0;
vals1[n[0]].val.int_val = 1;
n[0]++;
}
if(options&GAU_OPT_SERVER_ID) {
keys1[n[0]] = &srv_id_col;
ops1[n[0]] = OP_EQ;
vals1[n[0]].type = DB1_INT;
vals1[n[0]].nul = 0;
vals1[n[0]].val.int_val = server_id;
n[0]++;
}
/* TODO: use part_idx and part_max on keys1 */
for (dom = root; dom!=NULL ; dom=dom->next) {
if (ul_dbf.use_table(ul_dbh, dom->d->name) < 0) {
LM_ERR("sql use_table failed\n");
return -1;
}
if (ul_dbf.query(ul_dbh, keys1, ops1, vals1, keys2,
n[0], n[1], NULL, &res) <0 ) {
LM_ERR("query error\n");
return -1;
}
if( RES_ROW_N(res)==0 ) {
ul_dbf.free_result(ul_dbh, res);
continue;
}
for(i = 0; i < RES_ROW_N(res); i++) {
row = RES_ROWS(res) + i;
/* received */
recv.s = (char*)VAL_STRING(ROW_VALUES(row));
if ( VAL_NULL(ROW_VALUES(row)) || recv.s==0 || recv.s[0]==0 ) {
recv.s = NULL;
recv.len = 0;
}
else {
recv.len = strlen(recv.s);
}
/* contact */
addr.s = (char*)VAL_STRING(ROW_VALUES(row)+1);
if (VAL_NULL(ROW_VALUES(row)+1) || addr.s==0 || addr.s[0]==0) {
LM_ERR("empty contact -> skipping\n");
continue;
}
else {
addr.len = strlen(addr.s);
}
/* path */
path.s = (char*)VAL_STRING(ROW_VALUES(row)+4);
if (VAL_NULL(ROW_VALUES(row)+4) || path.s==0 || path.s[0]==0){
path.s = NULL;
path.len = 0;
} else {
path.len = strlen(path.s);
}
/* ruid */
ruid.s = (char*)VAL_STRING(ROW_VALUES(row)+5);
if (VAL_NULL(ROW_VALUES(row)+5) || ruid.s==0 || ruid.s[0]==0){
ruid.s = NULL;
ruid.len = 0;
} else {
ruid.len = strlen(ruid.s);
}
needed = (int)(sizeof(addr.len) + addr.len
+ sizeof(recv.len) + recv.len
+ sizeof(sock) + sizeof(dbflags)
+ sizeof(path.len) + path.len
+ sizeof(ruid.len) + ruid.len
+ sizeof(aorhash));
if (len < needed) {
shortage += needed ;
continue;
}
/* write contact */
memcpy(cp, &addr.len, sizeof(addr.len));
cp = (char*)cp + sizeof(addr.len);
memcpy(cp, addr.s, addr.len);
cp = (char*)cp + addr.len;
/* write received */
memcpy(cp, &recv.len, sizeof(recv.len));
cp = (char*)cp + sizeof(recv.len);
/* copy received only if exist */
if(recv.len){
memcpy(cp, recv.s, recv.len);
cp = (char*)cp + recv.len;
}
/* sock */
p = (char*)VAL_STRING(ROW_VALUES(row) + 2);
if (VAL_NULL(ROW_VALUES(row)+2) || p==0 || p[0]==0){
sock = 0;
} else {
if (parse_phostport( p, &host.s, &host.len,
&port, &proto)!=0) {
LM_ERR("bad socket <%s>...set to 0\n", p);
sock = 0;
} else {
sock = grep_sock_info( &host, (unsigned short)port, proto);
if (sock==0) {
LM_DBG("non-local socket <%s>...set to 0\n", p);
}
}
}
/* flags */
dbflags = VAL_BITMAP(ROW_VALUES(row) + 3);
/* write sock and flags */
memcpy(cp, &sock, sizeof(sock));
cp = (char*)cp + sizeof(sock);
memcpy(cp, &dbflags, sizeof(dbflags));
cp = (char*)cp + sizeof(dbflags);
/* write path */
memcpy(cp, &path.len, sizeof(path.len));
cp = (char*)cp + sizeof(path.len);
/* copy path only if exist */
if(path.len){
memcpy(cp, path.s, path.len);
cp = (char*)cp + path.len;
}
/* write ruid */
memcpy(cp, &ruid.len, sizeof(ruid.len));
cp = (char*)cp + sizeof(ruid.len);
/* copy ruid only if exist */
if(ruid.len){
memcpy(cp, ruid.s, ruid.len);
cp = (char*)cp + ruid.len;
}
/* aorhash not used for db-only records, but it is added
* (as 0) to match the struct used for mem records */
memcpy(cp, &aorhash, sizeof(aorhash));
cp = (char*)cp + sizeof(aorhash);
len -= needed;
} /* row cycle */
ul_dbf.free_result(ul_dbh, res);
} /* domain cycle */
/* len < 0 is possible, if size of the buffer < sizeof(c->c.len) */
if (len >= 0)
memset(cp, 0, sizeof(addr.len));
/* Shouldn't happen */
if (shortage > 0 && len > shortage) {
abort();
}
shortage -= len;
return shortage > 0 ? shortage : 0;
}
/*!
* \brief Get all contacts from the memory, in partitions if wanted
* \see get_all_ucontacts
* \param buf target buffer
* \param len length of buffer
* \param flags contact flags
* \param part_idx part index
* \param part_max maximal part
* \param options options
* \return 0 on success, positive if buffer size was not sufficient, negative on failure
*/
static inline int get_all_mem_ucontacts(void *buf, int len, unsigned int flags,
unsigned int part_idx, unsigned int part_max,
int options)
{
dlist_t *p;
urecord_t *r;
ucontact_t *c;
void *cp;
int shortage;
int needed;
int i = 0;
cp = buf;
shortage = 0;
time_t tnow = 0;
if(ul_keepalive_timeout>0)
tnow = time(NULL);
/* Reserve space for terminating 0000 */
len -= sizeof(c->c.len);
for (p = root; p != NULL; p = p->next) {
for(i=0; i<p->d->size; i++) {
if ( (i % part_max) != part_idx )
continue;
lock_ulslot(p->d, i);
if(p->d->table[i].n<=0)
{
unlock_ulslot(p->d, i);
continue;
}
for (r = p->d->table[i].first; r != NULL; r = r->next) {
for (c = r->contacts; c != NULL; c = c->next) {
if (c->c.len <= 0)
continue;
/*
* List only contacts that have all requested
* flags set
*/
if ((c->cflags & flags) != flags)
continue;
if(options&GAU_OPT_SERVER_ID && server_id!=c->server_id)
continue;
if(ul_keepalive_timeout>0 && c->last_keepalive>0)
{
if(c->sock!=NULL && c->sock->proto==PROTO_UDP)
{
if(c->last_keepalive+ul_keepalive_timeout < tnow)
{
/* set contact as expired in 10s */
if(c->expires > tnow + 10)
c->expires = tnow + 10;
continue;
}
}
}
needed = (int)(sizeof(c->c.len) + c->c.len
+ sizeof(c->received.len) + c->received.len
+ sizeof(c->sock) + sizeof(c->cflags)
+ sizeof(c->path.len) + c->path.len
+ sizeof(c->ruid.len) + c->ruid.len
+ sizeof(r->aorhash));
if (len >= needed) {
memcpy(cp, &c->c.len, sizeof(c->c.len));
cp = (char*)cp + sizeof(c->c.len);
memcpy(cp, c->c.s, c->c.len);
cp = (char*)cp + c->c.len;
memcpy(cp,&c->received.len,sizeof(c->received.len));
cp = (char*)cp + sizeof(c->received.len);
memcpy(cp, c->received.s, c->received.len);
cp = (char*)cp + c->received.len;
memcpy(cp, &c->sock, sizeof(c->sock));
cp = (char*)cp + sizeof(c->sock);
memcpy(cp, &c->cflags, sizeof(c->cflags));
cp = (char*)cp + sizeof(c->cflags);
memcpy(cp, &c->path.len, sizeof(c->path.len));
cp = (char*)cp + sizeof(c->path.len);
memcpy(cp, c->path.s, c->path.len);
cp = (char*)cp + c->path.len;
memcpy(cp, &c->ruid.len, sizeof(c->ruid.len));
cp = (char*)cp + sizeof(c->ruid.len);
memcpy(cp, c->ruid.s, c->ruid.len);
cp = (char*)cp + c->ruid.len;
memcpy(cp, &r->aorhash, sizeof(r->aorhash));
cp = (char*)cp + sizeof(r->aorhash);
len -= needed;
} else {
shortage += needed;
}
}
}
unlock_ulslot(p->d, i);
}
}
/* len < 0 is possible, if size of the buffer < sizeof(c->c.len) */
if (len >= 0)
memset(cp, 0, sizeof(c->c.len));
/* Shouldn't happen */
if (shortage > 0 && len > shortage) {
abort();
}
shortage -= len;
return shortage > 0 ? shortage : 0;
}
/*!
* \brief Get all contacts from the usrloc, in partitions if wanted
*
* Return list of all contacts for all currently registered
* users in all domains. The caller must provide buffer of
* sufficient length for fitting all those contacts. In the
* case when buffer was exhausted, the function returns
* estimated amount of additional space needed, in this
* case the caller is expected to repeat the call using
* this value as the hint.
*
* Information is packed into the buffer as follows:
*
* +------------+----------+-----+------+-----+
* |contact1.len|contact1.s|sock1|flags1|path1|
* +------------+----------+-----+------+-----+
* |contact2.len|contact2.s|sock2|flags2|path1|
* +------------+----------+-----+------+-----+
* |..........................................|
* +------------+----------+-----+------+-----+
* |contactN.len|contactN.s|sockN|flagsN|pathN|
* +------------+----------+-----+------+-----+
* |000000000000|
* +------------+
*
* \param buf target buffer
* \param len length of buffer
* \param flags contact flags
* \param part_idx part index
* \param part_max maximal part
* \param options options
* \return 0 on success, positive if buffer size was not sufficient, negative on failure
*/
int get_all_ucontacts(void *buf, int len, unsigned int flags,
unsigned int part_idx, unsigned int part_max,
int options)
{
if (db_mode==DB_ONLY)
return get_all_db_ucontacts( buf, len, flags, part_idx, part_max, options);
else
return get_all_mem_ucontacts( buf, len, flags, part_idx, part_max, options);
}
/**
*
*/
int ul_refresh_keepalive(unsigned int _aorhash, str *_ruid)
{
dlist_t *p;
urecord_t *r;
ucontact_t *c;
int i;
/* todo: get location domain via param */
for (p = root; p != NULL; p = p->next)
{
i = _aorhash&(p->d->size-1);
lock_ulslot(p->d, i);
if(p->d->table[i].n<=0)
{
unlock_ulslot(p->d, i);
continue;
}
for (r = p->d->table[i].first; r != NULL; r = r->next)
{
if(r->aorhash==_aorhash)
{
for (c = r->contacts; c != NULL; c = c->next)
{
if (c->c.len <= 0 || c->ruid.len<=0)
continue;
if(c->ruid.len==_ruid->len
&& !memcmp(c->ruid.s, _ruid->s, _ruid->len))
{
/* found */
c->last_keepalive = time(NULL);
LM_DBG("updated keepalive for [%.*s:%u] to %u\n",
_ruid->len, _ruid->s, _aorhash,
(unsigned int)c->last_keepalive);
unlock_ulslot(p->d, i);
return 0;
}
}
}
}
unlock_ulslot(p->d, i);
}
return 0;
}
/*!
* \brief Create a new domain structure
* \return 0 if everything went OK, otherwise value < 0 is returned
*
* \note The structure is NOT created in shared memory so the
* function must be called before the server forks if it should
* be available to all processes
*/
static inline int new_dlist(str* _n, dlist_t** _d)
{
dlist_t* ptr;
/* Domains are created before ser forks,
* so we can create them using pkg_malloc
*/
ptr = (dlist_t*)shm_malloc(sizeof(dlist_t));
if (ptr == 0) {
LM_ERR("no more share memory\n");
return -1;
}
memset(ptr, 0, sizeof(dlist_t));
/* copy domain name as null terminated string */
ptr->name.s = (char*)shm_malloc(_n->len+1);
if (ptr->name.s == 0) {
LM_ERR("no more memory left\n");
shm_free(ptr);
return -2;
}
memcpy(ptr->name.s, _n->s, _n->len);
ptr->name.len = _n->len;
ptr->name.s[ptr->name.len] = 0;
if (new_udomain(&(ptr->name), ul_hash_size, &(ptr->d)) < 0) {
LM_ERR("creating domain structure failed\n");
shm_free(ptr->name.s);
shm_free(ptr);
return -3;
}
*_d = ptr;
return 0;
}
/*!
* \brief Registers a new domain with usrloc
*
* Find and return a usrloc domain (location table)
* \param _n domain name
* \param _d usrloc domain
* \return 0 on success, -1 on failure
*/
int get_udomain(const char* _n, udomain_t** _d)
{
dlist_t* d;
str s;
if(_n == NULL) {
LM_ERR("null location table name\n");
goto notfound;
}
s.s = (char*)_n;
s.len = strlen(_n);
if(s.len <= 0) {
LM_ERR("empty location table name\n");
goto notfound;
}
if (find_dlist(&s, &d) == 0) {
*_d = d->d;
return 0;
}
notfound:
*_d = NULL;
return -1;
}
/*!
* \brief Registers a new domain with usrloc
*
* Registers a new domain with usrloc. If the domain exists,
* a pointer to existing structure will be returned, otherwise
* a new domain will be created
* \param _n domain name
* \param _d new created domain
* \return 0 on success, -1 on failure
*/
int register_udomain(const char* _n, udomain_t** _d)
{
dlist_t* d;
str s;
db1_con_t* con;
s.s = (char*)_n;
s.len = strlen(_n);
if (find_dlist(&s, &d) == 0) {
*_d = d->d;
return 0;
}
if (new_dlist(&s, &d) < 0) {
LM_ERR("failed to create new domain\n");
return -1;
}
/* Test tables from database if we are gonna
* to use database
*/
if (db_mode != NO_DB) {
con = ul_dbf.init(&db_url);
if (!con) {
LM_ERR("failed to open database connection\n");
goto dberror;
}
if(ul_version_table != 0
&& db_check_table_version(&ul_dbf, con, &s, UL_TABLE_VERSION) < 0) {
DB_TABLE_VERSION_ERROR(s);
goto dberror;
}
/* test if DB really exists */
if (testdb_udomain(con, d->d) < 0) {
LM_ERR("testing domain '%.*s' failed\n", s.len, ZSW(s.s));
goto dberror;
}
ul_dbf.close(con);
con = 0;
}
d->next = root;
root = d;
*_d = d->d;
return 0;
dberror:
if (con) ul_dbf.close(con);
con = 0;
free_udomain(d->d);
shm_free(d->name.s);
shm_free(d);
return -1;
}
/*!
* \brief Free all allocated memory for domains
*/
void free_all_udomains(void)
{
dlist_t* ptr;
while(root) {
ptr = root;
root = root->next;
free_udomain(ptr->d);
shm_free(ptr->name.s);
shm_free(ptr);
}
}
/*!
* \brief Print all domains, just for debugging
* \param _f output file
*/
void print_all_udomains(FILE* _f)
{
dlist_t* ptr;
ptr = root;
fprintf(_f, "===Domain list===\n");
while(ptr) {
print_udomain(_f, ptr->d);
ptr = ptr->next;
}
fprintf(_f, "===/Domain list===\n");
}
/*!
* \brief Loops through all domains summing up the number of users
* \return the number of users, could be zero
*/
unsigned long get_number_of_users(void)
{
long numberOfUsers = 0;
dlist_t* current_dlist;
current_dlist = root;
while (current_dlist)
{
numberOfUsers += get_stat_val(current_dlist->d->users);
current_dlist = current_dlist->next;
}
return numberOfUsers;
}
/*!
* \brief Run timer handler of all domains
* \return 0 if all timer return 0, != 0 otherwise
*/
int synchronize_all_udomains(int istart, int istep)
{
int res = 0;
dlist_t* ptr;
get_act_time(); /* Get and save actual time */
if (db_mode==DB_ONLY) {
for( ptr=root ; ptr ; ptr=ptr->next)
res |= db_timer_udomain(ptr->d);
} else {
for( ptr=root ; ptr ; ptr=ptr->next)
mem_timer_udomain(ptr->d, istart, istep);
}
return res;
}
/*!
* \brief Run timer handler to clean all domains in db
* \return 0 if all timer return 0, != 0 otherwise
*/
int ul_db_clean_udomains(void)
{
int res = 0;
dlist_t* ptr;
get_act_time(); /* Get and save actual time */
for( ptr=root ; ptr ; ptr=ptr->next)
res |= db_timer_udomain(ptr->d);
return res;
}
/*!
* \brief Find a particular domain, small wrapper around find_dlist
* \param _d domain name
* \param _p pointer to domain if found
* \return 1 if domain was found, 0 otherwise
*/
int find_domain(str* _d, udomain_t** _p)
{
dlist_t* d;
if (find_dlist(_d, &d) == 0) {
*_p = d->d;
return 0;
}
return 1;
}