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"
88 time_t t = time(
NULL);
91 strftime(date,
sizeof(date),
"%a, %d %b %Y %T GMT", &tm);
98 pjsip_module **
module = data;
100 ast_log(
LOG_ERROR,
"There is no PJSIP endpoint. Unable to register services\n");
104 ast_log(
LOG_ERROR,
"Unable to register module %.*s\n", (
int) pj_strlen(&(*module)->name), pj_strbuf(&(*module)->name));
107 ast_debug(1,
"Registered SIP service %.*s (%p)\n", (
int) pj_strlen(&(*module)->name), pj_strbuf(&(*module)->name), *module);
118 pjsip_module **
module = data;
123 ast_debug(1,
"Unregistered SIP service %.*s\n", (
int) pj_strlen(&(*module)->name), pj_strbuf(&(*module)->name));
141 ast_debug(1,
"Registered SIP authenticator module %p\n", auth);
149 ast_log(
LOG_WARNING,
"Trying to unregister authenticator %p but authenticator %p registered\n",
154 ast_debug(1,
"Unregistered SIP authenticator %p\n", auth);
160 && !pjsip_method_cmp(&rdata->msg_info.msg->line.req.method, &pjsip_options_method)) {
161 ast_debug(3,
"Skipping OPTIONS authentication due to endpoint configuration\n");
166 ast_log(
LOG_WARNING,
"No SIP authenticator registered. Assuming authentication is not required\n");
174 pjsip_rx_data *rdata, pjsip_tx_data *tdata)
177 ast_log(
LOG_WARNING,
"No SIP authenticator registered. Assuming authentication is successful\n");
192 ast_debug(1,
"Registered SIP outbound authenticator module %p\n", auth);
200 ast_log(
LOG_WARNING,
"Trying to unregister outbound authenticator %p but outbound authenticator %p registered\n",
205 ast_debug(1,
"Unregistered SIP outbound authenticator %p\n", auth);
209 pjsip_tx_data *old_request, pjsip_tx_data **new_request)
212 ast_log(
LOG_WARNING,
"No SIP outbound authenticator registered. Cannot respond to authentication challenge\n");
230 char *prev, *
current, *identifier_order;
234 id_list_item =
ast_calloc(1,
sizeof(*id_list_item));
272 if (!strcmp(prev,
name)) {
341 pjsip_generic_string_hdr *hdr;
344 hdr = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &
str,
NULL);
349 pj_strdup_with_null(rdata->tp_info.pool, &hdr_val, &hdr->hvalue);
374 e->
command =
"pjsip dump endpt [details]";
376 "Usage: pjsip dump endpt [details]\n"
377 " Dump the res_pjsip endpt internals.\n"
379 "Warning: PJPROJECT documents that the function used by this\n"
380 "CLI command may cause a crash when asking for details because\n"
381 "it tries to access all active memory pools.\n";
389 e->
command =
"pjsip dump endpt";
391 "Usage: pjsip dump endpt\n"
392 " Dump the res_pjsip endpt internals.\n";
400 || (
a->argc == 4 && strcasecmp(
a->argv[3],
"details"))) {
411#define ENDPOINT_IDENTIFIER_FORMAT "%-20.20s\n"
416 e->
command =
"pjsip show identifiers";
417 e->
usage =
"Usage: pjsip show identifiers\n"
418 " List all registered endpoint identifiers\n";
433 iter->
name ? iter->
name :
"name not specified");
437#undef ENDPOINT_IDENTIFIER_FORMAT
446 e->
command =
"pjsip show settings";
447 e->
usage =
"Usage: pjsip show settings\n"
448 " Show global and system configuration options\n";
455 if (!context.output_buffer) {
456 ast_cli(
a->fd,
"Could not allocate output buffer.\n");
462 ast_cli(
a->fd,
"Error retrieving settings.\n");
524 pjsip_rx_data *rdata)
530 if (uri->port == rdata->pkt_info.src_port
531 && !pj_strcmp(&uri->host,
532 pj_cstr(&host_name, rdata->pkt_info.src_name))
534 && PJSIP_TRANSPORT_IS_RELIABLE(rdata->tp_info.transport)) {
538 if (!strcasecmp(
"WSS", rdata->tp_info.transport->type_name)) {
540 pj_cstr(&type_name,
"ws");
542 pj_cstr(&type_name, rdata->tp_info.transport->type_name);
545 if (!pj_stricmp(&uri->transport_param, &type_name)
548 || !pj_stricmp(&uri->transport_param,
549 pj_cstr(&type_name,
"ws")))) {
564 pjsip_contact_hdr *contact = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CONTACT,
NULL);
566 if (!contact || (!PJSIP_URI_SCHEME_IS_SIP(contact->uri) && !PJSIP_URI_SCHEME_IS_SIPS(contact->uri))) {
570 return pjsip_uri_get_uri(contact->uri);
584 ((details->
type == transport_state->
type) && (transport_state->
factory) &&
607 pjsip_sip_uri *tmp_uri;
612 pj_strdup(tdata->pool, &uri->host, &tmp_uri->host);
613 uri->port = tmp_uri->port;
614 }
else if ((dlg = pjsip_tdata_get_dlg(tdata))
615 && (tmp_uri = pjsip_uri_get_uri(dlg->local.info->uri))
616 && (PJSIP_URI_SCHEME_IS_SIP(tmp_uri) || PJSIP_URI_SCHEME_IS_SIPS(tmp_uri))) {
617 pj_strdup(tdata->pool, &uri->host, &tmp_uri->host);
618 uri->port = tmp_uri->port;
627 if (transport_state->localnet) {
639 if (transport->external_signaling_port) {
640 uri->port = transport->external_signaling_port;
652 if (!details || !tdata) {
657 transport_type = use_ipv6 ? tdata->tp_info.transport->key.type & ~(PJSIP_TRANSPORT_IPV6)
658 : tdata->tp_info.transport->key.type;
660 if (tdata->tp_sel.type == PJSIP_TPSELECTOR_TRANSPORT) {
661 details->
transport = tdata->tp_sel.u.transport;
662 }
else if (tdata->tp_sel.type == PJSIP_TPSELECTOR_LISTENER) {
663 details->
factory = tdata->tp_sel.u.listener;
664 }
else if (transport_type == PJSIP_TRANSPORT_UDP || transport_type == PJSIP_TRANSPORT_UDP6) {
667 details->
transport = tdata->tp_info.transport;
669 if (transport_type == PJSIP_TRANSPORT_TCP) {
671 }
else if (transport_type == PJSIP_TRANSPORT_TLS) {
681 }
else if ((tdata->msg->type == PJSIP_REQUEST_MSG) &&
682 (via = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_VIA,
NULL))) {
697 pjsip_sip_uri *sip_uri,
char *
buf,
size_t buf_len)
701 pjsip_param *x_transport;
708 x_transport = pjsip_param_find(&sip_uri->other_param, &x_name);
726 pjsip_tpselector *selector)
729 pjsip_tpselector sel = { .type = PJSIP_TPSELECTOR_NONE, };
731 uri = pjsip_uri_get_uri(dlg->target);
738 pjsip_dlg_set_transport(dlg, selector);
740 if (selector == &sel) {
748 const char *domain,
const pj_str_t *target, pjsip_tpselector *selector)
750 pj_str_t tmp, local_addr;
752 pjsip_sip_uri *sip_uri;
753 pjsip_transport_type_e
type;
755 char default_user[PJSIP_MAX_URL_SIZE];
763 pj_strdup_with_null(pool, &tmp, target);
765 if (!(uri = pjsip_parse_uri(pool, tmp.ptr, tmp.slen, 0)) ||
766 (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri))) {
770 sip_uri = pjsip_uri_get_uri(uri);
773 type = pjsip_transport_get_type_from_name(&sip_uri->transport_param);
774 if (PJSIP_URI_SCHEME_IS_SIPS(sip_uri)) {
775 if (
type == PJSIP_TRANSPORT_UNSPECIFIED
776 || !(pjsip_transport_get_flag_from_type(
type) & PJSIP_TRANSPORT_SECURE)) {
777 type = PJSIP_TRANSPORT_TLS;
779 }
else if (!sip_uri->transport_param.slen) {
780 type = PJSIP_TRANSPORT_UDP;
781 }
else if (
type == PJSIP_TRANSPORT_UNSPECIFIED) {
786 if (pj_strchr(&sip_uri->host,
':')) {
787 type |= PJSIP_TRANSPORT_IPV6;
792 from->ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
793 from->slen = pj_ansi_snprintf(from->ptr, PJSIP_MAX_URL_SIZE,
796 (
type != PJSIP_TRANSPORT_UDP &&
type != PJSIP_TRANSPORT_UDP6) ?
";transport=" :
"",
797 (
type != PJSIP_TRANSPORT_UDP &&
type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(
type) :
"");
802 from->ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
803 from->slen = pj_ansi_snprintf(from->ptr, PJSIP_MAX_URL_SIZE,
807 (
type != PJSIP_TRANSPORT_UDP &&
type != PJSIP_TRANSPORT_UDP6) ?
";transport=" :
"",
808 (
type != PJSIP_TRANSPORT_UDP &&
type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(
type) :
"");
814 &local_addr, &local_port) != PJ_SUCCESS) {
817 pj_strdup(pool, &local_addr, pj_gethostname());
818 local_port = pjsip_transport_get_default_port_for_type(PJSIP_TRANSPORT_UDP);
822 if (pj_strchr(&local_addr,
':')) {
823 type |= PJSIP_TRANSPORT_IPV6;
826 from->ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
827 from->slen = pj_ansi_snprintf(from->ptr, PJSIP_MAX_URL_SIZE,
828 "<sip:%s@%s%.*s%s:%d%s%s>",
830 (
type & PJSIP_TRANSPORT_IPV6) ?
"[" :
"",
831 (int)local_addr.slen,
833 (
type & PJSIP_TRANSPORT_IPV6) ?
"]" :
"",
835 (
type != PJSIP_TRANSPORT_UDP &&
type != PJSIP_TRANSPORT_UDP6) ?
";transport=" :
"",
836 (
type != PJSIP_TRANSPORT_UDP &&
type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(
type) :
"");
847 if (!transport_state) {
854 if (transport_state->
flow) {
859 selector->type = PJSIP_TPSELECTOR_TRANSPORT;
860 selector->u.transport = transport_state->
transport;
861 pjsip_transport_add_ref(selector->u.transport);
862 }
else if (transport_state->
factory) {
863 selector->type = PJSIP_TPSELECTOR_LISTENER;
864 selector->u.listener = transport_state->
factory;
872#ifdef HAVE_PJSIP_TRANSPORT_DISABLE_CONNECTION_REUSE
873 selector->disable_connection_reuse = PJ_TRUE;
875 ast_log(
LOG_WARNING,
"Connection reuse could not be disabled on transport '%s' as support is not available\n",
882 if (transport_state->
flow) {
910 pjsip_sip_uri *sip_uri, pjsip_tpselector *selector)
912 char transport_name[128];
923 if (selector->type == PJSIP_TPSELECTOR_TRANSPORT && selector->u.transport) {
924 pjsip_transport_dec_ref(selector->u.transport);
930 pjsip_sip_uri *sip_uri;
932 static const pj_str_t STR_PHONE = {
"phone", 5 };
934 if (!endpoint || !endpoint->
usereqphone || (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri))) {
938 sip_uri = pjsip_uri_get_uri(uri);
940 if (!pj_strlen(&sip_uri->user)) {
944 if (pj_strbuf(&sip_uri->user)[0] ==
'+') {
949 for (; i < pj_strlen(&sip_uri->user); i++) {
955 if (i < pj_strlen(&sip_uri->user)) {
959 sip_uri->user_param = STR_PHONE;
963 const char *uri,
const char *request_user)
965 char enclosed_uri[PJSIP_MAX_URL_SIZE];
966 pj_str_t local_uri = {
"sip:temp@temp", 13 }, remote_uri, target_uri;
968 pjsip_dialog *dlg =
NULL;
970 pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, };
971 static const pj_str_t HCONTACT = {
"Contact", 7 };
974 snprintf(enclosed_uri,
sizeof(enclosed_uri),
"<%s>", uri);
976 snprintf(enclosed_uri,
sizeof(enclosed_uri),
"%s", uri);
978 pj_cstr(&remote_uri, enclosed_uri);
980 pj_cstr(&target_uri, uri);
982 res = pjsip_dlg_create_uac(pjsip_ua_instance(), &local_uri,
NULL, &remote_uri, &target_uri, &dlg);
983 if (res == PJ_SUCCESS && !(PJSIP_URI_SCHEME_IS_SIP(dlg->target) || PJSIP_URI_SCHEME_IS_SIPS(dlg->target))) {
986 res = PJSIP_EINVALIDURI;
987 pjsip_dlg_terminate(dlg);
989 if (res != PJ_SUCCESS) {
990 if (res == PJSIP_EINVALIDURI) {
992 "Endpoint '%s': Could not create dialog to invalid URI '%s'. Is endpoint registered and reachable?\n",
1005 pjsip_dlg_terminate(dlg);
1013 pj_strdup_with_null(dlg->pool, &dlg->local.info_str, &local_uri);
1014 dlg->local.info->uri = pjsip_parse_uri(dlg->pool, dlg->local.info_str.ptr, dlg->local.info_str.slen, 0);
1015 if (!dlg->local.info->uri) {
1017 "Could not parse URI '%s' for endpoint '%s'\n",
1020 pjsip_dlg_terminate(dlg);
1024 dlg->local.contact = pjsip_parse_hdr(dlg->pool, &HCONTACT, local_uri.ptr, local_uri.slen,
NULL);
1027 pjsip_sip_uri *sip_uri;
1029 sip_uri = pjsip_uri_get_uri(dlg->local.contact->uri);
1030 pj_strdup2(dlg->pool, &sip_uri->user, endpoint->
contact_user);
1035 pjsip_sip_uri *sip_uri;
1037 if (PJSIP_URI_SCHEME_IS_SIP(dlg->target) || PJSIP_URI_SCHEME_IS_SIPS(dlg->target)) {
1038 sip_uri = pjsip_uri_get_uri(dlg->target);
1039 pj_strdup2(dlg->pool, &sip_uri->user, request_user);
1041 if (PJSIP_URI_SCHEME_IS_SIP(dlg->remote.info->uri) || PJSIP_URI_SCHEME_IS_SIPS(dlg->remote.info->uri)) {
1042 sip_uri = pjsip_uri_get_uri(dlg->remote.info->uri);
1043 pj_strdup2(dlg->pool, &sip_uri->user, request_user);
1053 pjsip_route_hdr route_set, *route;
1054 static const pj_str_t ROUTE_HNAME = {
"Route", 5 };
1057 pj_list_init(&route_set);
1059 pj_strdup2_with_null(dlg->pool, &tmp, outbound_proxy);
1060 if (!(route = pjsip_parse_hdr(dlg->pool, &ROUTE_HNAME, tmp.ptr, tmp.slen,
NULL))) {
1061 ast_log(
LOG_ERROR,
"Could not create dialog to endpoint '%s' as outbound proxy URI '%s' is not valid\n",
1064 pjsip_dlg_terminate(dlg);
1067 pj_list_insert_nodes_before(&route_set, route);
1069 pjsip_dlg_set_route_set(dlg, &route_set);
1089 pjsip_rr_hdr *record_route;
1091 if (PJSIP_URI_SCHEME_IS_SIPS(rdata->msg_info.msg->line.req.uri)) {
1095 record_route = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_RECORD_ROUTE,
NULL);
1097 if (PJSIP_URI_SCHEME_IS_SIPS(&record_route->name_addr)) {
1101 pjsip_contact_hdr *contact;
1103 contact = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT,
NULL);
1105 if (PJSIP_URI_SCHEME_IS_SIPS(contact->uri)) {
1114 const pj_str_t *contact, pjsip_dialog **p_dlg);
1121 pjsip_transport_type_e
type = rdata->tp_info.transport->key.type;
1122 pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, };
1124 pjsip_contact_hdr *contact_hdr;
1128 contact_hdr = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT,
NULL);
1135 if (selector.type == PJSIP_TPSELECTOR_TRANSPORT) {
1140 contact.ptr = pj_pool_alloc(rdata->tp_info.pool, PJSIP_MAX_URL_SIZE);
1141 contact.slen = pj_ansi_snprintf(contact.ptr, PJSIP_MAX_URL_SIZE,
1142 "<%s:%s%s%s%.*s%s:%d%s%s>",
1146 (
type & PJSIP_TRANSPORT_IPV6) ?
"[" :
"",
1149 (
type & PJSIP_TRANSPORT_IPV6) ?
"]" :
"",
1151 (
type != PJSIP_TRANSPORT_UDP &&
type != PJSIP_TRANSPORT_UDP6) ?
";transport=" :
"",
1152 (
type != PJSIP_TRANSPORT_UDP &&
type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(
type) :
"");
1154 *
status = create_fun(pjsip_ua_instance(), rdata, &contact, &dlg);
1155 if (*
status != PJ_SUCCESS) {
1156 char err[PJ_ERR_MSG_SIZE];
1158 pj_strerror(*
status, err,
sizeof(err));
1166 pjsip_dlg_set_transport(dlg, &selector);
1176#ifdef HAVE_PJSIP_DLG_CREATE_UAS_AND_INC_LOCK
1181 pjsip_dlg_dec_lock(dlg);
1191 pjsip_rx_data *rdata, pj_status_t *
status)
1193#ifdef HAVE_PJSIP_DLG_CREATE_UAS_AND_INC_LOCK
1205 pjsip_dlg_inc_lock(dlg);
1213 char *transport_type,
const char *local_name,
int local_port,
const char *contact)
1221 pj_list_init(&rdata->msg_info.parse_err);
1223 rdata->tp_info.transport = PJ_POOL_ZALLOC_T(rdata->tp_info.pool, pjsip_transport);
1224 if (!rdata->tp_info.transport) {
1228 ast_copy_string(rdata->pkt_info.packet, packet,
sizeof(rdata->pkt_info.packet));
1229 ast_copy_string(rdata->pkt_info.src_name, src_name,
sizeof(rdata->pkt_info.src_name));
1230 rdata->pkt_info.src_port = src_port;
1231 pj_sockaddr_parse(pj_AF_UNSPEC(), 0, pj_cstr(&tmp, src_name), &rdata->pkt_info.src_addr);
1232 pj_sockaddr_set_port(&rdata->pkt_info.src_addr, src_port);
1234 pjsip_parse_rdata(packet, strlen(packet), rdata);
1235 if (!rdata->msg_info.msg || !pj_list_empty(&rdata->msg_info.parse_err)) {
1240 pjsip_contact_hdr *contact_hdr;
1242 contact_hdr = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT,
NULL);
1244 contact_hdr->uri = pjsip_parse_uri(rdata->tp_info.pool, (
char *)contact,
1245 strlen(contact), PJSIP_PARSE_URI_AS_NAMEADDR);
1246 if (!contact_hdr->uri) {
1253 pj_strdup2(rdata->tp_info.pool, &rdata->msg_info.via->recvd_param, rdata->pkt_info.src_name);
1254 rdata->msg_info.via->rport_param = -1;
1256 rdata->tp_info.transport->key.type = pjsip_transport_get_type_from_name(pj_cstr(&tmp, transport_type));
1257 rdata->tp_info.transport->type_name = transport_type;
1258 pj_strdup2(rdata->tp_info.pool, &rdata->tp_info.transport->local_name.host, local_name);
1259 rdata->tp_info.transport->local_name.port = local_port;
1265 char *transport_type,
const char *local_name,
int local_port)
1268 local_name, local_port,
NULL);
1272static const pjsip_method
info_method = {PJSIP_OTHER_METHOD, {
"INFO", 4} };
1274static const pjsip_method
refer_method = {PJSIP_OTHER_METHOD, {
"REFER", 5} };
1280 {
"INVITE", &pjsip_invite_method },
1281 {
"CANCEL", &pjsip_cancel_method },
1282 {
"ACK", &pjsip_ack_method },
1283 {
"BYE", &pjsip_bye_method },
1284 {
"REGISTER", &pjsip_register_method },
1285 {
"OPTIONS", &pjsip_options_method },
1286 {
"SUBSCRIBE", &pjsip_subscribe_method },
1287 {
"NOTIFY", &pjsip_notify_method },
1307 if (pjsip_dlg_create_request(dlg,
method, -1, tdata) != PJ_SUCCESS) {
1317 .name = {
"Out of dialog supplement hook", 29 },
1319 .priority = PJSIP_MOD_PRIORITY_APPLICATION - 1,
1324 const char *uri,
struct ast_sip_contact *provided_contact, pjsip_tx_data **tdata)
1327 pj_str_t remote_uri;
1330 pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, };
1332 const char *fromuser;
1349 pj_cstr(&remote_uri, contact->uri);
1351 pj_cstr(&remote_uri, uri);
1361 sip_uri = pjsip_parse_uri(pool, remote_uri.ptr, remote_uri.slen, 0);
1362 if (!sip_uri || (!PJSIP_URI_SCHEME_IS_SIP(sip_uri) && !PJSIP_URI_SCHEME_IS_SIPS(sip_uri))) {
1363 ast_log(
LOG_ERROR,
"Unable to create outbound %.*s request to endpoint %s as URI '%s' is not valid\n",
1364 (
int) pj_strlen(&
method->name), pj_strbuf(&
method->name),
1366 pj_strbuf(&remote_uri));
1375 endpoint ? endpoint->
fromdomain :
NULL, &remote_uri, &selector)) {
1376 ast_log(
LOG_ERROR,
"Unable to create From header for %.*s request to endpoint %s\n",
1377 (
int) pj_strlen(&
method->name), pj_strbuf(&
method->name),
1385 &from, &remote_uri, &from,
NULL, -1,
NULL, tdata) != PJ_SUCCESS) {
1386 ast_log(
LOG_ERROR,
"Unable to create outbound %.*s request to endpoint %s\n",
1387 (
int) pj_strlen(&
method->name), pj_strbuf(&
method->name),
1394 pjsip_tx_data_set_transport(*tdata, &selector);
1399 pjsip_contact_hdr *contact_hdr;
1400 pjsip_sip_uri *contact_uri;
1401 static const pj_str_t HCONTACT = {
"Contact", 7 };
1402 static const pj_str_t HCONTACTSHORT = {
"m", 1 };
1404 contact_hdr = pjsip_msg_find_hdr_by_names((*tdata)->msg, &HCONTACT, &HCONTACTSHORT,
NULL);
1406 contact_uri = pjsip_uri_get_uri(contact_hdr->uri);
1407 pj_strdup2((*tdata)->pool, &contact_uri->user, endpoint->
contact_user);
1417 ast_log(
LOG_ERROR,
"Unable to apply outbound proxy on request %.*s to endpoint %s as outbound proxy URI '%s' is not valid\n",
1480 if (supplement == iter) {
1490 if (pjsip_dlg_send_request(dlg, tdata, -1,
NULL) != PJ_SUCCESS) {
1505 pj_cstr(&
method, supplement_method);
1510#define TIMER_INACTIVE 0
1511#define TIMEOUT_TIMER2 5
1582 if (e->body.tsx_state.type == PJSIP_EVENT_TIMER) {
1583 ast_debug(2,
"%p: PJSIP tsx timer expired\n", req_wrapper);
1587 ast_debug(3,
"%p: Timeout already handled\n", req_wrapper);
1592 ast_debug(2,
"%p: PJSIP tsx response received\n", req_wrapper);
1603 int timers_cancelled = 0;
1605 ast_debug(3,
"%p: Cancelling timer\n", req_wrapper);
1607 timers_cancelled = pj_timer_heap_cancel_if_active(
1610 if (timers_cancelled > 0) {
1614 ast_debug(3,
"%p: Timer cancelled\n", req_wrapper);
1622 ast_debug(3,
"%p: Timer already expired\n", req_wrapper);
1635 ast_debug(2,
"%p: Callbacks executed\n", req_wrapper);
1651 ast_debug(2,
"%p: Internal tsx timer expired after %d msec\n",
1652 req_wrapper, req_wrapper->
timeout);
1661 ast_debug(3,
"%p: Timeout already handled\n", req_wrapper);
1667 ast_debug(3,
"%p: Timer handled here\n", req_wrapper);
1676 PJSIP_EVENT_INIT_TX_MSG(
event, req_wrapper->
tdata);
1677 event.body.tsx_state.type = PJSIP_EVENT_TIMER;
1680 ast_debug(2,
"%p: Callbacks executed\n", req_wrapper);
1690 pjsip_tx_data_dec_ref(req_wrapper->
tdata);
1691 ast_debug(2,
"%p: wrapper destroyed\n", req_wrapper);
1695 pjsip_tx_data *
tdata, pj_int32_t
timeout,
void *
token, pjsip_endpt_send_callback cb)
1698 pj_status_t ret_val;
1703 pjsip_tx_data_dec_ref(
tdata);
1710 pjsip_tx_data_dec_ref(
tdata);
1714 ast_debug(2,
"%p: Wrapper created\n", req_wrapper);
1722 pjsip_tx_data_add_ref(
tdata);
1725 pj_time_val timeout_timer_val = {
timeout / 1000,
timeout % 1000 };
1738 ret_val = pj_timer_heap_schedule(pjsip_endpt_get_timer_heap(endpt),
1740 if (ret_val != PJ_SUCCESS) {
1742 "Failed to set timer. Not sending %.*s request to endpoint %s.\n",
1743 (
int) pj_strlen(&
tdata->msg->line.req.method.name),
1744 pj_strbuf(&
tdata->msg->line.req.method.name),
1746 ao2_t_ref(req_wrapper, -2,
"Drop timer and routine ref");
1747 pjsip_tx_data_dec_ref(
tdata);
1757 if (ret_val != PJ_SUCCESS) {
1758 char errmsg[PJ_ERR_MSG_SIZE];
1766 pj_strerror(ret_val, errmsg,
sizeof(errmsg));
1768 (
int) ret_val, errmsg, (
int) pj_strlen(&
tdata->msg->line.req.method.name),
1769 pj_strbuf(&
tdata->msg->line.req.method.name),
1773 int timers_cancelled;
1776 timers_cancelled = pj_timer_heap_cancel_if_active(
1777 pjsip_endpt_get_timer_heap(endpt),
1779 if (timers_cancelled > 0) {
1790 ret_val = PJ_SUCCESS;
1806 ret_val = PJ_SUCCESS;
1819 || (
tdata->dest_info.cur_addr ==
tdata->dest_info.addr.count - 1)) {
1825 ++
tdata->dest_info.cur_addr;
1827 via = (pjsip_via_hdr*)pjsip_msg_find_hdr(
tdata->msg, PJSIP_H_VIA,
NULL);
1828 via->branch_param.slen = 0;
1830 pjsip_tx_data_invalidate_msg(
tdata);
1840 pjsip_transaction *tsx;
1841 pjsip_tx_data *tdata;
1848 tsx = e->body.tsx_state.tsx;
1850 switch (tsx->status_code) {
1856 e->body.tsx_state.src.rdata, tsx->last_tx, &tdata);
1861 tdata = tsx->last_tx;
1866 pjsip_tx_data_add_ref(tdata);
1886 if (e->type == PJSIP_EVENT_TSX_STATE) {
1887 switch(e->body.tsx_state.type) {
1888 case PJSIP_EVENT_TRANSPORT_ERROR:
1889 case PJSIP_EVENT_TIMER:
1899 case PJSIP_EVENT_RX_MSG:
1900 challenge = e->body.tsx_state.src.rdata;
1938 void (*
callback)(
void *token, pjsip_event *e))
1946 pjsip_tx_data_dec_ref(tdata);
1979 void (*
callback)(
void *token, pjsip_event *e))
1981 ast_assert(tdata->msg->type == PJSIP_REQUEST_MSG);
1992 pjsip_route_hdr *route;
1993 static const pj_str_t ROUTE_HNAME = {
"Route", 5 };
1996 pj_strdup2_with_null(tdata->pool, &tmp, proxy);
1997 if (!(route = pjsip_parse_hdr(tdata->pool, &ROUTE_HNAME, tmp.ptr, tmp.slen,
NULL))) {
2001 pj_list_insert_nodes_before(&tdata->msg->hdr, (pjsip_hdr*)route);
2010 pjsip_generic_string_hdr *hdr;
2012 pj_cstr(&hdr_name,
name);
2013 pj_cstr(&hdr_value,
value);
2015 hdr = pjsip_generic_string_hdr_create(tdata->pool, &hdr_name, &hdr_value);
2017 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *) hdr);
2026 pjsip_generic_string_hdr *hdr;
2028 pj_cstr(&hdr_name,
name);
2029 pj_cstr(&hdr_value,
value);
2031 hdr = pjsip_generic_string_hdr_create(tdata->pool, &hdr_name, &hdr_value);
2033 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *) hdr);
2044 pj_cstr(&subtype, body->
subtype);
2047 return pjsip_msg_body_create(pool, &
type, &subtype, &body_text);
2053 tdata->msg->body = pjsip_body;
2061 pjsip_msg_body *body = pjsip_multipart_create(tdata->pool,
NULL,
NULL);
2063 for (i = 0; i < num_bodies; ++i) {
2064 pjsip_multipart_part *part = pjsip_multipart_create_part(tdata->pool);
2066 pjsip_multipart_add_part(tdata->pool, body, part);
2069 tdata->msg->body = body;
2075 size_t combined_size = strlen(body_text) + tdata->msg->body->len;
2078 ast_str_set(&body_buffer, 0,
"%.*s%s", (
int) tdata->msg->body->len, (
char *) tdata->msg->body->data, body_text);
2080 tdata->msg->body->data = pj_pool_alloc(tdata->pool, combined_size);
2081 pj_memcpy(tdata->msg->body->data,
ast_str_buffer(body_buffer), combined_size);
2082 tdata->msg->body->len = combined_size;
2097#undef ast_sip_push_task
2101 const char *file,
int line,
const char *function)
2117#undef ast_sip_push_task_wait_servant
2125#undef ast_sip_push_task_synchronous
2133#undef ast_sip_push_task_wait_serializer
2142 const char *file,
int line,
const char *function)
2151 const char *file,
int line,
const char *function)
2161 const char *file,
int line,
const char *function)
2167 const char *file,
int line,
const char *function)
2178 size_t chars_to_copy =
MIN(size - 1, pj_strlen(src));
2179 memcpy(dest, pj_strbuf(src), chars_to_copy);
2180 dest[chars_to_copy] =
'\0';
2185 int res =
ast_asprintf(dest,
"%.*s", (
int)pj_strlen(src), pj_strbuf(src));
2198 rc = pjsip_media_type_cmp(
a,
b, 0) ? 0 : 1;
2206 pjsip_media_type *
b =
NULL;
2212 while ((
b = va_arg(ap, pjsip_media_type *)) != (pjsip_media_type *)
SENTINEL) {
2213 if (pjsip_media_type_cmp(
a,
b, 0) == 0) {
2227 if (!content_type) {
2233 return pjsip_media_type_cmp(content_type, &
compare, 0) ? 0 : -1;
2244 const pj_time_val delay = {0, 10};
2258#define SIP_SERVANT_ID 0x5E2F1D
2262 pj_thread_desc *
desc;
2264 uint32_t *servant_id;
2268 ast_log(
LOG_ERROR,
"Could not set SIP servant ID in thread-local storage.\n");
2275 ast_log(
LOG_ERROR,
"Could not get thread desc from thread-local storage. Expect awful things to occur\n");
2280 if (pj_thread_register(
"Asterisk Thread", *
desc, &
thread) != PJ_SUCCESS) {
2287 uint32_t *servant_id;
2290 pthread_self() == *(pthread_t *)pj_thread_get_os_handle(
monitor_thread)) {
2304 unsigned int hval = 0;
2310 return pj_hash_get(ht, key, PJ_HASH_KEY_STRING, &hval);
2314 const char *key,
void *
val)
2317 ht = pj_hash_create(pool, 11);
2320 pj_hash_set(pool, ht, key, PJ_HASH_KEY_STRING, 0,
val);
2329 if (pjsip_rdata_get_dlg(rdata)) {
2352 pjsip_cseq_hdr *cseq = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CSEQ,
NULL);
2377 if (
status != PJ_SUCCESS) {
2378 pjsip_tx_data_dec_ref(tdata);
2381 return status == PJ_SUCCESS ? 0 : -1;
2386 pj_pool_t *pool = (pj_pool_t *)arg;
2396 pjsip_tx_data_dec_ref(tdata);
2401 pjsip_transaction *tsx;
2402 pj_grp_lock_t *tsx_glock;
2422 pj_grp_lock_add_ref(tsx_glock);
2424 if (pjsip_tsx_create_uas2(
NULL, rdata, tsx_glock, &tsx) != PJ_SUCCESS) {
2426 pj_grp_lock_dec_ref(tsx_glock);
2430 pjsip_tsx_recv_msg(tsx, rdata);
2433 if (pjsip_tsx_send_msg(tsx, tdata) != PJ_SUCCESS) {
2434 pj_grp_lock_dec_ref(tsx_glock);
2435 pjsip_tx_data_dec_ref(tdata);
2439 pj_grp_lock_dec_ref(tsx_glock);
2470 if (af == pj_AF_INET()) {
2472 }
else if (af == pj_AF_INET6()) {
2480 char *
buf,
size_t buf_len)
2512 if (!strcasecmp(dtmf_mode,
"info")) {
2514 }
else if (!strcasecmp(dtmf_mode,
"rfc4733")) {
2516 }
else if (!strcasecmp(dtmf_mode,
"inband")) {
2518 }
else if (!strcasecmp(dtmf_mode,
"none")) {
2520 }
else if (!strcasecmp(dtmf_mode,
"auto")) {
2522 }
else if (!strcasecmp(dtmf_mode,
"auto_info")) {
2536 value =
"local_merge";
2538 value =
"local_first";
2542 value =
"remote_merge";
2544 value =
"remote_first";
2556 if (strcmp(pref_str,
"local") == 0) {
2558 }
else if (is_outgoing && strcmp(pref_str,
"local_merge") == 0) {
2560 }
else if (strcmp(pref_str,
"local_first") == 0) {
2562 }
else if (strcmp(pref_str,
"remote") == 0) {
2564 }
else if (is_outgoing && strcmp(pref_str,
"remote_merge") == 0) {
2566 }
else if (strcmp(pref_str,
"remote_first") == 0) {
2586 pjsip_name_addr *id_name_addr = (pjsip_name_addr *) hdr->uri;
2592 semi = strchr(cid_num,
';');
2614 id_name_addr->display.ptr, id_name_addr->display.slen);
2618 "' for number '%s' has invalid UTF-8 characters which "
2631 id->number.valid = 1;
2648static pjsip_fromto_hdr *
get_id_header(pjsip_rx_data *rdata,
const pj_str_t *header_name)
2650 static const pj_str_t from = {
"From", 4 };
2651 pj_str_t header_content;
2652 pjsip_fromto_hdr *parsed_hdr;
2653 pjsip_generic_string_hdr *ident = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg,
2661 pj_strdup_with_null(rdata->tp_info.pool, &header_content, &ident->hvalue);
2663 parsed_hdr = pjsip_parse_hdr(rdata->tp_info.pool, &from, header_content.ptr,
2664 pj_strlen(&header_content), &parsed_len);
2687 static const pj_str_t pai_str = {
"P-Asserted-Identity", 19 };
2688 static const pj_str_t privacy_str = {
"Privacy", 7 };
2690 pjsip_generic_string_hdr *privacy;
2698 if (!
id->number.valid) {
2702 privacy = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &privacy_str,
NULL);
2703 if (!privacy || !pj_stricmp2(&privacy->hvalue,
"none")) {
2728 static const pj_str_t rpid_str = {
"Remote-Party-ID", 15 };
2729 static const pj_str_t privacy_str = {
"privacy", 7 };
2730 static const pj_str_t screen_str = {
"screen", 6 };
2731 pjsip_fromto_hdr *rpid_hdr =
get_id_header(rdata, &rpid_str);
2732 pjsip_param *screen;
2733 pjsip_param *privacy;
2741 if (!
id->number.valid) {
2745 privacy = pjsip_param_find(&rpid_hdr->other_param, &privacy_str);
2746 screen = pjsip_param_find(&rpid_hdr->other_param, &screen_str);
2747 if (privacy && !pj_stricmp2(&privacy->value,
"full")) {
2754 if (screen && !pj_stricmp2(&screen->value,
"yes")) {
2780 pjsip_fromto_hdr *from = pjsip_msg_find_hdr(rdata->msg_info.msg,
2781 PJSIP_H_FROM, rdata->msg_info.msg->hdr.next);
2790 if (!
id->number.valid) {
2827 pjsip_name_addr *id_name_addr;
2828 pjsip_sip_uri *id_uri;
2830 id_name_addr = (pjsip_name_addr *) id_hdr->uri;
2831 id_uri = pjsip_uri_get_uri(id_name_addr->uri);
2833 if (
id->name.valid) {
2835 int name_buf_len = strlen(
id->name.str) * 2 + 1;
2839 pj_strdup2(pool, &id_name_addr->display, name_buf);
2841 pj_strdup2(pool, &id_name_addr->display,
NULL);
2845 if (
id->number.valid) {
2846 pj_strdup2(pool, &id_uri->user,
id->number.str);
2870 pjsip_name_addr *name_addr;
2871 pjsip_sip_uri *sip_uri;
2887 name_addr = (pjsip_name_addr *) pjsip_parse_uri(pool, (
char*)contact->uri, strlen(contact->uri), PJSIP_PARSE_URI_AS_NAMEADDR);
2888 if (!name_addr || (!PJSIP_URI_SCHEME_IS_SIP(name_addr->uri) && !PJSIP_URI_SCHEME_IS_SIPS(name_addr->uri))) {
2896 sip_uri = pjsip_uri_get_uri(name_addr->uri);
2897 pj_strset2(&sip_uri->user, (
char*)
user);
2904 pjsip_uri_print(PJSIP_URI_IN_REQ_URI, name_addr, *
uri, PJSIP_MAX_URL_SIZE);
2932 char *endpoint_name =
NULL;
2945 char *temp_uri =
ast_malloc(strlen(destination) + strlen(
"sip:") + 1);
2949 sprintf(temp_uri,
"sip:%s", destination);
2951 if (get_default_outbound) {
2954 ast_debug(3,
"Dest: '%s' Didn't find endpoint so adding scheme and using URI '%s'%s\n",
2955 to, *uri, get_default_outbound ?
" with default endpoint" :
"");
2963 endpoint_name = destination;
2966 ast_log(
LOG_WARNING,
"Dest: '%s'. Found endpoint '%s' but didn't find an aor/contact for it\n",
2978 ast_debug(3,
"Dest: '%s' Found endpoint '%s' and found contact with URI '%s'\n",
2979 to, endpoint_name, *uri);
3010 char *slash,
char *atsign,
char *scheme)
3012 char *endpoint_name =
NULL;
3016 char *afterslash = slash + 1;
3020 ast_debug(3,
"Dest: '%s' Dialplan format'\n", to);
3024 if (!atsign || strchr(afterslash,
'/')) {
3030 "Dest: '%s'. Destinations beginning with 'PJSIP/' must be in the form of 'PJSIP/user@endpoint'\n",
3036 endpoint_name = atsign + 1;
3037 ast_debug(3,
"Dest: '%s' User: '%s' Endpoint: '%s'\n", to,
user, endpoint_name);
3045 endpoint_name = destination;
3046 ast_debug(3,
"Dest: '%s' Endpoint: '%s'\n", to, endpoint_name);
3065 ast_debug(3,
"Dest: '%s' Found endpoint '%s' and found URI '%s' after '/'\n",
3066 to, endpoint_name, *uri);
3087 ast_debug(3,
"Dest: '%s' User: '%s' Endpoint: '%s' URI: '%s'\n", to,
user,
3088 endpoint_name, *uri);
3104 *uri =
ast_malloc(strlen(afterslash) + strlen(
"sip:") + 1);
3108 sprintf(*uri,
"sip:%s", afterslash);
3109 ast_debug(3,
"Dest: '%s' Found endpoint '%s' but didn't find aor after '/' so using URI '%s'\n",
3110 to, endpoint_name, *uri);
3117 ast_debug(3,
"Dest: '%s' Found endpoint '%s' and found aor '%s' after '/'\n",
3122 ast_log(
LOG_WARNING,
"Dest: '%s'. Found endpoint '%s' but didn't find contact for aor '%s'\n",
3135 ast_debug(3,
"Dest: '%s' Found endpoint '%s' and found contact with URI '%s' for aor '%s'\n",
3167 char *slash,
char *atsign,
char *scheme,
int get_default_outbound)
3169 char *endpoint_name =
NULL;
3172 char *afterat = atsign + 1;
3189 sprintf(*
uri,
"sip:%s", to);
3190 if (get_default_outbound) {
3193 ast_debug(3,
"Dest: '%s' Didn't find endpoint before the '@' so using URI '%s'%s\n",
3194 to, *
uri, get_default_outbound ?
" with default endpoint" :
"");
3213 ast_debug(3,
"Dest: '%s' Found endpoint '%s' and found contact with URI '%s' (discarding domain %s)\n",
3228 char *atsign =
NULL;
3229 char *scheme =
NULL;
3234 slash = strchr(destination,
'/');
3235 atsign = strchr(destination,
'@');
3236 scheme =
S_OR(strstr(destination,
"sip:"), strstr(destination,
"sips:"));
3238 if (!slash && !atsign && !scheme) {
3254 return handle_slash(to, destination, uri, slash, atsign, scheme);
3257 if (atsign && !scheme) {
3264 return handle_atsign(to, destination, uri, slash, atsign, scheme, get_default_outbound);
3275 ast_debug(3,
"Dest: '%s' Didn't find an endpoint but did find a scheme so using URI '%s'%s\n",
3276 to, *uri, get_default_outbound ?
" with default endpoint" :
"");
3278 *uri =
ast_malloc(strlen(destination) + strlen(
"sip:") + 1);
3282 sprintf(*uri,
"sip:%s", destination);
3283 ast_debug(3,
"Dest: '%s' Didn't find an endpoint and didn't find scheme so adding scheme and using URI '%s'%s\n",
3284 to, *uri, get_default_outbound ?
" with default endpoint" :
"");
3286 if (get_default_outbound) {
3300 pjsip_name_addr *parsed_name_addr;
3301 pjsip_sip_uri *sip_uri;
3302 pjsip_name_addr *tdata_name_addr;
3303 pjsip_sip_uri *tdata_sip_uri;
3304 pjsip_to_hdr *to_hdr;
3306#define DEBUG_BUF_SIZE 256
3308 parsed_name_addr = (pjsip_name_addr *) pjsip_parse_uri(tdata->pool, (
char*)to, strlen(to),
3309 PJSIP_PARSE_URI_AS_NAMEADDR);
3311 if (!parsed_name_addr || (!PJSIP_URI_SCHEME_IS_SIP(parsed_name_addr->uri)
3312 && !PJSIP_URI_SCHEME_IS_SIPS(parsed_name_addr->uri))) {
3317 sip_uri = pjsip_uri_get_uri(parsed_name_addr->uri);
3321 ast_debug(3,
"Parsed To: %.*s %s\n", (
int)parsed_name_addr->display.slen,
3322 parsed_name_addr->display.ptr,
buf);
3325 to_hdr = PJSIP_MSG_TO_HDR(tdata->msg);
3326 tdata_name_addr = to_hdr ? (pjsip_name_addr *) to_hdr->uri :
NULL;
3327 if (!tdata_name_addr || (!PJSIP_URI_SCHEME_IS_SIP(tdata_name_addr->uri)
3328 && !PJSIP_URI_SCHEME_IS_SIPS(tdata_name_addr->uri))) {
3334 tdata_sip_uri = pjsip_uri_get_uri(tdata_name_addr->uri);
3338 ast_debug(3,
"Original tdata To: %.*s %s\n", (
int)tdata_name_addr->display.slen,
3339 tdata_name_addr->display.ptr,
buf);
3343 pjsip_sip_uri_assign(tdata->pool, tdata_sip_uri, sip_uri);
3345 pj_strdup(tdata->pool, &tdata_name_addr->display, &parsed_name_addr->display);
3349 pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, tdata_sip_uri,
buf, 256);
3350 ast_debug(3,
"New tdata To: %.*s %s\n", (
int)tdata_name_addr->display.slen,
3351 tdata_name_addr->display.ptr,
buf);
3355#undef DEBUG_BUF_SIZE
3360 pjsip_name_addr *name_addr;
3362 pjsip_name_addr *parsed_name_addr;
3363 pjsip_from_hdr *from_hdr;
3369 from_hdr = PJSIP_MSG_FROM_HDR(tdata->msg);
3373 name_addr = (pjsip_name_addr *) from_hdr->uri;
3374 uri = pjsip_uri_get_uri(name_addr);
3376 parsed_name_addr = (pjsip_name_addr *) pjsip_parse_uri(tdata->pool, from,
3377 strlen(from), PJSIP_PARSE_URI_AS_NAMEADDR);
3378 if (parsed_name_addr) {
3379 pjsip_sip_uri *parsed_uri;
3381 if (!PJSIP_URI_SCHEME_IS_SIP(parsed_name_addr->uri)
3382 && !PJSIP_URI_SCHEME_IS_SIPS(parsed_name_addr->uri)) {
3387 parsed_uri = pjsip_uri_get_uri(parsed_name_addr->uri);
3389 if (pj_strlen(&parsed_name_addr->display)) {
3390 pj_strdup(tdata->pool, &name_addr->display, &parsed_name_addr->display);
3394 pj_strdup(tdata->pool, &uri->user, &parsed_uri->user);
3395 pj_strdup(tdata->pool, &uri->host, &parsed_uri->host);
3396 uri->port = parsed_uri->port;
3401 char *domain = strchr(from,
'@');
3406 pj_strset3(&pj_from, from, domain);
3407 pj_strdup(tdata->pool, &uri->user, &pj_from);
3409 pj_strdup2(tdata->pool, &uri->host, domain + 1);
3411 pj_strdup2(tdata->pool, &uri->user, from);
3422 const pjsip_hdr *
request_headers = pjsip_endpt_get_request_headers(endpt);
3426 pjsip_hdr *to_erase = iter;
3428 pj_list_erase(to_erase);
3444 return (PJSIP_URI_SCHEME_IS_SIP(uri) || PJSIP_URI_SCHEME_IS_SIPS(uri));
3455 pjsip_sip_uri *sip_uri = pjsip_uri_get_uri(uri);
3459 return &sip_uri->user;
3460 }
else if (PJSIP_URI_SCHEME_IS_TEL(uri)) {
3461 pjsip_tel_uri *tel_uri = pjsip_uri_get_uri(uri);
3465 return &tel_uri->number;
3474 pjsip_sip_uri *sip_uri = pjsip_uri_get_uri(uri);
3478 return &sip_uri->host;
3479 }
else if (PJSIP_URI_SCHEME_IS_TEL(uri)) {
3489 pjsip_sip_uri *sip_uri = pjsip_uri_get_uri(uri);
3493 return pjsip_param_find(&sip_uri->other_param, param_str);
3494 }
else if (PJSIP_URI_SCHEME_IS_TEL(uri)) {
3495 pjsip_tel_uri *tel_uri = pjsip_uri_get_uri(uri);
3499 return pjsip_param_find(&tel_uri->other_param, param_str);
3507 float ret = strtof(q_value, &
end);
3509 if (
end == q_value) {
3515 if (!isfinite(ret)) {
3518 if (ret > 1.0f || ret < 0.0f) {
3600 if (cause < 500 && cause >= 400) {
3603 }
else if (cause < 600 && cause >= 500) {
3606 }
else if (cause < 700 && cause >= 600) {
3630 { PJSIP_SC_NULL,
"PJSIP_SC_NULL",
"NULL" },
3631 { PJSIP_SC_TRYING,
"PJSIP_SC_TRYING",
"TRYING" },
3632 { PJSIP_SC_RINGING,
"PJSIP_SC_RINGING",
"RINGING" },
3633 { PJSIP_SC_CALL_BEING_FORWARDED,
"PJSIP_SC_CALL_BEING_FORWARDED",
"CALL_BEING_FORWARDED" },
3634 { PJSIP_SC_QUEUED,
"PJSIP_SC_QUEUED",
"QUEUED" },
3635 { PJSIP_SC_PROGRESS,
"PJSIP_SC_PROGRESS",
"PROGRESS" },
3636 { PJSIP_SC_EARLY_DIALOG_TERMINATED,
"PJSIP_SC_EARLY_DIALOG_TERMINATED",
"EARLY_DIALOG_TERMINATED" },
3637 { PJSIP_SC_OK,
"PJSIP_SC_OK",
"OK" },
3638 { PJSIP_SC_ACCEPTED,
"PJSIP_SC_ACCEPTED",
"ACCEPTED" },
3639 { PJSIP_SC_NO_NOTIFICATION,
"PJSIP_SC_NO_NOTIFICATION",
"NO_NOTIFICATION" },
3640 { PJSIP_SC_MULTIPLE_CHOICES,
"PJSIP_SC_MULTIPLE_CHOICES",
"MULTIPLE_CHOICES" },
3641 { PJSIP_SC_MOVED_PERMANENTLY,
"PJSIP_SC_MOVED_PERMANENTLY",
"MOVED_PERMANENTLY" },
3642 { PJSIP_SC_MOVED_TEMPORARILY,
"PJSIP_SC_MOVED_TEMPORARILY",
"MOVED_TEMPORARILY" },
3643 { PJSIP_SC_USE_PROXY,
"PJSIP_SC_USE_PROXY",
"USE_PROXY" },
3644 { PJSIP_SC_ALTERNATIVE_SERVICE,
"PJSIP_SC_ALTERNATIVE_SERVICE",
"ALTERNATIVE_SERVICE" },
3645 { PJSIP_SC_BAD_REQUEST,
"PJSIP_SC_BAD_REQUEST",
"BAD_REQUEST" },
3646 { PJSIP_SC_UNAUTHORIZED,
"PJSIP_SC_UNAUTHORIZED",
"UNAUTHORIZED" },
3647 { PJSIP_SC_PAYMENT_REQUIRED,
"PJSIP_SC_PAYMENT_REQUIRED",
"PAYMENT_REQUIRED" },
3648 { PJSIP_SC_FORBIDDEN,
"PJSIP_SC_FORBIDDEN",
"FORBIDDEN" },
3649 { PJSIP_SC_NOT_FOUND,
"PJSIP_SC_NOT_FOUND",
"NOT_FOUND" },
3650 { PJSIP_SC_METHOD_NOT_ALLOWED,
"PJSIP_SC_METHOD_NOT_ALLOWED",
"METHOD_NOT_ALLOWED" },
3651 { PJSIP_SC_NOT_ACCEPTABLE,
"PJSIP_SC_NOT_ACCEPTABLE",
"NOT_ACCEPTABLE" },
3652 { PJSIP_SC_PROXY_AUTHENTICATION_REQUIRED,
"PJSIP_SC_PROXY_AUTHENTICATION_REQUIRED",
"PROXY_AUTHENTICATION_REQUIRED" },
3653 { PJSIP_SC_REQUEST_TIMEOUT,
"PJSIP_SC_REQUEST_TIMEOUT",
"REQUEST_TIMEOUT" },
3654 { PJSIP_SC_CONFLICT,
"PJSIP_SC_CONFLICT",
"CONFLICT" },
3655 { PJSIP_SC_GONE,
"PJSIP_SC_GONE",
"GONE" },
3656 { PJSIP_SC_LENGTH_REQUIRED,
"PJSIP_SC_LENGTH_REQUIRED",
"LENGTH_REQUIRED" },
3657 { PJSIP_SC_CONDITIONAL_REQUEST_FAILED,
"PJSIP_SC_CONDITIONAL_REQUEST_FAILED",
"CONDITIONAL_REQUEST_FAILED" },
3658 { PJSIP_SC_REQUEST_ENTITY_TOO_LARGE,
"PJSIP_SC_REQUEST_ENTITY_TOO_LARGE",
"REQUEST_ENTITY_TOO_LARGE" },
3659 { PJSIP_SC_REQUEST_URI_TOO_LONG,
"PJSIP_SC_REQUEST_URI_TOO_LONG",
"REQUEST_URI_TOO_LONG" },
3660 { PJSIP_SC_UNSUPPORTED_MEDIA_TYPE,
"PJSIP_SC_UNSUPPORTED_MEDIA_TYPE",
"UNSUPPORTED_MEDIA_TYPE" },
3661 { PJSIP_SC_UNSUPPORTED_URI_SCHEME,
"PJSIP_SC_UNSUPPORTED_URI_SCHEME",
"UNSUPPORTED_URI_SCHEME" },
3662 { PJSIP_SC_UNKNOWN_RESOURCE_PRIORITY,
"PJSIP_SC_UNKNOWN_RESOURCE_PRIORITY",
"UNKNOWN_RESOURCE_PRIORITY" },
3663 { PJSIP_SC_BAD_EXTENSION,
"PJSIP_SC_BAD_EXTENSION",
"BAD_EXTENSION" },
3664 { PJSIP_SC_EXTENSION_REQUIRED,
"PJSIP_SC_EXTENSION_REQUIRED",
"EXTENSION_REQUIRED" },
3665 { PJSIP_SC_SESSION_TIMER_TOO_SMALL,
"PJSIP_SC_SESSION_TIMER_TOO_SMALL",
"SESSION_TIMER_TOO_SMALL" },
3666 { PJSIP_SC_INTERVAL_TOO_BRIEF,
"PJSIP_SC_INTERVAL_TOO_BRIEF",
"INTERVAL_TOO_BRIEF" },
3667 { PJSIP_SC_BAD_LOCATION_INFORMATION,
"PJSIP_SC_BAD_LOCATION_INFORMATION",
"BAD_LOCATION_INFORMATION" },
3668 { PJSIP_SC_USE_IDENTITY_HEADER,
"PJSIP_SC_USE_IDENTITY_HEADER",
"USE_IDENTITY_HEADER" },
3669 { PJSIP_SC_PROVIDE_REFERRER_HEADER,
"PJSIP_SC_PROVIDE_REFERRER_HEADER",
"PROVIDE_REFERRER_HEADER" },
3670 { PJSIP_SC_FLOW_FAILED,
"PJSIP_SC_FLOW_FAILED",
"FLOW_FAILED" },
3671 { PJSIP_SC_ANONIMITY_DISALLOWED,
"PJSIP_SC_ANONIMITY_DISALLOWED",
"ANONIMITY_DISALLOWED" },
3672 { PJSIP_SC_BAD_IDENTITY_INFO,
"PJSIP_SC_BAD_IDENTITY_INFO",
"BAD_IDENTITY_INFO" },
3673 { PJSIP_SC_UNSUPPORTED_CERTIFICATE,
"PJSIP_SC_UNSUPPORTED_CERTIFICATE",
"UNSUPPORTED_CERTIFICATE" },
3674 { PJSIP_SC_INVALID_IDENTITY_HEADER,
"PJSIP_SC_INVALID_IDENTITY_HEADER",
"INVALID_IDENTITY_HEADER" },
3675 { PJSIP_SC_FIRST_HOP_LACKS_OUTBOUND_SUPPORT,
"PJSIP_SC_FIRST_HOP_LACKS_OUTBOUND_SUPPORT",
"FIRST_HOP_LACKS_OUTBOUND_SUPPORT" },
3676 { PJSIP_SC_MAX_BREADTH_EXCEEDED,
"PJSIP_SC_MAX_BREADTH_EXCEEDED",
"MAX_BREADTH_EXCEEDED" },
3677 { PJSIP_SC_BAD_INFO_PACKAGE,
"PJSIP_SC_BAD_INFO_PACKAGE",
"BAD_INFO_PACKAGE" },
3678 { PJSIP_SC_CONSENT_NEEDED,
"PJSIP_SC_CONSENT_NEEDED",
"CONSENT_NEEDED" },
3679 { PJSIP_SC_TEMPORARILY_UNAVAILABLE,
"PJSIP_SC_TEMPORARILY_UNAVAILABLE",
"TEMPORARILY_UNAVAILABLE" },
3680 { PJSIP_SC_CALL_TSX_DOES_NOT_EXIST,
"PJSIP_SC_CALL_TSX_DOES_NOT_EXIST",
"CALL_TSX_DOES_NOT_EXIST" },
3681 { PJSIP_SC_LOOP_DETECTED,
"PJSIP_SC_LOOP_DETECTED",
"LOOP_DETECTED" },
3682 { PJSIP_SC_TOO_MANY_HOPS,
"PJSIP_SC_TOO_MANY_HOPS",
"TOO_MANY_HOPS" },
3683 { PJSIP_SC_ADDRESS_INCOMPLETE,
"PJSIP_SC_ADDRESS_INCOMPLETE",
"ADDRESS_INCOMPLETE" },
3684 { PJSIP_SC_BUSY_HERE,
"PJSIP_SC_BUSY_HERE",
"BUSY_HERE" },
3685 { PJSIP_SC_REQUEST_TERMINATED,
"PJSIP_SC_REQUEST_TERMINATED",
"REQUEST_TERMINATED" },
3686 { PJSIP_SC_NOT_ACCEPTABLE_HERE,
"PJSIP_SC_NOT_ACCEPTABLE_HERE",
"NOT_ACCEPTABLE_HERE" },
3687 { PJSIP_SC_BAD_EVENT,
"PJSIP_SC_BAD_EVENT",
"BAD_EVENT" },
3688 { PJSIP_SC_REQUEST_UPDATED,
"PJSIP_SC_REQUEST_UPDATED",
"REQUEST_UPDATED" },
3689 { PJSIP_SC_REQUEST_PENDING,
"PJSIP_SC_REQUEST_PENDING",
"REQUEST_PENDING" },
3690 { PJSIP_SC_UNDECIPHERABLE,
"PJSIP_SC_UNDECIPHERABLE",
"UNDECIPHERABLE" },
3691 { PJSIP_SC_SECURITY_AGREEMENT_NEEDED,
"PJSIP_SC_SECURITY_AGREEMENT_NEEDED",
"SECURITY_AGREEMENT_NEEDED" },
3692 { PJSIP_SC_INTERNAL_SERVER_ERROR,
"PJSIP_SC_INTERNAL_SERVER_ERROR",
"INTERNAL_SERVER_ERROR" },
3693 { PJSIP_SC_NOT_IMPLEMENTED,
"PJSIP_SC_NOT_IMPLEMENTED",
"NOT_IMPLEMENTED" },
3694 { PJSIP_SC_BAD_GATEWAY,
"PJSIP_SC_BAD_GATEWAY",
"BAD_GATEWAY" },
3695 { PJSIP_SC_SERVICE_UNAVAILABLE,
"PJSIP_SC_SERVICE_UNAVAILABLE",
"SERVICE_UNAVAILABLE" },
3696 { PJSIP_SC_SERVER_TIMEOUT,
"PJSIP_SC_SERVER_TIMEOUT",
"SERVER_TIMEOUT" },
3697 { PJSIP_SC_VERSION_NOT_SUPPORTED,
"PJSIP_SC_VERSION_NOT_SUPPORTED",
"VERSION_NOT_SUPPORTED" },
3698 { PJSIP_SC_MESSAGE_TOO_LARGE,
"PJSIP_SC_MESSAGE_TOO_LARGE",
"MESSAGE_TOO_LARGE" },
3699 { PJSIP_SC_PUSH_NOTIFICATION_SERVICE_NOT_SUPPORTED,
"PJSIP_SC_PUSH_NOTIFICATION_SERVICE_NOT_SUPPORTED",
"PUSH_NOTIFICATION_SERVICE_NOT_SUPPORTED" },
3700 { PJSIP_SC_PRECONDITION_FAILURE,
"PJSIP_SC_PRECONDITION_FAILURE",
"PRECONDITION_FAILURE" },
3701 { PJSIP_SC_BUSY_EVERYWHERE,
"PJSIP_SC_BUSY_EVERYWHERE",
"BUSY_EVERYWHERE" },
3702 { PJSIP_SC_DECLINE,
"PJSIP_SC_DECLINE",
"DECLINE" },
3703 { PJSIP_SC_DOES_NOT_EXIST_ANYWHERE,
"PJSIP_SC_DOES_NOT_EXIST_ANYWHERE",
"DOES_NOT_EXIST_ANYWHERE" },
3704 { PJSIP_SC_NOT_ACCEPTABLE_ANYWHERE,
"PJSIP_SC_NOT_ACCEPTABLE_ANYWHERE",
"NOT_ACCEPTABLE_ANYWHERE" },
3705 { PJSIP_SC_UNWANTED,
"PJSIP_SC_UNWANTED",
"UNWANTED" },
3706 { PJSIP_SC_REJECTED,
"PJSIP_SC_REJECTED",
"REJECTED" },
3728#ifdef TEST_FRAMEWORK
3735 info->name =
"xml_sanitization_end_null";
3736 info->category =
"/res/res_pjsip/";
3737 info->summary =
"Ensure XML sanitization works as expected with a long string";
3738 info->description =
"This test sanitizes a string which exceeds the output\n"
3739 "buffer size. Once done the string is confirmed to be NULL terminated.";
3746 if (sanitized[7] !=
'\0') {
3760 info->name =
"xml_sanitization_exceeds_buffer";
3761 info->category =
"/res/res_pjsip/";
3762 info->summary =
"Ensure XML sanitization does not exceed buffer when output won't fit";
3763 info->description =
"This test sanitizes a string which before sanitization would\n"
3764 "fit within the output buffer. After sanitization, however, the string would\n"
3765 "exceed the buffer. Once done the string is confirmed to be NULL terminated.";
3772 if (sanitized[7] !=
'\0') {
3823 pj_pool_release(temp_pool);
3839 const unsigned int flags = 0;
3848 ast_log(
LOG_ERROR,
"Failed to create PJSIP endpoint structure. Aborting load\n");
3859 ast_log(
LOG_ERROR,
"Failed to create memory pool for SIP. Aborting load\n");
3879 if (
status != PJ_SUCCESS) {
3900 pjmedia_strerror(0,
NULL, 0);
3922 if (pj_init() != PJ_SUCCESS) {
3926 if (pjlib_util_init() != PJ_SUCCESS) {
3931 if (pj_register_strerror(PJMEDIA_ERRNO_START, PJ_ERRNO_SPACE_SIZE, pjmedia_strerror)
3933 ast_log(
LOG_WARNING,
"Failed to register pjmedia error codes. Codes will not be decoded.\n");
3952 ast_log(
LOG_ERROR,
"Failed to initialize SIP 'system' configuration section. Aborting load\n");
3975 ast_log(
LOG_ERROR,
"Failed to initialize SIP transport monitor. Aborting load\n");
3983 ast_log(
LOG_ERROR,
"Failed to pre-initialize OPTIONS handling. Aborting load\n");
3988 ast_log(
LOG_ERROR,
"Failed to initialize SIP configuration. Aborting load\n");
3996 ast_log(
LOG_ERROR,
"Failed to initialize SIP transport management. Aborting load\n");
4001 ast_log(
LOG_ERROR,
"Failed to register distributor module. Aborting load\n");
4006 ast_log(
LOG_ERROR,
"Failed to initialize supplement hooks. Aborting load\n");
4011 ast_log(
LOG_ERROR,
"Failed to initialize OPTIONS handling. Aborting load\n");
4024 ast_log(
LOG_ERROR,
"Failed to initialize message IP updating. Aborting load\n");
4081 .
requires =
"dnsmgr,res_pjproject,res_sorcery_config,res_sorcery_memory,res_sorcery_astdb",
4082 .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_REDIRECTED_TO_NEW_DESTINATION
#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, int rdlock)
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)
void sip_get_taskpool_options(struct ast_taskpool_options *taskpool_options)
int sip_cli_print_system(struct ast_sip_cli_context *context)
int ast_sip_initialize_system(void)
void ast_sip_initialize_dns(void)
static struct ao2_container * transport_states
Generic File Format Support. Should be included by clients of the file handling routines....
int ast_option_pjproject_log_level
int __ast_sip_push_task_synchronous(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data, const char *file, int line, const char *function)
Push a task to SIP servants and wait for it to complete.
#define ast_sip_push_task(serializer, sip_task, task_data)
#define ast_sip_push_task_synchronous(serializer, sip_task, task_data)
int __ast_sip_push_task_wait_servant(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data, const char *file, int line, const char *function)
Push a task to SIP servants and wait for it to complete.
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.
#define ast_sip_push_task_wait_serializer(serializer, sip_task, task_data)
int ast_sip_thread_is_servant(void)
Determine if the current thread is a SIP servant thread.
#define ast_sip_push_task_wait_servant(serializer, sip_task, task_data)
int __ast_sip_push_task_wait_serializer(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data, const char *file, int line, const char *function)
Push a task to the serializer and wait for it to complete.
int __ast_sip_push_task(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data, const char *file, int line, const char *function)
Pushes a task to SIP servants.
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 SCOPED_LOCK(varname, lock, lockfunc, unlockfunc)
Scoped Locks.
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.
static struct ast_taskpool * sip_taskpool
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 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 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.
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.
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)
long ast_sip_taskpool_queue_size(void)
Return the size of the SIP taskpool's task queue.
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.
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 struct @486 methods[]
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)
float ast_sip_parse_qvalue(const char *q_value)
Parses a string representing a q_value to a float.
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
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)
struct ast_taskpool * ast_sip_taskpool(void)
Retrieve the SIP taskpool object.
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.
static int __ast_sip_push_task_wait(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data, const char *file, int line, const char *function)
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.
pjsip_media_type pjsip_media_type_multipart_related
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.
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.
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.
An opaque taskpool structure.
A ast_taskprocessor structure is a singleton by name.
struct ast_sip_endpoint_identifier * identifier
struct endpoint_identifier_list::@487 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
int __ast_taskpool_push_wait(struct ast_taskpool *pool, int(*task)(void *data), void *data, const char *file, int line, const char *function) attribute_warn_unused_result
Push a task to the taskpool, and wait for completion.
int __ast_taskpool_serializer_push_wait(struct ast_taskprocessor *serializer, int(*task)(void *data), void *data, const char *file, int line, const char *function) attribute_warn_unused_result
Push a task to a serializer, and wait for completion.
void ast_taskpool_shutdown(struct ast_taskpool *pool)
Shut down a taskpool and remove the underlying taskprocessors.
int __ast_taskpool_push(struct ast_taskpool *pool, int(*task)(void *data), void *data, const char *file, int line, const char *function) attribute_warn_unused_result
Push a task to the taskpool.
struct ast_taskprocessor * ast_taskpool_serializer_group(const char *name, struct ast_taskpool *pool, struct ast_serializer_shutdown_group *shutdown_group)
Serialized execution of tasks within a ast_taskpool.
struct ast_taskpool * ast_taskpool_create(const char *name, const struct ast_taskpool_options *options)
Create a new taskpool.
long ast_taskpool_queue_size(struct ast_taskpool *pool)
Get the current number of queued tasks in the taskpool.
An API for managing task processing threads that can be shared across modules.
int __ast_taskprocessor_push(struct ast_taskprocessor *tps, int(*task_exe)(void *datap), void *datap, const char *file, int line, const char *function) 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_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.