17 #include <sipwitch-config.h>
18 #include <ucommon/ucommon.h>
19 #include <ucommon/export.h>
24 static int family = AF_INET;
28 bool voip::publish(
voip::context_t ctx,
const char *uri,
const char *contact,
const char *event,
const char *duration,
const char *type,
const char *body)
59 void voip::add_authentication(context_t ctx,
const char *user,
const char *secret,
const char *realm,
bool automatic)
75 bool voip::make_request_message(context_t ctx,
const char *method,
const char *to,
const char *from, msg_t *msg,
const char *route)
326 bool voip::make_invite_request(context_t ctx,
const char *to,
const char *from,
const char *subject, msg_t *msg,
const char *route)
397 unsigned s = timeout / 1000l;
398 unsigned ms = timeout % 1000l;
402 bool voip::listen(context_t ctx,
int proto,
const char *addr,
unsigned port,
bool tls)
410 if(family == AF_INET6 && addr && (!strcmp(addr,
"::0") || !strcmp(addr,
"::*")))
413 if(addr && !strcmp(addr,
"*"))
417 port = port & 0xfffe;
429 void voip::create(context_t *ctx,
const char *agent,
int f)
440 if(family == AF_INET6)
455 static bool active =
false;
457 bool voip::publish(
voip::context_t ctx,
const char *uri,
const char *contact,
const char *event,
const char *duration,
const char *type,
const char *body)
827 unsigned s = timeout / 1000l;
828 unsigned ms = timeout % 1000l;
837 if(family == AF_INET6 && addr && (!strcmp(addr,
"::0") || !strcmp(addr,
"::*")))
840 if(addr && !strcmp(addr,
"*"))
844 port = port & 0xfffe;
872 if(family == AF_INET6)
902 shell::printf(
"%s", text);
914 osip_message_set_header(msg,
ALLOW,
"INVITE,ACK,CANCEL,OPTIONS,INFO,REFER,MESSAGE,SUBSCRIBE,NOTIFY,REGISTER,PRACK");
943 attach(msg, type, body, strlen(body));
int eXosip_options_build_answer(struct eXosip_t *excontext, int tid, int status, osip_message_t **answer)
Build answer for an OPTIONS request.
Structure for SIP Message (REQUEST and RESPONSE).
static void automatic_action(context_t ctx)
static void call_reference(context_t ctx, call_t cid, void *route)
int eXosip_publish(struct eXosip_t *excontext, osip_message_t *message, const char *to)
Send an Publication Message (PUBLISH request).
int eXosip_call_build_request(struct eXosip_t *excontext, int did, const char *method, osip_message_t **request)
Build a default request within a call.
static void add_authentication(context_t ctx, const char *user, const char *secret, const char *realm, bool automatic=false)
static void release(context_t ctx)
void eXosip_set_user_agent(struct eXosip_t *excontext, const char *user_agent)
Set the SIP User-Agent: header string.
int eXosip_register_build_register(struct eXosip_t *excontext, int rid, int expires, osip_message_t **reg)
Build a new REGISTER request for an existing registration.
int eXosip_message_send_request(struct eXosip_t *excontext, osip_message_t *message)
Send an request.
static bool make_prack_message(context_t ctx, tid_t tid, msg_t *msg)
int eXosip_call_send_prack(struct eXosip_t *excontext, int tid, osip_message_t *prack)
Send a PRACK for invite.
static bool make_answer_response(context_t ctx, tid_t tid, int status, msg_t *msg)
int eXosip_lock(struct eXosip_t *excontext)
Lock the eXtented oSIP library.
static void send_ack_message(context_t ctx, did_t did, msg_t msg=NULL)
int eXosip_call_set_reference(struct eXosip_t *excontext, int id, void *reference)
Set a new application context for an existing call.
Structure for event description.
int eXosip_message_build_request(struct eXosip_t *excontext, osip_message_t **message, const char *method, const char *to, const char *from, const char *route)
Build a default request message.
int eXosip_call_send_request(struct eXosip_t *excontext, int did, osip_message_t *request)
send the request within call.
void eXosip_event_free(eXosip_event_t *je)
Free ressource in an eXosip event.
int eXosip_default_action(struct eXosip_t *excontext, eXosip_event_t *je)
Initiate some default actions:
int eXosip_build_publish(struct eXosip_t *excontext, osip_message_t **message, const char *to, const char *from, const char *route, const char *event, const char *expires, const char *ctype, const char *body)
build publication for a user.
static void send_registry_request(context_t ctx, reg_t rid, msg_t msg)
int eXosip_message_send_answer(struct eXosip_t *excontext, int tid, int status, osip_message_t *answer)
Send answer for a request.
int eXosip_init(struct eXosip_t *excontext)
Initiate the eXtented oSIP library.
int osip_message_set_content_type(osip_message_t *sip, const char *hvalue)
Set the Content-type header.
static bool make_request_message(context_t ctx, const char *method, const char *to, const char *from, msg_t *msg, const char *route=NULL)
void eXosip_quit(struct eXosip_t *excontext)
Release ressource used by the eXtented oSIP library.
static bool publish(context_t ctx, const char *uri, const char *contact, const char *event, const char *duration, const char *type, const char *body)
static bool make_ack_message(context_t ctx, did_t did, msg_t *msg)
int osip_message_set_header(osip_message_t *sip, const char *hname, const char *hvalue)
Allocate and Add an "unknown" header (not defined in oSIP).
int eXosip_call_build_refer(struct eXosip_t *excontext, int did, const char *refer_to, osip_message_t **request)
Build a default REFER for a call transfer.
int eXosip_call_terminate(struct eXosip_t *excontext, int cid, int did)
Terminate a call.
static call_t send_invite_request(context_t ctx, msg_t msg)
static void release_event(event_t ev)
static void send_dialog_message(context_t ctx, did_t did, msg_t msg)
int eXosip_register_build_initial_register(struct eXosip_t *excontext, const char *from, const char *proxy, const char *contact, int expires, osip_message_t **reg)
Build initial REGISTER request.
static bool make_dialog_info(context_t ctx, did_t did, msg_t *msg)
static bool make_dialog_request(context_t ctx, did_t did, const char *method, msg_t *msg)
int eXosip_options_send_answer(struct eXosip_t *excontext, int tid, int status, osip_message_t *answer)
Send answer for an OPTIONS request.
void osip_message_free(osip_message_t *sip)
Free all resource in a osip_message_t element.
static void server_requires(voip::msg_t msg, const char *txt)
#define osip_message_set_supported(sip, value)
Allocate and Add a new Supported header.
static bool make_options_response(context_t ctx, tid_t tid, int status, msg_t *msg)
static void send_options_response(context_t ctx, tid_t tid, int status, msg_t msg=NULL)
int eXosip_add_authentication_info(struct eXosip_t *excontext, const char *username, const char *userid, const char *passwd, const char *ha1, const char *realm)
Add authentication credentials.
int eXosip_call_build_prack(struct eXosip_t *excontext, int tid, osip_message_t **prack)
Build a PRACK for invite.
int eXosip_unlock(struct eXosip_t *excontext)
UnLock the eXtented oSIP library.
int eXosip_register_send_register(struct eXosip_t *excontext, int rid, osip_message_t *reg)
Send a REGISTER request for an existing registration.
int eXosip_call_build_initial_invite(struct eXosip_t *excontext, osip_message_t **invite, const char *to, const char *from, const char *route, const char *subject)
Build a default INVITE message for a new call.
int eXosip_set_option(struct eXosip_t *excontext, int opt, const void *value)
Set eXosip options.
static bool make_dialog_notify(context_t ctx, did_t did, int status, msg_t *msg)
int eXosip_call_send_ack(struct eXosip_t *excontext, int did, osip_message_t *ack)
Send the ACK for the 200ok received.
static bool listen(context_t ctx, int proto=IPPROTO_UDP, const char *iface=NULL, unsigned port=5060, bool tls=false)
static void attach(msg_t msg, const char *type, const char *body)
static void server_supports(voip::msg_t msg, const char *txt)
static bool make_dialog_options(context_t ctx, did_t did, msg_t *msg)
static void release_call(context_t ctx, call_t cid, did_t did)
int eXosip_call_build_ack(struct eXosip_t *excontext, int did, osip_message_t **ack)
Build a default ACK for a 200ok received.
int eXosip_call_build_notify(struct eXosip_t *excontext, int did, int subscription_status, osip_message_t **request)
Build a default NOTIFY within a call.
static void send_response_message(context_t ctx, tid_t tid, int status, msg_t msg=NULL)
int osip_message_to_str(osip_message_t *sip, char **dest, size_t *message_length)
Get a string representation of a osip_message_t element.
int eXosip_message_build_answer(struct eXosip_t *excontext, int tid, int status, osip_message_t **answer)
Build answer for a request.
static void send_answer_response(context_t ctx, tid_t tid, int status, msg_t msg=NULL)
struct eXosip_t * eXosip_malloc(void)
Allocate an eXosip context.
static void free_message_request(context_t ctx, voip::msg_t msg)
eXosip_event_t * eXosip_event_wait(struct eXosip_t *excontext, int tv_s, int tv_ms)
Wait for an eXosip event.
static void default_action(context_t ctx, event_t ev)
static void send_prack_message(context_t ctx, tid_t tid, msg_t msg)
int eXosip_call_send_initial_invite(struct eXosip_t *excontext, osip_message_t *invite)
Initiate a call.
void eXosip_automatic_action(struct eXosip_t *excontext)
Initiate some automatic actions:
static void option(context_t ctx, int opt, const void *value)
static bool make_dialog_refer(context_t ctx, did_t did, const char *to, msg_t *msg)
static void send_request_message(context_t ctx, msg_t msg)
int eXosip_call_send_answer(struct eXosip_t *excontext, int tid, int status, osip_message_t *answer)
Send Answer for invite.
int eXosip_call_build_options(struct eXosip_t *excontext, int did, osip_message_t **request)
Build a default OPTIONS within a call.
static bool make_dialog_update(context_t ctx, did_t did, msg_t *msg)
static void server_accepts(voip::msg_t msg)
static bool make_response_message(context_t ctx, tid_t tid, int status, msg_t *msg)
int eXosip_call_build_info(struct eXosip_t *excontext, int did, osip_message_t **request)
Build a default INFO within a call.
static void show(msg_t msg)
static bool make_invite_request(context_t ctx, const char *to, const char *from, const char *subject, msg_t *msg, const char *route=NULL)
static reg_t make_registry_request(context_t ctx, const char *uri, const char *s, const char *c, unsigned exp, msg_t *msg)
static void server_allows(voip::msg_t msg)
int eXosip_listen_addr(struct eXosip_t *excontext, int transport, const char *addr, int port, int family, int secure)
Listen on a specified socket.
int osip_message_set_body(osip_message_t *sip, const char *buf, size_t length)
Set the Body of the SIP message.
static void header(msg_t msg, const char *key, const char *value)
void eXosip_enable_ipv6(int ipv6_enable)
Use IPv6 instead of IPv4.
#define osip_message_set_require(sip, value)
Allocate and Add a new Require header.
int eXosip_call_build_answer(struct eXosip_t *excontext, int tid, int status, osip_message_t **answer)
Build default Answer for request.
int eXosip_call_build_update(struct eXosip_t *excontext, int did, osip_message_t **request)
Build a default UPDATE within a call.
static bool release_registry(context_t ctx, reg_t rid)
static void create(context_t *ctx, const char *agent, int family=AF_INET)
static event_t get_event(context_t ctx, timeout_t timeout)