232 #include <inttypes.h> 277 #include "sip/include/dialplan_functions.h" 684 .resync_threshold = 1000,
720 {
NONE,
"-",
"unknown",
"unknown" },
722 {
DIALOG_INFO_XML,
"dialog",
"application/dialog-info+xml",
"dialog-info+xml" },
723 {
CPIM_PIDF_XML,
"presence",
"application/cpim-pidf+xml",
"cpim-pidf+xml" },
724 {
PIDF_XML,
"presence",
"application/pidf+xml",
"pidf+xml" },
725 {
XPIDF_XML,
"presence",
"application/xpidf+xml",
"xpidf+xml" },
726 {
MWI_NOTIFICATION,
"message-summary",
"application/simple-message-summary",
"mwi" }
813 #define SIP_PEDANTIC_DECODE(str) \ 814 if (sip_cfg.pedanticsipchecking && !ast_strlen_zero(str)) { \ 815 ast_uri_decode(str, ast_uri_sip_user); \ 948 static const struct {
958 static const struct {
1044 #define sip_pvt_lock(x) ao2_lock(x) 1045 #define sip_pvt_trylock(x) ao2_trylock(x) 1046 #define sip_pvt_unlock(x) ao2_unlock(x) 1058 #define BOGUS_PEER_MD5SECRET "intentionally_invalid_md5_string" 1076 #define SIP_TRANSPORT_STR_BUFSIZE 128 1157 #define UNLINK(element, head, prev) do { \ 1159 (prev)->next = (element)->next; \ 1161 (head) = (element)->next; \ 1239 const char *
file,
int line,
const char *func);
1240 #define find_call(req, addr, intended_method) \ 1241 __find_call(req, addr, intended_method, __FILE__, __LINE__, __PRETTY_FUNCTION__) 1279 int debug,
int *min_packet_size,
int *max_packet_size);
1291 const char *secret,
const char *md5secret,
int sipmethod,
1337 #define peer_in_destruction(peer) (ao2_ref(peer, 0) == 0) 1389 const char *
name,
int flag,
unsigned int transport);
1448 static const char *
find_alias(
const char *
name,
const char *_default);
1551 static int parse_minse(
const char *p_hdrval,
int *
const p_interval);
1575 .description =
"Session Initiation Protocol (SIP)",
1673 .name =
"call-completion",
1701 if (!(epa_entry =
ao2_t_alloc(
sizeof(*epa_entry), static_data->
destructor,
"Allocate new EPA entry"))) {
1801 expires_ms = expires * 1000;
1843 const char *uri = arg;
1858 const char *uri = arg;
1873 struct sip_pvt *call_pvt = arg;
2025 return monitor_instance->
core_id;
2049 ao2_t_ref(monitor_instance->
suspension_entry, -1,
"Decrementing suspension entry refcount in sip_monitor_instance_destructor");
2058 if (!monitor_instance) {
2063 ao2_ref(monitor_instance, -1);
2071 ao2_link(sip_monitor_instances, monitor_instance);
2072 return monitor_instance;
2108 if (!monitor_instance) {
2129 ao2_t_ref(monitor, +1,
"Adding a ref to the monitor for the scheduler");
2144 ast_str_append(&body, 0,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
2151 ast_str_append(&body, 0,
"<presence xmlns=\"urn:ietf:params:xml:ns:pidf\" entity=\"%s\">\n", presentity);
2153 ast_str_append(&body, 0,
"<status><basic>%s</basic></status>\n", state ==
CC_OPEN ?
"open" :
"closed");
2166 if (!monitor_instance) {
2174 ao2_ref(monitor_instance, -1);
2177 if (!(cc_entry =
ast_calloc(1,
sizeof(*cc_entry)))) {
2178 ast_log(
LOG_WARNING,
"Unable to allocate space for instance data of EPA entry for call-completion\n");
2179 ao2_ref(monitor_instance, -1);
2216 if (!monitor_instance) {
2237 if (*sched_id != -1) {
2239 ao2_t_ref(monitor, -1,
"Removing scheduler's reference to the monitor");
2247 ao2_unlink(sip_monitor_instances, monitor_instance);
2257 static const char cc_purpose[] =
"purpose=call-completion";
2258 static const int cc_purpose_len =
sizeof(cc_purpose) - 1;
2265 uri =
strsep(&call_info,
";");
2267 while ((purpose =
strsep(&call_info,
";"))) {
2268 if (!strncmp(purpose, cc_purpose, cc_purpose_len)) {
2278 while ((service_str =
strsep(&call_info,
";"))) {
2279 if (!strncmp(service_str,
"m=", 2)) {
2292 strsep(&service_str,
"=");
2363 ao2_ref(monitor_instance, -1);
2388 .name =
"SIP TCP server",
2399 .name =
"SIP TLS server",
2406 #define append_history(p, event, fmt , args... ) append_history_full(p, "%-15s " fmt, event, ## args) 2415 for (cur = table; cur->
s; cur++) {
2430 for (cur = table; cur->
s; cur++) {
2431 if (!strcasecmp(cur->
s, s)) {
2461 && !strchr(
"-.!%*_+`'~", *str)) {
2481 code = reason->
code;
2498 #define check_request_transport(peer, tmpl) ({ \ 2500 if (peer->socket.type == tmpl->socket.type) \ 2502 else if (!(peer->transports & tmpl->socket.type)) {\ 2503 ast_log(LOG_ERROR, \ 2504 "'%s' is not a valid transport for '%s'. we only use '%s'! ending call.\n", \ 2505 sip_get_transport(tmpl->socket.type), peer->name, get_transport_list(peer->transports) \ 2508 } else if (peer->socket.type & AST_TRANSPORT_TLS) { \ 2509 ast_log(LOG_WARNING, \ 2510 "peer '%s' HAS NOT USED (OR SWITCHED TO) TLS in favor of '%s' (but this was allowed in sip.conf)!\n", \ 2511 peer->name, sip_get_transport(tmpl->socket.type) \ 2515 "peer '%s' has contacted us over %s even though we prefer %s.\n", \ 2516 peer->name, sip_get_transport(tmpl->socket.type), sip_get_transport(peer->socket.type) \ 2529 for (v = src ; v ; v = v->
next) {
2575 ao2_t_ref(packet, -1,
"thread destruction, removing packet from frame queue");
2595 ao2_t_ref(th, -1,
"Failed to open alert pipe on sip_threadinfo");
2596 ast_log(
LOG_ERROR,
"Could not create sip alert pipe in tcptls thread, error %s\n", strerror(
errno));
2599 ao2_t_ref(tcptls_session, +1,
"tcptls_session ref for sip_threadinfo object");
2602 ao2_t_link(threadt, th,
"Adding new tcptls helper thread");
2603 ao2_t_ref(th, -1,
"Decrementing threadinfo ref from alloc, only table ref remains");
2614 .tcptls_session = tcptls_session,
2618 if (!tcptls_session) {
2624 if (!tcptls_session->
stream ||
2627 goto tcptls_write_setup_error;
2630 if (!(th =
ao2_t_find(threadt, &tmp,
OBJ_POINTER,
"ao2_find, getting sip_threadinfo in tcp helper thread"))) {
2632 goto tcptls_write_setup_error;
2643 if (write(th->
alert_pipe[1], &alert,
sizeof(alert)) == -1) {
2645 ao2_t_ref(packet, -1,
"could not write to alert pipe, remove packet");
2654 ao2_t_ref(th, -1,
"In sip_tcptls_write, unref threadinfo object after finding it");
2657 tcptls_write_setup_error:
2659 ao2_t_ref(th, -1,
"In sip_tcptls_write, unref threadinfo obj, could not create packet");
2662 ao2_t_ref(packet, -1,
"could not allocate packet's data");
2692 uint64_t payload_len;
2703 char data[payload_len + 1];
2709 strncpy(data, payload, payload_len);
2710 data[payload_len] =
'\0';
2744 if(time(&now) == -1) {
2791 char *content_length_str;
2792 int content_length = -1;
2810 if ((content_length_str =
strcasestr(msg,
"\nContent-Length:"))) {
2811 content_length_str +=
sizeof(
"\nContent-Length:") - 1;
2812 }
else if ((content_length_str =
strcasestr(msg,
"\nl:"))) {
2813 content_length_str +=
sizeof(
"\nl:") - 1;
2824 if (!strchr(content_length_str,
'\n')) {
2828 if (sscanf(content_length_str,
"%30d", &content_length) != 1) {
2829 content_length = -1;
2834 return content_length;
2862 body = strstr(message,
"\r\n\r\n");
2869 body +=
sizeof(
"\r\n\r\n") - 1;
2870 body_len = message_len - (body - message);
2876 if (content_length < 0) {
2878 }
else if (content_length == 0) {
2883 if (body_len == 0) {
2894 if (body_len < content_length) {
2897 }
else if (body_len > content_length) {
2919 int authenticated, time_t start)
2930 if (!tcptls_session->
client && !authenticated) {
2936 ast_debug(2,
"SIP TCP/TLS server timed out\n");
2944 ast_debug(2,
"SIP TCP/TLS server :: ast_wait_for_input returned %d\n", res);
2946 }
else if (res == 0) {
2947 ast_debug(2,
"SIP TCP/TLS server timed out\n");
2956 ast_debug(2,
"SIP TCP/TLS server error when receiving data\n");
2958 }
else if (res == 0) {
2959 ast_debug(2,
"SIP TCP/TLS server has shut down\n");
2962 readbuf[res] =
'\0';
2971 ast_log(
LOG_WARNING,
"Rejecting TCP/TLS packet from '%s' because way too large: %zu\n",
2987 int res,
timeout = -1, authenticated = 0, flags;
2989 struct sip_request req = { 0, } , reqcpy = { 0, };
2991 char buf[1024] =
"";
2992 struct pollfd fds[2] = { { 0 }, { 0 }, };
3006 if (!tcptls_session->
client) {
3017 ao2_t_ref(me, +1,
"Adding threadinfo ref for tcp_helper_thread");
3020 .tcptls_session = tcptls_session,
3023 if ((!(ca = tcptls_session->
parent)) ||
3024 (!(me =
ao2_t_find(threadt, &tmp,
OBJ_POINTER,
"ao2_find, getting sip_threadinfo in tcp helper thread")))) {
3046 fds[0].events = fds[1].events = POLLIN | POLLPRI;
3055 if(time(&start) == -1) {
3079 if (!tcptls_session->
client && !authenticated ) {
3097 }
else if (res == 0) {
3112 str_save = req.
data;
3113 memset(&req, 0,
sizeof(req));
3114 req.
data = str_save;
3117 str_save = reqcpy.data;
3118 memset(&reqcpy, 0,
sizeof(reqcpy));
3119 reqcpy.data = str_save;
3122 memset(buf, 0,
sizeof(buf));
3141 if (fds[1].revents) {
3147 if (read(me->
alert_pipe[0], &alert,
sizeof(alert)) == -1) {
3158 ast_log(
LOG_WARNING,
"TCPTLS thread alert_pipe indicated packet should be sent, but frame_q is empty\n");
3166 ao2_t_ref(packet, -1,
"tcptls packet sent, this is no longer needed");
3181 if (tcptls_session && !tcptls_session->
client && !authenticated) {
3186 ao2_t_unlink(threadt, me,
"Removing tcptls helper thread, thread is closing");
3187 ao2_t_ref(me, -1,
"Removing tcp_helper_threads threadinfo ref");
3194 ao2_t_ref(ca, -1,
"closing tcptls thread, getting rid of client tcptls_session arguments");
3197 if (tcptls_session) {
3204 tcptls_session =
NULL;
3215 if (peer->
expire != -1) {
3314 while ((cp = dialog->
packets)) {
3318 ao2_t_ref(cp, -1,
"Stop scheduled packet retransmission"));
3319 ao2_t_ref(cp, -1,
"Packet retransmission list");
3336 dialog_unref(dialog,
"Stop scheduled request_queue_sched_id"));
3339 dialog_unref(dialog,
"Stop scheduled provisional keepalive"));
3353 struct sip_pvt *dialog = (
void *) data;
3356 dialog_unref(dialog,
"Stop scheduled items for unlink action");
3371 dialog_ref(dialog,
"Let's bump the count in the unlink so it doesn't accidentally become dead before we are done");
3373 ao2_t_unlink(dialogs, dialog,
"unlinking dialog via ao2_unlink");
3374 ao2_t_unlink(dialogs_needdestroy, dialog,
"unlinking dialog_needdestroy via ao2_unlink");
3375 ao2_t_unlink(dialogs_rtpcheck, dialog,
"unlinking dialog_rtpcheck via ao2_unlink");
3406 dialog_ref(dialog,
"Stop scheduled items for unlink action");
3412 dialog_unref(dialog,
"Failed to schedule stop scheduled items for unlink action");
3416 dialog_unref(dialog,
"Let's unbump the count in the unlink so the poor pvt can disappear if it is time");
3420 __attribute__((
format(printf, 2, 3)));
3426 return map_x_s(referstatusstrings, rstatus,
"");
3434 append_history(pvt,
"NeedDestroy",
"Setting needdestroy because %s", reason);
3437 ao2_t_link(dialogs_needdestroy, pvt,
"link pvt into dialogs_needdestroy container");
3447 ast_debug(1,
"Initializing already initialized SIP dialog %s (presumably reinvite)\n", p->
callid);
3462 ast_debug(3,
"Setting SIP_ALREADYGONE on dialog %s\n", dialog->
callid);
3493 char *mutable_proxy, *sep, *
name;
3507 sep = strchr(mutable_proxy,
',');
3522 dest->
name[0] =
'\0';
3540 int port = standard;
3541 if (
ast_strlen_zero(pt) || (sscanf(pt,
"%30d", &port) != 1) || (port < 1) || (port > 65535)) {
3553 ast_debug(1,
"OBPROXY: Applying dialplan set OBproxy to this call\n");
3560 ast_debug(1,
"OBPROXY: Applying peer OBproxy to this call\n");
3567 ast_debug(1,
"OBPROXY: Applying global OBproxy to this call\n");
3573 ast_debug(1,
"OBPROXY: Not applying OBproxy to this call\n");
3587 int l_name = name ? strlen(name) : 0;
3589 return (l_name >= len && name && name[len] < 33 &&
3666 if (!strcasecmp(transport,
"udp")) {
3669 if (!strcasecmp(transport,
"tcp")) {
3672 if (!strcasecmp(transport,
"tls")) {
3675 if (!strcasecmp(transport,
"ws")) {
3678 if (!strcasecmp(transport,
"wss")) {
3718 buf[strlen(buf) - 1] = 0;
3825 ast_debug(2,
"Socket type is TCP but no tcptls_session is present to write to\n");
3853 snprintf(p->
via,
sizeof(p->
via),
"SIP/2.0/%s %s;branch=z9hG4bK%08x%s",
3856 (
unsigned)p->
branch, rport);
3892 "but we're using IPv6, which doesn't need it. Please " 3893 "remove \"localnet\" and/or \"externaddr\" settings.\n");
3896 want_remap = localaddr &&
3944 ast_debug(1,
"Target address %s is not local, substituting externaddr\n",
3992 vsnprintf(buf,
sizeof(buf), fmt, ap);
3994 l = strlen(buf) + 1;
3995 if (!(hist =
ast_calloc(1,
sizeof(*hist) + l))) {
3998 if (!p->history && !(p->history =
ast_calloc(1,
sizeof(*p->history)))) {
4002 memcpy(hist->
event, buf, l);
4006 p->history_entries--;
4010 p->history_entries++;
4066 ast_debug(4,
"SIP TIMER: Not rescheduling id #%d:%s (Method %d) (No timer T1)\n",
4075 ast_debug(4,
"SIP TIMER: Rescheduling retransmission #%d (%d) %s - %d\n",
4101 reschedule = siptimer_a;
4102 ast_debug(4,
"** SIP timers: Rescheduling retransmission %d to %d ms (t1 %d ms (Retrans id #%d)) \n",
4112 ast_verbose(
"Retransmitting #%d (%s) to %s:\n%s\n---\n",
4127 if (reschedule >= diff) {
4143 ast_log(
LOG_WARNING,
"Retransmission timeout reached on transmission %s for seqno %u (%s %s) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions\n" 4144 "Packet timed out after %dms with no response\n",
4147 pkt->
is_fatal ?
"Critical" :
"Non-critical",
4148 pkt->
is_resp ?
"Response" :
"Request",
4152 ast_log(
LOG_WARNING,
"Cancelling retransmit of OPTIONs (call id %s) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions\n", pkt->
owner->
callid);
4167 ast_log(
LOG_WARNING,
"Hanging up call %s - no reply to our critical packet (see https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions).\n", pkt->
owner->
callid);
4216 append_history(pkt->
owner,
"ByeFailure",
"Remote peer doesn't respond to bye. Destroying call anyway.");
4225 ao2_t_ref(pkt, -1,
"Packet retransmission list (retransmission complete)");
4236 ao2_t_ref(pkt, -1,
"Scheduled packet retransmission complete");
4243 struct sip_pkt *pkt = (
void *) data;
4246 ao2_t_ref(pkt, -1,
"Stop scheduled packet retransmission"));
4247 ao2_t_ref(pkt, -1,
"Stop packet retransmission action");
4253 ao2_t_ref(pkt, +1,
"Stop packet retransmission action");
4256 ao2_t_ref(pkt, -1,
"Failed to schedule stop packet retransmission action");
4262 struct sip_pkt *pkt = (
void *) vdoomed;
4294 ao2_t_ref(pkt, -1,
"Failed to initialize");
4303 pkt->
owner =
dialog_ref(p,
"__sip_reliable_xmit: setting pkt->owner");
4331 ao2_t_ref(pkt, +1,
"Schedule packet retransmission");
4334 ao2_t_ref(pkt, -1,
"Failed to schedule packet retransmission");
4338 ast_debug(4,
"*** SIP TIMER: Initializing retransmit timer on packet: Id #%d\n", pkt->
retransid);
4345 ast_log(
LOG_ERROR,
"Serious Network Trouble; __sip_xmit returns error for pkt data\n");
4350 ao2_t_ref(pkt, -1,
"Packet retransmission list");
4383 ast_debug(3,
"Re-scheduled destruction of SIP subscription %s\n", p->
callid ? p->
callid :
"<unknown>");
4390 char method_str[31];
4394 if (sscanf(p->
lastmsg,
"Tx: %30s", method_str) == 1 || sscanf(p->
lastmsg,
"Rx: %30s", method_str) == 1) {
4412 "Autodestruct on dialog '%s' with owner %s in place (Method: %s). Rescheduling destruction for 10000 ms\n",
4425 ast_debug(3,
"Finally hanging up channel after transfer: %s\n", p->
callid);
4455 struct sip_pvt *pvt = (
void *) data;
4473 dialog_unref(pvt,
"Failed to schedule cancel destroy action");
4488 int ms = sched_data->
ms;
4528 ast_verbose(
"Scheduling destruction of SIP dialog '%s' in %d ms (Method: %s)\n",
4532 sched_data =
ast_malloc(
sizeof(*sched_data));
4537 sched_data->
pvt = p;
4538 sched_data->
ms = ms;
4573 const char *msg =
"Not Found";
4585 for (cur = p->
packets; cur; prev = cur, cur = cur->
next) {
4598 ast_debug(4,
"** SIP TIMER: Cancelling retransmit of packet (reply received) Retransid #%d\n", cur->
retransid);
4604 ao2_t_ref(cur, -1,
"Packet retransmission list");
4608 ast_debug(1,
"Stopping retransmission on '%s' of %s %u: Match %s\n",
4609 p->
callid, resp ?
"Response" :
"Request", seqno, msg);
4650 ast_debug(1,
"(Provisional) Stopping retransmission (but retaining packet) on '%s' %s %u: %s\n", p->
callid, resp ?
"Response" :
"Request", seqno, res == -1 ?
"Not Found" :
"Found");
4674 const char *msg =
NULL;
4681 msg =
"183 Session Progress";
4702 dialog_unref(pvt,
"Schedule provisional keepalive complete");
4718 struct sip_pvt *pvt = (
void *) data;
4727 dialog_unref(pvt,
"Stop scheduled provisional keepalive for update"));
4732 dialog_ref(pvt,
"Schedule provisional keepalive");
4737 dialog_unref(pvt,
"Failed to schedule provisional keepalive");
4742 dialog_unref(pvt,
"Update provisional keepalive action");
4749 struct sip_pvt *pvt = (
void *) data;
4757 struct sip_pvt *pvt = (
void *) data;
4764 dialog_ref(pvt,
"Update provisional keepalive action");
4768 dialog_unref(pvt,
"Failed to schedule update provisional keepalive action");
4775 struct sip_pvt *pvt = (
void *) data;
4778 dialog_unref(pvt,
"Stop scheduled provisional keepalive"));
4779 dialog_unref(pvt,
"Stop provisional keepalive action");
4785 dialog_ref(pvt,
"Stop provisional keepalive action");
4788 dialog_unref(pvt,
"Failed to schedule stop provisional keepalive action");
4830 ast_verbose(
"\n<--- %sTransmitting (%s) to %s --->\n%s\n<------------>\n",
4945 ast_log(
LOG_ERROR,
"Attempt to Ref a null pointer. sip private structure is gone!\n");
4965 char *cp = (
char *) data;
5002 ast_debug(1,
"Attempt to Ref a null pointer. Sip private structure is gone!\n");
5040 *cp = p->
dsp ? 1 : 0;
5076 char last_char =
'\0';
5078 for (s = start; *s && s != lim; last_char = *s++) {
5079 if (*s ==
'"' && last_char !=
'\\')
5144 ast_debug(2,
"Trying to send MESSAGE to device that does not support it.\n");
5167 static void realtime_update_peer(
const char *
peername,
struct ast_sockaddr *addr,
const char *defaultuser,
const char *fullcontact,
const char *useragent,
int expirey,
unsigned short deprecated_username,
int lastms,
const char *path)
5170 char ipaddr[INET6_ADDRSTRLEN];
5171 char regseconds[20];
5172 char *tablename =
NULL;
5173 char str_lastms[20];
5176 char *syslabel =
NULL;
5178 time_t nowtime = time(
NULL) + expirey;
5179 const char *fc = fullcontact ?
"fullcontact" :
NULL;
5183 tablename = realtimeregs ?
"sipregs" :
"sippeers";
5185 snprintf(str_lastms,
sizeof(str_lastms),
"%d", lastms);
5186 snprintf(regseconds,
sizeof(regseconds),
"%d", (
int)nowtime);
5193 syslabel =
"regserver";
5207 "port", port,
"regseconds", regseconds,
5208 deprecated_username ?
"username" :
"defaultuser", defaultuser,
5209 "useragent", useragent,
"lastms", str_lastms,
5211 fc, fullcontact, syslabel, sysname,
SENTINEL);
5214 "port", port,
"regseconds", regseconds,
5215 "useragent", useragent,
"lastms", str_lastms,
5216 deprecated_username ?
"username" :
"defaultuser", defaultuser,
5223 "port", port,
"regseconds", regseconds,
5224 deprecated_username ?
"username" :
"defaultuser", defaultuser,
5225 "useragent", useragent,
"lastms", str_lastms,
5226 fc, fullcontact, syslabel, sysname,
SENTINEL);
5229 "port", port,
"regseconds", regseconds,
5230 "useragent", useragent,
"lastms", str_lastms,
5231 deprecated_username ?
"username" :
"defaultuser", defaultuser,
5253 while ((ext =
strsep(&stringp,
"&"))) {
5254 if ((context = strchr(ext,
'@'))) {
5257 ast_log(
LOG_WARNING,
"Context %s must exist in regcontext= in sip.conf!\n", context);
5283 #define REMOVE_MAILBOX_WITH_LOCKED_PEER(__peer) \ 5285 struct sip_mailbox *__mailbox;\ 5287 __mailbox = AST_LIST_REMOVE_HEAD(&(__peer->mailboxes), entry);\ 5288 ao2_unlock(__peer);\ 5401 const char *insecure;
5438 const char *regname;
5459 if (!strcasecmp(regname, peername)) {
5496 for (tmp = var;
tmp; tmp = tmp->
next) {
5497 if (!strcasecmp(tmp->
name,
"name")) {
5527 for (tmp = *var;
tmp; tmp = tmp->
next) {
5528 if (!strcasecmp(tmp->
name,
"host")) {
5565 const char *old_name = *
name;
5628 if (varregs && *varregs) {
5638 if (varregs && !*varregs) {
5668 sip_unref_peer(peer,
"register_realtime_peers: Done registering releasing");
5690 char ipaddr[INET6_ADDRSTRLEN];
5701 }
else if (addr &&
realtime_peer_by_addr(&newpeername, addr, ipaddr, callbackexten, &var, realtimeregs ? &varregs : NULL)) {
5711 for (tmp = var;
tmp; tmp = tmp->
next) {
5712 if (!strcasecmp(tmp->
name,
"type") && (!strcasecmp(tmp->
value,
"peer"))) {
5719 peer =
build_peer(newpeername, var, varregs,
TRUE, devstate_only);
5726 if (peer->
type == 0) {
5729 }
else if (which_objects ==
FINDPEERS) {
5736 ast_debug(3,
"-REALTIME- loading peer from database to memory. Name: %s. Peer objects: %d\n", peer->
name,
rpeerobjs);
5747 ao2_t_link(peers, peer,
"link peer into peers table");
5749 ao2_t_link(peers_by_ip, peer,
"link peer into peers_by_ip table");
5764 int *which_objects = data;
5767 if (strcmp(search->
name, match->name)) {
5771 switch (*which_objects) {
5811 if (!p && (realtime || devstate_only)) {
5814 p =
realtime_peer(peer, addr, callbackexten, devstate_only, which_objects);
5816 switch (which_objects) {
5868 mode = natflags ?
"On" :
"Off";
5871 ast_debug(1,
"Setting NAT on RTP to %s\n", mode);
5875 ast_debug(1,
"Setting NAT on VRTP to %s\n", mode);
5879 ast_debug(1,
"Setting NAT on UDPTL to %s\n", mode);
5883 ast_debug(1,
"Setting NAT on TRTP to %s\n", mode);
5968 *to_sock = *from_sock;
6018 ast_log(
LOG_ERROR,
"No DTLS-SRTP support present on engine for RTP instance '%p', was it compiled with support for it?\n",
6024 ast_log(
LOG_ERROR,
"Attempted to set an invalid DTLS-SRTP configuration on RTP instance '%p'\n",
6030 ast_log(
LOG_ERROR,
"Failed to create required SRTP structure on RTP instance '%p'\n",
6150 dialog->
recv = dialog->
sa;
6223 credentials = peer->
auth;
6225 ao2_t_ref(credentials, +1,
"Ref peer auth for dialog");
6246 new_callid = strchr(tmpcall,
'@');
6253 callid_size = strlen(tmpcall) + strlen(peer->
fromdomain) + 2;
6255 snprintf(new_callid, callid_size,
"%s@%s", tmpcall, peer->
fromdomain);
6320 char *
peername, *peername2, *hostn;
6349 sip_unref_peer(peer,
"create_addr: unref peer from sip_find_peer hashtab lookup");
6355 ast_log(
LOG_WARNING,
"Purely numeric hostname (%s), and not a peer--rejecting!\n", peername);
6387 snprintf(service,
sizeof(service),
"_%s._%s.%s",
6438 dialog_unref(p,
"unreffing arg passed into auto_congest callback (p->initid)");
6451 const char *referer =
NULL;
6468 ao2_t_ref(recall_monitor, -1,
"Got the URI we need so unreffing monitor");
6483 }
else if (!strcmp(
ast_var_name(current),
"SIPFROMDOMAIN")) {
6485 }
else if (!strcmp(
ast_var_name(current),
"SIPTRANSFER")) {
6488 }
else if (!strcmp(
ast_var_name(current),
"SIPTRANSFER_REFERER")) {
6491 }
else if (!strcmp(
ast_var_name(current),
"SIPTRANSFER_REPLACES")) {
6494 }
else if (!strcmp(
ast_var_name(current),
"SIP_MAX_FORWARDS")) {
6496 ast_log(
LOG_WARNING,
"The SIP_MAX_FORWARDS channel variable is not a valid integer.\n");
6510 ast_debug(1,
"Direct media not possible when using SRTP, ignoring canreinvite setting\n");
6544 snprintf(buf,
sizeof(buf)-1,
"-> %s (via %s)", p->
cid_name, referer);
6546 snprintf(buf,
sizeof(buf)-1,
"-> %s", p->
cid_name);
6586 memset(&update_connected, 0,
sizeof(update_connected));
6597 update_connected.
id.
name = 1;
6620 dialog_unref(_data,
"dialog ptr dec when SCHED_REPLACE del op succeeded"),
6621 dialog_unref(p,
"dialog ptr dec when SCHED_REPLACE add failed"),
6622 dialog_ref(p,
"dialog ptr inc when SCHED_REPLACE add succeeded") );
6689 ast_debug(2,
"This call did not properly clean up call limits. Call ID %s\n", p->
callid);
6851 ast_debug(3,
"Updating call counter for %s call\n", outgoing ?
"outgoing" :
"incoming");
6870 ast_debug(2,
"%s is not a local device, no call limit\n", name);
6922 ast_debug(2,
"Call %s %s '%s' removed from call limit %d\n", outgoing ?
"to" :
"from",
"peer", name, *call_limit);
6928 if (*call_limit > 0 ) {
6929 if (*inuse >= *call_limit) {
6930 ast_log(
LOG_NOTICE,
"Call %s %s '%s' rejected due to usage limit of %d\n", outgoing ?
"to" :
"from",
"peer", name, *call_limit);
6931 sip_unref_peer(p,
"update_call_counter: unref peer p, call limit exceeded");
6956 ast_debug(2,
"Call %s %s '%s' is %d out of %d\n", outgoing ?
"to" :
"from",
"peer", name, *inuse, *call_limit);
6976 ast_log(
LOG_ERROR,
"update_call_counter(%s, %d) called with no event!\n", name, event);
6980 sip_unref_peer(p,
"update_call_counter: sip_unref_peer from call counter");
7060 if (cause < 500 && cause >= 400) {
7063 }
else if (cause < 600 && cause >= 500) {
7066 }
else if (cause < 700 && cause >= 600) {
7114 return "404 Not Found";
7117 return "503 Service Unavailable";
7119 return "408 Request Timeout";
7122 return "480 Temporarily unavailable";
7124 return "403 Forbidden";
7128 return "480 Temporarily unavailable";
7130 return "484 Address incomplete";
7132 return "486 Busy here";
7134 return "500 Server internal failure";
7136 return "501 Not Implemented";
7138 return "503 Service Unavailable";
7141 return "502 Bad Gateway";
7143 return "488 Not Acceptable Here";
7145 return "500 Network error";
7149 ast_debug(1,
"AST hangup cause %d (no match found in SIP)\n", cause);
7178 struct sip_pvt *pvt = (
void *) data;
7191 dialog_unref(pvt,
"Failed to schedule stop reinviteid action");
7200 int needcancel =
FALSE;
7201 int needdestroy = 0;
7205 ast_debug(1,
"Asked to hangup channel that was not connected\n");
7209 ast_debug(1,
"This call was answered elsewhere\n");
7221 ast_debug(1,
"update_call_counter(%s) - decrement call limit counter on hangup\n", p->
username);
7224 ast_debug(4,
"SIP Transfer: Not hanging up right now... Rescheduling hangup for %s.\n", p->
callid);
7229 oldowner = p->
owner;
7243 ast_debug(1,
"update_call_counter(%s) - decrement call limit counter on hangup\n", p->
username);
7248 if (p->
owner != ast) {
7292 append_history(p,
"DELAY",
"Not sending cancel, waiting for timeout");
7408 char *codec_list_copy;
7411 int first_codec = 1;
7428 if (!original_jointcaps) {
7433 for (codec = strtok_r(codec_list_copy,
",", &strtok_ptr); codec; codec = strtok_r(
NULL,
",", &strtok_ptr)) {
7440 ast_log(
AST_LOG_NOTICE,
"Ignoring ${SIP_CODEC*} variable because of unrecognized/not configured codec %s (check allow/disallow in sip.conf)\n", codec);
7445 ast_verb(4,
"Set codec to '%s' for this call because of ${SIP_CODEC*} variable\n", codec);
7452 ast_verb(4,
"Add codec to '%s' for this call because of ${SIP_CODEC*} variable\n", codec);
7458 ast_log(
AST_LOG_NOTICE,
"Ignoring ${SIP_CODEC*} variable because it is not shared by both ends: %s\n", codec);
7469 ao2_ref(original_jointcaps, -1);
7483 ast_debug(1,
"Asked to answer channel %s without tech pvt; ignoring\n",
7520 ast_log(
LOG_WARNING,
"Asked to transmit frame type %s, while native formats is %s read/write = %s/%s\n",
7533 }
else if (p->
rtp) {
7634 ast_debug(1,
"New channel is zombie\n");
7636 ast_debug(1,
"Old channel is zombie\n");
7650 if (p->
owner != oldchan)
7675 ast_debug(1,
"Asked to begin DTMF digit on channel %s with no pvt; ignoring\n",
7705 ast_debug(1,
"Asked to end DTMF digit on channel %s with no pvt; ignoring\n",
7736 ast_debug(1,
"Asked to transfer channel %s with no pvt; ignoring\n",
7885 ast_debug(1,
"Setting NAT on UDPTL to %s\n", natflags ?
"On" :
"Off");
7900 const char *content_type,
7901 const char *content,
7902 const char *useragent_filter)
7928 for (var = headers;
var; var = var->
next) {
7932 add_header(&req,
"Content-Type", content_type);
7954 ast_debug(1,
"Asked to indicate condition on channel %s with no pvt; ignoring\n",
8179 const char *my_name;
8191 tmp =
ast_channel_alloc_with_endpoint(1, state, i->
cid_num, i->
cid_name, i->
accountcode, i->
exten, i->
context, assignedids, requestor, i->
amaflags, i->
relatedpeer->
endpoint,
"SIP/%s-%08x", my_name, (
unsigned)
ast_atomic_fetchadd_int((
int *)&
chan_idx, +1));
8193 tmp =
ast_channel_alloc(1, state, i->
cid_num, i->
cid_name, i->
accountcode, i->
exten, i->
context, assignedids, requestor, i->
amaflags,
"SIP/%s-%08x", my_name, (
unsigned)
ast_atomic_fetchadd_int((
int *)&
chan_idx, +1));
8285 ast_debug(3,
"This channel can handle video! HOLLYWOOD next!\n");
8287 ast_debug(3,
"This channel will not be able to handle video.\n");
8316 if (needvideo && i->
vrtp) {
8324 if (needtext && i->
trtp) {
8355 ast_channel_parkinglot_set(tmp, i->
parkinglot);
8364 ast_channel_language_set(tmp, i->
language);
8369 ast_log(
LOG_ERROR,
"Unknown country code '%s' for tonezone. Check indications.conf for available country codes.\n", i->
zone);
8427 char valuebuf[1024];
8446 int len = strlen(name);
8451 if (!strncasecmp(line, name, len) && line[len] ==
'=') {
8470 const char *line =
NULL;
8476 while (*start < stop) {
8478 if (line[1] ==
'=') {
8492 int len = strlen(name);
8495 for (i = 0; i < req->
lines; i++) {
8497 if (!strncasecmp(line, name, len) && line[len] == delimiter) {
8511 {
"Content-Type",
"c" },
8512 {
"Content-Encoding",
"e" },
8516 {
"Content-Length",
"l" },
8519 {
"Supported",
"k" },
8520 {
"Refer-To",
"r" },
8521 {
"Referred-By",
"b" },
8522 {
"Allow-Events",
"u" },
8525 {
"Accept-Contact",
"a" },
8526 {
"Reject-Contact",
"j" },
8527 {
"Request-Disposition",
"d" },
8528 {
"Session-Expires",
"x" },
8529 {
"Identity",
"y" },
8530 {
"Identity-Info",
"n" },
8538 for (x = 0; x <
ARRAY_LEN(aliases); x++) {
8539 if (!strcasecmp(aliases[x].fullname, name))
8540 return aliases[x].shortname;
8551 if (strlen(name) == 1) {
8553 for (x = 0; x <
ARRAY_LEN(aliases); ++x) {
8554 if (!strcasecmp(aliases[x].shortname, name))
8555 return aliases[x].fullname;
8572 int x,
len = strlen(name), slen = (sname ? 1 : 0);
8573 for (x = *start; x < req->
headers; x++) {
8575 int smatch = 0,
match = !strncasecmp(header, name, len);
8577 smatch = !strncasecmp(header, sname, slen);
8579 if (
match || smatch) {
8581 const char *r = header + (
match ?
len : slen );
8583 while (*r ==
' ' || *r ==
'\t') {
8621 for (i = 0; i < req->
lines; i++) {
8659 unsigned char* arr = f->
data.
ptr;
8664 for (i = 0; i < f->
datalen; i++) {
8665 ast_str_append(&out, 0,
"%c", (arr[i] >
' ' && arr[i] <
'}') ? arr[i] :
'.');
8668 for (i = 0; i < f->
datalen; i++) {
8699 ast_debug(1,
"Bogus frame of format '%s' received from '%s'!\n",
8704 ast_debug(1,
"Oooh, format changed to %s\n",
8746 int faxdetected =
FALSE;
8804 snprintf(buf, size,
"%08lx%08lx%08lx%08lx", (
unsigned long)val[0], (
unsigned long)val[1], (
unsigned long)val[2], (
unsigned long)val[3]);
8838 #define CONTAINER_UNLINK(container, obj, tag) \ 8841 typeof((obj)) __removed_obj; \ 8842 __removed_obj = ao2_t_callback((container), \ 8843 OBJ_UNLINK | OBJ_POINTER, ao2_match_by_addr, (obj), (tag)); \ 8844 if (__removed_obj) { \ 8845 ao2_ref(__removed_obj, -1); \ 8862 int in_dialog_container;
8863 int in_rtp_container;
8869 "About to change the callid -- remove the old name");
8871 "About to change the callid -- remove the old name");
8877 if (in_dialog_container) {
8878 ao2_t_link(dialogs, pvt,
"New dialog callid -- inserted back into table");
8880 if (in_rtp_container) {
8881 ao2_t_link(dialogs_rtpcheck, pvt,
"New dialog callid -- inserted back into table");
8886 if (strcmp(oldid, pvt->
callid)) {
8887 ast_debug(1,
"SIP call-id changed from '%s' to '%s'\n", oldid, pvt->
callid);
8944 const char *
file,
int line,
const char *func)
8956 ao2_t_ref(p, -1,
"failed to string_field_init, drop p");
8961 ao2_t_ref(p, -1,
"Yuck, couldn't allocate cc_params struct. Get rid o' p");
8965 if (logger_callid) {
8981 ao2_t_ref(p, -1,
"Yuck, couldn't allocate format capabilities. Get rid o' p");
9017 p->
method = intended_method;
9062 if (useglobal_nat && addr) {
9096 ao2_t_link(dialogs, p,
"link pvt into dialogs table");
9135 setsockopt(
sipsock, IPPROTO_IP, IP_MULTICAST_TTL, &via->
ttl,
sizeof(via->
ttl));
9179 const char *init_ruri =
NULL;
9193 if (strcmp(arg->
fromtag, sip_pvt_ptr->
tag)) {
9208 char invite_branch[32] = { 0, };
9210 snprintf(invite_branch,
sizeof(invite_branch),
"z9hG4bK%08x", (
unsigned)sip_pvt_ptr->
invite_branch);
9224 if ((arg->
respid == 200) &&
9227 !strcmp(invite_branch, arg->
viabranch)) {
9430 if (pvt->
owner == chan) {
9470 const char *
file,
int line,
const char *func)
9484 (sscanf(cseq,
"%30u", &seqno) != 1)) {
9489 req,
"400 Bad Request");
9501 if (
gettag(req,
"To", totag,
sizeof(totag)))
9503 gettag(req,
"From", fromtag,
sizeof(fromtag));
9505 ast_debug(5,
"= Looking for Call ID: %s (Checking %s) --From tag %s --To-tag %s \n", callid, req->
method==
SIP_RESPONSE ?
"To" :
"From", fromtag, totag);
9528 "find_call in dialogs", file, line, func);
9546 "pedantic ao2_find in dialogs",
9601 __ao2_ref(sip_pvt_ptr, -1,
"pvt did not match incoming SIP msg, unref from search.",
9608 dialog_unref(fork_pvt,
"throwing way pvt to fork off of.");
9609 fork_pvt =
dialog_ref(sip_pvt_ptr,
"this pvt has a forked request, save this off to copy information into new dialog\n");
9613 __ao2_ref(sip_pvt_ptr, -1,
"pvt did not match incoming SIP msg, unref from search",
9632 fork_pvt =
dialog_unref(fork_pvt,
"throwing way pvt to fork off of");
9648 if (!(p =
sip_alloc(callid, addr, 1, intended_method, req, logger_callid))) {
9658 ast_debug(4,
"Failed allocating SIP dialog, sending 500 Server internal error and giving up\n");
9664 ast_debug(2,
"Got a request with unsupported SIP method.\n");
9668 ast_debug(2,
"That's odd... Got a request in unknown dialog. Callid %s\n", callid ? callid :
"<unknown>");
9673 ast_debug(2,
"That's odd... Got a response on a call we don't know about. Callid %s\n", callid ? callid :
"<unknown>");
9685 ao2_t_ref(reg, -1,
"throw away found registry");
9698 ao2_t_ref(reg, -1,
"failed to string_field_init, drop reg");
9704 ao2_t_ref(reg, -1,
"failure to parse, unref the reg pointer");
9713 ao2_t_link(registry_list, reg,
"link reg to registry_list");
9714 ao2_t_ref(reg, -1,
"unref the reg pointer");
9736 if ((hostname = strrchr(buf,
'@'))) {
9742 if ((secret = strchr(username,
':'))) {
9744 if ((authuser = strchr(secret,
':'))) {
9749 if ((mailbox = strchr(hostname,
'/'))) {
9754 ast_log(
LOG_WARNING,
"Format for MWI subscription is user[:secret[:authuser]]@host[:port]/mailbox at line %d\n", lineno);
9758 if ((porta = strchr(hostname,
':'))) {
9760 if (!(portnum = atoi(porta))) {
9773 ao2_t_ref(mwi, -1,
"failed to string_field_init, drop mwi");
9789 ao2_t_link(subscription_mwi_list, mwi,
"link new mwi object");
9790 ao2_t_ref(mwi, -1,
"unref to match ao2_t_alloc");
9797 (*allowed_methods) |= (1 <<
method);
9802 (*allowed_methods) &= ~(1 <<
method);
9808 return ((*allowed_methods) >> method) & 1;
9849 char *
methods = strstr(contact,
";methods=");
9868 return allowed_methods;
9900 int just_read_eol = 0;
9901 int done_with_headers = 0;
9905 if (msgbuf[h] ==
'\r') {
9910 if (msgbuf[h] ==
'\n') {
9911 if (just_read_eol) {
9912 done_with_headers = 1;
9920 if (!done_with_headers
9921 && (msgbuf[h + 1] ==
' ' || msgbuf[h + 1] ==
'\t')) {
9927 msgbuf[t++] = msgbuf[h++];
9933 if (!done_with_headers
9934 && (msgbuf[h] ==
' ' || msgbuf[h] ==
'\t')) {
9939 msgbuf[t++] = msgbuf[h++];
9943 msgbuf[t++] = msgbuf[h++];
9957 ptrdiff_t *dst = req->
header;
9960 unsigned int skipping_headers = 0;
9961 ptrdiff_t current_header_offset = 0;
9962 char *previous_header =
"";
9969 }
else if (*c ==
'\n') {
9973 if (skipping_headers) {
9978 skipping_headers = 0;
9980 dst[i] = current_header_offset;
9985 req->
headers < 0 ?
"Header" :
"Body",
9986 i, (
int) strlen(previous_header), previous_header);
10005 skipping_headers = 1;
10009 dst[i] = current_header_offset;
10022 req->
headers < 0 ?
"Header" :
"Body",
10023 i, (
int) strlen(previous_header), previous_header );
10056 const char *content_type;
10057 const char *content_length;
10058 const char *search;
10061 int boundaryisquoted =
FALSE;
10062 int found_application_sdp =
FALSE;
10063 int found_end_of_headers =
FALSE;
10068 if (sscanf(content_length,
"%30u", &x) != 1) {
10082 if (!strncasecmp(content_type,
"application/sdp", 15)) {
10085 return req->
lines ? 1 : 0;
10089 if (strncasecmp(content_type,
"multipart/mixed", 15))
10093 if ((search =
strcasestr(content_type,
";boundary=")))
10095 else if ((search =
strcasestr(content_type,
"; boundary=")))
10104 if (*search ==
'\"') {
10106 boundaryisquoted =
TRUE;
10112 boundary[0] = boundary[1] =
'-';
10114 if (boundaryisquoted)
10115 boundary[strlen(boundary) - 1] =
'\0';
10120 for (x = 0; x < (req->
lines); x++) {
10122 if (!strncasecmp(line, boundary, strlen(boundary))){
10123 if (found_application_sdp && found_end_of_headers) {
10127 found_application_sdp =
FALSE;
10129 if (!strcasecmp(line,
"Content-Type: application/sdp"))
10130 found_application_sdp =
TRUE;
10133 if (found_application_sdp && !found_end_of_headers){
10135 found_end_of_headers =
TRUE;
10139 if (found_application_sdp && found_end_of_headers) {
10164 else if (sendonly == 2)
10187 if (m == offer->
type) {
10199 if (local_rtcp_mux && remote_rtcp_mux) {
10221 if (local_rtcp_mux && remote_rtcp_mux) {
10239 while ((type =
get_sdp_line(&start, next, req, &value)) !=
'\0') {
10240 if (type ==
'a' && !strcasecmp(value, attr)) {
10260 int iterator = start;
10265 const char *m =
NULL;
10266 const char *nextm =
NULL;
10283 int udptlportno = -1;
10290 int peernoncodeccapability = 0, vpeernoncodeccapability = 0, tpeernoncodeccapability = 0;
10297 int newnoncodeccapability;
10300 unsigned int codec;
10303 int secure_audio =
FALSE;
10304 int secure_video =
FALSE;
10307 int remote_rtcp_mux_audio =
FALSE;
10308 int remote_rtcp_mux_video =
FALSE;
10312 unsigned int numberofports;
10313 int last_rtpmap_codec = 0;
10314 int red_data_pt[10];
10315 int red_num_gen = 0;
10316 char red_fmtp[100] =
"empty";
10328 goto process_sdp_cleanup;
10330 if (!peercapability || !vpeercapability || !tpeercapability || !newpeercapability || !newjointcapability) {
10332 goto process_sdp_cleanup;
10338 goto process_sdp_cleanup;
10351 goto process_sdp_cleanup;
10355 while ((type =
get_sdp_line(&iterator, next - 1, req, &value)) !=
'\0') {
10356 int processed =
FALSE;
10364 goto process_sdp_cleanup;
10385 else if (
process_sdp_a_text(value, p, &newtextrtp, red_fmtp, &red_num_gen, red_data_pt, &last_rtpmap_codec))
10422 ast_debug(3,
"Processing session-level SDP %c=%s... %s\n", type, value, (processed ==
TRUE)?
"OK." :
"UNSUPPORTED OR FAILED.");
10435 int processed_crypto =
FALSE;
10436 int rtcp_mux_offered = 0;
10437 char protocol[18] = {0,};
10448 if (!(offer =
ast_calloc(1,
sizeof(*offer)))) {
10451 goto process_sdp_cleanup;
10460 if (p->
rtp && strncmp(m,
"audio ", 6) == 0) {
10461 if ((sscanf(m,
"audio %30u/%30u %17s %n", &x, &numberofports, protocol, &len) == 3 && len > 0) ||
10462 (sscanf(m,
"audio %30u %17s %n", &x, protocol, &len) == 2 && len > 0)) {
10469 goto process_sdp_cleanup;
10472 sprintf(offer->
decline_m_line,
"m=audio 0 %s %s\r\n", protocol, codecs);
10475 ast_debug(1,
"Ignoring audio media offer because port number is zero\n");
10485 if (numberofports > 1) {
10486 ast_log(
LOG_WARNING,
"%u ports offered for audio media, not supported by Asterisk. Will try anyway...\n", numberofports);
10491 ast_log(
LOG_NOTICE,
"Received SAVPF profle in audio offer but AVPF is not enabled, enabling: %s\n", m);
10497 ast_log(
LOG_WARNING,
"Received SAVPF profle in audio answer but AVPF is not enabled: %s\n", m);
10502 ast_log(
LOG_NOTICE,
"Received SAVP profle in audio offer but AVPF is enabled, disabling: %s\n", m);
10507 ast_log(
LOG_WARNING,
"Received SAVP profile in audio offer but AVPF is enabled: %s\n", m);
10510 }
else if (!strcmp(protocol,
"UDP/TLS/RTP/SAVP") || !strcmp(protocol,
"UDP/TLS/RTP/SAVPF")) {
10513 processed_crypto = 1;
10517 }
else if (!strcmp(protocol,
"RTP/SAVP") || !strcmp(protocol,
"RTP/SAVPF")) {
10521 ast_log(
LOG_NOTICE,
"Received AVPF profile in audio offer but AVPF is not enabled, enabling: %s\n", m);
10525 ast_log(
LOG_WARNING,
"Received AVP profile in audio answer but AVPF is enabled: %s\n", m);
10530 ast_log(
LOG_NOTICE,
"Received AVP profile in audio answer but AVPF is enabled, disabling: %s\n", m);
10534 ast_log(
LOG_WARNING,
"Received AVP profile in audio answer but AVPF is enabled: %s\n", m);
10537 }
else if ((!strcmp(protocol,
"UDP/TLS/RTP/SAVP") || !strcmp(protocol,
"UDP/TLS/RTP/SAVPF")) &&
10539 ast_log(
LOG_WARNING,
"Received UDP/TLS in audio offer but DTLS is not enabled: %s\n", m);
10541 }
else if (strcmp(protocol,
"RTP/AVP") && strcmp(protocol,
"RTP/AVPF")) {
10552 if (sscanf(codecs,
"%30u%n", &codec, &len) != 1) {
10555 goto process_sdp_cleanup;
10558 ast_verbose(
"Found RTP audio format %u\n", codec);
10564 ast_log(
LOG_WARNING,
"Rejecting audio media offer due to invalid or unsupported syntax: %s\n", m);
10566 goto process_sdp_cleanup;
10570 else if (p->
vrtp && strncmp(m,
"video ", 6) == 0) {
10571 if ((sscanf(m,
"video %30u/%30u %17s %n", &x, &numberofports, protocol, &len) == 3 && len > 0) ||
10572 (sscanf(m,
"video %30u %17s %n", &x, protocol, &len) == 2 && len > 0)) {
10579 goto process_sdp_cleanup;
10582 sprintf(offer->
decline_m_line,
"m=video 0 %s %s\r\n", protocol, codecs);
10585 ast_debug(1,
"Ignoring video stream offer because port number is zero\n");
10590 if (numberofports > 1) {
10591 ast_log(
LOG_WARNING,
"%u ports offered for video stream, not supported by Asterisk. Will try anyway...\n", numberofports);
10600 ast_log(
LOG_WARNING,
"Received SAVPF profle in video offer but AVPF is not enabled: %s\n", m);
10603 ast_log(
LOG_WARNING,
"Received SAVP profile in video offer but AVPF is enabled: %s\n", m);
10605 }
else if (!strcmp(protocol,
"UDP/TLS/RTP/SAVP") || !strcmp(protocol,
"UDP/TLS/RTP/SAVPF")) {
10608 processed_crypto = 1;
10612 }
else if (!strcmp(protocol,
"RTP/SAVP") || !strcmp(protocol,
"RTP/SAVPF")) {
10615 ast_log(
LOG_WARNING,
"Received AVPF profile in video offer but AVPF is not enabled: %s\n", m);
10618 ast_log(
LOG_WARNING,
"Received AVP profile in video offer but AVPF is enabled: %s\n", m);
10620 }
else if (strcmp(protocol,
"RTP/AVP") && strcmp(protocol,
"RTP/AVPF")) {
10632 if (sscanf(codecs,
"%30u%n", &codec, &len) != 1) {
10635 goto process_sdp_cleanup;
10638 ast_verbose(
"Found RTP video format %u\n", codec);
10643 ast_log(
LOG_WARNING,
"Rejecting video media offer due to invalid or unsupported syntax: %s\n", m);
10645 goto process_sdp_cleanup;
10649 else if (p->
trtp && strncmp(m,
"text ", 5) == 0) {
10650 if ((sscanf(m,
"text %30u/%30u %17s %n", &x, &numberofports, protocol, &len) == 3 && len > 0) ||
10651 (sscanf(m,
"text %30u %17s %n", &x, protocol, &len) == 2 && len > 0)) {
10658 goto process_sdp_cleanup;
10661 sprintf(offer->
decline_m_line,
"m=text 0 %s %s\r\n", protocol, codecs);
10664 ast_debug(1,
"Ignoring text stream offer because port number is zero\n");
10669 if (numberofports > 1) {
10670 ast_log(
LOG_WARNING,
"%u ports offered for text stream, not supported by Asterisk. Will try anyway...\n", numberofports);
10674 ast_log(
LOG_WARNING,
"Received AVPF profile in text offer but AVPF is not enabled: %s\n", m);
10677 ast_log(
LOG_WARNING,
"Received AVP profile in text offer but AVPF is enabled: %s\n", m);
10679 }
else if (strcmp(protocol,
"RTP/AVP") && strcmp(protocol,
"RTP/AVPF")) {
10696 if (sscanf(codecs,
"%30u%n", &codec, &len) != 1) {
10699 goto process_sdp_cleanup;
10702 ast_verbose(
"Found RTP text format %u\n", codec);
10707 ast_log(
LOG_WARNING,
"Rejecting text stream offer due to invalid or unsupported syntax: %s\n", m);
10709 goto process_sdp_cleanup;
10713 else if (strncmp(m,
"image ", 6) == 0) {
10714 if (((sscanf(m,
"image %30u udptl t38%n", &x, &len) == 1 && len > 0) ||
10715 (sscanf(m,
"image %30u UDPTL t38%n", &x, &len) == 1 && len > 0))) {
10721 goto process_sdp_cleanup;
10727 ast_debug(1,
"Ignoring image stream offer because port number is zero\n");
10756 }
else if (sscanf(m,
"image %30u %17s t38%n", &x, protocol, &len) == 2 && len > 0) {
10757 ast_log(
LOG_WARNING,
"Declining image stream due to unsupported transport: %s\n", m);
10763 goto process_sdp_cleanup;
10766 sprintf(offer->
decline_m_line,
"m=image 0 %s t38\r\n", protocol);
10769 ast_log(
LOG_WARNING,
"Rejecting image media offer due to invalid or unsupported syntax: %s\n", m);
10771 goto process_sdp_cleanup;
10774 char type[20] = {0,};
10775 if ((sscanf(m,
"%19s %30u/%30u %n", type, &x, &numberofports, &len) == 3 && len > 0) ||
10776 (sscanf(m,
"%19s %30u %n", type, &x, &len) == 2 && len > 0)) {
10782 goto process_sdp_cleanup;
10790 goto process_sdp_cleanup;
10795 while ((type =
get_sdp_line(&iterator, next - 1, req, &value)) !=
'\0') {
10796 int processed =
FALSE;
10805 }
else if (video) {
10815 }
else if (image) {
10828 processed_crypto =
TRUE;
10836 processed_crypto =
TRUE;
10838 if (secure_audio ==
FALSE) {
10839 ast_log(
AST_LOG_NOTICE,
"Processed audio crypto attribute without SAVP specified; accepting anyway\n");
10840 secure_audio =
TRUE;
10853 processed_crypto =
TRUE;
10859 processed_crypto =
TRUE;
10861 if (secure_video ==
FALSE) {
10862 ast_log(
AST_LOG_NOTICE,
"Processed video crypto attribute without SAVP specified; accepting anyway\n");
10863 secure_video =
TRUE;
10875 }
else if (
process_sdp_a_text(value, p, &newtextrtp, red_fmtp, &red_num_gen, red_data_pt, &last_rtpmap_codec)) {
10878 processed_crypto =
TRUE;
10890 ast_debug(3,
"Processing media-level (%s) SDP %c=%s... %s\n",
10891 (audio ==
TRUE)?
"audio" : (video ==
TRUE)?
"video" : (text ==
TRUE)?
"text" :
"image",
10893 (processed ==
TRUE)?
"OK." :
"UNSUPPORTED OR FAILED.");
10897 if (audio && secure_audio && !processed_crypto) {
10898 ast_log(
LOG_WARNING,
"Rejecting secure audio stream without encryption details: %s\n", m);
10900 goto process_sdp_cleanup;
10901 }
else if (video && secure_video && !processed_crypto) {
10902 ast_log(
LOG_WARNING,
"Rejecting secure video stream without encryption details: %s\n", m);
10904 goto process_sdp_cleanup;
10909 if (!sa && !vsa && !tsa && !isa) {
10912 goto process_sdp_cleanup;
10915 if ((portno == -1) &&
10918 (udptlportno == -1)) {
10921 goto process_sdp_cleanup;
10924 if (p->
srtp && p->
udptl && udptlportno != -1) {
10925 ast_debug(1,
"Terminating SRTP due to T.38 UDPTL\n");
10933 goto process_sdp_cleanup;
10936 if (!secure_audio && p->
srtp) {
10937 ast_log(
LOG_WARNING,
"Failed to receive SDP offer/answer with required SRTP crypto attributes for audio\n");
10939 goto process_sdp_cleanup;
10945 goto process_sdp_cleanup;
10949 ast_log(
LOG_WARNING,
"Failed to receive SDP offer/answer with required SRTP crypto attributes for video\n");
10951 goto process_sdp_cleanup;
10957 goto process_sdp_cleanup;
10960 if (udptlportno == -1) {
10988 goto process_sdp_cleanup;
11004 ast_verbose(
"Capabilities: us - %s, peer - audio=%s/video=%s/text=%s, combined - %s\n",
11011 ast_verbose(
"Non-codec capabilities (dtmf): us - %s, peer - %s, combined - %s\n",
11023 if ((portno != -1 || vportno != -1 || tportno != -1) &&
ast_format_cap_count(newjointcapability)) {
11026 unsigned int framing;
11049 if (sa && portno > 0) {
11080 }
else if (udptlportno > 0) {
11082 ast_verbose(
"Got T.38 Re-invite without audio. Keeping RTP active during T.38 session.\n");
11102 if (vsa && vportno > 0) {
11122 if (tsa && tportno > 0) {
11146 if (isa && udptlportno > 0) {
11196 ast_debug(1,
"Peer doesn't provide T.38 UDPTL\n");
11201 ast_debug(3,
"Have T.38 but no audio, accepting offer anyway\n");
11203 goto process_sdp_cleanup;
11211 goto process_sdp_cleanup;
11214 ast_debug(4,
"We have an owner, now see if we need to change this call\n");
11217 unsigned int framing;
11223 ast_debug(1,
"Setting native formats after processing SDP. peer joint formats %s, old nativeformats %s\n",
11263 process_sdp_cleanup:
11280 const char *o_copy_start;
11284 int64_t sess_version;
11307 token =
strsep(&o_copy,
" ");
11312 token =
strsep(&o_copy,
" ");
11317 token =
strsep(&o_copy,
" ");
11318 if (!o_copy || !sscanf(token,
"%30" SCNd64, &sess_version)) {
11329 offset = (o_copy - o_copy_start);
11330 if (offset <
sizeof(unique)) {
11332 int sess_version_start = token - o_copy_start;
11333 ast_copy_string(unique + sess_version_start, o + offset,
sizeof(unique) - sess_version_start);
11357 ast_verbose(
"Got SDP version %" PRId64
" and unique parts [%s]\n",
11358 sess_version, unique);
11360 ast_verbose(
"Comparing SDP version %" PRId64
" -> %" PRId64
" and unique parts [%s] -> [%s]\n",
11374 ast_log(
LOG_WARNING,
"Call %s responded to our T.38 reinvite without changing SDP version; 'ignoresdpversion' should be set for this peer.\n", p->
callid);
11377 ast_debug(2,
"Call %s responded to our reinvite without changing SDP version; ignoring SDP.\n", p->
callid);
11387 char proto[4],
host[258];
11391 if (sscanf(c,
"IN %3s %255s", proto, host) == 2) {
11392 if (!strcmp(
"IP4", proto)) {
11394 }
else if (!strcmp(
"IP6", proto)) {
11416 if (!strcasecmp(a,
"sendonly")) {
11417 if (*sendonly == -1)
11420 }
else if (!strcasecmp(a,
"inactive")) {
11421 if (*sendonly == -1)
11424 }
else if (!strcasecmp(a,
"sendrecv")) {
11425 if (*sendonly == -1)
11436 char ufrag[256], pwd[256], foundation[33], transport[4],
address[46], cand_type[6], relay_address[46] =
"";
11438 unsigned int port, relay_port = 0;
11444 if (sscanf(a,
"ice-ufrag: %255s", ufrag) == 1) {
11447 }
else if (sscanf(a,
"ice-pwd: %255s", pwd) == 1) {
11450 }
else if (sscanf(a,
"candidate: %32s %30u %3s %30u %23s %30u typ %5s %*s %23s %*s %30u", foundation, &candidate.
id, transport, (
unsigned *)&candidate.
priority,
11451 address, &port, cand_type, relay_address, &relay_port) >= 7) {
11464 if (!strcasecmp(cand_type,
"host")) {
11466 }
else if (!strcasecmp(cand_type,
"srflx")) {
11468 }
else if (!strcasecmp(cand_type,
"relay")) {
11485 }
else if (!strcasecmp(a,
"ice-lite")) {
11497 if (!strncasecmp(a,
"rtcp-mux", 8)) {
11509 char value[256], hash[32];
11515 if (sscanf(a,
"setup: %255s", value) == 1) {
11518 if (!strcasecmp(value,
"active")) {
11520 }
else if (!strcasecmp(value,
"passive")) {
11522 }
else if (!strcasecmp(value,
"actpass")) {
11524 }
else if (!strcasecmp(value,
"holdconn")) {
11527 ast_log(
LOG_WARNING,
"Unsupported setup attribute value '%s' received on dialog '%s'\n",
11530 }
else if (sscanf(a,
"connection: %255s", value) == 1) {
11533 if (!strcasecmp(value,
"new")) {
11534 dtls->
reset(instance);
11535 }
else if (!strcasecmp(value,
"existing")) {
11538 ast_log(
LOG_WARNING,
"Unsupported connection attribute value '%s' received on dialog '%s'\n",
11541 }
else if (sscanf(a,
"fingerprint: %31s %255s", hash, value) == 2) {
11544 if (!strcasecmp(hash,
"sha-1")) {
11546 }
else if (!strcasecmp(hash,
"sha-256")) {
11549 ast_log(
LOG_WARNING,
"Unsupported fingerprint hash type '%s' received on dialog '%s'\n",
11560 unsigned int codec;
11561 char mimeSubtype[128];
11562 char fmtp_string[256];
11563 unsigned int sample_rate;
11566 if (!strncasecmp(a,
"ptime", 5)) {
11567 char *
tmp = strrchr(a,
':');
11568 long int framing = 0;
11571 framing = strtol(tmp,
NULL, 10);
11572 if (framing == LONG_MIN || framing == LONG_MAX) {
11574 ast_debug(1,
"Can't read framing from SDP: %s\n", a);
11579 ast_debug(1,
"Setting framing to %ld\n", framing);
11584 }
else if (sscanf(a,
"rtpmap: %30u %127[^/]/%30u", &codec, mimeSubtype, &sample_rate) == 3) {
11590 ast_verbose(
"Found audio description format %s for ID %u\n", mimeSubtype, codec);
11592 (*last_rtpmap_codec)++;
11597 ast_verbose(
"Found unknown media description format %s for ID %u\n", mimeSubtype, codec);
11601 ast_verbose(
"Discarded description format %s for ID %u\n", mimeSubtype, codec);
11603 }
else if (sscanf(a,
"fmtp: %30u %255[^\t\n]", &codec, fmtp_string) == 2) {
11607 unsigned int bit_rate;
11611 if (format_parsed) {
11621 if (sscanf(fmtp_string,
"bitrate=%30u", &bit_rate) == 1) {
11622 if (bit_rate != 64000) {
11623 ast_log(
LOG_WARNING,
"Got G.719 offer at %u bps, but only 64000 bps supported; ignoring.\n", bit_rate);
11640 unsigned int codec;
11641 char mimeSubtype[128];
11642 unsigned int sample_rate;
11644 char fmtp_string[256];
11646 if (sscanf(a,
"rtpmap: %30u %127[^/]/%30u", &codec, mimeSubtype, &sample_rate) == 3) {
11650 if (!strncasecmp(mimeSubtype,
"H26", 3) || !strncasecmp(mimeSubtype,
"MP4", 3)
11651 || !strncasecmp(mimeSubtype,
"VP8", 3)) {
11654 ast_verbose(
"Found video description format %s for ID %u\n", mimeSubtype, codec);
11656 (*last_rtpmap_codec)++;
11661 ast_verbose(
"Found unknown media description format %s for ID %u\n", mimeSubtype, codec);
11666 ast_verbose(
"Discarded description format %s for ID %u\n", mimeSubtype, codec);
11668 }
else if (sscanf(a,
"fmtp: %30u %255[^\t\n]", &codec, fmtp_string) == 2) {
11676 if (format_parsed) {
11694 unsigned int codec;
11695 char mimeSubtype[128];
11696 unsigned int sample_rate;
11700 if (sscanf(a,
"rtpmap: %30u %127[^/]/%30u", &codec, mimeSubtype, &sample_rate) == 3) {
11703 if (!strncasecmp(mimeSubtype,
"T140", 4)) {
11709 }
else if (!strncasecmp(mimeSubtype,
"RED", 3)) {
11712 sprintf(red_fmtp,
"fmtp:%u ", codec);
11714 ast_verbose(
"RED submimetype has payload type: %u\n", codec);
11720 ast_verbose(
"Discarded description format %s for ID %u\n", mimeSubtype, codec);
11722 }
else if (!strncmp(a, red_fmtp, strlen(red_fmtp))) {
11725 red_cp = &red_fmtp[strlen(red_fmtp)];
11726 strncpy(red_fmtp, a, 100);
11728 sscanf(red_cp,
"%30u", (
unsigned *)&red_data_pt[*red_num_gen]);
11729 red_cp = strtok_r(red_cp,
"/", &rest);
11731 sscanf(red_cp,
"%30u", (
unsigned *)&red_data_pt[*red_num_gen]);
11732 red_cp = strtok_r(
NULL,
"/", &rest);
11758 for (pos = attrib; *pos; ++pos) {
11759 *pos = tolower(*pos);
11762 if ((sscanf(attrib,
"t38faxmaxbuffer:%30u", &x) == 1)) {
11765 }
else if ((sscanf(attrib,
"t38maxbitrate:%30u", &x) == 1) || (sscanf(attrib,
"t38faxmaxrate:%30u", &x) == 1)) {
11766 ast_debug(3,
"T38MaxBitRate: %u\n", x);
11788 }
else if ((sscanf(attrib,
"t38faxversion:%30u", &x) == 1)) {
11792 }
else if ((sscanf(attrib,
"t38faxmaxdatagram:%30u", &x) == 1) || (sscanf(attrib,
"t38maxdatagram:%30u", &x) == 1)) {
11798 ast_debug(3,
"FaxMaxDatagram: %u\n", x);
11801 }
else if ((strncmp(attrib,
"t38faxfillbitremoval",
sizeof(
"t38faxfillbitremoval") - 1) == 0)) {
11802 if (sscanf(attrib,
"t38faxfillbitremoval:%30u", &x) == 1) {
11803 ast_debug(3,
"FillBitRemoval: %u\n", x);
11812 }
else if ((strncmp(attrib,
"t38faxtranscodingmmr",
sizeof(
"t38faxtranscodingmmr") - 1) == 0)) {
11813 if (sscanf(attrib,
"t38faxtranscodingmmr:%30u", &x) == 1) {
11814 ast_debug(3,
"Transcoding MMR: %u\n", x);
11823 }
else if ((strncmp(attrib,
"t38faxtranscodingjbig",
sizeof(
"t38faxtranscodingjbig") - 1) == 0)) {
11824 if (sscanf(attrib,
"t38faxtranscodingjbig:%30u", &x) == 1) {
11825 ast_debug(3,
"Transcoding JBIG: %u\n", x);
11834 }
else if ((sscanf(attrib,
"t38faxratemanagement:%255s", s) == 1)) {
11835 ast_debug(3,
"RateManagement: %s\n", s);
11836 if (!strcasecmp(s,
"localTCF"))
11838 else if (!strcasecmp(s,
"transferredTCF"))
11841 }
else if ((sscanf(attrib,
"t38faxudpec:%255s", s) == 1)) {
11843 if (!strcasecmp(s,
"t38UDPRedundancy")) {
11845 }
else if (!strcasecmp(s,
"t38UDPFEC")) {
11864 sprintf(supported_value,
"replaces%s%s",
11867 res =
add_header(req,
"Supported", supported_value);
11905 snprintf(clen,
sizeof(clen),
"%d", dialog->
maxforwards);
11907 return add_header(req,
"Max-Forwards", clen);
11916 ast_log(
LOG_WARNING,
"finalize_content() called on a message that has already been finalized\n");
11934 ast_log(
LOG_WARNING,
"Can't add more content when the content has been finalized\n");
11967 return copied ? 0 : -1;
11991 char leftmost[512], *others, *rport;
11995 others = strchr(leftmost,
',');
12000 rport = strstr(leftmost,
";rport");
12001 if (rport && *(rport+6) ==
'=')
12008 rport = strstr(leftmost,
";rport");
12011 end = strchr(rport + 1,
';');
12013 memmove(rport, end, strlen(end) + 1);
12019 snprintf(
new,
sizeof(
new),
"%s;received=%s;rport=%d%s%s",
12022 others ?
"," :
"", others ? others :
"");
12025 snprintf(
new,
sizeof(
new),
"%s;received=%s%s%s",
12027 others ?
"," :
"", others ? others :
"");
12069 char *trans, *maddr,
hostname[256];
12073 int tls_on =
FALSE;
12076 ast_verbose(
"set_destination: Parsing <%s> for address/port to send to\n", uri);
12078 if ((trans =
strcasestr(uri,
";transport="))) {
12079 trans += strlen(
";transport=");
12081 if (!strncasecmp(trans,
"ws", 2)) {
12083 ast_verbose(
"set_destination: URI is for WebSocket, we can't set destination\n");
12089 h = strchr(uri,
'@');
12094 if (!strncasecmp(h,
"sip:", 4)) {
12096 }
else if (!strncasecmp(h,
"sips:", 5)) {
12101 hn = strcspn(h,
";>") + 1;
12102 if (hn >
sizeof(hostname))
12116 maddr = strstr(h,
"maddr=");
12121 hn = strspn(maddr,
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 12122 "0123456789-.:[]") + 1;
12123 if (hn >
sizeof(hostname))
12145 ast_verbose(
"set_destination: set destination to %s\n",
12154 memset(resp, 0,
sizeof(*resp));
12176 memset(req, 0,
sizeof(*req));
12231 if ((msg[0] >=
'1' && msg[0] <=
'3') || !strncmp(msg,
"485", 3))
12238 if (msg[0] ==
'2' || msg[0] ==
'3' || !strncmp(msg,
"485", 3))
12247 if (msg[0] ==
'3' || !strncmp(msg,
"485", 3))
12253 if (msg[0] >=
'2' && msg[0] <=
'6')
12276 if (msg[0] ==
'1' || msg[0] ==
'2')
12280 if (!
strcasestr(ot,
"tag=") && strncmp(msg,
"100", 3)) {
12284 snprintf(newto,
sizeof(newto),
"%s;tag=%s", ot, p->
theirtag);
12286 snprintf(newto,
sizeof(newto),
"%s;tag=%s", ot, p->
tag);
12304 add_header(resp,
"Session-Expires", se_hdr);
12329 char *brackets = strchr(contact_uri,
'<');
12330 snprintf(contact,
sizeof(contact),
"%s%s%s;expires=%d", brackets ?
"" :
"<", contact_uri, brackets ?
"" :
">", p->
expiry);
12354 ast_log(
LOG_WARNING,
"error processing via header, will send response to originating address\n");
12368 const char *ot, *of;
12369 int is_strict =
FALSE;
12383 }
else if (newbranch && (sipmethod ==
SIP_INVITE)) {
12387 }
else if (newbranch) {
12401 }
else if (sipmethod ==
SIP_ACK) {
12424 snprintf(tmp,
sizeof(tmp),
"%u %s", seqno,
sip_methods[sipmethod].
text);
12460 snprintf(newto,
sizeof(newto),
"%s;tag=%s", ot, p->
theirtag);
12461 else if (!is_outbound)
12462 snprintf(newto,
sizeof(newto),
"%s;tag=%s", ot, p->
tag);
12464 snprintf(newto,
sizeof(newto),
"%s", ot);
12514 uint32_t seqno = 0;
12516 if (reliable && (sscanf(
sip_get_header(req,
"CSeq"),
"%30u ", &seqno) != 1)) {
12524 && (!strncmp(msg,
"180", 3) || !strncmp(msg,
"183", 3))) {
12533 if (!strncmp(msg,
"302", 3)) {
12543 int hangupcause = 0;
12551 if (sscanf(msg,
"%30d ", &respcode))
12556 sprintf(buf,
"Q.850;cause=%i", hangupcause & 0x7f);
12564 add_header(&resp,
"X-Asterisk-HangupCauseCode", buf);
12574 if (need_new_etag) {
12618 p->
method = intended_method;
12631 if (useglobal_nat && addr) {
12666 add_header(&resp,
"Unsupported", unsupported);
12674 char minse_str[20];
12679 snprintf(minse_str,
sizeof(minse_str),
"%d", minse_int);
12698 time_t t = time(
NULL);
12701 strftime(tmp,
sizeof(tmp),
"%a, %d %b %Y %T GMT", &tm);
12710 snprintf(tmp,
sizeof(tmp),
"%d", expires);
12737 add_header(&resp,
"Accept",
"application/sdp");
12747 snprintf(tmp,
sizeof(tmp),
"%d", minexpires);
12758 uint32_t seqno = 0;
12760 if (reliable && (sscanf(
sip_get_header(req,
"CSeq"),
"%30u ", &seqno) != 1)) {
12769 snprintf(tmp,
sizeof(tmp),
"Digest algorithm=MD5, realm=\"%s\", nonce=\"%s\"%s", p->
realm, nonce, stale ?
", stale=true" :
"");
12791 if (strncasecmp(from,
"sip:", 4)) {
12803 if ((a = strchr(from,
';')))
12806 for (a = from; *a !=
'\0'; ++
a) {
12807 if (*a ==
':' && bracket == 0) {
12810 }
else if (*a ==
'[') {
12812 }
else if (*a ==
']') {
12816 if ((a = strchr(from,
'@'))) {
12908 size_t hdr_len_name;
12909 size_t hdr_len_value;
12913 hdr_len_name = strlen(hdr_name) + 1;
12914 hdr_len_value = strlen(hdr_value) + 1;
12916 node =
ast_calloc(1,
sizeof(*node) + hdr_len_name + hdr_len_value);
12922 strcpy(pos, hdr_name);
12923 pos += hdr_len_name;
12925 strcpy(pos, hdr_value);
12933 const char *content_type =
NULL;
12938 if (!strcasecmp(node->
name,
"Content-Type")) {
12940 content_type = node->
value;
12947 content_type =
"text/plain;charset=UTF-8";
12949 add_header(req,
"Content-Type", content_type);
12966 if (
'0' <= digit && digit <=
'9') {
12967 event = digit -
'0';
12968 }
else if (digit ==
'*') {
12970 }
else if (digit ==
'#') {
12972 }
else if (
'A' <= digit && digit <=
'D') {
12973 event = 12 + digit -
'A';
12974 }
else if (
'a' <= digit && digit <=
'd') {
12975 event = 12 + digit -
'a';
12980 snprintf(tmp,
sizeof(tmp),
"%d\r\n", event);
12981 add_header(req,
"Content-Type",
"application/dtmf");
12985 snprintf(tmp,
sizeof(tmp),
"Signal=%c\r\nDuration=%u\r\n", digit, duration);
12986 add_header(req,
"Content-Type",
"application/dtmf-relay");
13000 char lid_name_buf[128];
13004 const char *fromdomain;
13005 const char *privacy =
NULL;
13006 const char *screen =
NULL;
13008 const char *anonymous_string =
"\"Anonymous\" <sip:anonymous@anonymous.invalid>";
13024 lid_name = lid_num;
13038 !strcmp(
"anonymous.invalid", fromdomain))) {
13050 ast_str_set(&tmp, -1,
"\"%s\" <sip:%s@%s>", lid_name_buf, lid_num, fromdomain);
13058 ast_str_set(&tmp, -1,
"\"%s\" <sip:%s@%s>", lid_name_buf, lid_num, fromdomain);
13065 ast_str_set(&tmp, -1,
"\"%s\" <sip:%s@%s>;party=%s", lid_name_buf, lid_num, fromdomain, p->
outgoing_call ?
"calling" :
"called");
13067 switch (lid_pres) {
13101 ast_str_append(&tmp, -1,
";privacy=%s;screen=%s", privacy, screen);
13113 const char *xml_is_a_huge_waste_of_space =
13114 "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n" 13115 " <media_control>\r\n" 13116 " <vc_primitive>\r\n" 13117 " <to_encoder>\r\n" 13118 " <picture_fast_update>\r\n" 13119 " </picture_fast_update>\r\n" 13120 " </to_encoder>\r\n" 13121 " </vc_primitive>\r\n" 13122 " </media_control>\r\n";
13123 add_header(req,
"Content-Type",
"application/media_control+xml");
13142 if ((username = ice->
get_ufrag(instance))) {
13190 ice->
start(instance);
13198 const char *fingerprint;
13246 int *min_packet_size,
13247 int *max_packet_size)
13251 unsigned int rate, framing;
13265 ast_str_append(a_buf, 0,
"a=rtpmap:%d %s/%u/2\r\n", rtp_code, mime, rate);
13267 ast_str_append(a_buf, 0,
"a=rtpmap:%d %s/%u\r\n", rtp_code, mime, rate);
13279 ast_str_append(a_buf, 0,
"a=fmtp:%d bitrate=64000\r\n", rtp_code);
13287 if (framing && (framing < *min_packet_size)) {
13288 *min_packet_size = framing;
13292 if ((*min_packet_size) == 0 && framing) {
13293 *min_packet_size = framing;
13305 int debug,
int *min_packet_size)
13308 const char *subtype;
13324 ast_str_append(a_buf, 0,
"a=rtpmap:%d %s/%u\r\n", rtp_code, subtype, rate);
13336 int debug,
int *min_packet_size)
13415 int use_externip = 0;
13508 if (!tmp || dtls_enabled) {
13518 char *
copy = a_crypto;
13525 if (
ast_asprintf(&a_crypto,
"%sa=crypto:%s\r\n", copy, orig_crypto) == -1) {
13547 int doing_directmedia =
FALSE;
13562 char connection[256];
13563 char *session_time =
"t=0 0\r\n";
13564 char bandwidth[256] =
"";
13580 int needaudio =
FALSE;
13581 int needvideo =
FALSE;
13582 int needtext =
FALSE;
13584 int min_audio_packet_size = 0;
13585 int max_audio_packet_size = 0;
13586 int min_video_packet_size = 0;
13587 int min_text_packet_size = 0;
13594 if (!alreadysent || !tmpcap) {
13596 goto add_sdp_cleanup;
13601 goto add_sdp_cleanup;
13612 if (oldsdp ==
FALSE)
13619 if (doing_directmedia) {
13632 ast_debug(2,
"This call needs video offers, but caller probably did not offer it!\n");
13633 }
else if (p->
vrtp) {
13635 ast_debug(2,
"This call needs video offers!\n");
13637 ast_debug(2,
"This call needs video offers, but there's no video support enabled!\n");
13650 ast_debug(2,
"This call needs text offers! \n");
13652 ast_debug(2,
"This call needs text offers, but there's no text support enabled ! \n");
13657 ast_debug(1,
"** Our capability: %s Video flag: %s Text flag: %s\n",
13659 p->
novideo ?
"True" :
"False", p->
notext ?
"True" :
"False");
13666 snprintf(owner,
sizeof(owner),
"o=%s %d %d IN %s %s\r\n",
13673 snprintf(connection,
sizeof(connection),
"c=IN %s %s\r\n",
13680 hold =
"a=recvonly\r\n";
13681 doing_directmedia =
FALSE;
13683 hold =
"a=inactive\r\n";
13684 doing_directmedia =
FALSE;
13686 hold =
"a=sendrecv\r\n";
13705 snprintf(bandwidth,
sizeof(bandwidth),
"b=CT:%d\r\n", p->
maxcallbitrate);
13710 if (!doing_directmedia) {
13734 if (!doing_directmedia) {
13774 add_codec_to_sdp(p, tmp_fmt, &m_audio, &a_audio, debug, &min_audio_packet_size, &max_audio_packet_size);
13790 add_codec_to_sdp(p, tmp_fmt, &m_audio, &a_audio, debug, &min_audio_packet_size, &max_audio_packet_size);
13792 add_vcodec_to_sdp(p, tmp_fmt, &m_video, &a_video, debug, &min_video_packet_size);
13809 ast_debug(3,
"-- Done with adding codecs to SDP\n");
13815 if (min_audio_packet_size) {
13816 ast_str_append(&a_audio, 0,
"a=ptime:%d\r\n", min_audio_packet_size);
13820 if (min_video_packet_size) {
13821 ast_str_append(&a_video, 0,
"a=ptime:%d\r\n", min_video_packet_size);
13825 if (min_text_packet_size) {
13826 ast_str_append(&a_text, 0,
"a=ptime:%d\r\n", min_text_packet_size);
13829 if (max_audio_packet_size) {
13830 ast_str_append(&a_audio, 0,
"a=maxptime:%d\r\n", max_audio_packet_size);
13834 ast_debug(1,
"Setting framing on incoming call: %u\n", min_audio_packet_size);
13838 if (!doing_directmedia) {
13894 ast_str_append(&a_modem, 0,
"a=T38FaxRateManagement:transferredTCF\r\n");
13897 ast_str_append(&a_modem, 0,
"a=T38FaxRateManagement:localTCF\r\n");
13908 ast_str_append(&a_modem, 0,
"a=T38FaxUdpEC:t38UDPRedundancy\r\n");
13920 add_header(resp,
"Content-Type",
"application/sdp");
13933 switch (offer->
type) {
14023 ao2_t_unlink(dialogs_rtpcheck, p,
"unlink pvt into dialogs_rtpcheck container");
14024 ao2_t_link(dialogs_rtpcheck, p,
"link pvt into dialogs_rtpcheck container");
14027 ast_debug(3,
"Done building SDP. Settling with this capability: %s\n",
14046 if (sscanf(
sip_get_header(req,
"CSeq"),
"%30u ", &seqno) != 1) {
14054 ast_log(
LOG_ERROR,
"Can't add SDP to response, since we have no UDPTL session allocated. Call-ID %s\n", p->
callid);
14072 dst->
data = duplicate;
14073 dst->
content = duplicate_content;
14117 ast_str_set(&header, 0,
"<%s>;purpose=call-completion;m=%s", uri,
"NR");
14129 if (sscanf(
sip_get_header(req,
"CSeq"),
"%30u ", &seqno) != 1) {
14134 if (rpid ==
TRUE) {
14149 ast_log(
LOG_ERROR,
"Can't add SDP to response, since we have no RTP session allocated. Call-ID %s\n", p->
callid);
14160 char *local_rlpart1;
14175 if (!strcasecmp(local_rlpart1,
"SIP/2.0") ) {
14181 ast_debug(3,
"Oops. Bogus uri in <> %s\n", e);
14191 if (strcasecmp(e,
"SIP/2.0") ) {
14192 ast_debug(3,
"Skipping packet - Bad request protocol %s\n", e);
14244 if (oldsdp ==
TRUE)
14245 add_header(&req,
"X-asterisk-Info",
"SIP re-invite (Session-Timers)");
14247 add_header(&req,
"X-asterisk-Info",
"SIP re-invite (External RTP bridge)");
14278 atsign = strchr(uri,
'@');
14282 atsign = strchr(atsign,
';');
14322 if (record_route) {
14325 if (!strncmp(record_route_uri,
"sips:", 5)) {
14332 if (!strncmp(contact_uri,
"sips:", 5)) {
14362 if (!strncmp(route_uri,
"sips:", 5)) {
14412 #define SIPHEADER 256 14418 const char *l =
NULL;
14419 const char *n =
NULL;
14420 const char *
d =
NULL;
14421 const char *urioptions =
"";
14423 int cid_has_name = 1;
14424 int cid_has_num = 1;
14444 urioptions =
";user=phone";
14517 ret =
ast_str_set(&from, 0,
"<sip:%s@%s:%d>;tag=%s", tmp_l, d, ourport, p->
tag);
14519 ret =
ast_str_set(&from, 0,
"<sip:%s@%s>;tag=%s", tmp_l, d, p->
tag);
14523 ast_log(
LOG_ERROR,
"The From header was truncated in call '%s'. This call setup will fail.\n", p->
callid);
14532 if (cid_has_name || !cid_has_num) {
14539 name_len = strlen(n);
14546 memmove(from_buf + name_len + 3, from_buf, written + 1);
14548 memcpy(from_buf + 1, n, name_len);
14549 from_buf[name_len + 1] =
'"';
14550 from_buf[name_len + 2] =
' ';
14591 if (!strchr(p->
todnid,
'@')) {
14610 ast_log(
LOG_ERROR,
"The To header was truncated in call '%s'. This call setup will fail.\n", p->
callid);
14656 const char *reason;
14657 const char *quote_str;
14658 char header_text[256];
14685 quote_str = *reason ==
'\"' ||
sip_is_token(reason) ?
"" :
"\"";
14690 snprintf(header_text,
sizeof(header_text),
"<sip:%s@%s>;reason=%s%s%s",
14693 quote_str, reason, quote_str);
14701 snprintf(header_text,
sizeof(header_text),
"\"%s\" <sip:%s@%s>;reason=%s%s%s",
14705 quote_str, reason, quote_str);
14727 dialog_unref(pvt,
"create_addr failed in transmit_publish. Unref dialog");
14742 dialog_unref(pvt,
"Done with the sip_pvt allocated for transmitting PUBLISH");
14769 reqprep(&req, p, sipmethod, 0, init ? 0 : 1);
14785 add_header(&req,
"Event",
"message-summary");
14786 add_header(&req,
"Accept",
"application/simple-message-summary");
14788 add_header(&req,
"Event",
"call-completion");
14789 add_header(&req,
"Accept",
"application/call-completion");
14816 add_header(&req,
"Session-Expires", i2astr);
14841 if (!strncmp(
ast_var_name(current),
"SIPADDHEADER", strlen(
"SIPADDHEADER"))) {
14842 char *content, *
end;
14847 if (*headdup ==
'"') {
14850 if ((content = strchr(headdup,
':'))) {
14854 end = content + strlen(content) -1;
14861 ast_debug(1,
"Adding SIP Header \"%s\" with content :%s: \n", headdup, content);
14880 }
else if (p->
rtp) {
14894 add_header(&req,
"Event",
"call-completion");
14901 add_header(&req,
"Content-Type",
"application/pidf+xml");
14929 ao2_t_ref(mwi, -1,
"Scheduled mwi resub complete");
14940 ao2_t_ref(mwi, -1,
"Stop scheduled mwi resub"));
14948 ao2_t_ref(mwi, -1,
"Shutdown MWI subscription action");
14954 ao2_t_ref(mwi, +1,
"Shutdown MWI subscription action");
14957 ao2_t_ref(mwi, -1,
"Failed to schedule shutdown MWI subscription action");
14971 int ms = sched_data->
ms;
14976 ao2_t_ref(mwi, -1,
"Stop scheduled mwi resub"));
14978 ao2_t_ref(mwi, +1,
"Schedule mwi resub");
14980 if (mwi->
resub < 0) {
14982 ao2_t_ref(mwi, -1,
"Failed to schedule mwi resub");
14985 ao2_t_ref(mwi, -1,
"Start MWI subscription action");
14993 sched_data =
ast_malloc(
sizeof(*sched_data));
14998 sched_data->
mwi = mwi;
14999 sched_data->
ms = ms;
15000 ao2_t_ref(mwi, +1,
"Start MWI subscription action");
15003 ao2_t_ref(mwi, -1,
"Failed to schedule start MWI subscription action");
15011 const char *old_str;
15015 ast_debug(1,
"Empty sockaddr change...ignoring!\n");
15032 const char *old_str;
15036 ast_debug(1,
"Empty sockaddr change...ignoring!\n");
15061 const char *old_str;
15065 ast_debug(1,
"Empty sockaddr change...ignoring!\n");
15083 ao2_t_ref(mwi, +1,
"dnsmgr reference to mwi");
15086 ao2_t_ref(mwi, -1,
"dnsmgr disabled, remove reference");
15166 struct timeval tv = {0,};
15189 return (strstr(p->
useragent,
"Digium")) ? 1 : 0;
15196 const char *statestring =
"terminated";
15197 const char *pidfstate =
"--";
15198 const char *pidfnote =
"Ready";
15201 switch (data->
state) {
15205 pidfstate =
"busy";
15206 pidfnote =
"Ringing";
15209 statestring =
"early";
15211 pidfstate =
"busy";
15212 pidfnote =
"Ringing";
15215 statestring =
"confirmed";
15217 pidfstate =
"busy";
15218 pidfnote =
"On the phone";
15221 statestring =
"confirmed";
15223 pidfstate =
"busy";
15224 pidfnote =
"On the phone";
15227 statestring =
"terminated";
15229 pidfstate =
"away";
15230 pidfnote =
"Unavailable";
15233 statestring =
"confirmed";
15235 pidfstate =
"busy";
15236 pidfnote =
"On hold";
15247 char *individual_hint =
NULL;
15248 int hint_count = 0, unavailable_count = 0;
15251 if ((hint2 = strrchr(hint,
','))) {
15256 while ((individual_hint =
strsep(&hint2,
"&"))) {
15260 unavailable_count++;
15266 if (hint_count > 0 && hint_count == unavailable_count) {
15268 pidfstate =
"away";
15269 pidfnote =
"Not online";
15273 switch (subscribed) {
15277 "<?xml version=\"1.0\"?>\n" 15278 "<!DOCTYPE presence PUBLIC \"-//IETF//DTD RFCxxxx XPIDF 1.0//EN\" \"xpidf.dtd\">\n" 15280 ast_str_append(tmp, 0,
"<presentity uri=\"%s;method=SUBSCRIBE\" />\n", mfrom);
15282 ast_str_append(tmp, 0,
"<address uri=\"%s;user=ip\" priority=\"0.800000\">\n", mto);
15289 "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" 15290 "<presence xmlns=\"urn:ietf:params:xml:ns:pidf\" \nxmlns:pp=\"urn:ietf:params:xml:ns:pidf:person\"\nxmlns:es=\"urn:ietf:params:xml:ns:pidf:rpid:status:rpid-status\"\nxmlns:ep=\"urn:ietf:params:xml:ns:pidf:rpid:rpid-person\"\nentity=\"%s\">\n", mfrom);
15292 if (pidfstate[0] !=
'-') {
15293 ast_str_append(tmp, 0,
"<ep:activities><ep:%s/></ep:activities>\n", pidfstate);
15298 ast_str_append(tmp, 0,
"<contact priority=\"1\">%s</contact>\n", mto);
15299 if (pidfstate[0] ==
'b')
15300 ast_str_append(tmp, 0,
"<status><basic>open</basic></status>\n");
15309 ast_str_append(tmp, 0,
"<digium_presence type=\"%s\" subtype=\"%s\">%s</digium_presence>\n",
15315 "PresenceState: %s\r\n" 15326 ast_str_append(tmp, 0,
"<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" version=\"%u\" state=\"%s\" entity=\"%s\">\n", p->
dialogver, full ?
"full" :
"partial", mto);
15353 static char *anonymous =
"anonymous";
15354 static char *invalid =
"anonymous.invalid";
15356 char *connected_num;
15358 int cid_num_restricted, connected_num_restricted;
15365 S_COR(cid_num_restricted, anonymous,
15368 need = strlen(cid_num) + (cid_num_restricted ? strlen(invalid) :
15372 snprintf(local_target, need,
"sip:%s@%s", cid_num,
15373 cid_num_restricted ? invalid : p->
fromdomain);
15379 local_display,
sizeof(local_display));
15384 S_COR(connected_num_restricted, anonymous,
15387 need = strlen(connected_num) + (connected_num_restricted ? strlen(invalid) :
15391 snprintf(remote_target, need,
"sip:%s@%s", connected_num,
15392 connected_num_restricted ? invalid : p->
fromdomain);
15398 remote_display,
sizeof(remote_display));
15407 ast_str_append(tmp, 0,
"<dialog id=\"%s\" call-id=\"pickup-%s\" local-tag=\"%s\" remote-tag=\"%s\" direction=\"recipient\">\n",
15410 ast_str_append(tmp, 0,
"<dialog id=\"%s\" call-id=\"pickup-%s\" direction=\"recipient\">\n",
15417 "<identity display=\"%s\">%s</identity>\n" 15418 "<target uri=\"%s\"/>\n" 15421 "<identity display=\"%s\">%s</identity>\n" 15422 "<target uri=\"%s\"/>\n" 15424 remote_display, remote_target, remote_target, local_display, local_target, local_target);
15426 ast_str_append(tmp, 0,
"<dialog id=\"%s\" direction=\"recipient\">\n", exten);
15435 "<param pname=\"+sip.rendering\" pvalue=\"no\"/>\n" 15436 "</target>\n</local>\n", mto);
15450 char uri[
SIPBUFSIZE +
sizeof(
"cc-URI: \r\n") - 1];
15451 char state_str[64];
15452 char subscription_state_hdr[64];
15455 ast_log(
LOG_WARNING,
"Invalid state provided for transmit_cc_notify (%u)\n", state);
15461 add_header(&req,
"Event",
"call-completion");
15462 add_header(&req,
"Content-Type",
"application/call-completion");
15463 snprintf(subscription_state_hdr,
sizeof(subscription_state_hdr),
"active;expires=%d", subscription->
expiry);
15464 add_header(&req,
"Subscription-State", subscription_state_hdr);
15465 if (state == CC_READY) {
15467 snprintf(uri,
sizeof(uri),
"cc-URI: %s\r\n", agent_pvt->
notify_uri);
15470 if (state == CC_READY) {
15480 char from[256], to[256];
15481 char *
c, *mfrom, *mto;
15490 memset(from, 0,
sizeof(from));
15491 memset(to, 0,
sizeof(to));
15497 if (strncasecmp(c,
"sip:", 4) && strncasecmp(c,
"sips:", 5)) {
15506 if (strncasecmp(c,
"sip:", 4) && strncasecmp(c,
"sips:", 5)) {
15514 switch(data->
state) {
15517 add_header(&req,
"Subscription-State",
"terminated;reason=timeout");
15519 add_header(&req,
"Subscription-State",
"terminated;reason=probation");
15524 add_header(&req,
"Subscription-State",
"terminated;reason=noresource");
15528 add_header(&req,
"Subscription-State",
"active");
15530 add_header(&req,
"Subscription-State",
"terminated;reason=timeout");
15593 add_header(&req,
"Event",
"message-summary");
15595 ast_str_append(&out, 0,
"Messages-Waiting: %s\r\n", newmsgs ?
"yes" :
"no");
15602 ast_str_append(&out, 0,
"Message-Account: sip:%s@%s:%d\r\n", exten, domain, ourport);
15608 ast_str_append(&out, 0,
"Message-Account: sip:%s@%s\r\n", exten, domain);
15621 add_header(&req,
"Subscription-State",
"active");
15623 add_header(&req,
"Subscription-State",
"terminated;reason=timeout");
15642 snprintf(tmp,
sizeof(tmp),
"refer;id=%d", cseq);
15644 add_header(&req,
"Subscription-state", terminate ?
"terminated;reason=noresource" :
"active");
15645 add_header(&req,
"Content-Type",
"message/sipfrag;version=2.0");
15649 snprintf(tmp,
sizeof(tmp),
"SIP/2.0 %s\r\n", message);
15673 if (!strncasecmp(channame,
"sip/", 4)) {
15679 struct sip_pvt tmp_dialog = {
15697 astman_send_error(s, m,
"Unable to build sip pvt data for notify (memory/socket error)");
15720 for (var = vars;
var; var = var->
next) {
15721 if (!strcasecmp(var->
name,
"Content")) {
15725 }
else if (!strcasecmp(var->
name,
"Content-Length")) {
15729 header = header->
next;
15746 dialog_unref(p,
"bump down the count of p since we're done with it.");
15804 add_header(&req,
"X-Asterisk-rpid-update",
"Yes");
15849 return map_x_s(regstatestrings, regstate,
"Unknown");
15902 ao2_t_ref(r, -1,
"Scheduled reregister timeout complete");
15927 int ms = sched_data->
ms;
15932 ao2_t_ref(reg, -1,
"Stop scheduled reregister timeout"));
15934 ao2_t_ref(reg, +1,
"Schedule reregister timeout");
15938 ao2_t_ref(reg, -1,
"Failed to schedule reregister timeout");
15941 ao2_t_ref(reg, -1,
"Start reregister timeout action");
15949 sched_data =
ast_malloc(
sizeof(*sched_data));
15954 sched_data->
reg = reg;
15955 sched_data->
ms = ms;
15956 ao2_t_ref(reg, +1,
"Start reregister timeout action");
15959 ao2_t_ref(reg, -1,
"Failed to schedule start reregister timeout action");
15993 ao2_t_ref(r, -1,
"Scheduled register timeout completed early");
16035 ao2_t_ref(r, -1,
"Scheduled register timeout complete");
16045 ao2_t_ref(reg, -1,
"Stop scheduled register timeout"));
16046 ao2_t_ref(reg, -1,
"Stop register timeout action");
16052 ao2_t_ref(reg, +1,
"Stop register timeout action");
16055 ao2_t_ref(reg, -1,
"Failed to schedule stop register timeout action");
16065 ao2_t_ref(reg, -1,
"Stop scheduled register timeout"));
16067 ao2_t_ref(reg, +1,
"Schedule register timeout");
16071 ao2_t_ref(reg, -1,
"Failed to schedule register timeout");
16073 ast_debug(1,
"Scheduled a registration timeout for %s id #%d \n",
16076 ao2_t_ref(reg, -1,
"Start register timeout action");
16082 ao2_t_ref(reg, +1,
"Start register timeout action");
16085 ao2_t_ref(reg, -1,
"Failed to schedule start register timeout action");
16096 memset(&addr, 0,
sizeof(addr));
16137 ao2_t_ref(r, +1,
"add reg ref for dnsmgr");
16141 ao2_t_ref(r, -1,
"remove reg ref, dnsmgr disabled");
16145 peer =
sip_unref_peer(peer,
"removing peer ref for dnsmgr_lookup");
16154 p =
dialog_ref(r->
call,
"getting a copy of the r->call dialog in transmit_register");
16166 ast_log(
LOG_WARNING,
"Unable to allocate registration transaction (memory or socket error)\n");
16203 ast_log(
LOG_WARNING,
"Probably a DNS error for registration to %s@%s, trying REGISTER again (after %d seconds)\n",
16226 r->
call =
dialog_ref(p,
"copying dialog into registry r->call");
16227 p->
registry =
ao2_t_bump(r,
"transmit_register: addref to p->registry in transmit_register");
16263 if (auth ==
NULL) {
16323 memset(digest, 0,
sizeof(digest));
16343 dialog_unref(p,
"p is finished here at the end of transmit_register");
16374 return p->
refer ? 1 : 0;
16394 return p->
notify ? 1 : 0;
16424 if (!strncasecmp(of,
"sip:", 4)) {
16426 }
else if (!strncasecmp(of,
"sips:", 5)) {
16433 if (strchr(dest,
'@')) {
16435 }
else if ((c = strchr(of,
'@'))) {
16439 snprintf(referto,
sizeof(referto),
"<sip%s:%s@%s>", use_tls ?
"s" :
"", dest, c);
16441 snprintf(referto,
sizeof(referto),
"<sip%s:%s>", use_tls ?
"s" :
"", dest);
16480 switch (charging) {
16536 reqprep(&resp, p, sipmethod, seqno, newbranch);
16538 add_header(&resp,
"Reason",
"SIP;cause=200;text=\"Call completed elsewhere\"");
16552 *header =
"WWW-Authenticate";
16553 *respheader =
"Authorization";
16555 *header =
"Proxy-Authenticate";
16556 *respheader =
"Proxy-Authorization";
16558 ast_verbose(
"-- wrong response code %u\n", code);
16559 *header = *respheader =
"Invalid";
16568 reqprep(&resp, p, sipmethod, seqno, newbranch);
16572 memset(digest, 0,
sizeof(digest));
16574 char *
dummy, *response;
16583 switch (sipmethod) {
16593 snprintf(buf,
sizeof(buf),
"Q.850;cause=%d", p->
hangupcause & 0x7f);
16598 snprintf(buf,
sizeof(buf),
"%d", p->
hangupcause);
16599 add_header(&resp,
"X-Asterisk-HangupCauseCode", buf);
16616 char *tablename = (realtimeregs) ?
"sipregs" :
"sippeers";
16620 ast_update_realtime(tablename,
"name", peer->
name,
"fullcontact",
"",
"ipaddr",
"",
"port",
"0",
"regseconds",
"0",
"regserver",
"",
"useragent",
"",
"lastms",
"0",
SENTINEL);
16632 if (socket->
type != transport) {
16634 socket->
type = transport;
16672 "peer_status",
"Unregistered",
16673 "cause",
"Expired");
16683 ast_debug(3,
"-REALTIME- peer expired registration. Name: %s. Realtime peer objects now %d\n", peer->
name,
rpeerobjs);
16688 ao2_t_unlink(peers, peer,
"ao2_unlink of peer from peers table");
16694 ao2_t_unlink(peers_by_ip, peer,
"ao2_unlink of peer from peers_by_ip table");
16699 memset(&peer->
addr, 0,
sizeof(peer->
addr));
16718 }
else if (foundpeer->
name != peer->
name) {
16749 char full_addr[128];
16762 if (
ast_db_get(
"SIP/Registry", peer->
name, data,
sizeof(data))) {
16768 snprintf(full_addr,
sizeof(full_addr),
"%s:%s",
args.addr,
args.port);
16774 if (
args.expiry_str) {
16775 expire = atoi(
args.expiry_str);
16780 if (
args.username) {
16783 if (
args.contact) {
16787 ast_debug(2,
"SIP Seeding peer from astdb: '%s' at %s@%s for %d\n",
16805 if (!
ast_db_get(
"SIP/RegistryPath", peer->
name, path,
sizeof(path))) {
16844 const char *rp, *
rh;
16856 if (strncasecmp(rh,
"Q.850", 5)) {
16862 rp = strstr(rh,
"cause=");
16863 if (rp && sscanf(rp + 6,
"%3d", &cause) == 1) {
16867 ast_verbose(
"Using Reason header for cause code: %d\n",
16882 int ret =
parse_uri(uri, scheme, user, pass, hostport, transport);
16885 if ((p = strchr(uri, (
int)
';'))) {
16894 char *hostport, *transport;
16895 char contact_buf[256];
16900 contact = contact_buf;
16911 ast_log(
LOG_WARNING,
"Invalid contact uri %s (missing sip: or sips:), attempting to use anyway\n", fullcontact);
16930 "resolve in DNS) : '%s'\n", hostport);
16939 !strncasecmp(fullcontact,
"sips", 4)) ?
16966 int expire = atoi(expires);
16967 char *curi =
NULL, *hostport =
NULL, *transport =
NULL;
16968 int transport_type;
16969 const char *useragent;
16971 char *firstcuri =
NULL;
16973 int wildcard_found = 0;
16974 int single_binding_found = 0;
16981 expires =
strsep(&s,
";");
16982 if (sscanf(expires + 9,
"%30d", &expire) != 1) {
17004 if (strchr(contact,
'<') ==
NULL)
17011 if (!strcasecmp(curi,
"*")) {
17012 wildcard_found = 1;
17014 single_binding_found = 1;
17017 if (wildcard_found && (
ast_strlen_zero(expires) || expire != 0 || single_binding_found)) {
17037 }
else if (!strcasecmp(curi,
"*") || !expire) {
17054 ast_log(
LOG_NOTICE,
"Not a valid SIP contact (missing sip:/sips:) trying to use anyway\n");
17069 oldsin = peer->
addr;
17073 ao2_t_unlink(peers_by_ip, peer,
"ao2_unlink of peer from peers_by_ip table");
17079 ast_debug(1,
"Store REGISTER's Contact header for call routing.\n");
17101 ast_debug(1,
"Store REGISTER's src-IP:port for call routing.\n");
17108 ast_log(
LOG_WARNING,
"Domain '%s' disallowed by contact ACL (violating IP %s)\n", hostport,
17125 ao2_t_link(peers_by_ip, peer,
"ao2_link into peers_by_ip table");
17143 if (peer->
expire == -1) {
17169 "peer_status",
"Registered",
17176 ast_verb(3,
"Registered SIP '%s' at %s\n", peer->
name,
17186 if (strcasecmp(useragent, peer->
useragent)) {
17216 if ((resp < 100) || (resp > 199)) {
17228 if (*header ==
'\0') {
17240 if (strchr(header,
'<')) {
17243 len = strlen(header);
17245 if (header && len) {
17265 ast_debug(2,
"build_path: do not use Path headers\n");
17268 ast_debug(2,
"build_path: try to build pre-loaded route-set by parsing Path headers\n");
17275 if (*header ==
'\0') {
17280 }
else if (pathbuf) {
17314 for (i = keys; i->
key !=
NULL; i++) {
17315 const char *separator =
",";
17317 if (strncasecmp(c, i->
key, strlen(i->
key)) != 0) {
17321 c += strlen(i->
key);
17342 const char *secret,
const char *md5secret,
int sipmethod,
17343 const char *uri,
enum xmittype reliable)
17345 const char *response;
17346 char *reqheader, *respheader;
17347 const char *authtoken;
17349 char resp_hash[256]=
"";
17351 int is_bogus_peer = 0;
17352 int wrongnonce =
FALSE;
17354 const char *usednonce = p->
nonce;
17360 [
K_RESP] = {
"response=",
"" },
17361 [
K_URI] = {
"uri=",
"" },
17362 [
K_USER] = {
"username=",
"" },
17363 [
K_NONCE] = {
"nonce=",
"" },
17374 response =
"401 Unauthorized";
17430 if (strcmp(username, keys[
K_USER].s) && !is_bogus_peer) {
17432 username, keys[
K_USER].s);
17451 snprintf(a1,
sizeof(a1),
"%s:%s:%s", username, p->
realm, secret);
17464 snprintf(resp,
sizeof(resp),
"%s:%s:%s", a1_hash, usednonce, a2_hash);
17468 good_response = keys[
K_RESP].
s &&
17469 !strncasecmp(keys[
K_RESP].s, resp_hash, strlen(resp_hash)) &&
17472 if (good_response) {
17497 if (good_response) {
17498 append_history(p,
"AuthOK",
"Auth challenge successful for %s", username);
17549 if (!network_change_sub) {
17564 if (!acl_change_sub) {
17594 ast_verb(1,
"SIP, got a network change message, renewing all SIP registrations.\n");
17604 dialog_unref(p,
"the extensionstate containing this dialog ptr was destroyed");
17614 switch (data->
state) {
17718 const char *response =
"401 Unauthorized";
17719 const char *reqheader =
"Authorization";
17720 const char *respheader =
"WWW-Authenticate";
17721 const char *authtoken;
17731 [
K_NONCE] = {
"nonce=",
"" },
17766 for (i = keys; i->key !=
NULL; i++) {
17767 const char *separator =
",";
17769 if (strncasecmp(c, i->key, strlen(i->key)) != 0) {
17773 c += strlen(i->key);
17782 if (i->key == NULL) {
17818 while (*t && *t >
' ' && *t !=
';') {
17925 int expire = atoi(expires);
17929 expire = atoi(expires + 9);
17948 sip_unref_peer(peer,
"register_verify: sip_unref_peer: from sip_find_peer operation");
17959 ast_log(
LOG_ERROR,
"Peer '%s' is trying to register, but not configured as host=dynamic\n", peer->
name);
18017 ao2_t_ref(peer, -1,
"failed to allocate Stasis endpoint, drop peer");
18021 ao2_t_link(peers, peer,
"link peer into peer table");
18023 ao2_t_link(peers_by_ip, peer,
"link peer into peers-by-ip table");
18052 "peer_status",
"Registered",
18085 "peer_status",
"Rejected",
18086 "cause",
"AUTH_SECRET_FAILED",
18087 "address", peer_addr,
18088 "port", peer_port);
18106 "peer_status",
"Rejected",
18108 "address", peer_addr,
18109 "port", peer_port);
18120 "peer_status",
"Rejected",
18121 "cause",
"AUTH_PEER_NOT_DYNAMIC",
18122 "address", peer_addr,
18123 "port", peer_port);
18132 "peer_status",
"Rejected",
18134 "address", peer_addr,
18135 "port", peer_port);
18150 sip_unref_peer(peer,
"register_verify: sip_unref_peer: tossing stack peer pointer at end of func");
18159 if (!strcmp(reason,
"unknown")) {
18161 }
else if (!strcmp(reason,
"user-busy")) {
18163 }
else if (!strcmp(reason,
"no-answer")) {
18165 }
else if (!strcmp(reason,
"unavailable")) {
18167 }
else if (!strcmp(reason,
"unconditional")) {
18169 }
else if (!strcmp(reason,
"time-of-day")) {
18171 }
else if (!strcmp(reason,
"do-not-disturb")) {
18173 }
else if (!strcmp(reason,
"deflection")) {
18175 }
else if (!strcmp(reason,
"follow-me")) {
18177 }
else if (!strcmp(reason,
"out-of-service")) {
18179 }
else if (!strcmp(reason,
"away")) {
18196 char emptyname[1] =
"";
18199 int is_anonymous = 0, do_update = 1, no_name = 0;
18217 if (!strncasecmp(uri,
"sip:anonymous@anonymous.invalid", 31)) {
18224 cid_num = (
char *)p->
cid_num;
18233 cid_name = (
char *)emptyname;
18252 if (!is_anonymous) {
18273 char *privacy =
"";
18297 if (*start ==
'"') {
18299 end = strchr(start,
'"');
18308 start = end = strchr(start,
'<');
18313 while (--end >= cid_name && *end < 33) {
18321 end = strchr(start,
'@');
18325 if (strncasecmp(start,
"sip:", 4))
18327 cid_num = start + 4;
18332 end = strchr(start,
'>');
18342 end = strchr(start,
';');
18345 if (!strncasecmp(start,
"privacy=", 8))
18346 privacy = start + 8;
18347 else if (!strncasecmp(start,
"screen=", 7))
18348 screen = start + 7;
18352 if (!strcasecmp(privacy,
"full")) {
18353 if (!strcasecmp(screen,
"yes"))
18355 else if (!strcasecmp(screen,
"no"))
18358 if (!strcasecmp(screen,
"yes"))
18360 else if (!strcasecmp(screen,
"no"))
18396 char tmp[256], *
exten, *rexten, *rdomain, *rname =
NULL;
18397 char *params, *reason_param =
NULL;
18403 req = oreq ? oreq : &p->
initreq;
18409 if ((params = strchr(tmp,
'>'))) {
18410 params = strchr(params,
';');
18414 if (!strncasecmp(exten,
"sip:", 4)) {
18416 }
else if (!strncasecmp(exten,
"sips:", 5)) {
18427 while (*params ==
';' || *params ==
' ')
18430 if ((reason_param =
strcasestr(params,
"reason="))) {
18433 if ((end = strchr(reason_param,
';'))) {
18440 rexten =
strsep(&rdomain,
"@");
18445 ast_verbose(
"RDNIS for this call is %s (reason %s)\n", exten,
S_OR(reason_param,
""));
18449 if (*tmp ==
'\"') {
18452 end_quote = strchr(rname,
'\"');
18462 if (name && rname) {
18470 if (*reason_param ==
'"') {
18475 if (*reason_code < 0) {
18510 char tmp[256] =
"", *uri, *unused_password, *
domain;
18516 const char *pickupexten;
18519 ast_log(
LOG_ERROR,
"Unable to retrieve pickup configuration options. Unable to detect call pickup extension\n");
18523 pickupexten = pickup_cfg->pickupexten;
18586 domain_context[0] =
'\0';
18640 || !strcmp(decoded_uri, pickupexten)) {
18657 if (cc_recall_core_id) {
18658 *cc_recall_core_id = agent->
core_id;
18668 || !strncmp(decoded_uri, pickupexten, strlen(decoded_uri)))) {
18697 struct sip_pvt tmp_dialog = {
18702 ast_debug(4,
"Looking for callid %s (fromtag %s totag %s)\n", callid, fromtag ? fromtag :
"<no fromtag>", totag ? totag :
"<no totag>");
18707 sip_pvt_ptr =
ao2_t_find(dialogs, &tmp_dialog,
OBJ_POINTER,
"ao2_find of dialog in dialogs table");
18712 unsigned char frommismatch = 0, tomismatch = 0;
18715 ast_debug(4,
"Matched %s call for callid=%s - no from tag specified, pedantic check fails\n",
18716 sip_pvt_ptr->outgoing_call ==
TRUE ?
"OUTGOING":
"INCOMING", sip_pvt_ptr->callid);
18721 ast_debug(4,
"Matched %s call for callid=%s - no to tag specified, pedantic check fails\n",
18722 sip_pvt_ptr->outgoing_call ==
TRUE ?
"OUTGOING":
"INCOMING", sip_pvt_ptr->callid);
18739 frommismatch = !!strcmp(fromtag, sip_pvt_ptr->theirtag);
18740 tomismatch = !!strcmp(totag, sip_pvt_ptr->tag);
18746 if (frommismatch) {
18747 ast_debug(4,
"Matched %s call for callid=%s - pedantic from tag check fails; their tag is %s our tag is %s\n",
18748 sip_pvt_ptr->outgoing_call ==
TRUE ?
"OUTGOING":
"INCOMING", sip_pvt_ptr->callid,
18749 fromtag, sip_pvt_ptr->theirtag);
18752 ast_debug(4,
"Matched %s call for callid=%s - pedantic to tag check fails; their tag is %s our tag is %s\n",
18753 sip_pvt_ptr->outgoing_call ==
TRUE ?
"OUTGOING":
"INCOMING", sip_pvt_ptr->callid,
18754 totag, sip_pvt_ptr->tag);
18761 ast_debug(4,
"Matched %s call - their tag is %s Our tag is %s\n",
18762 sip_pvt_ptr->outgoing_call ==
TRUE ?
"OUTGOING":
"INCOMING",
18763 sip_pvt_ptr->theirtag, sip_pvt_ptr->tag);
18765 *out_pvt = sip_pvt_ptr;
18771 if (!sip_pvt_ptr) {
18777 sip_pvt_ptr =
NULL;
18788 if (strcmp(prefix,
"*") == 0) {
18792 for (i = 0; i < req->
headers; i++) {
18795 int hdrlen = strcspn(header,
" \t:");
18797 if (hdrlen > 0 && *val ==
':') {
18798 ast_str_set(&pbxvar, -1,
"~HASH~TRANSFER_DATA~%.*s~", hdrlen, header);
18814 const char *p_referred_by =
NULL;
18815 char *h_refer_to =
NULL;
18816 char *h_referred_by =
NULL;
18818 const char *p_refer_to;
18819 char *referred_by_uri =
NULL;
18822 const char *transfer_context =
NULL;
18825 req = outgoing_req;
18826 refer = transferer->
refer;
18839 if (!strncasecmp(refer_to,
"sip:", 4)) {
18841 }
else if (!strncasecmp(refer_to,
"sips:", 5)) {
18844 ast_log(
LOG_WARNING,
"Can't transfer to non-sip: URI. (Refer-to: %s)?\n", refer_to);
18852 if (transferer->
owner) {
18867 const char *get_xfrdata;
18883 if (!owner_relock) {
18884 ast_debug(3,
"Unable to reacquire owner channel lock, channel is gone\n");
18894 if (!strncasecmp(referred_by_uri,
"sip:", 4)) {
18895 referred_by_uri += 4;
18896 }
else if (!strncasecmp(referred_by_uri,
"sips:", 5)) {
18897 referred_by_uri += 5;
18899 ast_log(
LOG_WARNING,
"Huh? Not a sip: header (Referred-by: %s). Skipping.\n", referred_by_uri);
18900 referred_by_uri =
NULL;
18905 if ((ptr =
strcasestr(refer_to,
"replaces="))) {
18906 char *to =
NULL, *from =
NULL, *callid;
18913 if ((ptr = strchr(callid,
';'))) {
18927 if ((to = strchr(ptr,
'&'))) {
18930 if ((to = strchr(ptr,
';'))) {
18938 if ((from = strchr(ptr,
'&'))) {
18941 if ((from = strchr(ptr,
';'))) {
18956 ast_debug(2,
"Attended transfer: Will use Replace-Call-ID : %s (No check of from/to tags)\n", refer->
replaces_callid);
18962 if ((ptr = strchr(refer_to,
'@'))) {
18967 if ((urioption = strchr(ptr,
';'))) {
18968 *urioption++ =
'\0';
18974 for (; *ptr !=
'\0'; ++ptr) {
18975 if (*ptr ==
':' && bracket == 0) {
18978 }
else if (*ptr ==
'[') {
18980 }
else if (*ptr ==
']') {
18995 if ((ptr = strchr(refer_to,
';')))
19001 if (referred_by_uri) {
19002 if ((ptr = strchr(referred_by_uri,
';')))
19011 if (transferer->
owner) {
19027 ast_verbose(
"SIP transfer to extension %s@%s by %s\n", refer_to, transfer_context,
S_OR(referred_by_uri,
"Unknown"));
19033 ast_verbose(
"Failed SIP Transfer to non-existing extension %s in context %s\n n", refer_to, transfer_context);
19045 char tmp[256] =
"", *
c, *
a;
19048 const char *transfer_context =
NULL;
19088 ast_debug(1,
"SIP Bye-also transfer to Extension %s@%s \n",
c, transfer_context);
19174 if (!strncasecmp(via,
"SIP/2.0/WS", 10)) {
19179 c = strchr(via,
',');
19184 c = strstr(via,
";rport");
19185 if (c && (c[6] !=
'=')) {
19191 maddr = strstr(via,
"maddr=");
19194 c = maddr + strspn(maddr,
"abcdefghijklmnopqrstuvwxyz" 19195 "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-.:[]");
19199 c = strchr(via,
';');
19203 c = strchr(via,
' ');
19207 if (strcasecmp(via,
"SIP/2.0/UDP") && strcasecmp(via,
"SIP/2.0/TCP") && strcasecmp(via,
"SIP/2.0/TLS")) {
19240 enum xmittype reliable,
char *calleridname,
char *uri2)
19258 char *uri_tmp, *callback =
NULL, *
dummy;
19260 parse_uri(uri_tmp,
"sip:,sips:,tel:", &callback, &dummy, &dummy, &dummy);
19271 ast_verbose(
"No matching peer for '%s' from '%s'\n",
19295 ast_debug(2,
"Found peer '%s' for '%s', but fails host access\n", peer->
name, of);
19296 sip_unref_peer(peer,
"sip_unref_peer: check_peer_ok: from sip_find_peer call, early return of AUTH_ACL_FAILED");
19299 if (debug && peer != bogus_peer) {
19300 ast_verbose(
"Found peer '%s' for '%s' from %s\n",
19392 ao2_t_ref(peer, 1,
"copy pointer into (*authpeer)");
19393 (*authpeer) = peer;
19475 sip_unref_peer(peer,
"check_peer_ok: sip_unref_peer: tossing temp ptr to peer from sip_find_peer");
19494 char calleridname[256];
19503 if (!(of = (
char *)
get_calleridname(ofbuf, calleridname,
sizeof(calleridname)))) {
19508 if (calleridname[0]) {
19514 if (!strncasecmp(t,
"sip:", 4)) {
19516 }
else if (!strncasecmp(t,
"sips:", 5)) {
19518 }
else if (!strncasecmp(t,
"tel:", 4)) {
19522 t = strchr(p->
exten,
'@');
19562 tmp =
strsep(&tmp,
";");
19584 namebuf = name =
ast_strdup(hdr + strlen(
"username=\""));
19585 name =
strsep(&name,
"\"");
19590 authpeer, reliable, calleridname, uri2);
19628 const char *response;
19640 response =
"403 Forbidden";
19646 response =
"480 Temporarily Unavailable";
19657 response =
"503 Service Unavailable";
19665 response =
"503 Service Unavailable";
19678 char name_buf[1024];
19679 char val_buf[1024];
19684 for (x = 0; x < req->
headers; x++) {
19687 if ((c = strchr(header,
':'))) {
19717 char from_name[50];
19721 if (strncmp(content_type,
"text/plain", strlen(
"text/plain"))) {
19742 if (buf[--len] !=
'\n') {
19751 ast_verbose(
"SIP Text message received: '%s'\n", buf);
19753 memset(&f, 0,
sizeof(f));
19773 ast_debug(1,
"MESSAGE outside of a call administratively disabled.\n");
19815 peer =
sip_unref_peer(peer,
"from sip_find_peer() in receive_message");
19829 switch (dest_result) {
19859 if (from_name[0]) {
19860 char from_buf[128];
19899 switch (dest_result) {
19918 #define FORMAT "%-25.25s %-15.15s %-15.15s \n" 19919 #define FORMAT2 "%-25.25s %-15.15s %-15.15s \n" 19922 int showall =
FALSE;
19928 e->
command =
"sip show inuse [all]";
19930 "Usage: sip show inuse [all]\n" 19931 " List all SIP devices usage counters and limits.\n" 19932 " Add option \"all\" to show all devices, not only those with a limit.\n";
19941 if (a->
argc == 4 && !strcmp(a->
argv[3],
"all"))
19950 snprintf(ilimits,
sizeof(ilimits),
"%d", peer->
call_limit);
19953 snprintf(iused,
sizeof(iused),
"%d/%d/%d", peer->
inuse, peer->
ringing, peer->
onhold);
19992 return map_x_s(stmodes, m,
"Unknown");
19997 return map_s_x(stmodes, s, -1);
20017 return map_x_s(strefresher_params, r,
"Unknown");
20022 return map_s_x(strefresher_params, s, -1);
20035 return map_x_s(strefreshers, r,
"Unknown");
20040 return map_x_s(autopeermodes, r,
"Unknown");
20050 snprintf(status, statuslen,
"LAGGED (%d ms)", peer->
lastms);
20052 }
else if (peer->
lastms) {
20053 snprintf(status, statuslen,
"OK (%d ms)", peer->
lastms);
20072 #define FORMAT2 "%-47.47s %9.9s %6.6s\n" 20073 #define FORMAT "%-47.47s %-9.9s %-6.6s\n" 20079 "Usage: sip show tcp\n" 20080 " Lists all active TCP/TLS sessions.\n";
20092 while ((th =
ao2_t_iterator_next(&i,
"iterate through tcp threads for 'sip show tcp'"))) {
20097 ao2_t_ref(th, -1,
"decrement ref from iterator");
20110 int havepattern =
FALSE;
20114 #define FORMAT "%-25.25s %-15.15s %-15.15s %-15.15s %-5.5s%-10.10s\n" 20118 e->
command =
"sip show users [like]";
20120 "Usage: sip show users [like <pattern>]\n" 20121 " Lists all known SIP users.\n" 20122 " Optional regular expression pattern is used to filter the user list.\n";
20130 if (!strcasecmp(a->
argv[3],
"like")) {
20131 if (regcomp(®exbuf, a->
argv[4], REG_EXTENDED | REG_NOSUB))
20133 havepattern =
TRUE;
20142 ast_cli(a->
fd,
FORMAT,
"Username",
"Secret",
"Accountcode",
"Def.Context",
"ACL",
"Forcerport");
20153 if (havepattern && regexec(®exbuf, user->
name, 0,
NULL, 0)) {
20171 regfree(®exbuf);
20181 char idtext[256] =
"";
20187 snprintf(idtext,
sizeof(idtext),
"ActionID: %s\r\n",
id);
20196 "Event: RegistryEntry\r\n" 20202 "DomainPort: %d\r\n" 20205 "RegistrationTime: %ld\r\n" 20215 (
long) iterator->
regtime.tv_sec);
20218 ao2_t_ref(iterator, -1,
"manager_show_registry iter");
20234 const char *
a[] = {
"sip",
"show",
"peers"};
20235 char idtext[256] =
"";
20239 snprintf(idtext,
sizeof(idtext),
"ActionID: %s\r\n",
id);
20257 e->
command =
"sip show peers [like]";
20259 "Usage: sip show peers [like <pattern>]\n" 20260 " Lists all known SIP peers.\n" 20261 " Optional regular expression pattern is used to filter the peer list.\n";
20276 return strcmp((*ap)->name, (*bp)->name);
20280 #define PEERS_FORMAT2 "%-25.25s %-39.39s %-3.3s %-10.10s %-10.10s %-3.3s %-8s %-11s %-32.32s %s\n" 20301 .peers_mon_online = 0,
20302 .peers_mon_offline = 0,
20303 .peers_unmon_online = 0,
20304 .peers_unmon_offline = 0,
20310 int total_peers = 0;
20320 snprintf(cont.
idtext,
sizeof(cont.
idtext),
"ActionID: %s\r\n",
id);
20326 if (!strcasecmp(argv[3],
"like")) {
20327 if (regcomp(&cont.
regexbuf, argv[4], REG_EXTENDED | REG_NOSUB)) {
20342 ast_cli(fd,
PEERS_FORMAT2,
"Name/username",
"Host",
"Dyn",
"Forcerport",
"Comedia",
"ACL",
"Port",
"Status",
"Description", (cont.
realtimepeers ?
"Realtime" :
""));
20364 sip_unref_peer(peer,
"unref peer because it's actually a user");
20374 peerarray[total_peers++] = peer;
20379 qsort(peerarray, total_peers,
sizeof(
struct sip_peer *), peercomparefunc);
20381 for(k = 0; k < total_peers; k++) {
20386 ast_cli(fd,
"%d sip peers [Monitored: %d online, %d offline Unmonitored: %d online, %d offline]\n",
20395 *total = total_peers;
20435 snprintf(name,
sizeof(name),
"%s/%s", peer->
name, peer->
username);
20440 pstatus =
peer_status(peer, status,
sizeof(status));
20441 if (pstatus == 1) {
20443 }
else if (pstatus == 0) {
20467 "Event: PeerEntry\r\n%s" 20468 "Channeltype: SIP\r\n" 20469 "ObjectName: %s\r\n" 20470 "ChanObjectType: peer\r\n" 20471 "IPaddress: %s\r\n" 20474 "AutoForcerport: %s\r\n" 20475 "Forcerport: %s\r\n" 20476 "AutoComedia: %s\r\n" 20478 "VideoSupport: %s\r\n" 20479 "TextSupport: %s\r\n" 20482 "RealtimeDevice: %s\r\n" 20483 "Description: %s\r\n" 20484 "Accountcode: %s\r\n" 20507 #undef PEERS_FORMAT2 20515 ast_cli(a->
fd,
"name: %s\ntype: peer\nobjflags: %d\nrefcount: %d\n\n",
20516 peer->
name, 0, refc);
20522 struct sip_pvt *pvt = userobj;
20526 ast_cli(a->
fd,
"name: %s\ntype: dialog\nobjflags: %d\nrefcount: %d\n\n",
20540 e->
command =
"sip show objects";
20542 "Usage: sip show objects\n" 20543 " Lists status of known SIP objects\n";
20553 ast_cli(a->
fd,
"-= Peer objects by IP =-\n\n");
20562 ao2_t_ref(reg, -1,
"sip_show_objects iter");
20566 ast_cli(a->
fd,
"-= Dialog objects:\n\n");
20600 return map_x_s(dtmfstr, mode,
"<error>");
20606 return map_s_x(dtmfstr, str, -1);
20620 return map_x_s(insecurestr, mode,
"<error>");
20633 return map_x_s(allowoverlapstr, mode,
"<error>");
20645 return map_x_s(trust_id_outboundstr, mode,
"<error>");
20653 char *oldcontext, *newcontext, *stalecontext, *stringp, newlist[
AST_MAX_CONTEXT];
20655 while ((oldcontext =
strsep(&old,
"&"))) {
20656 stalecontext =
NULL;
20659 while ((newcontext =
strsep(&stringp,
"&"))) {
20660 if (!strcmp(newcontext, oldcontext)) {
20662 stalecontext =
NULL;
20664 }
else if (strcmp(newcontext, oldcontext)) {
20665 stalecontext = oldcontext;
20683 struct sip_pvt *dialog = dialogobj;
20691 if (dialog->
rtp || dialog->
vrtp) {
20699 return match_status;
20714 struct sip_pvt *dialog = dialogobj;
20756 int prunepeer =
FALSE;
20760 int havepattern = 0;
20762 static const char *
const choices[] = {
"all",
"like",
NULL };
20766 e->
command =
"sip prune realtime [peer|all]";
20768 "Usage: sip prune realtime [peer [<name>|all|like <pattern>]|all]\n" 20769 " Prunes object(s) from the cache.\n" 20770 " Optional regular expression pattern is used to filter the objects.\n";
20773 if (a->
pos == 4 && !strcasecmp(a->
argv[3],
"peer")) {
20779 if (a->
pos == 5 && !strcasecmp(a->
argv[4],
"like"))
20787 if (!strcasecmp(name,
"peer") || !strcasecmp(name,
"like"))
20790 if (!strcasecmp(name,
"all")) {
20799 if (!strcasecmp(a->
argv[3],
"peer"))
20801 else if (!strcasecmp(a->
argv[3],
"like")) {
20806 if (!strcasecmp(name,
"like"))
20808 if (!multi && !strcasecmp(name,
"all")) {
20817 if (strcasecmp(a->
argv[4],
"like"))
20819 if (!strcasecmp(a->
argv[3],
"peer")) {
20828 if (multi && name) {
20829 if (regcomp(®exbuf, name, REG_EXTENDED | REG_NOSUB)) {
20842 if (name && regexec(®exbuf, pi->
name, 0,
NULL, 0)) {
20857 ast_cli(a->
fd,
"%d peers pruned.\n", pruned);
20859 ast_cli(a->
fd,
"No peers found to prune.\n");
20867 ao2_t_unlink(peers_by_ip, peer,
"unlinking peer from peers_by_ip also");
20870 ast_cli(a->
fd,
"Peer '%s' is not a Realtime peer, cannot be pruned.\n", name);
20872 ao2_t_link(peers, peer,
"link peer into peer table");
20874 ao2_t_link(peers_by_ip, peer,
"link peer into peers_by_ip table");
20877 ast_cli(a->
fd,
"Peer '%s' pruned.\n", name);
20878 sip_unref_peer(peer,
"sip_prune_realtime: sip_unref_peer: tossing temp peer ptr");
20880 ast_cli(a->
fd,
"Peer '%s' not found.\n", name);
20885 regfree(®exbuf);
20896 return "[Automatic]";
20898 return "[Configured]";
20908 #define FORMAT "%-40.40s %-20.20s %-16.16s\n" 20912 e->
command =
"sip show domains";
20914 "Usage: sip show domains\n" 20915 " Lists all configured SIP local domains.\n" 20916 " Asterisk only responds to SIP messages to local domains.\n";
20923 ast_cli(a->
fd,
"SIP Domain support not enabled.\n\n");
20926 ast_cli(a->
fd,
FORMAT,
"Our local SIP domains:",
"Context",
"Set by");
20964 e->
command =
"sip show peer";
20966 "Usage: sip show peer <name> [load]\n" 20967 " Shows all details on one SIP peer and the current status.\n" 20968 " Option \"load\" forces lookup of peer in realtime storage.\n";
20972 static const char *
const completions[] = {
"load",
NULL };
20983 char time[128] =
"";
20987 snprintf(status,
sizeof(status),
"PeerStatus: Unreachable\r\n");
20989 snprintf(status,
sizeof(status),
"PeerStatus: Lagged\r\n");
20990 snprintf(time,
sizeof(time),
"Time: %d\r\n", peer->
lastms);
20991 }
else if (peer->
lastms) {
20992 snprintf(status,
sizeof(status),
"PeerStatus: Reachable\r\n");
20993 snprintf(time,
sizeof(time),
"Time: %d\r\n", peer->
lastms);
20995 snprintf(status,
sizeof(status),
"PeerStatus: Unknown\r\n");
20998 snprintf(status,
sizeof(status),
"PeerStatus: Unmonitored\r\n");
21002 "Event: PeerStatus\r\n" 21003 "Privilege: System\r\n" 21004 "ChannelType: SIP\r\n" 21010 peer->
name, status, time, idText);
21024 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n",
id);
21029 if (strlen(peer_name) >= 4 && !strncasecmp(
"SIP/", peer_name, 4)) {
21074 body =
ast_json_pack(
"{s: s, s: s}",
"Peer", peer,
"ActionID",
id);
21092 load_realtime = (argc == 5 && !strcmp(argv[4],
"load")) ?
TRUE :
FALSE;
21105 }
else if (type == 0) {
21106 ast_cli(fd,
"Peer '%s' not found\n", argv[3]);
21139 e->
command =
"sip qualify peer";
21141 "Usage: sip qualify peer <name> [load]\n" 21142 " Requests a response from one SIP peer and the current status.\n" 21143 " Option \"load\" forces lookup of peer in realtime storage.\n";
21147 static const char *
const completions[] = {
"load",
NULL };
21177 return map_x_s(faxecmodes, faxec,
"Unknown");
21188 int x = 0, load_realtime;
21196 load_realtime = (argc == 5 && !strcmp(argv[4],
"load")) ?
TRUE :
FALSE;
21207 snprintf (cbuf,
sizeof(cbuf),
"Peer %s not found.", argv[3]);
21212 if (peer && type==0 ) {
21218 credentials = peer->
auth;
21220 ao2_t_ref(credentials, +1,
"Ref peer auth for show");
21227 if (realtimepeers) {
21237 ast_cli(fd,
" Realm-auth : Realm %-15.15s User %-10.20s %s\n",
21243 ?
"<MD5secret set>" :
"<Not set>"));
21245 ao2_t_ref(credentials, -1,
"Unref peer auth for show");
21252 ast_cli(fd,
" Tonezone : %s\n", peer->
zone[0] !=
'\0' ? peer->
zone :
"<Not set>");
21262 ast_cli(fd,
" Callgroup : ");
21264 ast_cli(fd,
" Pickupgroup : ");
21266 ast_cli(fd,
" Named Callgr : ");
21268 ast_cli(fd,
" Nam. Pickupgr: ");
21324 ast_cli(fd,
" SIP Options : ");
21326 int lastoption = -1;
21349 ast_cli(fd,
" Variables :\n");
21364 peer =
sip_unref_peer(peer,
"sip_show_peer: sip_unref_peer: done with peer ptr");
21365 }
else if (peer && type == 1) {
21459 peer =
sip_unref_peer(peer,
"sip_show_peer: sip_unref_peer: done with peer");
21462 ast_cli(fd,
"Peer %s not found.\n", argv[3]);
21473 int wordlen = strlen(word);
21487 if (!strncasecmp(word, user->
name, wordlen) && ++which > state) {
21518 e->
command =
"sip show user";
21520 "Usage: sip show user <name> [load]\n" 21521 " Shows all details on one SIP user and the current status.\n" 21522 " Option \"load\" forces lookup of peer in realtime storage.\n";
21526 static const char *
const completions[] = {
"load",
NULL };
21550 ast_cli(a->
fd,
" Tonezone : %s\n", user->
zone[0] !=
'\0' ? user->
zone :
"<Not set>");
21598 "__sip_autodestruct",
21603 "sip_poke_peer_now",
21604 "sip_poke_noanswer",
21606 "sip_reinvite_retry" 21624 e->
command =
"sip show sched";
21626 "Usage: sip show sched\n" 21627 " Shows stats on what's in the sched queue at the moment\n";
21645 #define FORMAT2 "%-39.39s %-6.6s %-12.12s %8.8s %-20.20s %-25.25s\n" 21646 #define FORMAT "%-39.39s %-6.6s %-12.12s %8d %-20.20s %-25.25s\n" 21657 e->
command =
"sip show registry";
21659 "Usage: sip show registry\n" 21660 " Lists all registration requests and status.\n";
21668 ast_cli(a->
fd,
FORMAT2,
"Host",
"dnsmgr",
"Username",
"Refresh",
"State",
"Reg.Time");
21675 snprintf(user,
sizeof(user),
"%s", iterator->
username);
21677 snprintf(tmpdat,
sizeof(tmpdat),
"%s", user);
21678 snprintf(user,
sizeof(user),
"%s@%s", tmpdat, iterator->
regdomain);}
21680 snprintf(tmpdat,
sizeof(tmpdat),
"%s", user);
21681 snprintf(user,
sizeof(user),
"%s:%d", tmpdat, iterator->
regdomainport);}
21682 if (iterator->
regtime.tv_sec) {
21684 ast_strftime(tmpdat,
sizeof(tmpdat),
"%a, %d %b %Y %T", &tm);
21690 ao2_t_ref(iterator, -1,
"sip_show_registry iter");
21695 ast_cli(a->
fd,
"%d SIP registrations.\n", counter);
21708 int load_realtime = 0;
21712 e->
command =
"sip unregister";
21714 "Usage: sip unregister <peer>\n" 21715 " Unregister (force expiration) a SIP peer from the registry\n";
21725 if (peer->
expire > -1) {
21729 ast_cli(a->
fd,
"Unregistered peer \'%s\'\n\n", a->
argv[2]);
21733 sip_unref_peer(peer,
"sip_unregister: sip_unref_peer via sip_unregister: done with peer from sip_find_peer call");
21735 ast_cli(a->
fd,
"Peer unknown: \'%s\'. Not unregistered.\n", a->
argv[2]);
21744 #define FORMAT2 "%-15.15s %-11.11s %-8.8s %-10.10s %-10.10s ( %%) %-6.6s %-10.10s %-10.10s ( %%) %-6.6s\n" 21745 #define FORMAT "%-15.15s %-11.11s %-8.8s %-10.10u%-1.1s %-10.10u (%5.2f%%) %-6.4lf %-10.10u%-1.1s %-10.10u (%5.2f%%) %-6.4lf\n" 21762 ast_cli(fd,
"%-15.15s %-11.11s (inv state: %s) -- %s\n",
21765 "-- No RTP active");
21787 stats.
rxcount > (
unsigned int) 100000 ? (
unsigned int) (stats.
rxcount)/(
unsigned int) 1000 : stats.
rxcount,
21788 stats.
rxcount > (
unsigned int) 100000 ?
"K":
" ",
21792 stats.
txcount > (
unsigned int) 100000 ? (
unsigned int) (stats.
txcount)/(
unsigned int) 1000 : stats.
txcount,
21793 stats.
txcount > (
unsigned int) 100000 ?
"K":
" ",
21813 e->
command =
"sip show channelstats";
21815 "Usage: sip show channelstats\n" 21816 " Lists all currently active SIP channel's RTCP statistics.\n" 21817 " Note that calls in the much optimized RTP P2P bridge mode will not show any packets here.";
21826 ast_cli(a->
fd,
FORMAT2,
"Peer",
"Call ID",
"Duration",
"Recv: Pack",
"Lost",
"Jitter",
"Send: Pack",
"Lost",
"Jitter");
21852 e->
command =
"sip show settings";
21854 "Usage: sip show settings\n" 21855 " Provides detailed list of the configuration of the SIP channel.\n";
21868 credentials =
authl;
21870 ao2_t_ref(credentials, +1,
"Ref global auth for show");
21874 ast_cli(a->
fd,
"\n\nGlobal Settings:\n");
21878 ast_cli(a->
fd,
" ** Additional Info:\n");
21879 ast_cli(a->
fd,
" [::] may include IPv4 in addition to IPv6, if such a feature is enabled in the OS.\n");
21881 ast_cli(a->
fd,
" TCP SIP Bindaddress: %s\n",
21885 ast_cli(a->
fd,
" TLS SIP Bindaddress: %s\n",
21889 ast_cli(a->
fd,
" RTP Bindaddress: %s\n",
21910 ast_cli(a->
fd,
" Realm. auth entry: Realm %-15.15s User %-10.20s %s\n",
21916 ?
"<MD5secret set>" :
"<Not set>"));
21918 ao2_t_ref(credentials, -1,
"Unref global auth for show");
21947 if (!realtimepeers && !realtimeregs)
21948 ast_cli(a->
fd,
" SIP realtime: Disabled\n" );
21950 ast_cli(a->
fd,
" SIP realtime: Enabled\n" );
21954 ast_cli(a->
fd,
"\nNetwork QoS Settings:\n");
21955 ast_cli(a->
fd,
"---------------------------\n");
21976 ast_cli(a->
fd,
"\nNetwork Settings:\n");
21977 ast_cli(a->
fd,
"---------------------------\n");
21979 if (localaddr ==
NULL)
21980 msg =
"Disabled, no localnet list";
21984 msg =
"Enabled using externhost";
21986 msg =
"Enabled using externaddr";
21987 ast_cli(a->
fd,
" SIP address remapping: %s\n", msg);
21993 const char *
prefix =
"Localnet:";
21995 for (d = localaddr;
d ; prefix =
"", d = d->
next) {
21998 ast_cli(a->
fd,
" %-24s%s/%s\n", prefix, addr, mask);
22001 ast_cli(a->
fd,
"\nGlobal Signalling Settings:\n");
22002 ast_cli(a->
fd,
"---------------------------\n");
22044 ast_cli(a->
fd,
"\nDefault Settings:\n");
22065 if (realtimepeers || realtimeregs) {
22066 ast_cli(a->
fd,
"\nRealtime SIP Settings:\n");
22067 ast_cli(a->
fd,
"----------------------\n");
22083 #define FORMAT "%-30.30s %-12.12s %-10.10s %-10.10s\n" 22092 "Usage: sip show mwi\n" 22093 " Provides a list of MWI subscriptions and status.\n";
22107 ao2_t_ref(iterator, -1,
"sip_show_mwi iter");
22149 #define FORMAT4 "%-15.15s %-15.15s %-15.15s %-15.15s %-13.13s %-15.15s %-10.10s %-6.6d\n" 22150 #define FORMAT3 "%-15.15s %-15.15s %-15.15s %-15.15s %-13.13s %-15.15s %-10.10s %-6.6s\n" 22151 #define FORMAT2 "%-15.15s %-15.15s %-15.15s %-15.15s %-7.7s %-15.15s %-10.10s %-10.10s\n" 22152 #define FORMAT "%-15.15s %-15.15s %-15.15s %-15.15s %-3.3s %-3.3s %-15.15s %-10.10s %-10.10s\n" 22212 e->
command =
"sip show {channels|subscriptions}";
22214 "Usage: sip show channels\n" 22215 " Lists all currently active SIP calls (dialogs).\n" 22216 "Usage: sip show subscriptions\n" 22217 " Lists active SIP subscriptions.\n";
22226 ast_cli(arg.
fd,
FORMAT2,
"Peer",
"User/ANR",
"Call ID",
"Format",
"Hold",
"Last Message",
"Expiry",
"Peer");
22228 ast_cli(arg.
fd,
FORMAT3,
"Peer",
"User",
"Call ID",
"Extension",
"Last state",
"Type",
"Mailbox",
"Expiry");
22257 int wordlen = strlen(word);
22267 if (!strncasecmp(word, cur->
callid, wordlen) && ++which > state) {
22285 int wordlen = strlen(word);
22292 if (!strncasecmp(word, peer->
name, wordlen) &&
22309 int wordlen = strlen(word);
22316 if (!strncasecmp(word, peer->
name, wordlen) &&
22318 ++which > state && peer->
expire > -1)
22366 int wordlen = strlen(word);
22374 if (!strncasecmp(word, cat, wordlen) && ++which > state) {
22398 e->
command =
"sip show channel";
22400 "Usage: sip show channel <call-id>\n" 22401 " Provides detailed status on a given SIP dialog (identified by SIP call-id).\n";
22409 len = strlen(a->
argv[3]);
22415 if (!strncasecmp(cur->
callid, a->
argv[3], len)) {
22442 " Audio IP: %s (local)\n",
22446 " Audio IP: %s (Outside bridge)\n",
22485 ast_cli(a->
fd,
" Session-Timer: Uninitiallized\n");
22502 ast_cli(a->
fd,
" Media: %s\n", cur->
srtp ?
"SRTP" : cur->
rtp ?
"RTP" :
"None");
22511 ao2_t_ref(cur, -1,
"toss dialog ptr set by iterator_next");
22516 ast_cli(a->
fd,
"No such SIP Call ID starting with '%s'\n", a->
argv[3]);
22532 e->
command =
"sip show history";
22534 "Usage: sip show history <call-id>\n" 22535 " Provides detailed dialog history on a given SIP call (specified by call-id).\n";
22541 if (a->
argc != 4) {
22546 ast_cli(a->
fd,
"\n***Note: History recording is currently DISABLED. Use 'sip set history on' to ENABLE.\n");
22549 len = strlen(a->
argv[3]);
22554 if (!strncasecmp(cur->
callid, a->
argv[3], len)) {
22574 ao2_t_ref(cur, -1,
"toss dialog ptr from iterator_next");
22579 ast_cli(a->
fd,
"No such SIP Call ID starting with '%s'\n", a->
argv[3]);
22590 static int errmsg = 0;
22598 ast_log(
LOG_NOTICE,
"You must have debugging enabled (SIP or Asterisk) in order to dump SIP history.\n");
22624 const char *
buf =
"";
22625 unsigned int event;
22630 if (!strcasecmp(c,
"application/hook-flash")) {
22635 ast_verbose(
"* DTMF-relay event received: FLASH\n");
22641 if (!strcasecmp(c,
"application/dtmf-relay") ||
22642 !strcasecmp(c,
"application/vnd.nortelnetworks.digits") ||
22643 !strcasecmp(c,
"application/dtmf")) {
22644 unsigned int duration = 0;
22654 if (strcasecmp(c,
"application/dtmf")) {
22660 "call %s\n", p->
callid);
22665 sscanf(tmp,
"%30u", &duration);
22682 if (buf[0] ==
'*') {
22684 }
else if (buf[0] ==
'#') {
22686 }
else if (buf[0] ==
'!') {
22688 }
else if (
'A' <= buf[0] && buf[0] <=
'D') {
22689 event = 12 + buf[0] -
'A';
22690 }
else if (
'a' <= buf[0] && buf[0] <=
'd') {
22691 event = 12 + buf[0] -
'a';
22692 }
else if ((sscanf(buf,
"%30u", &event) != 1) || event > 16) {
22694 "value for INFO message on call %s\n", p->
callid);
22704 ast_verbose(
"* DTMF-relay event received: FLASH\n");
22711 }
else if (event == 10) {
22713 }
else if (event == 11) {
22726 }
else if (!strcasecmp(c,
"application/media_control+xml")) {
22753 int suppress_warning = 0;
22763 if (!strcasecmp(c,
"on")) {
22765 suppress_warning = 1;
22769 }
else if (!strcasecmp(c,
"off")) {
22771 suppress_warning = 1;
22776 ast_log(
LOG_ERROR,
"Received INFO requesting to record with invalid value: %s\n", c);
22780 if (!suppress_warning) {
22781 ast_log(
LOG_WARNING,
"Recording requested, but no One Touch Monitor registered. (See features.conf)\n");
22789 for (j = 0; j < strlen(feat); j++) {
22797 ast_debug(1,
"Got a Request to Record the channel, state %s\n", c);
22831 ast_cli(fd,
"No such peer '%s'\n", arg);
22833 ast_cli(fd,
"Unable to get IP address of peer '%s'\n", arg);
22840 sip_unref_peer(peer,
"sip_do_debug_peer: sip_unref_peer, from sip_find_peer call");
22852 e->
command =
"sip set debug {on|off|ip|peer}";
22854 "Usage: sip set debug {off|on|ip addr[:port]|peer peername}\n" 22855 " Globally disables dumping of SIP packets,\n" 22856 " or enables it either globally or for a (single)\n" 22857 " IP address or registered peer.\n";
22860 if (a->
pos == 4 && !strcasecmp(a->
argv[3],
"peer"))
22867 if (!strcasecmp(what,
"on")) {
22871 ast_cli(a->
fd,
"SIP Debugging %senabled\n", oldsipdebug ?
"re-" :
"");
22873 }
else if (!strcasecmp(what,
"off")) {
22877 ast_cli(a->
fd,
"SIP Debugging Disabled\n");
22879 ast_cli(a->
fd,
"SIP Debugging still enabled due to configuration.\n");
22880 ast_cli(a->
fd,
"Set sipdebug=no in sip.conf and reload to actually disable.\n");
22884 }
else if (a->
argc == e->
args + 1) {
22885 if (!strcasecmp(what,
"ip"))
22887 else if (!strcasecmp(what,
"peer"))
22903 "Usage: sip notify <type> <peer> [<peer>...]\n" 22904 " Send a NOTIFY message to a SIP peer or peers\n" 22905 " Message types are defined in sip_notify.conf\n";
22914 if (!notify_types) {
22922 ast_cli(a->
fd,
"Unable to find notify type '%s'\n", a->
argv[2]);
22926 for (i = 3; i < a->
argc; i++) {
22932 ast_log(
LOG_WARNING,
"Unable to build sip pvt data for notify (memory/socket error)\n");
22941 ast_cli(a->
fd,
"Could not create address for '%s'\n", a->
argv[i]);
22950 for (var = varlist;
var; var = var->
next) {
22954 if (!strcasecmp(var->
name,
"Content")) {
22958 }
else if (!strcasecmp(var->
name,
"Content-Length")) {
22959 ast_log(
LOG_WARNING,
"it is not necessary to specify Content-Length in sip_notify.conf, ignoring\n");
22962 header = header->
next;
22972 ast_cli(a->
fd,
"Sending NOTIFY of type '%s' to '%s'\n", a->
argv[2], a->
argv[i]);
22975 dialog_unref(p,
"bump down the count of p since we're done with it.");
22986 e->
command =
"sip set history {on|off}";
22988 "Usage: sip set history {on|off}\n" 22989 " Enables/Disables recording of SIP dialog history for debugging purposes.\n" 22990 " Use 'sip show history' to view the history of a call number.\n";
22999 if (!strncasecmp(a->
argv[e->
args - 1],
"on", 2)) {
23001 ast_cli(a->
fd,
"SIP History Recording Enabled (use 'sip show history')\n");
23002 }
else if (!strncasecmp(a->
argv[e->
args - 1],
"off", 3)) {
23004 ast_cli(a->
fd,
"SIP History Recording Disabled\n");
23014 char *
header, *respheader;
23019 memset(digest, 0,
sizeof(digest));
23038 char *
header, *respheader;
23047 memset(digest, 0,
sizeof(digest));
23048 if (
reply_digest(p, req, header, sipmethod, digest,
sizeof(digest) )) {
23066 char oldnonce[256];
23074 {
"realm=", &p->
realm },
23075 {
"nonce=", &p->
nonce },
23076 {
"opaque=", &p->
opaque },
23077 {
"qop=", &p->
qop },
23078 {
"domain=", &p->
domain },
23087 if (strncasecmp(tmp,
"Digest ", strlen(
"Digest "))) {
23091 c = tmp + strlen(
"Digest ");
23094 for (i = keys; i->key !=
NULL; i++) {
23095 char *src, *separator;
23096 if (strncasecmp(c, i->key, strlen(i->key)) != 0)
23099 c += strlen(i->key);
23111 if (i->key ==
NULL)
23115 if (strcmp(p->
nonce, oldnonce))
23146 char resp_hash[256];
23148 char opaque[256] =
"";
23150 const char *username;
23151 const char *secret;
23152 const char *md5secret;
23163 snprintf(cnonce,
sizeof(cnonce),
"%08lx", (
unsigned long)
ast_random());
23169 ao2_t_ref(credentials, +1,
"Ref peer auth for digest");
23176 ao2_t_ref(credentials, -1,
"Unref peer auth for digest");
23179 credentials =
authl;
23181 ao2_t_ref(credentials, +1,
"Ref global auth for digest");
23205 ao2_t_ref(credentials, -1,
"Unref auth for digest");
23211 snprintf(a1,
sizeof(a1),
"%s:%s:%s", username, p->
realm, secret);
23221 snprintf(resp,
sizeof(resp),
"%s:%s:%08x:%s:%s:%s", a1_hash, p->
nonce, (
unsigned)p->
noncecount, cnonce,
"auth", a2_hash);
23223 snprintf(resp,
sizeof(resp),
"%s:%s:%s", a1_hash, p->
nonce, a2_hash);
23228 snprintf(opaque,
sizeof(opaque),
", opaque=\"%s\"", p->
opaque);
23233 snprintf(digest, digest_len,
"Digest username=\"%s\", realm=\"%s\", algorithm=MD5, uri=\"%s\", nonce=\"%s\", response=\"%s\"%s, qop=auth, cnonce=\"%s\", nc=%08x", username, p->
realm, uri, p->
nonce, resp_hash, opaque, cnonce, (
unsigned)p->
noncecount);
23235 snprintf(digest, digest_len,
"Digest username=\"%s\", realm=\"%s\", algorithm=MD5, uri=\"%s\", nonce=\"%s\", response=\"%s\"%s", username, p->
realm, uri, p->
nonce, resp_hash, opaque);
23240 ao2_t_ref(credentials, -1,
"Unref auth for digest");
23249 const char *content =
NULL;
23255 int i,
number, start = 0;
23275 if (!
args.number) {
23278 sscanf(
args.number,
"%30d", &number);
23291 for (i = 0; i < number; i++)
23306 .
name =
"SIP_HEADER",
23340 if (!
args.pattern || strcmp(
args.pattern,
"*") == 0) {
23347 int hdrlen = strcspn(header,
" \t:,");
23349 if (hdrlen > 0 && *term ==
':') {
23350 const char *s =
NULL;
23354 char short_hdr[2] = { header[0],
'\0' };
23362 ast_str_set(&token, -1,
"%.*s,", hdrlen, header);
23390 .
name =
"SIP_HEADERS",
23410 .
name =
"CHECKSIPDOMAIN",
23420 if ((colname = strchr(data,
','))) {
23429 if (!strcasecmp(colname,
"ip")) {
23431 }
else if (!strcasecmp(colname,
"port")) {
23433 }
else if (!strcasecmp(colname,
"status")) {
23435 }
else if (!strcasecmp(colname,
"language")) {
23437 }
else if (!strcasecmp(colname,
"regexten")) {
23439 }
else if (!strcasecmp(colname,
"limit")) {
23441 }
else if (!strcasecmp(colname,
"busylevel")) {
23443 }
else if (!strcasecmp(colname,
"curcalls")) {
23444 snprintf(buf, len,
"%d", peer->
inuse);
23445 }
else if (!strcasecmp(colname,
"maxforwards")) {
23447 }
else if (!strcasecmp(colname,
"accountcode")) {
23449 }
else if (!strcasecmp(colname,
"callgroup")) {
23451 }
else if (!strcasecmp(colname,
"pickupgroup")) {
23453 }
else if (!strcasecmp(colname,
"namedcallgroup")) {
23459 }
else if (!strcasecmp(colname,
"namedpickupgroup")) {
23465 }
else if (!strcasecmp(colname,
"useragent")) {
23467 }
else if (!strcasecmp(colname,
"mailbox")) {
23471 }
else if (!strcasecmp(colname,
"context")) {
23473 }
else if (!strcasecmp(colname,
"expire")) {
23474 snprintf(buf, len,
"%d", peer->
expire);
23475 }
else if (!strcasecmp(colname,
"dynamic")) {
23477 }
else if (!strcasecmp(colname,
"callerid_name")) {
23479 }
else if (!strcasecmp(colname,
"callerid_num")) {
23481 }
else if (!strcasecmp(colname,
"codecs")) {
23485 }
else if (!strcasecmp(colname,
"encryption")) {
23487 }
else if (!strncasecmp(colname,
"chanvar[", 8)) {
23491 chanvar =
strsep(&chanvar,
"]");
23493 if (!strcasecmp(v->
name, chanvar)) {
23497 }
else if (!strncasecmp(colname,
"codec[", 6)) {
23501 codecnum = colname + 6;
23502 codecnum =
strsep(&codecnum,
"]");
23514 sip_unref_peer(peer,
"sip_unref_peer from function_sippeer, just before return");
23532 char *redirecting_from_name =
NULL;
23533 char *redirecting_from_number =
NULL;
23534 char *redirecting_to_name =
NULL;
23535 char *redirecting_to_number =
NULL;
23536 char *reason_str =
NULL;
23541 res =
get_rdnis(p, req, &redirecting_from_name, &redirecting_from_number, &reason, &reason_str);
23555 parse_moved_contact(p, req, &redirecting_to_name, &redirecting_to_number, set_call_forward);
23561 ast_debug(3,
"Got redirecting from number %s\n", redirecting_from_number);
23567 ast_free(redirecting_from_number);
23570 ast_debug(3,
"Got redirecting from name %s\n", redirecting_from_name);
23571 update_redirecting->
from.
name = 1;
23574 redirecting->
from.
name.
str = redirecting_from_name;
23585 ast_debug(3,
"Got redirecting to number %s\n", redirecting_to_number);
23586 update_redirecting->
to.
number = 1;
23589 redirecting->
to.
number.
str = redirecting_to_number;
23594 ast_debug(3,
"Got redirecting to name %s\n", redirecting_to_name);
23595 update_redirecting->
to.
name = 1;
23598 redirecting->
to.
name.
str = redirecting_to_name;
23620 char *contact_name =
NULL;
23621 char *contact_number =
NULL;
23622 char *separator, *trans;
23627 if ((separator = strchr(contact,
',')))
23631 if ((trans =
strcasestr(contact_number,
";transport="))) {
23634 if ((separator = strchr(trans,
';')))
23637 if (!strncasecmp(trans,
"tcp", 3))
23639 else if (!strncasecmp(trans,
"tls", 3))
23642 if (strncasecmp(trans,
"udp", 3))
23643 ast_debug(1,
"received contact with an invalid transport, '%s'\n", contact_number);
23662 if (!strncasecmp(contact_number,
"sip:", 4))
23663 contact_number += 4;
23664 else if (!strncasecmp(contact_number,
"sips:", 5))
23665 contact_number += 5;
23666 separator = strchr(contact_number,
'/');
23669 if ((host = strchr(contact_number,
'@'))) {
23673 ast_channel_call_forward_build(p->
owner,
"SIP/%s::::%s@%s", contact_number,
sip_get_transport(transport), host);
23677 ast_channel_call_forward_build(p->
owner,
"SIP/::::%s@%s",
sip_get_transport(transport), contact_number);
23680 separator = strchr(contact,
'@');
23682 *separator++ =
'\0';
23683 domain = separator;
23688 separator = strchr(contact,
'/');
23692 if (!strncasecmp(contact_number,
"sip:", 4))
23693 contact_number += 4;
23694 else if (!strncasecmp(contact_number,
"sips:", 5))
23695 contact_number += 5;
23696 separator = strchr(contact_number,
';');
23700 if (set_call_forward) {
23701 ast_debug(2,
"Received 302 Redirect to extension '%s' (domain %s)\n", contact_number, domain);
23704 ast_channel_call_forward_set(p->
owner, contact_number);
23711 if (*contact ==
'\"') {
23712 contact_name = contact + 1;
23714 ast_log(
LOG_NOTICE,
"No closing quote on name in Contact header? %s\n", contact);
23774 ast_debug(2,
"NOT Sending pending reinvite (yet) on '%s'\n", p->
callid);
23787 struct sip_pvt *pvt = (
void *) data;
23804 dialog_ref(pvt,
"Check pending actions action");
23807 dialog_unref(pvt,
"Failed to schedule check pending actions action");
23838 struct sip_pvt *pvt = (
void *) data;
23848 dialog_ref(pvt,
"Stop reinvite retry action");
23851 dialog_unref(pvt,
"Failed to schedule stop reinvite retry action");
23875 const char *min_expires;
23877 if (!monitor_instance) {
23878 ast_log(
LOG_WARNING,
"Can't find monitor_instance corresponding to epa_entry %p.\n", epa_entry);
23884 "Received error response to our PUBLISH");
23885 ao2_ref(monitor_instance, -1);
23903 "PUBLISH expiry overflowed");
23904 ao2_ref(monitor_instance, -1);
23907 }
else if (sscanf(min_expires,
"%30d", &pvt->
expiry) != 1) {
23909 "Min-Expires has non-numeric value");
23910 ao2_ref(monitor_instance, -1);
23917 ao2_ref(monitor_instance, -1);
23927 if (resp == 401 || resp == 407) {
23940 if (resp == 501 || resp == 405) {
24018 ast_debug(4,
"SIP response %d to RE-invite on %s call %s\n", resp, outgoing ?
"outgoing" :
"incoming", p->
callid);
24020 ast_debug(4,
"SIP response %d to standard invite\n", resp);
24024 ast_debug(1,
"Got response on call that is already terminated: %s (ignoring)\n", p->
callid);
24035 if (resp > 100 && resp < 200 && resp!=101 && resp != 180 && resp != 181 && resp != 182 && resp != 183) {
24040 if ((resp >= 200) && (resp < 300)) {
24045 if (resp >= 100 && resp < 200 && p->invitestate ==
INV_CALLING) {
24054 if ((resp >= 200 && reinvite)) {
24096 memset(&update_connected, 0,
sizeof(update_connected));
24103 update_connected.
id.
name = 1;
24114 &update_connected);
24157 memset(&update_redirecting, 0,
sizeof(update_redirecting));
24167 &update_redirecting);
24189 memset(&update_connected, 0,
sizeof(update_connected));
24196 update_connected.
id.
name = 1;
24207 &update_connected);
24242 if (res && !req->
ignore) {
24255 }
else if (!reinvite) {
24270 if (rpid_changed || !reinvite) {
24273 memset(&update_connected, 0,
sizeof(update_connected));
24285 update_connected.
id.
name = 1;
24297 &update_connected);
24323 if (!reinvite && !res) {
24347 int tmp_st_interval = 0;
24352 ast_log(
LOG_WARNING,
"Got Session-Expires less than local Min-SE in 200 OK, tearing down call\n");
24362 if (tmp_st_interval) {
24448 append_history(p,
"Identity",
"SIP identity is required. Not supported by Asterisk.");
24461 append_history(p,
"TempUnavailable",
"Endpoint is temporarily unavailable.");
24465 char *quoted_rest =
ast_alloca(strlen(rest) + 3);
24468 memset(&update_redirecting, 0,
sizeof(update_redirecting));
24472 sprintf(quoted_rest,
"\"%s\"", rest);
24492 append_history(p,
"Hangup",
"Got 487 on CANCEL request from us. Queued AST hangup request");
24493 }
else if (!req->
ignore) {
24495 append_history(p,
"Hangup",
"Got 487 on CANCEL request from us on call without owner. Killing this dialog.");
24537 dialog_ref(p,
"Schedule waitid for sip_reinvite_retry.");
24543 ast_debug(2,
"Reinvite race. Scheduled sip_reinvite_retry in %d secs in handle_response_invite (waitid %d, dialog '%s')\n",
24628 monitor_instance =
ao2_callback(sip_monitor_instances, 0,
24630 if (monitor_instance) {
24633 "Received error response to our SUBSCRIBE");
24634 ao2_ref(monitor_instance, -1);
24648 ast_debug(3,
"Got 200 OK on subscription for MWI\n");
24666 ao2_t_ref(p->
mwi, -1,
"failed to authenticate SUBSCRIBE");
24679 ast_log(
LOG_WARNING,
"Subscription failed for MWI. The remote side said that a mailbox may not have been configured.\n");
24685 ast_log(
LOG_WARNING,
"Subscription failed for MWI. The remote side said that our dialog did not exist.\n");
24696 ast_log(
LOG_WARNING,
"Subscription failed for MWI. The remote side may have suffered a heart attack.\n");
24721 ast_debug(3,
"Got 202 accepted on transfer\n");
24728 ast_log(
LOG_WARNING,
"Asked to authenticate REFER to %s but we have no matching peer or realm auth!\n",
24809 int expires, expires_ms;
24822 ast_log(
LOG_NOTICE,
"Treating 403 response to REGISTER as non-fatal for %s@%s\n",
24854 ast_log(
LOG_WARNING,
"Got a 408 response to our REGISTER on call %s after we had destroyed the registry object\n", p->
callid);
24894 ast_debug(1,
"Registration successful\n");
24919 const char *tmptmp =
NULL;
24934 if (sscanf(tmptmp + 8,
"%30d", &expires) != 1) {
24945 expires_ms = expires * 1000;
24951 ast_log(
LOG_NOTICE,
"Outbound Registration: Expiry for %s is %d sec (Scheduling reregistration in %d s)\n", r->
hostname, expires, expires_ms/1000);
24953 r->
refresh= (int) expires_ms / 1000;
24965 int statechanged, is_reachable, was_reachable;
24973 if (pingtime < 1) {
24977 if (!peer->
maxms) {
24987 is_reachable = pingtime <= peer->
maxms;
24988 statechanged = peer->
lastms == 0
24989 || was_reachable != is_reachable;
24991 peer->
lastms = pingtime;
24993 if (statechanged) {
24994 const char *s = is_reachable ?
"Reachable" :
"Lagged";
24995 char str_lastms[20];
24997 snprintf(str_lastms,
sizeof(str_lastms),
"%d", pingtime);
25057 if (300 <= resp && resp < 700) {
25058 ast_verb(3,
"Got SIP %s response %d \"%s\" back from host '%s'\n",
25088 memset(digest, 0,
sizeof(digest));
25091 ast_debug(1,
"Nothing to use for MESSAGE authentication\n");
25136 if (100 <= resp && resp < 200) {
25138 }
else if (200 <= resp && resp < 300) {
25143 }
else if (300 <= resp && resp < 700) {
25144 ast_verb(3,
"Got SIP %s response %d \"%s\" back from host '%s'\n",
25148 ?
"MESSAGE delivery failed" :
"MESSAGE delivery refused");
25180 int ack_res =
FALSE;
25196 if ((resp >= 100) && (resp <= 199)) {
25202 ack_res =
__sip_ack(p, seqno, 0, sipmethod);
25205 if (ack_res ==
FALSE) {
25207 if (sipmethod ==
SIP_INVITE && resp >= 200) {
25224 gettag(req,
"To", tag,
sizeof(tag));
25246 if ((resp == 404 || resp == 408 || resp == 481) && sipmethod ==
SIP_BYE) {
25257 }
else if (sipmethod ==
SIP_REFER && resp >= 200) {
25264 }
else if (sipmethod ==
SIP_INFO) {
25293 }
else if (sipmethod ==
SIP_BYE) {
25308 }
else if (sipmethod ==
SIP_BYE) {
25312 ast_log(
LOG_WARNING,
"Asked to authenticate %s, to %s but we have no matching peer!\n",
25332 ast_log(
LOG_WARNING,
"Forbidden - maybe wrong password on authentication for %s\n", msg);
25358 else if (sipmethod ==
SIP_BYE) {
25360 ast_debug(4,
"Got timeout on bye. Thanks for the answer. Now, kill this call\n");
25379 }
else if (owner) {
25389 }
else if (sipmethod ==
SIP_BYE) {
25432 if ((resp >= 200) && (resp < 300)) {
25436 }
else if ((resp >= 300) && (resp < 700)) {
25455 memset(&update_redirecting, 0,
sizeof(update_redirecting));
25457 &update_redirecting,
TRUE);
25459 &update_redirecting);
25488 if (owner && sipmethod !=
SIP_BYE) {
25501 if (owner && sipmethod !=
SIP_BYE)
25512 }
else if ((resp >= 100) && (resp < 200)) {
25531 ast_verbose(
"SIP Response message for INCOMING dialog %s arrived\n", msg);
25533 if (sipmethod ==
SIP_INVITE && resp == 200) {
25538 gettag(req,
"To", tag,
sizeof(tag));
25547 ast_debug(1,
"Got 200 OK on CANCEL\n");
25550 }
else if (sipmethod ==
SIP_BYE) {
25558 else if (sipmethod ==
SIP_BYE) {
25569 }
else if (sipmethod ==
SIP_BYE) {
25580 if ((resp >= 100) && (resp < 200)) {
25586 }
else if ((resp >= 200) && (resp < 300)) {
25590 }
else if ((resp >= 300) && (resp < 700)) {
25636 pthread_t threadid;
25656 const char *thetag;
25666 return strsep(&tagbuf,
";");
25679 if (!monitor_instance) {
25685 ao2_ref(monitor_instance, -1);
25690 if (!strcmp(status,
"queued")) {
25697 ao2_ref(monitor_instance, -1);
25725 ao2_ref(monitor_instance, -1);
25740 if( (sep = strchr(event,
';')) ) {
25745 ast_debug(2,
"Got NOTIFY Event: %s\n", event);
25747 if (!strcmp(event,
"refer")) {
25752 char *
buf, *cmd, *code;
25754 int success =
TRUE;
25763 if (strncasecmp(
sip_get_header(req,
"Content-Type"),
"message/sipfrag", strlen(
"message/sipfrag"))) {
25798 ast_debug(3,
"* SIP Transfer NOTIFY Attachment: \n---%s\n---\n", buf);
25802 while(*code && (*code > 32)) {
25809 while(*sep && (*sep > 32)) {
25813 respcode = atoi(code);
25814 switch (respcode) {
25830 ast_log(
LOG_NOTICE,
"Error parsing sipfrag in NOTIFY in response to REFER.\n");
25834 if (respcode < 200) {
25838 ast_log(
LOG_NOTICE,
"Got unknown code '%d' in NOTIFY in response to REFER.\n", respcode);
25843 if (success ==
FALSE) {
25844 ast_log(
LOG_NOTICE,
"Transfer failed. Sorry. Nothing further to do with this call\n");
25847 if (p->
owner && success != -1) {
25853 }
else if (!strcmp(event,
"message-summary")) {
25869 char *old =
strsep(&c,
" ");
25870 char *
new =
strsep(&old,
"/");
25879 }
else if (!strcmp(event,
"keep-alive")) {
25883 }
else if (!strcmp(event,
"call-completion")) {
25940 msg =
"503 Unavailable";
25942 msg =
"404 Not Found";
25945 msg =
"416 Unsupported URI scheme";
25996 ast_log(
LOG_ERROR,
"Unable to create new channel. Invite/replace failed.\n");
25998 append_history(p,
"Xfer",
"INVITE/Replace Failed. No new channel.");
26054 ast_log(
LOG_ERROR,
"Unable to perform pickup: Application 'Pickup' not loaded (app_directed_pickup.so).\n");
26108 struct sip_pvt *pvt = (
void *) data;
26121 dialog_unref(pvt,
"Failed to schedule stop t38id action");
26128 struct sip_pvt *pvt = (
void *) data;
26135 if (pvt->
t38id < 0) {
26149 dialog_unref(pvt,
"Failed to schedule start t38id action");
26179 memset(&update_connected, 0,
sizeof(update_connected));
26186 update_connected.
id.
name = 1;
26210 const char *p_uac_se_hdr;
26211 const char *p_uac_min_se;
26212 int uac_max_se = -1;
26213 int uac_min_se = -1;
26214 int st_active =
FALSE;
26215 int st_interval = 0;
26217 int dlg_min_se = -1;
26227 ast_debug(2,
"Incoming INVITE with 'timer' option supported\n");
26237 ast_debug(2,
"INVITE also has \"Session-Expires\" header.\n");
26249 ast_debug(2,
"INVITE also has \"Min-SE\" header.\n");
26261 if (uac_max_se > 0 && uac_max_se < dlg_min_se) {
26273 if (uac_max_se > 0) {
26274 if (dlg_max_se >= uac_min_se) {
26275 st_interval = (uac_max_se < dlg_max_se) ? uac_max_se : dlg_max_se;
26277 st_interval = uac_max_se;
26279 }
else if (uac_min_se > 0) {
26280 st_interval =
MAX(dlg_max_se, uac_min_se);
26282 st_interval = dlg_max_se;
26289 ast_log(
LOG_WARNING,
"Received SIP INVITE with supported but disabled option: timer\n");
26315 if (reinvite == 0) {
26317 if (st_active ==
TRUE) {
26327 ast_debug (2,
"Restarting session-timers on a refresh - %s\n", p->
callid);
26330 if (st_interval > 0) {
26351 const char *p_replaces;
26352 char *replace_id =
NULL;
26353 const char *required;
26354 unsigned int required_profile = 0;
26360 int supported_start = 0;
26361 int require_start = 0;
26362 char unsupported[256] = { 0, };
26374 const char *supported =
NULL;
26376 supported =
__get_header(req,
"Supported", &supported_start);
26385 required =
__get_header(req,
"Require", &require_start);
26395 ast_log(
LOG_WARNING,
"Received SIP INVITE with unsupported required extension: %s\n", unsupported);
26401 goto request_invite_cleanup;
26421 different =
sip_uri_cmp(initial_rlpart2, this_rlpart2);
26423 different = strcmp(initial_rlpart2, this_rlpart2);
26429 goto request_invite_cleanup;
26439 char *at = strchr(uri,
'@');
26441 ast_debug(2,
"Potential spiral detected. Original RURI was %s, new RURI is %s\n", initial_rlpart2, this_rlpart2);
26447 if ((peerorhost = strchr(uri,
':'))) {
26448 *peerorhost++ =
'\0';
26453 ast_channel_call_forward_set(p->
owner, peerorhost);
26456 goto request_invite_cleanup;
26478 ast_debug(1,
"Got INVITE on call where we already have pending INVITE, deferring that - %s\n", p->
callid);
26481 goto request_invite_cleanup;
26489 char *fromtag =
NULL;
26490 char *totag =
NULL;
26495 ast_debug(3,
"INVITE w Replaces on existing call? Refusing action. [%s]\n", p->
callid);
26501 goto request_invite_cleanup;
26505 ast_debug(3,
"INVITE part of call transfer. Replaces [%s]\n", p_replaces);
26512 append_history(p,
"Xfer",
"INVITE/Replace Failed. Out of memory.");
26518 goto request_invite_cleanup;
26532 start = replace_id;
26533 while ( (ptr =
strsep(&start,
";")) ) {
26537 else if ( (to =
strcasestr(ptr,
"from-tag=") ) ) {
26539 fromtag =
strsep(&fromtag,
"&");
26544 ast_debug(4,
"Invite/replaces: Will use Replace-Call-ID : %s Fromtag: %s Totag: %s\n",
26546 fromtag ? fromtag :
"<no from tag>",
26547 totag ? totag :
"<no to tag>");
26553 if (strncmp(replace_id,
"pickup-", 7) == 0) {
26560 ast_log(
LOG_NOTICE,
"Unable to find subscription with call-id: %s\n", replace_id);
26565 ast_log(
LOG_NOTICE,
"Trying to pick up %s@%s\n", subscription->exten, subscription->context);
26566 ast_copy_string(pickup.exten, subscription->exten,
sizeof(pickup.exten));
26567 ast_copy_string(pickup.context, subscription->context,
sizeof(pickup.context));
26572 totag, fromtag, &replaces_pvt, &replaces_chan)) {
26573 ast_log(
LOG_NOTICE,
"Supervised transfer attempted to replace non-existent call id (%s)!\n", replace_id);
26582 if (replaces_pvt == p) {
26590 ast_log(
LOG_NOTICE,
"Supervised transfer attempted to replace non-existing call id (%s)!\n", replace_id);
26600 ast_log(
LOG_NOTICE,
"Supervised transfer attempted to replace non-ringing or active call id (%s)!\n", replace_id);
26612 goto request_invite_cleanup;
26647 memset(&update_connected, 0,
sizeof(update_connected));
26654 update_connected.
id.
name = 1;
26665 &update_connected);
26681 goto request_invite_cleanup;
26687 ast_debug(1,
"Hm.... No sdp for the moment\n");
26701 }
else if (req->
debug)
26707 int cc_recall_core_id = -1;
26712 goto request_invite_cleanup;
26718 goto request_invite_cleanup;
26745 ast_debug(1,
"No compatible codecs for this SIP call.\n");
26747 goto request_invite_cleanup;
26752 ast_debug(2,
"No SDP in Invite, third party call control\n");
26772 goto request_invite_cleanup;
26809 " '%s' rejected because extension not found in context '%s'.\n",
26823 goto request_invite_cleanup;
26837 goto request_invite_cleanup;
26845 if (cc_recall_core_id != -1) {
26856 memset(&update_redirecting, 0,
sizeof(update_redirecting));
26865 memset(&update_redirecting, 0,
sizeof(update_redirecting));
26870 ast_debug(2,
"Got a SIP re-transmit of INVITE for call %s\n", p->
callid);
26881 goto request_invite_cleanup;
26895 if (reinvite && p->
stimer) {
26902 if (c && replace_id) {
26927 goto request_invite_cleanup;
26931 ast_debug(4,
"Sending this call to the invite/replaces handler %s\n", p->
callid);
26933 goto request_invite_cleanup;
26941 const char *pickupexten;
26944 ast_log(
LOG_ERROR,
"Unable to retrieve pickup configuration options. Unable to detect call pickup extension\n");
26947 pickupexten =
ast_strdupa(pickup_cfg->pickupexten);
26970 if (strcmp(p->
exten, pickupexten)) {
27065 msg =
"488 Not Acceptable Here (codec error)";
27068 msg =
"503 Unavailable";
27076 request_invite_cleanup:
27079 authpeer =
sip_unref_peer(authpeer,
"sip_unref_peer, from handle_request_invite authpeer");
27089 const char *from =
NULL;
27090 const char *s =
NULL;
27093 if (!chan || !req) {
27107 }
else if ((s =
strcasestr(from,
";ss7-oli="))) {
27109 }
else if ((s =
strcasestr(from,
";oli="))) {
27123 if (sscanf(s,
"%d", &ani2)) {
27153 &targetcall_pvt, &targetcall_chan)) {
27165 ast_debug(3,
"SIP attended transfer: Not our call - generating INVITE with replaces\n");
27169 if (!targetcall_chan) {
27170 ast_debug(4,
"SIP attended transfer: Error: No owner of target call\n");
27189 switch (transfer_res) {
27198 append_history(transferer,
"Xfer",
"Refer failed (internal error)");
27204 append_history(transferer,
"Xfer",
"Refer failed (invalid bridge state)");
27210 append_history(transferer,
"Xfer",
"Refer failed (operation not permitted)");
27326 char *refer_to =
NULL;
27327 char *refer_to_context =
NULL;
27335 ast_verbose(
"Call %s got a SIP call transfer from %s: (REFER)!\n",
27343 ast_debug(3,
"Call %s: Declined REFER, outside of dialog...\n", p->
callid);
27357 append_history(p,
"Xfer",
"Refer failed. Allowtransfer == closed.");
27372 append_history(p,
"Xfer",
"Refer failed. Memory allocation error.");
27386 ast_debug(1,
"SIP transfer to black hole can't be handled (no refer-to: )\n");
27393 ast_debug(1,
"SIP transfer to non-SIP uri denied\n");
27437 ast_debug(3,
"SIP %s transfer: Transferer channel %s\n",
27456 ast_debug(4,
"SIP attended transfer: Still not our call - generating INVITE with replaces\n");
27474 if (!replaces_str) {
27475 ast_log(
LOG_NOTICE,
"Unable to create Replaces string for remote attended transfer. Transfer failed\n");
27500 switch (transfer_res) {
27505 append_history(p,
"Xfer",
"Refer failed (only bridged calls).");
27512 append_history(p,
"Xfer",
"Refer failed (bridge does not permit transfers)");
27547 ast_debug(1,
"Got CANCEL on an answered call. Ignoring... \n");
27574 struct sip_pkt *pkt, *prev_pkt;
27586 for (pkt = p->
packets, prev_pkt =
NULL; pkt; prev_pkt = pkt, pkt = pkt->
next) {
27591 ao2_t_ref(pkt, -1,
"Packet retransmission list");
27609 const char *required;
27643 if (!owner_relock) {
27644 ast_debug(3,
"Unable to reacquire owner channel lock, channel is gone\n");
27686 if (peer_channel) {
27695 if (peer_pvt->
rtp) {
27698 peer_rtp = peer_pvt->
rtp;
27715 if (!owner_relock) {
27716 ast_debug(3,
"Unable to reacquire owner channel lock, channel is gone\n");
27747 ast_log(
LOG_NOTICE,
"Client '%s' using deprecated BYE/Also transfer method. Ask vendor to support REFER instead\n",
27755 if (peer_channel) {
27772 if (!owner_relock) {
27773 ast_debug(3,
"Unable to reacquire owner channel lock, channel is gone\n");
27785 }
else if (p->
owner) {
27788 ast_debug(3,
"Received bye, issuing owner hangup\n");
27791 ast_debug(3,
"Received bye, no owner, selfdestruct soon.\n");
27798 char unsupported[256] = { 0, };
27804 ast_log(
LOG_WARNING,
"Received SIP BYE with unsupported required extension: required:%s unsupported:%s\n", required, unsupported);
27857 static const char *hdr[] = {
27870 for (idx = 0; idx <
ARRAY_LEN(hdr); ++idx) {
27871 if (!strcasecmp(header_name, hdr[idx])) {
27898 if (!strcasecmp(var,
"Request-URI")) {
27920 sip_unref_peer(peer_ptr,
"sip_unref_peer, from sip_msg_send, sip_find_peer");
27921 }
else if (strchr(from,
'<')) {
27943 if (strchr(location,
':')) {
27964 dialog_unref(pvt,
"create_addr failed sending a MESSAGE");
27981 if (!strcasecmp(var,
"Max-Forwards")) {
27987 dialog_unref(pvt,
"MESSAGE(Max-Forwards) reached zero.");
27989 "MESSAGE(Max-Forwards) reached zero. MESSAGE not sent.\n");
28016 int body_present = req->
lines > 0;
28026 }
else if (sscanf(expires,
"%30d", expires_int) != 1) {
28030 if (*expires_int == 0) {
28032 }
else if (!etag_present && body_present) {
28034 }
else if (etag_present && !body_present) {
28036 }
else if (etag_present && body_present) {
28043 #ifdef HAVE_LIBXML2 28047 int status_found =
FALSE;
28048 struct ast_xml_node *tuple_children;
28049 struct ast_xml_node *tuple_children_iterator;
28063 for (tuple_children_iterator = tuple_children; tuple_children_iterator;
28073 if (status_found ==
TRUE) {
28075 ast_log(
LOG_WARNING,
"Multiple status elements found in tuple. Only one allowed\n");
28078 status_found =
TRUE;
28080 return status_found;
28087 struct ast_xml_node *child_nodes;
28088 struct ast_xml_node *node_iterator;
28089 struct ast_xml_ns *ns;
28091 const char *
namespace;
28092 const char presence_namespace[] =
"urn:ietf:params:xml:ns:pidf";
28094 if (!presence_node) {
28110 ast_log(
LOG_WARNING,
"Presence element of PIDF document has no 'entity' attribute\n");
28122 if (
ast_strlen_zero(
namespace) || strcmp(
namespace, presence_namespace)) {
28128 ast_log(
LOG_WARNING,
"PIDF document has no elements as children of 'presence'. Invalid\n");
28140 for (node_iterator = child_nodes; node_iterator;
28172 struct ast_xml_doc *doc;
28177 if (
ast_strlen_zero(content_type) || strcmp(content_type,
"application/pidf+xml")) {
28206 struct ast_xml_doc *pidf_doc =
NULL;
28207 const char *basic_status =
NULL;
28208 struct ast_xml_node *presence_node;
28209 struct ast_xml_node *presence_children;
28210 struct ast_xml_node *tuple_node;
28211 struct ast_xml_node *tuple_children;
28212 struct ast_xml_node *status_node;
28213 struct ast_xml_node *status_children;
28214 struct ast_xml_node *basic_node;
28227 goto cc_publish_cleanup;
28240 goto cc_publish_cleanup;
28246 goto cc_publish_cleanup;
28259 goto cc_publish_cleanup;
28265 goto cc_publish_cleanup;
28273 goto cc_publish_cleanup;
28276 if (!strcmp(basic_status,
"open")) {
28280 }
else if (!strcmp(basic_status,
"closed")) {
28288 cc_publish_cleanup:
28289 if (basic_status) {
28329 int expires_ms = expires * 1000;
28357 int expires_ms = expires * 1000;
28419 int handler_result = -1;
28427 if (!(esc =
get_esc(event))) {
28437 }
else if (auth_result < 0) {
28451 }
else if (expires_int < min_expiry && expires_int > 0) {
28456 p->
expiry = expires_int;
28461 switch (publish_type) {
28481 if (!handler_result && p->
expiry > 0) {
28487 return handler_result;
28519 char *param_separator;
28526 sscanf(expires_str,
"%30d", &expires);
28529 if ((param_separator = strchr(uri,
';'))) {
28530 *param_separator =
'\0';
28592 }
else if (req->
debug) {
28594 ast_debug(1,
"Got a re-subscribe on existing subscription %s\n", p->
callid);
28596 ast_debug(1,
"Got a new subscription %s (possibly with auth) or retransmission\n", p->
callid);
28609 if (!req->
ignore && !resubscribe) {
28617 ast_verbose(
"Received resubscription for a dialog we no longer know about. Telling remote side to subscribe again.\n");
28633 ast_verbose(
"Ignoring this SUBSCRIBE request\n");
28638 ast_debug(2,
"Received SIP subscribe for unknown event package: <none>\n");
28671 sip_unref_peer(authpeer,
"sip_unref_peer, from handle_request_subscribe (authpeer 1)");
28685 if (!strcmp(event,
"presence") || !strcmp(event,
"dialog")) {
28687 const char *accept;
28690 const char *unknown_accept =
NULL;
28702 sip_unref_peer(authpeer,
"sip_unref_peer, from handle_request_subscribe (authpeer 2)");
28710 if (strstr(accept,
"application/pidf+xml")) {
28716 }
else if (strstr(accept,
"application/dialog-info+xml")) {
28719 }
else if (strstr(accept,
"application/cpim-pidf+xml")) {
28721 }
else if (strstr(accept,
"application/xpidf+xml")) {
28724 unknown_accept = accept;
28734 "stateid: %d, laststate: %d, dialogver: %u, subscribecont: " 28735 "'%s', subscribeuri: '%s'\n",
28743 sip_unref_peer(authpeer,
"sip_unref_peer, from handle_request_subscribe (authpeer 2)");
28749 }
else if (subscribed ==
NONE) {
28754 snprintf(buf,
sizeof(buf),
"489 Bad Event (format %s)", unknown_accept);
28756 snprintf(buf,
sizeof(buf),
"489 Bad Event");
28760 "'%s' pvt: subscribed: %d, stateid: %d, laststate: %d," 28761 "dialogver: %u, subscribecont: '%s', subscribeuri: '%s'\n",
28771 sip_unref_peer(authpeer,
"sip_unref_peer, from handle_request_subscribe (authpeer 2)");
28777 }
else if (!strcmp(event,
"message-summary")) {
28779 int found_supported = 0;
28780 const char *accept;
28784 found_supported = strcmp(accept,
"application/simple-message-summary") ? 0 : 1;
28785 if (!found_supported) {
28786 ast_debug(3,
"Received SIP mailbox subscription for unknown format: %s\n", accept);
28791 if (start && !found_supported) {
28794 ast_debug(2,
"Received SIP mailbox subscription for unknown format\n");
28797 sip_unref_peer(authpeer,
"sip_unref_peer, from handle_request_subscribe (authpeer 3)");
28816 sip_unref_peer(authpeer,
"sip_unref_peer, from handle_request_subscribe (authpeer 3)");
28827 if (authpeer->
mwipvt != p) {
28843 }
else if (!strcmp(event,
"call-completion")) {
28847 ast_debug(2,
"Received SIP subscribe for unknown event package: %s\n", event);
28850 sip_unref_peer(authpeer,
"sip_unref_peer, from handle_request_subscribe (authpeer 5)");
28864 p->
expiry = atoi(expires_str);
28873 "with Expire header less than 'subminexpire' limit. Received \"Expire: %d\" min is %d\n",
28877 sip_unref_peer(authpeer,
"sip_unref_peer, from handle_request_subscribe (authpeer 6)");
28883 const char *action = p->
expiry > 0 ?
"Adding" :
"Removing";
28885 ast_debug(2,
"%s subscription for mailbox notification - peer %s\n",
28890 ast_debug(2,
"%s subscription for extension %s context %s for peer %s\n",
28907 sip_ref_peer(peer,
"ensure a peer ref is held during MWI sending");
28911 sip_unref_peer(peer,
"release a peer ref now that MWI is sent");
28915 char *subtype =
NULL;
28919 if (p->
expiry > 0 && !resubscribe) {
28924 dialog_ref(p,
"copying dialog ptr into extension state struct");
28927 dialog_unref(p,
"copying dialog ptr into extension state struct failed");
28935 if (data.
state < 0) {
28943 sip_unref_peer(authpeer,
"sip_unref_peer, from handle_request_subscribe (authpeer 6)");
29009 const char *reason;
29013 reason =
"Wrong password";
29016 reason =
"Username/auth name mismatch";
29019 reason =
"No matching peer found";
29022 reason =
"Not a local domain";
29025 reason =
"Peer is not supposed to register";
29028 reason =
"Device does not match ACL";
29031 reason =
"Device not configured to use this transport type";
29034 reason =
"RTP initialization failed";
29037 reason =
"Unknown failure";
29071 const char *useragent;
29073 const char *callid;
29081 int oldmethod = p->
method;
29096 ast_log(
LOG_ERROR,
"Dropping this SIP message with Call-ID '%s', it's incomplete.\n", callid);
29099 if (!error && sscanf(cseq,
"%30u%n", &seqno, &len) != 1) {
29100 ast_log(
LOG_ERROR,
"No seqno in '%s'. Dropping incomplete message.\n", cmd);
29130 if (sscanf(e,
"%30d %n", &respid, &len) != 1) {
29142 ast_log(
LOG_WARNING,
"Misrouted SIP response '%s' with Call-ID '%s', too many vias\n", e, callid);
29146 ast_debug(1,
"Ignoring out of order response %u (expecting %u)\n", seqno, p->
ocseq);
29149 if ((respid == 200) || ((respid >= 300) && (respid <= 399))) {
29155 int data_size =
sizeof(*cause_code);
29159 memset(cause_code, 0, data_size);
29163 snprintf(cause_code->
code, data_size -
sizeof(*cause_code) + 1,
"SIP %s",
REQ_OFFSET_TO_STR(req, rlpart2));
29187 ast_debug(2,
"Got CANCEL or ACK on INVITE with transactions in between.\n");
29189 ast_debug(1,
"Ignoring too old SIP packet packet %u (expecting >= %u)\n", seqno, p->
icseq);
29193 snprintf(seconds,
sizeof(seconds),
"%u", ran);
29200 }
else if (p->
icseq &&
29201 p->
icseq == seqno &&
29218 if (seqno >= p->
icseq)
29228 gettag(req,
"From", tag,
sizeof(tag));
29248 gettag(req,
"To", totag,
sizeof(totag));
29385 static char readbuf[65535];
29387 memset(&req, 0,
sizeof(req));
29388 res =
ast_recvfrom(fd, readbuf,
sizeof(readbuf) - 1, 0, &addr);
29390 #if !defined(__FreeBSD__) 29391 if (
errno == EAGAIN)
29395 if (
errno != ECONNREFUSED)
29400 readbuf[res] =
'\0';
29436 ast_verbose(
"\n<--- SIP read from %s:%s --->\n%s\n<------------->\n",
29485 ast_debug(1,
"SIP message could not be handled, bad request: %-70.70s\n", p->
callid[0] ? p->
callid :
"<no callid>");
29492 if (p->
owner && !nounlock) {
29495 if (owner_chan_ref) {
29504 ao2_t_ref(p, -1,
"throw away dialog ptr from find_call at end of routine");
29547 ao2_t_ref(th, -1,
"decrement ref from callback");
29550 return tcptls_instance;
29574 return addr->
ss.ss_family;
29581 static const char name[] =
"SIP socket";
29586 pthread_t launched;
29640 goto create_tcptls_session_fail;
29647 goto create_tcptls_session_fail;
29657 goto create_tcptls_session_fail;
29679 goto create_tcptls_session_fail;
29689 goto create_tcptls_session_fail;
29698 goto create_tcptls_session_fail;
29705 create_tcptls_session_fail:
29707 ao2_t_ref(ca, -1,
"failed to create client, getting rid of client tcptls_session arguments");
29716 ao2_t_unlink(threadt, th,
"Removing tcptls thread info object, thread failed to open");
29760 int newmsgs = 0, oldmsgs = 0;
29804 p =
dialog_ref(peer->
mwipvt,
"sip_send_mwi_to_peer: Setting dialog ptr p from peer->mwipvt");
29822 dialog_unref(p,
"unref dialog p just created via sip_alloc");
29854 dialog_unref(p,
"unref dialog ptr p just before it goes out of scope at the end of sip_send_mwi_to_peer.");
29856 update_peer_lastmsgssent(peer, ((newmsgs > 0x7fff ? 0x7fff0000 : (newmsgs << 16)) | (oldmsgs > 0xffff ? 0xffff : oldmsgs)), 0);
29868 if (!channel_string) {
29905 if (!dialog->
rtp) {
29914 if (!dialog->
owner) {
29938 if (!keepalive && !timeout && !hold_timeout) {
29956 if (dialog->
lastrtprx && (timeout || hold_timeout) && (t > dialog->
lastrtprx + timeout)) {
29967 ast_log(
LOG_NOTICE,
"Disconnecting call '%s' for lack of RTP activity in %ld seconds\n",
29981 if (dialog->
vrtp) {
30041 "callback to check rtptimeout and hangup calls if necessary");
30047 NULL,
"callback to check dialogs which need to be destroyed");
30055 pthread_testcancel();
30058 if ((res < 0) || (res > 1000)) {
30063 ast_debug(1,
"chan_sip: ast_io_wait ran %d all at once\n", res);
30068 ast_debug(1,
"chan_sip: ast_sched_runq ran %d all at once\n", res);
30116 ast_verbose(
"Previous SIP reload not yet done\n");
30175 ast_debug(2,
"Session timer stopped: %d - %s\n",
30195 ast_debug(2,
"Session timer stopped: %d - %s\n",
30198 dialog_unref(pvt,
"Stop scheduled session timer st_schedid"));
30205 struct sip_pvt *pvt = (
void *) data;
30218 dialog_ref(pvt,
"Stop session timer action");
30221 dialog_unref(pvt,
"Failed to schedule stop session timer action");
30228 struct sip_pvt *pvt = (
void *) data;
30230 unsigned int timeout_ms;
30245 timeout_ms -=
MIN(timeout_ms / 3, 32000);
30251 dialog_ref(pvt,
"Schedule session timer st_schedid");
30254 dialog_unref(pvt,
"Failed to schedule session timer st_schedid");
30256 ast_debug(2,
"Session timer started: %d - %s %ums\n",
30270 dialog_ref(pvt,
"Start session timer action");
30273 dialog_unref(pvt,
"Failed to schedule start session timer action");
30295 if (!sscanf(p_hdrval,
"%30d", p_interval)) {
30300 ast_debug(2,
"Received Min-SE: %d\n", *p_interval);
30323 while ((p_token =
strsep(&p_se_hdr,
";"))) {
30325 if (!sscanf(p_token,
"%30d", p_interval)) {
30330 ast_debug(2,
"Session-Expires: %d\n", *p_interval);
30336 ref_idx = strlen(
"refresher=");
30337 if (!strncasecmp(p_se_hdr,
"refresher=", ref_idx)) {
30338 p_se_hdr += ref_idx;
30341 if (!strncasecmp(p_se_hdr,
"uac", strlen(
"uac"))) {
30344 }
else if (!strncasecmp(p_se_hdr,
"uas", strlen(
"uas"))) {
30368 const char *p_hdrval;
30507 if (res != count) {
30529 if (peer->
lastms > -1) {
30540 "peer_status",
"Unreachable",
30557 if (peer->
lastms > -1) {
30611 peer->
call =
dialog_ref(p,
"copy sip alloc from p to peer->call");
30657 #ifdef VOCAL_DATA_HACK 30667 }
else if (!force) {
30673 dialog_unref(p,
"unref dialog at end of sip_poke_peer, obtained from sip_alloc, just before it goes out of scope");
30720 if ((tmp = strchr(host,
'@')))
30723 ast_debug(3,
"Checking device state for peer %s\n", host);
30771 sip_unref_peer(p,
"sip_unref_peer, from sip_devicestate, release ref from sip_find_peer");
30801 char *secret =
NULL;
30802 char *md5secret =
NULL;
30803 char *authname =
NULL;
30804 char *trans =
NULL;
30805 char dialstring[256];
30806 char *remote_address;
30830 ast_log(
LOG_ERROR,
"Unable to build sip pvt data for '%s' (Out of memory or socket error)\n", dest);
30837 snprintf(dialstring,
sizeof(dialstring),
"%s/%s", type, dest);
30844 ast_log(
LOG_ERROR,
"Unable to build option SIP data structure - Out of memory\n");
30858 dnid = strchr(tmp,
'!');
30859 if (dnid !=
NULL) {
30860 char *fromuser_and_domain;
30863 if ((fromuser_and_domain = strchr(dnid,
'!'))) {
30864 char *forward_compat;
30867 *fromuser_and_domain++ =
'\0';
30872 if ((forward_compat = strchr(fromuser_and_domain,
'!'))) {
30874 *forward_compat =
'\0';
30877 if ((fromdomain = strchr(fromuser_and_domain,
'@'))) {
30878 *fromdomain++ =
'\0';
30900 dialog_unref(p,
"unref dialog p from bad destination");
30909 host = strchr(
args.peerorhost,
'@');
30912 ext =
args.peerorhost;
30913 secret = strchr(ext,
':');
30917 md5secret = strchr(secret,
':');
30920 *md5secret++ =
'\0';
30921 authname = strchr(md5secret,
':');
30924 *authname++ =
'\0';
30925 trans = strchr(authname,
':');
30929 if (!strcasecmp(trans,
"tcp"))
30931 else if (!strcasecmp(trans,
"tls"))
30934 if (strcasecmp(trans,
"udp"))
30935 ast_log(
LOG_WARNING,
"'%s' is not a valid transport option to Dial() for SIP calls, using udp by default.\n", trans);
30944 host =
args.peerorhost;
30945 remote_address =
args.remote_address;
30947 remote_address =
args.remote_address;
30949 ast_log(
LOG_NOTICE,
"Conflicting extension values given. Using '%s' and not '%s'\n", ext,
args.exten);
30956 ast_log(
LOG_WARNING,
"Unable to parse outboundproxy %s. We will not use this remote IP address\n", remote_address);
30969 ast_debug(3,
"Cant create SIP call - target device not registered\n");
31026 printf(
"Setting up to call extension '%s' at '%s'\n", ext ? ext :
"<none>", host);
31042 dialog_unref(p,
"toss pvt ptr at end of sip_request_call");
31060 while ((word =
strsep(&next,
","))) {
31061 if (!strcasecmp(word,
"port"))
31063 else if (!strcasecmp(word,
"invite"))
31076 unsigned int *maxdatagram)
31080 if (!strcasecmp(v->
name,
"t38pt_udptl")) {
31086 while ((word =
strsep(&next,
","))) {
31087 if (
ast_true(word) || !strcasecmp(word,
"fec")) {
31090 }
else if (!strcasecmp(word,
"redundancy")) {
31093 }
else if (!strcasecmp(word,
"none")) {
31096 }
else if (!strncasecmp(word,
"maxdatagram=", 12)) {
31097 if (sscanf(&word[12],
"%30u", maxdatagram) != 1) {
31103 }
else if (!strcasecmp(v->
name,
"t38pt_usertpsource")) {
31124 if (!strcasecmp(v->
name,
"trustrpid")) {
31127 }
else if (!strcasecmp(v->
name,
"supportpath")) {
31130 }
else if (!strcasecmp(v->
name,
"sendrpid")) {
31132 if (!strcasecmp(v->
value,
"pai")) {
31134 }
else if (!strcasecmp(v->
value,
"rpid")) {
31139 }
else if (!strcasecmp(v->
name,
"rpid_update")) {
31142 }
else if (!strcasecmp(v->
name,
"rpid_immediate")) {
31145 }
else if (!strcasecmp(v->
name,
"trust_id_outbound")) {
31148 if (!strcasecmp(v->
value,
"legacy")) {
31158 }
else if (!strcasecmp(v->
name,
"g726nonstandard")) {
31161 }
else if (!strcasecmp(v->
name,
"useclientcode")) {
31164 }
else if (!strcasecmp(v->
name,
"dtmfmode")) {
31167 if (!strcasecmp(v->
value,
"inband"))
31169 else if (!strcasecmp(v->
value,
"rfc2833"))
31171 else if (!strcasecmp(v->
value,
"info"))
31173 else if (!strcasecmp(v->
value,
"shortinfo"))
31175 else if (!strcasecmp(v->
value,
"auto"))
31181 }
else if (!strcasecmp(v->
name,
"nat")) {
31183 }
else if (!strcasecmp(v->
name,
"directmedia") || !strcasecmp(v->
name,
"canreinvite")) {
31193 while ((word =
strsep(&next,
","))) {
31194 if (!strcasecmp(word,
"update")) {
31196 }
else if (!strcasecmp(word,
"nonat")) {
31199 }
else if (!strcasecmp(word,
"outgoing")) {
31208 }
else if (!strcasecmp(v->
name,
"insecure")) {
31212 }
else if (!strcasecmp(v->
name,
"progressinband")) {
31217 else if (!strcasecmp(v->
value,
"never"))
31219 }
else if (!strcasecmp(v->
name,
"promiscredir")) {
31222 }
else if (!strcasecmp(v->
name,
"videosupport")) {
31223 if (!strcasecmp(v->
value,
"always")) {
31230 }
else if (!strcasecmp(v->
name,
"textsupport")) {
31234 }
else if (!strcasecmp(v->
name,
"allowoverlap")) {
31239 }
else if (!strcasecmp(v->
value,
"dtmf")){
31242 }
else if (!strcasecmp(v->
name,
"allowsubscribe")) {
31245 }
else if (!strcasecmp(v->
name,
"ignoresdpversion")) {
31248 }
else if (!strcasecmp(v->
name,
"faxdetect")) {
31258 while ((word =
strsep(&next,
","))) {
31259 if (!strcasecmp(word,
"cng")) {
31261 }
else if (!strcasecmp(word,
"t38")) {
31268 }
else if (!strcasecmp(v->
name,
"rfc2833compensate")) {
31271 }
else if (!strcasecmp(v->
name,
"buggymwi")) {
31274 }
else if (!strcasecmp(v->
name,
"rtcp_mux")) {
31308 ast_debug(1,
"Added local SIP domain '%s'\n", domain);
31321 if (strcasecmp(d->
domain, domain)) {
31386 ast_debug(1,
"Auth config :: %s\n", configuration);
31389 username = authcopy;
31392 realm = strrchr(username,
'@');
31396 ast_log(
LOG_WARNING,
"Format for authentication entry is user[:secret]@realm at line %d\n", lineno);
31401 if ((secret = strchr(username,
':'))) {
31403 }
else if ((md5secret = strchr(username,
'#'))) {
31404 *md5secret++ =
'\0';
31408 if (!*credentials) {
31410 "Create realm auth container.");
31411 if (!*credentials) {
31432 ast_verb(3,
"Added authentication for realm %s\n", realm);
31450 if (!strcasecmp(auth->
realm, realm)) {
31469 if ((varval = strchr(varname,
'='))) {
31473 tmpvar->
next = list;
31558 ao2_t_ref(peer, -1,
"failed to string_field_init, drop peer");
31563 ao2_t_ref(peer, -1,
"failed to allocate cc_params for peer");
31568 ao2_t_ref(peer, -1,
"failed to allocate format capabilities, drop peer");
31596 while ((mbox =
strsep(&next,
","))) {
31608 if (!strcmp(mailbox->
id, mbox)) {
31618 mailbox =
ast_calloc(1,
sizeof(*mailbox) + strlen(mbox));
31622 strcpy(mailbox->
id, mbox);
31624 mailbox->
peer = peer;
31643 int timerb_set = 0, timert1_set = 0;
31644 time_t regseconds = 0;
31645 struct ast_flags peerflags[3] = {{(0)}};
31649 static int deprecation_warning = 1;
31650 int alt_fullcontact = alt ? 1 : 0, headercount = 0;
31652 int acl_change_subscription_needed = 0;
31670 ao2_t_unlink(peers_by_ip, peer,
"ao2_unlink peer from peers_by_ip table");
31682 ao2_t_ref(peer, -1,
"failed to allocate endpoint, drop peer");
31686 ao2_t_ref(peer, -1,
"failed to allocate format capabilities, drop peer");
31690 ao2_t_ref(peer, -1,
"failed to string_field_init, drop peer");
31695 ao2_t_ref(peer, -1,
"failed to allocate cc_params for peer");
31702 ast_debug(3,
"-REALTIME- peer built. Name: %s. Peer objects: %d\n", name,
rpeerobjs);
31713 oldacl = peer->
acl;
31739 ao2_t_ref(peer->
auth, -1,
"Removing old peer authentication");
31748 if (!devstate_only) {
31764 for (; v || ((v = alt) && !(alt=
NULL)); v = v->
next) {
31765 if (!devstate_only) {
31772 if (!strcasecmp(v->
name,
"transport")) {
31777 while ((trans =
strsep(&val,
","))) {
31780 if (!strncasecmp(trans,
"udp", 3)) {
31782 }
else if (!strncasecmp(trans,
"wss", 3)) {
31784 }
else if (!strncasecmp(trans,
"ws", 2)) {
31788 }
else if (default_tls_cfg.
enabled && !strncasecmp(trans,
"tls", 3)) {
31790 }
else if (!strncasecmp(trans,
"tcp", 3) || !strncasecmp(trans,
"tls", 3)) {
31791 ast_log(
LOG_WARNING,
"'%.3s' is not a valid transport type when %.3senable=no. If no other is specified, the defaults from general will be used.\n", trans, trans);
31793 ast_log(
LOG_NOTICE,
"'%s' is not a valid transport type. if no other is specified, the defaults from general will be used.\n", trans);
31800 }
else if (realtime && !strcasecmp(v->
name,
"regseconds")) {
31802 }
else if (realtime && !strcasecmp(v->
name,
"name")) {
31804 }
else if (realtime && !strcasecmp(v->
name,
"useragent")) {
31806 }
else if (!strcasecmp(v->
name,
"type")) {
31807 if (!strcasecmp(v->
value,
"peer")) {
31809 }
else if (!strcasecmp(v->
value,
"user")) {
31811 }
else if (!strcasecmp(v->
value,
"friend")) {
31814 }
else if (!strcasecmp(v->
name,
"remotesecret")) {
31816 }
else if (!strcasecmp(v->
name,
"secret")) {
31818 }
else if (!strcasecmp(v->
name,
"description")) {
31820 }
else if (!strcasecmp(v->
name,
"md5secret")) {
31822 }
else if (!strcasecmp(v->
name,
"auth")) {
31824 }
else if (!strcasecmp(v->
name,
"callerid")) {
31830 }
else if (!strcasecmp(v->
name,
"mwi_from")) {
31832 }
else if (!strcasecmp(v->
name,
"fullname")) {
31834 }
else if (!strcasecmp(v->
name,
"trunkname")) {
31837 }
else if (!strcasecmp(v->
name,
"cid_number")) {
31839 }
else if (!strcasecmp(v->
name,
"cid_tag")) {
31841 }
else if (!strcasecmp(v->
name,
"context")) {
31844 }
else if (!strcasecmp(v->
name,
"recordonfeature")) {
31846 }
else if (!strcasecmp(v->
name,
"recordofffeature")) {
31848 }
else if (!strcasecmp(v->
name,
"outofcall_message_context")) {
31850 }
else if (!strcasecmp(v->
name,
"subscribecontext")) {
31852 }
else if (!strcasecmp(v->
name,
"fromdomain")) {
31853 char *fromdomainport;
31855 if ((fromdomainport = strchr(peer->
fromdomain,
':'))) {
31856 *fromdomainport++ =
'\0';
31858 ast_log(
LOG_NOTICE,
"'%s' is not a valid port number for fromdomain.\n",fromdomainport);
31863 }
else if (!strcasecmp(v->
name,
"usereqphone")) {
31865 }
else if (!strcasecmp(v->
name,
"fromuser")) {
31867 }
else if (!strcasecmp(v->
name,
"outboundproxy")) {
31879 }
else if (!strcasecmp(v->
name,
"host")) {
31880 if (!strcasecmp(v->
value,
"dynamic")) {
31894 srvlookup = v->
value;
31896 }
else if (!strcasecmp(v->
name,
"defaultip")) {
31899 sip_unref_peer(peer,
"sip_unref_peer: from build_peer defaultip");
31902 }
else if (!strcasecmp(v->
name,
"permit") || !strcasecmp(v->
name,
"deny") || !strcasecmp(v->
name,
"acl")) {
31909 sip_unref_peer(peer,
"Removing peer due to bad ACL configuration");
31912 }
else if (!strcasecmp(v->
name,
"contactpermit") || !strcasecmp(v->
name,
"contactdeny") || !strcasecmp(v->
name,
"contactacl")) {
31919 sip_unref_peer(peer,
"Removing peer due to bad contact ACL configuration");
31922 }
else if (!strcasecmp(v->
name,
"directmediapermit") || !strcasecmp(v->
name,
"directmediadeny") || !strcasecmp(v->
name,
"directmediaacl")) {
31927 sip_unref_peer(peer,
"Removing peer due to bad direct media ACL configuration");
31930 }
else if (!strcasecmp(v->
name,
"port")) {
31940 }
else if (!strcasecmp(v->
name,
"callingpres")) {
31945 }
else if (!strcasecmp(v->
name,
"username") || !strcasecmp(v->
name,
"defaultuser")) {
31947 if (!strcasecmp(v->
name,
"username")) {
31948 if (deprecation_warning) {
31949 ast_log(
LOG_NOTICE,
"The 'username' field for sip peers has been deprecated in favor of the term 'defaultuser'\n");
31950 deprecation_warning = 0;
31954 }
else if (!strcasecmp(v->
name,
"tonezone")) {
31957 ast_log(
LOG_ERROR,
"Unknown country code '%s' for tonezone in device [%s] at line %d. Check indications.conf for available country codes.\n", v->
value, peer->
name, v->
lineno);
31962 }
else if (!strcasecmp(v->
name,
"language")) {
31964 }
else if (!strcasecmp(v->
name,
"regexten")) {
31966 }
else if (!strcasecmp(v->
name,
"callbackextension")) {
31968 }
else if (!strcasecmp(v->
name,
"amaflags")) {
31975 }
else if (!strcasecmp(v->
name,
"maxforwards")) {
31981 }
else if (!strcasecmp(v->
name,
"accountcode")) {
31983 }
else if (!strcasecmp(v->
name,
"mohinterpret")) {
31985 }
else if (!strcasecmp(v->
name,
"mohsuggest")) {
31987 }
else if (!strcasecmp(v->
name,
"parkinglot")) {
31989 }
else if (!strcasecmp(v->
name,
"rtp_engine")) {
31991 }
else if (!strcasecmp(v->
name,
"mailbox")) {
31993 }
else if (!strcasecmp(v->
name,
"hasvoicemail")) {
32001 if (strchr(name,
'@')) {
32006 snprintf(mailbox,
sizeof(mailbox),
"%s@default", name);
32010 }
else if (!strcasecmp(v->
name,
"subscribemwi")) {
32012 }
else if (!strcasecmp(v->
name,
"vmexten")) {
32014 }
else if (!strcasecmp(v->
name,
"callgroup")) {
32016 }
else if (!strcasecmp(v->
name,
"allowtransfer")) {
32018 }
else if (!strcasecmp(v->
name,
"pickupgroup")) {
32020 }
else if (!strcasecmp(v->
name,
"namedcallgroup")) {
32022 }
else if (!strcasecmp(v->
name,
"namedpickupgroup")) {
32024 }
else if (!strcasecmp(v->
name,
"allow")) {
32029 }
else if (!strcasecmp(v->
name,
"disallow")) {
32034 }
else if (!strcasecmp(v->
name,
"preferred_codec_only")) {
32036 }
else if (!strcasecmp(v->
name,
"autoframing")) {
32038 }
else if (!strcasecmp(v->
name,
"rtptimeout")) {
32043 }
else if (!strcasecmp(v->
name,
"rtpholdtimeout")) {
32048 }
else if (!strcasecmp(v->
name,
"rtpkeepalive")) {
32053 }
else if (!strcasecmp(v->
name,
"timert1")) {
32059 }
else if (!strcasecmp(v->
name,
"timerb")) {
32065 }
else if (!strcasecmp(v->
name,
"setvar")) {
32067 }
else if (!strcasecmp(v->
name,
"header")) {
32069 snprintf(tmp,
sizeof(tmp),
"__SIPADDHEADERpre%2d=%s", ++headercount, v->
value);
32071 }
else if (!strcasecmp(v->
name,
"qualifyfreq")) {
32073 if (sscanf(v->
value,
"%30d", &i) == 1) {
32079 }
else if (!strcasecmp(v->
name,
"maxcallbitrate")) {
32084 }
else if (!strcasecmp(v->
name,
"session-timers")) {
32092 }
else if (!strcasecmp(v->
name,
"session-expires")) {
32097 }
else if (!strcasecmp(v->
name,
"session-minse")) {
32106 }
else if (!strcasecmp(v->
name,
"session-refresher")) {
32114 }
else if (!strcasecmp(v->
name,
"disallowed_methods")) {
32117 }
else if (!strcasecmp(v->
name,
"unsolicited_mailbox")) {
32119 }
else if (!strcasecmp(v->
name,
"use_q850_reason")) {
32121 }
else if (!strcasecmp(v->
name,
"encryption")) {
32123 }
else if (!strcasecmp(v->
name,
"encryption_taglen")) {
32125 }
else if (!strcasecmp(v->
name,
"snom_aoc_enabled")) {
32127 }
else if (!strcasecmp(v->
name,
"avpf")) {
32129 }
else if (!strcasecmp(v->
name,
"icesupport")) {
32131 }
else if (!strcasecmp(v->
name,
"ignore_requested_pref")) {
32133 }
else if (!strcasecmp(v->
name,
"discard_remote_hold_retrieval")) {
32135 }
else if (!strcasecmp(v->
name,
"force_avp")) {
32144 sip_unref_peer(peer,
"Removing peer due to bad DTLS configuration");
32154 if (realtime && !strcasecmp(v->
name,
"lastms")) {
32158 }
else if (realtime && !strcasecmp(v->
name,
"fullcontact")) {
32159 if (alt_fullcontact && !alt) {
32165 alt_fullcontact = 0;
32174 }
else if (!strcasecmp(v->
name,
"qualify")) {
32175 if (!strcasecmp(v->
value,
"no")) {
32177 }
else if (!strcasecmp(v->
value,
"yes")) {
32179 }
else if (sscanf(v->
value,
"%30d", &peer->
maxms) != 1) {
32180 ast_log(
LOG_WARNING,
"Qualification of peer '%s' should be 'yes', 'no', or a number of milliseconds at line %d of sip.conf\n", peer->
name, v->
lineno);
32188 ast_log(
LOG_WARNING,
"Qualify is incompatible with dynamic uncached realtime. Please either turn rtcachefriends on or turn qualify off on peer '%s'\n", peer->
name);
32191 }
else if (!strcasecmp(v->
name,
"keepalive")) {
32192 if (!strcasecmp(v->
value,
"no")) {
32194 }
else if (!strcasecmp(v->
value,
"yes")) {
32197 ast_log(
LOG_WARNING,
"Keep alive of peer '%s' should be 'yes', 'no', or a number of milliseconds at line %d of sip.conf\n", peer->
name, v->
lineno);
32200 }
else if (!strcasecmp(v->
name,
"callcounter")) {
32202 }
else if (!strcasecmp(v->
name,
"call-limit")) {
32207 }
else if (!strcasecmp(v->
name,
"busylevel")) {
32217 if (!devstate_only) {
32229 ast_log(
LOG_WARNING,
"Peer %s has a cc_agent_policy of 'native' but required libxml2 dependency is not installed. Changing policy to 'never'\n", peer->
name);
32236 if (timerb_set && timert1_set) {
32238 }
else if (timerb_set) {
32293 if ((params = strchr(_srvlookup,
';'))) {
32302 ast_log(
LOG_ERROR,
"srvlookup failed for host: %s, on peer %s, removing peer\n", _srvlookup, peer->
name);
32303 sip_unref_peer(peer,
"dnsmgr lookup failed, getting rid of peer dnsmgr ref");
32319 ast_log(
LOG_ERROR,
"Bad or unresolved host/IP entry in configuration for peer %s, cannot add to contact ACL\n", peer->
name);
32345 int enablepoke = 1;
32348 time_t nowtime = time(
NULL);
32350 if ((nowtime - regseconds) > 0) {
32352 memset(&peer->
addr, 0,
sizeof(peer->
addr));
32355 ast_debug(1,
"Bah, we're expired (%d/%d/%d)!\n", (
int)(nowtime - regseconds), (
int)regseconds, (
int)nowtime);
32360 if (!devstate_only && enablepoke) {
32408 if (acl_change_subscription_needed) {
32447 int global_nat, specific_nat;
32450 ast_log(
LOG_WARNING,
"!!! PLEASE NOTE: Setting 'nat' for a peer/user that differs from the global setting can make\n");
32451 ast_log(
LOG_WARNING,
"!!! the name of that peer/user discoverable by an attacker. Replies for non-existent peers/users\n");
32452 ast_log(
LOG_WARNING,
"!!! will be sent to a different port than replies for an existing peer/user. If at all possible,\n");
32453 ast_log(
LOG_WARNING,
"!!! use the global 'nat' setting and do not set 'nat' per peer/user.\n");
32473 ao2_t_ref(reg, -1,
"Stop scheduled reregister timeout"));
32475 ao2_t_ref(reg, -1,
"Stop scheduled register timeout"));
32480 ao2_t_ref(reg, -1,
"reg ptr unref from dnsmgr");
32485 ao2_t_ref(reg, -1,
"cleanup_registration action");
32493 ao2_t_ref(reg, +1,
"cleanup_registration action");
32496 ao2_t_ref(reg, -1,
"Failed to schedule cleanup_registration action");
32519 char *cat, *stringp, *
context, *oldregcontext;
32524 int auto_sip_domains =
FALSE;
32526 int registry_count = 0, peer_count = 0, timerb_set = 0, timert1_set = 0;
32527 int subscribe_network_change = 1;
32528 time_t run_start, run_end;
32530 int acl_change_subscription_needed = 0;
32531 int min_subexpiry_set = 0, max_subexpiry_set = 0;
32534 run_start = time(0);
32548 ast_log(
LOG_ERROR,
"Contents of users.conf are invalid and cannot be parsed\n");
32569 ast_log(
LOG_ERROR,
"Contents of users.conf are invalid and cannot be parsed\n");
32581 ast_debug(4,
"--------------- SIP reload started\n");
32586 ao2_t_ref(authl, -1,
"Removing old global authentication");
32593 ast_debug(4,
"--------------- Done destroying registry list\n");
32620 oldregcontext = oldcontexts;
32635 memset(&localaddr, 0,
sizeof(localaddr));
32793 if (!strcasecmp(v->
name,
"tlsverifyclient")) {
32800 if (!strcasecmp(v->
name,
"context")) {
32802 }
else if (!strcasecmp(v->
name,
"recordonfeature")) {
32804 }
else if (!strcasecmp(v->
name,
"recordofffeature")) {
32806 }
else if (!strcasecmp(v->
name,
"subscribecontext")) {
32808 }
else if (!strcasecmp(v->
name,
"callcounter")) {
32810 }
else if (!strcasecmp(v->
name,
"allowguest")) {
32812 }
else if (!strcasecmp(v->
name,
"realm")) {
32814 }
else if (!strcasecmp(v->
name,
"domainsasrealm")) {
32816 }
else if (!strcasecmp(v->
name,
"useragent")) {
32819 }
else if (!strcasecmp(v->
name,
"sdpsession")) {
32821 }
else if (!strcasecmp(v->
name,
"sdpowner")) {
32823 if (!strstr(v->
value,
" ")) {
32828 }
else if (!strcasecmp(v->
name,
"allowtransfer")) {
32830 }
else if (!strcasecmp(v->
name,
"rtcachefriends")) {
32832 }
else if (!strcasecmp(v->
name,
"rtsavesysname")) {
32834 }
else if (!strcasecmp(v->
name,
"rtsavepath")) {
32836 }
else if (!strcasecmp(v->
name,
"rtupdate")) {
32838 }
else if (!strcasecmp(v->
name,
"ignoreregexpire")) {
32840 }
else if (!strcasecmp(v->
name,
"timert1")) {
32845 }
else if (!strcasecmp(v->
name,
"timerb")) {
32852 }
else if (!strcasecmp(v->
name,
"t1min")) {
32854 }
else if (!strcasecmp(v->
name,
"transport")) {
32859 while ((trans =
strsep(&val,
","))) {
32862 if (!strncasecmp(trans,
"udp", 3)) {
32864 }
else if (!strncasecmp(trans,
"tcp", 3)) {
32866 }
else if (!strncasecmp(trans,
"tls", 3)) {
32868 }
else if (!strncasecmp(trans,
"wss", 3)) {
32870 }
else if (!strncasecmp(trans,
"ws", 2)) {
32873 ast_log(
LOG_NOTICE,
"'%s' is not a valid transport type. if no other is specified, udp will be used.\n", trans);
32879 }
else if (!strcasecmp(v->
name,
"tcpenable")) {
32881 ast_debug(2,
"Enabling TCP socket for listening\n");
32884 }
else if (!strcasecmp(v->
name,
"tcpbindaddr")) {
32890 ast_debug(2,
"Setting TCP socket address to %s\n",
32892 }
else if (!strcasecmp(v->
name,
"dynamic_exclude_static") || !strcasecmp(v->
name,
"dynamic_excludes_static")) {
32894 }
else if (!strcasecmp(v->
name,
"contactpermit") || !strcasecmp(v->
name,
"contactdeny") || !strcasecmp(v->
name,
"contactacl")) {
32901 }
else if (!strcasecmp(v->
name,
"rtautoclear")) {
32902 int i = atoi(v->
value);
32909 }
else if (!strcasecmp(v->
name,
"usereqphone")) {
32911 }
else if (!strcasecmp(v->
name,
"prematuremedia")) {
32913 }
else if (!strcasecmp(v->
name,
"relaxdtmf")) {
32915 }
else if (!strcasecmp(v->
name,
"vmexten")) {
32917 }
else if (!strcasecmp(v->
name,
"rtptimeout")) {
32922 }
else if (!strcasecmp(v->
name,
"rtpholdtimeout")) {
32927 }
else if (!strcasecmp(v->
name,
"rtpkeepalive")) {
32932 }
else if (!strcasecmp(v->
name,
"compactheaders")) {
32934 }
else if (!strcasecmp(v->
name,
"notifymimetype")) {
32936 }
else if (!strcasecmp(v->
name,
"directrtpsetup")) {
32938 }
else if (!strcasecmp(v->
name,
"notifyringing")) {
32939 if (!strcasecmp(v->
value,
"notinuse")) {
32944 }
else if (!strcasecmp(v->
name,
"notifyhold")) {
32946 }
else if (!strcasecmp(v->
name,
"notifycid")) {
32947 if (!strcasecmp(v->
value,
"ignore-context")) {
32952 }
else if (!strcasecmp(v->
name,
"alwaysauthreject")) {
32954 }
else if (!strcasecmp(v->
name,
"auth_options_requests")) {
32958 }
else if (!strcasecmp(v->
name,
"auth_message_requests")) {
32960 }
else if (!strcasecmp(v->
name,
"accept_outofcall_message")) {
32962 }
else if (!strcasecmp(v->
name,
"outofcall_message_context")) {
32964 }
else if (!strcasecmp(v->
name,
"mohinterpret")) {
32966 }
else if (!strcasecmp(v->
name,
"mohsuggest")) {
32968 }
else if (!strcasecmp(v->
name,
"tonezone")) {
32971 ast_log(
LOG_ERROR,
"Unknown country code '%s' for tonezone in [general] at line %d. Check indications.conf for available country codes.\n", v->
value, v->
lineno);
32976 }
else if (!strcasecmp(v->
name,
"language")) {
32978 }
else if (!strcasecmp(v->
name,
"regcontext")) {
32980 stringp = newcontexts;
32984 while ((context =
strsep(&stringp,
"&"))) {
32989 }
else if (!strcasecmp(v->
name,
"regextenonqualify")) {
32991 }
else if (!strcasecmp(v->
name,
"legacy_useroption_parsing")) {
32993 }
else if (!strcasecmp(v->
name,
"send_diversion")) {
32995 }
else if (!strcasecmp(v->
name,
"callerid")) {
32997 }
else if (!strcasecmp(v->
name,
"mwi_from")) {
32999 }
else if (!strcasecmp(v->
name,
"fromdomain")) {
33000 char *fromdomainport;
33003 *fromdomainport++ =
'\0';
33005 ast_log(
LOG_NOTICE,
"'%s' is not a valid port number for fromdomain.\n",fromdomainport);
33010 }
else if (!strcasecmp(v->
name,
"outboundproxy")) {
33021 }
else if (!strcasecmp(v->
name,
"autocreatepeer")) {
33022 if (!strcasecmp(v->
value,
"persist")) {
33027 }
else if (!strcasecmp(v->
name,
"match_auth_username")) {
33029 }
else if (!strcasecmp(v->
name,
"srvlookup")) {
33031 }
else if (!strcasecmp(v->
name,
"pedantic")) {
33033 }
else if (!strcasecmp(v->
name,
"maxexpirey") || !strcasecmp(v->
name,
"maxexpiry")) {
33038 }
else if (!strcasecmp(v->
name,
"minexpirey") || !strcasecmp(v->
name,
"minexpiry")) {
33043 }
else if (!strcasecmp(v->
name,
"defaultexpiry") || !strcasecmp(v->
name,
"defaultexpirey")) {
33048 }
else if (!strcasecmp(v->
name,
"submaxexpirey") || !strcasecmp(v->
name,
"submaxexpiry")) {
33053 max_subexpiry_set = 1;
33054 }
else if (!strcasecmp(v->
name,
"subminexpirey") || !strcasecmp(v->
name,
"subminexpiry")) {
33059 min_subexpiry_set = 1;
33060 }
else if (!strcasecmp(v->
name,
"mwiexpiry") || !strcasecmp(v->
name,
"mwiexpirey")) {
33065 }
else if (!strcasecmp(v->
name,
"tcpauthtimeout")) {
33071 }
else if (!strcasecmp(v->
name,
"tcpauthlimit")) {
33077 }
else if (!strcasecmp(v->
name,
"sipdebug")) {
33080 }
else if (!strcasecmp(v->
name,
"dumphistory")) {
33082 }
else if (!strcasecmp(v->
name,
"recordhistory")) {
33084 }
else if (!strcasecmp(v->
name,
"registertimeout")) {
33089 }
else if (!strcasecmp(v->
name,
"registerattempts")) {
33091 }
else if (!strcasecmp(v->
name,
"register_retry_403")) {
33093 }
else if (!strcasecmp(v->
name,
"bindaddr") || !strcasecmp(v->
name,
"udpbindaddr")) {
33097 }
else if (!strcasecmp(v->
name,
"localnet")) {
33109 }
else if (!strcasecmp(v->
name,
"media_address")) {
33112 }
else if (!strcasecmp(v->
name,
"rtpbindaddr")) {
33116 }
else if (!strcasecmp(v->
name,
"externaddr") || !strcasecmp(v->
name,
"externip")) {
33119 "Invalid address for externaddr keyword: %s\n",
33123 }
else if (!strcasecmp(v->
name,
"externhost")) {
33129 }
else if (!strcasecmp(v->
name,
"externrefresh")) {
33134 }
else if (!strcasecmp(v->
name,
"externtcpport")) {
33136 ast_log(
LOG_WARNING,
"Invalid externtcpport value, must be a positive integer between 1 and 65535 at line %d\n", v->
lineno);
33138 }
else if (!strcasecmp(v->
name,
"externtlsport")) {
33140 ast_log(
LOG_WARNING,
"Invalid externtlsport value, must be a positive integer between 1 and 65535 at line %d\n", v->
lineno);
33142 }
else if (!strcasecmp(v->
name,
"allow")) {
33147 }
else if (!strcasecmp(v->
name,
"disallow")) {
33152 }
else if (!strcasecmp(v->
name,
"preferred_codec_only")) {
33154 }
else if (!strcasecmp(v->
name,
"autoframing")) {
33156 }
else if (!strcasecmp(v->
name,
"allowexternaldomains")) {
33158 }
else if (!strcasecmp(v->
name,
"autodomain")) {
33160 }
else if (!strcasecmp(v->
name,
"domain")) {
33162 char *cntx = strchr(domain,
',');
33169 ast_debug(1,
"No context specified at line %d for domain '%s'\n", v->
lineno, domain);
33176 }
else if (!strcasecmp(v->
name,
"register")) {
33180 }
else if (!strcasecmp(v->
name,
"mwi")) {
33182 }
else if (!strcasecmp(v->
name,
"tos_sip")) {
33186 }
else if (!strcasecmp(v->
name,
"tos_audio")) {
33190 }
else if (!strcasecmp(v->
name,
"tos_video")) {
33194 }
else if (!strcasecmp(v->
name,
"tos_text")) {
33198 }
else if (!strcasecmp(v->
name,
"cos_sip")) {
33202 }
else if (!strcasecmp(v->
name,
"cos_audio")) {
33206 }
else if (!strcasecmp(v->
name,
"cos_video")) {
33210 }
else if (!strcasecmp(v->
name,
"cos_text")) {
33214 }
else if (!strcasecmp(v->
name,
"bindport")) {
33215 if (sscanf(v->
value,
"%5d", &bindport) != 1) {
33218 }
else if (!strcasecmp(v->
name,
"qualify")) {
33219 if (!strcasecmp(v->
value,
"no")) {
33221 }
else if (!strcasecmp(v->
value,
"yes")) {
33224 ast_log(
LOG_WARNING,
"Qualification default should be 'yes', 'no', or a number of milliseconds at line %d of sip.conf\n", v->
lineno);
33227 }
else if (!strcasecmp(v->
name,
"keepalive")) {
33228 if (!strcasecmp(v->
value,
"no")) {
33230 }
else if (!strcasecmp(v->
value,
"yes")) {
33233 ast_log(
LOG_WARNING,
"Keep alive default should be 'yes', 'no', or a number of milliseconds at line %d of sip.conf\n", v->
lineno);
33236 }
else if (!strcasecmp(v->
name,
"qualifyfreq")) {
33238 if (sscanf(v->
value,
"%30d", &i) == 1) {
33244 }
else if (!strcasecmp(v->
name,
"authfailureevents")) {
33246 }
else if (!strcasecmp(v->
name,
"maxcallbitrate")) {
33251 }
else if (!strcasecmp(v->
name,
"matchexternaddrlocally") || !strcasecmp(v->
name,
"matchexterniplocally")) {
33253 }
else if (!strcasecmp(v->
name,
"session-timers")) {
33261 }
else if (!strcasecmp(v->
name,
"session-expires")) {
33266 }
else if (!strcasecmp(v->
name,
"session-minse")) {
33275 }
else if (!strcasecmp(v->
name,
"session-refresher")) {
33283 }
else if (!strcasecmp(v->
name,
"storesipcause")) {
33286 ast_log(
LOG_WARNING,
"Usage of SIP_CAUSE is deprecated. Please use HANGUPCAUSE instead.\n");
33288 }
else if (!strcasecmp(v->
name,
"qualifygap")) {
33294 }
else if (!strcasecmp(v->
name,
"qualifypeers")) {
33299 }
else if (!strcasecmp(v->
name,
"disallowed_methods")) {
33302 }
else if (!strcasecmp(v->
name,
"shrinkcallerid")) {
33310 }
else if (!strcasecmp(v->
name,
"use_q850_reason")) {
33312 }
else if (!strcasecmp(v->
name,
"maxforwards")) {
33318 }
else if (!strcasecmp(v->
name,
"subscribe_network_change_event")) {
33320 subscribe_network_change = 1;
33322 subscribe_network_change = 0;
33326 }
else if (!strcasecmp(v->
name,
"snom_aoc_enabled")) {
33328 }
else if (!strcasecmp(v->
name,
"icesupport")) {
33330 }
else if (!strcasecmp(v->
name,
"discard_remote_hold_retrieval")) {
33332 }
else if (!strcasecmp(v->
name,
"parkinglot")) {
33334 }
else if (!strcasecmp(v->
name,
"refer_addheaders")) {
33336 }
else if (!strcasecmp(v->
name,
"websocket_write_timeout")) {
33342 }
else if (!strcasecmp(v->
name,
"websocket_enabled")) {
33358 if (!min_subexpiry_set) {
33361 if (!max_subexpiry_set) {
33369 if (subscribe_network_change) {
33381 if (timerb_set && timert1_set) {
33383 }
else if (timerb_set) {
33394 ast_log(
LOG_WARNING,
"To disallow external domains, you need to configure local SIP domains.\n");
33399 ast_log(
LOG_WARNING,
"Cannot use 'tcp' transport with tcpenable=no. Removing from available transports.\n");
33404 ast_log(
LOG_WARNING,
"Cannot use 'tls' transport with tlsenable=no. Removing from available transports.\n");
33419 if (!strcasecmp(v->
name,
"auth")) {
33427 "Using %d.\n", bindport);
33451 AF_INET6 : AF_INET, SOCK_DGRAM, 0);
33459 const int reuseFlag = 1;
33461 setsockopt(
sipsock, SOL_SOCKET, SO_REUSEADDR,
33462 (
const char*)&reuseFlag,
33496 ast_log(
LOG_ERROR,
"SIP TCP Server start failed. Not listening on TCP socket.\n");
33498 ast_debug(2,
"SIP TCP server started\n");
33501 if (setsockopt(sip_tcp_desc.
accept_fd, SOL_SOCKET, SO_KEEPALIVE, &flags,
sizeof(flags))) {
33509 memcpy(sip_tls_desc.
tls_cfg, &default_tls_cfg,
sizeof(default_tls_cfg));
33523 ast_log(
LOG_ERROR,
"TLS Server start failed. Not listening on TLS socket.\n");
33528 if (setsockopt(sip_tls_desc.
accept_fd, SOL_SOCKET, SO_KEEPALIVE, &flags,
sizeof(flags))) {
33541 int genhassip, genregistersip;
33542 const char *hassip, *registersip;
33549 if (strcasecmp(cat,
"general")) {
33552 if (
ast_true(hassip) || (!hassip && genhassip)) {
33557 ao2_t_link(peers, peer,
"link peer into peer table");
33559 ao2_t_link(peers_by_ip, peer,
"link peer into peers_by_ip table");
33566 if (
ast_true(registersip) || (!registersip && genregistersip)) {
33588 snprintf(tmp,
sizeof(tmp),
"%s?%s:%s:%s@%s/%s", cat, username, secret, authuser, host, contact);
33590 snprintf(tmp,
sizeof(tmp),
"%s?%s:%s@%s/%s", cat, username, secret, host, contact);
33593 snprintf(tmp,
sizeof(tmp),
"%s?%s::%s@%s/%s", cat, username, authuser, host, contact);
33595 snprintf(tmp,
sizeof(tmp),
"%s?%s@%s/%s", cat, username, host, contact);
33612 if (!strcasecmp(cat,
"general") || !strcasecmp(cat,
"authentication"))
33619 if (!strcasecmp(utype,
"user")) {
33621 }
else if (!strcasecmp(utype,
"friend")) {
33623 }
else if (!strcasecmp(utype,
"peer")) {
33632 ao2_t_link(peers, peer,
"link peer into peers table");
33634 ao2_t_link(peers_by_ip, peer,
"link peer into peers_by_ip table");
33636 sip_unref_peer(peer,
"unref the result of the build_peer call. Now, the links from the tables are the only ones left.");
33647 if (auto_sip_domains) {
33659 ast_log(
LOG_NOTICE,
"Can't add wildcard IP address to domain list, please add IP address to domain manually.\n");
33690 if (!gethostname(temp,
sizeof(temp))) {
33701 if (notify_types) {
33706 notify_types =
NULL;
33719 ast_debug(4,
"SIP reload_config done...Runtime= %d sec\n", (
int)(run_end-run_start));
33722 if (acl_change_subscription_needed) {
33750 struct ast_sockaddr us = { { 0, }, }, them = { { 0, }, };
33759 ast_debug(3,
"Reinvite %s to %s denied by directmedia ACL on %s\n",
33760 rtptype, them_addr, us_addr);
33797 *instance = p->
rtp;
33845 *instance = p->
vrtp;
33872 *instance = p->
trtp;
33893 if (p->
owner != chan) {
33901 if ((instance || vinstance || tinstance) &&
33983 append_history(p,
"ExtInv",
"Initial invite sent with remote bridge proposal.");
34019 #ifdef TEST_FRAMEWORK 34027 const char *mode = data;
34030 ast_log(
LOG_WARNING,
"This application requires the argument: info, inband, rfc2833\n");
34045 if (!strcasecmp(mode,
"info")) {
34049 }
else if (!strcasecmp(mode,
"shortinfo")) {
34053 }
else if (!strcasecmp(mode,
"rfc2833")) {
34057 }
else if (!strcasecmp(mode,
"inband")) {
34083 const char *
inbuf = data;
34093 while (!ok && no <= 50) {
34095 snprintf(varbuf,
sizeof(varbuf),
"__SIPADDHEADER%.2d", no);
34103 size_t len = strlen(inbuf);
34108 ast_debug(1,
"SIP Header added \"%s\" as %s\n", inbuf, varbuf);
34123 char *
inbuf = (
char *) data;
34132 if (strncmp(
ast_var_name(newvariable),
"SIPADDHEADER", strlen(
"SIPADDHEADER")) == 0) {
34133 if (removeall || (!strncasecmp(
ast_var_value(newvariable),inbuf,strlen(inbuf)))) {
34135 ast_debug(1,
"removing SIP Header \"%s\" as %s\n",
34150 #ifdef TEST_FRAMEWORK 34154 char *info_data, *useragent;
34162 info_data =
strsep(&useragent,
",");
34185 extension =
strsep(&cdest,
"@");
34194 char *local_to_header;
34195 char to_header[256];
34199 ast_log(
LOG_ERROR,
"Cannot retrieve the 'To' header from the original SIP request!\n");
34202 if (((local_to_header =
strcasestr(to_header,
"sip:")) || (local_to_header =
strcasestr(to_header,
"sips:")))
34203 && (local_to_header = strchr(local_to_header,
'@'))) {
34206 memset(ldomain, 0,
sizeof(ldomain));
34209 sscanf(local_to_header,
"%255[^<>; ]", ldomain);
34234 #ifdef HAVE_LIBXML2 34244 int ms = 0, num = 0;
34309 if (regspacing > 100) {
34320 ao2_t_ref(iterator, -1,
"sip_send_all_registers iter");
34334 ao2_t_ref(mwi, -1,
"sip_send_all_mwi_subscriptions iter");
34346 ast_debug(3,
"Received offer with crypto line for media stream that is not enabled\n");
34350 if (strncasecmp(a,
"crypto:", 7)) {
34354 a += strlen(
"crypto:");
34386 time_t start_poke, end_poke;
34391 start_poke = time(0);
34395 ast_debug(4,
"--------------- Done destroying pruned peers\n");
34408 end_poke = time(0);
34410 ast_debug(4,
"do_reload finished. peer poke/prune reg contact time = %d sec.\n", (
int)(end_poke-start_poke));
34412 ast_debug(4,
"--------------- SIP reload done\n");
34426 "Usage: sip reload\n" 34427 " Reloads SIP configuration from sip.conf\n";
34435 ast_verbose(
"Previous SIP reload not yet done\n");
34444 if ((new_peer =
temp_peer(
"(bogus_peer)"))) {
34448 "Replacing the old bogus peer during reload.");
34449 ao2_t_ref(new_peer, -1,
"done with new_peer");
34480 const char*
name,
int flag,
unsigned int transport)
34490 const struct sip_peer *peer = obj;
34500 struct sip_peer *peer = obj, *peer2 = arg;
34512 const struct sip_peer *peer = obj;
34545 struct sip_peer *peer = obj, *peer2 = arg;
34546 char *callback = data;
34560 if ((peer->
transports & peer2->transports) == 0) {
34625 const struct sip_pvt *pvt = obj;
34635 struct sip_pvt *pvt = obj, *pvt2 = arg;
34645 struct sip_pvt *pvt = obj, *pvt2 = arg;
34662 key =
object->configvalue;
34676 const char *right_key = arg;
34684 cmp = strcmp(object_left->
configvalue, right_key);
34740 #ifdef TEST_FRAMEWORK 34747 const char *mwi1 =
"1234@mysipprovider.com/1234";
34748 const char *mwi2 =
"1234:password@mysipprovider.com/1234";
34749 const char *mwi3 =
"1234:password@mysipprovider.com:5061/1234";
34750 const char *mwi4 =
"1234:password:authuser@mysipprovider.com/1234";
34751 const char *mwi5 =
"1234:password:authuser@mysipprovider.com:5061/1234";
34752 const char *mwi6 =
"1234:password";
34756 info->name =
"sip_mwi_subscribe_parse_test";
34757 info->category =
"/channels/chan_sip/";
34758 info->summary =
"SIP MWI subscribe line parse unit test";
34759 info->description =
34760 "Tests the parsing of mwi subscription lines (e.g., mwi => from sip.conf)";
34776 !strcmp(iterator->
hostname,
"mysipprovider.com") &&
34777 !strcmp(iterator->
username,
"1234") &&
34778 !strcmp(iterator->
secret,
"") &&
34779 !strcmp(iterator->
authuser,
"") &&
34780 !strcmp(iterator->
mailbox,
"1234") &&
34781 iterator->
portno == 0) {
34786 ao2_t_ref(iterator, -1,
"test_sip_mwi_subscribe_parse mwi1");
34804 !strcmp(iterator->
hostname,
"mysipprovider.com") &&
34805 !strcmp(iterator->
username,
"1234") &&
34806 !strcmp(iterator->
secret,
"password") &&
34807 !strcmp(iterator->
authuser,
"") &&
34808 !strcmp(iterator->
mailbox,
"1234") &&
34809 iterator->
portno == 0) {
34814 ao2_t_ref(iterator, -1,
"test_sip_mwi_subscribe_parse mwi2");
34832 !strcmp(iterator->
hostname,
"mysipprovider.com") &&
34833 !strcmp(iterator->
username,
"1234") &&
34834 !strcmp(iterator->
secret,
"password") &&
34835 !strcmp(iterator->
authuser,
"") &&
34836 !strcmp(iterator->
mailbox,
"1234") &&
34837 iterator->
portno == 5061) {
34842 ao2_t_ref(iterator, -1,
"test_sip_mwi_subscribe_parse mwi3");
34860 !strcmp(iterator->
hostname,
"mysipprovider.com") &&
34861 !strcmp(iterator->
username,
"1234") &&
34862 !strcmp(iterator->
secret,
"password") &&
34863 !strcmp(iterator->
authuser,
"authuser") &&
34864 !strcmp(iterator->
mailbox,
"1234") &&
34865 iterator->
portno == 0) {
34870 ao2_t_ref(iterator, -1,
"test_sip_mwi_subscribe_parse mwi4");
34888 !strcmp(iterator->
hostname,
"mysipprovider.com") &&
34889 !strcmp(iterator->
username,
"1234") &&
34890 !strcmp(iterator->
secret,
"password") &&
34891 !strcmp(iterator->
authuser,
"authuser") &&
34892 !strcmp(iterator->
mailbox,
"1234") &&
34893 iterator->
portno == 5061) {
34898 ao2_t_ref(iterator, -1,
"test_sip_mwi_subscribe_parse mwi4");
34954 if (strcmp(
ast_str_buffer(req_data), messages[*num_messages])) {
34975 "INVITE sip:bob@example.org SIP/2.0\r\n" 34976 "Via: SIP/2.0/TCP 127.0.0.1:5060;branch=[branch]\r\n" 34977 "From: sipp <sip:127.0.0.1:5061>;tag=12345\r\n" 34978 "To: <sip:bob@example.org:5060>\r\n" 34979 "Call-ID: 12345\r\n" 34980 "CSeq: 1 INVITE\r\n" 34981 "Contact: sip:127.0.0.1:5061\r\n" 34982 "Max-Forwards: 70\r\n" 34983 "Content-Type: application/sdp\r\n" 34984 "Content-Length: 130\r\n" 34987 "o=user1 53655765 2353687637 IN IP4 127.0.0.1\r\n" 34989 "c=IN IP4 127.0.0.1\r\n" 34991 "m=audio 10000 RTP/AVP 0\r\n" 34992 "a=rtpmap:0 PCMU/8000\r\n" 34998 char *fragmented[] = {
34999 "INVITE sip:bob@example.org SIP/2.0\r\n" 35000 "Via: SIP/2.0/TCP 127.0.0.1:5060;branch=[branch]\r\n" 35001 "From: sipp <sip:127.0.0.1:5061>;tag=12345\r\n" 35002 "To: <sip:bob@example.org:5060>\r\n" 35003 "Call-ID: 12345\r\n" 35004 "CSeq: 1 INVITE\r\n" 35005 "Contact: sip:127.0.0.1:5061\r\n" 35009 "Content-Type: application/sdp\r\n" 35010 "Content-Length: 130\r\n" 35013 "o=user1 53655765 2353687637 IN IP4 127.0.0.1\r\n" 35015 "c=IN IP4 127.0.0.1\r\n" 35017 "m=audio 10000 RTP/AVP 0\r\n" 35018 "a=rtpmap:0 PCMU/8000\r\n" 35023 char *fragmented_body[] = {
35024 "INVITE sip:bob@example.org SIP/2.0\r\n" 35025 "Via: SIP/2.0/TCP 127.0.0.1:5060;branch=[branch]\r\n" 35026 "From: sipp <sip:127.0.0.1:5061>;tag=12345\r\n" 35027 "To: <sip:bob@example.org:5060>\r\n" 35028 "Call-ID: 12345\r\n" 35029 "CSeq: 1 INVITE\r\n" 35030 "Contact: sip:127.0.0.1:5061\r\n" 35031 "Max-Forwards: 70\r\n" 35032 "Content-Type: application/sdp\r\n" 35033 "Content-Length: 130\r\n" 35037 "o=user1 53655765 2353687637 IN IP4 127.0.0.1\r\n" 35039 "c=IN IP4 127.0.0.1\r\n" 35041 "m=audio 10000 RTP/AVP 0\r\n" 35042 "a=rtpmap:0 PCMU/8000\r\n" 35048 char *multi_fragment[] = {
35049 "INVITE sip:bob@example.org SIP/2.0\r\n" 35050 "Via: SIP/2.0/TCP 127.0.0.1:5060;branch=[branch]\r\n" 35051 "From: sipp <sip:127.0.0.1:5061>;tag=12345\r\n" 35052 "To: <sip:bob@example.org:5060>\r\n" 35053 "Call-ID: 12345\r\n" 35054 "CSeq: 1 INVITE\r\n",
35056 "Contact: sip:127.0.0.1:5061\r\n" 35057 "Max-Forwards: 70\r\n" 35058 "Content-Type: application/sdp\r\n" 35059 "Content-Length: 130\r\n" 35062 "o=user1 53655765 2353687637 IN IP4 127.0.0.1\r\n" 35068 "m=audio 10000 RTP/AVP 0\r\n" 35069 "a=rtpmap:0 PCMU/8000\r\n" 35075 char *multi_message[] = {
35076 "SIP/2.0 100 Trying\r\n" 35077 "Via: SIP/2.0/TCP 127.0.0.1:5060;branch=[branch]\r\n" 35078 "From: sipp <sip:127.0.0.1:5061>;tag=12345\r\n" 35079 "To: <sip:bob@example.org:5060>\r\n" 35080 "Call-ID: 12345\r\n" 35081 "CSeq: 1 INVITE\r\n" 35082 "Contact: <sip:bob@example.org:5060>\r\n" 35083 "Content-Length: 0\r\n" 35085 "SIP/2.0 180 Ringing\r\n" 35086 "Via: SIP/2.0/TCP 127.0.0.1:5060;branch=[branch]\r\n" 35087 "From: sipp <sip:127.0.0.1:5061>;tag=12345\r\n" 35088 "To: <sip:bob@example.org:5060>\r\n" 35089 "Call-ID: 12345\r\n" 35090 "CSeq: 1 INVITE\r\n" 35091 "Contact: <sip:bob@example.org:5060>\r\n" 35092 "Content-Length: 0\r\n" 35095 char *multi_message_divided[] = {
35096 "SIP/2.0 100 Trying\r\n" 35097 "Via: SIP/2.0/TCP 127.0.0.1:5060;branch=[branch]\r\n" 35098 "From: sipp <sip:127.0.0.1:5061>;tag=12345\r\n" 35099 "To: <sip:bob@example.org:5060>\r\n" 35100 "Call-ID: 12345\r\n" 35101 "CSeq: 1 INVITE\r\n" 35102 "Contact: <sip:bob@example.org:5060>\r\n" 35103 "Content-Length: 0\r\n" 35106 "SIP/2.0 180 Ringing\r\n" 35107 "Via: SIP/2.0/TCP 127.0.0.1:5060;branch=[branch]\r\n" 35108 "From: sipp <sip:127.0.0.1:5061>;tag=12345\r\n" 35109 "To: <sip:bob@example.org:5060>\r\n" 35110 "Call-ID: 12345\r\n" 35111 "CSeq: 1 INVITE\r\n" 35112 "Contact: <sip:bob@example.org:5060>\r\n" 35113 "Content-Length: 0\r\n" 35119 char *multi_message_body[] = {
35120 "INVITE sip:bob@example.org SIP/2.0\r\n" 35121 "Via: SIP/2.0/TCP 127.0.0.1:5060;branch=[branch]\r\n" 35122 "From: sipp <sip:127.0.0.1:5061>;tag=12345\r\n" 35123 "To: <sip:bob@example.org:5060>\r\n" 35124 "Call-ID: 12345\r\n" 35125 "CSeq: 1 INVITE\r\n" 35126 "Contact: sip:127.0.0.1:5061\r\n" 35127 "Max-Forwards: 70\r\n" 35128 "Content-Type: application/sdp\r\n" 35129 "Content-Length: 130\r\n" 35132 "o=user1 53655765 2353687637 IN IP4 127.0.0.1\r\n" 35134 "c=IN IP4 127.0.0.1\r\n" 35136 "m=audio 10000 RTP/AVP 0\r\n" 35137 "a=rtpmap:0 PCMU/8000\r\n" 35138 "INVITE sip:bob@example.org SIP/2.0\r\n" 35139 "Via: SIP/2.0/TCP 127.0.0.1:5060;branch=[branch]\r\n" 35140 "From: sipp <sip:127.0.0.1:5061>;tag=12345\r\n" 35141 "To: <sip:bob@example.org:5060>\r\n" 35142 "Call-ID: 12345\r\n" 35143 "CSeq: 2 INVITE\r\n" 35144 "Contact: sip:127.0.0.1:5061\r\n" 35145 "Max-Forwards: 70\r\n" 35146 "Content-Type: application/sdp\r\n" 35147 "Content-Length: 130\r\n" 35150 "o=user1 53655765 2353687637 IN IP4 127.0.0.1\r\n" 35152 "c=IN IP4 127.0.0.1\r\n" 35154 "m=audio 10000 RTP/AVP 0\r\n" 35155 "a=rtpmap:0 PCMU/8000\r\n" 35157 char *multi_message_body_divided[] = {
35158 "INVITE sip:bob@example.org SIP/2.0\r\n" 35159 "Via: SIP/2.0/TCP 127.0.0.1:5060;branch=[branch]\r\n" 35160 "From: sipp <sip:127.0.0.1:5061>;tag=12345\r\n" 35161 "To: <sip:bob@example.org:5060>\r\n" 35162 "Call-ID: 12345\r\n" 35163 "CSeq: 1 INVITE\r\n" 35164 "Contact: sip:127.0.0.1:5061\r\n" 35165 "Max-Forwards: 70\r\n" 35166 "Content-Type: application/sdp\r\n" 35167 "Content-Length: 130\r\n" 35170 "o=user1 53655765 2353687637 IN IP4 127.0.0.1\r\n" 35172 "c=IN IP4 127.0.0.1\r\n" 35174 "m=audio 10000 RTP/AVP 0\r\n" 35175 "a=rtpmap:0 PCMU/8000\r\n",
35177 "INVITE sip:bob@example.org SIP/2.0\r\n" 35178 "Via: SIP/2.0/TCP 127.0.0.1:5060;branch=[branch]\r\n" 35179 "From: sipp <sip:127.0.0.1:5061>;tag=12345\r\n" 35180 "To: <sip:bob@example.org:5060>\r\n" 35181 "Call-ID: 12345\r\n" 35182 "CSeq: 2 INVITE\r\n" 35183 "Contact: sip:127.0.0.1:5061\r\n" 35184 "Max-Forwards: 70\r\n" 35185 "Content-Type: application/sdp\r\n" 35186 "Content-Length: 130\r\n" 35189 "o=user1 53655765 2353687637 IN IP4 127.0.0.1\r\n" 35191 "c=IN IP4 127.0.0.1\r\n" 35193 "m=audio 10000 RTP/AVP 0\r\n" 35194 "a=rtpmap:0 PCMU/8000\r\n" 35201 char *multi_message_in_fragments[] = {
35202 "SIP/2.0 100 Trying\r\n" 35203 "Via: SIP/2.0/TCP 127.0.0.1:5060;branch=[branch]\r\n" 35204 "From: sipp <sip:127.0.0.1:5061>;tag=12345\r\n" 35205 "To: <sip:bob@example.org:5060>\r\n" 35206 "Call-ID: 12345\r\n" 35210 "Contact: <sip:bob@example.org:5060>\r\n" 35211 "Content-Length: 0\r\n" 35213 "SIP/2.0 180 Ringing\r\n" 35214 "Via: SIP/2.0/TCP 127.0.0.1:5060;branch=[branch]\r\n" 35215 "From: sipp <sip:127.0.0.1:5061>;tag=12345\r\n" 35216 "To: <sip:bob@example.org:5060>\r\n" 35217 "Call-ID: 12345\r\n" 35218 "CSeq: 1 INVITE\r\n" 35219 "Contact: <sip:bob@example.org:5060>\r\n" 35220 "Content-Length: 0\r\n" 35227 char *compact[] = {
35228 "INVITE sip:bob@example.org SIP/2.0\r\n" 35229 "Via: SIP/2.0/TCP 127.0.0.1:5060;branch=[branch]\r\n" 35230 "From: sipp <sip:127.0.0.1:5061>;tag=12345\r\n" 35231 "To: <sip:bob@example.org:5060>\r\n" 35232 "Call-ID: 12345\r\n" 35233 "CSeq: 1 INVITE\r\n" 35234 "Contact: sip:127.0.0.1:5061\r\n" 35235 "Max-Forwards: 70\r\n" 35236 "Content-Type: application/sdp\r\n" 35240 "o=user1 53655765 2353687637 IN IP4 127.0.0.1\r\n" 35242 "c=IN IP4 127.0.0.1\r\n" 35244 "m=audio 10000 RTP/AVP 0\r\n" 35245 "a=rtpmap:0 PCMU/8000\r\n" 35252 "INVITE sip:bob@example.org SIP/2.0\r\n" 35253 "Via: SIP/2.0/TCP 127.0.0.1:5060;branch=[branch]\r\n" 35254 "From: sipp <sip:127.0.0.1:5061>;tag=12345\r\n" 35255 "To: <sip:bob@example.org:5060>\r\n" 35256 "Call-ID: 12345\r\n" 35257 "CSeq: 1 INVITE\r\n" 35258 "Contact: sip:127.0.0.1:5061\r\n" 35259 "Max-Forwards: 70\r\n" 35260 "Content-Type: application/sdp\r\n" 35261 "DisContent-Length: 0\r\n" 35262 "MalContent-Length: 60\r\n" 35263 "Content-Length:130\r\n" 35266 "o=user1 53655765 2353687637 IN IP4 127.0.0.1\r\n" 35268 "c=IN IP4 127.0.0.1\r\n" 35270 "m=audio 10000 RTP/AVP 0\r\n" 35271 "a=rtpmap:0 PCMU/8000\r\n" 35280 "INVITE sip:bob@example.org SIP/2.0\r\n" 35281 "Via: SIP/2.0/TCP 127.0.0.1:5060;branch=[branch]\r\n" 35282 "From: sipp <sip:127.0.0.1:5061>;tag=12345\r\n" 35283 "To: <sip:bob@example.org:5060>\r\n" 35284 "Call-ID: 12345\r\n" 35285 "CSeq: 1 INVITE\r\n" 35286 "Contact: sip:127.0.0.1:5061\r\n" 35287 "Max-Forwards: 70\r\n" 35288 "Content-Type: application/sdp\r\n" 35289 "Content-Length: \t\r\n" 35294 "o=user1 53655765 2353687637 IN IP4 127.0.0.1\r\n" 35296 "c=IN IP4 127.0.0.1\r\n" 35298 "m=audio 10000 RTP/AVP 0\r\n" 35299 "a=rtpmap:0 PCMU/8000\r\n" 35306 char *cl_in_body[] = {
35307 "INVITE sip:bob@example.org SIP/2.0\r\n" 35308 "Via: SIP/2.0/TCP 127.0.0.1:5060;branch=[branch]\r\n" 35309 "From: sipp <sip:127.0.0.1:5061>;tag=12345\r\n" 35310 "To: <sip:bob@example.org:5060>\r\n" 35311 "Call-ID: 12345\r\n" 35312 "CSeq: 1 INVITE\r\n" 35313 "Contact: sip:127.0.0.1:5061\r\n" 35314 "Max-Forwards: 70\r\n" 35315 "Content-Type: application/sdp\r\n" 35319 "Content-Length: 0\r\n" 35320 "o=user1 53655765 2353687637 IN IP4 127.0.0.1\r\n" 35322 "c=IN IP4 127.0.0.1\r\n" 35324 "m=audio 10000 RTP/AVP 0\r\n" 35325 "a=rtpmap:0 PCMU/8000\r\n" 35331 size_t fragment_count;
35334 const char *description;
35336 { normal,
ARRAY_LEN(normal), normal, 1,
"normal" },
35337 { fragmented,
ARRAY_LEN(fragmented), normal, 1,
"fragmented" },
35338 { fragmented_body,
ARRAY_LEN(fragmented_body), normal, 1,
"fragmented_body" },
35339 { multi_fragment,
ARRAY_LEN(multi_fragment), normal, 1,
"multi_fragment" },
35340 { multi_message,
ARRAY_LEN(multi_message), multi_message_divided, 2,
"multi_message" },
35341 { multi_message_body,
ARRAY_LEN(multi_message_body), multi_message_body_divided, 2,
"multi_message_body" },
35342 { multi_message_in_fragments,
ARRAY_LEN(multi_message_in_fragments), multi_message_divided, 2,
"multi_message_in_fragments" },
35343 { compact,
ARRAY_LEN(compact), compact, 1,
"compact" },
35344 { faux,
ARRAY_LEN(faux), faux, 1,
"faux" },
35345 { folded,
ARRAY_LEN(folded), folded, 1,
"folded" },
35346 { cl_in_body,
ARRAY_LEN(cl_in_body), cl_in_body, 1,
"cl_in_body" },
35353 info->name =
"sip_tcp_message_fragmentation";
35354 info->category =
"/main/sip/transport/";
35355 info->summary =
"SIP TCP message fragmentation test";
35356 info->description =
35357 "Tests reception of different TCP messages that have been fragmented or" 35358 "run together. This test mimicks the code that TCP reception uses.";
35364 ast_log(
LOG_WARNING,
"Not running test. Pedantic SIP checking is not enabled, so it is guaranteed to fail\n");
35373 int num_messages = 0;
35375 &overflow,
tests[i].expected, &num_messages,
test)) {
35380 if (num_messages !=
tests[i].num_expected) {
35382 "Expected %d but received %d\n",
tests[i].num_expected, num_messages);
35394 const char *start =
NULL;
35398 #define CHECK_RESULTS(in, expected_res, expected_start, expected_len) do { \ 35400 res = get_in_brackets_const(input, &start, &len); \ 35401 if ((expected_res) != res) { \ 35402 ast_test_status_update(test, "Unexpected result: %d != %d\n", expected_res, res); \ 35403 return AST_TEST_FAIL; \ 35405 if ((expected_start) != start) { \ 35406 const char *e = expected_start ? expected_start : "(null)"; \ 35407 const char *a = start ? start : "(null)"; \ 35408 ast_test_status_update(test, "Unexpected start: %s != %s\n", e, a); \ 35409 return AST_TEST_FAIL; \ 35411 if ((expected_len) != len) { \ 35412 ast_test_status_update(test, "Unexpected len: %d != %d\n", expected_len, len); \ 35413 return AST_TEST_FAIL; \ 35419 info->name = __func__;
35420 info->category =
"/channels/chan_sip/";
35421 info->summary =
"get_in_brackets_const test";
35422 info->description =
35423 "Tests the get_in_brackets_const function";
35433 CHECK_RESULTS(
"\"yes < really\" <test>", 0, input + 16, 4);
35435 CHECK_RESULTS(
"<sip:id1@10.10.10.10;lr>", 0, input + 1, 22);
35436 CHECK_RESULTS(
"<sip:id1@10.10.10.10;lr>, <sip:id1@10.10.10.20;lr>", 0, input + 1, 22);
35437 CHECK_RESULTS(
"<sip:id1,id2@10.10.10.10;lr>", 0, input + 1, 26);
35438 CHECK_RESULTS(
"<sip:id1@10., <sip:id2@10.10.10.10;lr>", 0, input + 1, 36);
35439 CHECK_RESULTS(
"\"quoted text\" <sip:dlg1@10.10.10.10;lr>", 0, input + 15, 23);
35448 .name =
"chan_sip",
35454 ast_log(
LOG_WARNING,
"chan_sip has no official maintainer and is deprecated. Migration to\n");
35455 ast_log(
LOG_WARNING,
"chan_pjsip is recommended. See guides at the Asterisk Wiki:\n");
35456 ast_log(
LOG_WARNING,
"https://wiki.asterisk.org/wiki/display/AST/Migrating+from+chan_sip+to+res_pjsip\n");
35457 ast_log(
LOG_WARNING,
"https://wiki.asterisk.org/wiki/display/AST/Configuring+res_pjsip\n");
35473 if (strcmp(type,
"FullyBooted")) {
35534 if (!peers || !peers_by_ip || !dialogs || !dialogs_needdestroy || !dialogs_rtpcheck
35573 if (!(bogus_peer =
temp_peer(
"(bogus_peer)"))) {
35582 ao2_t_ref(bogus_peer, -1,
"Module load is done with the bogus peer.");
35603 #ifdef TEST_FRAMEWORK 35619 #ifdef TEST_FRAMEWORK 35648 ast_log(
LOG_ERROR,
"Unable to initialize the SIP request and response parser\n");
35668 if (!sip_monitor_instances) {
35679 "ipaddr",
RQ_CHAR, INET6_ADDRSTRLEN - 1,
35713 struct timeval start;
35742 #ifdef TEST_FRAMEWORK 35764 if (sip_tcp_desc.
master) {
35767 if (sip_tls_desc.
master) {
35774 while ((th =
ao2_t_iterator_next(&i,
"iterate through tcp threads for 'sip show tcp'"))) {
35777 pthread_kill(thread, SIGURG);
35778 ao2_t_ref(th, -1,
"decrement ref from iterator");
35787 ao2_t_ref(p, -1,
"toss dialog ptr from iterator_next");
35795 pthread_cancel(th);
35796 pthread_kill(th, SIGURG);
35798 pthread_join(th,
NULL);
35818 ao2_t_ref(mwi, -1,
"unload_module iter");
35827 ao2_t_ref(p, -1,
"throw away iterator result");
35850 ast_debug(2,
"TCP/TLS thread container did not become empty :(\n");
35881 ao2_t_cleanup(dialogs_needdestroy,
"unref dialogs_needdestroy");
35884 ao2_t_cleanup(sip_monitor_instances,
"unref the sip_monitor_instances table");
35902 if (notify_types) {
35904 notify_types =
NULL;
35923 .unload = unload_module,
35926 .requires =
"ccss,dnsmgr,udptl",
35927 .optional_modules =
"res_crypto,res_http_websocket",
void ast_iostream_set_exclusive_input(struct ast_iostream *stream, int exclusive_input)
Set the iostream if it can exclusively depend upon the set timeouts.
static char * ast_sockaddr_stringify_addr(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only.
int ast_io_wait(struct io_context *ioc, int howlong)
Waits for IO.
static const struct epa_static_data cc_epa_static_data
static void on_dns_update_peer(struct ast_sockaddr *old, struct ast_sockaddr *new, void *data)
#define check_request_transport(peer, tmpl)
generic function for determining if a correct transport is being used to contact a peer ...
static struct ao2_container * dialogs
void ast_uri_decode(char *s, struct ast_flags spec)
Decode URI, URN, URL (overwrite string)
#define ao2_t_ref(o, delta, tag)
Reference/unreference an object and return the old refcount.
void sip_dialplan_function_register_tests(void)
SIP test registration.
void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, struct ast_format_cap *astformats, int *nonastformats)
Retrieve all formats that were found.
struct sip_registry * reg
const char * sip_get_header(const struct sip_request *req, const char *name)
Get header from SIP request.
static struct ao2_container * threadt
The table of TCP threads.
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
int AST_OPTIONAL_API_NAME() ast_websocket_read(struct ast_websocket *session, char **payload, uint64_t *payload_len, enum ast_websocket_opcode *opcode, int *fragmented)
static struct ast_tcptls_session_args sip_tls_desc
The TCP/TLS server definition.
static const char * trust_id_outbound2str(int mode)
static int esc_cmp_fn(void *obj, void *arg, int flags)
static int transmit_request_with_auth(struct sip_pvt *p, int sipmethod, uint32_t seqno, enum xmittype reliable, int newbranch)
Transmit SIP request, auth added.
static int transmit_info_with_digit(struct sip_pvt *p, const char digit, unsigned int duration)
Send SIP INFO dtmf message, see Cisco documentation on cisco.com.
#define AST_CAUSE_PROTOCOL_ERROR
#define SIP_PAGE3_ICE_SUPPORT
struct ast_variable * ast_load_realtime(const char *family,...) attribute_sentinel
int ast_cc_monitor_failed(int core_id, const char *const monitor_name, const char *const debug,...)
Indicate that a failure has occurred on a specific monitor.
#define DEFAULT_RECORD_FEATURE
#define SIP_PAGE2_FAX_DETECT_CNG
enum sip_publish_type publish_type
int ast_cc_agent_register(const struct ast_cc_agent_callbacks *callbacks)
Register a set of agent callbacks with the core.
#define ast_string_field_ptr_set(x, ptr, data)
Set a field to a simple string value.
struct ast_variable * next
struct ast_format_cap * peercaps
#define AST_THREADSTORAGE(name)
Define a thread storage variable.
sip packet - raw format for outbound packets that are sent or scheduled for transmission Packets are ...
static unsigned int global_cos_video
#define SIP_PAGE3_RTCP_MUX
int ast_queue_hangup(struct ast_channel *chan)
Queue a hangup frame.
unsigned long long ast_group_t
#define DEFAULT_MAX_CALL_BITRATE
static int global_shrinkcallerid
int ast_rtp_instance_activate(struct ast_rtp_instance *instance)
Indicate to the RTP engine that packets are now expected to be sent/received on the RTP instance...
structure for secure RTP audio
struct ast_sched_context * sched
static void destroy_association(struct sip_peer *peer)
Remove registration data from realtime database or AST/DB when registration expires.
static int reload(void)
Part of Asterisk module interface.
Struct containing info for an AMI event to send out.
static void add_dtls_to_sdp(struct ast_rtp_instance *instance, struct ast_str **a_buf)
Add DTLS attributes to SDP.
struct sockaddr_storage ss
Information needed to identify an endpoint in a call.
int ast_set_cc_agent_policy(struct ast_cc_config_params *config, enum ast_cc_agent_policies value)
Set the cc_agent_policy.
static unsigned int global_tos_text
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
static char accountcode[AST_MAX_ACCOUNT_CODE]
void ast_channel_pickupgroup_set(struct ast_channel *chan, ast_group_t value)
int presentation
Q.931 encoded presentation-indicator encoded field.
struct ast_cc_config_params * cc_params
int ast_get_hint(char *hint, int hintsize, char *name, int namesize, struct ast_channel *c, const char *context, const char *exten)
If an extension hint exists, return non-zero.
void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani)
Set caller ID number, name and ANI and generate AMI event.
struct ast_dnsmgr_entry * dnsmgr
int ast_extension_state_add_destroy_extended(const char *context, const char *exten, ast_state_cb_type change_cb, ast_state_cb_destroy_type destroy_cb, void *data)
Add watcher for extended extension states with destructor.
#define SIP_PAGE2_TRUST_ID_OUTBOUND_NO
void ast_sip_api_provider_unregister(void)
Unregister a SIP API provider.
#define ast_channel_lock(chan)
static char mohinterpret[MAX_MUSICCLASS]
static int copy_via_headers(struct sip_pvt *p, struct sip_request *req, const struct sip_request *orig, const char *field)
Copy SIP VIA Headers from the request to the response.
int ast_rtp_dtls_cfg_parse(struct ast_rtp_dtls_cfg *dtls_cfg, const char *name, const char *value)
Parse DTLS related configuration options.
const char * last_provisional
struct ast_frame * ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp, struct ast_frame *inf)
Return AST_FRAME_NULL frames when there is silence, AST_FRAME_BUSY on busies, and call progress...
static char exten[AST_MAX_EXTENSION]
static void handle_response_message(struct sip_pvt *p, int resp, const char *rest, struct sip_request *req, uint32_t seqno)
Main Channel structure associated with a channel.
void sip_route_process_header(struct sip_route *route, const char *header, int inserthead)
Add routes from header.
struct ast_party_dialed::@246 number
Dialed/Called number.
static int dialog_checkrtp_cb(void *dialogobj, void *arg, int flags)
Check RTP Timeout on dialogs.
#define AST_CLI_DEFINE(fn, txt,...)
static int uas_sips_contact(struct sip_request *req)
Determine if, as a UAS, we need to use a SIPS Contact.
struct ast_namedgroups * named_pickupgroups
ast_device_state
Device States.
static uint16_t externtcpport
#define DEFAULT_PARKINGLOT
The default parking lot.
static int process_sdp_a_ice(const char *a, struct sip_pvt *p, struct ast_rtp_instance *instance, int rtcp_mux)
int ast_msg_set_tech(struct ast_msg *msg, const char *fmt,...)
Set the technology associated with this message.
const char * type
Type of monitor the callbacks belong to.
char * str
Subscriber phone number (Malloced)
int ast_rtp_red_init(struct ast_rtp_instance *instance, int buffer_time, int *payloads, int generations)
Initialize RED support on an RTP instance.
ssize_t ast_sendto(int sockfd, const void *buf, size_t len, int flags, const struct ast_sockaddr *dest_addr)
Wrapper around sendto(2) that uses ast_sockaddr.
static char * sip_do_debug_peer(int fd, const char *arg)
Turn on SIP debugging for a given peer.
void ast_enable_packet_fragmentation(int sock)
Disable PMTU discovery on a socket.
static char * sip_show_user(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Show one user in detail.
#define ao2_t_cleanup(obj, tag)
static void destroy_msg_headers(struct sip_pvt *pvt)
#define SIP_PAGE2_ALLOWSUBSCRIBE
static int mock_tcp_loop(char *fragments[], size_t num_fragments, struct ast_str **overflow, char **messages, int *num_messages, struct ast_test *test)
Imitation TCP reception loop.
void ast_cc_agent_unregister(const struct ast_cc_agent_callbacks *callbacks)
Unregister a set of agent callbacks with the core.
static struct ast_variable * add_var(const char *buf, struct ast_variable *list)
implement the setvar config line
const ast_string_field tel_phone_context
static void receive_message(struct sip_pvt *p, struct sip_request *req, struct ast_sockaddr *addr, const char *e)
Receive SIP MESSAGE method messages.
int(* set_configuration)(struct ast_rtp_instance *instance, const struct ast_rtp_dtls_cfg *dtls_cfg)
#define AST_LIST_LOCK(head)
Locks a list.
struct ast_format_cap * prefcaps
static const char * sip_reason_code_to_str(struct ast_party_redirecting_reason *reason)
enum subscriptiontype subscribed
void sip_route_copy(struct sip_route *dst, const struct sip_route *src)
copy route-set
int ast_sipinfo_send(struct ast_channel *chan, struct ast_variable *headers, const char *content_type, const char *content, const char *useragent_filter)
Send a customized SIP INFO request.
static int construct_pidf_body(enum sip_cc_publish_state state, char *pidf_body, size_t size, const char *presentity)
static void send_check_user_failure_response(struct sip_pvt *p, struct sip_request *req, int res, enum xmittype reliable)
static struct ast_ha * localaddr
List of local networks We store "localnet" addresses from the config file into an access list...
static const struct _map_x_s trust_id_outboundstr[]
static int expire_register(const void *data)
Expire registration of SIP peer.
static struct sip_proxy * proxy_from_config(const char *proxy, int sipconf_lineno, struct sip_proxy *dest)
Parse proxy string and return an ao2_alloc'd proxy. If dest is non-NULL, no allocation is performed a...
static int get_rpid(struct sip_pvt *p, struct sip_request *oreq)
Get name, number and presentation from remote party id header, returns true if a valid header was fou...
static void dialog_clean_rtp(struct sip_pvt *p)
Asterisk locking-related definitions:
static int transmit_response_with_sip_etag(struct sip_pvt *p, const char *msg, const struct sip_request *req, struct sip_esc_entry *esc_entry, int need_new_etag)
void astman_append(struct mansession *s, const char *fmt,...)
static int pidf_validate_tuple(struct ast_xml_node *tuple_node)
#define SIP_PAGE2_CONNECTLINEUPDATE_PEND
static int sipinfo_send(struct ast_channel *chan, struct ast_variable *headers, const char *content_type, const char *content, const char *useragent_filter)
Asterisk main include file. File version handling, generic pbx functions.
int ast_shutting_down(void)
static int local_attended_transfer(struct sip_pvt *transferer, struct ast_channel *transferer_chan, uint32_t seqno, int *nounlock)
Find all call legs and bridge transferee with target called from handle_request_refer.
Generate security events in the SIP channel.
static int __start_t38_abort_timer(const void *data)
void ast_rtp_instance_available_formats(struct ast_rtp_instance *instance, struct ast_format_cap *to_endpoint, struct ast_format_cap *to_asterisk, struct ast_format_cap *result)
Request the formats that can be transcoded.
static char * sip_show_mwi(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
enum ast_transfer_result ast_bridge_transfer_attended(struct ast_channel *to_transferee, struct ast_channel *to_transfer_target)
Attended transfer.
static int sip_cc_monitor_request_cc(struct ast_cc_monitor *monitor, int *available_timer_id)
static struct sip_esc_entry * get_esc_entry(const char *entity_tag, struct event_state_compositor *esc)
static void set_ice_components(struct sip_pvt *p, struct ast_rtp_instance *instance, int remote_rtcp_mux)
const ast_string_field realm
char * get_in_brackets(char *tmp)
Pick out text in brackets from character string.
struct sip_proxy * outboundproxy
void __sip_pretend_ack(struct sip_pvt *p)
Pretend to ack all packets called with p locked.
unsigned int allowed_methods
#define SIP_PAGE2_FAX_DETECT_BOTH
const char * presence_message
The Event State Compositors.
struct ast_features_pickup_config * ast_get_chan_features_pickup_config(struct ast_channel *chan)
Get the pickup configuration options for a channel.
void free_via(struct sip_via *v)
char * str
Subscriber phone number (Malloced)
char chan_name[AST_CHANNEL_NAME]
char original_callid[SIPBUFSIZE]
static struct ast_frame * sip_rtp_read(struct ast_channel *ast, struct sip_pvt *p, int *faxdetect)
Read RTP from network.
invitestates
States for the INVITE transaction, not the dialog.
static void sip_set_default_format_capabilities(struct ast_format_cap *cap)
static void start_t38_abort_timer(struct sip_pvt *pvt)
static char * ast_sockaddr_stringify_addr_remote(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only.
static char parkinglot[AST_MAX_CONTEXT]
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame without payload.
#define DEFAULT_MAX_FORWARDS
#define SIP_PAGE2_ALLOWOVERLAP_NO
int64_t sessionversion_remote
static struct ast_tls_config default_tls_cfg
Default TLS connection configuration.
static const int DEFAULT_PUBLISH_EXPIRES
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
static int dialog_initialize_dtls_srtp(const struct sip_pvt *dialog, struct ast_rtp_instance *rtp, struct ast_sdp_srtp **srtp)
Initialize DTLS-SRTP support on an RTP instance.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
struct sip_peer * sip_find_peer(const char *peer, struct ast_sockaddr *addr, int realtime, int which_objects, int devstate_only, int transport)
Locate device by name or ip address.
static const char * find_full_alias(const char *name, const char *_default)
Find full SIP alias.
enum notifycid_setting notifycid
int ast_rtp_codecs_payload_replace_format(struct ast_rtp_codecs *codecs, int payload, struct ast_format *format)
Update the format associated with a tx payload type in a codecs structure.
static int sip_sipredirect(struct sip_pvt *p, const char *dest)
Transfer call before connect with a 302 redirect.
struct ast_party_id ast_channel_redirecting_effective_from(struct ast_channel *chan)
const ast_string_field hostname
#define PROVIS_KEEPALIVE_TIMEOUT
int matchexternaddrlocally
static char * complete_sip_show_user(const char *line, const char *word, int pos, int state)
Support routine for 'sip show user' CLI.
static int sip_refer_alloc(struct sip_pvt *p)
Allocate SIP refer structure.
static int func_check_sipdomain(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
Dial plan function to check if domain is local.
void ast_rtp_instance_set_channel_id(struct ast_rtp_instance *instance, const char *uniqueid)
Set the channel that owns this RTP instance.
static void handle_response_subscribe(struct sip_pvt *p, int resp, const char *rest, struct sip_request *req, uint32_t seqno)
int ast_callerid_split(const char *src, char *name, int namelen, char *num, int numlen)
static void append_history_full(struct sip_pvt *p, const char *fmt,...)
Append to SIP dialog history with arg list.
enum sip_auth_type auth_type
#define ast_channel_alloc_with_endpoint(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag, endpoint,...)
static struct ast_tone_zone * ast_tone_zone_unref(struct ast_tone_zone *tz)
Release a reference to an ast_tone_zone.
static int extensionstate_update(const char *context, const char *exten, struct state_notify_data *data, struct sip_pvt *p, int force)
Callback for the devicestate notification (SUBSCRIBE) support subsystem.
static int default_keepalive
static void get_realm(struct sip_pvt *p, const struct sip_request *req)
Choose realm based on From header and then To header or use globaly configured realm. Realm from From/To header should be listed among served domains in config file: domain=...
int ast_cc_failed(int core_id, const char *const debug,...)
Indicate failure has occurred.
char * ast_get_encoded_str(const char *stream, char *result, size_t result_len)
Decode a stream of encoded control or extended ASCII characters.
const ast_string_field language
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
const struct epa_static_data * static_data
static const struct sip_reasons sip_reason_table[]
const ast_string_field parkinglot
static void stop_retrans_pkt(struct sip_pkt *pkt)
static int sip_monitor_instance_cmp_fn(void *obj, void *arg, int flags)
Structure to store route information.
void ast_udptl_set_local_max_ifp(struct ast_udptl *udptl, unsigned int max_ifp)
void ast_tcptls_server_start(struct ast_tcptls_session_args *desc)
This is a generic (re)start routine for a TCP server, which does the socket/bind/listen and starts a ...
static int find_by_notify_uri_helper(void *obj, void *arg, int flags)
static unsigned int global_cos_text
static void build_via(struct sip_pvt *p)
Build a Via header for a request.
void ast_ssl_teardown(struct ast_tls_config *cfg)
free resources used by an SSL server
const ast_string_field mohsuggest
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
channelreloadreason
Channel reload reasons for manager events at load or reload of configuration.
int ast_rtp_instance_dtmf_mode_set(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode)
Set the DTMF mode that should be used.
int AST_OPTIONAL_API_NAME() ast_websocket_is_secure(struct ast_websocket *session)
static int global_qualify_gap
const ast_string_field mwi_from
Channels have this property if they can accept input with jitter; i.e. most VoIP channels.
void ast_cc_config_params_destroy(struct ast_cc_config_params *params)
Free memory from CCSS configuration params.
static int transmit_refer(struct sip_pvt *p, const char *dest)
Transmit SIP REFER message (initiated by the transfer() dialplan application.
static char * sip_do_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Turn on SIP debugging (CLI command)
void ast_rtp_instance_change_source(struct ast_rtp_instance *instance)
Indicate a new source of audio has dropped in and the ssrc should change.
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
static int sip_tcptls_read(struct sip_request *req, struct ast_tcptls_session_instance *tcptls_session, int authenticated, time_t start)
Read SIP request or response from a TCP/TLS connection.
void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
static unsigned int global_tos_audio
static int __update_provisional_keepalive(const void *data)
int ast_msg_set_context(struct ast_msg *msg, const char *fmt,...)
Set the dialplan context for this message.
#define SIP_PAGE2_STATECHANGEQUEUE
#define ao2_t_alloc(data_size, destructor_fn, debug_msg)
static int process_sdp_a_sendonly(const char *a, int *sendonly)
static const struct _map_x_s strefresher_params[]
const char *(* get_password)(struct ast_rtp_instance *instance)
static const char * get_sdp_iterate(int *start, struct sip_request *req, const char *name)
Lookup 'name' in the SDP starting at the 'start' line. Returns the matching line, and 'start' is upda...
int ast_sched_runq(struct ast_sched_context *con)
Runs the queue.
static struct ast_sockaddr debugaddr
int ast_ssl_setup(struct ast_tls_config *cfg)
Set up an SSL server.
static unsigned int dumphistory
int ast_rtp_instance_get_stats(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat)
Retrieve statistics about an RTP instance.
static struct ast_sockaddr rtpbindaddr
const char *(* get_fingerprint)(struct ast_rtp_instance *instance)
media_type
Media types generate different "dummy answers" for not accepting the offer of a media stream...
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
static const char * find_alias(const char *name, const char *_default)
Find compressed SIP alias.
static enum message_integrity check_message_integrity(struct ast_str **request, struct ast_str **overflow)
Check that a message received over TCP is a full message.
static struct ast_variable * get_insecure_variable_from_sippeers(const char *column, const char *value)
const ast_string_field engine
int ast_cc_get_current_core_id(struct ast_channel *chan)
Get the core id for the current call.
Asterisk version information.
struct ast_party_id id
Connected party ID.
static uint32_t keepalive
static struct ao2_container * peers
The peer list: Users, Peers and Friends.
A request to stop the tcp_handler thread.
int ast_find_ourip(struct ast_sockaddr *ourip, const struct ast_sockaddr *bindaddr, int family)
Find our IP address.
struct ast_rtp_dtls_cfg dtls_cfg
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
const ast_string_field username
void * ast_channel_tech_pvt(const struct ast_channel *chan)
#define AST_CAUSE_NORMAL_TEMPORARY_FAILURE
void * __ao2_find(struct ao2_container *c, const void *arg, enum search_flags flags, const char *tag, const char *file, int line, const char *func)
enum sipregistrystate regstate
#define ast_channel_unref(c)
Decrease channel reference count.
definition of a sip proxy server
static void sip_destroy_peer_fn(void *peer)
int ast_msg_set_body(struct ast_msg *msg, const char *fmt,...)
Set the 'body' text of a message (in UTF-8)
struct ast_endpoint * ast_endpoint_create(const char *tech, const char *resource)
Create an endpoint struct.
struct ast_rtp_instance * trtp
static const struct @131 sip_cc_notify_state_map[]
The arg parameter is a search key, but is not an object.
static struct _map_x_s autopeermodes[]
static struct sip_peer * _sip_show_peers_one(int fd, struct mansession *s, struct show_peers_context *cont, struct sip_peer *peer)
Emit informations for one peer during sip show peers command.
const char * ast_describe_caller_presentation(int data)
Convert caller ID pres value to explanatory string.
#define ast_set2_flag(p, value, flag)
static int add_sip_domain(const char *domain, const enum domain_mode mode, const char *context)
Add SIP domain to list of domains we are responsible for.
#define ast_test_flag(p, flag)
static void startup_event_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
Event callback which indicates we're fully booted.
struct ao2_container * dialogs_needdestroy
void sip_auth_headers(enum sip_auth_type code, char **header, char **respheader)
return the request and response header for a 401 or 407 code
#define AST_CAUSE_SWITCH_CONGESTION
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
const ast_string_field messagecontext
static const struct _map_x_s strefreshers[]
static int registry_cmp_cb(void *obj, void *arg, int flags)
#define AST_OPTION_DEVICE_NAME
int sip_parse_register_line(struct sip_registry *reg, int default_expiry, const char *value, int lineno)
Parse register=> line in sip.conf.
static const struct cfsip_methods sip_methods[]
static void publish_qualify_peer_done(const char *id, const char *peer)
struct ast_control_t38_parameters our_parms
struct stasis_topic * ast_security_topic(void)
A stasis_topic which publishes messages for security related issues.
Support for translation of data formats. translate.c.
static int transmit_response_with_retry_after(struct sip_pvt *p, const char *msg, const struct sip_request *req, const char *seconds)
Append Retry-After header field when transmitting response.
static void ast_sockaddr_copy(struct ast_sockaddr *dst, const struct ast_sockaddr *src)
Copies the data from one ast_sockaddr to another.
ssize_t ast_iostream_write(struct ast_iostream *stream, const void *buffer, size_t count)
Write data to an iostream.
#define DEFAULT_MWI_EXPIRY
const ast_string_field parkinglot
const char * ast_var_value(const struct ast_var_t *var)
static void initreqprep(struct sip_request *req, struct sip_pvt *p, int sipmethod, const char *const explicit_uri)
Initiate new SIP request to peer/user.
struct sip_peer * relatedpeer
There is new data to be sent out.
static void get_our_media_address(struct sip_pvt *p, int needvideo, int needtext, struct ast_sockaddr *addr, struct ast_sockaddr *vaddr, struct ast_sockaddr *taddr, struct ast_sockaddr *dest, struct ast_sockaddr *vdest, struct ast_sockaddr *tdest)
Set all IP media addresses for this call.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
struct ast_party_name name
Subscriber name.
#define DSP_DIGITMODE_DTMF
static int get_rdnis(struct sip_pvt *p, struct sip_request *oreq, char **name, char **number, int *reason, char **reason_str)
Get referring dnis.
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
static int transmit_publish(struct sip_epa_entry *epa_entry, enum sip_publish_type publish_type, const char *const explicit_uri)
#define SIP_PAGE2_CALL_ONHOLD_ONEDIR
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
static void add_route(struct sip_request *req, struct sip_route *route, int skip)
Add route header into request per learned route.
struct ast_set_party_redirecting update_redirecting
static int handle_cc_notify(struct sip_pvt *pvt, struct sip_request *req)
static struct ast_threadstorage check_auth_buf
static void stop_reinvite_retry(struct sip_pvt *pvt)
void ast_dsp_free(struct ast_dsp *dsp)
#define DSP_FEATURE_DIGIT_DETECT
int ast_extension_state_del(int id, ast_state_cb_type change_cb)
Deletes a state change watcher by ID.
enum subscriptiontype event
#define AST_CAUSE_UNALLOCATED
static int process_sdp_a_dtls(const char *a, struct sip_pvt *p, struct ast_rtp_instance *instance)
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
static struct ast_channel * sip_request_call(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *dest, int *cause)
PBX interface function -build SIP pvt structure SIP calls initiated by the PBX arrive here...
const char * ast_get_version(void)
Retrieve the Asterisk version string.
#define peer_in_destruction(peer)
static int get_address_family_filter(unsigned int transport)
Helper for dns resolution to filter by address family.
struct stasis_cache * ast_mwi_state_cache(void)
Backend cache for ast_mwi_topic_cached().
static const struct _map_x_s allowoverlapstr[]
static void * _sip_tcp_helper_thread(struct ast_tcptls_session_instance *tcptls_session)
SIP TCP thread management function This function reads from the socket, parses the packet into a requ...
void ast_channel_update_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
Indicate that the redirecting id has changed.
#define DEFAULT_TOS_VIDEO
static char * get_content_line(struct sip_request *req, char *name, char delimiter)
Get a specific line from the message content.
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
int ast_rtp_instance_get_timeout(struct ast_rtp_instance *instance)
Get the RTP timeout value.
int ast_queue_unhold(struct ast_channel *chan)
Queue an unhold frame.
#define ao2_t_global_obj_replace_unref(holder, obj, tag)
Replace an ao2 object in the global holder, throwing away any old object.
struct ast_channel_snapshot * snapshot
Convenient Signal Processing routines.
static void add_ice_to_sdp(struct ast_rtp_instance *instance, struct ast_str **a_buf)
Add ICE attributes to SDP.
#define SIP_PAGE2_FAX_DETECT
static void hold(struct ast_channel *chan)
Helper method to place a channel in a bridge on hold.
static ast_mutex_t monlock
Protect the monitoring thread, so only one process can kill or start it, and not when it's doing some...
struct ast_str * overflow_buf
static int handle_invite_replaces(struct sip_pvt *p, struct sip_request *req, int *nounlock, struct sip_pvt *replaces_pvt, struct ast_channel *replaces_chan)
Handle the transfer part of INVITE with a replaces: header,.
static int global_dynamic_exclude_static
const ast_string_field accountcode
const char * ast_xml_get_ns_href(struct ast_xml_ns *ns)
const char * ast_var_name(const struct ast_var_t *var)
void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format)
static int sip_check_authtimeout(time_t start)
Check if the authtimeout has expired.
static int check_sip_domain(const char *domain, char *context, size_t len)
check_sip_domain: Check if domain part of uri is local to our server
#define SIP_PAGE2_PREFERRED_CODEC
static enum check_auth_result check_peer_ok(struct sip_pvt *p, char *of, struct sip_request *req, int sipmethod, struct ast_sockaddr *addr, struct sip_peer **authpeer, enum xmittype reliable, char *calleridname, char *uri2)
Validate device authentication.
static void reg_source_db(struct sip_peer *peer)
Get registration details from Asterisk DB.
static unsigned int parse_allowed_methods(struct sip_request *req)
parse the Allow header to see what methods the endpoint we are communicating with allows...
static int get_cached_mwi(struct sip_peer *peer, int *new, int *old)
Get cached MWI info.
static void stop_provisional_keepalive(struct sip_pvt *pvt)
static void network_change_stasis_unsubscribe(void)
#define ast_set_flag(p, flag)
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
struct ast_rtp_codecs * ast_rtp_instance_get_codecs(struct ast_rtp_instance *instance)
Get the codecs structure of an RTP instance.
void astman_send_list_complete_start(struct mansession *s, const struct message *m, const char *event_name, int count)
Start the list complete event.
static struct sip_auth_container * authl
Authentication container for realm authentication.
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
int ast_cc_is_config_param(const char *const name)
Is this a CCSS configuration parameter?
descriptor for a cli entry.
static int transmit_invite(struct sip_pvt *p, int sipmethod, int sdp, int init, const char *const explicit_uri)
Build REFER/INVITE/OPTIONS/SUBSCRIBE message and transmit it.
struct ast_sdp_srtp * tsrtp
static void sip_threadinfo_destructor(void *obj)
const struct epa_static_data * static_data
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
#define AST_RTP_PT_LAST_STATIC
struct ast_cc_config_params * cc_params
static int realtime_peer_by_name(const char *const *name, struct ast_sockaddr *addr, const char *ipaddr, struct ast_variable **var, struct ast_variable **varregs)
const ast_string_field mohinterpret
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
#define ast_str_make_space(buf, new_len)
Support for DNS SRV records, used in to locate SIP services.
static int build_path(struct sip_pvt *p, struct sip_peer *peer, struct sip_request *req, const char *pathbuf)
Build route list from Path header RFC 3327 requires that the Path header contains SIP URIs with lr pa...
int64_t ast_tvdiff_sec(struct timeval end, struct timeval start)
Computes the difference (in seconds) between two struct timeval instances.
static int sip_call(struct ast_channel *ast, const char *dest, int timeout)
Initiate SIP call from PBX used from the dial() application.
static int sip_allow_rtp_remote(struct ast_channel *chan1, struct ast_rtp_instance *instance)
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
static int debug
Global debug status.
static char global_useragent[AST_MAX_EXTENSION]
static int __sip_reliable_xmit(struct sip_pvt *p, uint32_t seqno, int resp, struct ast_str *data, int fatal, int sipmethod)
static void check_via(struct sip_pvt *p, const struct sip_request *req)
check Via: header for hostname, port and rport request/answer
static char * sip_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
List global settings for the SIP channel.
#define DEFAULT_MIN_EXPIRY
const ast_string_field peername
transfermodes
Authorization scheme for call transfers.
static int __stop_retrans_pkt(const void *data)
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
static void dummy(char *unused,...)
#define ao2_callback(c, flags, cb_fn, arg)
#define AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN
int ast_jb_read_conf(struct ast_jb_conf *conf, const char *varname, const char *value)
Sets jitterbuffer configuration property.
int ast_unload_realtime(const char *family)
Release any resources cached for a realtime family.
#define CONFIG_STATUS_FILEINVALID
#define DEFAULT_TRANS_TIMEOUT
#define SIP_DEFER_BYE_ON_TRANSFER
static void acl_change_event_stasis_unsubscribe(void)
struct ast_msg * ast_msg_alloc(void)
Allocate a message.
static int unload_module(void)
PBX unload module API.
struct ast_dsp * ast_dsp_new(void)
Allocates a new dsp, assumes 8khz for internal sample rate.
static char * _sip_show_peers(int fd, int *total, struct mansession *s, const struct message *m, int argc, const char *argv[])
Execute sip show peers command.
static int global_rtptimeout
const char * service_string
static void add_expires(struct sip_request *req, int expires)
Add Expires header to SIP message.
static const char * sip_get_callid(struct ast_channel *chan)
Deliver SIP call ID for the call.
struct stasis_message_type * ast_network_change_type(void)
A stasis_message_type for network changes.
struct ast_tcptls_session_args * parent
#define DEFAULT_QUALIFYFREQ
static char * complete_sip_unregister(const char *line, const char *word, int pos, int state)
Support routine for 'sip unregister' CLI.
int ast_redirecting_reason_parse(const char *data)
Convert redirecting reason text code to value (used in config file parsing)
unsigned int disallowed_methods
struct ast_namedgroups * named_pickupgroups
int ast_cc_agent_caller_busy(int core_id, const char *const debug,...)
Indicate that the caller is busy.
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
static struct ast_rtp_glue sip_rtp_glue
static void sip_dump_history(struct sip_pvt *dialog)
Dump SIP history to debug log file at end of lifespan for SIP dialog.
enum ast_state_cb_update_reason reason
unsigned short needdestroy
#define AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED
static int pidf_validate_presence(struct ast_xml_doc *doc)
static void sip_get_codec(struct ast_channel *chan, struct ast_format_cap *result)
#define AST_CAUSE_FACILITY_REJECTED
int ast_rtp_instance_early_bridge(struct ast_channel *c0, struct ast_channel *c1)
Early bridge two channels that use RTP instances.
static struct ast_cli_entry cli_sip[]
SIP Cli commands definition.
#define AST_CAUSE_RECOVERY_ON_TIMER_EXPIRE
static void sip_alreadygone(struct sip_pvt *dialog)
Encapsulate setting of SIP_ALREADYGONE to be able to trace it with debugging.
struct ast_sockaddr redirip
int ast_check_realtime(const char *family)
Check if realtime engine is configured for family.
static int initialize_escs(void)
unsigned short outgoing_call
Structure for variables, used for configurations and for channel variables.
static int copy_header(struct sip_request *req, const struct sip_request *orig, const char *field)
Copy one header field from one request to another.
#define SIP_PAGE2_CALL_ONHOLD_INACTIVE
static int sip_is_xml_parsable(void)
static int find_sip_monitor_instance_by_suspension_entry(void *obj, void *arg, int flags)
static int method_match(enum sipmethod id, const char *name)
returns true if 'name' (with optional trailing whitespace) matches the sip method 'id'...
static char * sip_do_debug_ip(int fd, const char *arg)
Enable SIP Debugging for a single IP.
void sip_request_parser_register_tests(void)
register request parsing tests
char * ast_uri_encode(const char *string, char *outbuf, int buflen, struct ast_flags spec)
Turn text string to URI-encoded XX version.
int ast_cc_agent_status_response(int core_id, enum ast_device_state devstate)
Response with a caller's current status.
static struct ast_cc_agent * find_sip_cc_agent_by_subscribe_uri(const char *const uri)
int ast_rtp_instance_set_qos(struct ast_rtp_instance *instance, int tos, int cos, const char *desc)
Set QoS parameters on an RTP session.
static int add_supported(struct sip_pvt *pvt, struct sip_request *req)
Add "Supported" header to sip message. Since some options may be disabled in the config, the sip_pvt must be inspected to determine what is supported for this dialog.
int ast_msg_var_iterator_next(const struct ast_msg *msg, struct ast_msg_var_iterator *iter, const char **name, const char **value)
Get the next variable name and value that is set for sending outbound.
int ast_cc_monitor_request_acked(int core_id, const char *const debug,...)
Indicate that an outbound entity has accepted our CC request.
static enum channelreloadreason sip_reloadreason
struct stasis_subscription * ast_mwi_subscriber_subscription(struct ast_mwi_subscriber *sub)
Retrieve the stasis MWI topic subscription if available.
static int sip_debug_test_addr(const struct ast_sockaddr *addr)
See if we pass debug IP filter.
#define SIP_PAGE3_DIRECT_MEDIA_OUTGOING
static struct ast_threadstorage sip_transport_str_buf
int ast_rtp_instance_write(struct ast_rtp_instance *instance, struct ast_frame *frame)
Send a frame out over RTP.
static struct _map_x_s faxecmodes[]
void * __ao2_alloc(size_t data_size, ao2_destructor_fn destructor_fn, unsigned int options, const char *tag, const char *file, int line, const char *func) attribute_warn_unused_result
static void tcptls_packet_destructor(void *obj)
static unsigned int global_tos_video
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
#define ast_rtp_glue_register(glue)
static int sip_sendtext(struct ast_channel *ast, const char *text)
const char * sip_get_transport(enum ast_transport t)
Return transport as string.
const ast_string_field username
struct ast_set_party_id priv_orig
int ast_do_pickup(struct ast_channel *chan, struct ast_channel *target)
Pickup a call target.
#define DEFAULT_REGISTRATION_TIMEOUT
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
void ast_rtp_codecs_payloads_xover(struct ast_rtp_codecs *src, struct ast_rtp_codecs *dest, struct ast_rtp_instance *instance)
Crossover copy the tx payload mapping of src to the rx payload mapping of dest.
struct ast_sockaddr defaddr
const ast_string_field hostname
static int send_provisional_keepalive_with_sdp(const void *data)
static void enable_dsp_detect(struct sip_pvt *p)
static const struct cfsubscription_types subscription_types[]
struct sip_pvt * __sip_alloc(ast_string_field callid, struct ast_sockaddr *addr, int useglobal_nat, const int intended_method, struct sip_request *req, ast_callid logger_callid, const char *file, int line, const char *func)
Allocate sip_pvt structure, set defaults and link in the container. Returns a reference to the object...
int ast_sdp_crypto_process(struct ast_rtp_instance *rtp, struct ast_sdp_srtp *srtp, const char *attr)
Parse the a=crypto line from SDP and set appropriate values on the ast_sdp_crypto struct...
#define BOGUS_PEER_MD5SECRET
We can recognize the bogus peer by this invalid MD5 hash.
#define DEFAULT_COMPACTHEADERS
#define STASIS_MESSAGE_TYPE_CLEANUP(name)
Boiler-plate messaging macro for cleaning up message types.
static int peer_cmp_cb(void *obj, void *arg, int flags)
const ast_string_field theirprovtag
unsigned int ast_udptl_get_local_max_datagram(struct ast_udptl *udptl)
retrieves local_max_datagram.
static int handle_incoming(struct sip_pvt *p, struct sip_request *req, struct ast_sockaddr *addr, int *recount, int *nounlock)
Handle incoming SIP requests (methods)
enum ast_cc_service_type service
enum ast_control_t38 request_response
struct ast_namedgroups * named_callgroups
static int sip_offer_timer_expire(const void *data)
const char *const name
Name of this message technology.
const ast_string_field opaque
#define AST_TEST_REGISTER(cb)
void * ast_aoc_destroy_decoded(struct ast_aoc_decoded *decoded)
free an ast_aoc_decoded object
static int peer_markall_func(void *device, void *arg, int flags)
#define ao2_t_replace(dst, src, tag)
Replace one object reference with another cleaning up the original.
int auth_message_requests
static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, uint32_t seqno, int *nounlock)
struct ao2_container * sip_monitor_instances
int ast_sched_add_variable(struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data, int variable) attribute_warn_unused_result
Adds a scheduled event with rescheduling support.
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
int ast_cc_available_timer_expire(const void *data)
Scheduler callback for available timer expiration.
Structure to pass both assignedid values to channel drivers.
static struct ast_config * notify_types
static int auto_congest(const void *arg)
Scheduled congestion on a call. Only called by the scheduler, must return the reference when done...
Registrations with other SIP proxies.
int stasis_subscription_set_filter(struct stasis_subscription *subscription, enum stasis_subscription_message_filter filter)
Set the message type filtering level on a subscription.
#define ao2_t_global_obj_release(holder, tag)
Release the ao2 object held in the global holder.
enum ast_acl_sense ast_apply_ha(const struct ast_ha *ha, const struct ast_sockaddr *addr)
Apply a set of rules to a given IP address.
struct ast_sockaddr ourip
struct stasis_message_type * ast_named_acl_change_type(void)
a stasis_message_type for changes against a named ACL or the set of all named ACLs ...
#define SIP_NAT_FORCE_RPORT
static int sip_hangup(struct ast_channel *ast)
sip_hangup: Hangup SIP call Part of PBX interface, called from ast_hangup
void ast_channel_callgroup_set(struct ast_channel *chan, ast_group_t value)
static const char * gettag(const struct sip_request *req, const char *header, char *tagbuf, int tagbufsize)
Get tag from packet.
static char default_language[MAX_LANGUAGE]
static int realtime_peer_by_addr(const char **name, struct ast_sockaddr *addr, const char *ipaddr, const char *callbackexten, struct ast_variable **var, struct ast_variable **varregs)
ast_channel_state
ast_channel states
struct sip_pvt::@173 msg_headers
#define ao2_t_link(container, obj, tag)
Add an object to a container.
const ast_string_field notify_uri
static const char * get_name_from_variable(const struct ast_variable *var)
char * str
Subscriber name (Malloced)
#define ao2_t_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn, tag)
Allocate and initialize a list container.
static struct ast_tcptls_session_args sip_tcp_desc
The TCP server definition.
int * ast_io_add(struct io_context *ioc, int fd, ast_io_cb callback, short events, void *data)
Adds an IO context.
#define ast_calloc_with_stringfields(n, type, size)
Allocate a structure with embedded stringfields in a single allocation.
struct ast_rtp_engine_ice * ast_rtp_instance_get_ice(struct ast_rtp_instance *instance)
Obtain a pointer to the ICE support present on an RTP instance.
#define AST_SCHED_DEL_UNREF(sched, id, refcall)
schedule task to get deleted and call unref function
check_auth_result
Authentication result from check_auth* functions.
static void set_insecure_flags(struct ast_flags *flags, const char *value, int lineno)
Parse insecure= setting in sip.conf and set flags according to setting.
static int init_req(struct sip_request *req, int sipmethod, const char *recip)
Initialize SIP request.
static int sip_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
sip_fixup: Fix up a channel: If a channel is consumed, this is called. Basically update any ->owner l...
static struct ast_sockaddr internip
our (internal) default address/port to put in SIP/SDP messages internip is initialized picking a suit...
#define DEFAULT_STORE_SIP_CAUSE
#define ast_log_dynamic_level(level,...)
Send a log message to a dynamically registered log level.
static const struct adsi_event events[]
struct ast_acl_list * directmediaacl
struct ast_format_cap * jointcaps
const char * ast_channel_amaflags2string(enum ama_flags flags)
Convert the enum representation of an AMA flag to a string representation.
#define SIP_PAGE2_CALL_ONHOLD_ACTIVE
static void state_notify_build_xml(struct state_notify_data *data, int full, const char *exten, const char *context, struct ast_str **tmp, struct sip_pvt *p, int subscribed, const char *mfrom, const char *mto)
Builds XML portion of NOTIFY messages for presence or dialog updates.
static char get_sdp_line(int *start, int stop, struct sip_request *req, const char **value)
Fetches the next valid SDP line between the 'start' line (inclusive) and the 'stop' line (exclusive)...
void(* add_remote_candidate)(struct ast_rtp_instance *instance, const struct ast_rtp_engine_ice_candidate *candidate)
void(* change_components)(struct ast_rtp_instance *instance, int num_components)
Used in the sip_show_peers functions to pass parameters.
static void sip_refer_destroy(struct sip_pvt *p)
Destroy SIP refer structure.
int ast_msg_tech_register(const struct ast_msg_tech *tech)
Register a message technology.
static char * ast_sockaddr_stringify_remote(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
static int sip_reg_timeout(const void *data)
Registration request timeout, register again.
static const char notify_config[]
ast_t38_state
Possible T38 states on channels.
static int * sipsock_read_id
static int get_also_info(struct sip_pvt *p, struct sip_request *oreq)
Call transfer support (old way, deprecated by the IETF)
int AST_OPTIONAL_API_NAME() ast_websocket_write_string(struct ast_websocket *ws, const char *buf)
static const char * get_srv_protocol(enum ast_transport t)
Return protocol string for srv dns query.
static int __sip_do_register(struct sip_registry *r)
Register with SIP proxy.
Background DNS update manager.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
ptrdiff_t header[SIP_MAX_HEADERS]
static int sip_poke_noanswer(const void *data)
React to lack of answer to Qualify poke.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
void ast_channel_named_pickupgroups_set(struct ast_channel *chan, struct ast_namedgroups *value)
static void parse_moved_contact(struct sip_pvt *p, struct sip_request *req, char **name, char **number, int set_call_forward)
Parse 302 Moved temporalily response.
#define CONTAINER_UNLINK(container, obj, tag)
Unlink the given object from the container and return TRUE if it was in the container.
#define ao2_t_unlink(container, obj, tag)
Remove an object from a container.
void(* stop)(struct ast_rtp_instance *instance)
char * ast_sdp_get_rtp_profile(unsigned int sdes_active, struct ast_rtp_instance *instance, unsigned int using_avpf, unsigned int force_avp)
Get the RTP profile in use by a media session.
unsigned short host_dynamic
static char default_fromdomain[AST_MAX_EXTENSION]
unsigned int ongoing_reinvite
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define DEFAULT_AUTH_OPTIONS
static int send_provisional_keepalive_full(struct sip_pvt *pvt, int with_sdp)
#define DEFAULT_MOHINTERPRET
int ast_iostream_get_fd(struct ast_iostream *stream)
Get an iostream's file descriptor.
unsigned short rt_fromcontact
static int temp_pvt_init(void *)
#define DEFAULT_LEGACY_USEROPTION_PARSING
static int match_and_cleanup_peer_sched(void *peerobj, void *arg, int flags)
static int copy(char *infile, char *outfile)
Utility function to copy a file.
static void acl_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
static void sip_set_owner(struct sip_pvt *p, struct ast_channel *chan)
Set the owning channel on the sip_pvt object.
static int do_proxy_auth(struct sip_pvt *p, struct sip_request *req, enum sip_auth_type code, int sipmethod, int init)
Add authentication on outbound SIP packet.
void ast_endpoint_set_state(struct ast_endpoint *endpoint, enum ast_endpoint_state state)
Updates the state of the given endpoint.
#define SIP_PAGE2_CALL_ONHOLD
arguments for the accepting thread
const char * ast_string_field
static struct @481 methods[]
#define MAX_HISTORY_ENTRIES
int(*const send_digit_begin)(struct ast_channel *chan, char digit)
Start sending a literal DTMF digit.
static int __stop_reinvite_retry(const void *data)
static void sip_websocket_callback(struct ast_websocket *session, struct ast_variable *parameters, struct ast_variable *headers)
SIP WebSocket connection handler.
unsigned int reqsipoptions
static int __update_provisional_keepalive_full(struct sip_pvt *pvt, int with_sdp)
void sip_config_parser_register_tests(void)
SIP test registration.
static int peer_dump_func(void *userobj, void *arg, int flags)
static int dialog_find_multiple(void *obj, void *arg, int flags)
Wrapper for an ast_acl linked list.
enum st_mode st_cached_mode
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
void ast_rtp_instance_set_timeout(struct ast_rtp_instance *instance, int timeout)
Set the RTP timeout value.
#define ao2_alloc_options(data_size, destructor_fn, options)
void ast_udptl_set_far_max_datagram(struct ast_udptl *udptl, unsigned int max_datagram)
sets far max datagram size. If max_datagram is = 0, the far max datagram size is set to a default val...
void * __ao2_callback(struct ao2_container *c, enum search_flags flags, ao2_callback_fn *cb_fn, void *arg, const char *tag, const char *file, int line, const char *func)
static void add_date(struct sip_request *req)
Add date header to SIP message.
#define ast_mutex_lock(a)
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
static int transmit_response_with_allow(struct sip_pvt *p, const char *msg, const struct sip_request *req, enum xmittype reliable)
Append Accept header, content length before transmitting response.
#define SIP_PAGE2_SUBSCRIBEMWIONLY
const ast_string_field replaces_callid_fromtag
static int show_chanstats_cb(struct sip_pvt *cur, struct __show_chan_arg *arg)
Callback for show_chanstats.
#define AST_OPTION_SECURE_MEDIA
static const int HASH_PEER_SIZE
static char * sip_qualify_peer(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Send an OPTIONS packet to a SIP peer.
static void ast_sip_ouraddrfor(const struct ast_sockaddr *them, struct ast_sockaddr *us, struct sip_pvt *p)
NAT fix - decide which IP address to use for Asterisk server?
int ast_channel_register(const struct ast_channel_tech *tech)
Register a channel technology (a new channel driver) Called by a channel module to register the kind ...
struct ast_flags flags[3]
static struct ast_custom_function sippeer_function
Structure to declare a dialplan function: SIPPEER.
static int sip_setoption(struct ast_channel *chan, int option, void *data, int datalen)
Set an option on a SIP dialog.
const ast_string_field context
static int match(struct ast_sockaddr *addr, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
#define ast_copy_flags(dest, src, flagz)
#define ast_str_alloca(init_len)
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
const ast_string_field mailbox
void ast_verbose(const char *fmt,...)
const ast_string_field peermd5secret
static int peer_iphash_cb(const void *obj, const int flags)
static int __start_register_timeout(const void *data)
#define ast_strdup(str)
A wrapper for strdup()
#define SIP_PAGE2_RFC2833_COMPENSATE
static unsigned int global_t38_maxdatagram
#define SIP_PAGE2_TRUST_ID_OUTBOUND
static char default_callerid[AST_MAX_EXTENSION]
void ast_rtp_codecs_set_framing(struct ast_rtp_codecs *codecs, unsigned int framing)
Set the framing used for a set of codecs.
static char * app_sipaddheader
struct varshead * ast_channel_varshead(struct ast_channel *chan)
static struct ast_threadstorage ts_temp_pvt
static int find_by_name(void *obj, void *arg, void *data, int flags)
ast_cc_agent_response_reason
#define AST_RTP_CODECS_NULL_INIT
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
const char * find_closing_quote(const char *start, const char *lim)
Locate closing quote in a string, skipping escaped quotes. optionally with a limit on the search...
int ast_str2tos(const char *value, unsigned int *tos)
Convert a string to the appropriate TOS value.
static int sip_sendhtml(struct ast_channel *chan, int subclass, const char *data, int datalen)
Send message with Access-URL header, if this is an HTML URL only!
const char * ast_state2str(enum ast_channel_state)
Gives the string form of a given channel state.
#define DEFAULT_TOS_AUDIO
sip_result
The result of a lot of functions.
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
const ast_string_field subscribecontext
void(* stop)(struct ast_rtp_instance *instance)
const ast_string_field subscribecontext
int ast_queue_cc_frame(struct ast_channel *chan, const char *const monitor_type, const char *const dialstring, enum ast_cc_service_type service, void *private_data)
Queue an AST_CONTROL_CC frame.
static void handle_response_publish(struct sip_pvt *p, int resp, const char *rest, struct sip_request *req, uint32_t seqno)
static int do_message_auth(struct sip_pvt *p, int resp, const char *rest, struct sip_request *req, uint32_t seqno)
const ast_string_field md5secret
static int sip_senddigit_end(struct ast_channel *ast, char digit, unsigned int duration)
Send DTMF character on SIP channel within one call, we're able to transmit in many methods simultaneo...
static ast_mutex_t authl_lock
Global authentication container protection while adjusting the references.
int sip_uri_cmp(const char *input1, const char *input2)
Compare two URIs as described in RFC 3261 Section 19.1.4.
sip_get_dest_result
Result from get_destination function.
void ast_udptl_destroy(struct ast_udptl *udptl)
int ast_sockaddr_cmp(const struct ast_sockaddr *a, const struct ast_sockaddr *b)
Compares two ast_sockaddr structures.
static int inbuf(struct baseio *bio, FILE *fi)
utility used by inchar(), for base_encode()
int ast_cc_agent_accept_request(int core_id, const char *const debug,...)
Accept inbound CC request.
#define sip_ref_peer(peer, tag)
static int func_headers_read2(struct ast_channel *chan, const char *function, char *data, struct ast_str **buf, ssize_t maxlen)
Read unique list of SIP headers (dialplan function)
#define AST_CAUSE_NO_USER_RESPONSE
struct ast_xml_node * ast_xml_get_root(struct ast_xml_doc *doc)
Get the document root node.
I/O Management (derived from Cheops-NG)
int provisional_keepalive_sched_id
void sip_route_clear(struct sip_route *route)
Free all routes in the list.
Definitions to aid in the use of thread local storage.
const ast_string_field vmexten
int ast_channel_move(struct ast_channel *dest, struct ast_channel *source)
Move a channel from its current location to a new location.
#define CHECK_RESULTS(in, expected_res, expected_start, expected_len)
static int default_maxcallbitrate
static int set_message_vars_from_req(struct ast_msg *msg, struct sip_request *req)
Out-of-call text message support.
void sip_report_failed_acl(const struct sip_pvt *p, const char *aclname)
void sip_dialplan_function_unregister_tests(void)
SIP test registration.
static enum ast_rtp_glue_result sip_get_vrtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)
static const struct @130 sip_cc_service_map[]
#define SIP_PAGE2_TRUST_ID_OUTBOUND_YES
Common implementation-independent jitterbuffer stuff.
int ast_dnsmgr_refresh(struct ast_dnsmgr_entry *entry)
Force a refresh of a dnsmgr entry.
void ast_cli(int fd, const char *fmt,...)
#define AST_PRES_ALLOWED_NETWORK_NUMBER
void ast_channel_zone_set(struct ast_channel *chan, struct ast_tone_zone *value)
const struct sip_esc_publish_callbacks * callbacks
char subscribe_uri[SIPBUFSIZE]
#define ast_cc_config_params_init()
Allocate and initialize an ast_cc_config_params structure.
const char * ast_aoc_get_currency_multiplier_decimal(struct ast_aoc_decoded *decoded)
get the currency multiplier for AOC-D and AOC-E messages in decimal format
void ast_update_use_count(void)
Notify when usecount has been changed.
static int input(yyscan_t yyscanner)
int ast_hint_presence_state(struct ast_channel *c, const char *context, const char *exten, char **subtype, char **message)
Uses hint and presence state callback to get the presence state of an extension.
static int peer_markall_autopeers_func(void *device, void *arg, int flags)
int ast_xml_escape(const char *string, char *outbuf, size_t buflen)
Escape reserved characters for use in XML.
#define AST_CAUSE_INVALID_NUMBER_FORMAT
static void transmit_fake_auth_response(struct sip_pvt *p, struct sip_request *req, enum xmittype reliable)
Send a fake 401 Unauthorized response when the administrator wants to hide the names of local devices...
int ast_cc_agent_recalling(int core_id, const char *const debug,...)
Tell the CC core that a caller is currently recalling.
#define SIP_PAGE2_RPID_IMMEDIATE
static int handle_request_notify(struct sip_pvt *p, struct sip_request *req, struct ast_sockaddr *addr, uint32_t seqno, const char *e)
Handle incoming notifications.
#define DEFAULT_ALLOWGUEST
int ast_is_shrinkable_phonenumber(const char *exten)
Check if a string consists only of digits and + # ( ) - . (meaning it can be cleaned with ast_shrink_...
static void disable_dsp_detect(struct sip_pvt *p)
int request_queue_sched_id
static int manager_sip_peer_status(struct mansession *s, const struct message *m)
Show SIP peers in the manager API.
int ast_unregister_application(const char *app)
Unregister an application.
static enum st_mode st_get_mode(struct sip_pvt *, int no_cached)
Get the session-timer mode.
Structure for an ICE candidate.
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
#define AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED
static int handle_cc_subscribe(struct sip_pvt *p, struct sip_request *req)
void ast_free_ptr(void *ptr)
free() wrapper
st_mode
Modes in which Asterisk can be configured to run SIP Session-Timers.
Socket address structure.
static char cid_num[AST_MAX_EXTENSION]
static int peer_status(struct sip_peer *peer, char *status, int statuslen)
static unsigned int default_transports
static int handle_sip_publish_modify(struct sip_pvt *p, struct sip_request *req, struct event_state_compositor *esc, const char *const etag, const int expires)
const char * ast_msg_get_body(const struct ast_msg *msg)
Get the body of a message.
static int sip_epa_register(const struct epa_static_data *static_data)
int code
enum AST_REDIRECTING_REASON value for redirection
sip global declaration header file
static struct ast_str * password
#define SIP_PAGE3_SNOM_AOC
static void build_localtag_registry(struct sip_registry *reg)
Build SIP From tag value for REGISTER.
int ast_bind(int sockfd, const struct ast_sockaddr *addr)
Wrapper around bind(2) that uses struct ast_sockaddr.
unsigned short transports
const ast_string_field language
#define AST_CLI_ONOFF(x)
return On or Off depending on the argument. This is used in many places in CLI command, having a function to generate this helps maintaining a consistent output (and possibly emitting the output in other languages, at some point).
static void make_our_tag(struct sip_pvt *pvt)
Make our SIP dialog tag.
#define ast_pthread_create_detached_background(a, b, c, d)
int ast_update_realtime(const char *family, const char *keyfield, const char *lookup,...) attribute_sentinel
Update realtime configuration.
#define ast_verb(level,...)
int ast_sockaddr_cmp_addr(const struct ast_sockaddr *a, const struct ast_sockaddr *b)
Compares the addresses of two ast_sockaddr structures.
static void build_route(struct sip_pvt *p, struct sip_request *req, int backwards, int resp)
Build route list from Record-Route header.
#define sip_pvt_unlock(x)
void ast_msg_var_iterator_destroy(struct ast_msg_var_iterator *iter)
Destroy a message variable iterator.
enum ast_rtp_dtls_hash(* get_fingerprint_hash)(struct ast_rtp_instance *instance)
char * ast_skip_nonblanks(const char *str)
Gets a pointer to first whitespace character in a string.
struct ast_dnsmgr_entry * dnsmgr
int ast_cc_is_recall(struct ast_channel *chan, int *core_id, const char *const monitor_type)
Decide if a call to a particular channel is a CC recall.
struct sip_proxy * outboundproxy
static struct stasis_subscription * network_change_sub
struct ast_manager_event_blob * ast_manager_event_blob_create(int event_flags, const char *manager_event, const char *extra_fields_fmt,...)
Construct a ast_manager_event_blob.
static int handle_sip_publish_initial(struct sip_pvt *p, struct sip_request *req, struct event_state_compositor *esc, const int expires)
static int sip_cc_agent_recall(struct ast_cc_agent *agent)
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
int jointnoncodeccapability
const ast_string_field fullcontact
#define SIP_TRANSPORT_STR_BUFSIZE
Size of the SIP transport buffer.
unsigned int ast_rtp_codecs_get_framing(struct ast_rtp_codecs *codecs)
Get the framing used for a set of codecs.
void(* handle_error)(struct sip_pvt *, const int resp, struct sip_request *, struct sip_epa_entry *)
ast_cc_monitor_policies
The various possibilities for cc_monitor_policy values.
struct ast_mwi_subscriber * event_sub
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
const ast_string_field sessionunique_remote
int ast_raw_answer(struct ast_channel *chan)
Answer a channel.
int ast_msg_set_to(struct ast_msg *msg, const char *fmt,...)
Set the 'to' URI of a message.
common ESC items for all event types
int ast_canmatch_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks for a valid matching extension.
static int update_call_counter(struct sip_pvt *fup, int event)
update_call_counter: Handle call_limit for SIP devices Setting a call-limit will cause calls above th...
static struct ao2_container * registry_list
The register list: Other SIP proxies we register with and receive calls from.
#define ast_publish_mwi_state(mailbox, context, new_msgs, old_msgs)
Publish a MWI state update via stasis.
const ast_string_field nonce
enum ast_rtp_dtls_setup(* get_setup)(struct ast_rtp_instance *instance)
static int resp_needs_contact(const char *msg, enum sipmethod method)
Test if this response needs a contact header.
#define DEFAULT_REGEXTENONQUALIFY
int ast_callid_threadassoc_remove(void)
Removes callid from thread storage of the calling thread.
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
const ast_string_field fromuser
static int manager_sip_show_peer(struct mansession *s, const struct message *m)
Show SIP peers in the manager API.
struct ast_frame_subclass subclass
static const char * stmode2str(enum st_mode m)
static const char * allowoverlap2str(int mode) attribute_const
Convert AllowOverlap setting to printable string.
struct ast_variable * chanvars
static struct ao2_container * peers_by_ip
static void add_noncodec_to_sdp(const struct sip_pvt *p, int format, struct ast_str **m_buf, struct ast_str **a_buf, int debug)
Add RFC 2833 DTMF offer to SDP.
enum ast_t38_ec_modes ast_udptl_get_error_correction_scheme(const struct ast_udptl *udptl)
struct sip_invite_param * options
static int sip_reinvite_retry(const void *data)
Reset the NEEDREINVITE flag after waiting when we get 491 on a Re-invite to avoid race conditions bet...
domain_mode
Modes for SIP domain handling in the PBX.
ast_callid ast_read_threadstorage_callid(void)
extracts the callerid from the thread
const esc_publish_callback modify_handler
const ast_string_field qop
Insert objects at the beginning of the container. (Otherwise it is the opposite; insert at the end...
static int notify_uri(void *obj)
const ast_string_field localtag
int ast_context_remove_extension(const char *context, const char *extension, int priority, const char *registrar)
Simply remove extension from context.
static int retrans_pkt(const void *data)
Retransmit SIP message if no answer.
#define SIP_INSECURE_PORT
static int manager_show_registry(struct mansession *s, const struct message *m)
Show SIP registrations in the manager API.
int hangup_sip2cause(int cause)
Convert SIP hangup causes to Asterisk hangup causes.
static char * transfermode2str(enum transfermodes mode) attribute_const
Convert transfer mode to text string.
char * ast_print_group(char *buf, int buflen, ast_group_t group)
Print call and pickup groups into buffer.
static void ast_sockaddr_setnull(struct ast_sockaddr *addr)
Sets address addr to null.
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
static void handle_response_notify(struct sip_pvt *p, int resp, const char *rest, struct sip_request *req, uint32_t seqno)
enum transfermodes allowtransfer
Blob of data associated with a channel.
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
Queue a hangup frame with hangupcause set.
#define AST_PRES_RESTRICTED
static struct ast_jb_conf default_jbconf
Global jitterbuffer configuration - by default, jb is disabled.
const char * comedia_string(struct ast_flags *flags)
Return a string describing the comedia value for the given flags.
const ast_string_field dialstring
int args
This gets set in ast_cli_register()
#define AST_MAX_MAILBOX_UNIQUEID
#define AST_OPTION_FORMAT_WRITE
char * ast_str_truncate(struct ast_str *buf, ssize_t len)
Truncates the enclosed string to the given length.
static const struct epa_static_data * find_static_data(const char *const event_package)
int ast_context_destroy_by_name(const char *context, const char *registrar)
Destroy a context by name.
const char * astman_get_header(const struct message *m, char *var)
Get header from mananger transaction.
struct ast_sdp_srtp * vsrtp
#define ast_module_unref(mod)
Release a reference to the module.
#define ast_strlen_zero(foo)
Structure for conversion between compressed SIP and "normal" SIP headers.
enum ast_cc_monitor_policies ast_get_cc_monitor_policy(struct ast_cc_config_params *config)
Get the cc_monitor_policy.
static const char * mbox(struct ast_vm_user *vmu, int id)
static void build_callid_registry(struct sip_registry *reg, const struct ast_sockaddr *ourip, const char *fromdomain)
Build SIP Call-ID value for a REGISTER transaction.
static int add_text(struct sip_request *req, struct sip_pvt *p)
Add text body to SIP message.
int AST_OPTIONAL_API_NAME() ast_websocket_fd(struct ast_websocket *session)
#define DEFAULT_AUTH_MESSAGE
#define DEFAULT_NOTIFYCID
const ast_string_field tohost
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
enum sip_cc_publish_state current_state
static void stop_session_timer(struct sip_pvt *p)
Session-Timers: Stop session timer.
#define DEFAULT_MATCHEXTERNADDRLOCALLY
struct ast_set_party_id from
static void cleanup_stale_contexts(char *new, char *old)
Destroy disused contexts between reloads Only used in reload_config so the code for regcontext doesn'...
#define SIP_PAGE3_FORCE_AVP
static int __stop_session_timer(const void *data)
static void add_msg_header(struct sip_pvt *pvt, const char *hdr_name, const char *hdr_value)
int get_in_brackets_const(const char *src, const char **start, int *length)
Get text in brackets on a const without copy.
char * ast_cli_complete(const char *word, const char *const choices[], int pos)
static unsigned int chan_idx
#define AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN
#define AST_RED_MAX_GENERATION
Structure to store Via information.
static int transmit_response_reliable(struct sip_pvt *p, const char *msg, const struct sip_request *req)
Transmit response, Make sure you get an ACK This is only used for responses to INVITEs, where we need to make sure we get an ACK.
static enum check_auth_result check_user_full(struct sip_pvt *p, struct sip_request *req, int sipmethod, const char *uri, enum xmittype reliable, struct ast_sockaddr *addr, struct sip_peer **authpeer)
Check if matching user or peer is defined Match user on From: user name and peer on IP/port This is u...
static int sip_devicestate(const char *data)
Part of PBX channel interface.
static int sip_get_cc_information(struct sip_request *req, char *subscribe_uri, size_t size, enum ast_cc_service_type *service)
static int __sip_scheddestroy(const void *data)
int AST_OPTIONAL_API_NAME() ast_websocket_add_protocol(const char *name, ast_websocket_callback callback)
#define ast_pthread_create_background(a, b, c, d)
static int allow_notify_user_presence(struct sip_pvt *p)
const char * ast_config_AST_SYSTEM_NAME
void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
#define SIP_PAGE2_USE_SRTP
static int sip_is_token(const char *str)
static void configure_rtcp(struct sip_pvt *p, struct ast_rtp_instance *instance, int which, int remote_rtcp_mux)
static void deinit_req(struct sip_request *req)
Deinitialize SIP response/request.
static int proxy_update(struct sip_proxy *proxy)
ssize_t ast_iostream_read(struct ast_iostream *stream, void *buffer, size_t count)
Read data from an iostream.
static const char * strefresherparam2str(enum st_refresher_param r)
void sip_digest_parser(char *c, struct digestkeys *keys)
Takes the digest response and parses it.
char default_record_off_feature[AST_FEATURE_MAX_LEN]
SSL * ast_iostream_get_ssl(struct ast_iostream *stream)
Get a pointer to an iostream's OpenSSL SSL structure.
static int ast_sockaddr_isnull(const struct ast_sockaddr *addr)
Checks if the ast_sockaddr is null. "null" in this sense essentially means uninitialized, or having a 0 length.
#define FROMDOMAIN_INVALID
static char used_context[AST_MAX_CONTEXT]
void ast_udptl_get_us(const struct ast_udptl *udptl, struct ast_sockaddr *us)
char zone[MAX_TONEZONE_COUNTRY]
unsigned int ast_get_ccbs_available_timer(struct ast_cc_config_params *config)
Get the ccbs_available_timer.
struct ast_str * sip_route_list(const struct sip_route *route, int formatcli, int skip)
Make the comma separated list of route hops.
enum ama_flags ast_channel_string2amaflag(const char *flag)
Convert a string to a detail record AMA flag.
const ast_string_field mohsuggest
long resync_threshold
Resynchronization threshold of the jitterbuffer implementation.
#define ast_sockaddr_port(addr)
Get the port number of a socket address.
void sip_config_parser_unregister_tests(void)
SIP test registration.
Custom localtime functions for multiple timezones.
const char * ast_xml_get_attribute(struct ast_xml_node *node, const char *attrname)
Get a node attribute by name.
#define DEFAULT_AUTHLIMIT
enum ast_rtp_ice_candidate_type type
internal representation of ACL entries In principle user applications would have no need for this...
int ast_callid_threadassoc_add(ast_callid callid)
Adds a known callid to thread storage of the calling thread.
void ast_xml_free_attr(const char *attribute)
Free an attribute returned by ast_xml_get_attribute()
enum transfermodes allowtransfer
void dialog_unlink_all(struct sip_pvt *dialog)
Unlink a dialog from the dialogs container, as well as any other places that it may be currently stor...
enum ast_rtp_dtls_connection(* get_connection)(struct ast_rtp_instance *instance)
static const struct _map_x_s insecurestr[]
static int process_sdp_a_rtcp_mux(const char *a, struct sip_pvt *p, int *requested)
const ast_string_field username
const ast_string_field authuser
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
#define SIP_PAGE2_RPORT_PRESENT
struct ast_party_id id
Caller party ID.
void ast_logger_unregister_level(const char *name)
Unregister a previously registered logger level.
static struct ast_custom_function sip_header_function
int ast_cc_monitor_register(const struct ast_cc_monitor_callbacks *callbacks)
Register a set of monitor callbacks with the core.
#define SIP_PAGE2_SYMMETRICRTP
static char * ast_sockaddr_stringify_port(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return a port only.
Configuration File Parser.
char default_subscribecontext[AST_MAX_CONTEXT]
#define DEFAULT_AUTHTIMEOUT
enum ast_extension_states exten_state
static const char * get_transport_pvt(struct sip_pvt *p)
Return transport of dialog.
static struct ast_sockaddr media_address
static struct ast_variable * realtime_peer_get_sippeer_helper(const char **name, struct ast_variable **varregs)
static int map_s_x(const struct _map_x_s *table, const char *s, int errorvalue)
map from a string to an integer value, case insensitive. If no match is found, return errorvalue...
static void deprecation_notice(void)
int __sip_semi_ack(struct sip_pvt *p, uint32_t seqno, int resp, int sipmethod)
Acks receipt of packet, keep it around (used for provisional responses)
static void extract_transferrer_headers(const char *prefix, struct ast_channel *peer, const struct sip_request *req)
static int transmit_response(struct sip_pvt *p, const char *msg, const struct sip_request *req)
Transmit response, no retransmits.
static int reload_config(enum channelreloadreason reason)
Re-read SIP.conf config file.
#define DSP_DIGITMODE_RELAXDTMF
int __ao2_ref(void *o, int delta, const char *tag, const char *file, int line, const char *func)
static void handle_response_info(struct sip_pvt *p, int resp, const char *rest, struct sip_request *req, uint32_t seqno)
struct ast_rtp_dtls_cfg dtls_cfg
static char mailbox[AST_MAX_MAILBOX_UNIQUEID]
struct ast_channel * causing_channel
int ast_get_time_t(const char *src, time_t *dst, time_t _default, int *consumed)
get values from config variables.
int __sip_ack(struct sip_pvt *p, uint32_t seqno, int resp, int sipmethod)
Acknowledges receipt of a packet and stops retransmission called with p locked.
char * ast_strip_quoted(char *s, const char *beg_quotes, const char *end_quotes)
Strip leading/trailing whitespace and quotes from a string.
static int reqprep(struct sip_request *req, struct sip_pvt *p, int sipmethod, uint32_t seqno, int newbranch)
Initialize a SIP request message (not the initial one in a dialog)
static void add_required_respheader(struct sip_request *req)
#define EVENT_FLAG_SYSTEM
struct ast_variable * ast_category_root(struct ast_config *config, char *cat)
returns the root ast_variable of a config
struct ast_websocket * ws_session
static void destroy_escs(void)
unsigned short alreadygone
const ast_string_field subscribe_uri
static void change_redirecting_information(struct sip_pvt *p, struct sip_request *req, struct ast_party_redirecting *redirecting, struct ast_set_party_redirecting *update_redirecting, int set_call_forward)
update redirecting information for a channel based on headers
int ast_ouraddrfor(const struct ast_sockaddr *them, struct ast_sockaddr *us)
Get our local IP address when contacting a remote host.
Definition of a thread that handles a socket.
static int get_refer_info(struct sip_pvt *transferer, struct sip_request *outgoing_req)
Call transfer support (the REFER method) Extracts Refer headers into pvt dialog structure.
#define ast_debug(level,...)
Log a DEBUG message.
struct stasis_message_type * ast_manager_get_generic_type(void)
Get the stasis_message_type for generic messages.
static int find_by_callid_helper(void *obj, void *arg, int flags)
#define STANDARD_TLS_PORT
Standard SIP TLS port from RFC 3261. DO NOT CHANGE THIS.
struct ast_bridge * ast_bridge_transfer_acquire_bridge(struct ast_channel *chan)
Acquire the channel's bridge for transfer purposes.
#define SIP_PROG_INBAND_YES
int ast_sockaddr_is_any(const struct ast_sockaddr *addr)
Determine if the address type is unspecified, or "any" address.
struct ast_namedgroups * named_callgroups
void(* handle_ok)(struct sip_pvt *, struct sip_request *, struct sip_epa_entry *)
static unsigned int t38_get_rate(enum ast_control_t38_rate rate)
Get Max T.38 Transmission rate from T38 capabilities.
struct sip_registry * registry
void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format)
static unsigned char global_refer_addheaders
#define sip_route_empty(route)
Check if route has no URI's.
struct sip_subscription_mwi * mwi
static int transmit_response_with_sdp(struct sip_pvt *p, const char *msg, const struct sip_request *req, enum xmittype reliable, int oldsdp, int rpid)
Used for 200 OK and 183 early media.
struct ast_format * ast_rtp_codecs_get_payload_format(struct ast_rtp_codecs *codecs, int payload)
Retrieve the actual ast_format stored on the codecs structure for a specific tx payload type...
static void set_destination(struct sip_pvt *p, const char *uri)
Set destination from SIP URI.
#define AST_CAUSE_NO_ROUTE_TRANSIT_NET
static const char * insecure2str(int mode) attribute_const
Convert Insecure setting to printable string.
void ast_rtp_instance_stop(struct ast_rtp_instance *instance)
Stop an RTP instance.
static int add_max_forwards(struct sip_pvt *dialog, struct sip_request *req)
Add 'Max-Forwards' header to SIP message.
static void sip_pvt_callid_set(struct sip_pvt *pvt, ast_callid callid)
struct ast_context * ast_context_find(const char *name)
Find a context.
Generic Advice of Charge encode and decode routines.
#define ast_config_load(filename, flags)
Load a config file.
static int process_sdp_a_audio(const char *a, struct sip_pvt *p, struct ast_rtp_codecs *newaudiortp, int *last_rtpmap_codec)
static const struct ast_msg_tech sip_msg_tech
unsigned int transcoding_mmr
const char * ast_transport2str(enum ast_transport transport)
Returns a string representation of an ast_transport.
#define AST_PRES_PROHIB_NETWORK_NUMBER
static int __dialog_unlink_sched_items(const void *data)
static void sip_queue_hangup_cause(struct sip_pvt *p, int cause)
static void do_cancel_destroy(struct sip_pvt *pvt)
struct ast_acl_list * ast_duplicate_acl_list(struct ast_acl_list *original)
Duplicates the contests of a list of lists of host access rules.
static int process_sdp_a_video(const char *a, struct sip_pvt *p, struct ast_rtp_codecs *newvideortp, int *last_rtpmap_codec)
void * ast_tcptls_server_root(void *)
int ast_get_srv(struct ast_channel *chan, char *host, int hostlen, int *port, const char *service)
Lookup entry in SRV records Returns 1 if found, 0 if not found, -1 on hangup.
static int set_address_from_contact(struct sip_pvt *pvt)
Change the other partys IP address based on given contact.
static int threadinfo_locate_cb(void *obj, void *arg, int flags)
struct ast_aoc_decoded * ast_aoc_decode(struct ast_aoc_encoded *encoded, size_t size, struct ast_channel *chan)
decodes an encoded aoc payload.
static int transmit_info_with_aoc(struct sip_pvt *p, struct ast_aoc_decoded *decoded)
Send SIP INFO advice of charge message.
int ast_devstate_changed(enum ast_device_state state, enum ast_devstate_cache cachable, const char *fmt,...)
Tells Asterisk the State for Device is changed.
static int __shutdown_mwi_subscription(const void *data)
int ast_sockaddr_split_hostport(char *str, char **host, char **port, int flags)
Splits a string into its host and port components.
struct ast_acl_list * acl
static struct sip_proxy * obproxy_get(struct sip_pvt *dialog, struct sip_peer *peer)
Get default outbound proxy or global proxy.
enum ast_transfer_result ast_bridge_transfer_blind(int is_external, struct ast_channel *transferer, const char *exten, const char *context, transfer_channel_cb new_channel_cb, void *user_data)
Blind transfer target to the extension and context provided.
char * ast_callerid_merge(char *buf, int bufsiz, const char *name, const char *num, const char *unknown)
#define DEFAULT_DOMAINSASREALM
unsigned int ast_get_ccnr_available_timer(struct ast_cc_config_params *config)
Get the ccnr_available_timer.
void ast_channel_queue_connected_line_update(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
Queue a connected line update frame on a channel.
int ast_bridge_impart(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap, struct ast_bridge_features *features, enum ast_bridge_impart_flags flags) attribute_warn_unused_result
Impart a channel to a bridge (non-blocking)
static char * sip_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI for show channels or subscriptions. This is a new-style CLI handler so a single function contains...
struct ast_party_id ani
Automatic Number Identification (ANI)
static void offered_media_list_destroy(struct sip_pvt *p)
Destroy SDP media offer list.
#define STANDARD_SIP_PORT
Standard SIP unsecure port for UDP and TCP from RFC 3261. DO NOT CHANGE THIS.
int ast_cc_agent_set_interfaces_chanvar(struct ast_channel *chan)
Set the first level CC_INTERFACES channel variable for a channel.
static int sip_standard_port(enum ast_transport type, int port)
Returns the port to use for this socket.
void ast_channel_rings_set(struct ast_channel *chan, int value)
int ast_realtime_require_field(const char *family,...) attribute_sentinel
Inform realtime what fields that may be stored.
const char * ast_rtp_lookup_mime_subtype2(const int asterisk_format, const struct ast_format *format, int code, enum ast_rtp_options options)
Retrieve mime subtype information on a payload.
const ast_string_field unsolicited_mailbox
#define AST_SCHED_DEL(sched, id)
Remove a scheduler entry.
void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force)
Set the source of the hangup in this channel and it's bridge.
Asterisk file paths, configured in asterisk.conf.
void io_context_destroy(struct io_context *ioc)
Destroys a context.
int ast_str_copy_string(struct ast_str **dst, struct ast_str *src)
static int sip_poke_peer_s(const void *data)
Poke peer (send qualify to check if peer is alive and well)
static const struct invstate2stringtable invitestate2string[]
void astman_send_list_complete_end(struct mansession *s)
End the list complete event.
#define DEFAULT_MOHSUGGEST
static void print_group(int fd, ast_group_t group, int crlf)
Print call group and pickup group.
static enum st_mode str2stmode(const char *s)
const ast_string_field refer_to_context
const char * presence_message
struct ast_sockaddr netmask
static void handle_response(struct sip_pvt *p, int resp, const char *rest, struct sip_request *req, uint32_t seqno)
Handle SIP response in dialogue.
static int global_store_sip_cause
SRTP and SDP Security descriptions.
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
const ast_string_field peersecret
static void network_change_stasis_subscribe(void)
#define ast_test_status_update(a, b, c...)
enum ast_presence_state presence_state
int ast_variable_list_replace(struct ast_variable **head, struct ast_variable *replacement)
Replace a variable in the given list with a new value.
A set of tones for a given locale.
struct sip_history_head * history
int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, int asterisk_format, struct ast_format *format, int code)
Retrieve a rx mapped payload type based on whether it is an Asterisk format and the code...
#define DEFAULT_ALLOW_EXT_DOM
int ast_sip_api_provider_register(const struct ast_sip_api_tech *provider)
Register a SIP API provider.
static struct ast_generator gen
void ast_dnsmgr_release(struct ast_dnsmgr_entry *entry)
Free a DNS manager entry.
void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value)
static int dialog_initialize_rtp(struct sip_pvt *dialog)
Initialize RTP portion of a dialog.
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
static struct event_state_compositor * get_esc(const char *const event_package)
int ast_setup_cc_recall_datastore(struct ast_channel *chan, const int core_id)
Set up a CC recall datastore on a channel.
void ast_channel_stage_snapshot_done(struct ast_channel *chan)
Clear flag to indicate channel snapshot is being staged, and publish snapshot.
int authentication_present
static int do_magic_pickup(struct ast_channel *channel, const char *extension, const char *context)
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
static enum sip_get_dest_result get_destination(struct sip_pvt *p, struct sip_request *oreq, int *cc_recall_core_id)
Find out who the call is for.
static int __start_reregister_timeout(const void *data)
#define SIP_PROG_INBAND_NO
struct ast_format_cap * caps
static int init_resp(struct sip_request *resp, const char *msg)
Initialize SIP response, based on SIP request.
static const struct _map_x_s dtmfstr[]
mapping between dtmf flags and strings
static char * sip_show_objects(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
List all allocated SIP Objects (realtime or static)
#define AST_PTHREADT_NULL
static void start_register_timeout(struct sip_registry *reg)
static const struct sip_esc_publish_callbacks cc_esc_publish_callbacks
static struct ast_mansession session
int allow_external_domains
char destination[SIPBUFSIZE]
void ast_msg_var_unref_current(struct ast_msg_var_iterator *iter)
Unref a message var from inside an iterator loop.
sip_auth_type
Authentication types - proxy or www authentication.
#define ast_poll(a, b, c)
#define EXPIRY_GUARD_SECS
static char * sip_show_history(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Show history details of one dialog.
struct sip_request initreq
static char * app_sipsendcustominfo
Data structure associated with a custom dialplan function.
#define AST_CAUSE_ANSWERED_ELSEWHERE
Access Control of various sorts.
static char default_zone[MAX_TONEZONE_COUNTRY]
static struct ao2_container * codecs
Registered codecs.
static char * sip_show_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Show details of one active dialog.
static void unlink_all_peers_from_tables(void)
static void ringing(struct ast_channel *chan)
Helper method to send a ringing indication to a channel in a bridge.
void(* set_fingerprint)(struct ast_rtp_instance *instance, enum ast_rtp_dtls_hash hash, const char *fingerprint)
static struct ast_threadstorage sip_content_buf
Global IO variables are now in a struct in order to be made threadsafe.
const ast_string_field messagecontext
static void cc_handle_publish_error(struct sip_pvt *pvt, const int resp, struct sip_request *req, struct sip_epa_entry *epa_entry)
static int initialize_udptl(struct sip_pvt *p)
static char * remove_uri_parameters(char *uri)
static const int HASH_DIALOG_SIZE
static char mohsuggest[MAX_MUSICCLASS]
#define DEFAULT_SEND_DIVERSION
static uint16_t externtlsport
#define AST_MAX_EXTENSION
static char * generate_random_string(char *buf, size_t size)
Generate 32 byte random string for callid's etc.
static int reply_digest(struct sip_pvt *p, struct sip_request *req, char *header, int sipmethod, char *digest, int digest_len)
reply to authentication for outbound registrations
static void restart_session_timer(struct sip_pvt *p)
Session-Timers: Restart session timer.
static char externhost[MAXHOSTNAMELEN]
static void copy_request(struct sip_request *dst, const struct sip_request *src)
copy SIP request (mostly used to save request for responses)
void AST_OPTIONAL_API_NAME() ast_websocket_ref(struct ast_websocket *session)
static int find_sdp(struct sip_request *req)
Determine whether a SIP message contains an SDP in its body.
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
#define AST_CAUSE_NORMAL_CLEARING
Scheduler Routines (derived from cheops)
#define AST_CAUSE_CHAN_NOT_IMPLEMENTED
static int ast_sockaddr_resolve_first(struct ast_sockaddr *addr, const char *name, int flag)
Return the first entry from ast_sockaddr_resolve filtered by family of binddaddr. ...
static int sip_notify_alloc(struct sip_pvt *p)
Allocate SIP refer structure.
static void sip_subscribe_mwi_destroy(void *data)
Destroy MWI subscription object.
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
#define ast_channel_cleanup(c)
Cleanup a channel reference.
structure to hold extensions
struct ast_sockaddr remote_address
static int sip_poke_peer_now(const void *data)
#define ao2_ref(o, delta)
void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format)
struct ast_sockaddr *AST_OPTIONAL_API_NAME() ast_websocket_remote_address(struct ast_websocket *session)
static ast_mutex_t netlock
const ast_string_field remotesecret
static int proc_session_timer(const void *vp)
Session-Timers: Process session refresh timeout event.
const char * ast_extension_state2str(int extension_state)
Return string representation of the state of an extension.
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
int ast_softhangup(struct ast_channel *chan, int reason)
Softly hangup up a channel.
static int interpret_t38_parameters(struct sip_pvt *p, const struct ast_control_t38_parameters *parameters)
Helper function which updates T.38 capability information and triggers a reinvite.
enum ast_transport transport
static int threadt_hash_cb(const void *obj, const int flags)
enum ast_control_t38_rate rate
const ast_string_field fromdomain
void ast_config_destroy(struct ast_config *config)
Destroys a config.
#define DSP_FEATURE_FAX_DETECT
In case you didn't read that giant block of text above the mansession_session struct, the struct mansession is named this solely to keep the API the same in Asterisk. This structure really represents data that is different from Manager action to Manager action. The mansession_session pointer contained within points to session-specific data.
const char * presence_subtype
long int ast_random(void)
static const char * sip_sanitized_host(const char *host)
static void esc_entry_destructor(void *obj)
static const struct ast_sockaddr * sip_real_dst(const struct sip_pvt *p)
The real destination address for a write.
static int cleanup_registration(void *obj, void *arg, int flags)
#define MAX_TONEZONE_COUNTRY
const ast_string_field exten
#define AST_SIP_API_VERSION
#define AST_SRTP_CRYPTO_OFFER_OK
static int __sip_xmit(struct sip_pvt *p, struct ast_str *data)
static struct ast_codec codec_list[]
static int find_by_subscribe_uri_helper(void *obj, void *arg, int flags)
int ast_cc_agent_caller_available(int core_id, const char *const debug,...)
Indicate that a previously unavailable caller has become available.
static void create_new_sip_etag(struct sip_esc_entry *esc_entry, int is_linked)
#define ast_strdupa(s)
duplicate a string in memory from the stack
static void add_realm_authentication(struct sip_auth_container **credentials, const char *configuration, int lineno)
const ast_string_field refer_to
enum st_refresher st_cached_ref
#define sip_alloc(callid, addr, useglobal_nat, intended_method, req, logger_callid)
static int transmit_request(struct sip_pvt *p, int sipmethod, uint32_t seqno, enum xmittype reliable, int newbranch)
Transmit generic SIP request returns XMIT_ERROR if transmit failed with a critical error (don't retry...
long target_extra
amount of additional jitterbuffer adjustment
static struct ast_channel * sip_new(struct sip_pvt *i, int state, const char *title, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, ast_callid callid)
Initiate a call in the SIP channel.
static int register_realtime_peers_with_callbackextens(void)
static struct ast_cc_agent * find_sip_cc_agent_by_notify_uri(const char *const uri)
static void set_peer_defaults(struct sip_peer *peer)
Set peer defaults before configuring specific configurations.
static void start_ice(struct ast_rtp_instance *instance, int offer)
Start ICE negotiation on an RTP instance.
struct ast_xml_node * ast_xml_find_element(struct ast_xml_node *root_node, const char *name, const char *attrname, const char *attrvalue)
Find a node element by name.
const ast_string_field username
#define DEFAULT_RTPKEEPALIVE
struct sip_epa_entry * epa_entry
static int function_sippeer(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
${SIPPEER()} Dialplan function - reads peer data
int ast_cc_set_param(struct ast_cc_config_params *params, const char *const name, const char *value)
set a CCSS configuration parameter, given its name
static char * crypto_get_attrib(struct ast_sdp_srtp *srtp, int dtls_enabled, int default_taglen_32)
static void extract_uri(struct sip_pvt *p, struct sip_request *req)
Check Contact: URI of SIP message.
const ast_string_field nonce
#define SIP_PAGE3_FLAGS_TO_COPY
enum ast_device_state device_state
static void add_codec_to_sdp(const struct sip_pvt *p, struct ast_format *codec, struct ast_str **m_buf, struct ast_str **a_buf, int debug, int *min_packet_size, int *max_packet_size)
Add codec offer to SDP offer/answer body in INVITE or 200 OK.
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value)
unsigned short autoframing
static char * sip_cli_notify(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Cli command to send SIP notify to peer.
static char * sip_show_users(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI Command 'SIP Show Users'.
int ast_sockaddr_resolve_first_af(struct ast_sockaddr *addr, const char *name, int flag, int family)
Return the first entry from ast_sockaddr_resolve filtered by address family.
#define SCOPED_LOCK(varname, lock, lockfunc, unlockfunc)
Scoped Locks.
static int build_reply_digest(struct sip_pvt *p, int method, char *digest, int digest_len)
Build reply digest.
A set of macros to manage forward-linked lists.
void ast_channel_set_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
Set the redirecting id information in the Asterisk channel.
static char language[MAX_LANGUAGE]
static int sip_send_mwi_to_peer(struct sip_peer *peer, int cache_only)
Send message waiting indication to alert peer that they've got voicemail.
static struct sip_monitor_instance * sip_monitor_instance_init(int core_id, const char *const subscribe_uri, const char *const peername, const char *const device_name)
static int sip_addheader(struct ast_channel *chan, const char *data)
Add a SIP header to an outbound INVITE.
static struct ast_sockaddr externaddr
our external IP address/port for SIP sessions. externaddr.sin_addr is only set when we know we might ...
#define ast_malloc(len)
A wrapper for malloc()
static int handle_t38_options(struct ast_flags *flags, struct ast_flags *mask, struct ast_variable *v, unsigned int *maxdatagram)
Handle T.38 configuration options common to users and peers.
const ast_string_field theirtag
static enum st_refresher st_get_refresher(struct sip_pvt *)
Get the entity (UAC or UAS) that's acting as the session-timer refresher.
struct sip_peer::@176 mailboxes
const esc_publish_callback remove_handler
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
const ast_string_field md5secret
static void copy_socket_data(struct sip_socket *to_sock, const struct sip_socket *from_sock)
static int sip_senddigit_begin(struct ast_channel *ast, char digit)
#define SIP_PAGE2_VIDEOSUPPORT_ALWAYS
static time_t externexpire
#define ast_variable_new(name, value, filename)
unsigned short req_secure_signaling
ast_group_t ast_get_group(const char *s)
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
#define SIP_PAGE2_T38SUPPORT_UDPTL_FEC
#define AST_CAUSE_NO_ANSWER
int ast_msg_set_var(struct ast_msg *msg, const char *name, const char *value)
Set a variable on the message going to the dialplan.
static int __start_session_timer(const void *data)
static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req, struct ast_sockaddr *addr, uint32_t seqno, const char *e)
Handle incoming SUBSCRIBE request.
const ast_string_field useragent
const ast_string_field authname
AST_LIST_HEAD_NOLOCK(contactliststruct, contact)
static struct event_state_compositor event_state_compositors[]
static struct ast_custom_function sip_headers_function
char * ast_rtp_instance_get_quality(struct ast_rtp_instance *instance, enum ast_rtp_instance_stat_field field, char *buf, size_t size)
Retrieve quality statistics about an RTP instance.
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
static ast_mutex_t sip_reload_lock
static int sip_cc_agent_start_offer_timer(struct ast_cc_agent *agent)
Support for WebSocket connections within the Asterisk HTTP server and client WebSocket connections to...
static int network_change_sched_id
unsigned int t38_maxdatagram
const ast_string_field authuser
static void mark_parsed_methods(unsigned int *methods, char *methods_str)
Asterisk XML abstraction layer.
int AST_OPTIONAL_API_NAME() ast_websocket_remove_protocol(const char *name, ast_websocket_callback callback)
struct ast_str * ast_manager_build_channel_state_string(const struct ast_channel_snapshot *snapshot)
Generate the AMI message body from a channel snapshot.
static struct io_context * io
int ast_queue_hold(struct ast_channel *chan, const char *musicclass)
Queue a hold frame.
int ast_get_feature(struct ast_channel *chan, const char *feature, char *buf, size_t len)
Get the DTMF code for a call feature.
int ast_logger_register_level(const char *name)
Register a new logger level.
static int sip_cc_monitor_suspend(struct ast_cc_monitor *monitor)
static void set_t38_capabilities(struct sip_pvt *p)
Set the global T38 capabilities on a SIP dialog structure.
static int process_sdp_o(const char *o, struct sip_pvt *p)
static int sip_cc_agent_status_request(struct ast_cc_agent *agent)
static struct sip_st_dlg * sip_st_alloc(struct sip_pvt *const p)
Allocate Session-Timers struct w/in dialog.
AST_REDIRECTING_REASON
redirecting reason codes.
sipmethod
SIP Request methods known by Asterisk.
const ast_string_field replaces_callid_totag
enum ast_acl_sense ast_apply_acl(struct ast_acl_list *acl_list, const struct ast_sockaddr *addr, const char *purpose)
Apply a set of rules to a given IP address.
static void lws2sws(struct ast_str *msgbuf)
Parse multiline SIP headers into one header This is enabled if pedanticsipchecking is enabled...
char impl[AST_JB_IMPL_NAME_SIZE]
Name of the jitterbuffer implementation to be used.
static force_inline char * ast_str_to_lower(char *str)
Convert a string to all lower-case.
#define AST_CAUSE_NOTDEFINED
Structure to describe a channel "technology", ie a channel driver See for examples: ...
struct ast_tcptls_session_instance * tcptls_session
int ast_sockaddr_hash(const struct ast_sockaddr *addr)
Computes a hash value from the address. The port is ignored.
static int __sip_subscribe_mwi_do(struct sip_subscription_mwi *mwi)
Actually setup an MWI subscription or resubscribe.
void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value)
const char * ast_channel_exten(const struct ast_channel *chan)
struct ast_sockaddr relay_address
Core PBX routines and definitions.
static void sip_cc_agent_respond(struct ast_cc_agent *agent, enum ast_cc_agent_response_reason reason)
int ast_channel_cc_params_init(struct ast_channel *chan, const struct ast_cc_config_params *base_params)
Set up datastore with CCSS parameters for a channel.
int ast_parse_caller_presentation(const char *data)
Convert caller ID text code to value (used in config file parsing)
unsigned int ast_aoc_get_currency_amount(struct ast_aoc_decoded *decoded)
get the currency amount for AOC-D and AOC-E messages
describes a server instance
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
static void sip_pkt_dtor(void *vdoomed)
Structure that represents the optional DTLS SRTP support within an RTP engine.
ast_pbx_result
The result codes when starting the PBX on a channel with ast_pbx_start.
#define AST_NONSTANDARD_RAW_ARGS(args, parse, sep)
#define DEFAULT_COS_AUDIO
static void extract_host_from_hostport(char **hostport)
Terminate a host:port at the ':'.
struct ast_acl_list * directmediaacl
struct ast_set_party_id priv
static char global_sdpowner[AST_MAX_EXTENSION]
#define SIP_PAGE2_FLAGS_TO_COPY
#define DEFAULT_MAX_EXPIRY
#define SIP_PAGE2_IGNORESDPVERSION
static int process_crypto(struct sip_pvt *p, struct ast_rtp_instance *rtp, struct ast_sdp_srtp **srtp, const char *a)
static int default_expiry
#define AST_CAUSE_DESTINATION_OUT_OF_ORDER
int ast_extension_state_extended(struct ast_channel *c, const char *context, const char *exten, struct ao2_container **device_state_info)
Uses hint and devicestate callback to get the extended state of an extension.
char entity_tag[SIPBUFSIZE]
int ast_acl_list_is_empty(struct ast_acl_list *acl_list)
Determines if an ACL is empty or if it contains entries.
#define AST_CC_GENERIC_MONITOR_TYPE
static void sip_registry_destroy(void *reg)
Destroy registry object Objects created with the register= statement in static configuration.
#define CONFIG_STATUS_FILEUNCHANGED
static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int oldsdp, int add_audio, int add_t38)
Add Session Description Protocol message.
#define stasis_subscribe(topic, callback, data)
Wrapper for network related headers, masking differences between various operating systems...
static char * sip_show_channelstats(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
SIP show channelstats CLI (main function)
#define AST_LIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a list of specified type, statically initialized.
static int sip_monitor_instance_hash_fn(const void *obj, const int flags)
struct ast_sched_context * ast_sched_context_create(void)
Create a scheduler context.
struct ao2_container * device_state_info
static int dialog_cmp_cb(void *obj, void *arg, int flags)
#define ast_test_suite_event_notify(s, f,...)
static char * generate_uri(struct sip_pvt *pvt, char *buf, size_t size)
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
int ast_channel_fdno(const struct ast_channel *chan)
static struct sip_epa_entry * create_epa_entry(const char *const event_package, const char *const destination)
int get_name_and_number(const char *hdr, char **name, char **number)
Get name and number from sip header.
const char * ast_channel_uniqueid(const struct ast_channel *chan)
const ast_string_field replaces_callid
static int __stop_t38_abort_timer(const void *data)
int ast_channel_timingfd(const struct ast_channel *chan)
static int sip_dtmfmode(struct ast_channel *chan, const char *data)
Set the DTMFmode for an outbound SIP call (application)
int ast_msg_queue(struct ast_msg *msg)
Queue a message for routing through the dialplan.
char messagecontext[AST_MAX_CONTEXT]
void ast_sched_report(struct ast_sched_context *con, struct ast_str **buf, struct ast_cb_names *cbnames)
Show statics on what it is in the schedule queue.
static enum match_req_res match_req_to_dialog(struct sip_pvt *sip_pvt_ptr, struct match_req_args *arg)
struct ast_cc_config_params * config_params
struct sip_auth_container::@170 list
#define AST_CAUSE_FAILURE
static int peer_hash_cb(const void *obj, const int flags)
int64_t retrans_stop_time
void ast_iostream_set_timeout_disable(struct ast_iostream *stream)
Disable the iostream timeout timer.
static const char * __get_header(const struct sip_request *req, const char *name, int *start)
static void handle_response_update(struct sip_pvt *p, int resp, const char *rest, struct sip_request *req, uint32_t seqno)
Handle authentication challenge for SIP UPDATE.
Readable descriptions of device states.
struct ast_cc_config_params * cc_params
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
Struct to handle custom SIP notify requests. Dynamically allocated when needed.
struct sip_epa_entry * suspension_entry
Redirecting reason information.
sip_debug_e
debugging state We store separately the debugging requests from the config file and requests from the...
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
static int sip_send_keepalive(const void *data)
Send keep alive packet to peer.
const ast_string_field mohinterpret
static int transmit_message(struct sip_pvt *p, int init, int auth)
Transmit with SIP MESSAGE method.
#define SIP_PEDANTIC_DECODE(str)
sip request response parser header file
static const char * autocreatepeer2str(enum autocreatepeer_mode r)
static void sip_publish_registry(const char *username, const char *domain, const char *status)
void ast_channel_stage_snapshot(struct ast_channel *chan)
Set flag to indicate channel snapshot is being staged.
static void * do_monitor(void *data)
The SIP monitoring thread.
#define EXPIRY_GUARD_LIMIT
#define SIP_PAGE2_ALLOWOVERLAP
#define SIP_PAGE3_DISCARD_REMOTE_HOLD_RETRIEVAL
const char * type
Type of agent the callbacks belong to.
#define AST_OPTION_DIGIT_DETECT
static int __start_mwi_subscription(const void *data)
struct epa_backend * next
argument for the 'show channels|subscriptions' callback.
const char *(* get_ufrag)(struct ast_rtp_instance *instance)
unsigned int ast_udptl_get_far_max_ifp(struct ast_udptl *udptl)
retrieves far max ifp
static void mwi_event_cb(void *, struct stasis_subscription *, struct stasis_message *)
Receive MWI events that we have subscribed to.
Structure that contains information about a bridge.
static enum check_auth_result register_verify(struct sip_pvt *p, struct ast_sockaddr *addr, struct sip_request *req, const char *uri)
Verify registration of user.
#define SIP_PAGE2_ALLOWOVERLAP_YES
struct ast_config * ast_load_realtime_multientry(const char *family,...) attribute_sentinel
Retrieve realtime configuration.
static int default_qualify
static enum ast_cc_service_type service_string_to_service_type(const char *const service_string)
static char * sip_show_tcp(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Show active TCP connections.
static struct sip_peer * build_peer(const char *name, struct ast_variable *v, struct ast_variable *alt, int realtime, int devstate_only)
Build peer from configuration (file or realtime static/dynamic)
int ast_rtp_instance_get_hold_timeout(struct ast_rtp_instance *instance)
Get the RTP timeout value for when an RTP instance is on hold.
ptrdiff_t line[SIP_MAX_LINES]
const ast_string_field callid
#define SIP_REINVITE_UPDATE
const char * hangup_cause2sip(int cause)
Convert Asterisk hangup causes to SIP codes.
struct ast_namedgroups * ast_get_namedgroups(const char *s)
Create an ast_namedgroups set with group names from comma separated string.
static int transmit_reinvite_with_sdp(struct sip_pvt *p, int t38version, int oldsdp)
Transmit reinvite with SDP.
void(* set_authentication)(struct ast_rtp_instance *instance, const char *ufrag, const char *password)
#define AST_DEFAULT_WEBSOCKET_WRITE_TIMEOUT
Default websocket write timeout, in ms.
const ast_string_field callid
static int global_callcounter
int ast_tvcmp(struct timeval _a, struct timeval _b)
Compres two struct timeval instances returning -1, 0, 1 if the first arg is smaller, equal or greater to the second.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
static void send_session_timeout(struct ast_channel *chan, const char *source)
Sends a session timeout channel blob used to produce SessionTimeout AMI messages. ...
static unsigned int recordhistory
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
const ast_string_field referred_by
static const char * referstatus2str(enum referstatus rstatus) attribute_pure
Convert transfer status to string.
static int copy_all_header(struct sip_request *req, const struct sip_request *orig, const char *field)
Copy all headers from one request to another.
int ast_pickup_call(struct ast_channel *chan)
Pickup a call.
#define SIP_PAGE2_Q850_REASON
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
char name[MAXHOSTNAMELEN]
#define SIP_DTMF_SHORTINFO
int legacy_useroption_parsing
const ast_string_field useragent
struct ao2_container *(* get_local_candidates)(struct ast_rtp_instance *instance)
static int handle_request_bye(struct sip_pvt *p, struct sip_request *req)
Handle incoming BYE request.
static int global_reg_retry_403
backend for an event publication agent
struct ast_format_cap * caps
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
struct ast_format_cap * redircaps
struct ast_endpoint * endpoint
#define DEFAULT_KEEPALIVE
void ast_iostream_set_timeout_sequence(struct ast_iostream *stream, struct timeval start, int timeout)
Set the iostream I/O sequence timeout timer.
ast_callid ast_create_callid(void)
factory function to create a new uniquely identifying callid.
const ast_string_field cid_num
static void pvt_set_needdestroy(struct sip_pvt *pvt, const char *reason)
#define sip_pvt_trylock(x)
static void sip_send_all_mwi_subscriptions(void)
Send all MWI subscriptions.
const ast_string_field initviasentby
#define SIP_PAGE2_UDPTL_DESTINATION
static int sip_removeheader(struct ast_channel *chan, const char *data)
Remove SIP headers added previously with SipAddHeader application.
#define ao2_t_global_obj_ref(holder, tag)
Get a reference to the object stored in the global holder.
struct sip_st_dlg * stimer
struct ast_rtp_engine_dtls * ast_rtp_instance_get_dtls(struct ast_rtp_instance *instance)
Obtain a pointer to the DTLS support present on an RTP instance.
static void start_reregister_timeout(struct sip_registry *reg, int ms)
static int threadt_cmp_cb(void *obj, void *arg, int flags)
static int show_channels_cb(struct sip_pvt *cur, struct __show_chan_arg *arg)
callback for show channel|subscription
Structure representing an agent.
const ast_string_field zone
struct ast_party_id ast_channel_connected_effective_id(struct ast_channel *chan)
void ast_udptl_set_peer(struct ast_udptl *udptl, const struct ast_sockaddr *them)
const ast_string_field fromdomain
struct ast_set_party_id priv_from
#define ao2_unlink(container, obj)
static int sip_do_reload(enum channelreloadreason reason)
Reload module.
static void initialize_initreq(struct sip_pvt *p, struct sip_request *req)
Initialize the initital request packet in the pvt structure. This packet is used for creating replies...
void(* set_role)(struct ast_rtp_instance *instance, enum ast_rtp_ice_role role)
static enum sip_publish_type determine_sip_publish_type(struct sip_request *req, const char *const event, const char *const etag, const char *const expires, int *expires_int)
int ast_msg_tech_unregister(const struct ast_msg_tech *tech)
Unregister a message technology.
#define ao2_t_iterator_next(iter, tag)
static void try_suggested_sip_codec(struct sip_pvt *p)
Try setting the codecs suggested by the SIP_CODEC channel variable.
static char default_parkinglot[AST_MAX_CONTEXT]
#define REMOVE_MAILBOX_WITH_LOCKED_PEER(__peer)
#define ast_sockaddr_set_port(addr, port)
Sets the port number of a socket address.
#define AST_CAUSE_NORMAL_UNSPECIFIED
struct ast_sockaddr bindaddr
void ast_channel_named_callgroups_set(struct ast_channel *chan, struct ast_namedgroups *value)
xmittype
When sending a SIP message, we can send with a few options, depending on type of SIP request...
int ast_rtp_instance_sendcng(struct ast_rtp_instance *instance, int level)
Send a comfort noise packet to the RTP instance.
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
#define AST_TEST_UNREGISTER(cb)
static const struct cfsubscription_types * find_subscription_type(enum subscriptiontype subtype)
Find subscription type in array.
#define dialog_unref(dialog, tag)
#define AST_CAUSE_CHANNEL_UNACCEPTABLE
int parse_uri(char *uri, const char *scheme, char **ret_name, char **pass, char **hostport, char **transport)
parses a URI in its components.
static int transmit_response_with_minexpires(struct sip_pvt *p, const char *msg, const struct sip_request *req, int minexpires)
Append Min-Expires header, content length before transmitting response.
const ast_string_field record_on_feature
struct ao2_container * device_state_info
unsigned int fill_bit_removal
static unsigned int monitor
const ast_string_field callback
const ast_string_field fullcontact
const char * get_calleridname(const char *input, char *output, size_t outputsize)
Get caller id name from SIP headers, copy into output buffer.
static int sip_register(const char *value, int lineno)
create sip_registry object from register=> line in sip.conf and link into reg container ...
static void update_peer_lastmsgssent(struct sip_peer *peer, int value, int locked)
int ast_set_qos(int sockfd, int tos, int cos, const char *desc)
Set type of service.
const struct ast_aoc_unit_entry * ast_aoc_get_unit_info(struct ast_aoc_decoded *decoded, unsigned int entry_number)
get a specific unit entry.
static const struct cfalias aliases[]
struct ast_acl_list * ast_free_acl_list(struct ast_acl_list *acl)
Free a list of ACLs.
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the 'nonstandard' argument separation process for an application.
Diversion header reasons.
#define SIP_PAGE2_HAVEPEERCONTEXT
const ast_string_field domain
struct ast_tone_zone * ast_get_indication_zone(const char *country)
locate ast_tone_zone
static struct ast_variable * copy_vars(struct ast_variable *src)
duplicate a list of channel variables,
static char * sip_show_registry(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Show SIP Registry (registrations with other SIP proxies.
static void sip_poke_all_peers(void)
Send a poke to all known peers.
static int transmit_register(struct sip_registry *r, int sipmethod, const char *auth, const char *authheader)
Transmit register to SIP proxy or UA auth = NULL on the initial registration (from sip_reregister()) ...
#define ast_rtp_instance_set_remote_address(instance, address)
Set the address of the remote endpoint that we are sending RTP to.
void ast_var_delete(struct ast_var_t *var)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
int ani2
Automatic Number Identification 2 (Info Digits)
struct stasis_message_type * ast_endpoint_state_type(void)
Message type for endpoint state changes.
enum ast_rtp_ice_component_type id
static int get_sip_pvt_from_replaces(const char *callid, const char *totag, const char *fromtag, struct sip_pvt **out_pvt, struct ast_channel **out_chan)
Find a companion dialog based on Replaces information.
static int get_pai(struct sip_pvt *p, struct sip_request *req)
Parse the parts of the P-Asserted-Identity header on an incoming packet. Returns 1 if a valid header ...
int sip_acf_channel_read(struct ast_channel *chan, const char *funcname, char *preparse, char *buf, size_t buflen)
Channel read dialplan function for SIP.
const ast_string_field last_presence_message
static void blind_transfer_cb(struct ast_channel *chan, struct transfer_channel_data *user_data_wrapper, enum ast_transfer_type transfer_type)
static const char * regstate2str(enum sipregistrystate regstate) attribute_const
Convert registration state status to string.
static char * sip_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Force reload of module from cli.
#define stasis_subscribe_pool(topic, callback, data)
struct sip_threadinfo::@178 packet_q
struct ast_cc_agent * ast_cc_agent_callback(int flags, ao2_callback_fn *function, void *arg, const char *const type)
Call a callback on all agents of a specific type.
static int sip_pickup(struct ast_channel *chan)
Pickup a call using the subsystem in features.c This is executed in a separate thread.
static const char * map_x_s(const struct _map_x_s *table, int x, const char *errorstring)
map from an integer value to a string. If no match is found, return errorstring
#define ao2_t_callback(c, flags, cb_fn, arg, tag)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container, as described below.
#define SIP_PROG_INBAND_NEVER
Instance data for a Call completion EPA entry.
Connected Line/Party information.
static struct stasis_subscription * acl_change_sub
int ast_rtp_instance_dtmf_begin(struct ast_rtp_instance *instance, char digit)
Begin sending a DTMF digit.
static int global_reg_timeout
#define SIP_PAGE2_ALLOWOVERLAP_DTMF
static char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
static struct ast_flags global_flags[3]
static enum sip_debug_e sipdebug
static int __stop_reinviteid(const void *data)
unsigned int disallowed_methods
static void change_callid_pvt(struct sip_pvt *pvt, const char *callid)
Subscription types that we support. We support.
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
static void on_dns_update_registry(struct ast_sockaddr *old, struct ast_sockaddr *new, void *data)
static int sip_subscribe_mwi_do(const void *data)
Send a subscription or resubscription for MWI.
struct ast_rtp_instance * vrtp
static int sip_prepare_socket(struct sip_pvt *p)
def ignore(key=None, val=None, section=None, pjsip=None, nmapped=None, type='endpoint')
static struct ast_cc_agent_callbacks sip_cc_agent_callbacks
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
ssize_t ast_recvfrom(int sockfd, void *buf, size_t len, int flags, struct ast_sockaddr *src_addr)
Wrapper around recvfrom(2) that uses struct ast_sockaddr.
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
static void print_named_groups(int fd, struct ast_namedgroups *groups, int crlf)
Print named call groups and pickup groups.
#define SIP_DIRECT_MEDIA_NAT
static struct ast_jb_conf global_jbconf
static void stop_media_flows(struct sip_pvt *p)
Immediately stop RTP, VRTP and UDPTL as applicable.
static int send_request(struct sip_pvt *p, struct sip_request *req, enum xmittype reliable, uint32_t seqno)
int ast_aoc_get_termination_request(struct ast_aoc_decoded *decoded)
get whether or not the AST_AOC_REQUEST message as a termination request.
static void register_peer_exten(struct sip_peer *peer, int onoff)
Automatically add peer extension to dial plan.
static void cb_extensionstate_destroy(int id, void *data)
#define ALLOWED_METHODS
SIP Methods we support.
int ast_udptl_setqos(struct ast_udptl *udptl, unsigned int tos, unsigned int cos)
struct stasis_subscription * stasis_unsubscribe(struct stasis_subscription *subscription)
Cancel a subscription.
#define ao2_iterator_next(iter)
static int handle_response_register(struct sip_pvt *p, int resp, const char *rest, struct sip_request *req, uint32_t seqno)
Handle responses on REGISTER to services.
static void sip_tcptls_client_args_destructor(void *obj)
#define ao2_alloc(data_size, destructor_fn)
static void sip_unregister_tests(void)
SIP test registration.
const ast_string_field regexten
#define AST_PRES_NUMBER_NOT_AVAILABLE
int ast_get_ip(struct ast_sockaddr *addr, const char *hostname)
Get the IP address given a hostname.
static void do_stop_session_timer(struct sip_pvt *pvt)
struct timeval ast_channel_creationtime(struct ast_channel *chan)
static int cb_extensionstate(const char *context, const char *exten, struct ast_state_cb_info *info, void *data)
Callback for the devicestate notification (SUBSCRIBE) support subsystem.
static struct sip_settings sip_cfg
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
static char * _sip_qualify_peer(int type, int fd, struct mansession *s, const struct message *m, int argc, const char *argv[])
Send qualify message to peer from cli or manager. Mostly for debugging.
const ast_string_field redircause
#define DEFAULT_NOTIFYMIME
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
void(* reset)(struct ast_rtp_instance *instance)
static int handle_request_update(struct sip_pvt *p, struct sip_request *req)
bare-bones support for SIP UPDATE
static char * sip_unregister(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Unregister (force expiration) a SIP peer in the registry via CLI.
static struct sip_peer * temp_peer(const char *name)
Create temporary peer (used in autocreatepeer mode)
long ast_sched_when(struct ast_sched_context *con, int id)
Returns the number of seconds before an event takes place.
unsigned short final_destruction_scheduled
#define SIP_NAT_RPORT_PRESENT
#define SIP_PAGE2_RTCACHEFRIENDS
ast_rtp_dtls_hash
DTLS fingerprint hashes.
#define SIP_PAGE3_NAT_AUTO_RPORT
char * strcasestr(const char *, const char *)
struct stasis_topic * ast_system_topic(void)
A Stasis Message Bus API topic which publishes messages regarding system changes. ...
struct ast_format_cap * capabilities
int AST_OPTIONAL_API_NAME() ast_websocket_set_timeout(struct ast_websocket *session, int timeout)
static char default_mohsuggest[MAX_MUSICCLASS]
int ast_softhangup_nolock(struct ast_channel *chan, int reason)
Softly hangup up a channel (no channel lock)
Structure used for each SIP dialog, ie. a call, a registration, a subscribe. Created and initialized ...
int ast_channel_is_bridged(const struct ast_channel *chan)
Determine if a channel is in a bridge.
static void clear_sip_domains(void)
Clear our domain list (at reload)
static int transmit_notify_with_mwi(struct sip_pvt *p, int newmsgs, int oldmsgs, const char *vmexten)
Notify user of messages waiting in voicemail (RFC3842)
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
struct ast_control_t38_parameters their_parms
static char * complete_sip_notify(const char *line, const char *word, int pos, int state)
Support routine for 'sip notify' CLI.
int ast_rtp_dtls_cfg_validate(struct ast_rtp_dtls_cfg *dtls_cfg)
Validates DTLS related configuration options.
int stasis_subscription_final_message(struct stasis_subscription *sub, struct stasis_message *msg)
Determine whether a message is the final message to be received on a subscription.
static struct ast_channel * sip_pvt_lock_full(struct sip_pvt *pvt)
static int load_module(void)
Load the module.
static int dialog_dump_func(void *userobj, void *arg, int flags)
static int sip_sendcustominfo(struct ast_channel *chan, const char *data)
Send a custom INFO message via AST_CONTROL_CUSTOM indication.
struct ast_namedgroups * ast_ref_namedgroups(struct ast_namedgroups *groups)
static char * sip_set_history(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Enable/Disable SIP History logging (CLI)
char * str
a string value for the redirecting reason
int ast_rtp_instance_set_read_format(struct ast_rtp_instance *instance, struct ast_format *format)
Request that the underlying RTP engine provide audio frames in a specific format. ...
static int get_domain(const char *str, char *domain, int len)
Extract domain from SIP To/From header.
static void sip_destroy_peer(struct sip_peer *peer)
Destroy peer object from memory.
static int global_timer_b
static int __set_address_from_contact(const char *fullcontact, struct ast_sockaddr *addr, int tcp)
int ast_sockaddr_is_ipv4_multicast(const struct ast_sockaddr *addr)
Determine if an IPv4 address is a multicast address.
#define ast_channel_unlock(chan)
static char version[AST_MAX_EXTENSION]
static void peer_sched_cleanup(struct sip_peer *peer)
static int sipsock
Main socket for UDP SIP communication.
const char * ast_cause2str(int state) attribute_pure
Gives the string form of a given cause code.
struct ast_sockaddr tredirip
#define sip_unref_peer(peer, tag)
void ast_dsp_set_features(struct ast_dsp *dsp, int features)
Select feature set.
unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, const struct ast_format *format, int code)
Get the sample rate associated with known RTP payload types.
unsigned short deprecated_username
unsigned int reqsipoptions
const char * force_rport_string(struct ast_flags *flags)
Return a string describing the force_rport value for the given flags.
static void build_contact(struct sip_pvt *p, struct sip_request *req, int incoming)
Build contact header.
static char * ast_sockaddr_stringify_host_remote(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only, suitable for a URL (with brack...
#define AST_CAUSE_UNREGISTERED
static int sip_cc_agent_stop_offer_timer(struct ast_cc_agent *agent)
int source
Information about the source of an update.
static const struct cfsip_options sip_options[]
#define AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN
void(* start)(struct ast_rtp_instance *instance)
unsigned short is_realtime
static enum st_refresher_param str2strefresherparam(const char *s)
int ast_channel_get_duration(struct ast_channel *chan)
Obtain how long the channel since the channel was created.
static int sip_t38_abort(const void *data)
Called to deny a T38 reinvite if the core does not respond to our request.
const char * sip_route_add(struct sip_route *route, const char *uri, size_t len, int inserthead)
Add a new hop to the route.
Structure definition for session.
#define ast_calloc(num, len)
A wrapper for calloc()
char * ast_escape_quoted(const char *string, char *outbuf, int buflen)
Escape characters found in a quoted string.
static char * complete_sip_show_history(const char *line, const char *word, int pos, int state)
Support routine for 'sip show history' CLI.
#define SIP_FLAGS_TO_COPY
Flags to copy from peer/user to dialog.
#define AST_OPTION_SECURE_SIGNALING
static char global_sdpsession[AST_MAX_EXTENSION]
static struct ast_cc_agent * find_sip_cc_agent_by_original_callid(struct sip_pvt *pvt)
static void start_session_timer(struct sip_pvt *p)
Session-Timers: Start session timer.
static struct ast_variable * get_insecure_variable_from_sipregs(const char *column, const char *value, struct ast_variable **var)
unsigned short do_history
struct ast_channel * owner
message_integrity
Indication of a TCP message's integrity.
static int sip_cc_monitor_unsuspend(struct ast_cc_monitor *monitor)
static int transmit_provisional_response(struct sip_pvt *p, const char *msg, const struct sip_request *req, int with_sdp)
static int send_response(struct sip_pvt *p, struct sip_request *req, enum xmittype reliable, uint32_t seqno)
Transmit response on SIP request.
static enum ast_rtp_glue_result sip_get_trtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)
unsigned short selfdestruct
static void unlink_peers_from_tables(peer_unlink_flag_t flag)
int ast_str2cos(const char *value, unsigned int *cos)
Convert a string to the appropriate COS value.
const ast_string_field mwi_from
Call Completion Supplementary Services API.
#define DEFAULT_USERAGENT
#define dialog_ref(dialog, tag)
when we create or delete references, make sure to use these functions so we keep track of the refcoun...
static void update_connectedline(struct sip_pvt *p, const void *data, size_t datalen)
Notify peer that the connected line has changed.
static int __transmit_response(struct sip_pvt *p, const char *msg, const struct sip_request *req, enum xmittype reliable)
Base transmit response function.
struct ao2_container * last_device_state_info
char original_exten[SIPBUFSIZE]
void * ast_mwi_unsubscribe_and_join(struct ast_mwi_subscriber *sub)
Unsubscribe from the stasis topic, block until the final message is received, and then unsubscribe fr...
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
static void stop_reinviteid(struct sip_pvt *pvt)
static void realtime_update_peer(const char *peername, struct ast_sockaddr *addr, const char *username, const char *fullcontact, const char *useragent, int expirey, unsigned short deprecated_username, int lastms, const char *path)
Update peer object in realtime storage If the Asterisk system name is set in asterisk.conf, we will use that name and store that in the "regserver" field in the sippeers table to facilitate multi-server setups.
void sip_parse_nat_option(const char *value, struct ast_flags *mask, struct ast_flags *flags)
Parse the comma-separated nat= option values.
static int transmit_response_with_minse(struct sip_pvt *p, const char *msg, const struct sip_request *req, int minse_int)
Transmit 422 response with Min-SE header (Session-Timers)
st_refresher
The entity playing the refresher role for Session-Timers.
static int func_header_read(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len)
Read SIP header (dialplan function)
static int __stop_register_timeout(const void *data)
void(* set_setup)(struct ast_rtp_instance *instance, enum ast_rtp_dtls_setup setup)
Structure for SIP peer data, we place calls to peers if registered or fixed IP address (host) ...
#define REQ_OFFSET_TO_STR(req, offset)
struct ast_sdp_srtp * ast_sdp_srtp_alloc(void)
allocate a ast_sdp_srtp structure
#define AST_CAUSE_NUMBER_CHANGED
unsigned int ast_get_cc_offer_timer(struct ast_cc_config_params *config)
Get the cc_offer_timer.
static int sip_transfer(struct ast_channel *ast, const char *dest)
Transfer SIP call.
void ast_rtp_instance_set_hold_timeout(struct ast_rtp_instance *instance, int timeout)
Set the RTP timeout value for when the instance is on hold.
static int transmit_response_with_auth(struct sip_pvt *p, const char *msg, const struct sip_request *req, const char *rand, enum xmittype reliable, const char *header, int stale)
Respond with authorization request.
static void sip_cc_agent_destructor(struct ast_cc_agent *agent)
int ast_udptl_fd(const struct ast_udptl *udptl)
static void to_ami(struct ast_sip_subscription *sub, struct ast_str **buf)
struct ast_sdp_crypto * ast_sdp_crypto_alloc(void)
Initialize an return an ast_sdp_crypto struct.
#define ao2_t_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn, tag)
Allocate and initialize a hash container with the desired number of buckets.
#define DEFAULT_ALWAYSAUTHREJECT
int ast_parse_arg(const char *arg, enum ast_parse_flags flags, void *result,...)
The argument parsing routine.
struct ast_acl_list * contactacl
static unsigned int global_autoframing
static struct sip_esc_entry * create_esc_entry(struct event_state_compositor *esc, struct sip_request *req, const int expires)
static struct ast_manager_event_blob * session_timeout_to_ami(struct stasis_message *msg)
static void stop_t38_abort_timer(struct sip_pvt *pvt)
int ast_rtp_instance_fd(struct ast_rtp_instance *instance, int rtcp)
Get the file descriptor for an RTP session (or RTCP)
#define DEFAULT_QUALIFY_PEERS
static int manager_sipnotify(struct mansession *s, const struct message *m)
struct stasis_subscription * stasis_unsubscribe_and_join(struct stasis_subscription *subscription)
Cancel a subscription, blocking until the last message is processed.
struct stasis_message_type * ast_mwi_state_type(void)
Get the Stasis Message Bus API message type for MWI messages.
static int determine_firstline_parts(struct sip_request *req)
Parse first line of incoming SIP request.
Module has failed to load, may be in an inconsistent state.
sip dialog management header file
static int parse_request(struct sip_request *req)
Parse a SIP message.
static int str2dtmfmode(const char *str) attribute_unused
maps a string to dtmfmode, returns -1 on error
static void sip_handle_cc(struct sip_pvt *pvt, struct sip_request *req, enum ast_cc_service_type service)
int ast_sockaddr_is_ipv4_mapped(const struct ast_sockaddr *addr)
Determine if this is an IPv4-mapped IPv6 address.
static struct ast_tcptls_session_instance * sip_tcp_locate(struct ast_sockaddr *s)
Find thread for TCP/TLS session (based on IP/Port.
static void parse_copy(struct sip_request *dst, const struct sip_request *src)
Copy SIP request, parse it.
static void destroy_mailbox(struct sip_mailbox *mailbox)
unsigned short route_persistent
static int sip_allow_anyrtp_remote(struct ast_channel *chan1, struct ast_rtp_instance *instance, const char *rtptype)
static int handle_request_cancel(struct sip_pvt *p, struct sip_request *req)
Handle incoming CANCEL request.
int ast_strftime(char *buf, size_t len, const char *format, const struct ast_tm *tm)
Special version of strftime(3) that handles fractions of a second. Takes the same arguments as strfti...
#define ao2_find(container, arg, flags)
#define DEFAULT_NOTIFYRINGING
static int registry_hash_cb(const void *obj, const int flags)
static int finalize_content(struct sip_request *req)
Add 'Content-Length' header and content to SIP message.
const char * ast_aoc_get_currency_name(struct ast_aoc_decoded *decoded)
get the currency name for AOC-D and AOC-E messages
static char * complete_sip_user(const char *word, int state)
Do completion on user name.
int ast_can_pickup(struct ast_channel *chan)
Test if a channel can be picked up.
static int request(void *obj)
unsigned int flags
Combination of the AST_JB_ENABLED, AST_JB_FORCED and AST_JB_LOG flags.
static int __cleanup_registration(const void *data)
struct ast_rtp_instance * rtp
const ast_string_field peername
static char default_engine[256]
static struct ast_variable * get_insecure_variable_from_config(struct ast_config *config)
void ast_cc_copy_config_params(struct ast_cc_config_params *dest, const struct ast_cc_config_params *src)
copy CCSS configuration parameters from one structure to another
static int add_rpid(struct sip_request *req, struct sip_pvt *p)
Add Remote-Party-ID header to SIP message.
int ast_db_get(const char *family, const char *key, char *value, int valuelen)
Get key value specified by family/key.
char notify_uri[SIPBUFSIZE]
struct ast_cc_interface * interface
static int global_qualifyfreq
const char *const mediatype
static int find_sip_method(const char *msg)
find_sip_method: Find SIP method from header
struct sip_subscription_mwi * mwi
static void sip_epa_unregister_all(void)
struct sip_pvt * subscribe_pvt
static enum check_auth_result check_auth(struct sip_pvt *p, struct sip_request *req, const char *username, const char *secret, const char *md5secret, int sipmethod, const char *uri, enum xmittype reliable)
Check user authorization from peer definition Some actions, like REGISTER and INVITEs from peers requ...
void ast_xml_close(struct ast_xml_doc *doc)
Close an already open document and free the used structure.
static int network_change_sched_cb(const void *data)
sip.conf parser header file
#define AST_CAUSE_INTERWORKING
struct ast_party_redirecting_reason reason
Reason for the redirection.
static void handle_response_invite(struct sip_pvt *p, int resp, const char *rest, struct sip_request *req, uint32_t seqno)
Handle SIP response to INVITE dialogue.
static void add_vcodec_to_sdp(const struct sip_pvt *p, struct ast_format *format, struct ast_str **m_buf, struct ast_str **a_buf, int debug, int *min_packet_size)
Add video codec offer to SDP offer/answer body in INVITE or 200 OK.
int ast_msg_set_exten(struct ast_msg *msg, const char *fmt,...)
Set the dialplan extension for this message.
#define SIP_PAGE2_BUGGY_MWI
int ast_sched_add(struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data) attribute_warn_unused_result
Adds a scheduled event.
STASIS_MESSAGE_TYPE_DEFN_LOCAL(session_timeout_type,.to_ami=session_timeout_to_ami,)
enum st_mode st_mode_oper
void ast_sdp_srtp_destroy(struct ast_sdp_srtp *srtp)
free a ast_sdp_srtp structure
static struct sip_peer * realtime_peer(const char *peername, struct ast_sockaddr *sin, char *callbackexten, int devstate_only, int which_objects)
realtime_peer: Get peer from realtime storage Checks the "sippeers" realtime family from extconfig...
const ast_string_field opaque
enum invitestates invitestate
structure to hold users read from users.conf
static int unauth_sessions
void ast_rtp_codecs_payloads_destroy(struct ast_rtp_codecs *codecs)
Destroy the contents of an RTP codecs structure (but not the structure itself)
#define ast_string_field_build(x, field, fmt, args...)
Set a field to a complex (built) value.
void ast_cdr_setuserfield(const char *channel_name, const char *userfield)
Set CDR user field for channel (stored in CDR)
static void * cleanup(void *unused)
void ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the local address that we are expecting RTP on.
static struct sip_auth * find_realm_authentication(struct sip_auth_container *credentials, const char *realm)
void sip_reqresp_parser_exit(void)
Free resources used by request and response parser.
Structure used to handle boolean flags.
static int do_register_auth(struct sip_pvt *p, struct sip_request *req, enum sip_auth_type code)
Authenticate for outbound registration.
struct stasis_topic * ast_manager_get_topic(void)
Get the Stasis Message Bus API topic for AMI.
static void ref_proxy(struct sip_pvt *pvt, struct sip_proxy *proxy)
maintain proper refcounts for a sip_pvt's outboundproxy
int ast_rtp_instance_destroy(struct ast_rtp_instance *instance)
Destroy an RTP instance.
static int dialog_needdestroy(void *dialogobj, void *arg, int flags)
Match dialogs that need to be destroyed.
static AO2_GLOBAL_OBJ_STATIC(g_bogus_peer)
A bogus peer, to be used when authentication should fail.
int peercomparefunc(const void *a, const void *b)
static int sip_debug_test_pvt(struct sip_pvt *p)
Test PVT for debugging output.
unsigned short autoframing
void sip_request_parser_unregister_tests(void)
unregister request parsing tests
int sip_parse_host(char *line, int lineno, char **hostname, int *portnum, enum ast_transport *transport)
parses a config line for a host with a transport
static int get_transport_str2enum(const char *transport)
Return int representing a bit field of transport types found in const char *transport.
const ast_string_field secret
struct ast_format_cap * caps
Global list of addresses dynamic peers are not allowed to use.
#define ast_clear_flag(p, flag)
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
int ast_check_digits(const char *arg)
Check if a string is only digits.
static int sip_pidf_validate(struct sip_request *req, struct ast_xml_doc **pidf_doc)
Makes sure that body is properly formatted PIDF.
int ast_io_remove(struct io_context *ioc, int *id)
Removes an IO context.
char * ast_unescape_semicolon(char *s)
Strip backslash for "escaped" semicolons, the string to be stripped (will be modified).
static enum st_refresher_param global_st_refresher
static void sip_register_tests(void)
SIP test registration.
static int sipdebug_text
extra debugging for 'text' related events. At the moment this is set together with sip_debug_console...
#define SIP_PAGE2_FAX_DETECT_T38
can_create_dialog
States whether a SIP message can create a dialog in Asterisk.
struct ast_iostream * stream
static char cid_name[AST_MAX_EXTENSION]
static void destroy_realm_authentication(void *obj)
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
void ast_rtp_instance_set_keepalive(struct ast_rtp_instance *instance, int timeout)
Set the RTP keepalive interval.
static void build_callid_pvt(struct sip_pvt *pvt)
Build SIP Call-ID value for a non-REGISTER transaction.
void ast_channel_callid_set(struct ast_channel *chan, ast_callid value)
Indicate what information in ast_party_connected_line should be set.
int ast_msg_set_from(struct ast_msg *msg, const char *fmt,...)
Set the 'from' URI of a message.
void ast_jb_configure(struct ast_channel *chan, const struct ast_jb_conf *conf)
Configures a jitterbuffer on a channel.
static int transmit_notify_with_sipfrag(struct sip_pvt *p, int cseq, char *message, int terminate)
Notify a transferring party of the status of transfer (RFC3515)
static void do_setnat(struct sip_pvt *p)
Set nat mode on the various data sockets.
struct ast_udptl * ast_udptl_new_with_bindaddr(struct ast_sched_context *sched, struct io_context *io, int callbackmode, struct ast_sockaddr *in)
static struct sip_pvt * __find_call(struct sip_request *req, struct ast_sockaddr *addr, const int intended_method, const char *file, int line, const char *func)
find or create a dialog structure for an incoming SIP message. Connect incoming SIP message to curren...
static void handle_response_peerpoke(struct sip_pvt *p, int resp, struct sip_request *req)
Handle qualification responses (OPTIONS)
static void parse_oli(struct sip_request *req, struct ast_channel *chan)
Check for the presence of OLI tag(s) in the From header and set on the channel.
static int sip_reregister(const void *data)
Update registration with SIP Proxy.
sip_request: The data grabbed from the UDP socket
static char * complete_sip_registered_peer(const char *word, int state, int flags2)
Do completion on registered peer name.
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
AST_TEST_DEFINE(test_sip_mwi_subscribe_parse)
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
static void sip_monitor_instance_destructor(void *data)
const ast_string_field authdomain
static void check_pendings(struct sip_pvt *p)
Check pending actions on SIP call.
int ast_get_ip_or_srv(struct ast_sockaddr *addr, const char *hostname, const char *service)
Get the IP address given a hostname and optional service.
unsigned int transcoding_jbig
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
#define AST_THREADSTORAGE_CUSTOM(a, b, c)
Define a thread storage variable, with custom initialization and cleanup.
static int handle_request_message(struct sip_pvt *p, struct sip_request *req, struct ast_sockaddr *addr, const char *e)
Handle incoming MESSAGE request.
referstatus
Parameters to know status of transfer.
void ast_endpoint_blob_publish(struct ast_endpoint *endpoint, struct stasis_message_type *type, struct ast_json *blob)
Creates and publishes a ast_endpoint_blob message.
#define SIP_PAGE2_TEXTSUPPORT
struct ast_frame * ast_udptl_read(struct ast_udptl *udptl)
autocreatepeer_mode
Automatic peer registration behavior.
#define DEFAULT_KEEPALIVE_INTERVAL
struct ast_sockaddr vredirip
#define SIP_PAGE2_VIDEOSUPPORT
static void handle_request_info(struct sip_pvt *p, struct sip_request *req)
Receive SIP INFO Message.
static char * complete_sip_show_peer(const char *line, const char *word, int pos, int state)
Support routine for 'sip show peer' CLI.
static void change_hold_state(struct sip_pvt *dialog, struct sip_request *req, int holdstate, int sendonly)
Change hold state for a call.
#define AST_PRES_RESTRICTION
static int handle_common_options(struct ast_flags *flags, struct ast_flags *mask, struct ast_variable *v)
Handle flag-type options common to configuration of devices - peers.
struct ast_frame ast_null_frame
static struct ast_frame * sip_read(struct ast_channel *ast)
Read SIP RTP from channel.
void ast_rtp_codecs_payloads_copy(struct ast_rtp_codecs *src, struct ast_rtp_codecs *dest, struct ast_rtp_instance *instance)
Copy payload information from one RTP instance to another.
static struct ast_channel * find_ringing_channel(struct ao2_container *device_state_info, struct sip_pvt *p)
#define ao2_t_bump(obj, tag)
Bump refcount on an AO2 object by one, returning the object.
void ast_free_ha(struct ast_ha *ha)
Free a list of HAs.
Definition of an MWI subscription to another server.
static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action, int is_offer)
Process SIP SDP offer, select formats and activate media channels If offer is rejected, we will not change any properties of the call Return 0 on success, a negative value on errors. Must be called after find_sdp().
#define AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN
#define SIP_PAGE3_NAT_AUTO_COMEDIA
enum ast_aoc_charge_type ast_aoc_get_charge_type(struct ast_aoc_decoded *decoded)
get the charging type for an AOC-D or AOC-E message
static char * app_dtmfmode
const ast_string_field cid_name
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
#define EVENT_FLAG_REPORTING
const ast_string_field cid_name
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
#define SIP_PAGE2_T38SUPPORT
struct sip_pvt::request_queue request_queue
static struct sip_peer * sip_find_peer_full(const char *peer, struct ast_sockaddr *addr, char *callbackexten, int realtime, int which_objects, int devstate_only, int transport)
const ast_string_field initviabranch
char * tag
User-set "tag".
static int is_method_allowed(unsigned int *allowed_methods, enum sipmethod method)
Check if method is allowed for a device or a dialog.
static int publish_expire(const void *data)
struct ast_set_party_id id
static char * complete_sipch(const char *line, const char *word, int pos, int state)
Support routine for 'sip show channel' and 'sip show history' CLI This is in charge of generating all...
struct ast_variable * headers
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
struct sip_auth_container * auth
int(* active)(struct ast_rtp_instance *instance)
sip_cc_notify_state
The states that can be represented in a SIP call-completion NOTIFY.
#define AST_SCHED_REPLACE_UNREF(id, sched, when, callback, data, unrefcall, addfailcall, refcall)
static int has_media_stream(struct sip_pvt *p, enum media_type m)
Check the media stream list to see if the given type already exists.
#define AST_CAUSE_REQUESTED_CHAN_UNAVAIL
The arg parameter is an object of the same type.
struct timeval last_ringing_channel_time
static void add_diversion(struct sip_request *req, struct sip_pvt *pvt)
Add "Diversion" header to outgoing message.
static char * sip_show_sched(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
const char * presence_subtype
int sip_route_is_strict(struct sip_route *route)
Check if the route is strict.
const ast_string_field realm
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
#define DEFAULT_AUTOCREATEPEER
static int use_reason_header(struct sip_pvt *pvt, struct sip_request *req)
Parses SIP reason header according to RFC3326 and sets channel's hangupcause if configured so and hea...
const esc_publish_callback initial_handler
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
static int handle_request_publish(struct sip_pvt *p, struct sip_request *req, struct ast_sockaddr *addr, const uint32_t seqno, const char *uri)
char * strsep(char **str, const char *delims)
struct ast_set_party_id to
int ast_rtp_instance_set_write_format(struct ast_rtp_instance *instance, struct ast_format *format)
Tell underlying RTP engine that audio frames will be provided in a specific format.
const ast_string_field msg_body
#define AST_CAUSE_NO_ROUTE_DESTINATION
static void proc_422_rsp(struct sip_pvt *p, struct sip_request *rsp)
Handle 422 response to INVITE with session-timer requested.
static void send_manager_peer_status(struct mansession *s, struct sip_peer *peer, const char *idText)
static void * sip_tcp_worker_fn(void *)
SIP TCP connection handler.
static void cleanup_all_regs(void)
enum transfermodes allowtransfer
static struct ast_tls_config sip_tls_cfg
Working TLS connection configuration.
static int handle_request_do(struct sip_request *req, struct ast_sockaddr *addr)
Handle incoming SIP message - request or response.
const ast_string_field peername
const ast_string_field record_off_feature
struct ast_variable * astman_get_variables_order(const struct message *m, enum variable_orders order)
Get a linked list of the Variable: headers with order specified.
static struct ast_cc_monitor_callbacks sip_cc_monitor_callbacks
static int handle_request_register(struct sip_pvt *p, struct sip_request *req, struct ast_sockaddr *sin, const char *e)
Handle incoming REGISTER request.
#define ao2_t_callback_data(container, flags, cb_fn, arg, data, tag)
ao2_callback_data() is a generic function that applies cb_fn() to all objects in a container...
#define UNLINK(element, head, prev)
#define ast_channel_ref(c)
Increase channel reference count.
#define ao2_replace(dst, src)
#define SIP_TRANS_TIMEOUT
int ast_msg_set_endpoint(struct ast_msg *msg, const char *fmt,...)
Set the technology's endpoint associated with this message.
static char * sip_prune_realtime(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Remove temporary realtime objects from memory (CLI)
static struct ao2_container * subscription_mwi_list
The MWI subscription list.
static int uac_sips_contact(struct sip_request *req)
Determine if, as a UAC, we need to use a SIPS Contact.
static enum st_mode global_st_mode
int ast_add_extension(const char *context, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void(*datad)(void *), const char *registrar)
Add and extension to an extension context.
static void add_peer_mwi_subs(struct sip_peer *peer)
void sip_cancel_destroy(struct sip_pvt *pvt)
Cancel destruction of SIP dialog.
static char * sip_show_inuse(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI Command to show calls within limits set by call_limit.
static const char * domain_mode_to_text(const enum domain_mode mode)
Print domain mode to cli.
Indicate what information in ast_party_redirecting should be set.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
int ast_rtp_codecs_payloads_initialize(struct ast_rtp_codecs *codecs)
Initialize an RTP codecs structure.
char * ast_rtp_lookup_mime_multiple2(struct ast_str *buf, struct ast_format_cap *ast_format_capability, int rtp_capability, const int asterisk_format, enum ast_rtp_options options)
Convert formats into a string and put them into a buffer.
static void change_t38_state(struct sip_pvt *p, int state)
Change the T38 state on a SIP dialog.
static int transmit_state_notify(struct sip_pvt *p, struct state_notify_data *data, int full, int timeout)
Used in the SUBSCRIBE notification subsystem (RFC3265)
Standard Command Line Interface.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
static int transmit_cc_notify(struct ast_cc_agent *agent, struct sip_pvt *subscription, enum sip_cc_notify_state state)
void sip_scheddestroy_final(struct sip_pvt *p, int ms)
Schedule final destruction of SIP dialog.
structure for queuing ARI channel variable setting
static void sched_check_pendings(struct sip_pvt *pvt)
static char default_mohinterpret[MAX_MUSICCLASS]
int ast_channel_hangupcause(const struct ast_channel *chan)
static void build_nonce(struct sip_pvt *p, int forceupdate)
builds the sip_pvt's nonce field which is used for the authentication challenge. When forceupdate is ...
int ast_db_del(const char *family, const char *key)
Delete entry in astdb.
static const char * faxec2str(int faxec)
void ast_channel_context_set(struct ast_channel *chan, const char *value)
#define SIP_USECLIENTCODE
char realm[AST_MAX_EXTENSION]
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
int ast_msg_has_destination(const struct ast_msg *msg)
Determine if a particular message has a destination via some handler.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
static int handle_sip_publish_remove(struct sip_pvt *p, struct sip_request *req, struct event_state_compositor *esc, const char *const etag)
static void sip_cc_monitor_destructor(void *private_data)
void ast_str_update(struct ast_str *buf)
Update the length of the buffer, after using ast_str merely as a buffer.
void ast_append_acl(const char *sense, const char *stuff, struct ast_acl_list **path, int *error, int *named_acl_flag)
Add a rule to an ACL struct.
unsigned int emulate_sip_cause
const ast_string_field secret
void ast_tcptls_close_session_file(struct ast_tcptls_session_instance *tcptls_session)
Closes a tcptls session instance's file and/or file descriptor. The tcptls_session will be set to NUL...
The core structure to setup dialogs. We parse incoming messages by using structure and then route the...
static struct sip_threadinfo * sip_threadinfo_create(struct ast_tcptls_session_instance *tcptls_session, int transport)
creates a sip_threadinfo object and links it into the threadt table.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
static int add_digit(struct sip_request *req, char digit, unsigned int duration, int mode)
Add DTMF INFO tone to sip message Mode = 0 for application/dtmf-relay (Cisco) 1 for application/dtmf...
static int sip_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen)
Play indication to user With SIP a lot of indications is sent as messages, letting the device play th...
ast_app: A registered application
struct ast_flags flags[3]
static int transmit_response_with_date(struct sip_pvt *p, const char *msg, const struct sip_request *req)
Add date before transmitting response.
struct ast_channel * ast_channel_bridge_peer(struct ast_channel *chan)
Get the channel's bridge peer only if the bridge is two-party.
int ast_rtp_red_buffer(struct ast_rtp_instance *instance, struct ast_frame *frame)
Buffer a frame in an RTP instance for RED.
static int manager_sip_qualify_peer(struct mansession *s, const struct message *m)
Qualify SIP peers in the manager API.
struct ast_tcptls_session_instance * ast_tcptls_client_create(struct ast_tcptls_session_args *desc)
const char * ast_channel_name(const struct ast_channel *chan)
void ast_party_redirecting_init(struct ast_party_redirecting *init)
Initialize the given redirecting structure.
#define SIP_SENDRPID_RPID
void ast_rtp_codecs_payloads_unset(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload)
Remove tx payload type mapped information.
static char * _sip_show_peer(int type, int fd, struct mansession *s, const struct message *m, int argc, const char *argv[])
Show one peer in detail (main function)
void ast_rtp_dtls_cfg_free(struct ast_rtp_dtls_cfg *dtls_cfg)
Free contents of a DTLS configuration structure.
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"...
void ast_udptl_set_error_correction_scheme(struct ast_udptl *udptl, enum ast_t38_ec_modes ec)
void sip_route_dump(const struct sip_route *route)
Verbose dump of all hops for debugging.
static int default_fromdomainport
struct ast_rtp_instance * ast_rtp_instance_get_bridged(struct ast_rtp_instance *instance)
Get the other RTP instance that an instance is bridged to.
static char default_mwi_from[80]
static int has_media_level_attribute(int start, struct sip_request *req, const char *attr)
static int manager_sip_show_peers(struct mansession *s, const struct message *m)
Show SIP peers in the manager API.
static int sip_answer(struct ast_channel *ast)
sip_answer: Answer SIP call , send 200 OK on Invite Part of PBX interface
static const char * get_transport_list(unsigned int transports)
Return configuration of transports for a device.
#define AST_CAUSE_USER_BUSY
void ast_sched_dump(struct ast_sched_context *con)
Dumps the scheduler contents.
static int sip_queryoption(struct ast_channel *chan, int option, void *data, int *datalen)
Query an option on a SIP dialog.
static int global_match_auth_username
const ast_string_field secret
void ast_udptl_stop(struct ast_udptl *udptl)
unsigned int port_str2int(const char *pt, unsigned int standard)
converts ascii port to int representation. If no pt buffer is provided or the pt has errors when bein...
void ast_rtp_instance_get_requested_target_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the requested target address of the remote endpoint.
const ast_string_field cid_tag
static int global_regattempts_max
const char * ast_xml_get_text(struct ast_xml_node *node)
Get an element content string.
unsigned short session_modify
int ast_rtp_engine_srtp_is_registered(void)
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
#define AST_PTHREADT_STOP
int ast_rtp_glue_unregister(struct ast_rtp_glue *glue)
Unregister RTP glue.
static int create_addr_from_peer(struct sip_pvt *r, struct sip_peer *peer)
Create address structure from peer reference. This function copies data from peer to the dialog...
enum autocreatepeer_mode autocreatepeer
static int sip_allow_vrtp_remote(struct ast_channel *chan1, struct ast_rtp_instance *instance)
static int sip_poke_peer(struct sip_peer *peer, int force)
Check availability of peer, also keep NAT open.
static void add_cc_call_info_to_response(struct sip_pvt *p, struct sip_request *resp)
const ast_string_field tohost
static void acl_change_stasis_subscribe(void)
#define append_history(p, event, fmt, args...)
Append to SIP dialog history.
static struct sip_peer * sip_find_peer_by_ip_and_exten(struct ast_sockaddr *addr, char *callbackexten, int transport)
int ast_async_goto(struct ast_channel *chan, const char *context, const char *exten, int priority)
Set the channel to next execute the specified dialplan location.
int ast_udptl_write(struct ast_udptl *udptl, struct ast_frame *f)
int accept_outofcall_message
#define ao2_t_find(container, arg, flags, tag)
generic struct to map between strings and integers. Fill it with x-s pairs, terminate with an entry w...
struct ast_party_redirecting redirecting
#define AST_FEATURE_MAX_LEN
char default_record_on_feature[AST_FEATURE_MAX_LEN]
enum ast_control_t38_rate_management rate_management
int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control, const void *data, size_t datalen)
Queue a control frame with payload.
struct sip_via * parse_via(const char *header)
Parse a Via header.
#define AST_OPTION_FORMAT_READ
struct ast_set_party_id priv_to
int ast_rtp_codecs_payloads_set_rtpmap_type_rate(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int pt, char *mimetype, char *mimesubtype, enum ast_rtp_options options, unsigned int sample_rate)
Set tx payload type to a known MIME media type for a codec with a specific sample rate...
static int global_authfailureevents
#define SIP_G726_NONSTANDARD
unsigned short answered_elsewhere
static int handle_sip_publish_refresh(struct sip_pvt *p, struct sip_request *req, struct event_state_compositor *esc, const char *const etag, const int expires)
sip_auth: Credentials for authentication to other SIP services
AO2 object that wraps data for transfer_channel_cb.
const ast_string_field regdomain
void ast_iostream_nonblock(struct ast_iostream *stream)
Make an iostream non-blocking.
int ast_sched_wait(struct ast_sched_context *con) attribute_warn_unused_result
Determines number of seconds until the next outstanding event to take place.
const ast_string_field tag
unsigned int flags
Flags for agent operation.
int stasis_subscription_accept_message_type(struct stasis_subscription *subscription, const struct stasis_message_type *type)
Indicate to a subscription that we are interested in a message type.
static int check_rtp_timeout(struct sip_pvt *dialog, time_t t)
helper function for the monitoring thread – seems to be called with the assumption that the dialog i...
int ast_tls_read_conf(struct ast_tls_config *tls_cfg, struct ast_tcptls_session_args *tls_desc, const char *varname, const char *value)
Used to parse conf files containing tls/ssl options.
void ast_udptl_set_tag(struct ast_udptl *udptl, const char *format,...)
Associates a character string 'tag' with a UDPTL session.
void ast_rtp_instance_set_stats_vars(struct ast_channel *chan, struct ast_rtp_instance *instance)
Set standard statistics from an RTP instance on a channel.
int ast_channel_get_device_name(struct ast_channel *chan, char *device_name, size_t name_buffer_length)
Get a device name given its channel structure.
struct stasis_forward * sub
Data structure associated with a single frame of data.
sip_publish_type
The types of PUBLISH messages defined in RFC 3903.
int ast_rtp_instance_get_keepalive(struct ast_rtp_instance *instance)
Get the RTP keepalive interval.
static const struct ast_sip_api_tech chan_sip_api_provider
#define SIP_PAGE3_SRTP_TAG_32
static int esc_etag_counter
static int create_addr(struct sip_pvt *dialog, const char *opeer, struct ast_sockaddr *addr, int newdialog)
create address structure from device name Or, if peer not found, find it in the global DNS returns TR...
Internal Asterisk hangup causes.
void ast_party_redirecting_set_init(struct ast_party_redirecting *init, const struct ast_party_redirecting *guide)
Initialize the given redirecting id structure using the given guide for a set update operation...
static int sip_msg_send(const struct ast_msg *msg, const char *to, const char *from)
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
static void add_tcodec_to_sdp(const struct sip_pvt *p, struct ast_format *format, struct ast_str **m_buf, struct ast_str **a_buf, int debug, int *min_packet_size)
Add text codec offer to SDP offer/answer body in INVITE or 200 OK.
enum ast_srtp_suite suite
enum ast_transport default_outbound_transport
static struct ast_str * hostname
void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value)
const ast_string_field cid_num
static void add_peer_mailboxes(struct sip_peer *peer, const char *value)
const struct ast_flags ast_uri_sip_user
struct sip_pvt * subscription_pvt
struct stasis_message * stasis_cache_get(struct stasis_cache *cache, struct stasis_message_type *type, const char *id)
Retrieve an item from the cache for the ast_eid_default entity.
static void * sip_pickup_thread(void *stuff)
SIP pickup support function Starts in a new thread, then pickup the call.
static int respprep(struct sip_request *resp, struct sip_pvt *p, const char *msg, const struct sip_request *req)
Prepare SIP response packet.
const ast_string_field fromuser
parse_register_result
Results from the parse_register() function.
Structure that represents the optional ICE support within an RTP engine.
static enum parse_register_result parse_register_contact(struct sip_pvt *pvt, struct sip_peer *p, struct sip_request *req)
Parse contact header and save registration (peer registration)
Abstract JSON element (object, array, string, int, ...).
int * ast_io_change(struct io_context *ioc, int *id, int fd, ast_io_cb callback, short events, void *data)
Changes an IO handler.
#define find_call(req, addr, intended_method)
static void start_mwi_subscription(struct sip_subscription_mwi *mwi, int ms)
#define SIP_INSECURE_INVITE
static void clear_peer_mailboxes(struct sip_peer *peer)
#define DEFAULT_SRVLOOKUP
sip_cc_publish_state
The states that can be represented in a SIP call-completion PUBLISH.
static char * get_content(struct sip_request *req)
Get message body content.
static void stop_register_timeout(struct sip_registry *reg)
static int reinvite_timeout(const void *data)
static int restart_monitor(void)
Start the channel monitor thread.
static void forked_invite_init(struct sip_request *req, const char *new_theirtag, struct sip_pvt *original, struct ast_sockaddr *addr)
This function creates a dialog to handle a forked request. This dialog exists only to properly termin...
unsigned int ast_udptl_get_far_max_datagram(const struct ast_udptl *udptl)
#define DEFAULT_QUALIFY_GAP
int sip_report_security_event(const char *peer, struct ast_sockaddr *addr, const struct sip_pvt *p, const struct sip_request *req, const int res)
struct ast_ha * ast_append_ha(const char *sense, const char *stuff, struct ast_ha *path, int *error)
Add a new rule to a list of HAs.
static void update_peer(struct sip_peer *p, int expire)
Update peer data in database (if used)
const char * ast_channel_context(const struct ast_channel *chan)
int ast_db_put(const char *family, const char *key, const char *value)
Store value addressed by family/key.
static int dialog_hash_cb(const void *obj, const int flags)
int error(const char *format,...)
struct stasis_message_type * stasis_subscription_change_type(void)
Gets the message type for subscription change notices.
static int global_rtpholdtimeout
static int rtcp_mux(struct ast_rtp *rtp, const unsigned char *packet)
struct ast_tcptls_session_instance * ast_tcptls_client_start(struct ast_tcptls_session_instance *tcptls_session)
attempts to connect and start tcptls session, on error the tcptls_session's ref count is decremented...
static int sip_scheddestroy_full(struct sip_pvt *p, int ms)
static unsigned int set_pvt_allowed_methods(struct sip_pvt *pvt, struct sip_request *req)
static const struct _map_x_s regstatestrings[]
enum ast_aoc_type ast_aoc_get_msg_type(struct ast_aoc_decoded *decoded)
get the message type, AOC-D, AOC-E, or AOC Request
void ast_rtp_instance_set_prop(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value)
Set the value of an RTP instance property.
static int __sched_check_pendings(const void *data)
const ast_string_field last_presence_subtype
const ast_string_field accountcode
void ast_cc_monitor_unregister(const struct ast_cc_monitor_callbacks *callbacks)
Unregister a set of monitor callbacks with the core.
union ast_frame::@263 data
int ast_wait_for_input(int fd, int ms)
static char default_vmexten[AST_MAX_EXTENSION]
enum ast_transport transport
static const int HASH_REGISTRY_SIZE
const ast_string_field todnid
static const char * get_srv_service(enum ast_transport t)
Return service string for srv dns query.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
static int transmit_response_with_t38_sdp(struct sip_pvt *p, char *msg, struct sip_request *req, int retrans)
Used for 200 OK and 183 early media.
enum ast_frame_type frametype
static int sip_cc_monitor_cancel_available_timer(struct ast_cc_monitor *monitor, int *sched_id)
static int __sip_autodestruct(const void *data)
Kill a SIP dialog (called only by the scheduler) The scheduler has a reference to this dialog when p-...
void * private_data
Data that is private to a monitor technology.
void ast_tcptls_server_stop(struct ast_tcptls_session_args *desc)
Shutdown a running server if there is one.
#define SIP_PAGE2_RTAUTOCLEAR
static int default_sip_port(enum ast_transport type)
The default sip port for the given transport.
struct ast_tls_config * tls_cfg
static char default_notifymime[AST_MAX_EXTENSION]
void ast_channel_queue_redirecting_update(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
Queue a redirecting update frame on a channel.
char domain[MAXHOSTNAMELEN]
void ast_system_publish_registry(const char *channeltype, const char *username, const char *domain, const char *status, const char *cause)
Publish a channel driver outgoing registration message.
static int sip_subscribe_mwi(const char *value, int lineno)
Parse mwi=> line in sip.conf and add to list.
struct ast_xml_doc * ast_xml_read_memory(char *buffer, size_t size)
Open an XML document that resides in memory.
#define SIP_PAGE3_IGNORE_PREFCAPS
struct ast_acl_list * contact_acl
static enum ast_rtp_glue_result sip_get_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)
static unsigned int global_cos_audio
int sip_reqresp_parser_init(void)
initialize request and response parser data
static void add_blank(struct sip_request *req)
add a blank line if no body
struct ast_sockaddr address
int auth_options_requests
static void do_dialog_unlink_sched_items(struct sip_pvt *dialog)
static char * complete_sip_peer(const char *word, int state, int flags2)
Do completion on peer name.
#define AST_CLI_YESNO(x)
Return Yes or No depending on the argument.
#define ast_channel_trylock(chan)
static int send_provisional_keepalive(const void *data)
static void check_for_nat(const struct ast_sockaddr *them, struct sip_pvt *p)
Check and see if the requesting UA is likely to be behind a NAT.
struct ast_str * ast_str_thread_get(struct ast_threadstorage *ts, size_t init_len)
Retrieve a thread locally stored dynamic string.
Callbacks defined by CC monitors.
struct ast_xml_ns * ast_xml_find_namespace(struct ast_xml_doc *doc, struct ast_xml_node *node, const char *ns_name)
struct ast_channel_tech sip_tech
Definition of this channel for PBX channel registration.
unsigned char valid
TRUE if the name information is valid/present.
const ast_string_field qop
struct ast_namedgroups * ast_unref_namedgroups(struct ast_namedgroups *groups)
struct ast_sockaddr local_address
sipregistrystate
States for outbound registrations (with register= lines in sip.conf.
static void mark_method_allowed(unsigned int *allowed_methods, enum sipmethod method)
Search option field mask.
struct ao2_container * dialogs_rtpcheck
static void temp_pvt_cleanup(void *)
void ast_format_duration_hh_mm_ss(int duration, char *buf, size_t length)
Formats a duration into HH:MM:SS.
#define SIP_PAGE2_T38SUPPORT_UDPTL
#define DEFAULT_ACCEPT_OUTOFCALL_MESSAGE
static void set_socket_transport(struct sip_socket *socket, int transport)
void ast_channel_publish_blob(struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
Publish a channel blob message.
static char context[AST_MAX_CONTEXT]
static int check_user(struct sip_pvt *p, struct sip_request *req, int sipmethod, const char *uri, enum xmittype reliable, struct ast_sockaddr *addr)
Find user If we get a match, this will add a reference pointer to the user object, that needs to be unreferenced.
static char * terminate_uri(char *uri)
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
struct ast_tcptls_session_instance * tcptls_session
static int handle_request_options(struct sip_pvt *p, struct sip_request *req, struct ast_sockaddr *addr, const char *e)
Handle incoming OPTIONS request An OPTIONS request should be answered like an INVITE from the same UA...
int ast_rtp_instance_dtmf_end_with_duration(struct ast_rtp_instance *instance, char digit, unsigned int duration)
struct sip_pvt::@174 offered_media
static void append_history_va(struct sip_pvt *p, const char *fmt, va_list ap)
Append to SIP dialog history with arg list.
struct ast_context * ast_context_find_or_create(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *name, const char *registrar)
Register a new context or find an existing one.
int AST_OPTIONAL_API_NAME() ast_websocket_set_nonblock(struct ast_websocket *session)
const char * state_string
struct sip_proxy outboundproxy
static void sip_send_all_registers(void)
Send all known registrations.
struct ast_msg * ast_msg_destroy(struct ast_msg *msg)
Destroy an ast_msg.
const ast_string_field device_name
struct ast_format * format
static int process_sdp_a_text(const char *a, struct sip_pvt *p, struct ast_rtp_codecs *newtextrtp, char *red_fmtp, int *red_num_gen, int *red_data_pt, int *last_rtpmap_codec)
const ast_string_field fromname
void ast_rtp_dtls_cfg_copy(const struct ast_rtp_dtls_cfg *src_cfg, struct ast_rtp_dtls_cfg *dst_cfg)
Copy contents of a DTLS configuration structure.
struct ast_channel_tech sip_tech_info
This version of the sip channel tech has no send_digit_begin callback so that the core knows that the...
struct ast_sdp_srtp * srtp
static int sockaddr_is_null_or_any(const struct ast_sockaddr *addr)
static int peer_ipcmp_cb_full(void *obj, void *arg, void *data, int flags)
void AST_OPTIONAL_API_NAME() ast_websocket_unref(struct ast_websocket *session)
const char * ast_sdp_srtp_get_attrib(struct ast_sdp_srtp *srtp, int dtls_enabled, int default_taglen_32)
Get the crypto attribute line for the srtp structure.
static unsigned int global_cos_sip
const ast_string_field callback
static int __stop_provisional_keepalive(const void *data)
const char * ast_channel_macrocontext(const struct ast_channel *chan)
void ast_set_party_id_all(struct ast_set_party_id *update_id)
Set the update marker to update all information of a corresponding party id.
static struct ast_rtp_dtls_cfg default_dtls_cfg
Default DTLS connection configuration.
void ast_shrink_phone_number(char *n)
Shrink a phone number in place to just digits (more accurately it just removes ()'s, .'s, and -'s...
The structure that contains MWI state.
struct ast_rtp_instance * ast_rtp_instance_new(const char *engine_name, struct ast_sched_context *sched, const struct ast_sockaddr *sa, void *data)
Create a new RTP instance.
static int transmit_response_using_temp(ast_string_field callid, struct ast_sockaddr *addr, int useglobal_nat, const int intended_method, const struct sip_request *req, const char *msg)
Transmit response, no retransmits, using a temporary pvt structure.
static void unlink_marked_peers_from_tables(void)
const ast_string_field description
static int add_content(struct sip_request *req, const char *line)
Add content (not header) to SIP message.
struct ast_app * pbx_findapp(const char *app)
Look up an application.
static int esc_hash_fn(const void *obj, const int flags)
#define ast_manager_register_xml(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
enum ast_cc_service_type service_offered
struct ast_xml_node * ast_xml_node_get_next(struct ast_xml_node *node)
Get the next node in the same level.
void ast_endpoint_shutdown(struct ast_endpoint *endpoint)
Shutsdown an ast_endpoint.
void ast_md5_hash(char *output, const char *input)
Produces MD5 hash based on input string.
enum ast_transport transport
#define ASTERISK_GPL_KEY
The text the key() function should return.
#define DEBUG_ATLEAST(level)
static void update_provisional_keepalive(struct sip_pvt *pvt, int with_sdp)
#define AST_CAUSE_CALL_REJECTED
static unsigned int global_tos_sip
static int parse_session_expires(const char *p_hdrval, int *const p_interval, enum st_refresher_param *const p_ref)
Session-Timers: Function for parsing Session-Expires header.
static int sip_write(struct ast_channel *ast, struct ast_frame *frame)
Send frame to media channel (rtp)
void ast_channel_priority_set(struct ast_channel *chan, int value)
Pluggable RTP Architecture.
char default_context[AST_MAX_CONTEXT]
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
static char * app_sipremoveheader
static void update_redirecting(struct sip_pvt *p, const void *data, size_t datalen)
Send a provisional response indicating that a call was redirected.
void ast_rtp_instance_update_source(struct ast_rtp_instance *instance)
Indicate that the RTP marker bit should be set on an RTP stream.
#define AST_CAUSE_BEARERCAPABILITY_NOTAVAIL
static unsigned int default_primary_transport
struct ast_cc_monitor * ast_cc_get_monitor_by_recall_core_id(const int core_id, const char *const device_name)
Get the associated monitor given the device name and core_id.
static int add_header(struct sip_request *req, const char *var, const char *value)
Add header to SIP message.
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
Asterisk module definitions.
static void network_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
enum st_refresher_param st_ref
void(* destructor)(void *instance_data)
#define CHECK_AUTH_BUF_INITLEN
static void shutdown_mwi_subscription(struct sip_subscription_mwi *mwi)
ast_websocket_opcode
WebSocket operation codes.
static int process_sdp_a_image(const char *a, struct sip_pvt *p)
struct ast_exten * pbx_find_extension(struct ast_channel *chan, struct ast_context *bypass, struct pbx_find_info *q, const char *context, const char *exten, int priority, const char *label, const char *callerid, enum ext_match_t action)
char * ast_print_namedgroups(struct ast_str **buf, struct ast_namedgroups *groups)
Print named call groups and named pickup groups.
static char * sip_show_domains(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command to list local domains.
static int transmit_response_with_unsupported(struct sip_pvt *p, const char *msg, const struct sip_request *req, const char *unsupported)
Transmit response, no retransmits.
struct ast_mwi_subscriber * ast_mwi_subscribe_pool(const char *mailbox, stasis_subscription_cb callback, void *data)
Add an MWI state subscriber, and stasis subscription to the mailbox.
static snd_pcm_format_t format
static void set_peer_nat(const struct sip_pvt *p, struct sip_peer *peer)
Set the peers nat flags if they are using auto_* settings.
enum ast_cc_agent_policies ast_get_cc_agent_policy(struct ast_cc_config_params *config)
Get the cc_agent_policy.
struct ast_dnsmgr_entry * dnsmgr
static int global_rtpkeepalive
struct ao2_container * compositor
long max_size
Max size of the jitterbuffer implementation.
static int find_sip_monitor_instance_by_subscription_pvt(void *obj, void *arg, int flags)
static int add_vidupdate(struct sip_request *req)
add XML encoded media control with update
Persistant data storage (akin to *doze registry)
#define ast_rtp_instance_get_remote_address(instance, address)
Get the address of the remote endpoint that we are sending RTP to.
const char * ast_tos2str(unsigned int tos)
Convert a TOS value into its string representation.
char realm[MAXHOSTNAMELEN]
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
The SIP socket definition.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
static pthread_t monitor_thread
This is the thread for the monitor which checks for input on the channels which are not currently in ...
static const struct _map_x_s referstatusstrings[]
#define SIP_PAGE2_DIALOG_ESTABLISHED
#define DEFAULT_DEFAULT_EXPIRY
const ast_string_field url
const ast_string_field cid_tag
void ast_udptl_setnat(struct ast_udptl *udptl, int nat)
static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_rtp_instance *vinstance, struct ast_rtp_instance *tinstance, const struct ast_format_cap *cap, int nat_active)
const ast_string_field refer_to_domain
static void sip_pvt_dtor(void *vdoomed)
ao2 destructor for SIP dialog structure
static int sip_cc_agent_start_monitoring(struct ast_cc_agent *agent)
#define DEFAULT_CALLCOUNTER
#define DEFAULT_COS_VIDEO
char context[AST_MAX_EXTENSION]
static char * sip_show_peer(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Show one peer in detail.
static int __update_provisional_keepalive_with_sdp(const void *data)
struct ast_variable * ast_variables_dup(struct ast_variable *var)
Duplicate variable list.
const ast_string_field engine
char regcontext[AST_MAX_CONTEXT]
static int handle_request_invite_st(struct sip_pvt *p, struct sip_request *req, int reinvite)
Container of SIP authentication credentials.
static void on_dns_update_mwi(struct ast_sockaddr *old, struct ast_sockaddr *new, void *data)
const esc_publish_callback refresh_handler
unsigned char valid
TRUE if the number information is valid/present.
static const char * sip_nat_mode(const struct sip_pvt *p)
Display SIP nat mode.
#define ast_rtp_instance_get_and_cmp_remote_address(instance, address)
Get the address of the remote endpoint that we are sending RTP to, comparing its address to another...
static int global_relaxdtmf
const char * sip_route_first_uri(const struct sip_route *route)
Get the URI of the route's first hop.
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
General jitterbuffer configuration.
#define SDP_MAX_RTPMAP_CODECS
static const int ESC_MAX_BUCKETS
void ast_channel_hangupcause_hash_set(struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen)
Sets the HANGUPCAUSE hash and optionally the SIP_CAUSE hash on the given channel. ...
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
static int st_get_se(struct sip_pvt *, int max)
Get Max or Min SE (session timer expiry)
struct ast_variable * chanvars
void ast_rtp_codecs_payloads_set_m_type(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload)
Record tx payload type information that was seen in an m= SDP line.
void ast_sched_context_destroy(struct ast_sched_context *c)
destroys a schedule context
#define ast_custom_function_register(acf)
Register a custom function.
a place to store all global settings for the sip channel driver
int websocket_write_timeout
static void sip_peer_hold(struct sip_pvt *p, int hold)
Change onhold state of a peer using a pvt structure.
const ast_string_field subscribeuri
unsigned int parse_sip_options(const char *options, char *unsupported, size_t unsupported_len)
Parse supported header in incoming packet.
static char * sip_show_peers(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI Show Peers command.
#define AST_CAUSE_CONGESTION
void sip_scheddestroy(struct sip_pvt *p, int ms)
Schedule destruction of SIP dialog.
int ast_sockaddr_is_ipv6(const struct ast_sockaddr *addr)
Determine if this is an IPv6 address.
#define SIP_PAGE2_T38SUPPORT_UDPTL_REDUNDANCY
#define SIP_PROGRESS_SENT
static int cc_esc_publish_handler(struct sip_pvt *pvt, struct sip_request *req, struct event_state_compositor *esc, struct sip_esc_entry *esc_entry)
static const char * subscription_type2str(enum subscriptiontype subtype) attribute_pure
Show subscription type in string format.
#define AST_MUTEX_DEFINE_STATIC(mutex)
static void sip_set_redirstr(struct sip_pvt *p, char *reason)
Translate referring cause.
static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, struct ast_sockaddr *addr, uint32_t seqno, int *recount, const char *e, int *nounlock)
Handle incoming INVITE request.
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
int ast_cc_monitor_callee_available(const int core_id, const char *const debug,...)
Alert the core that a device being monitored has become available.
#define SIP_PAGE2_RPID_UPDATE
struct ast_xml_node * ast_xml_node_get_children(struct ast_xml_node *node)
Get the node's children.
static const char config[]
static int __sip_cancel_destroy(const void *data)
static const char * dtmfmode2str(int mode) attribute_const
Convert DTMF mode to printable string.
const char * ast_xml_node_get_name(struct ast_xml_node *node)
Get the name of a node.
const ast_string_field uri
struct sip_proxy * outboundproxy
sip_history: Structure for saving transactions within a SIP dialog
int ast_dsp_set_digitmode(struct ast_dsp *dsp, int digitmode)
Set digit mode.
subscriptiontype
Type of subscription, based on the packages we do support, see subscription_types.
static force_inline int attribute_pure ast_str_case_hash(const char *str)
Compute a hash value on a case-insensitive string.
char hostname[MAXHOSTNAMELEN]
int ast_dnsmgr_lookup_cb(const char *name, struct ast_sockaddr *result, struct ast_dnsmgr_entry **dnsmgr, const char *service, dns_update_func func, void *data)
Allocate and initialize a DNS manager entry, with update callback.
static int process_sdp_c(const char *c, struct ast_sockaddr *addr)
#define AST_OPTION_T38_STATE
const char * ast_presence_state2str(enum ast_presence_state state)
Convert presence state to text string for output.
#define DEFAULT_SDPSESSION
static int ast_sockaddr_resolve_first_transport(struct ast_sockaddr *addr, const char *name, int flag, unsigned int transport)
Return the first entry from ast_sockaddr_resolve filtered by family of binddaddr. ...
struct ast_frame * ast_rtp_instance_read(struct ast_rtp_instance *instance, int rtcp)
Receive a frame over RTP.
Structure to handle SIP transfers. Dynamically allocated when needed.
static int sip_tcptls_write(struct ast_tcptls_session_instance *tcptls_session, const void *buf, size_t len)
used to indicate to a tcptls thread that data is ready to be written
void ast_xml_free_text(const char *text)
Free a content element that was returned by ast_xml_get_text()
const ast_string_field okcontacturi
static int read_raw_content_length(const char *message)
Get the content length from an unparsed SIP message.
#define SIP_PAGE2_TRUST_ID_OUTBOUND_LEGACY
void ast_manager_publish_event(const char *type, int class_type, struct ast_json *obj)
Publish an event to AMI.
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...
static void handle_response_refer(struct sip_pvt *p, int resp, const char *rest, struct sip_request *req, uint32_t seqno)
static int global_qualify_peers
static char vmexten[AST_MAX_EXTENSION]
static struct ast_custom_function checksipdomain_function
DTLS configuration structure.
static int global_prematuremediafilter
static int parse_uri_legacy_check(char *uri, const char *scheme, char **user, char **pass, char **hostport, char **transport)
parse uri in a way that allows semicolon stripping if legacy mode is enabled
struct sip_notify * notify
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
int ast_app_inboxcount(const char *mailboxes, int *newmsgs, int *oldmsgs)
Determine number of new/old messages in a mailbox.
#define ast_mutex_unlock(a)
int ast_sockaddr_resolve(struct ast_sockaddr **addrs, const char *str, int flags, int family)
Parses a string with an IPv4 or IPv6 address and place results into an array.
static int process_via(struct sip_pvt *p, const struct sip_request *req)
Process the Via header according to RFC 3261 section 18.2.2.
static const char * strefresher2str(enum st_refresher r)
static int parse_ok_contact(struct sip_pvt *pvt, struct sip_request *req)
Save contact header for 200 OK on INVITE.
Configuration relating to call pickup.
const ast_string_field context
static const struct _map_x_s stmodes[]
Report Peer status in character string.
static char prefix[MAX_PREFIX]
unsigned short natdetected
#define AST_APP_ARG(name)
Define an application argument.
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
static int transmit_info_with_vidupdate(struct sip_pvt *p)
Send SIP INFO with video update request.
struct ast_sockaddr remote_address
#define SIP_MAX_PACKET_SIZE
static int sipsock_read(int *id, int fd, short events, void *ignore)
Read data from SIP UDP socket.
int ast_callerid_parse(char *instr, char **name, char **location)
Destructively parse inbuf into name and location (or number)
#define SIP_PAGE3_USE_AVPF
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Channels have this property if they can create jitter; i.e. most VoIP channels.
static void sip_keepalive_all_peers(void)
Send a keepalive to all known peers.
static int sip_cc_agent_init(struct ast_cc_agent *agent, struct ast_channel *chan)
static int block_msg_header(const char *header_name)
#define DEFAULT_FREQ_NOTOK
static void peer_mailboxes_to_str(struct ast_str **mailbox_str, struct sip_peer *peer)
list peer mailboxes to CLI
void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag)
Send ack in manager transaction to begin a list.
const ast_string_field configvalue
Structure that encapsulates all attributes related to running SIP Session-Timers feature on a per dia...
enum sip_mailbox_status status
struct ast_party_number number
Subscriber phone number.
void(* ice_lite)(struct ast_rtp_instance *instance)
#define AST_MAX_USER_FIELD
const ast_string_field rdnis
#define ast_module_ref(mod)
Hold a reference to the module.
struct sip_auth_container * peerauth
#define ao2_link(container, obj)
static void display_nat_warning(const char *cat, int reason, struct ast_flags *flags)
struct io_context * io_context_create(void)
Creates a context Create a context for I/O operations Basically mallocs an IO structure and sets up s...
struct ast_msg_var_iterator * ast_msg_var_iterator_init(const struct ast_msg *msg)
Create a new message variable iterator.
unsigned int disallowed_methods
static int parse_minse(const char *p_hdrval, int *const p_interval)
Session-Timers: Function for parsing Min-SE header.
const ast_string_field our_contact
static void mark_method_unallowed(unsigned int *allowed_methods, enum sipmethod method)
static void cc_epa_destructor(void *data)