23#include <pjsip_simple.h> 
   24#include <pjsip/sip_transaction.h> 
   27#include <pjmedia/errno.h> 
   31#include "pjsip/sip_parser.h" 
   66#define MOD_DATA_CONTACT "contact" 
   69#define SERIALIZER_POOL_SIZE        8 
   94    time_t t = time(
NULL);
 
   97    strftime(date, 
sizeof(date), 
"%a, %d %b %Y %T GMT", &tm);
 
 
  104    pjsip_module **
module = data;
 
  106        ast_log(
LOG_ERROR, 
"There is no PJSIP endpoint. Unable to register services\n");
 
  110        ast_log(
LOG_ERROR, 
"Unable to register module %.*s\n", (
int) pj_strlen(&(*module)->name), pj_strbuf(&(*module)->name));
 
  113    ast_debug(1, 
"Registered SIP service %.*s (%p)\n", (
int) pj_strlen(&(*module)->name), pj_strbuf(&(*module)->name), *module);
 
 
  124    pjsip_module **
module = data;
 
  129    ast_debug(1, 
"Unregistered SIP service %.*s\n", (
int) pj_strlen(&(*module)->name), pj_strbuf(&(*module)->name));
 
 
  147    ast_debug(1, 
"Registered SIP authenticator module %p\n", auth);
 
 
  155        ast_log(
LOG_WARNING, 
"Trying to unregister authenticator %p but authenticator %p registered\n",
 
  160    ast_debug(1, 
"Unregistered SIP authenticator %p\n", auth);
 
 
  166        && !pjsip_method_cmp(&rdata->msg_info.msg->line.req.method, &pjsip_options_method)) {
 
  167        ast_debug(3, 
"Skipping OPTIONS authentication due to endpoint configuration\n");
 
  172        ast_log(
LOG_WARNING, 
"No SIP authenticator registered. Assuming authentication is not required\n");
 
 
  180        pjsip_rx_data *rdata, pjsip_tx_data *tdata)
 
  183        ast_log(
LOG_WARNING, 
"No SIP authenticator registered. Assuming authentication is successful\n");
 
 
  198    ast_debug(1, 
"Registered SIP outbound authenticator module %p\n", auth);
 
 
  206        ast_log(
LOG_WARNING, 
"Trying to unregister outbound authenticator %p but outbound authenticator %p registered\n",
 
  211    ast_debug(1, 
"Unregistered SIP outbound authenticator %p\n", auth);
 
 
  215        pjsip_tx_data *old_request, pjsip_tx_data **new_request)
 
  218        ast_log(
LOG_WARNING, 
"No SIP outbound authenticator registered. Cannot respond to authentication challenge\n");
 
 
  236    char *prev, *
current, *identifier_order;
 
  240    id_list_item = 
ast_calloc(1, 
sizeof(*id_list_item));
 
  278        if (!strcmp(prev, 
name)) {
 
 
  347    pjsip_generic_string_hdr *hdr;
 
  350    hdr = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &
str, 
NULL);
 
  355    pj_strdup_with_null(rdata->tp_info.pool, &hdr_val, &hdr->hvalue);
 
 
  376        e->
command = 
"pjsip dump endpt [details]";
 
  378            "Usage: pjsip dump endpt [details]\n" 
  379            "       Dump the res_pjsip endpt internals.\n" 
  381            "Warning: PJPROJECT documents that the function used by this\n" 
  382            "CLI command may cause a crash when asking for details because\n" 
  383            "it tries to access all active memory pools.\n";
 
  391        e->
command = 
"pjsip dump endpt";
 
  393            "Usage: pjsip dump endpt\n" 
  394            "       Dump the res_pjsip endpt internals.\n";
 
  402        || (
a->argc == 4 && strcasecmp(
a->argv[3], 
"details"))) {
 
 
  413#define ENDPOINT_IDENTIFIER_FORMAT "%-20.20s\n" 
  418        e->
command = 
"pjsip show identifiers";
 
  419        e->
usage = 
"Usage: pjsip show identifiers\n" 
  420                    "      List all registered endpoint identifiers\n";
 
  435                iter->
name ? iter->
name : 
"name not specified");
 
  439#undef ENDPOINT_IDENTIFIER_FORMAT 
 
  448        e->
command = 
"pjsip show settings";
 
  449        e->
usage = 
"Usage: pjsip show settings\n" 
  450                    "      Show global and system configuration options\n";
 
  457    if (!context.output_buffer) {
 
  458        ast_cli(
a->fd, 
"Could not allocate output buffer.\n");
 
  464        ast_cli(
a->fd, 
"Error retrieving settings.\n");
 
 
  526    pjsip_rx_data *rdata)
 
  532    if (uri->port == rdata->pkt_info.src_port
 
  533        && !pj_strcmp(&uri->host,
 
  534            pj_cstr(&host_name, rdata->pkt_info.src_name))
 
  536        && PJSIP_TRANSPORT_IS_RELIABLE(rdata->tp_info.transport)) {
 
  540        if (!strcasecmp(
"WSS", rdata->tp_info.transport->type_name)) {
 
  542            pj_cstr(&type_name, 
"ws");
 
  544            pj_cstr(&type_name, rdata->tp_info.transport->type_name);
 
  547        if (!pj_stricmp(&uri->transport_param, &type_name)
 
  550                || !pj_stricmp(&uri->transport_param,
 
  551                    pj_cstr(&type_name, 
"ws")))) {
 
 
  566    pjsip_contact_hdr *contact = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CONTACT, 
NULL);
 
  568    if (!contact || (!PJSIP_URI_SCHEME_IS_SIP(contact->uri) && !PJSIP_URI_SCHEME_IS_SIPS(contact->uri))) {
 
  572    return pjsip_uri_get_uri(contact->uri);
 
 
  586        ((details->
type == transport_state->
type) && (transport_state->
factory) &&
 
 
  609    pjsip_sip_uri *tmp_uri;
 
  614        pj_strdup(tdata->pool, &uri->host, &tmp_uri->host);
 
  615        uri->port = tmp_uri->port;
 
  616    } 
else if ((dlg = pjsip_tdata_get_dlg(tdata))
 
  617        && (tmp_uri = pjsip_uri_get_uri(dlg->local.info->uri))
 
  618        && (PJSIP_URI_SCHEME_IS_SIP(tmp_uri) || PJSIP_URI_SCHEME_IS_SIPS(tmp_uri))) {
 
  619        pj_strdup(tdata->pool, &uri->host, &tmp_uri->host);
 
  620        uri->port = tmp_uri->port;
 
  629    if (transport_state->localnet) {
 
  641    if (transport->external_signaling_port) {
 
  642        uri->port = transport->external_signaling_port;
 
 
  654    if (!details || !tdata) {
 
  659    transport_type = use_ipv6 ? tdata->tp_info.transport->key.type & ~(PJSIP_TRANSPORT_IPV6)
 
  660        : tdata->tp_info.transport->key.type;
 
  662    if (tdata->tp_sel.type == PJSIP_TPSELECTOR_TRANSPORT) {
 
  663        details->
transport = tdata->tp_sel.u.transport;
 
  664    } 
else if (tdata->tp_sel.type == PJSIP_TPSELECTOR_LISTENER) {
 
  665        details->
factory = tdata->tp_sel.u.listener;
 
  666    } 
else if (transport_type == PJSIP_TRANSPORT_UDP || transport_type == PJSIP_TRANSPORT_UDP6) {
 
  669        details->
transport = tdata->tp_info.transport;
 
  671        if (transport_type == PJSIP_TRANSPORT_TCP) {
 
  673        } 
else if (transport_type == PJSIP_TRANSPORT_TLS) {
 
  683        } 
else if ((tdata->msg->type == PJSIP_REQUEST_MSG) &&
 
  684            (via = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_VIA, 
NULL))) {
 
 
  699    pjsip_sip_uri *sip_uri, 
char *
buf, 
size_t buf_len)
 
  703    pjsip_param *x_transport;
 
  710    x_transport = pjsip_param_find(&sip_uri->other_param, &x_name);
 
 
  728    pjsip_tpselector *selector)
 
  731    pjsip_tpselector sel = { .type = PJSIP_TPSELECTOR_NONE, };
 
  733    uri = pjsip_uri_get_uri(dlg->target);
 
  740    pjsip_dlg_set_transport(dlg, selector);
 
  742    if (selector == &sel) {
 
 
  750    const char *domain, 
const pj_str_t *target, pjsip_tpselector *selector)
 
  752    pj_str_t tmp, local_addr;
 
  754    pjsip_sip_uri *sip_uri;
 
  755    pjsip_transport_type_e 
type;
 
  757    char default_user[PJSIP_MAX_URL_SIZE];
 
  765    pj_strdup_with_null(pool, &tmp, target);
 
  767    if (!(uri = pjsip_parse_uri(pool, tmp.ptr, tmp.slen, 0)) ||
 
  768        (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri))) {
 
  772    sip_uri = pjsip_uri_get_uri(uri);
 
  775    type = pjsip_transport_get_type_from_name(&sip_uri->transport_param);
 
  776    if (PJSIP_URI_SCHEME_IS_SIPS(sip_uri)) {
 
  777        if (
type == PJSIP_TRANSPORT_UNSPECIFIED
 
  778            || !(pjsip_transport_get_flag_from_type(
type) & PJSIP_TRANSPORT_SECURE)) {
 
  779            type = PJSIP_TRANSPORT_TLS;
 
  781    } 
else if (!sip_uri->transport_param.slen) {
 
  782        type = PJSIP_TRANSPORT_UDP;
 
  783    } 
else if (
type == PJSIP_TRANSPORT_UNSPECIFIED) {
 
  788    if (pj_strchr(&sip_uri->host, 
':')) {
 
  789        type |= PJSIP_TRANSPORT_IPV6;
 
  794        from->ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
 
  795        from->slen = pj_ansi_snprintf(from->ptr, PJSIP_MAX_URL_SIZE,
 
  798                (
type != PJSIP_TRANSPORT_UDP && 
type != PJSIP_TRANSPORT_UDP6) ? 
";transport=" : 
"",
 
  799                (
type != PJSIP_TRANSPORT_UDP && 
type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(
type) : 
"");
 
  804        from->ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
 
  805        from->slen = pj_ansi_snprintf(from->ptr, PJSIP_MAX_URL_SIZE,
 
  809                (
type != PJSIP_TRANSPORT_UDP && 
type != PJSIP_TRANSPORT_UDP6) ? 
";transport=" : 
"",
 
  810                (
type != PJSIP_TRANSPORT_UDP && 
type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(
type) : 
"");
 
  816                                  &local_addr, &local_port) != PJ_SUCCESS) {
 
  819        pj_strdup(pool, &local_addr, pj_gethostname());
 
  820        local_port = pjsip_transport_get_default_port_for_type(PJSIP_TRANSPORT_UDP);
 
  824    if (pj_strchr(&local_addr, 
':')) {
 
  825        type |= PJSIP_TRANSPORT_IPV6;
 
  828    from->ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
 
  829    from->slen = pj_ansi_snprintf(from->ptr, PJSIP_MAX_URL_SIZE,
 
  830                      "<sip:%s@%s%.*s%s:%d%s%s>",
 
  832                      (
type & PJSIP_TRANSPORT_IPV6) ? 
"[" : 
"",
 
  833                      (int)local_addr.slen,
 
  835                      (
type & PJSIP_TRANSPORT_IPV6) ? 
"]" : 
"",
 
  837                      (
type != PJSIP_TRANSPORT_UDP && 
type != PJSIP_TRANSPORT_UDP6) ? 
";transport=" : 
"",
 
  838                      (
type != PJSIP_TRANSPORT_UDP && 
type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(
type) : 
"");
 
 
  849    if (!transport_state) {
 
  856    if (transport_state->
flow) {
 
  861        selector->type = PJSIP_TPSELECTOR_TRANSPORT;
 
  862        selector->u.transport = transport_state->
transport;
 
  863        pjsip_transport_add_ref(selector->u.transport);
 
  864    } 
else if (transport_state->
factory) {
 
  865        selector->type = PJSIP_TPSELECTOR_LISTENER;
 
  866        selector->u.listener = transport_state->
factory;
 
  874#ifdef HAVE_PJSIP_TRANSPORT_DISABLE_CONNECTION_REUSE 
  875        selector->disable_connection_reuse = PJ_TRUE;
 
  877        ast_log(
LOG_WARNING, 
"Connection reuse could not be disabled on transport '%s' as support is not available\n",
 
  884    if (transport_state->
flow) {
 
 
  912    pjsip_sip_uri *sip_uri, pjsip_tpselector *selector)
 
  914    char transport_name[128];
 
 
  925    if (selector->type == PJSIP_TPSELECTOR_TRANSPORT && selector->u.transport) {
 
  926        pjsip_transport_dec_ref(selector->u.transport);
 
 
  932    pjsip_sip_uri *sip_uri;
 
  934    static const pj_str_t STR_PHONE = { 
"phone", 5 };
 
  936    if (!endpoint || !endpoint->
usereqphone || (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri))) {
 
  940    sip_uri = pjsip_uri_get_uri(uri);
 
  942    if (!pj_strlen(&sip_uri->user)) {
 
  946    if (pj_strbuf(&sip_uri->user)[0] == 
'+') {
 
  951    for (; i < pj_strlen(&sip_uri->user); i++) {
 
  957    if (i < pj_strlen(&sip_uri->user)) {
 
  961    sip_uri->user_param = STR_PHONE;
 
 
  965    const char *uri, 
const char *request_user)
 
  967    char enclosed_uri[PJSIP_MAX_URL_SIZE];
 
  968    pj_str_t local_uri = { 
"sip:temp@temp", 13 }, remote_uri, target_uri;
 
  970    pjsip_dialog *dlg = 
NULL;
 
  972    pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, };
 
  973    static const pj_str_t HCONTACT = { 
"Contact", 7 };
 
  976        snprintf(enclosed_uri, 
sizeof(enclosed_uri), 
"<%s>", uri);
 
  978        snprintf(enclosed_uri, 
sizeof(enclosed_uri), 
"%s", uri);
 
  980    pj_cstr(&remote_uri, enclosed_uri);
 
  982    pj_cstr(&target_uri, uri);
 
  984    res = pjsip_dlg_create_uac(pjsip_ua_instance(), &local_uri, 
NULL, &remote_uri, &target_uri, &dlg);
 
  985    if (res == PJ_SUCCESS && !(PJSIP_URI_SCHEME_IS_SIP(dlg->target) || PJSIP_URI_SCHEME_IS_SIPS(dlg->target))) {
 
  988        res = PJSIP_EINVALIDURI;
 
  989        pjsip_dlg_terminate(dlg);
 
  991    if (res != PJ_SUCCESS) {
 
  992        if (res == PJSIP_EINVALIDURI) {
 
  994                "Endpoint '%s': Could not create dialog to invalid URI '%s'.  Is endpoint registered and reachable?\n",
 
 1007        pjsip_dlg_terminate(dlg);
 
 1015    pj_strdup_with_null(dlg->pool, &dlg->local.info_str, &local_uri);
 
 1016    dlg->local.info->uri = pjsip_parse_uri(dlg->pool, dlg->local.info_str.ptr, dlg->local.info_str.slen, 0);
 
 1017    if (!dlg->local.info->uri) {
 
 1019            "Could not parse URI '%s' for endpoint '%s'\n",
 
 1022        pjsip_dlg_terminate(dlg);
 
 1026    dlg->local.contact = pjsip_parse_hdr(dlg->pool, &HCONTACT, local_uri.ptr, local_uri.slen, 
NULL);
 
 1029        pjsip_sip_uri *sip_uri;
 
 1031        sip_uri = pjsip_uri_get_uri(dlg->local.contact->uri);
 
 1032        pj_strdup2(dlg->pool, &sip_uri->user, endpoint->
contact_user);
 
 1037        pjsip_sip_uri *sip_uri;
 
 1039        if (PJSIP_URI_SCHEME_IS_SIP(dlg->target) || PJSIP_URI_SCHEME_IS_SIPS(dlg->target)) {
 
 1040            sip_uri = pjsip_uri_get_uri(dlg->target);
 
 1041            pj_strdup2(dlg->pool, &sip_uri->user, request_user);
 
 1043        if (PJSIP_URI_SCHEME_IS_SIP(dlg->remote.info->uri) || PJSIP_URI_SCHEME_IS_SIPS(dlg->remote.info->uri)) {
 
 1044            sip_uri = pjsip_uri_get_uri(dlg->remote.info->uri);
 
 1045            pj_strdup2(dlg->pool, &sip_uri->user, request_user);
 
 1055        pjsip_route_hdr route_set, *route;
 
 1056        static const pj_str_t ROUTE_HNAME = { 
"Route", 5 };
 
 1059        pj_list_init(&route_set);
 
 1061        pj_strdup2_with_null(dlg->pool, &tmp, outbound_proxy);
 
 1062        if (!(route = pjsip_parse_hdr(dlg->pool, &ROUTE_HNAME, tmp.ptr, tmp.slen, 
NULL))) {
 
 1063            ast_log(
LOG_ERROR, 
"Could not create dialog to endpoint '%s' as outbound proxy URI '%s' is not valid\n",
 
 1066            pjsip_dlg_terminate(dlg);
 
 1069        pj_list_insert_nodes_before(&route_set, route);
 
 1071        pjsip_dlg_set_route_set(dlg, &route_set);
 
 
 1091    pjsip_rr_hdr *record_route;
 
 1093    if (PJSIP_URI_SCHEME_IS_SIPS(rdata->msg_info.msg->line.req.uri)) {
 
 1097    record_route = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_RECORD_ROUTE, 
NULL);
 
 1099        if (PJSIP_URI_SCHEME_IS_SIPS(&record_route->name_addr)) {
 
 1103        pjsip_contact_hdr *contact;
 
 1105        contact = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, 
NULL);
 
 1107        if (PJSIP_URI_SCHEME_IS_SIPS(contact->uri)) {
 
 
 1116    const pj_str_t *contact, pjsip_dialog **p_dlg);
 
 1123    pjsip_transport_type_e 
type = rdata->tp_info.transport->key.type;
 
 1124    pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, };
 
 1126    pjsip_contact_hdr *contact_hdr;
 
 1130    contact_hdr = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, 
NULL);
 
 1137    if (selector.type == PJSIP_TPSELECTOR_TRANSPORT) {
 
 1142    contact.ptr = pj_pool_alloc(rdata->tp_info.pool, PJSIP_MAX_URL_SIZE);
 
 1143    contact.slen = pj_ansi_snprintf(contact.ptr, PJSIP_MAX_URL_SIZE,
 
 1144            "<%s:%s%s%s%.*s%s:%d%s%s>",
 
 1148            (
type & PJSIP_TRANSPORT_IPV6) ? 
"[" : 
"",
 
 1151            (
type & PJSIP_TRANSPORT_IPV6) ? 
"]" : 
"",
 
 1153            (
type != PJSIP_TRANSPORT_UDP && 
type != PJSIP_TRANSPORT_UDP6) ? 
";transport=" : 
"",
 
 1154            (
type != PJSIP_TRANSPORT_UDP && 
type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(
type) : 
"");
 
 1156    *
status = create_fun(pjsip_ua_instance(), rdata, &contact, &dlg);
 
 1157    if (*
status != PJ_SUCCESS) {
 
 1158        char err[PJ_ERR_MSG_SIZE];
 
 1160        pj_strerror(*
status, err, 
sizeof(err));
 
 1168    pjsip_dlg_set_transport(dlg, &selector);
 
 
 1178#ifdef HAVE_PJSIP_DLG_CREATE_UAS_AND_INC_LOCK 
 1183        pjsip_dlg_dec_lock(dlg);
 
 
 1193    pjsip_rx_data *rdata, pj_status_t *
status)
 
 1195#ifdef HAVE_PJSIP_DLG_CREATE_UAS_AND_INC_LOCK 
 1207        pjsip_dlg_inc_lock(dlg);
 
 
 1215    char *transport_type, 
const char *local_name, 
int local_port, 
const char *contact)
 
 1223    pj_list_init(&rdata->msg_info.parse_err);
 
 1225    rdata->tp_info.transport = PJ_POOL_ZALLOC_T(rdata->tp_info.pool, pjsip_transport);
 
 1226    if (!rdata->tp_info.transport) {
 
 1230    ast_copy_string(rdata->pkt_info.packet, packet, 
sizeof(rdata->pkt_info.packet));
 
 1231    ast_copy_string(rdata->pkt_info.src_name, src_name, 
sizeof(rdata->pkt_info.src_name));
 
 1232    rdata->pkt_info.src_port = src_port;
 
 1233    pj_sockaddr_parse(pj_AF_UNSPEC(), 0, pj_cstr(&tmp, src_name), &rdata->pkt_info.src_addr);
 
 1234    pj_sockaddr_set_port(&rdata->pkt_info.src_addr, src_port);
 
 1236    pjsip_parse_rdata(packet, strlen(packet), rdata);
 
 1237    if (!rdata->msg_info.msg || !pj_list_empty(&rdata->msg_info.parse_err)) {
 
 1242        pjsip_contact_hdr *contact_hdr;
 
 1244        contact_hdr = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, 
NULL);
 
 1246            contact_hdr->uri = pjsip_parse_uri(rdata->tp_info.pool, (
char *)contact,
 
 1247                strlen(contact), PJSIP_PARSE_URI_AS_NAMEADDR);
 
 1248            if (!contact_hdr->uri) {
 
 1255    pj_strdup2(rdata->tp_info.pool, &rdata->msg_info.via->recvd_param, rdata->pkt_info.src_name);
 
 1256    rdata->msg_info.via->rport_param = -1;
 
 1258    rdata->tp_info.transport->key.type = pjsip_transport_get_type_from_name(pj_cstr(&tmp, transport_type));
 
 1259    rdata->tp_info.transport->type_name = transport_type;
 
 1260    pj_strdup2(rdata->tp_info.pool, &rdata->tp_info.transport->local_name.host, local_name);
 
 1261    rdata->tp_info.transport->local_name.port = local_port;
 
 
 1267    char *transport_type, 
const char *local_name, 
int local_port)
 
 1270        local_name, local_port, 
NULL);
 
 
 1274static const pjsip_method 
info_method = {PJSIP_OTHER_METHOD, {
"INFO", 4} };
 
 1276static const pjsip_method 
refer_method = {PJSIP_OTHER_METHOD, {
"REFER", 5} };
 
 1282    { 
"INVITE", &pjsip_invite_method },
 
 1283    { 
"CANCEL", &pjsip_cancel_method },
 
 1284    { 
"ACK", &pjsip_ack_method },
 
 1285    { 
"BYE", &pjsip_bye_method },
 
 1286    { 
"REGISTER", &pjsip_register_method },
 
 1287    { 
"OPTIONS", &pjsip_options_method },
 
 1288    { 
"SUBSCRIBE", &pjsip_subscribe_method },
 
 1289    { 
"NOTIFY", &pjsip_notify_method },
 
 1309    if (pjsip_dlg_create_request(dlg, 
method, -1, tdata) != PJ_SUCCESS) {
 
 
 1319    .name = { 
"Out of dialog supplement hook", 29 },
 
 1321    .priority = PJSIP_MOD_PRIORITY_APPLICATION - 1,
 
 
 1326        const char *uri, 
struct ast_sip_contact *provided_contact, pjsip_tx_data **tdata)
 
 1329    pj_str_t remote_uri;
 
 1332    pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, };
 
 1334    const char *fromuser;
 
 1351        pj_cstr(&remote_uri, contact->uri);
 
 1353        pj_cstr(&remote_uri, uri);
 
 1363    sip_uri = pjsip_parse_uri(pool, remote_uri.ptr, remote_uri.slen, 0);
 
 1364    if (!sip_uri || (!PJSIP_URI_SCHEME_IS_SIP(sip_uri) && !PJSIP_URI_SCHEME_IS_SIPS(sip_uri))) {
 
 1365        ast_log(
LOG_ERROR, 
"Unable to create outbound %.*s request to endpoint %s as URI '%s' is not valid\n",
 
 1366            (
int) pj_strlen(&
method->name), pj_strbuf(&
method->name),
 
 1368            pj_strbuf(&remote_uri));
 
 1377                endpoint ? endpoint->
fromdomain : 
NULL, &remote_uri, &selector)) {
 
 1378        ast_log(
LOG_ERROR, 
"Unable to create From header for %.*s request to endpoint %s\n",
 
 1379                (
int) pj_strlen(&
method->name), pj_strbuf(&
method->name),
 
 1387            &from, &remote_uri, &from, 
NULL, -1, 
NULL, tdata) != PJ_SUCCESS) {
 
 1388        ast_log(
LOG_ERROR, 
"Unable to create outbound %.*s request to endpoint %s\n",
 
 1389                (
int) pj_strlen(&
method->name), pj_strbuf(&
method->name),
 
 1396    pjsip_tx_data_set_transport(*tdata, &selector);
 
 1401        pjsip_contact_hdr *contact_hdr;
 
 1402        pjsip_sip_uri *contact_uri;
 
 1403        static const pj_str_t HCONTACT = { 
"Contact", 7 };
 
 1404        static const pj_str_t HCONTACTSHORT = { 
"m", 1 };
 
 1406        contact_hdr = pjsip_msg_find_hdr_by_names((*tdata)->msg, &HCONTACT, &HCONTACTSHORT, 
NULL);
 
 1408            contact_uri = pjsip_uri_get_uri(contact_hdr->uri);
 
 1409            pj_strdup2((*tdata)->pool, &contact_uri->user, endpoint->
contact_user);
 
 1419        ast_log(
LOG_ERROR, 
"Unable to apply outbound proxy on request %.*s to endpoint %s as outbound proxy URI '%s' is not valid\n",
 
 
 1482        if (supplement == iter) {
 
 
 1492    if (pjsip_dlg_send_request(dlg, tdata, -1, 
NULL) != PJ_SUCCESS) {
 
 
 1507    pj_cstr(&
method, supplement_method);
 
 
 1512#define TIMER_INACTIVE      0 
 1513#define TIMEOUT_TIMER2      5 
 1584    if (e->body.tsx_state.type == PJSIP_EVENT_TIMER) {
 
 1585        ast_debug(2, 
"%p: PJSIP tsx timer expired\n", req_wrapper);
 
 1589            ast_debug(3, 
"%p: Timeout already handled\n", req_wrapper);
 
 1594        ast_debug(2, 
"%p: PJSIP tsx response received\n", req_wrapper);
 
 1605        int timers_cancelled = 0;
 
 1607        ast_debug(3, 
"%p: Cancelling timer\n", req_wrapper);
 
 1609        timers_cancelled = pj_timer_heap_cancel_if_active(
 
 1612        if (timers_cancelled > 0) {
 
 1616            ast_debug(3, 
"%p: Timer cancelled\n", req_wrapper);
 
 1624            ast_debug(3, 
"%p: Timer already expired\n", req_wrapper);
 
 1637        ast_debug(2, 
"%p: Callbacks executed\n", req_wrapper);
 
 
 1653    ast_debug(2, 
"%p: Internal tsx timer expired after %d msec\n",
 
 1654        req_wrapper, req_wrapper->
timeout);
 
 1663        ast_debug(3, 
"%p: Timeout already handled\n", req_wrapper);
 
 1669    ast_debug(3, 
"%p: Timer handled here\n", req_wrapper);
 
 1678        PJSIP_EVENT_INIT_TX_MSG(
event, req_wrapper->
tdata);
 
 1679        event.body.tsx_state.type = PJSIP_EVENT_TIMER;
 
 1682        ast_debug(2, 
"%p: Callbacks executed\n", req_wrapper);
 
 
 1692    pjsip_tx_data_dec_ref(req_wrapper->
tdata);
 
 1693    ast_debug(2, 
"%p: wrapper destroyed\n", req_wrapper);
 
 
 1697    pjsip_tx_data *
tdata, pj_int32_t 
timeout, 
void *
token, pjsip_endpt_send_callback cb)
 
 1700    pj_status_t ret_val;
 
 1705        pjsip_tx_data_dec_ref(
tdata);
 
 1712        pjsip_tx_data_dec_ref(
tdata);
 
 1716    ast_debug(2, 
"%p: Wrapper created\n", req_wrapper);
 
 1724    pjsip_tx_data_add_ref(
tdata);
 
 1727        pj_time_val timeout_timer_val = { 
timeout / 1000, 
timeout % 1000 };
 
 1740        ret_val = pj_timer_heap_schedule(pjsip_endpt_get_timer_heap(endpt),
 
 1742        if (ret_val != PJ_SUCCESS) {
 
 1744                "Failed to set timer.  Not sending %.*s request to endpoint %s.\n",
 
 1745                (
int) pj_strlen(&
tdata->msg->line.req.method.name),
 
 1746                pj_strbuf(&
tdata->msg->line.req.method.name),
 
 1748            ao2_t_ref(req_wrapper, -2, 
"Drop timer and routine ref");
 
 1749            pjsip_tx_data_dec_ref(
tdata);
 
 1759    if (ret_val != PJ_SUCCESS) {
 
 1760        char errmsg[PJ_ERR_MSG_SIZE];
 
 1768        pj_strerror(ret_val, errmsg, 
sizeof(errmsg));
 
 1770            (
int) ret_val, errmsg, (
int) pj_strlen(&
tdata->msg->line.req.method.name),
 
 1771            pj_strbuf(&
tdata->msg->line.req.method.name),
 
 1775            int timers_cancelled;
 
 1778            timers_cancelled = pj_timer_heap_cancel_if_active(
 
 1779                pjsip_endpt_get_timer_heap(endpt),
 
 1781            if (timers_cancelled > 0) {
 
 1792                ret_val = PJ_SUCCESS;
 
 1808            ret_val = PJ_SUCCESS;
 
 
 1821        || (
tdata->dest_info.cur_addr == 
tdata->dest_info.addr.count - 1)) {
 
 1827    ++
tdata->dest_info.cur_addr;
 
 1829    via = (pjsip_via_hdr*)pjsip_msg_find_hdr(
tdata->msg, PJSIP_H_VIA, 
NULL);
 
 1830    via->branch_param.slen = 0;
 
 1832    pjsip_tx_data_invalidate_msg(
tdata);
 
 
 1842    pjsip_transaction *tsx;
 
 1843    pjsip_tx_data *tdata;
 
 1850    tsx = e->body.tsx_state.tsx;
 
 1852    switch (tsx->status_code) {
 
 1858                e->body.tsx_state.src.rdata, tsx->last_tx, &tdata);
 
 1863            tdata = tsx->last_tx;
 
 1868            pjsip_tx_data_add_ref(tdata);
 
 
 1888    if (e->type == PJSIP_EVENT_TSX_STATE) {
 
 1889        switch(e->body.tsx_state.type) {
 
 1890        case PJSIP_EVENT_TRANSPORT_ERROR:
 
 1891        case PJSIP_EVENT_TIMER:
 
 1901        case PJSIP_EVENT_RX_MSG:
 
 1902            challenge = e->body.tsx_state.src.rdata;
 
 
 1940    void (*
callback)(
void *token, pjsip_event *e))
 
 1948        pjsip_tx_data_dec_ref(tdata);
 
 
 1981    void (*
callback)(
void *token, pjsip_event *e))
 
 1983    ast_assert(tdata->msg->type == PJSIP_REQUEST_MSG);
 
 
 1994    pjsip_route_hdr *route;
 
 1995    static const pj_str_t ROUTE_HNAME = { 
"Route", 5 };
 
 1998    pj_strdup2_with_null(tdata->pool, &tmp, proxy);
 
 1999    if (!(route = pjsip_parse_hdr(tdata->pool, &ROUTE_HNAME, tmp.ptr, tmp.slen, 
NULL))) {
 
 2003    pj_list_insert_nodes_before(&tdata->msg->hdr, (pjsip_hdr*)route);
 
 
 2012    pjsip_generic_string_hdr *hdr;
 
 2014    pj_cstr(&hdr_name, 
name);
 
 2015    pj_cstr(&hdr_value, 
value);
 
 2017    hdr = pjsip_generic_string_hdr_create(tdata->pool, &hdr_name, &hdr_value);
 
 2019    pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *) hdr);
 
 
 2028    pjsip_generic_string_hdr *hdr;
 
 2030    pj_cstr(&hdr_name, 
name);
 
 2031    pj_cstr(&hdr_value, 
value);
 
 2033    hdr = pjsip_generic_string_hdr_create(tdata->pool, &hdr_name, &hdr_value);
 
 2035    pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *) hdr);
 
 
 2046    pj_cstr(&subtype, body->
subtype);
 
 2049    return pjsip_msg_body_create(pool, &
type, &subtype, &body_text);
 
 
 2055    tdata->msg->body = pjsip_body;
 
 
 2063    pjsip_msg_body *body = pjsip_multipart_create(tdata->pool, 
NULL, 
NULL);
 
 2065    for (i = 0; i < num_bodies; ++i) {
 
 2066        pjsip_multipart_part *part = pjsip_multipart_create_part(tdata->pool);
 
 2068        pjsip_multipart_add_part(tdata->pool, body, part);
 
 2071    tdata->msg->body = body;
 
 
 2077    size_t combined_size = strlen(body_text) + tdata->msg->body->len;
 
 2080    ast_str_set(&body_buffer, 0, 
"%.*s%s", (
int) tdata->msg->body->len, (
char *) tdata->msg->body->data, body_text);
 
 2082    tdata->msg->body->data = pj_pool_alloc(tdata->pool, combined_size);
 
 2083    pj_memcpy(tdata->msg->body->data, 
ast_str_buffer(body_buffer), combined_size);
 
 2084    tdata->msg->body->len = combined_size;
 
 
 2142    memset(&std, 0, 
sizeof(std));
 
 2145    std.
task = sip_task;
 
 
 2203    size_t chars_to_copy = 
MIN(size - 1, pj_strlen(src));
 
 2204    memcpy(dest, pj_strbuf(src), chars_to_copy);
 
 2205    dest[chars_to_copy] = 
'\0';
 
 
 2210    int res = 
ast_asprintf(dest, 
"%.*s", (
int)pj_strlen(src), pj_strbuf(src));
 
 
 2223        rc = pjsip_media_type_cmp(
a, 
b, 0) ? 0 : 1;
 
 
 2231    pjsip_media_type *
b = 
NULL;
 
 2237    while ((
b = va_arg(ap, pjsip_media_type *)) != (pjsip_media_type *)
SENTINEL) {
 
 2238        if (pjsip_media_type_cmp(
a, 
b, 0) == 0) {
 
 
 2252    if (!content_type) {
 
 2258    return pjsip_media_type_cmp(content_type, &
compare, 0) ? 0 : -1;
 
 
 2269        const pj_time_val delay = {0, 10};
 
 
 2283#define SIP_SERVANT_ID 0x5E2F1D 
 2287    pj_thread_desc *
desc;
 
 2289    uint32_t *servant_id;
 
 2293        ast_log(
LOG_ERROR, 
"Could not set SIP servant ID in thread-local storage.\n");
 
 2300        ast_log(
LOG_ERROR, 
"Could not get thread desc from thread-local storage. Expect awful things to occur\n");
 
 2305    if (pj_thread_register(
"Asterisk Thread", *
desc, &
thread) != PJ_SUCCESS) {
 
 
 2312    uint32_t *servant_id;
 
 2315            pthread_self() == *(pthread_t *)pj_thread_get_os_handle(
monitor_thread)) {
 
 
 2329    unsigned int hval = 0;
 
 2335    return pj_hash_get(ht, key, PJ_HASH_KEY_STRING, &hval);
 
 
 2339               const char *key, 
void *
val)
 
 2342        ht = pj_hash_create(pool, 11);
 
 2345    pj_hash_set(pool, ht, key, PJ_HASH_KEY_STRING, 0, 
val);
 
 
 2354    if (pjsip_rdata_get_dlg(rdata)) {
 
 
 2377    pjsip_cseq_hdr *cseq = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CSEQ, 
NULL);
 
 
 2402    if (
status != PJ_SUCCESS) {
 
 2403        pjsip_tx_data_dec_ref(tdata);
 
 2406    return status == PJ_SUCCESS ? 0 : -1;
 
 
 2411    pj_pool_t *pool = (pj_pool_t *)arg;
 
 
 2421    pjsip_tx_data_dec_ref(tdata);
 
 
 2426    pjsip_transaction *tsx;
 
 2427    pj_grp_lock_t *tsx_glock;
 
 2447    pj_grp_lock_add_ref(tsx_glock);
 
 2449    if (pjsip_tsx_create_uas2(
NULL, rdata, tsx_glock, &tsx) != PJ_SUCCESS) {
 
 2451        pj_grp_lock_dec_ref(tsx_glock);
 
 2455    pjsip_tsx_recv_msg(tsx, rdata);
 
 2458    if (pjsip_tsx_send_msg(tsx, tdata) != PJ_SUCCESS) {
 
 2459        pj_grp_lock_dec_ref(tsx_glock);
 
 2460        pjsip_tx_data_dec_ref(tdata);
 
 2464    pj_grp_lock_dec_ref(tsx_glock);
 
 
 2495    if (af == pj_AF_INET()) {
 
 2497    } 
else if (af == pj_AF_INET6()) {
 
 
 2505                char *
buf, 
size_t buf_len)
 
 
 2537    if (!strcasecmp(dtmf_mode, 
"info")) {
 
 2539    } 
else if (!strcasecmp(dtmf_mode, 
"rfc4733")) {
 
 2541    } 
else if (!strcasecmp(dtmf_mode, 
"inband")) {
 
 2543    } 
else if (!strcasecmp(dtmf_mode, 
"none")) {
 
 2545    } 
else if (!strcasecmp(dtmf_mode, 
"auto")) {
 
 2547    } 
else if (!strcasecmp(dtmf_mode, 
"auto_info")) {
 
 
 2561        value = 
"local_merge";
 
 2563        value = 
"local_first";
 
 2567        value = 
"remote_merge";
 
 2569        value = 
"remote_first";
 
 
 2581    if (strcmp(pref_str, 
"local") == 0) {
 
 2583    } 
else if (is_outgoing && strcmp(pref_str, 
"local_merge") == 0) {
 
 2585    } 
else if (strcmp(pref_str, 
"local_first") == 0) {
 
 2587    } 
else if (strcmp(pref_str, 
"remote") == 0) {
 
 2589    } 
else if (is_outgoing && strcmp(pref_str, 
"remote_merge") == 0) {
 
 2591    } 
else if (strcmp(pref_str, 
"remote_first") == 0) {
 
 
 2611    pjsip_name_addr *id_name_addr = (pjsip_name_addr *) hdr->uri;
 
 2617    semi = strchr(cid_num, 
';');
 
 2639        id_name_addr->display.ptr, id_name_addr->display.slen);
 
 2643            "' for number '%s' has invalid UTF-8 characters which " 
 2656        id->number.valid = 1;
 
 
 2673static pjsip_fromto_hdr *
get_id_header(pjsip_rx_data *rdata, 
const pj_str_t *header_name)
 
 2675    static const pj_str_t from = { 
"From", 4 };
 
 2676    pj_str_t header_content;
 
 2677    pjsip_fromto_hdr *parsed_hdr;
 
 2678    pjsip_generic_string_hdr *ident = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg,
 
 2686    pj_strdup_with_null(rdata->tp_info.pool, &header_content, &ident->hvalue);
 
 2688    parsed_hdr = pjsip_parse_hdr(rdata->tp_info.pool, &from, header_content.ptr,
 
 2689            pj_strlen(&header_content), &parsed_len);
 
 
 2712    static const pj_str_t pai_str = { 
"P-Asserted-Identity", 19 };
 
 2713    static const pj_str_t privacy_str = { 
"Privacy", 7 };
 
 2715    pjsip_generic_string_hdr *privacy;
 
 2723    if (!
id->number.valid) {
 
 2727    privacy = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &privacy_str, 
NULL);
 
 2728    if (!privacy || !pj_stricmp2(&privacy->hvalue, 
"none")) {
 
 
 2753    static const pj_str_t rpid_str = { 
"Remote-Party-ID", 15 };
 
 2754    static const pj_str_t privacy_str = { 
"privacy", 7 };
 
 2755    static const pj_str_t screen_str = { 
"screen", 6 };
 
 2756    pjsip_fromto_hdr *rpid_hdr = 
get_id_header(rdata, &rpid_str);
 
 2757    pjsip_param *screen;
 
 2758    pjsip_param *privacy;
 
 2766    if (!
id->number.valid) {
 
 2770    privacy = pjsip_param_find(&rpid_hdr->other_param, &privacy_str);
 
 2771    screen = pjsip_param_find(&rpid_hdr->other_param, &screen_str);
 
 2772    if (privacy && !pj_stricmp2(&privacy->value, 
"full")) {
 
 2779    if (screen && !pj_stricmp2(&screen->value, 
"yes")) {
 
 
 2805    pjsip_fromto_hdr *from = pjsip_msg_find_hdr(rdata->msg_info.msg,
 
 2806            PJSIP_H_FROM, rdata->msg_info.msg->hdr.next);
 
 2815    if (!
id->number.valid) {
 
 
 2852    pjsip_name_addr *id_name_addr;
 
 2853    pjsip_sip_uri *id_uri;
 
 2855    id_name_addr = (pjsip_name_addr *) id_hdr->uri;
 
 2856    id_uri = pjsip_uri_get_uri(id_name_addr->uri);
 
 2858    if (
id->name.valid) {
 
 2860            int name_buf_len = strlen(
id->name.str) * 2 + 1;
 
 2864            pj_strdup2(pool, &id_name_addr->display, name_buf);
 
 2866            pj_strdup2(pool, &id_name_addr->display, 
NULL);
 
 2870    if (
id->number.valid) {
 
 2871        pj_strdup2(pool, &id_uri->user, 
id->number.str);
 
 
 2895    pjsip_name_addr *name_addr;
 
 2896    pjsip_sip_uri *sip_uri;
 
 2912    name_addr = (pjsip_name_addr *) pjsip_parse_uri(pool, (
char*)contact->uri, strlen(contact->uri), PJSIP_PARSE_URI_AS_NAMEADDR);
 
 2913    if (!name_addr || (!PJSIP_URI_SCHEME_IS_SIP(name_addr->uri) && !PJSIP_URI_SCHEME_IS_SIPS(name_addr->uri))) {
 
 2921    sip_uri = pjsip_uri_get_uri(name_addr->uri);
 
 2922    pj_strset2(&sip_uri->user, (
char*)
user);
 
 2929    pjsip_uri_print(PJSIP_URI_IN_REQ_URI, name_addr, *
uri, PJSIP_MAX_URL_SIZE);
 
 
 2957    char *endpoint_name = 
NULL;
 
 2970        char *temp_uri = 
ast_malloc(strlen(destination) + strlen(
"sip:") + 1);
 
 2974        sprintf(temp_uri, 
"sip:%s", destination);
 
 2976        if (get_default_outbound) {
 
 2979        ast_debug(3, 
"Dest: '%s' Didn't find endpoint so adding scheme and using URI '%s'%s\n",
 
 2980            to, *uri, get_default_outbound ? 
" with default endpoint" : 
"");
 
 2988    endpoint_name = destination;
 
 2991        ast_log(
LOG_WARNING, 
"Dest: '%s'. Found endpoint '%s' but didn't find an aor/contact for it\n",
 
 3003    ast_debug(3, 
"Dest: '%s' Found endpoint '%s' and found contact with URI '%s'\n",
 
 3004        to, endpoint_name, *uri);
 
 
 3035    char *slash, 
char *atsign, 
char *scheme)
 
 3037    char *endpoint_name = 
NULL;
 
 3041    char *afterslash = slash + 1;
 
 3045        ast_debug(3, 
"Dest: '%s' Dialplan format'\n", to);
 
 3049        if (!atsign || strchr(afterslash, 
'/')) {
 
 3055                "Dest: '%s'. Destinations beginning with 'PJSIP/' must be in the form of 'PJSIP/user@endpoint'\n",
 
 3061        endpoint_name = atsign + 1;
 
 3062        ast_debug(3, 
"Dest: '%s' User: '%s'  Endpoint: '%s'\n", to, 
user, endpoint_name);
 
 3070        endpoint_name = destination;
 
 3071        ast_debug(3, 
"Dest: '%s' Endpoint: '%s'\n", to, endpoint_name);
 
 3090        ast_debug(3, 
"Dest: '%s' Found endpoint '%s' and found URI '%s' after '/'\n",
 
 3091            to, endpoint_name, *uri);
 
 3112        ast_debug(3, 
"Dest: '%s' User: '%s'  Endpoint: '%s'  URI: '%s'\n", to, 
user,
 
 3113            endpoint_name, *uri);
 
 3129        *uri = 
ast_malloc(strlen(afterslash) + strlen(
"sip:") + 1);
 
 3133        sprintf(*uri, 
"sip:%s", afterslash);
 
 3134        ast_debug(3, 
"Dest: '%s' Found endpoint '%s' but didn't find aor after '/' so using URI '%s'\n",
 
 3135            to, endpoint_name, *uri);
 
 3142    ast_debug(3, 
"Dest: '%s' Found endpoint '%s' and found aor '%s' after '/'\n",
 
 3147        ast_log(
LOG_WARNING, 
"Dest: '%s'. Found endpoint '%s' but didn't find contact for aor '%s'\n",
 
 3160    ast_debug(3, 
"Dest: '%s' Found endpoint '%s' and found contact with URI '%s' for aor '%s'\n",
 
 
 3192    char *slash, 
char *atsign, 
char *scheme, 
int get_default_outbound)
 
 3194    char *endpoint_name = 
NULL;
 
 3197    char *afterat = atsign + 1;
 
 3214        sprintf(*
uri, 
"sip:%s", to);
 
 3215        if (get_default_outbound) {
 
 3218        ast_debug(3, 
"Dest: '%s' Didn't find endpoint before the '@' so using URI '%s'%s\n",
 
 3219            to, *
uri, get_default_outbound ? 
" with default endpoint" : 
"");
 
 3238    ast_debug(3, 
"Dest: '%s' Found endpoint '%s' and found contact with URI '%s' (discarding domain %s)\n",
 
 
 3253    char *atsign = 
NULL;
 
 3254    char *scheme = 
NULL;
 
 3259    slash = strchr(destination, 
'/');
 
 3260    atsign = strchr(destination, 
'@');
 
 3261    scheme = 
S_OR(strstr(destination, 
"sip:"), strstr(destination, 
"sips:"));
 
 3263    if (!slash && !atsign && !scheme) {
 
 3279        return handle_slash(to, destination, uri, slash, atsign, scheme);
 
 3282    if (atsign && !scheme) {
 
 3289        return handle_atsign(to, destination, uri, slash, atsign, scheme, get_default_outbound);
 
 3300        ast_debug(3, 
"Dest: '%s' Didn't find an endpoint but did find a scheme so using URI '%s'%s\n",
 
 3301            to, *uri, get_default_outbound ? 
" with default endpoint" : 
"");
 
 3303        *uri = 
ast_malloc(strlen(destination) + strlen(
"sip:") + 1);
 
 3307        sprintf(*uri, 
"sip:%s", destination);
 
 3308        ast_debug(3, 
"Dest: '%s' Didn't find an endpoint and didn't find scheme so adding scheme and using URI '%s'%s\n",
 
 3309            to, *uri, get_default_outbound ? 
" with default endpoint" : 
"");
 
 3311    if (get_default_outbound) {
 
 
 3325    pjsip_name_addr *parsed_name_addr;
 
 3326    pjsip_sip_uri *sip_uri;
 
 3327    pjsip_name_addr *tdata_name_addr;
 
 3328    pjsip_sip_uri *tdata_sip_uri;
 
 3329    pjsip_to_hdr *to_hdr;
 
 3331#define DEBUG_BUF_SIZE 256 
 3333    parsed_name_addr = (pjsip_name_addr *) pjsip_parse_uri(tdata->pool, (
char*)to, strlen(to),
 
 3334        PJSIP_PARSE_URI_AS_NAMEADDR);
 
 3336    if (!parsed_name_addr || (!PJSIP_URI_SCHEME_IS_SIP(parsed_name_addr->uri)
 
 3337            && !PJSIP_URI_SCHEME_IS_SIPS(parsed_name_addr->uri))) {
 
 3342    sip_uri = pjsip_uri_get_uri(parsed_name_addr->uri);
 
 3346        ast_debug(3, 
"Parsed To: %.*s  %s\n", (
int)parsed_name_addr->display.slen,
 
 3347            parsed_name_addr->display.ptr, 
buf);
 
 3350    to_hdr = PJSIP_MSG_TO_HDR(tdata->msg);
 
 3351    tdata_name_addr = to_hdr ? (pjsip_name_addr *) to_hdr->uri : 
NULL;
 
 3352    if (!tdata_name_addr || (!PJSIP_URI_SCHEME_IS_SIP(tdata_name_addr->uri)
 
 3353            && !PJSIP_URI_SCHEME_IS_SIPS(tdata_name_addr->uri))) {
 
 3359    tdata_sip_uri = pjsip_uri_get_uri(tdata_name_addr->uri);
 
 3363        ast_debug(3, 
"Original tdata To: %.*s  %s\n", (
int)tdata_name_addr->display.slen,
 
 3364            tdata_name_addr->display.ptr, 
buf);
 
 3368    pjsip_sip_uri_assign(tdata->pool, tdata_sip_uri, sip_uri);
 
 3370    pj_strdup(tdata->pool, &tdata_name_addr->display, &parsed_name_addr->display);
 
 3374        pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, tdata_sip_uri, 
buf, 256);
 
 3375        ast_debug(3, 
"New tdata To: %.*s  %s\n", (
int)tdata_name_addr->display.slen,
 
 3376            tdata_name_addr->display.ptr, 
buf);
 
 3380#undef DEBUG_BUF_SIZE 
 
 3385    pjsip_name_addr *name_addr;
 
 3387    pjsip_name_addr *parsed_name_addr;
 
 3388    pjsip_from_hdr *from_hdr;
 
 3394    from_hdr = PJSIP_MSG_FROM_HDR(tdata->msg);
 
 3398    name_addr = (pjsip_name_addr *) from_hdr->uri;
 
 3399    uri = pjsip_uri_get_uri(name_addr);
 
 3401    parsed_name_addr = (pjsip_name_addr *) pjsip_parse_uri(tdata->pool, from,
 
 3402        strlen(from), PJSIP_PARSE_URI_AS_NAMEADDR);
 
 3403    if (parsed_name_addr) {
 
 3404        pjsip_sip_uri *parsed_uri;
 
 3406        if (!PJSIP_URI_SCHEME_IS_SIP(parsed_name_addr->uri)
 
 3407                && !PJSIP_URI_SCHEME_IS_SIPS(parsed_name_addr->uri)) {
 
 3412        parsed_uri = pjsip_uri_get_uri(parsed_name_addr->uri);
 
 3414        if (pj_strlen(&parsed_name_addr->display)) {
 
 3415            pj_strdup(tdata->pool, &name_addr->display, &parsed_name_addr->display);
 
 3419        pj_strdup(tdata->pool, &uri->user, &parsed_uri->user);
 
 3420        pj_strdup(tdata->pool, &uri->host, &parsed_uri->host);
 
 3421        uri->port = parsed_uri->port;
 
 3426        char *domain = strchr(from, 
'@');
 
 3431            pj_strset3(&pj_from, from, domain);
 
 3432            pj_strdup(tdata->pool, &uri->user, &pj_from);
 
 3434            pj_strdup2(tdata->pool, &uri->host, domain + 1);
 
 3436            pj_strdup2(tdata->pool, &uri->user, from);
 
 
 3447    const pjsip_hdr *
request_headers = pjsip_endpt_get_request_headers(endpt);
 
 3451        pjsip_hdr *to_erase = iter;
 
 3453        pj_list_erase(to_erase);
 
 
 3469    return (PJSIP_URI_SCHEME_IS_SIP(uri) || PJSIP_URI_SCHEME_IS_SIPS(uri));
 
 
 3480        pjsip_sip_uri *sip_uri = pjsip_uri_get_uri(uri);
 
 3484        return &sip_uri->user;
 
 3485    } 
else if (PJSIP_URI_SCHEME_IS_TEL(uri)) {
 
 3486        pjsip_tel_uri *tel_uri = pjsip_uri_get_uri(uri);
 
 3490        return &tel_uri->number;
 
 
 3499        pjsip_sip_uri *sip_uri = pjsip_uri_get_uri(uri);
 
 3503        return &sip_uri->host;
 
 3504    } 
else if (PJSIP_URI_SCHEME_IS_TEL(uri)) {
 
 
 3514        pjsip_sip_uri *sip_uri = pjsip_uri_get_uri(uri);
 
 3518        return pjsip_param_find(&sip_uri->other_param, param_str);
 
 3519    } 
else if (PJSIP_URI_SCHEME_IS_TEL(uri)) {
 
 3520        pjsip_tel_uri *tel_uri = pjsip_uri_get_uri(uri);
 
 3524        return pjsip_param_find(&tel_uri->other_param, param_str);
 
 
 3605        if (cause < 500 && cause >= 400) {
 
 3608        } 
else if (cause < 600 && cause >= 500) {
 
 3611        } 
else if (cause < 700 && cause >= 600) {
 
 
 3635    { PJSIP_SC_NULL, 
"PJSIP_SC_NULL", 
"NULL" },
 
 3636    { PJSIP_SC_TRYING, 
"PJSIP_SC_TRYING", 
"TRYING" },
 
 3637    { PJSIP_SC_RINGING, 
"PJSIP_SC_RINGING", 
"RINGING" },
 
 3638    { PJSIP_SC_CALL_BEING_FORWARDED, 
"PJSIP_SC_CALL_BEING_FORWARDED", 
"CALL_BEING_FORWARDED" },
 
 3639    { PJSIP_SC_QUEUED, 
"PJSIP_SC_QUEUED", 
"QUEUED" },
 
 3640    { PJSIP_SC_PROGRESS, 
"PJSIP_SC_PROGRESS", 
"PROGRESS" },
 
 3641    { PJSIP_SC_EARLY_DIALOG_TERMINATED, 
"PJSIP_SC_EARLY_DIALOG_TERMINATED", 
"EARLY_DIALOG_TERMINATED" },
 
 3642    { PJSIP_SC_OK, 
"PJSIP_SC_OK", 
"OK" },
 
 3643    { PJSIP_SC_ACCEPTED, 
"PJSIP_SC_ACCEPTED", 
"ACCEPTED" },
 
 3644    { PJSIP_SC_NO_NOTIFICATION, 
"PJSIP_SC_NO_NOTIFICATION", 
"NO_NOTIFICATION" },
 
 3645    { PJSIP_SC_MULTIPLE_CHOICES, 
"PJSIP_SC_MULTIPLE_CHOICES", 
"MULTIPLE_CHOICES" },
 
 3646    { PJSIP_SC_MOVED_PERMANENTLY, 
"PJSIP_SC_MOVED_PERMANENTLY", 
"MOVED_PERMANENTLY" },
 
 3647    { PJSIP_SC_MOVED_TEMPORARILY, 
"PJSIP_SC_MOVED_TEMPORARILY", 
"MOVED_TEMPORARILY" },
 
 3648    { PJSIP_SC_USE_PROXY, 
"PJSIP_SC_USE_PROXY", 
"USE_PROXY" },
 
 3649    { PJSIP_SC_ALTERNATIVE_SERVICE, 
"PJSIP_SC_ALTERNATIVE_SERVICE", 
"ALTERNATIVE_SERVICE" },
 
 3650    { PJSIP_SC_BAD_REQUEST, 
"PJSIP_SC_BAD_REQUEST", 
"BAD_REQUEST" },
 
 3651    { PJSIP_SC_UNAUTHORIZED, 
"PJSIP_SC_UNAUTHORIZED", 
"UNAUTHORIZED" },
 
 3652    { PJSIP_SC_PAYMENT_REQUIRED, 
"PJSIP_SC_PAYMENT_REQUIRED", 
"PAYMENT_REQUIRED" },
 
 3653    { PJSIP_SC_FORBIDDEN, 
"PJSIP_SC_FORBIDDEN", 
"FORBIDDEN" },
 
 3654    { PJSIP_SC_NOT_FOUND, 
"PJSIP_SC_NOT_FOUND", 
"NOT_FOUND" },
 
 3655    { PJSIP_SC_METHOD_NOT_ALLOWED, 
"PJSIP_SC_METHOD_NOT_ALLOWED", 
"METHOD_NOT_ALLOWED" },
 
 3656    { PJSIP_SC_NOT_ACCEPTABLE, 
"PJSIP_SC_NOT_ACCEPTABLE", 
"NOT_ACCEPTABLE" },
 
 3657    { PJSIP_SC_PROXY_AUTHENTICATION_REQUIRED, 
"PJSIP_SC_PROXY_AUTHENTICATION_REQUIRED", 
"PROXY_AUTHENTICATION_REQUIRED" },
 
 3658    { PJSIP_SC_REQUEST_TIMEOUT, 
"PJSIP_SC_REQUEST_TIMEOUT", 
"REQUEST_TIMEOUT" },
 
 3659    { PJSIP_SC_CONFLICT, 
"PJSIP_SC_CONFLICT", 
"CONFLICT" },
 
 3660    { PJSIP_SC_GONE, 
"PJSIP_SC_GONE", 
"GONE" },
 
 3661    { PJSIP_SC_LENGTH_REQUIRED, 
"PJSIP_SC_LENGTH_REQUIRED", 
"LENGTH_REQUIRED" },
 
 3662    { PJSIP_SC_CONDITIONAL_REQUEST_FAILED, 
"PJSIP_SC_CONDITIONAL_REQUEST_FAILED", 
"CONDITIONAL_REQUEST_FAILED" },
 
 3663    { PJSIP_SC_REQUEST_ENTITY_TOO_LARGE, 
"PJSIP_SC_REQUEST_ENTITY_TOO_LARGE", 
"REQUEST_ENTITY_TOO_LARGE" },
 
 3664    { PJSIP_SC_REQUEST_URI_TOO_LONG, 
"PJSIP_SC_REQUEST_URI_TOO_LONG", 
"REQUEST_URI_TOO_LONG" },
 
 3665    { PJSIP_SC_UNSUPPORTED_MEDIA_TYPE, 
"PJSIP_SC_UNSUPPORTED_MEDIA_TYPE", 
"UNSUPPORTED_MEDIA_TYPE" },
 
 3666    { PJSIP_SC_UNSUPPORTED_URI_SCHEME, 
"PJSIP_SC_UNSUPPORTED_URI_SCHEME", 
"UNSUPPORTED_URI_SCHEME" },
 
 3667    { PJSIP_SC_UNKNOWN_RESOURCE_PRIORITY, 
"PJSIP_SC_UNKNOWN_RESOURCE_PRIORITY", 
"UNKNOWN_RESOURCE_PRIORITY" },
 
 3668    { PJSIP_SC_BAD_EXTENSION, 
"PJSIP_SC_BAD_EXTENSION", 
"BAD_EXTENSION" },
 
 3669    { PJSIP_SC_EXTENSION_REQUIRED, 
"PJSIP_SC_EXTENSION_REQUIRED", 
"EXTENSION_REQUIRED" },
 
 3670    { PJSIP_SC_SESSION_TIMER_TOO_SMALL, 
"PJSIP_SC_SESSION_TIMER_TOO_SMALL", 
"SESSION_TIMER_TOO_SMALL" },
 
 3671    { PJSIP_SC_INTERVAL_TOO_BRIEF, 
"PJSIP_SC_INTERVAL_TOO_BRIEF", 
"INTERVAL_TOO_BRIEF" },
 
 3672    { PJSIP_SC_BAD_LOCATION_INFORMATION, 
"PJSIP_SC_BAD_LOCATION_INFORMATION", 
"BAD_LOCATION_INFORMATION" },
 
 3673    { PJSIP_SC_USE_IDENTITY_HEADER, 
"PJSIP_SC_USE_IDENTITY_HEADER", 
"USE_IDENTITY_HEADER" },
 
 3674    { PJSIP_SC_PROVIDE_REFERRER_HEADER, 
"PJSIP_SC_PROVIDE_REFERRER_HEADER", 
"PROVIDE_REFERRER_HEADER" },
 
 3675    { PJSIP_SC_FLOW_FAILED, 
"PJSIP_SC_FLOW_FAILED", 
"FLOW_FAILED" },
 
 3676    { PJSIP_SC_ANONIMITY_DISALLOWED, 
"PJSIP_SC_ANONIMITY_DISALLOWED", 
"ANONIMITY_DISALLOWED" },
 
 3677    { PJSIP_SC_BAD_IDENTITY_INFO, 
"PJSIP_SC_BAD_IDENTITY_INFO", 
"BAD_IDENTITY_INFO" },
 
 3678    { PJSIP_SC_UNSUPPORTED_CERTIFICATE, 
"PJSIP_SC_UNSUPPORTED_CERTIFICATE", 
"UNSUPPORTED_CERTIFICATE" },
 
 3679    { PJSIP_SC_INVALID_IDENTITY_HEADER, 
"PJSIP_SC_INVALID_IDENTITY_HEADER", 
"INVALID_IDENTITY_HEADER" },
 
 3680    { PJSIP_SC_FIRST_HOP_LACKS_OUTBOUND_SUPPORT, 
"PJSIP_SC_FIRST_HOP_LACKS_OUTBOUND_SUPPORT", 
"FIRST_HOP_LACKS_OUTBOUND_SUPPORT" },
 
 3681    { PJSIP_SC_MAX_BREADTH_EXCEEDED, 
"PJSIP_SC_MAX_BREADTH_EXCEEDED", 
"MAX_BREADTH_EXCEEDED" },
 
 3682    { PJSIP_SC_BAD_INFO_PACKAGE, 
"PJSIP_SC_BAD_INFO_PACKAGE", 
"BAD_INFO_PACKAGE" },
 
 3683    { PJSIP_SC_CONSENT_NEEDED, 
"PJSIP_SC_CONSENT_NEEDED", 
"CONSENT_NEEDED" },
 
 3684    { PJSIP_SC_TEMPORARILY_UNAVAILABLE, 
"PJSIP_SC_TEMPORARILY_UNAVAILABLE", 
"TEMPORARILY_UNAVAILABLE" },
 
 3685    { PJSIP_SC_CALL_TSX_DOES_NOT_EXIST, 
"PJSIP_SC_CALL_TSX_DOES_NOT_EXIST", 
"CALL_TSX_DOES_NOT_EXIST" },
 
 3686    { PJSIP_SC_LOOP_DETECTED, 
"PJSIP_SC_LOOP_DETECTED", 
"LOOP_DETECTED" },
 
 3687    { PJSIP_SC_TOO_MANY_HOPS, 
"PJSIP_SC_TOO_MANY_HOPS", 
"TOO_MANY_HOPS" },
 
 3688    { PJSIP_SC_ADDRESS_INCOMPLETE, 
"PJSIP_SC_ADDRESS_INCOMPLETE", 
"ADDRESS_INCOMPLETE" },
 
 3689    { PJSIP_SC_BUSY_HERE, 
"PJSIP_SC_BUSY_HERE", 
"BUSY_HERE" },
 
 3690    { PJSIP_SC_REQUEST_TERMINATED, 
"PJSIP_SC_REQUEST_TERMINATED", 
"REQUEST_TERMINATED" },
 
 3691    { PJSIP_SC_NOT_ACCEPTABLE_HERE, 
"PJSIP_SC_NOT_ACCEPTABLE_HERE", 
"NOT_ACCEPTABLE_HERE" },
 
 3692    { PJSIP_SC_BAD_EVENT, 
"PJSIP_SC_BAD_EVENT", 
"BAD_EVENT" },
 
 3693    { PJSIP_SC_REQUEST_UPDATED, 
"PJSIP_SC_REQUEST_UPDATED", 
"REQUEST_UPDATED" },
 
 3694    { PJSIP_SC_REQUEST_PENDING, 
"PJSIP_SC_REQUEST_PENDING", 
"REQUEST_PENDING" },
 
 3695    { PJSIP_SC_UNDECIPHERABLE, 
"PJSIP_SC_UNDECIPHERABLE", 
"UNDECIPHERABLE" },
 
 3696    { PJSIP_SC_SECURITY_AGREEMENT_NEEDED, 
"PJSIP_SC_SECURITY_AGREEMENT_NEEDED", 
"SECURITY_AGREEMENT_NEEDED" },
 
 3697    { PJSIP_SC_INTERNAL_SERVER_ERROR, 
"PJSIP_SC_INTERNAL_SERVER_ERROR", 
"INTERNAL_SERVER_ERROR" },
 
 3698    { PJSIP_SC_NOT_IMPLEMENTED, 
"PJSIP_SC_NOT_IMPLEMENTED", 
"NOT_IMPLEMENTED" },
 
 3699    { PJSIP_SC_BAD_GATEWAY, 
"PJSIP_SC_BAD_GATEWAY", 
"BAD_GATEWAY" },
 
 3700    { PJSIP_SC_SERVICE_UNAVAILABLE, 
"PJSIP_SC_SERVICE_UNAVAILABLE", 
"SERVICE_UNAVAILABLE" },
 
 3701    { PJSIP_SC_SERVER_TIMEOUT, 
"PJSIP_SC_SERVER_TIMEOUT", 
"SERVER_TIMEOUT" },
 
 3702    { PJSIP_SC_VERSION_NOT_SUPPORTED, 
"PJSIP_SC_VERSION_NOT_SUPPORTED", 
"VERSION_NOT_SUPPORTED" },
 
 3703    { PJSIP_SC_MESSAGE_TOO_LARGE, 
"PJSIP_SC_MESSAGE_TOO_LARGE", 
"MESSAGE_TOO_LARGE" },
 
 3704    { PJSIP_SC_PUSH_NOTIFICATION_SERVICE_NOT_SUPPORTED, 
"PJSIP_SC_PUSH_NOTIFICATION_SERVICE_NOT_SUPPORTED", 
"PUSH_NOTIFICATION_SERVICE_NOT_SUPPORTED" },
 
 3705    { PJSIP_SC_PRECONDITION_FAILURE, 
"PJSIP_SC_PRECONDITION_FAILURE", 
"PRECONDITION_FAILURE" },
 
 3706    { PJSIP_SC_BUSY_EVERYWHERE, 
"PJSIP_SC_BUSY_EVERYWHERE", 
"BUSY_EVERYWHERE" },
 
 3707    { PJSIP_SC_DECLINE, 
"PJSIP_SC_DECLINE", 
"DECLINE" },
 
 3708    { PJSIP_SC_DOES_NOT_EXIST_ANYWHERE, 
"PJSIP_SC_DOES_NOT_EXIST_ANYWHERE", 
"DOES_NOT_EXIST_ANYWHERE" },
 
 3709    { PJSIP_SC_NOT_ACCEPTABLE_ANYWHERE, 
"PJSIP_SC_NOT_ACCEPTABLE_ANYWHERE", 
"NOT_ACCEPTABLE_ANYWHERE" },
 
 3710    { PJSIP_SC_UNWANTED, 
"PJSIP_SC_UNWANTED", 
"UNWANTED" },
 
 3711    { PJSIP_SC_REJECTED, 
"PJSIP_SC_REJECTED", 
"REJECTED" },
 
 
 3733#ifdef TEST_FRAMEWORK 
 3740        info->name = 
"xml_sanitization_end_null";
 
 3741        info->category = 
"/res/res_pjsip/";
 
 3742        info->summary = 
"Ensure XML sanitization works as expected with a long string";
 
 3743        info->description = 
"This test sanitizes a string which exceeds the output\n" 
 3744            "buffer size. Once done the string is confirmed to be NULL terminated.";
 
 3751    if (sanitized[7] != 
'\0') {
 
 3765        info->name = 
"xml_sanitization_exceeds_buffer";
 
 3766        info->category = 
"/res/res_pjsip/";
 
 3767        info->summary = 
"Ensure XML sanitization does not exceed buffer when output won't fit";
 
 3768        info->description = 
"This test sanitizes a string which before sanitization would\n" 
 3769            "fit within the output buffer. After sanitization, however, the string would\n" 
 3770            "exceed the buffer. Once done the string is confirmed to be NULL terminated.";
 
 3777    if (sanitized[7] != 
'\0') {
 
 3828        pj_pool_release(temp_pool);
 
 
 3844    const unsigned int flags = 0; 
 
 3853        ast_log(
LOG_ERROR, 
"Failed to create PJSIP endpoint structure. Aborting load\n");
 
 3864        ast_log(
LOG_ERROR, 
"Failed to create memory pool for SIP. Aborting load\n");
 
 3884    if (
status != PJ_SUCCESS) {
 
 
 3905    pjmedia_strerror(0, 
NULL, 0);
 
 
 3927    if (pj_init() != PJ_SUCCESS) {
 
 3931    if (pjlib_util_init() != PJ_SUCCESS) {
 
 3936    if (pj_register_strerror(PJMEDIA_ERRNO_START, PJ_ERRNO_SPACE_SIZE, pjmedia_strerror)
 
 3938        ast_log(
LOG_WARNING, 
"Failed to register pjmedia error codes.  Codes will not be decoded.\n");
 
 3957        ast_log(
LOG_ERROR, 
"Failed to initialize SIP 'system' configuration section. Aborting load\n");
 
 3972        ast_log(
LOG_ERROR, 
"Failed to create SIP serializer pool. Aborting load\n");
 
 3987        ast_log(
LOG_ERROR, 
"Failed to initialize SIP transport monitor. Aborting load\n");
 
 3995        ast_log(
LOG_ERROR, 
"Failed to pre-initialize OPTIONS handling. Aborting load\n");
 
 4000        ast_log(
LOG_ERROR, 
"Failed to initialize SIP configuration. Aborting load\n");
 
 4008        ast_log(
LOG_ERROR, 
"Failed to initialize SIP transport management. Aborting load\n");
 
 4013        ast_log(
LOG_ERROR, 
"Failed to register distributor module. Aborting load\n");
 
 4018        ast_log(
LOG_ERROR, 
"Failed to initialize supplement hooks. Aborting load\n");
 
 4023        ast_log(
LOG_ERROR, 
"Failed to initialize OPTIONS handling. Aborting load\n");
 
 4036        ast_log(
LOG_ERROR, 
"Failed to initialize message IP updating. Aborting load\n");
 
 
 4095    .
requires = 
"dnsmgr,res_pjproject,res_sorcery_config,res_sorcery_memory,res_sorcery_astdb",
 
 4096    .optional_modules = 
"res_geolocation,res_statsd",
 
Access Control of various sorts.
void ast_cli_unregister_multiple(void)
static int compare(const char *text, const char *template)
Asterisk main include file. File version handling, generic pbx functions.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
#define ast_calloc(num, len)
A wrapper for calloc()
#define ast_malloc(len)
A wrapper for malloc()
#define ao2_t_ref(o, delta, tag)
@ AO2_ALLOC_OPT_LOCK_NOLOCK
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_alloc_options(data_size, destructor_fn, options)
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
#define ao2_alloc(data_size, destructor_fn)
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
#define AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED
#define AST_PRES_USER_NUMBER_UNSCREENED
#define AST_PRES_USER_NUMBER_PASSED_SCREEN
#define AST_PRES_RESTRICTED
#define AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED
Internal Asterisk hangup causes.
#define AST_CAUSE_CONGESTION
#define AST_CAUSE_UNALLOCATED
#define AST_CAUSE_INTERWORKING
#define AST_CAUSE_NUMBER_CHANGED
#define AST_CAUSE_BEARERCAPABILITY_NOTAVAIL
#define AST_CAUSE_INVALID_NUMBER_FORMAT
#define AST_CAUSE_FAILURE
#define AST_CAUSE_DESTINATION_OUT_OF_ORDER
#define AST_CAUSE_NO_USER_RESPONSE
#define AST_CAUSE_NORMAL_TEMPORARY_FAILURE
#define AST_CAUSE_CALL_REJECTED
#define AST_CAUSE_FACILITY_REJECTED
#define AST_CAUSE_RECOVERY_ON_TIMER_EXPIRE
#define AST_CAUSE_NO_ROUTE_DESTINATION
#define AST_CAUSE_NO_ANSWER
#define AST_CAUSE_USER_BUSY
void ast_party_id_copy(struct ast_party_id *dest, const struct ast_party_id *src)
Copy the source party id information to the destination party id.
static struct ast_channel * callback(struct ast_channelstorage_instance *driver, ao2_callback_data_fn *cb_fn, void *arg, void *data, int ao2_flags)
Standard Command Line Interface.
#define AST_CLI_DEFINE(fn, txt,...)
void ast_cli(int fd, const char *fmt,...)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
int sip_cli_print_global(struct ast_sip_cli_context *context)
void ast_sip_destroy_system(void)
int sip_cli_print_system(struct ast_sip_cli_context *context)
int ast_sip_initialize_system(void)
void ast_sip_initialize_dns(void)
void sip_get_threadpool_options(struct ast_threadpool_options *threadpool_options)
static struct ao2_container * transport_states
Generic File Format Support. Should be included by clients of the file handling routines....
int ast_sip_push_task(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
Pushes a task to SIP servants.
struct ast_taskprocessor * ast_sip_create_serializer(const char *name)
Create a new serializer for SIP tasks.
struct ast_taskprocessor * ast_sip_create_serializer_group(const char *name, struct ast_serializer_shutdown_group *shutdown_group)
Create a new serializer for SIP tasks.
int ast_sip_thread_is_servant(void)
Determine if the current thread is a SIP servant thread.
int ast_sip_push_task_synchronous(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
Push a task to SIP servants and wait for it to complete.
int ast_sip_push_task_wait_servant(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
Push a task to SIP servants and wait for it to complete.
int ast_sip_push_task_wait_serializer(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
Push a task to the serializer and wait for it to complete.
Support for logging to various files, console and syslog Configuration in file logger....
#define DEBUG_ATLEAST(level)
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_verb(level,...)
A set of macros to manage forward-linked lists.
#define AST_RWLIST_REMOVE_CURRENT
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_RWLIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a read/write list of specified type, statically initialized.
#define AST_RWLIST_INSERT_AFTER
#define AST_RWLIST_TRAVERSE_SAFE_END
#define AST_RWLIST_TRAVERSE
#define AST_RWLIST_INSERT_HEAD
#define AST_RWLIST_INSERT_TAIL
#define AST_RWLIST_INSERT_BEFORE_CURRENT
Asterisk locking-related definitions:
#define ast_cond_destroy(cond)
#define ast_cond_wait(cond, mutex)
#define ast_cond_init(cond, attr)
#define ast_mutex_init(pmutex)
#define ast_mutex_unlock(a)
#define SCOPED_LOCK(varname, lock, lockfunc, unlockfunc)
Scoped Locks.
pthread_cond_t ast_cond_t
#define ast_mutex_destroy(a)
#define ast_mutex_lock(a)
#define ast_cond_signal(cond)
Asterisk module definitions.
@ AST_MODFLAG_GLOBAL_SYMBOLS
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODPRI_CHANNEL_DEPEND
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
static char * ast_sockaddr_stringify_host(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only, suitable for a URL (with brack...
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
static int ast_sockaddr_isnull(const struct ast_sockaddr *addr)
Checks if the ast_sockaddr is null. "null" in this sense essentially means uninitialized,...
#define ast_sockaddr_set_port(addr, port)
Sets the port number of a socket address.
static struct ast_serializer_shutdown_group * shutdown_group
Shutdown group for options serializers.
void ast_pjproject_log_intercept_begin(int fd)
Begin PJPROJECT log interception for CLI output.
void ast_pjproject_log_intercept_end(void)
End PJPROJECT log interception for CLI output.
void ast_pjproject_caching_pool_destroy(pj_caching_pool *cp)
Destroy caching pool factory and all cached pools.
void ast_pjproject_caching_pool_init(pj_caching_pool *cp, const pj_pool_factory_policy *policy, pj_size_t max_capacity)
Initialize the caching pool factory.
static const pjsip_method refer_method
static pjsip_endpoint * ast_pjsip_endpoint
void ast_sip_unregister_supplement(struct ast_sip_supplement *supplement)
Unregister a an supplement to SIP out of dialog processing.
static pj_sockaddr host_ip_ipv4
int ast_sip_is_media_type_in(pjsip_media_type *a,...)
Check if a media type is in a list of others.
struct ast_sip_endpoint * ast_sip_get_endpoint(const char *to, int get_default_outbound, char **uri)
Retrieves an endpoint and URI from the "to" string.
void ast_sip_add_usereqphone(const struct ast_sip_endpoint *endpoint, pj_pool_t *pool, pjsip_uri *uri)
Add 'user=phone' parameter to URI if enabled and user is a phone number.
static int unload_pjsip(void *data)
static void supplement_outgoing_response(pjsip_tx_data *tdata, struct ast_sip_endpoint *sip_endpoint)
struct pjsip_param * ast_sip_pjsip_uri_get_other_param(pjsip_uri *uri, const pj_str_t *param_str)
Find an 'other' SIP/SIPS URI parameter by name.
const pj_str_t * ast_sip_pjsip_uri_get_username(pjsip_uri *uri)
Get the user portion of the pjsip_uri.
static const pjsip_method info_method
void ast_sip_unregister_service(pjsip_module *module)
const char * ast_sip_get_host_ip_string(int af)
Retrieve the local host address in string form.
pj_status_t(* create_dlg_uac)(pjsip_user_agent *ua, pjsip_rx_data *rdata, const pj_str_t *contact, pjsip_dialog **p_dlg)
static struct ast_sip_outbound_authenticator * registered_outbound_authenticator
pjsip_media_type pjsip_media_type_application_media_control_xml
static struct ast_cli_entry cli_commands[]
static int create_in_dialog_request(const pjsip_method *method, struct pjsip_dialog *dlg, pjsip_tx_data **tdata)
int ast_sip_call_codec_str_to_pref(struct ast_flags *pref, const char *pref_str, int is_outgoing)
Convert a call codec preference string to preference flags.
char * ast_sip_rdata_get_header_value(pjsip_rx_data *rdata, const pj_str_t str)
Get a specific header value from rdata.
pjsip_dialog * ast_sip_create_dialog_uas(const struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pj_status_t *status)
General purpose method for creating a UAS dialog with an endpoint.
pjsip_media_type pjsip_media_type_application_json
static char * cli_dump_endpt(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int ast_sip_requires_authentication(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
Determine if an incoming request requires authentication.
static struct send_request_data * send_request_data_alloc(struct ast_sip_endpoint *endpoint, void *token, void(*callback)(void *token, pjsip_event *e))
int ast_sip_send_response(pjsip_response_addr *res_addr, pjsip_tx_data *tdata, struct ast_sip_endpoint *sip_endpoint)
Send a response to an out of dialog request.
pjsip_generic_string_hdr * ast_sip_add_header2(pjsip_tx_data *tdata, const char *name, const char *value)
Add a header to an outbound SIP message, returning a pointer to the header.
int ast_copy_pj_str2(char **dest, const pj_str_t *src)
Create and copy a pj_str_t into a standard character buffer.
int ast_sip_get_host_ip(int af, pj_sockaddr *addr)
Retrieve the local host address in IP form.
int ast_sip_register_service(pjsip_module *module)
Register a SIP service in Asterisk.
static const pjsip_method * get_pjsip_method(const char *method)
static int create_out_of_dialog_request(const pjsip_method *method, struct ast_sip_endpoint *endpoint, const char *uri, struct ast_sip_contact *provided_contact, pjsip_tx_data **tdata)
static void send_request_timer_callback(pj_timer_heap_t *theap, pj_timer_entry *entry)
static struct @487 methods[]
static int reload_configuration_task(void *obj)
int ast_sip_is_allowed_uri(pjsip_uri *uri)
Check whether a pjsip_uri is allowed or not.
int ast_sip_register_outbound_authenticator(struct ast_sip_outbound_authenticator *auth)
Register an outbound SIP authenticator.
static struct ast_sip_endpoint * handle_slash(const char *to, char *destination, char **uri, char *slash, char *atsign, char *scheme)
static struct ast_sip_endpoint * handle_single_token(const char *to, char *destination, int get_default_outbound, char **uri)
static int ast_sip_push_task_wait(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
static void send_request_wrapper_destructor(void *obj)
static pjsip_fromto_hdr * get_id_header(pjsip_rx_data *rdata, const pj_str_t *header_name)
static int unregister_service(void *data)
static void send_request_data_destroy(void *obj)
static int uas_use_sips_contact(pjsip_rx_data *rdata)
Determine if a SIPS Contact header is required.
const int ast_sip_hangup_sip2cause(int cause)
Convert SIP hangup causes to Asterisk hangup causes.
int ast_sip_rewrite_uri_to_local(pjsip_sip_uri *uri, pjsip_tx_data *tdata)
Replace domain and port of SIP URI to point to (external) signaling address of this Asterisk instance...
int ast_sip_set_id_connected_line(struct pjsip_rx_data *rdata, struct ast_party_id *id)
Set the ID for a connected line update.
pjsip_media_type pjsip_media_type_application_sdp
void ast_sip_register_supplement(struct ast_sip_supplement *supplement)
Register a supplement to SIP out of dialog processing.
void ast_sip_add_date_header(pjsip_tx_data *tdata)
Adds a Date header to the tdata, formatted like: Date: Wed, 01 Jan 2021 14:53:01 GMT.
pjsip_media_type pjsip_media_type_text_plain
pj_thread_t * monitor_thread
void ast_sip_unregister_outbound_authenticator(struct ast_sip_outbound_authenticator *auth)
Unregister an outbound SIP authenticator.
int ast_sip_set_id_from_invite(struct pjsip_rx_data *rdata, struct ast_party_id *id, struct ast_party_id *default_id, int trust_inbound)
Set the ID from an INVITE.
pjsip_media_type pjsip_media_type_application_pidf_xml
int ast_sip_create_rdata(pjsip_rx_data *rdata, char *packet, const char *src_name, int src_port, char *transport_type, const char *local_name, int local_port)
General purpose method for creating an rdata structure using specific information.
enum ast_sip_check_auth_result ast_sip_check_authentication(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pjsip_tx_data *tdata)
Method to determine authentication status of an incoming request.
pjsip_endpoint * ast_sip_get_pjsip_endpoint(void)
Get a pointer to the PJSIP endpoint.
int ast_sip_register_endpoint_identifier(struct ast_sip_endpoint_identifier *identifier)
Register a SIP endpoint identifier.
static void send_request_cb(void *token, pjsip_event *e)
void * ast_sip_dict_get(void *ht, const char *key)
Retrieves the value associated with the given key.
int ast_sip_update_from(pjsip_tx_data *tdata, char *from)
Overwrite fields in the outbound 'From' header.
static const pjsip_method message_method
int ast_sip_format_endpoint_ami(struct ast_sip_endpoint *endpoint, struct ast_sip_ami *ami, int *count)
Formats the endpoint and sends over AMI.
int ast_sip_dtmf_to_str(const enum ast_sip_dtmf_mode dtmf, char *buf, size_t buf_len)
Convert the DTMF mode enum value into a string.
int ast_sip_str2rc(const char *name)
Convert name to SIP response code.
static struct ast_threadpool * sip_threadpool
int ast_sip_set_tpselector_from_transport(const struct ast_sip_transport *transport, pjsip_tpselector *selector)
Sets pjsip_tpselector from ast_sip_transport.
int ast_sip_is_uri_sip_sips(pjsip_uri *uri)
Check whether a pjsip_uri is SIP/SIPS or not.
int ast_sip_set_tpselector_from_ep_or_uri(const struct ast_sip_endpoint *endpoint, pjsip_sip_uri *sip_uri, pjsip_tpselector *selector)
Sets pjsip_tpselector from an endpoint or uri.
static int check_request_status(struct send_request_data *req_data, pjsip_event *e)
static void sip_thread_start(void)
static char * cli_show_endpoint_identifiers(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static void clean_contact_from_tdata(pjsip_tx_data *tdata)
void ast_sip_unregister_endpoint_identifier(struct ast_sip_endpoint_identifier *identifier)
Unregister a SIP endpoint identifier.
static int reload_module(void)
void ast_copy_pj_str(char *dest, const pj_str_t *src, size_t size)
Copy a pj_str_t into a standard character buffer.
static int send_in_dialog_request(pjsip_tx_data *tdata, struct pjsip_dialog *dlg)
static int insert_user_in_contact_uri(const char *to, const char *endpoint_name, const char *aors, const char *user, char **uri)
Find a contact and insert a "user@" into its URI.
#define SERIALIZER_POOL_SIZE
const char * ast_sip_call_codec_pref_to_str(struct ast_flags pref)
Convert the call codec preference flags to a string.
struct ast_sip_endpoint * ast_sip_identify_endpoint(pjsip_rx_data *rdata)
Determine the endpoint that has sent a SIP message.
int ast_sip_send_out_of_dialog_request(pjsip_tx_data *tdata, struct ast_sip_endpoint *endpoint, int timeout, void *token, void(*callback)(void *token, pjsip_event *e))
General purpose method for sending an Out-Of-Dialog SIP request.
static struct ast_sip_endpoint * handle_atsign(const char *to, char *destination, char **uri, char *slash, char *atsign, char *scheme, int get_default_outbound)
pjsip_dialog * ast_sip_create_dialog_uas_locked(const struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pj_status_t *status)
General purpose method for creating a UAS dialog with an endpoint.
pjsip_media_type pjsip_media_type_application_simple_message_summary
struct ast_sip_transport_state * ast_sip_find_transport_state_in_use(struct ast_sip_request_transport_details *details)
Returns the transport state currently in use based on request transport details.
static char host_ip_ipv6_string[PJ_INET6_ADDRSTRLEN]
int ast_sip_dlg_set_transport(const struct ast_sip_endpoint *endpoint, pjsip_dialog *dlg, pjsip_tpselector *selector)
Set the transport on a dialog.
static pj_sockaddr host_ip_ipv6
pjsip_dialog * ast_sip_create_dialog_uac(const struct ast_sip_endpoint *endpoint, const char *uri, const char *request_user)
General purpose method for creating a UAC dialog with an endpoint.
static pj_status_t endpt_send_request(struct ast_sip_endpoint *endpoint, pjsip_tx_data *tdata, pj_int32_t timeout, void *token, pjsip_endpt_send_callback cb)
void ast_sip_unregister_authenticator(struct ast_sip_authenticator *auth)
Unregister a SIP authenticator.
int ast_sip_send_request(pjsip_tx_data *tdata, struct pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint, void *token, void(*callback)(void *token, pjsip_event *e))
General purpose method for sending a SIP request.
long ast_sip_threadpool_queue_size(void)
Return the size of the SIP threadpool's task queue.
int ast_sip_set_request_transport_details(struct ast_sip_request_transport_details *details, pjsip_tx_data *tdata, int use_ipv6)
Sets request transport details based on tdata.
static pj_bool_t supplement_on_rx_request(pjsip_rx_data *rdata)
static pjsip_msg_body * ast_body_to_pjsip_body(pj_pool_t *pool, const struct ast_sip_body *body)
void ast_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
Register an endpoint formatter.
int ast_sip_add_body(pjsip_tx_data *tdata, const struct ast_sip_body *body)
Add a body to an outbound SIP message.
void * ast_sip_dict_set(pj_pool_t *pool, void *ht, const char *key, void *val)
Set the value for the given key.
int ast_sip_are_media_types_equal(pjsip_media_type *a, pjsip_media_type *b)
Compare pjsip media types.
void ast_sip_tpselector_unref(pjsip_tpselector *selector)
Unreference a pjsip_tpselector.
void never_called_res_pjsip(void)
int ast_sip_get_transport_name(const struct ast_sip_endpoint *endpoint, pjsip_sip_uri *sip_uri, char *buf, size_t buf_len)
Get the transport name from an endpoint or request uri.
static int set_id_from_from(struct pjsip_rx_data *rdata, struct ast_party_id *id)
void ast_sip_unregister_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
Unregister an endpoint formatter.
static void * monitor_thread_exec(void *endpt)
static char * cli_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int ast_sip_register_authenticator(struct ast_sip_authenticator *auth)
Register a SIP authenticator.
int ast_sip_create_rdata_with_contact(pjsip_rx_data *rdata, char *packet, const char *src_name, int src_port, char *transport_type, const char *local_name, int local_port, const char *contact)
General purpose method for creating an rdata structure using specific information.
int ast_sip_add_body_multipart(pjsip_tx_data *tdata, const struct ast_sip_body *bodies[], int num_bodies)
Add a multipart body to an outbound SIP message.
static pjsip_dialog * create_dialog_uas(const struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pj_status_t *status, create_dlg_uac create_fun)
pjsip_media_type pjsip_media_type_application_rlmi_xml
static int monitor_continue
static const struct response_code_map rc_map[]
static void remove_request_headers(pjsip_endpoint *endpt)
int ast_sip_update_to_uri(pjsip_tx_data *tdata, const char *to)
Replace the To URI in the tdata with the supplied one.
pjsip_media_type pjsip_media_type_multipart_mixed
static int register_service(void *data)
pjsip_media_type pjsip_media_type_application_xpidf_xml
static int load_module(void)
int ast_sip_set_outbound_proxy(pjsip_tx_data *tdata, const char *proxy)
Set the outbound proxy for an outbound SIP message.
static struct ast_sip_authenticator * registered_authenticator
struct ast_threadpool * ast_sip_threadpool(void)
Retrieve the SIP threadpool object.
int ast_sip_will_uri_survive_restart(pjsip_sip_uri *uri, struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
int ast_sip_register_endpoint_identifier_with_name(struct ast_sip_endpoint_identifier *identifier, const char *name)
Register a SIP endpoint identifier with a name.
pjsip_media_type pjsip_media_type_multipart_alternative
int ast_sip_set_tpselector_from_transport_name(const char *transport_name, pjsip_tpselector *selector)
Sets pjsip_tpselector from ast_sip_transport.
int ast_sip_create_request(const char *method, struct pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint, const char *uri, struct ast_sip_contact *contact, pjsip_tx_data **tdata)
General purpose method for creating a SIP request.
pj_caching_pool caching_pool
static int find_transport_state_in_use(void *obj, void *arg, int flags)
Callback function for finding the transport the request is going out on.
static void endpt_send_request_cb(void *token, pjsip_event *e)
const pjsip_method * pmethod
int ast_sip_str_to_dtmf(const char *dtmf_mode)
Convert the DTMF mode name into an enum.
static int do_cli_dump_endpt(void *v_a)
int ast_sip_add_header(pjsip_tx_data *tdata, const char *name, const char *value)
Add a header to an outbound SIP message.
static int unload_module(void)
const pj_str_t * ast_sip_pjsip_uri_get_hostname(pjsip_uri *uri)
Get the host portion of the pjsip_uri.
static pjsip_module supplement_module
static void pool_destroy_callback(void *arg)
static char host_ip_ipv4_string[PJ_INET6_ADDRSTRLEN]
static int load_pjsip(void)
static pj_bool_t does_method_match(const pj_str_t *message_method, const char *supplement_method)
int ast_sip_send_stateful_response(pjsip_rx_data *rdata, pjsip_tx_data *tdata, struct ast_sip_endpoint *sip_endpoint)
Send a stateful response to an out of dialog request.
int ast_sip_is_content_type(pjsip_media_type *content_type, char *type, char *subtype)
Checks if the given content type matches type/subtype.
int ast_sip_append_body(pjsip_tx_data *tdata, const char *body_text)
Append body data to a SIP message.
static int set_id_from_pai(pjsip_rx_data *rdata, struct ast_party_id *id)
#define ENDPOINT_IDENTIFIER_FORMAT
int ast_sip_create_request_with_auth(const struct ast_sip_auth_vector *auths, pjsip_rx_data *challenge, pjsip_tx_data *old_request, pjsip_tx_data **new_request)
Create a response to an authentication challenge.
pjsip_media_type pjsip_media_type_application_cpim_xpidf_xml
static void set_id_from_hdr(pjsip_fromto_hdr *hdr, struct ast_party_id *id)
static int set_id_from_rpid(pjsip_rx_data *rdata, struct ast_party_id *id)
static void stop_monitor_thread(void)
pjsip_sip_uri * ast_sip_get_contact_sip_uri(pjsip_tx_data *tdata)
Return the SIP URI of the Contact header.
static int sync_task(void *data)
pjsip_media_type pjsip_media_type_multipart_related
static struct ast_serializer_pool * sip_serializer_pool
int ast_sip_failover_request(pjsip_tx_data *tdata)
Set a request to use the next value in the list of resolved addresses.
static int sip_dialog_create_from(pj_pool_t *pool, pj_str_t *from, const char *user, const char *domain, const pj_str_t *target, pjsip_tpselector *selector)
void ast_sip_modify_id_header(pj_pool_t *pool, pjsip_fromto_hdr *id_hdr, const struct ast_party_id *id)
Set name and number information on an identity header.
int ast_sip_create_response(const pjsip_rx_data *rdata, int st_code, struct ast_sip_contact *contact, pjsip_tx_data **tdata)
General purpose method for creating a SIP response.
char * ast_sip_get_endpoint_identifier_order(void)
Retrieve the global endpoint_identifier_order setting.
struct ast_sip_contact * ast_sip_location_retrieve_contact_from_aor_list(const char *aor_list)
Retrieve the first bound contact from a list of AORs.
struct ao2_container * ast_sip_get_transport_states(void)
Retrieves all transport states.
struct ast_sip_aor * ast_sip_location_retrieve_aor(const char *aor_name)
Retrieve a named AOR.
#define ast_sip_call_codec_pref_test(__param, __codec_pref)
Returns true if the preference is set in the parameter.
void ast_sip_message_apply_transport(const char *transport_name, pjsip_tx_data *tdata)
Apply the configuration for a transport to an outgoing message.
#define AST_SIP_X_AST_TXP
#define AST_SIP_USER_OPTIONS_TRUNCATE_CHECK(str)
Truncate the URI user field options string if enabled.
struct ast_sip_endpoint * ast_pjsip_rdata_get_endpoint(pjsip_rx_data *rdata)
Get the looked-up endpoint on an out-of dialog request or response.
struct ast_sip_endpoint * ast_sip_default_outbound_endpoint(void)
Retrieve the default outbound endpoint.
#define ast_sip_mod_data_set(pool, mod_data, id, key, val)
Utilizing a mod_data array for a given id, set the value associated with the given key.
unsigned int ast_sip_get_disable_multi_domain(void)
Retrieve the system setting 'disable multi domain'.
ast_sip_dtmf_mode
DTMF modes for SIP endpoints.
static const pj_str_t AST_PJ_STR_EMPTY
#define ast_sip_mod_data_get(mod_data, id, key)
Using the dictionary stored in mod_data array at a given id, retrieve the value associated with the g...
struct ast_sip_transport_state * ast_sip_get_transport_state(const char *transport_id)
Retrieve transport state.
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
#define MAX_RX_CHALLENGES
ast_sip_check_auth_result
Possible returns from ast_sip_check_authentication.
@ AST_SIP_AUTHENTICATION_SUCCESS
@ AST_SIP_CALL_CODEC_PREF_ALL
@ AST_SIP_CALL_CODEC_PREF_LOCAL
@ AST_SIP_CALL_CODEC_PREF_REMOTE
@ AST_SIP_CALL_CODEC_PREF_UNION
@ AST_SIP_CALL_CODEC_PREF_FIRST
@ AST_SIP_CALL_CODEC_PREF_INTERSECT
#define AST_SIP_X_AST_TXP_LEN
#define PJSTR_PRINTF_VAR(_v)
void ast_sip_get_default_from_user(char *from_user, size_t size)
Retrieve the global default from user.
struct ast_sip_contact * ast_sip_location_retrieve_first_aor_contact(const struct ast_sip_aor *aor)
Retrieve the first bound contact for an AOR.
void ast_sip_location_prune_boot_contacts(void)
Prune the prune_on_boot contacts.
#define ast_sip_transport_is_local(transport_state, addr)
#define PJSTR_PRINTF_SPEC
static void challenge(const char *endpoint_id, struct ast_sip_auth *auth, pjsip_tx_data *tdata, const pjsip_rx_data *rdata, int is_stale, const pjsip_auth_algorithm *algorithm)
Send a WWW-Authenticate challenge.
void ast_sip_sanitize_xml(const char *input, char *output, size_t len)
Replace offensive XML characters with XML entities.
int ast_sip_initialize_scheduler(void)
Initialize scheduler.
int ast_res_pjsip_preinit_options_handling(void)
int ast_sip_initialize_transport_management(void)
void ast_sip_initialize_resolver(void)
int ast_res_pjsip_init_options_handling(int reload)
int ast_sip_initialize_distributor(void)
int ast_res_pjsip_reload_configuration(void)
int ast_sip_destroy_scheduler(void)
void ast_sip_initialize_global_headers(void)
void ast_res_pjsip_cleanup_options_handling(void)
void ast_sip_destroy_transport_management(void)
int ast_sip_initialize_transport_events(void)
void ast_sip_destroy_distributor(void)
int ast_res_pjsip_initialize_configuration(void)
void ast_sip_destroy_global_headers(void)
void ast_res_pjsip_destroy_configuration(void)
int ast_res_pjsip_init_message_filter(void)
void ast_sip_destroy_transport_events(void)
void ast_res_pjsip_cleanup_message_filter(void)
const pjsip_method pjsip_publish_method
Defined method for PUBLISH.
struct ast_taskprocessor * ast_serializer_pool_get(struct ast_serializer_pool *pool)
Retrieve a serializer from the pool.
struct ast_serializer_pool * ast_serializer_pool_create(const char *name, unsigned int size, struct ast_threadpool *threadpool, int timeout)
Create a serializer pool.
int ast_serializer_pool_destroy(struct ast_serializer_pool *pool)
Destroy the serializer pool.
Sorcery Data Access Layer API.
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
void * ast_sorcery_retrieve_by_id(const struct ast_sorcery *sorcery, const char *type, const char *id)
Retrieve an object using its unique identifier.
String manipulation functions.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
#define ast_str_alloca(init_len)
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
char *attribute_pure ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
Checks whether a string begins with another.
descriptor for a cli entry.
struct ast_cli_entry * next
Structure used to handle boolean flags.
Structure for mutex and tracking information.
Information needed to identify an endpoint in a call.
char * tag
User-set "tag".
struct ast_party_number number
Subscriber phone number.
unsigned char valid
TRUE if the number information is valid/present.
An interchangeable way of handling digest authentication for SIP.
enum ast_sip_check_auth_result(* check_authentication)(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pjsip_tx_data *tdata)
Check that an incoming request passes authentication.
int(* requires_authentication)(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
Check if a request requires authentication See ast_sip_requires_authentication for more details.
CLI Formatter Context passed to all formatters.
An entity responsible for identifying the source of a SIP message.
struct ast_sip_endpoint *(* identify_endpoint)(pjsip_rx_data *rdata)
Callback used to identify the source of a message. See ast_sip_identify_endpoint for more details.
unsigned int rewrite_contact
An entity with which Asterisk communicates.
struct ast_sip_auth_vector outbound_auths
const ast_string_field transport
const ast_string_field aors
const ast_string_field outbound_proxy
const ast_string_field fromdomain
unsigned int allow_unauthenticated_options
const ast_string_field fromuser
struct ast_sip_endpoint_nat_configuration nat
struct ast_sip_endpoint_info_configuration info
an interchangeable way of responding to authentication challenges
int(* create_request_with_auth)(const struct ast_sip_auth_vector *auths, struct pjsip_rx_data *challenge, struct pjsip_tx_data *old_request, struct pjsip_tx_data **new_request)
Create a new request with authentication credentials.
Structure which contains information about a transport.
int local_port
Local port for transport.
pjsip_transport * transport
Potential pointer to the transport itself, if UDP.
enum ast_transport type
Type of transport.
pjsip_tpfactory * factory
Potential pointer to the transport factory itself, if TCP/TLS.
pj_str_t local_address
Local address for transport.
A supplement to SIP message processing.
void(* outgoing_request)(struct ast_sip_endpoint *endpoint, struct ast_sip_contact *contact, struct pjsip_tx_data *tdata)
Called on an outgoing SIP request This method is always called from a SIP servant thread.
int(* incoming_request)(struct ast_sip_endpoint *endpoint, struct pjsip_rx_data *rdata)
Called on incoming SIP request This method can indicate a failure in processing in its return....
void(* outgoing_response)(struct ast_sip_endpoint *endpoint, struct ast_sip_contact *contact, struct pjsip_tx_data *tdata)
Called on an outgoing SIP response This method is always called from a SIP servant thread.
void(* incoming_response)(struct ast_sip_endpoint *endpoint, struct pjsip_rx_data *rdata)
Called on an incoming SIP response This method is always called from a SIP servant thread.
enum ast_sip_supplement_priority priority
struct ast_sip_supplement * next
Structure for SIP transport information.
struct pjsip_tpfactory * factory
Transport factory.
struct pjsip_transport * transport
Transport itself.
Socket address structure.
Support for dynamic strings.
A ast_taskprocessor structure is a singleton by name.
An opaque threadpool structure.
struct ast_sip_endpoint_identifier * identifier
struct endpoint_identifier_list::@488 list
Structure to hold information about an outbound request.
struct ast_sip_endpoint * endpoint
unsigned int challenge_count
void(* callback)(void *token, pjsip_event *e)
unsigned int send_cb_called
pj_timer_entry * timeout_timer
void(* callback)(void *token, pjsip_event *e)
userdata associated with baseline taskprocessor test
structure to hold users read from phoneprov_users.conf
An API for managing task processing threads that can be shared across modules.
int ast_taskprocessor_is_task(struct ast_taskprocessor *tps)
Am I the given taskprocessor's current task.
int ast_taskprocessor_push(struct ast_taskprocessor *tps, int(*task_exe)(void *datap), void *datap) attribute_warn_unused_result
Push a task into the specified taskprocessor queue and signal the taskprocessor thread.
#define AST_TEST_REGISTER(cb)
#define ast_test_status_update(a, b, c...)
#define AST_TEST_UNREGISTER(cb)
#define AST_TEST_DEFINE(hdr)
void ast_threadpool_shutdown(struct ast_threadpool *pool)
Shut down a threadpool and destroy it.
long ast_threadpool_queue_size(struct ast_threadpool *pool)
Return the size of the threadpool's task queue.
struct ast_taskprocessor * ast_threadpool_serializer_group(const char *name, struct ast_threadpool *pool, struct ast_serializer_shutdown_group *shutdown_group)
Serialized execution of tasks within a ast_threadpool.
struct ast_threadpool * ast_threadpool_create(const char *name, struct ast_threadpool_listener *listener, const struct ast_threadpool_options *options)
Create a new threadpool.
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
#define AST_THREADSTORAGE(name)
Define a thread storage variable.
UTF-8 information and validation functions.
@ AST_UTF8_REPLACE_VALID
Source contained fully valid UTF-8.
enum ast_utf8_replace_result ast_utf8_replace_invalid_chars(char *dst, size_t *dst_size, const char *src, size_t src_len)
Copy a string safely replacing any invalid UTF-8 sequences.
int error(const char *format,...)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
char * ast_escape_quoted(const char *string, char *outbuf, int buflen)
Escape characters found in a quoted string.
#define ast_set_flag(p, flag)
Universally unique identifier support.