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);
370 e->
command =
"pjsip dump endpt [details]";
372 "Usage: pjsip dump endpt [details]\n"
373 " Dump the res_pjsip endpt internals.\n"
375 "Warning: PJPROJECT documents that the function used by this\n"
376 "CLI command may cause a crash when asking for details because\n"
377 "it tries to access all active memory pools.\n";
385 e->
command =
"pjsip dump endpt";
387 "Usage: pjsip dump endpt\n"
388 " Dump the res_pjsip endpt internals.\n";
396 || (
a->argc == 4 && strcasecmp(
a->argv[3],
"details"))) {
407#define ENDPOINT_IDENTIFIER_FORMAT "%-20.20s\n"
412 e->
command =
"pjsip show identifiers";
413 e->
usage =
"Usage: pjsip show identifiers\n"
414 " List all registered endpoint identifiers\n";
429 iter->
name ? iter->
name :
"name not specified");
433#undef ENDPOINT_IDENTIFIER_FORMAT
442 e->
command =
"pjsip show settings";
443 e->
usage =
"Usage: pjsip show settings\n"
444 " Show global and system configuration options\n";
451 if (!context.output_buffer) {
452 ast_cli(
a->fd,
"Could not allocate output buffer.\n");
458 ast_cli(
a->fd,
"Error retrieving settings.\n");
520 pjsip_rx_data *rdata)
526 if (uri->port == rdata->pkt_info.src_port
527 && !pj_strcmp(&uri->host,
528 pj_cstr(&host_name, rdata->pkt_info.src_name))
530 && PJSIP_TRANSPORT_IS_RELIABLE(rdata->tp_info.transport)) {
534 if (!strcasecmp(
"WSS", rdata->tp_info.transport->type_name)) {
536 pj_cstr(&type_name,
"ws");
538 pj_cstr(&type_name, rdata->tp_info.transport->type_name);
541 if (!pj_stricmp(&uri->transport_param, &type_name)
544 || !pj_stricmp(&uri->transport_param,
545 pj_cstr(&type_name,
"ws")))) {
560 pjsip_contact_hdr *contact = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CONTACT,
NULL);
562 if (!contact || (!PJSIP_URI_SCHEME_IS_SIP(contact->uri) && !PJSIP_URI_SCHEME_IS_SIPS(contact->uri))) {
566 return pjsip_uri_get_uri(contact->uri);
580 ((details->
type == transport_state->
type) && (transport_state->
factory) &&
603 pjsip_sip_uri *tmp_uri;
608 pj_strdup(tdata->pool, &uri->host, &tmp_uri->host);
609 uri->port = tmp_uri->port;
610 }
else if ((dlg = pjsip_tdata_get_dlg(tdata))
611 && (tmp_uri = pjsip_uri_get_uri(dlg->local.info->uri))
612 && (PJSIP_URI_SCHEME_IS_SIP(tmp_uri) || PJSIP_URI_SCHEME_IS_SIPS(tmp_uri))) {
613 pj_strdup(tdata->pool, &uri->host, &tmp_uri->host);
614 uri->port = tmp_uri->port;
623 if (transport_state->localnet) {
635 if (transport->external_signaling_port) {
636 uri->port = transport->external_signaling_port;
648 if (!details || !tdata) {
653 transport_type = use_ipv6 ? tdata->tp_info.transport->key.type & ~(PJSIP_TRANSPORT_IPV6)
654 : tdata->tp_info.transport->key.type;
656 if (tdata->tp_sel.type == PJSIP_TPSELECTOR_TRANSPORT) {
657 details->
transport = tdata->tp_sel.u.transport;
658 }
else if (tdata->tp_sel.type == PJSIP_TPSELECTOR_LISTENER) {
659 details->
factory = tdata->tp_sel.u.listener;
660 }
else if (transport_type == PJSIP_TRANSPORT_UDP || transport_type == PJSIP_TRANSPORT_UDP6) {
663 details->
transport = tdata->tp_info.transport;
665 if (transport_type == PJSIP_TRANSPORT_TCP) {
667 }
else if (transport_type == PJSIP_TRANSPORT_TLS) {
677 }
else if ((tdata->msg->type == PJSIP_REQUEST_MSG) &&
678 (via = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_VIA,
NULL))) {
693 pjsip_sip_uri *sip_uri,
char *
buf,
size_t buf_len)
697 pjsip_param *x_transport;
704 x_transport = pjsip_param_find(&sip_uri->other_param, &x_name);
722 pjsip_tpselector *selector)
725 pjsip_tpselector sel = { .type = PJSIP_TPSELECTOR_NONE, };
727 uri = pjsip_uri_get_uri(dlg->target);
734 pjsip_dlg_set_transport(dlg, selector);
736 if (selector == &sel) {
744 const char *domain,
const pj_str_t *target, pjsip_tpselector *selector)
746 pj_str_t tmp, local_addr;
748 pjsip_sip_uri *sip_uri;
749 pjsip_transport_type_e
type;
751 char default_user[PJSIP_MAX_URL_SIZE];
759 pj_strdup_with_null(pool, &tmp, target);
761 if (!(uri = pjsip_parse_uri(pool, tmp.ptr, tmp.slen, 0)) ||
762 (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri))) {
766 sip_uri = pjsip_uri_get_uri(uri);
769 type = pjsip_transport_get_type_from_name(&sip_uri->transport_param);
770 if (PJSIP_URI_SCHEME_IS_SIPS(sip_uri)) {
771 if (
type == PJSIP_TRANSPORT_UNSPECIFIED
772 || !(pjsip_transport_get_flag_from_type(
type) & PJSIP_TRANSPORT_SECURE)) {
773 type = PJSIP_TRANSPORT_TLS;
775 }
else if (!sip_uri->transport_param.slen) {
776 type = PJSIP_TRANSPORT_UDP;
777 }
else if (
type == PJSIP_TRANSPORT_UNSPECIFIED) {
782 if (pj_strchr(&sip_uri->host,
':')) {
783 type |= PJSIP_TRANSPORT_IPV6;
788 from->ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
789 from->slen = pj_ansi_snprintf(from->ptr, PJSIP_MAX_URL_SIZE,
792 (
type != PJSIP_TRANSPORT_UDP &&
type != PJSIP_TRANSPORT_UDP6) ?
";transport=" :
"",
793 (
type != PJSIP_TRANSPORT_UDP &&
type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(
type) :
"");
798 from->ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
799 from->slen = pj_ansi_snprintf(from->ptr, PJSIP_MAX_URL_SIZE,
803 (
type != PJSIP_TRANSPORT_UDP &&
type != PJSIP_TRANSPORT_UDP6) ?
";transport=" :
"",
804 (
type != PJSIP_TRANSPORT_UDP &&
type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(
type) :
"");
810 &local_addr, &local_port) != PJ_SUCCESS) {
813 pj_strdup(pool, &local_addr, pj_gethostname());
814 local_port = pjsip_transport_get_default_port_for_type(PJSIP_TRANSPORT_UDP);
818 if (pj_strchr(&local_addr,
':')) {
819 type |= PJSIP_TRANSPORT_IPV6;
822 from->ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
823 from->slen = pj_ansi_snprintf(from->ptr, PJSIP_MAX_URL_SIZE,
824 "<sip:%s@%s%.*s%s:%d%s%s>",
826 (
type & PJSIP_TRANSPORT_IPV6) ?
"[" :
"",
827 (int)local_addr.slen,
829 (
type & PJSIP_TRANSPORT_IPV6) ?
"]" :
"",
831 (
type != PJSIP_TRANSPORT_UDP &&
type != PJSIP_TRANSPORT_UDP6) ?
";transport=" :
"",
832 (
type != PJSIP_TRANSPORT_UDP &&
type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(
type) :
"");
843 if (!transport_state) {
850 if (transport_state->
flow) {
855 selector->type = PJSIP_TPSELECTOR_TRANSPORT;
856 selector->u.transport = transport_state->
transport;
857 pjsip_transport_add_ref(selector->u.transport);
858 }
else if (transport_state->
factory) {
859 selector->type = PJSIP_TPSELECTOR_LISTENER;
860 selector->u.listener = transport_state->
factory;
868#ifdef HAVE_PJSIP_TRANSPORT_DISABLE_CONNECTION_REUSE
869 selector->disable_connection_reuse = PJ_TRUE;
871 ast_log(
LOG_WARNING,
"Connection reuse could not be disabled on transport '%s' as support is not available\n",
878 if (transport_state->
flow) {
906 pjsip_sip_uri *sip_uri, pjsip_tpselector *selector)
908 char transport_name[128];
919 if (selector->type == PJSIP_TPSELECTOR_TRANSPORT && selector->u.transport) {
920 pjsip_transport_dec_ref(selector->u.transport);
926 pjsip_sip_uri *sip_uri;
928 static const pj_str_t STR_PHONE = {
"phone", 5 };
930 if (!endpoint || !endpoint->
usereqphone || (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri))) {
934 sip_uri = pjsip_uri_get_uri(uri);
936 if (!pj_strlen(&sip_uri->user)) {
940 if (pj_strbuf(&sip_uri->user)[0] ==
'+') {
945 for (; i < pj_strlen(&sip_uri->user); i++) {
951 if (i < pj_strlen(&sip_uri->user)) {
955 sip_uri->user_param = STR_PHONE;
959 const char *uri,
const char *request_user)
961 char enclosed_uri[PJSIP_MAX_URL_SIZE];
962 pj_str_t local_uri = {
"sip:temp@temp", 13 }, remote_uri, target_uri;
964 pjsip_dialog *dlg =
NULL;
966 pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, };
967 static const pj_str_t HCONTACT = {
"Contact", 7 };
970 snprintf(enclosed_uri,
sizeof(enclosed_uri),
"<%s>", uri);
972 snprintf(enclosed_uri,
sizeof(enclosed_uri),
"%s", uri);
974 pj_cstr(&remote_uri, enclosed_uri);
976 pj_cstr(&target_uri, uri);
978 res = pjsip_dlg_create_uac(pjsip_ua_instance(), &local_uri,
NULL, &remote_uri, &target_uri, &dlg);
979 if (res == PJ_SUCCESS && !(PJSIP_URI_SCHEME_IS_SIP(dlg->target) || PJSIP_URI_SCHEME_IS_SIPS(dlg->target))) {
982 res = PJSIP_EINVALIDURI;
983 pjsip_dlg_terminate(dlg);
985 if (res != PJ_SUCCESS) {
986 if (res == PJSIP_EINVALIDURI) {
988 "Endpoint '%s': Could not create dialog to invalid URI '%s'. Is endpoint registered and reachable?\n",
1001 pjsip_dlg_terminate(dlg);
1009 pj_strdup_with_null(dlg->pool, &dlg->local.info_str, &local_uri);
1010 dlg->local.info->uri = pjsip_parse_uri(dlg->pool, dlg->local.info_str.ptr, dlg->local.info_str.slen, 0);
1011 if (!dlg->local.info->uri) {
1013 "Could not parse URI '%s' for endpoint '%s'\n",
1016 pjsip_dlg_terminate(dlg);
1020 dlg->local.contact = pjsip_parse_hdr(dlg->pool, &HCONTACT, local_uri.ptr, local_uri.slen,
NULL);
1023 pjsip_sip_uri *sip_uri;
1025 sip_uri = pjsip_uri_get_uri(dlg->local.contact->uri);
1026 pj_strdup2(dlg->pool, &sip_uri->user, endpoint->
contact_user);
1031 pjsip_sip_uri *sip_uri;
1033 if (PJSIP_URI_SCHEME_IS_SIP(dlg->target) || PJSIP_URI_SCHEME_IS_SIPS(dlg->target)) {
1034 sip_uri = pjsip_uri_get_uri(dlg->target);
1035 pj_strdup2(dlg->pool, &sip_uri->user, request_user);
1037 if (PJSIP_URI_SCHEME_IS_SIP(dlg->remote.info->uri) || PJSIP_URI_SCHEME_IS_SIPS(dlg->remote.info->uri)) {
1038 sip_uri = pjsip_uri_get_uri(dlg->remote.info->uri);
1039 pj_strdup2(dlg->pool, &sip_uri->user, request_user);
1049 pjsip_route_hdr route_set, *route;
1050 static const pj_str_t ROUTE_HNAME = {
"Route", 5 };
1053 pj_list_init(&route_set);
1055 pj_strdup2_with_null(dlg->pool, &tmp, outbound_proxy);
1056 if (!(route = pjsip_parse_hdr(dlg->pool, &ROUTE_HNAME, tmp.ptr, tmp.slen,
NULL))) {
1057 ast_log(
LOG_ERROR,
"Could not create dialog to endpoint '%s' as outbound proxy URI '%s' is not valid\n",
1060 pjsip_dlg_terminate(dlg);
1063 pj_list_insert_nodes_before(&route_set, route);
1065 pjsip_dlg_set_route_set(dlg, &route_set);
1085 pjsip_rr_hdr *record_route;
1087 if (PJSIP_URI_SCHEME_IS_SIPS(rdata->msg_info.msg->line.req.uri)) {
1091 record_route = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_RECORD_ROUTE,
NULL);
1093 if (PJSIP_URI_SCHEME_IS_SIPS(&record_route->name_addr)) {
1097 pjsip_contact_hdr *contact;
1099 contact = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT,
NULL);
1101 if (PJSIP_URI_SCHEME_IS_SIPS(contact->uri)) {
1110 const pj_str_t *contact, pjsip_dialog **p_dlg);
1117 pjsip_transport_type_e
type = rdata->tp_info.transport->key.type;
1118 pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, };
1120 pjsip_contact_hdr *contact_hdr;
1124 contact_hdr = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT,
NULL);
1131 if (selector.type == PJSIP_TPSELECTOR_TRANSPORT) {
1136 contact.ptr = pj_pool_alloc(rdata->tp_info.pool, PJSIP_MAX_URL_SIZE);
1137 contact.slen = pj_ansi_snprintf(contact.ptr, PJSIP_MAX_URL_SIZE,
1138 "<%s:%s%s%s%.*s%s:%d%s%s>",
1142 (
type & PJSIP_TRANSPORT_IPV6) ?
"[" :
"",
1145 (
type & PJSIP_TRANSPORT_IPV6) ?
"]" :
"",
1147 (
type != PJSIP_TRANSPORT_UDP &&
type != PJSIP_TRANSPORT_UDP6) ?
";transport=" :
"",
1148 (
type != PJSIP_TRANSPORT_UDP &&
type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(
type) :
"");
1150 *
status = create_fun(pjsip_ua_instance(), rdata, &contact, &dlg);
1151 if (*
status != PJ_SUCCESS) {
1152 char err[PJ_ERR_MSG_SIZE];
1154 pj_strerror(*
status, err,
sizeof(err));
1162 pjsip_dlg_set_transport(dlg, &selector);
1172#ifdef HAVE_PJSIP_DLG_CREATE_UAS_AND_INC_LOCK
1177 pjsip_dlg_dec_lock(dlg);
1187 pjsip_rx_data *rdata, pj_status_t *
status)
1189#ifdef HAVE_PJSIP_DLG_CREATE_UAS_AND_INC_LOCK
1201 pjsip_dlg_inc_lock(dlg);
1209 char *transport_type,
const char *local_name,
int local_port,
const char *contact)
1217 pj_list_init(&rdata->msg_info.parse_err);
1219 rdata->tp_info.transport = PJ_POOL_ZALLOC_T(rdata->tp_info.pool, pjsip_transport);
1220 if (!rdata->tp_info.transport) {
1224 ast_copy_string(rdata->pkt_info.packet, packet,
sizeof(rdata->pkt_info.packet));
1225 ast_copy_string(rdata->pkt_info.src_name, src_name,
sizeof(rdata->pkt_info.src_name));
1226 rdata->pkt_info.src_port = src_port;
1227 pj_sockaddr_parse(pj_AF_UNSPEC(), 0, pj_cstr(&tmp, src_name), &rdata->pkt_info.src_addr);
1228 pj_sockaddr_set_port(&rdata->pkt_info.src_addr, src_port);
1230 pjsip_parse_rdata(packet, strlen(packet), rdata);
1231 if (!rdata->msg_info.msg || !pj_list_empty(&rdata->msg_info.parse_err)) {
1236 pjsip_contact_hdr *contact_hdr;
1238 contact_hdr = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT,
NULL);
1240 contact_hdr->uri = pjsip_parse_uri(rdata->tp_info.pool, (
char *)contact,
1241 strlen(contact), PJSIP_PARSE_URI_AS_NAMEADDR);
1242 if (!contact_hdr->uri) {
1249 pj_strdup2(rdata->tp_info.pool, &rdata->msg_info.via->recvd_param, rdata->pkt_info.src_name);
1250 rdata->msg_info.via->rport_param = -1;
1252 rdata->tp_info.transport->key.type = pjsip_transport_get_type_from_name(pj_cstr(&tmp, transport_type));
1253 rdata->tp_info.transport->type_name = transport_type;
1254 pj_strdup2(rdata->tp_info.pool, &rdata->tp_info.transport->local_name.host, local_name);
1255 rdata->tp_info.transport->local_name.port = local_port;
1261 char *transport_type,
const char *local_name,
int local_port)
1264 local_name, local_port,
NULL);
1268static const pjsip_method
info_method = {PJSIP_OTHER_METHOD, {
"INFO", 4} };
1270static const pjsip_method
refer_method = {PJSIP_OTHER_METHOD, {
"REFER", 5} };
1276 {
"INVITE", &pjsip_invite_method },
1277 {
"CANCEL", &pjsip_cancel_method },
1278 {
"ACK", &pjsip_ack_method },
1279 {
"BYE", &pjsip_bye_method },
1280 {
"REGISTER", &pjsip_register_method },
1281 {
"OPTIONS", &pjsip_options_method },
1282 {
"SUBSCRIBE", &pjsip_subscribe_method },
1283 {
"NOTIFY", &pjsip_notify_method },
1303 if (pjsip_dlg_create_request(dlg,
method, -1, tdata) != PJ_SUCCESS) {
1313 .name = {
"Out of dialog supplement hook", 29 },
1315 .priority = PJSIP_MOD_PRIORITY_APPLICATION - 1,
1320 const char *uri,
struct ast_sip_contact *provided_contact, pjsip_tx_data **tdata)
1323 pj_str_t remote_uri;
1326 pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, };
1328 const char *fromuser;
1345 pj_cstr(&remote_uri, contact->uri);
1347 pj_cstr(&remote_uri, uri);
1357 sip_uri = pjsip_parse_uri(pool, remote_uri.ptr, remote_uri.slen, 0);
1358 if (!sip_uri || (!PJSIP_URI_SCHEME_IS_SIP(sip_uri) && !PJSIP_URI_SCHEME_IS_SIPS(sip_uri))) {
1359 ast_log(
LOG_ERROR,
"Unable to create outbound %.*s request to endpoint %s as URI '%s' is not valid\n",
1360 (
int) pj_strlen(&
method->name), pj_strbuf(&
method->name),
1362 pj_strbuf(&remote_uri));
1371 endpoint ? endpoint->
fromdomain :
NULL, &remote_uri, &selector)) {
1372 ast_log(
LOG_ERROR,
"Unable to create From header for %.*s request to endpoint %s\n",
1373 (
int) pj_strlen(&
method->name), pj_strbuf(&
method->name),
1381 &from, &remote_uri, &from,
NULL, -1,
NULL, tdata) != PJ_SUCCESS) {
1382 ast_log(
LOG_ERROR,
"Unable to create outbound %.*s request to endpoint %s\n",
1383 (
int) pj_strlen(&
method->name), pj_strbuf(&
method->name),
1390 pjsip_tx_data_set_transport(*tdata, &selector);
1395 pjsip_contact_hdr *contact_hdr;
1396 pjsip_sip_uri *contact_uri;
1397 static const pj_str_t HCONTACT = {
"Contact", 7 };
1398 static const pj_str_t HCONTACTSHORT = {
"m", 1 };
1400 contact_hdr = pjsip_msg_find_hdr_by_names((*tdata)->msg, &HCONTACT, &HCONTACTSHORT,
NULL);
1402 contact_uri = pjsip_uri_get_uri(contact_hdr->uri);
1403 pj_strdup2((*tdata)->pool, &contact_uri->user, endpoint->
contact_user);
1413 ast_log(
LOG_ERROR,
"Unable to apply outbound proxy on request %.*s to endpoint %s as outbound proxy URI '%s' is not valid\n",
1476 if (supplement == iter) {
1486 if (pjsip_dlg_send_request(dlg, tdata, -1,
NULL) != PJ_SUCCESS) {
1501 pj_cstr(&
method, supplement_method);
1506#define TIMER_INACTIVE 0
1507#define TIMEOUT_TIMER2 5
1578 if (e->body.tsx_state.type == PJSIP_EVENT_TIMER) {
1579 ast_debug(2,
"%p: PJSIP tsx timer expired\n", req_wrapper);
1583 ast_debug(3,
"%p: Timeout already handled\n", req_wrapper);
1588 ast_debug(2,
"%p: PJSIP tsx response received\n", req_wrapper);
1599 int timers_cancelled = 0;
1601 ast_debug(3,
"%p: Cancelling timer\n", req_wrapper);
1603 timers_cancelled = pj_timer_heap_cancel_if_active(
1606 if (timers_cancelled > 0) {
1610 ast_debug(3,
"%p: Timer cancelled\n", req_wrapper);
1618 ast_debug(3,
"%p: Timer already expired\n", req_wrapper);
1631 ast_debug(2,
"%p: Callbacks executed\n", req_wrapper);
1647 ast_debug(2,
"%p: Internal tsx timer expired after %d msec\n",
1648 req_wrapper, req_wrapper->
timeout);
1657 ast_debug(3,
"%p: Timeout already handled\n", req_wrapper);
1663 ast_debug(3,
"%p: Timer handled here\n", req_wrapper);
1672 PJSIP_EVENT_INIT_TX_MSG(
event, req_wrapper->
tdata);
1673 event.body.tsx_state.type = PJSIP_EVENT_TIMER;
1676 ast_debug(2,
"%p: Callbacks executed\n", req_wrapper);
1686 pjsip_tx_data_dec_ref(req_wrapper->
tdata);
1687 ast_debug(2,
"%p: wrapper destroyed\n", req_wrapper);
1691 pjsip_tx_data *
tdata, pj_int32_t
timeout,
void *
token, pjsip_endpt_send_callback cb)
1694 pj_status_t ret_val;
1699 pjsip_tx_data_dec_ref(
tdata);
1706 pjsip_tx_data_dec_ref(
tdata);
1710 ast_debug(2,
"%p: Wrapper created\n", req_wrapper);
1718 pjsip_tx_data_add_ref(
tdata);
1721 pj_time_val timeout_timer_val = {
timeout / 1000,
timeout % 1000 };
1734 ret_val = pj_timer_heap_schedule(pjsip_endpt_get_timer_heap(endpt),
1736 if (ret_val != PJ_SUCCESS) {
1738 "Failed to set timer. Not sending %.*s request to endpoint %s.\n",
1739 (
int) pj_strlen(&
tdata->msg->line.req.method.name),
1740 pj_strbuf(&
tdata->msg->line.req.method.name),
1742 ao2_t_ref(req_wrapper, -2,
"Drop timer and routine ref");
1743 pjsip_tx_data_dec_ref(
tdata);
1753 if (ret_val != PJ_SUCCESS) {
1754 char errmsg[PJ_ERR_MSG_SIZE];
1762 pj_strerror(ret_val, errmsg,
sizeof(errmsg));
1764 (
int) ret_val, errmsg, (
int) pj_strlen(&
tdata->msg->line.req.method.name),
1765 pj_strbuf(&
tdata->msg->line.req.method.name),
1769 int timers_cancelled;
1772 timers_cancelled = pj_timer_heap_cancel_if_active(
1773 pjsip_endpt_get_timer_heap(endpt),
1775 if (timers_cancelled > 0) {
1786 ret_val = PJ_SUCCESS;
1802 ret_val = PJ_SUCCESS;
1815 || (
tdata->dest_info.cur_addr ==
tdata->dest_info.addr.count - 1)) {
1821 ++
tdata->dest_info.cur_addr;
1823 via = (pjsip_via_hdr*)pjsip_msg_find_hdr(
tdata->msg, PJSIP_H_VIA,
NULL);
1824 via->branch_param.slen = 0;
1826 pjsip_tx_data_invalidate_msg(
tdata);
1836 pjsip_transaction *tsx;
1837 pjsip_tx_data *tdata;
1844 tsx = e->body.tsx_state.tsx;
1846 switch (tsx->status_code) {
1852 e->body.tsx_state.src.rdata, tsx->last_tx, &tdata);
1857 tdata = tsx->last_tx;
1862 pjsip_tx_data_add_ref(tdata);
1882 if (e->type == PJSIP_EVENT_TSX_STATE) {
1883 switch(e->body.tsx_state.type) {
1884 case PJSIP_EVENT_TRANSPORT_ERROR:
1885 case PJSIP_EVENT_TIMER:
1895 case PJSIP_EVENT_RX_MSG:
1896 challenge = e->body.tsx_state.src.rdata;
1934 void (*
callback)(
void *token, pjsip_event *e))
1942 pjsip_tx_data_dec_ref(tdata);
1975 void (*
callback)(
void *token, pjsip_event *e))
1977 ast_assert(tdata->msg->type == PJSIP_REQUEST_MSG);
1988 pjsip_route_hdr *route;
1989 static const pj_str_t ROUTE_HNAME = {
"Route", 5 };
1992 pj_strdup2_with_null(tdata->pool, &tmp, proxy);
1993 if (!(route = pjsip_parse_hdr(tdata->pool, &ROUTE_HNAME, tmp.ptr, tmp.slen,
NULL))) {
1997 pj_list_insert_nodes_before(&tdata->msg->hdr, (pjsip_hdr*)route);
2006 pjsip_generic_string_hdr *hdr;
2008 pj_cstr(&hdr_name,
name);
2009 pj_cstr(&hdr_value,
value);
2011 hdr = pjsip_generic_string_hdr_create(tdata->pool, &hdr_name, &hdr_value);
2013 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *) hdr);
2022 pjsip_generic_string_hdr *hdr;
2024 pj_cstr(&hdr_name,
name);
2025 pj_cstr(&hdr_value,
value);
2027 hdr = pjsip_generic_string_hdr_create(tdata->pool, &hdr_name, &hdr_value);
2029 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *) hdr);
2040 pj_cstr(&subtype, body->
subtype);
2043 return pjsip_msg_body_create(pool, &
type, &subtype, &body_text);
2049 tdata->msg->body = pjsip_body;
2057 pjsip_msg_body *body = pjsip_multipart_create(tdata->pool,
NULL,
NULL);
2059 for (i = 0; i < num_bodies; ++i) {
2060 pjsip_multipart_part *part = pjsip_multipart_create_part(tdata->pool);
2062 pjsip_multipart_add_part(tdata->pool, body, part);
2065 tdata->msg->body = body;
2071 size_t combined_size = strlen(body_text) + tdata->msg->body->len;
2074 ast_str_set(&body_buffer, 0,
"%.*s%s", (
int) tdata->msg->body->len, (
char *) tdata->msg->body->data, body_text);
2076 tdata->msg->body->data = pj_pool_alloc(tdata->pool, combined_size);
2077 pj_memcpy(tdata->msg->body->data,
ast_str_buffer(body_buffer), combined_size);
2078 tdata->msg->body->len = combined_size;
2093#undef ast_sip_push_task
2097 const char *file,
int line,
const char *function)
2113#undef ast_sip_push_task_wait_servant
2121#undef ast_sip_push_task_synchronous
2129#undef ast_sip_push_task_wait_serializer
2138 const char *file,
int line,
const char *function)
2147 const char *file,
int line,
const char *function)
2157 const char *file,
int line,
const char *function)
2163 const char *file,
int line,
const char *function)
2174 size_t chars_to_copy =
MIN(size - 1, pj_strlen(src));
2175 memcpy(dest, pj_strbuf(src), chars_to_copy);
2176 dest[chars_to_copy] =
'\0';
2181 int res =
ast_asprintf(dest,
"%.*s", (
int)pj_strlen(src), pj_strbuf(src));
2194 rc = pjsip_media_type_cmp(
a,
b, 0) ? 0 : 1;
2202 pjsip_media_type *
b =
NULL;
2208 while ((
b = va_arg(ap, pjsip_media_type *)) != (pjsip_media_type *)
SENTINEL) {
2209 if (pjsip_media_type_cmp(
a,
b, 0) == 0) {
2223 if (!content_type) {
2229 return pjsip_media_type_cmp(content_type, &
compare, 0) ? 0 : -1;
2240 const pj_time_val delay = {0, 10};
2254#define SIP_SERVANT_ID 0x5E2F1D
2258 pj_thread_desc *
desc;
2260 uint32_t *servant_id;
2264 ast_log(
LOG_ERROR,
"Could not set SIP servant ID in thread-local storage.\n");
2271 ast_log(
LOG_ERROR,
"Could not get thread desc from thread-local storage. Expect awful things to occur\n");
2276 if (pj_thread_register(
"Asterisk Thread", *
desc, &
thread) != PJ_SUCCESS) {
2283 uint32_t *servant_id;
2286 pthread_self() == *(pthread_t *)pj_thread_get_os_handle(
monitor_thread)) {
2300 unsigned int hval = 0;
2306 return pj_hash_get(ht, key, PJ_HASH_KEY_STRING, &hval);
2310 const char *key,
void *
val)
2313 ht = pj_hash_create(pool, 11);
2316 pj_hash_set(pool, ht, key, PJ_HASH_KEY_STRING, 0,
val);
2325 if (pjsip_rdata_get_dlg(rdata)) {
2348 pjsip_cseq_hdr *cseq = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CSEQ,
NULL);
2373 if (
status != PJ_SUCCESS) {
2374 pjsip_tx_data_dec_ref(tdata);
2377 return status == PJ_SUCCESS ? 0 : -1;
2382 pj_pool_t *pool = (pj_pool_t *)arg;
2392 pjsip_tx_data_dec_ref(tdata);
2397 pjsip_transaction *tsx;
2398 pj_grp_lock_t *tsx_glock;
2418 pj_grp_lock_add_ref(tsx_glock);
2420 if (pjsip_tsx_create_uas2(
NULL, rdata, tsx_glock, &tsx) != PJ_SUCCESS) {
2422 pj_grp_lock_dec_ref(tsx_glock);
2426 pjsip_tsx_recv_msg(tsx, rdata);
2429 if (pjsip_tsx_send_msg(tsx, tdata) != PJ_SUCCESS) {
2430 pj_grp_lock_dec_ref(tsx_glock);
2431 pjsip_tx_data_dec_ref(tdata);
2435 pj_grp_lock_dec_ref(tsx_glock);
2466 if (af == pj_AF_INET()) {
2468 }
else if (af == pj_AF_INET6()) {
2476 char *
buf,
size_t buf_len)
2508 if (!strcasecmp(dtmf_mode,
"info")) {
2510 }
else if (!strcasecmp(dtmf_mode,
"rfc4733")) {
2512 }
else if (!strcasecmp(dtmf_mode,
"inband")) {
2514 }
else if (!strcasecmp(dtmf_mode,
"none")) {
2516 }
else if (!strcasecmp(dtmf_mode,
"auto")) {
2518 }
else if (!strcasecmp(dtmf_mode,
"auto_info")) {
2532 value =
"local_merge";
2534 value =
"local_first";
2538 value =
"remote_merge";
2540 value =
"remote_first";
2552 if (strcmp(pref_str,
"local") == 0) {
2554 }
else if (is_outgoing && strcmp(pref_str,
"local_merge") == 0) {
2556 }
else if (strcmp(pref_str,
"local_first") == 0) {
2558 }
else if (strcmp(pref_str,
"remote") == 0) {
2560 }
else if (is_outgoing && strcmp(pref_str,
"remote_merge") == 0) {
2562 }
else if (strcmp(pref_str,
"remote_first") == 0) {
2582 pjsip_name_addr *id_name_addr = (pjsip_name_addr *) hdr->uri;
2588 semi = strchr(cid_num,
';');
2610 id_name_addr->display.ptr, id_name_addr->display.slen);
2614 "' for number '%s' has invalid UTF-8 characters which "
2627 id->number.valid = 1;
2644static pjsip_fromto_hdr *
get_id_header(pjsip_rx_data *rdata,
const pj_str_t *header_name)
2646 static const pj_str_t from = {
"From", 4 };
2647 pj_str_t header_content;
2648 pjsip_fromto_hdr *parsed_hdr;
2649 pjsip_generic_string_hdr *ident = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg,
2657 pj_strdup_with_null(rdata->tp_info.pool, &header_content, &ident->hvalue);
2659 parsed_hdr = pjsip_parse_hdr(rdata->tp_info.pool, &from, header_content.ptr,
2660 pj_strlen(&header_content), &parsed_len);
2683 static const pj_str_t pai_str = {
"P-Asserted-Identity", 19 };
2684 static const pj_str_t privacy_str = {
"Privacy", 7 };
2686 pjsip_generic_string_hdr *privacy;
2694 if (!
id->number.valid) {
2698 privacy = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &privacy_str,
NULL);
2699 if (!privacy || !pj_stricmp2(&privacy->hvalue,
"none")) {
2724 static const pj_str_t rpid_str = {
"Remote-Party-ID", 15 };
2725 static const pj_str_t privacy_str = {
"privacy", 7 };
2726 static const pj_str_t screen_str = {
"screen", 6 };
2727 pjsip_fromto_hdr *rpid_hdr =
get_id_header(rdata, &rpid_str);
2728 pjsip_param *screen;
2729 pjsip_param *privacy;
2737 if (!
id->number.valid) {
2741 privacy = pjsip_param_find(&rpid_hdr->other_param, &privacy_str);
2742 screen = pjsip_param_find(&rpid_hdr->other_param, &screen_str);
2743 if (privacy && !pj_stricmp2(&privacy->value,
"full")) {
2750 if (screen && !pj_stricmp2(&screen->value,
"yes")) {
2776 pjsip_fromto_hdr *from = pjsip_msg_find_hdr(rdata->msg_info.msg,
2777 PJSIP_H_FROM, rdata->msg_info.msg->hdr.next);
2786 if (!
id->number.valid) {
2823 pjsip_name_addr *id_name_addr;
2824 pjsip_sip_uri *id_uri;
2826 id_name_addr = (pjsip_name_addr *) id_hdr->uri;
2827 id_uri = pjsip_uri_get_uri(id_name_addr->uri);
2829 if (
id->name.valid) {
2831 int name_buf_len = strlen(
id->name.str) * 2 + 1;
2835 pj_strdup2(pool, &id_name_addr->display, name_buf);
2837 pj_strdup2(pool, &id_name_addr->display,
NULL);
2841 if (
id->number.valid) {
2842 pj_strdup2(pool, &id_uri->user,
id->number.str);
2866 pjsip_name_addr *name_addr;
2867 pjsip_sip_uri *sip_uri;
2883 name_addr = (pjsip_name_addr *) pjsip_parse_uri(pool, (
char*)contact->uri, strlen(contact->uri), PJSIP_PARSE_URI_AS_NAMEADDR);
2884 if (!name_addr || (!PJSIP_URI_SCHEME_IS_SIP(name_addr->uri) && !PJSIP_URI_SCHEME_IS_SIPS(name_addr->uri))) {
2892 sip_uri = pjsip_uri_get_uri(name_addr->uri);
2893 pj_strset2(&sip_uri->user, (
char*)
user);
2900 pjsip_uri_print(PJSIP_URI_IN_REQ_URI, name_addr, *
uri, PJSIP_MAX_URL_SIZE);
2928 char *endpoint_name =
NULL;
2941 char *temp_uri =
ast_malloc(strlen(destination) + strlen(
"sip:") + 1);
2945 sprintf(temp_uri,
"sip:%s", destination);
2947 if (get_default_outbound) {
2950 ast_debug(3,
"Dest: '%s' Didn't find endpoint so adding scheme and using URI '%s'%s\n",
2951 to, *uri, get_default_outbound ?
" with default endpoint" :
"");
2959 endpoint_name = destination;
2962 ast_log(
LOG_WARNING,
"Dest: '%s'. Found endpoint '%s' but didn't find an aor/contact for it\n",
2974 ast_debug(3,
"Dest: '%s' Found endpoint '%s' and found contact with URI '%s'\n",
2975 to, endpoint_name, *uri);
3006 char *slash,
char *atsign,
char *scheme)
3008 char *endpoint_name =
NULL;
3012 char *afterslash = slash + 1;
3016 ast_debug(3,
"Dest: '%s' Dialplan format'\n", to);
3020 if (!atsign || strchr(afterslash,
'/')) {
3026 "Dest: '%s'. Destinations beginning with 'PJSIP/' must be in the form of 'PJSIP/user@endpoint'\n",
3032 endpoint_name = atsign + 1;
3033 ast_debug(3,
"Dest: '%s' User: '%s' Endpoint: '%s'\n", to,
user, endpoint_name);
3041 endpoint_name = destination;
3042 ast_debug(3,
"Dest: '%s' Endpoint: '%s'\n", to, endpoint_name);
3061 ast_debug(3,
"Dest: '%s' Found endpoint '%s' and found URI '%s' after '/'\n",
3062 to, endpoint_name, *uri);
3083 ast_debug(3,
"Dest: '%s' User: '%s' Endpoint: '%s' URI: '%s'\n", to,
user,
3084 endpoint_name, *uri);
3100 *uri =
ast_malloc(strlen(afterslash) + strlen(
"sip:") + 1);
3104 sprintf(*uri,
"sip:%s", afterslash);
3105 ast_debug(3,
"Dest: '%s' Found endpoint '%s' but didn't find aor after '/' so using URI '%s'\n",
3106 to, endpoint_name, *uri);
3113 ast_debug(3,
"Dest: '%s' Found endpoint '%s' and found aor '%s' after '/'\n",
3118 ast_log(
LOG_WARNING,
"Dest: '%s'. Found endpoint '%s' but didn't find contact for aor '%s'\n",
3131 ast_debug(3,
"Dest: '%s' Found endpoint '%s' and found contact with URI '%s' for aor '%s'\n",
3163 char *slash,
char *atsign,
char *scheme,
int get_default_outbound)
3165 char *endpoint_name =
NULL;
3168 char *afterat = atsign + 1;
3185 sprintf(*
uri,
"sip:%s", to);
3186 if (get_default_outbound) {
3189 ast_debug(3,
"Dest: '%s' Didn't find endpoint before the '@' so using URI '%s'%s\n",
3190 to, *
uri, get_default_outbound ?
" with default endpoint" :
"");
3209 ast_debug(3,
"Dest: '%s' Found endpoint '%s' and found contact with URI '%s' (discarding domain %s)\n",
3224 char *atsign =
NULL;
3225 char *scheme =
NULL;
3230 slash = strchr(destination,
'/');
3231 atsign = strchr(destination,
'@');
3232 scheme =
S_OR(strstr(destination,
"sip:"), strstr(destination,
"sips:"));
3234 if (!slash && !atsign && !scheme) {
3250 return handle_slash(to, destination, uri, slash, atsign, scheme);
3253 if (atsign && !scheme) {
3260 return handle_atsign(to, destination, uri, slash, atsign, scheme, get_default_outbound);
3271 ast_debug(3,
"Dest: '%s' Didn't find an endpoint but did find a scheme so using URI '%s'%s\n",
3272 to, *uri, get_default_outbound ?
" with default endpoint" :
"");
3274 *uri =
ast_malloc(strlen(destination) + strlen(
"sip:") + 1);
3278 sprintf(*uri,
"sip:%s", destination);
3279 ast_debug(3,
"Dest: '%s' Didn't find an endpoint and didn't find scheme so adding scheme and using URI '%s'%s\n",
3280 to, *uri, get_default_outbound ?
" with default endpoint" :
"");
3282 if (get_default_outbound) {
3296 pjsip_name_addr *parsed_name_addr;
3297 pjsip_sip_uri *sip_uri;
3298 pjsip_name_addr *tdata_name_addr;
3299 pjsip_sip_uri *tdata_sip_uri;
3300 pjsip_to_hdr *to_hdr;
3302#define DEBUG_BUF_SIZE 256
3304 parsed_name_addr = (pjsip_name_addr *) pjsip_parse_uri(tdata->pool, (
char*)to, strlen(to),
3305 PJSIP_PARSE_URI_AS_NAMEADDR);
3307 if (!parsed_name_addr || (!PJSIP_URI_SCHEME_IS_SIP(parsed_name_addr->uri)
3308 && !PJSIP_URI_SCHEME_IS_SIPS(parsed_name_addr->uri))) {
3313 sip_uri = pjsip_uri_get_uri(parsed_name_addr->uri);
3317 ast_debug(3,
"Parsed To: %.*s %s\n", (
int)parsed_name_addr->display.slen,
3318 parsed_name_addr->display.ptr,
buf);
3321 to_hdr = PJSIP_MSG_TO_HDR(tdata->msg);
3322 tdata_name_addr = to_hdr ? (pjsip_name_addr *) to_hdr->uri :
NULL;
3323 if (!tdata_name_addr || (!PJSIP_URI_SCHEME_IS_SIP(tdata_name_addr->uri)
3324 && !PJSIP_URI_SCHEME_IS_SIPS(tdata_name_addr->uri))) {
3330 tdata_sip_uri = pjsip_uri_get_uri(tdata_name_addr->uri);
3334 ast_debug(3,
"Original tdata To: %.*s %s\n", (
int)tdata_name_addr->display.slen,
3335 tdata_name_addr->display.ptr,
buf);
3339 pjsip_sip_uri_assign(tdata->pool, tdata_sip_uri, sip_uri);
3341 pj_strdup(tdata->pool, &tdata_name_addr->display, &parsed_name_addr->display);
3345 pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, tdata_sip_uri,
buf, 256);
3346 ast_debug(3,
"New tdata To: %.*s %s\n", (
int)tdata_name_addr->display.slen,
3347 tdata_name_addr->display.ptr,
buf);
3351#undef DEBUG_BUF_SIZE
3356 pjsip_name_addr *name_addr;
3358 pjsip_name_addr *parsed_name_addr;
3359 pjsip_from_hdr *from_hdr;
3365 from_hdr = PJSIP_MSG_FROM_HDR(tdata->msg);
3369 name_addr = (pjsip_name_addr *) from_hdr->uri;
3370 uri = pjsip_uri_get_uri(name_addr);
3372 parsed_name_addr = (pjsip_name_addr *) pjsip_parse_uri(tdata->pool, from,
3373 strlen(from), PJSIP_PARSE_URI_AS_NAMEADDR);
3374 if (parsed_name_addr) {
3375 pjsip_sip_uri *parsed_uri;
3377 if (!PJSIP_URI_SCHEME_IS_SIP(parsed_name_addr->uri)
3378 && !PJSIP_URI_SCHEME_IS_SIPS(parsed_name_addr->uri)) {
3383 parsed_uri = pjsip_uri_get_uri(parsed_name_addr->uri);
3385 if (pj_strlen(&parsed_name_addr->display)) {
3386 pj_strdup(tdata->pool, &name_addr->display, &parsed_name_addr->display);
3390 pj_strdup(tdata->pool, &uri->user, &parsed_uri->user);
3391 pj_strdup(tdata->pool, &uri->host, &parsed_uri->host);
3392 uri->port = parsed_uri->port;
3397 char *domain = strchr(from,
'@');
3402 pj_strset3(&pj_from, from, domain);
3403 pj_strdup(tdata->pool, &uri->user, &pj_from);
3405 pj_strdup2(tdata->pool, &uri->host, domain + 1);
3407 pj_strdup2(tdata->pool, &uri->user, from);
3418 const pjsip_hdr *
request_headers = pjsip_endpt_get_request_headers(endpt);
3422 pjsip_hdr *to_erase = iter;
3424 pj_list_erase(to_erase);
3440 return (PJSIP_URI_SCHEME_IS_SIP(uri) || PJSIP_URI_SCHEME_IS_SIPS(uri));
3451 pjsip_sip_uri *sip_uri = pjsip_uri_get_uri(uri);
3455 return &sip_uri->user;
3456 }
else if (PJSIP_URI_SCHEME_IS_TEL(uri)) {
3457 pjsip_tel_uri *tel_uri = pjsip_uri_get_uri(uri);
3461 return &tel_uri->number;
3470 pjsip_sip_uri *sip_uri = pjsip_uri_get_uri(uri);
3474 return &sip_uri->host;
3475 }
else if (PJSIP_URI_SCHEME_IS_TEL(uri)) {
3485 pjsip_sip_uri *sip_uri = pjsip_uri_get_uri(uri);
3489 return pjsip_param_find(&sip_uri->other_param, param_str);
3490 }
else if (PJSIP_URI_SCHEME_IS_TEL(uri)) {
3491 pjsip_tel_uri *tel_uri = pjsip_uri_get_uri(uri);
3495 return pjsip_param_find(&tel_uri->other_param, param_str);
3503 float ret = strtof(q_value, &
end);
3505 if (
end == q_value) {
3511 if (!isfinite(ret)) {
3514 if (ret > 1.0f || ret < 0.0f) {
3595 if (cause < 500 && cause >= 400) {
3598 }
else if (cause < 600 && cause >= 500) {
3601 }
else if (cause < 700 && cause >= 600) {
3625 { PJSIP_SC_NULL,
"PJSIP_SC_NULL",
"NULL" },
3626 { PJSIP_SC_TRYING,
"PJSIP_SC_TRYING",
"TRYING" },
3627 { PJSIP_SC_RINGING,
"PJSIP_SC_RINGING",
"RINGING" },
3628 { PJSIP_SC_CALL_BEING_FORWARDED,
"PJSIP_SC_CALL_BEING_FORWARDED",
"CALL_BEING_FORWARDED" },
3629 { PJSIP_SC_QUEUED,
"PJSIP_SC_QUEUED",
"QUEUED" },
3630 { PJSIP_SC_PROGRESS,
"PJSIP_SC_PROGRESS",
"PROGRESS" },
3631 { PJSIP_SC_EARLY_DIALOG_TERMINATED,
"PJSIP_SC_EARLY_DIALOG_TERMINATED",
"EARLY_DIALOG_TERMINATED" },
3632 { PJSIP_SC_OK,
"PJSIP_SC_OK",
"OK" },
3633 { PJSIP_SC_ACCEPTED,
"PJSIP_SC_ACCEPTED",
"ACCEPTED" },
3634 { PJSIP_SC_NO_NOTIFICATION,
"PJSIP_SC_NO_NOTIFICATION",
"NO_NOTIFICATION" },
3635 { PJSIP_SC_MULTIPLE_CHOICES,
"PJSIP_SC_MULTIPLE_CHOICES",
"MULTIPLE_CHOICES" },
3636 { PJSIP_SC_MOVED_PERMANENTLY,
"PJSIP_SC_MOVED_PERMANENTLY",
"MOVED_PERMANENTLY" },
3637 { PJSIP_SC_MOVED_TEMPORARILY,
"PJSIP_SC_MOVED_TEMPORARILY",
"MOVED_TEMPORARILY" },
3638 { PJSIP_SC_USE_PROXY,
"PJSIP_SC_USE_PROXY",
"USE_PROXY" },
3639 { PJSIP_SC_ALTERNATIVE_SERVICE,
"PJSIP_SC_ALTERNATIVE_SERVICE",
"ALTERNATIVE_SERVICE" },
3640 { PJSIP_SC_BAD_REQUEST,
"PJSIP_SC_BAD_REQUEST",
"BAD_REQUEST" },
3641 { PJSIP_SC_UNAUTHORIZED,
"PJSIP_SC_UNAUTHORIZED",
"UNAUTHORIZED" },
3642 { PJSIP_SC_PAYMENT_REQUIRED,
"PJSIP_SC_PAYMENT_REQUIRED",
"PAYMENT_REQUIRED" },
3643 { PJSIP_SC_FORBIDDEN,
"PJSIP_SC_FORBIDDEN",
"FORBIDDEN" },
3644 { PJSIP_SC_NOT_FOUND,
"PJSIP_SC_NOT_FOUND",
"NOT_FOUND" },
3645 { PJSIP_SC_METHOD_NOT_ALLOWED,
"PJSIP_SC_METHOD_NOT_ALLOWED",
"METHOD_NOT_ALLOWED" },
3646 { PJSIP_SC_NOT_ACCEPTABLE,
"PJSIP_SC_NOT_ACCEPTABLE",
"NOT_ACCEPTABLE" },
3647 { PJSIP_SC_PROXY_AUTHENTICATION_REQUIRED,
"PJSIP_SC_PROXY_AUTHENTICATION_REQUIRED",
"PROXY_AUTHENTICATION_REQUIRED" },
3648 { PJSIP_SC_REQUEST_TIMEOUT,
"PJSIP_SC_REQUEST_TIMEOUT",
"REQUEST_TIMEOUT" },
3649 { PJSIP_SC_CONFLICT,
"PJSIP_SC_CONFLICT",
"CONFLICT" },
3650 { PJSIP_SC_GONE,
"PJSIP_SC_GONE",
"GONE" },
3651 { PJSIP_SC_LENGTH_REQUIRED,
"PJSIP_SC_LENGTH_REQUIRED",
"LENGTH_REQUIRED" },
3652 { PJSIP_SC_CONDITIONAL_REQUEST_FAILED,
"PJSIP_SC_CONDITIONAL_REQUEST_FAILED",
"CONDITIONAL_REQUEST_FAILED" },
3653 { PJSIP_SC_REQUEST_ENTITY_TOO_LARGE,
"PJSIP_SC_REQUEST_ENTITY_TOO_LARGE",
"REQUEST_ENTITY_TOO_LARGE" },
3654 { PJSIP_SC_REQUEST_URI_TOO_LONG,
"PJSIP_SC_REQUEST_URI_TOO_LONG",
"REQUEST_URI_TOO_LONG" },
3655 { PJSIP_SC_UNSUPPORTED_MEDIA_TYPE,
"PJSIP_SC_UNSUPPORTED_MEDIA_TYPE",
"UNSUPPORTED_MEDIA_TYPE" },
3656 { PJSIP_SC_UNSUPPORTED_URI_SCHEME,
"PJSIP_SC_UNSUPPORTED_URI_SCHEME",
"UNSUPPORTED_URI_SCHEME" },
3657 { PJSIP_SC_UNKNOWN_RESOURCE_PRIORITY,
"PJSIP_SC_UNKNOWN_RESOURCE_PRIORITY",
"UNKNOWN_RESOURCE_PRIORITY" },
3658 { PJSIP_SC_BAD_EXTENSION,
"PJSIP_SC_BAD_EXTENSION",
"BAD_EXTENSION" },
3659 { PJSIP_SC_EXTENSION_REQUIRED,
"PJSIP_SC_EXTENSION_REQUIRED",
"EXTENSION_REQUIRED" },
3660 { PJSIP_SC_SESSION_TIMER_TOO_SMALL,
"PJSIP_SC_SESSION_TIMER_TOO_SMALL",
"SESSION_TIMER_TOO_SMALL" },
3661 { PJSIP_SC_INTERVAL_TOO_BRIEF,
"PJSIP_SC_INTERVAL_TOO_BRIEF",
"INTERVAL_TOO_BRIEF" },
3662 { PJSIP_SC_BAD_LOCATION_INFORMATION,
"PJSIP_SC_BAD_LOCATION_INFORMATION",
"BAD_LOCATION_INFORMATION" },
3663 { PJSIP_SC_USE_IDENTITY_HEADER,
"PJSIP_SC_USE_IDENTITY_HEADER",
"USE_IDENTITY_HEADER" },
3664 { PJSIP_SC_PROVIDE_REFERRER_HEADER,
"PJSIP_SC_PROVIDE_REFERRER_HEADER",
"PROVIDE_REFERRER_HEADER" },
3665 { PJSIP_SC_FLOW_FAILED,
"PJSIP_SC_FLOW_FAILED",
"FLOW_FAILED" },
3666 { PJSIP_SC_ANONIMITY_DISALLOWED,
"PJSIP_SC_ANONIMITY_DISALLOWED",
"ANONIMITY_DISALLOWED" },
3667 { PJSIP_SC_BAD_IDENTITY_INFO,
"PJSIP_SC_BAD_IDENTITY_INFO",
"BAD_IDENTITY_INFO" },
3668 { PJSIP_SC_UNSUPPORTED_CERTIFICATE,
"PJSIP_SC_UNSUPPORTED_CERTIFICATE",
"UNSUPPORTED_CERTIFICATE" },
3669 { PJSIP_SC_INVALID_IDENTITY_HEADER,
"PJSIP_SC_INVALID_IDENTITY_HEADER",
"INVALID_IDENTITY_HEADER" },
3670 { PJSIP_SC_FIRST_HOP_LACKS_OUTBOUND_SUPPORT,
"PJSIP_SC_FIRST_HOP_LACKS_OUTBOUND_SUPPORT",
"FIRST_HOP_LACKS_OUTBOUND_SUPPORT" },
3671 { PJSIP_SC_MAX_BREADTH_EXCEEDED,
"PJSIP_SC_MAX_BREADTH_EXCEEDED",
"MAX_BREADTH_EXCEEDED" },
3672 { PJSIP_SC_BAD_INFO_PACKAGE,
"PJSIP_SC_BAD_INFO_PACKAGE",
"BAD_INFO_PACKAGE" },
3673 { PJSIP_SC_CONSENT_NEEDED,
"PJSIP_SC_CONSENT_NEEDED",
"CONSENT_NEEDED" },
3674 { PJSIP_SC_TEMPORARILY_UNAVAILABLE,
"PJSIP_SC_TEMPORARILY_UNAVAILABLE",
"TEMPORARILY_UNAVAILABLE" },
3675 { PJSIP_SC_CALL_TSX_DOES_NOT_EXIST,
"PJSIP_SC_CALL_TSX_DOES_NOT_EXIST",
"CALL_TSX_DOES_NOT_EXIST" },
3676 { PJSIP_SC_LOOP_DETECTED,
"PJSIP_SC_LOOP_DETECTED",
"LOOP_DETECTED" },
3677 { PJSIP_SC_TOO_MANY_HOPS,
"PJSIP_SC_TOO_MANY_HOPS",
"TOO_MANY_HOPS" },
3678 { PJSIP_SC_ADDRESS_INCOMPLETE,
"PJSIP_SC_ADDRESS_INCOMPLETE",
"ADDRESS_INCOMPLETE" },
3679 { PJSIP_SC_BUSY_HERE,
"PJSIP_SC_BUSY_HERE",
"BUSY_HERE" },
3680 { PJSIP_SC_REQUEST_TERMINATED,
"PJSIP_SC_REQUEST_TERMINATED",
"REQUEST_TERMINATED" },
3681 { PJSIP_SC_NOT_ACCEPTABLE_HERE,
"PJSIP_SC_NOT_ACCEPTABLE_HERE",
"NOT_ACCEPTABLE_HERE" },
3682 { PJSIP_SC_BAD_EVENT,
"PJSIP_SC_BAD_EVENT",
"BAD_EVENT" },
3683 { PJSIP_SC_REQUEST_UPDATED,
"PJSIP_SC_REQUEST_UPDATED",
"REQUEST_UPDATED" },
3684 { PJSIP_SC_REQUEST_PENDING,
"PJSIP_SC_REQUEST_PENDING",
"REQUEST_PENDING" },
3685 { PJSIP_SC_UNDECIPHERABLE,
"PJSIP_SC_UNDECIPHERABLE",
"UNDECIPHERABLE" },
3686 { PJSIP_SC_SECURITY_AGREEMENT_NEEDED,
"PJSIP_SC_SECURITY_AGREEMENT_NEEDED",
"SECURITY_AGREEMENT_NEEDED" },
3687 { PJSIP_SC_INTERNAL_SERVER_ERROR,
"PJSIP_SC_INTERNAL_SERVER_ERROR",
"INTERNAL_SERVER_ERROR" },
3688 { PJSIP_SC_NOT_IMPLEMENTED,
"PJSIP_SC_NOT_IMPLEMENTED",
"NOT_IMPLEMENTED" },
3689 { PJSIP_SC_BAD_GATEWAY,
"PJSIP_SC_BAD_GATEWAY",
"BAD_GATEWAY" },
3690 { PJSIP_SC_SERVICE_UNAVAILABLE,
"PJSIP_SC_SERVICE_UNAVAILABLE",
"SERVICE_UNAVAILABLE" },
3691 { PJSIP_SC_SERVER_TIMEOUT,
"PJSIP_SC_SERVER_TIMEOUT",
"SERVER_TIMEOUT" },
3692 { PJSIP_SC_VERSION_NOT_SUPPORTED,
"PJSIP_SC_VERSION_NOT_SUPPORTED",
"VERSION_NOT_SUPPORTED" },
3693 { PJSIP_SC_MESSAGE_TOO_LARGE,
"PJSIP_SC_MESSAGE_TOO_LARGE",
"MESSAGE_TOO_LARGE" },
3694 { PJSIP_SC_PUSH_NOTIFICATION_SERVICE_NOT_SUPPORTED,
"PJSIP_SC_PUSH_NOTIFICATION_SERVICE_NOT_SUPPORTED",
"PUSH_NOTIFICATION_SERVICE_NOT_SUPPORTED" },
3695 { PJSIP_SC_PRECONDITION_FAILURE,
"PJSIP_SC_PRECONDITION_FAILURE",
"PRECONDITION_FAILURE" },
3696 { PJSIP_SC_BUSY_EVERYWHERE,
"PJSIP_SC_BUSY_EVERYWHERE",
"BUSY_EVERYWHERE" },
3697 { PJSIP_SC_DECLINE,
"PJSIP_SC_DECLINE",
"DECLINE" },
3698 { PJSIP_SC_DOES_NOT_EXIST_ANYWHERE,
"PJSIP_SC_DOES_NOT_EXIST_ANYWHERE",
"DOES_NOT_EXIST_ANYWHERE" },
3699 { PJSIP_SC_NOT_ACCEPTABLE_ANYWHERE,
"PJSIP_SC_NOT_ACCEPTABLE_ANYWHERE",
"NOT_ACCEPTABLE_ANYWHERE" },
3700 { PJSIP_SC_UNWANTED,
"PJSIP_SC_UNWANTED",
"UNWANTED" },
3701 { PJSIP_SC_REJECTED,
"PJSIP_SC_REJECTED",
"REJECTED" },
3723#ifdef TEST_FRAMEWORK
3730 info->name =
"xml_sanitization_end_null";
3731 info->category =
"/res/res_pjsip/";
3732 info->summary =
"Ensure XML sanitization works as expected with a long string";
3733 info->description =
"This test sanitizes a string which exceeds the output\n"
3734 "buffer size. Once done the string is confirmed to be NULL terminated.";
3741 if (sanitized[7] !=
'\0') {
3755 info->name =
"xml_sanitization_exceeds_buffer";
3756 info->category =
"/res/res_pjsip/";
3757 info->summary =
"Ensure XML sanitization does not exceed buffer when output won't fit";
3758 info->description =
"This test sanitizes a string which before sanitization would\n"
3759 "fit within the output buffer. After sanitization, however, the string would\n"
3760 "exceed the buffer. Once done the string is confirmed to be NULL terminated.";
3767 if (sanitized[7] !=
'\0') {
3818 pj_pool_release(temp_pool);
3834 const unsigned int flags = 0;
3843 ast_log(
LOG_ERROR,
"Failed to create PJSIP endpoint structure. Aborting load\n");
3854 ast_log(
LOG_ERROR,
"Failed to create memory pool for SIP. Aborting load\n");
3874 if (
status != PJ_SUCCESS) {
3895 pjmedia_strerror(0,
NULL, 0);
3917 if (pj_init() != PJ_SUCCESS) {
3921 if (pjlib_util_init() != PJ_SUCCESS) {
3926 if (pj_register_strerror(PJMEDIA_ERRNO_START, PJ_ERRNO_SPACE_SIZE, pjmedia_strerror)
3928 ast_log(
LOG_WARNING,
"Failed to register pjmedia error codes. Codes will not be decoded.\n");
3947 ast_log(
LOG_ERROR,
"Failed to initialize SIP 'system' configuration section. Aborting load\n");
3970 ast_log(
LOG_ERROR,
"Failed to initialize SIP transport monitor. Aborting load\n");
3978 ast_log(
LOG_ERROR,
"Failed to pre-initialize OPTIONS handling. Aborting load\n");
3983 ast_log(
LOG_ERROR,
"Failed to initialize SIP configuration. Aborting load\n");
3991 ast_log(
LOG_ERROR,
"Failed to initialize SIP transport management. Aborting load\n");
3996 ast_log(
LOG_ERROR,
"Failed to register distributor module. Aborting load\n");
4001 ast_log(
LOG_ERROR,
"Failed to initialize supplement hooks. Aborting load\n");
4006 ast_log(
LOG_ERROR,
"Failed to initialize OPTIONS handling. Aborting load\n");
4019 ast_log(
LOG_ERROR,
"Failed to initialize message IP updating. Aborting load\n");
4076 .
requires =
"dnsmgr,res_pjproject,res_sorcery_config,res_sorcery_memory,res_sorcery_astdb",
4077 .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, 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_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 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 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 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::@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
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.