~ubuntu-branches/ubuntu/utopic/sipwitch/utopic

« back to all changes in this revision

Viewing changes to server/voip.cpp

  • Committer: Package Import Robot
  • Author(s): Jonas Smedegaard
  • Date: 2012-06-25 16:55:59 UTC
  • Revision ID: package-import@ubuntu.com-20120625165559-3g3z1w6qxysi9t08
* New upstream release.

* Update upstream source URL.
* Extend copyright coverage of packaging.
* Add Vcs-* URLs to control file.
* Unfuzz patch 1001.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright (C) 2008-2009 David Sugar, Tycho Softworks.
2
 
//
3
 
// This program is free software; you can redistribute it and/or modify
4
 
// it under the terms of the GNU General Public License as published by
5
 
// the Free Software Foundation; either version 3 of the License, or
6
 
// (at your option) any later version.
7
 
//
8
 
// This program is distributed in the hope that it will be useful,
9
 
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
11
 
// GNU General Public License for more details.
12
 
//
13
 
// You should have received a copy of the GNU General Public License
14
 
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 
 
16
 
#include "voip.h"
17
 
 
18
 
static int family = AF_INET;
19
 
 
20
 
namespace sip {
21
 
 
22
 
#ifdef  EXOSIP_API4
23
 
 
24
 
void add_authentication(context_t ctx, const char *user, const char *secret, const char *realm, bool automatic) 
25
 
{
26
 
    eXosip_lock(ctx);
27
 
    eXosip_add_authentication_info(ctx, user, user, secret, NULL, realm);
28
 
    if(automatic)
29
 
        eXosip_automatic_action(ctx);
30
 
    eXosip_unlock(ctx);
31
 
}
32
 
 
33
 
bool make_request_message(context_t ctx, const char *method, const char *to, const char *from, msg_t *msg, const char *route)
34
 
{
35
 
    if(!msg)
36
 
        return false;
37
 
 
38
 
    *msg = NULL;
39
 
    eXosip_lock(ctx);
40
 
    eXosip_message_build_request(ctx, msg, method, to, from, route);
41
 
    if(!*msg) {
42
 
        eXosip_unlock(ctx);
43
 
        return false;
44
 
    }
45
 
    return true;
46
 
}
47
 
 
48
 
bool make_response_message(context_t ctx, tid_t tid, int status, msg_t *msg)
49
 
{
50
 
    if(!msg)
51
 
        return false;
52
 
 
53
 
    *msg = NULL;
54
 
    eXosip_lock(ctx);
55
 
    eXosip_message_build_answer(ctx, tid, status, msg);
56
 
    if(!*msg) {
57
 
        eXosip_unlock(ctx);
58
 
        return false;
59
 
    }
60
 
    return true;
61
 
}
62
 
 
63
 
void send_response_message(context_t ctx, tid_t tid, int status, msg_t msg)
64
 
{
65
 
    if(!msg)
66
 
        eXosip_lock(ctx);
67
 
    eXosip_message_send_answer(ctx, tid, status, msg);
68
 
    eXosip_unlock(ctx);
69
 
}
70
 
 
71
 
bool make_ack_message(context_t ctx, did_t did, msg_t *msg)
72
 
{
73
 
    if(!msg)
74
 
        return false;
75
 
 
76
 
    *msg = NULL;
77
 
    eXosip_lock(ctx);
78
 
    eXosip_call_build_ack(ctx, did, msg);
79
 
    if(!*msg) {
80
 
        eXosip_unlock(ctx);
81
 
        return false;
82
 
    }
83
 
    return true;
84
 
}
85
 
 
86
 
void send_ack_message(context_t ctx, did_t tid, msg_t msg)
87
 
{
88
 
    if(!msg)
89
 
        eXosip_lock(ctx);
90
 
    eXosip_call_send_ack(ctx, tid, msg);
91
 
    eXosip_unlock(ctx);
92
 
}
93
 
 
94
 
bool make_prack_message(context_t ctx, tid_t tid, msg_t *msg)
95
 
{
96
 
    if(!msg)
97
 
        return false;
98
 
 
99
 
    *msg = NULL;
100
 
    eXosip_lock(ctx);
101
 
    eXosip_call_build_prack(ctx, tid, msg);
102
 
    if(!*msg) {
103
 
        eXosip_unlock(ctx);
104
 
        return false;
105
 
    }
106
 
    return true;
107
 
}
108
 
 
109
 
void send_prack_message(context_t ctx, tid_t tid, msg_t msg)
110
 
{
111
 
    if(!msg)
112
 
        eXosip_lock(ctx);
113
 
    eXosip_call_send_prack(ctx, tid, msg);
114
 
    eXosip_unlock(ctx);
115
 
}
116
 
 
117
 
bool make_answer_response(context_t ctx, tid_t tid, int status, msg_t *msg)
118
 
{
119
 
    if(!msg)
120
 
        return false;
121
 
 
122
 
    *msg = NULL;
123
 
    eXosip_lock(ctx);
124
 
    eXosip_call_build_answer(ctx, tid, status, msg);
125
 
    if(!*msg) {
126
 
        eXosip_unlock(ctx);
127
 
        return false;
128
 
    }
129
 
    return true;
130
 
}
131
 
 
132
 
void send_answer_response(context_t ctx, tid_t tid, int status, msg_t msg)
133
 
{
134
 
    if(!msg)
135
 
        eXosip_lock(ctx);
136
 
    eXosip_call_send_answer(ctx, tid, status, msg);
137
 
    eXosip_unlock(ctx);
138
 
}
139
 
 
140
 
void send_request_message(context_t ctx, msg_t msg)
141
 
{
142
 
    if(!msg)
143
 
        return;
144
 
 
145
 
    eXosip_message_send_request(ctx, msg);
146
 
    eXosip_unlock(ctx);
147
 
}
148
 
 
149
 
void release_call(context_t ctx, call_t cid, did_t did)
150
 
{
151
 
    eXosip_lock(ctx);
152
 
    eXosip_call_terminate(ctx, cid, did);
153
 
    eXosip_unlock(ctx);
154
 
}
155
 
 
156
 
bool make_dialog_request(context_t ctx, did_t did, const char *method, msg_t *msg)
157
 
{
158
 
    if(!msg)
159
 
        return false;
160
 
 
161
 
    *msg = NULL;
162
 
    eXosip_lock(ctx);
163
 
    eXosip_call_build_request(ctx, did, method, msg);
164
 
    if(!*msg) {
165
 
        eXosip_unlock(ctx);
166
 
        return false;
167
 
    }
168
 
 
169
 
    return true;
170
 
}
171
 
 
172
 
bool make_dialog_notify(context_t ctx, did_t did, int status, msg_t *msg)
173
 
{
174
 
    if(!msg)
175
 
        return false;
176
 
 
177
 
    *msg = NULL;
178
 
    eXosip_lock(ctx);
179
 
    eXosip_call_build_notify(ctx, did, status, msg);
180
 
    if(!*msg) {
181
 
        eXosip_unlock(ctx);
182
 
        return false;
183
 
    }
184
 
 
185
 
    return true;
186
 
}
187
 
 
188
 
bool make_dialog_update(context_t ctx, did_t did, msg_t *msg)
189
 
{
190
 
    if(!msg)
191
 
        return false;
192
 
 
193
 
    *msg = NULL;
194
 
    eXosip_lock(ctx);
195
 
    eXosip_call_build_update(ctx, did, msg);
196
 
    if(!*msg) {
197
 
        eXosip_unlock(ctx);
198
 
        return false;
199
 
    }
200
 
 
201
 
    return true;
202
 
}
203
 
 
204
 
bool make_dialog_refer(context_t ctx, did_t did, const char *to, msg_t *msg)
205
 
{
206
 
    if(!msg)
207
 
        return false;
208
 
 
209
 
    *msg = NULL;
210
 
    eXosip_lock(ctx);
211
 
    eXosip_call_build_refer(ctx, did, to, msg);
212
 
    if(!*msg) {
213
 
        eXosip_unlock(ctx);
214
 
        return false;
215
 
    }
216
 
 
217
 
    return true;
218
 
}
219
 
 
220
 
bool make_dialog_info(context_t ctx, did_t did, msg_t *msg)
221
 
{
222
 
    if(!msg)
223
 
        return false;
224
 
 
225
 
    *msg = NULL;
226
 
    eXosip_lock(ctx);
227
 
    eXosip_call_build_info(ctx, did, msg);
228
 
    if(!*msg) {
229
 
        eXosip_unlock(ctx);
230
 
        return false;
231
 
    }
232
 
 
233
 
    return true;
234
 
}
235
 
 
236
 
bool make_dialog_options(context_t ctx, did_t did, msg_t *msg)
237
 
{
238
 
    if(!msg)
239
 
        return false;
240
 
 
241
 
    *msg = NULL;
242
 
    eXosip_lock(ctx);
243
 
    eXosip_call_build_options(ctx, did, msg);
244
 
    if(!*msg) {
245
 
        eXosip_unlock(ctx);
246
 
        return false;
247
 
    }
248
 
 
249
 
    return true;
250
 
}
251
 
 
252
 
void send_dialog_message(context_t ctx, did_t did, msg_t msg)
253
 
{
254
 
    if(!msg)
255
 
        return;
256
 
 
257
 
    eXosip_call_send_request(ctx, did, msg);
258
 
    eXosip_unlock(ctx);
259
 
}
260
 
 
261
 
bool make_invite_request(context_t ctx, const char *to, const char *from, const char *subject, msg_t *msg, const char *route)
262
 
{
263
 
    *msg = NULL;
264
 
    eXosip_lock(ctx);
265
 
    eXosip_call_build_initial_invite(ctx, msg, to, from, route, subject);
266
 
    if(!*msg) {
267
 
        eXosip_unlock(ctx);
268
 
        return false;
269
 
    }
270
 
 
271
 
    return true;
272
 
}
273
 
 
274
 
call_t send_invite_request(context_t ctx, msg_t msg)
275
 
{
276
 
    if(!msg)
277
 
        return -1;
278
 
 
279
 
    int rtn = eXosip_call_send_initial_invite(ctx, msg);
280
 
    eXosip_unlock(ctx);
281
 
    return rtn;
282
 
}
283
 
 
284
 
reg_t make_registry_request(context_t ctx, const char *uri, const char *s, const char *c, unsigned exp, msg_t *msg) 
285
 
{
286
 
    *msg = NULL;
287
 
    eXosip_lock(ctx);
288
 
    reg_t rid = eXosip_register_build_initial_register(ctx, uri, s, c, exp, msg);
289
 
    if(!*msg)
290
 
        eXosip_unlock(ctx);
291
 
    return rid;
292
 
}
293
 
 
294
 
void send_registry_request(context_t c, reg_t r, msg_t msg) 
295
 
{
296
 
    if(!msg)
297
 
            return;
298
 
    eXosip_register_send_register(c, r, msg);
299
 
    eXosip_unlock(c);
300
 
}
301
 
 
302
 
bool release_registry(context_t ctx, reg_t rid)
303
 
{
304
 
    bool rtn = false;
305
 
    msg_t msg = NULL;
306
 
    eXosip_lock(ctx);
307
 
    eXosip_register_build_register(ctx, rid, 0, &msg);
308
 
    if(msg) {
309
 
        eXosip_register_send_register(ctx, rid, msg);
310
 
        rtn = true;
311
 
    }
312
 
    eXosip_unlock(ctx);
313
 
    return rtn;
314
 
}
315
 
 
316
 
void default_action(context_t ctx, event_t ev)
317
 
{
318
 
    eXosip_lock(ctx);
319
 
    eXosip_default_action(ctx, ev);
320
 
    eXosip_unlock(ctx);
321
 
}
322
 
 
323
 
void automatic_action(context_t ctx)
324
 
{
325
 
    eXosip_lock(ctx);
326
 
    eXosip_automatic_action(ctx);
327
 
    eXosip_unlock(ctx);
328
 
}
329
 
 
330
 
event_t get_event(context_t ctx, timeout_t timeout)
331
 
{
332
 
    unsigned s = timeout / 1000l;
333
 
    unsigned ms = timeout % 1000l;
334
 
    return eXosip_event_wait(ctx, s, ms);
335
 
}
336
 
 
337
 
bool listen(context_t ctx, int proto, const char *addr, unsigned port, bool tls)
338
 
{
339
 
    int tlsmode = 0;
340
 
 
341
 
    if(!ctx)
342
 
        return false;
343
 
 
344
 
#ifdef  AF_INET6
345
 
    if(family == AF_INET6 && !addr)
346
 
        addr = "::0";
347
 
#endif
348
 
    if(!addr)
349
 
        addr = "*";
350
 
 
351
 
    // port always even...
352
 
    port = port & 0xfffe;
353
 
    if(tls) {
354
 
        tlsmode = 1;
355
 
        ++port; // tls always next odd port...
356
 
    }
357
 
 
358
 
    if(eXosip_listen_addr(ctx, proto, addr, port, family, tlsmode))
359
 
        return false;
360
 
 
361
 
    return true;
362
 
}
363
 
 
364
 
void create(context_t *ctx, const char *agent, int f)
365
 
{
366
 
    *ctx = eXosip_malloc();
367
 
    eXosip_init(*ctx);
368
 
 
369
 
    if(agent)
370
 
        eXosip_set_user_agent(*ctx, agent);
371
 
 
372
 
    family = f;
373
 
 
374
 
#ifdef  AF_INET6
375
 
    if(family == AF_INET6)
376
 
        eXosip_enable_ipv6(1);
377
 
#endif
378
 
}
379
 
 
380
 
void release(context_t ctx)
381
 
{
382
 
    if(!ctx)
383
 
        return;
384
 
 
385
 
    eXosip_quit(ctx);
386
 
}
387
 
 
388
 
#else
389
 
 
390
 
static bool active = false;
391
 
 
392
 
void add_authentication(context_t ctx, const char *user, const char *secret, const char *realm, bool automatic) 
393
 
{
394
 
    eXosip_lock();
395
 
    eXosip_add_authentication_info(user, user, secret, NULL, realm);
396
 
    if(automatic)
397
 
        eXosip_automatic_action();
398
 
    eXosip_unlock();
399
 
}
400
 
 
401
 
bool make_request_message(context_t ctx, const char *method, const char *to, const char *from, msg_t *msg, const char *route)
402
 
{
403
 
    if(!msg)
404
 
        return false;
405
 
 
406
 
    *msg = NULL;
407
 
    eXosip_lock();
408
 
    eXosip_message_build_request(msg, method, to, from, route);
409
 
    if(!*msg) {
410
 
        eXosip_unlock();
411
 
        return false;
412
 
    }
413
 
    return true;
414
 
}
415
 
 
416
 
bool make_response_message(context_t ctx, tid_t tid, int status, msg_t *msg)
417
 
{
418
 
    if(!msg)
419
 
        return false;
420
 
 
421
 
    *msg = NULL;
422
 
    eXosip_lock();
423
 
    eXosip_message_build_answer(tid, status, msg);
424
 
    if(!*msg) {
425
 
        eXosip_unlock();
426
 
        return false;
427
 
    }
428
 
    return true;
429
 
}
430
 
 
431
 
void send_response_message(context_t ctx, tid_t tid, int status, msg_t msg)
432
 
{
433
 
    if(!msg)
434
 
        eXosip_lock();
435
 
    eXosip_message_send_answer(tid, status, msg);
436
 
    eXosip_unlock();
437
 
}
438
 
 
439
 
bool make_invite_request(context_t ctx, const char *to, const char *from, const char *subject, msg_t *msg, const char *route)
440
 
{
441
 
    *msg = NULL;
442
 
    eXosip_lock();
443
 
    eXosip_call_build_initial_invite(msg, to, from, route, subject);
444
 
    if(!*msg) {
445
 
        eXosip_unlock();
446
 
        return false;
447
 
    }
448
 
 
449
 
    return true;
450
 
}
451
 
 
452
 
call_t send_invite_request(context_t ctx, msg_t msg)
453
 
{
454
 
    if(!msg)
455
 
        return -1;
456
 
 
457
 
    int rtn = eXosip_call_send_initial_invite(msg);
458
 
    eXosip_unlock();
459
 
    return rtn;
460
 
}
461
 
 
462
 
bool make_answer_response(context_t ctx, tid_t tid, int status, msg_t *msg)
463
 
{
464
 
    if(!msg)
465
 
        return false;
466
 
    *msg = NULL;
467
 
    eXosip_lock();
468
 
    eXosip_call_build_answer(tid, status, msg);
469
 
    if(!*msg) {
470
 
        eXosip_unlock();
471
 
        return false;
472
 
    }
473
 
    return true;
474
 
}
475
 
 
476
 
void send_answer_response(context_t ctx, tid_t tid, int status, msg_t msg)
477
 
{
478
 
    if(!msg)
479
 
        eXosip_lock();
480
 
    eXosip_call_send_answer(tid, status, msg);
481
 
    eXosip_unlock();
482
 
}
483
 
 
484
 
 
485
 
void send_request_message(context_t ctx, msg_t msg)
486
 
{
487
 
    if(!msg)
488
 
        return;
489
 
 
490
 
    eXosip_message_send_request(msg);
491
 
    eXosip_unlock();
492
 
}
493
 
 
494
 
reg_t make_registry_request(context_t ctx, const char *uri, const char *s, const char *c, unsigned exp, msg_t *msg) 
495
 
{
496
 
    if(!msg)
497
 
        return -1;
498
 
 
499
 
    *msg = NULL;
500
 
    eXosip_lock();
501
 
    reg_t rid = eXosip_register_build_initial_register(uri, s, c, exp, msg);
502
 
    if(!msg)
503
 
        eXosip_unlock();
504
 
    return rid;
505
 
}
506
 
 
507
 
void send_registry_request(context_t c, reg_t r, msg_t msg) 
508
 
{
509
 
    if(!msg)
510
 
        return;
511
 
    eXosip_register_send_register(r, msg);
512
 
    eXosip_unlock();
513
 
}
514
 
 
515
 
bool release_registry(context_t ctx, reg_t rid)
516
 
{
517
 
    bool rtn = false;
518
 
    msg_t msg = NULL;
519
 
    eXosip_lock();
520
 
    eXosip_register_build_register(rid, 0, &msg);
521
 
    if(msg) {
522
 
        eXosip_register_send_register(rid, msg);
523
 
        rtn = true;
524
 
    }
525
 
    eXosip_unlock();
526
 
    return rtn;
527
 
}
528
 
 
529
 
void release_call(context_t ctx, call_t cid, did_t did)
530
 
{
531
 
    eXosip_lock();
532
 
    eXosip_call_terminate(cid, did);
533
 
    eXosip_unlock();
534
 
}
535
 
 
536
 
bool make_ack_message(context_t ctx, did_t did, msg_t *msg)
537
 
{
538
 
    if(!msg)
539
 
        return false;
540
 
 
541
 
    *msg = NULL;
542
 
    eXosip_lock();
543
 
    eXosip_call_build_ack(did, msg);
544
 
    if(!*msg) {
545
 
        eXosip_unlock();
546
 
        return false;
547
 
    }
548
 
    return true;
549
 
}
550
 
 
551
 
void send_ack_message(context_t ctx, did_t tid, msg_t msg)
552
 
{
553
 
    if(!msg)
554
 
        eXosip_lock();
555
 
    eXosip_call_send_ack(tid, msg);
556
 
    eXosip_unlock();
557
 
}
558
 
 
559
 
bool make_prack_message(context_t ctx, tid_t tid, msg_t *msg)
560
 
{
561
 
    if(!msg)
562
 
        return false;
563
 
 
564
 
    *msg = NULL;
565
 
    eXosip_lock();
566
 
    eXosip_call_build_prack(tid, msg);
567
 
    if(!*msg) {
568
 
        eXosip_unlock();
569
 
        return false;
570
 
    }
571
 
    return true;
572
 
}
573
 
 
574
 
void send_prack_message(context_t ctx, tid_t tid, msg_t msg)
575
 
{
576
 
    if(!msg)
577
 
        eXosip_lock();
578
 
    eXosip_call_send_prack(tid, msg);
579
 
    eXosip_unlock();
580
 
}
581
 
 
582
 
bool make_dialog_request(context_t ctx, did_t did, const char *method, msg_t *msg)
583
 
{
584
 
    if(!msg)
585
 
        return false;
586
 
 
587
 
    *msg = NULL;
588
 
    eXosip_lock();
589
 
    eXosip_call_build_request(did, method, msg);
590
 
    if(!*msg) {
591
 
        eXosip_unlock();
592
 
        return false;
593
 
    }
594
 
 
595
 
    return true;
596
 
}
597
 
 
598
 
bool make_dialog_notify(context_t ctx, did_t did, int status, msg_t *msg)
599
 
{
600
 
    if(!msg)
601
 
        return false;
602
 
 
603
 
    *msg = NULL;
604
 
    eXosip_lock();
605
 
    eXosip_call_build_notify(did, status, msg);
606
 
    if(!*msg) {
607
 
        eXosip_unlock();
608
 
        return false;
609
 
    }
610
 
 
611
 
    return true;
612
 
}
613
 
 
614
 
bool make_dialog_update(context_t ctx, did_t did, msg_t *msg)
615
 
{
616
 
    if(!msg)
617
 
        return false;
618
 
 
619
 
    *msg = NULL;
620
 
    eXosip_lock();
621
 
    eXosip_call_build_update(did, msg);
622
 
    if(!*msg) {
623
 
        eXosip_unlock();
624
 
        return false;
625
 
    }
626
 
 
627
 
    return true;
628
 
}
629
 
 
630
 
bool make_dialog_refer(context_t ctx, did_t did, const char *to, msg_t *msg)
631
 
{
632
 
    if(!msg)
633
 
        return false;
634
 
 
635
 
    *msg = NULL;
636
 
    eXosip_lock();
637
 
    eXosip_call_build_refer(did, to, msg);
638
 
    if(!*msg) {
639
 
        eXosip_unlock();
640
 
        return false;
641
 
    }
642
 
 
643
 
    return true;
644
 
}
645
 
 
646
 
bool make_dialog_info(context_t ctx, did_t did, msg_t *msg)
647
 
{
648
 
    if(!msg)
649
 
        return false;
650
 
 
651
 
    *msg = NULL;
652
 
    eXosip_lock();
653
 
    eXosip_call_build_info(did, msg);
654
 
    if(!*msg) {
655
 
        eXosip_unlock();
656
 
        return false;
657
 
    }
658
 
 
659
 
    return true;
660
 
}
661
 
 
662
 
bool make_dialog_options(context_t ctx, did_t did, msg_t *msg)
663
 
{
664
 
    if(!msg)
665
 
        return false;
666
 
 
667
 
    *msg = NULL;
668
 
    eXosip_lock();
669
 
    eXosip_call_build_options(did, msg);
670
 
    if(!*msg) {
671
 
        eXosip_unlock();
672
 
        return false;
673
 
    }
674
 
 
675
 
    return true;
676
 
}
677
 
 
678
 
void send_dialog_message(context_t ctx, did_t did, msg_t msg)
679
 
{
680
 
    if(!msg)
681
 
        return;
682
 
 
683
 
    eXosip_call_send_request(did, msg);
684
 
    eXosip_unlock();
685
 
}
686
 
 
687
 
void default_action(context_t ctx, event_t ev)
688
 
{
689
 
    eXosip_lock();
690
 
    eXosip_default_action(ev);
691
 
    eXosip_unlock();
692
 
}
693
 
 
694
 
void automatic_action(context_t ctx)
695
 
{
696
 
    eXosip_lock();
697
 
    eXosip_automatic_action();
698
 
    eXosip_unlock();
699
 
}
700
 
 
701
 
event_t get_event(context_t ctx, timeout_t timeout)
702
 
{
703
 
    unsigned s = timeout / 1000l;
704
 
    unsigned ms = timeout % 1000l;
705
 
    return eXosip_event_wait(s, ms);
706
 
}
707
 
 
708
 
bool listen(context_t ctx, int proto, const char *addr, unsigned port, bool tls)
709
 
{
710
 
    int tlsmode = 0;
711
 
 
712
 
#ifdef  AF_INET6
713
 
    if(family == AF_INET6 && !addr)
714
 
        addr = "::0";
715
 
#endif
716
 
    if(!addr)
717
 
        addr = "*";
718
 
 
719
 
    // port always even...
720
 
    port = port & 0xfffe;
721
 
    if(tls) {
722
 
        tlsmode = 1;
723
 
        ++port; // tls always next odd port...
724
 
    }
725
 
 
726
 
    if(eXosip_listen_addr(proto, addr, port, family, tlsmode))
727
 
        return false;
728
 
 
729
 
    return true;
730
 
}
731
 
 
732
 
void create(context_t *ctx, const char *agent, int f)
733
 
{
734
 
    if(active) {
735
 
        *ctx = NULL;
736
 
        return;
737
 
    }
738
 
    *ctx = (void *)-1;
739
 
    eXosip_init();
740
 
    active = true;
741
 
 
742
 
    if(agent)
743
 
        eXosip_set_user_agent(agent);
744
 
 
745
 
    family = f;
746
 
 
747
 
#ifdef  AF_INET6
748
 
    if(family == AF_INET6)
749
 
        eXosip_enable_ipv6(1);
750
 
#endif
751
 
}
752
 
 
753
 
void release(context_t ctx)
754
 
{
755
 
    if(!ctx || !active)
756
 
        return;
757
 
 
758
 
    active = false;
759
 
    eXosip_quit();
760
 
}
761
 
 
762
 
#endif
763
 
 
764
 
void release_event(event_t ev)
765
 
{
766
 
    if(ev)
767
 
        eXosip_event_free(ev);
768
 
}
769
 
 
770
 
}   // end namespace