1
// Copyright (C) 2008-2009 David Sugar, Tycho Softworks.
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.
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.
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/>.
18
static int family = AF_INET;
24
void add_authentication(context_t ctx, const char *user, const char *secret, const char *realm, bool automatic)
27
eXosip_add_authentication_info(ctx, user, user, secret, NULL, realm);
29
eXosip_automatic_action(ctx);
33
bool make_request_message(context_t ctx, const char *method, const char *to, const char *from, msg_t *msg, const char *route)
40
eXosip_message_build_request(ctx, msg, method, to, from, route);
48
bool make_response_message(context_t ctx, tid_t tid, int status, msg_t *msg)
55
eXosip_message_build_answer(ctx, tid, status, msg);
63
void send_response_message(context_t ctx, tid_t tid, int status, msg_t msg)
67
eXosip_message_send_answer(ctx, tid, status, msg);
71
bool make_ack_message(context_t ctx, did_t did, msg_t *msg)
78
eXosip_call_build_ack(ctx, did, msg);
86
void send_ack_message(context_t ctx, did_t tid, msg_t msg)
90
eXosip_call_send_ack(ctx, tid, msg);
94
bool make_prack_message(context_t ctx, tid_t tid, msg_t *msg)
101
eXosip_call_build_prack(ctx, tid, msg);
109
void send_prack_message(context_t ctx, tid_t tid, msg_t msg)
113
eXosip_call_send_prack(ctx, tid, msg);
117
bool make_answer_response(context_t ctx, tid_t tid, int status, msg_t *msg)
124
eXosip_call_build_answer(ctx, tid, status, msg);
132
void send_answer_response(context_t ctx, tid_t tid, int status, msg_t msg)
136
eXosip_call_send_answer(ctx, tid, status, msg);
140
void send_request_message(context_t ctx, msg_t msg)
145
eXosip_message_send_request(ctx, msg);
149
void release_call(context_t ctx, call_t cid, did_t did)
152
eXosip_call_terminate(ctx, cid, did);
156
bool make_dialog_request(context_t ctx, did_t did, const char *method, msg_t *msg)
163
eXosip_call_build_request(ctx, did, method, msg);
172
bool make_dialog_notify(context_t ctx, did_t did, int status, msg_t *msg)
179
eXosip_call_build_notify(ctx, did, status, msg);
188
bool make_dialog_update(context_t ctx, did_t did, msg_t *msg)
195
eXosip_call_build_update(ctx, did, msg);
204
bool make_dialog_refer(context_t ctx, did_t did, const char *to, msg_t *msg)
211
eXosip_call_build_refer(ctx, did, to, msg);
220
bool make_dialog_info(context_t ctx, did_t did, msg_t *msg)
227
eXosip_call_build_info(ctx, did, msg);
236
bool make_dialog_options(context_t ctx, did_t did, msg_t *msg)
243
eXosip_call_build_options(ctx, did, msg);
252
void send_dialog_message(context_t ctx, did_t did, msg_t msg)
257
eXosip_call_send_request(ctx, did, msg);
261
bool make_invite_request(context_t ctx, const char *to, const char *from, const char *subject, msg_t *msg, const char *route)
265
eXosip_call_build_initial_invite(ctx, msg, to, from, route, subject);
274
call_t send_invite_request(context_t ctx, msg_t msg)
279
int rtn = eXosip_call_send_initial_invite(ctx, msg);
284
reg_t make_registry_request(context_t ctx, const char *uri, const char *s, const char *c, unsigned exp, msg_t *msg)
288
reg_t rid = eXosip_register_build_initial_register(ctx, uri, s, c, exp, msg);
294
void send_registry_request(context_t c, reg_t r, msg_t msg)
298
eXosip_register_send_register(c, r, msg);
302
bool release_registry(context_t ctx, reg_t rid)
307
eXosip_register_build_register(ctx, rid, 0, &msg);
309
eXosip_register_send_register(ctx, rid, msg);
316
void default_action(context_t ctx, event_t ev)
319
eXosip_default_action(ctx, ev);
323
void automatic_action(context_t ctx)
326
eXosip_automatic_action(ctx);
330
event_t get_event(context_t ctx, timeout_t timeout)
332
unsigned s = timeout / 1000l;
333
unsigned ms = timeout % 1000l;
334
return eXosip_event_wait(ctx, s, ms);
337
bool listen(context_t ctx, int proto, const char *addr, unsigned port, bool tls)
345
if(family == AF_INET6 && !addr)
351
// port always even...
352
port = port & 0xfffe;
355
++port; // tls always next odd port...
358
if(eXosip_listen_addr(ctx, proto, addr, port, family, tlsmode))
364
void create(context_t *ctx, const char *agent, int f)
366
*ctx = eXosip_malloc();
370
eXosip_set_user_agent(*ctx, agent);
375
if(family == AF_INET6)
376
eXosip_enable_ipv6(1);
380
void release(context_t ctx)
390
static bool active = false;
392
void add_authentication(context_t ctx, const char *user, const char *secret, const char *realm, bool automatic)
395
eXosip_add_authentication_info(user, user, secret, NULL, realm);
397
eXosip_automatic_action();
401
bool make_request_message(context_t ctx, const char *method, const char *to, const char *from, msg_t *msg, const char *route)
408
eXosip_message_build_request(msg, method, to, from, route);
416
bool make_response_message(context_t ctx, tid_t tid, int status, msg_t *msg)
423
eXosip_message_build_answer(tid, status, msg);
431
void send_response_message(context_t ctx, tid_t tid, int status, msg_t msg)
435
eXosip_message_send_answer(tid, status, msg);
439
bool make_invite_request(context_t ctx, const char *to, const char *from, const char *subject, msg_t *msg, const char *route)
443
eXosip_call_build_initial_invite(msg, to, from, route, subject);
452
call_t send_invite_request(context_t ctx, msg_t msg)
457
int rtn = eXosip_call_send_initial_invite(msg);
462
bool make_answer_response(context_t ctx, tid_t tid, int status, msg_t *msg)
468
eXosip_call_build_answer(tid, status, msg);
476
void send_answer_response(context_t ctx, tid_t tid, int status, msg_t msg)
480
eXosip_call_send_answer(tid, status, msg);
485
void send_request_message(context_t ctx, msg_t msg)
490
eXosip_message_send_request(msg);
494
reg_t make_registry_request(context_t ctx, const char *uri, const char *s, const char *c, unsigned exp, msg_t *msg)
501
reg_t rid = eXosip_register_build_initial_register(uri, s, c, exp, msg);
507
void send_registry_request(context_t c, reg_t r, msg_t msg)
511
eXosip_register_send_register(r, msg);
515
bool release_registry(context_t ctx, reg_t rid)
520
eXosip_register_build_register(rid, 0, &msg);
522
eXosip_register_send_register(rid, msg);
529
void release_call(context_t ctx, call_t cid, did_t did)
532
eXosip_call_terminate(cid, did);
536
bool make_ack_message(context_t ctx, did_t did, msg_t *msg)
543
eXosip_call_build_ack(did, msg);
551
void send_ack_message(context_t ctx, did_t tid, msg_t msg)
555
eXosip_call_send_ack(tid, msg);
559
bool make_prack_message(context_t ctx, tid_t tid, msg_t *msg)
566
eXosip_call_build_prack(tid, msg);
574
void send_prack_message(context_t ctx, tid_t tid, msg_t msg)
578
eXosip_call_send_prack(tid, msg);
582
bool make_dialog_request(context_t ctx, did_t did, const char *method, msg_t *msg)
589
eXosip_call_build_request(did, method, msg);
598
bool make_dialog_notify(context_t ctx, did_t did, int status, msg_t *msg)
605
eXosip_call_build_notify(did, status, msg);
614
bool make_dialog_update(context_t ctx, did_t did, msg_t *msg)
621
eXosip_call_build_update(did, msg);
630
bool make_dialog_refer(context_t ctx, did_t did, const char *to, msg_t *msg)
637
eXosip_call_build_refer(did, to, msg);
646
bool make_dialog_info(context_t ctx, did_t did, msg_t *msg)
653
eXosip_call_build_info(did, msg);
662
bool make_dialog_options(context_t ctx, did_t did, msg_t *msg)
669
eXosip_call_build_options(did, msg);
678
void send_dialog_message(context_t ctx, did_t did, msg_t msg)
683
eXosip_call_send_request(did, msg);
687
void default_action(context_t ctx, event_t ev)
690
eXosip_default_action(ev);
694
void automatic_action(context_t ctx)
697
eXosip_automatic_action();
701
event_t get_event(context_t ctx, timeout_t timeout)
703
unsigned s = timeout / 1000l;
704
unsigned ms = timeout % 1000l;
705
return eXosip_event_wait(s, ms);
708
bool listen(context_t ctx, int proto, const char *addr, unsigned port, bool tls)
713
if(family == AF_INET6 && !addr)
719
// port always even...
720
port = port & 0xfffe;
723
++port; // tls always next odd port...
726
if(eXosip_listen_addr(proto, addr, port, family, tlsmode))
732
void create(context_t *ctx, const char *agent, int f)
743
eXosip_set_user_agent(agent);
748
if(family == AF_INET6)
749
eXosip_enable_ipv6(1);
753
void release(context_t ctx)
764
void release_event(event_t ev)
767
eXosip_event_free(ev);