chan_sip: Remove deprecated module.

ASTERISK-30297

Change-Id: Ic700168c80b68879d9cee8bb07afe2712fb17996
This commit is contained in:
Mike Bradeen 2022-11-28 13:05:21 -07:00 committed by George Joseph
parent e66c5da145
commit 4095a382da
80 changed files with 177 additions and 45491 deletions

View File

@ -66,7 +66,7 @@ OPTIMIZE?=-O3
ifneq ($(findstring darwin,$(OSARCH)),)
ifeq ($(shell if test `/usr/bin/sw_vers -productVersion | cut -c4` -gt 5; then echo 6; else echo 0; fi),6)
# Snow Leopard/Lion has an issue with this optimization flag on large files (like chan_sip)
# Snow Leopard/Lion has an issue with this optimization flag on large files
OPTIMIZE+=-fno-inline-functions
endif
endif

View File

@ -52,28 +52,28 @@ request.
```INI
[incoming]
exten => _X.,1,Verbose(2,Incoming call to extension ${EXTEN})
exten => _X.,n,Dial(SIP/${EXTEN})
exten => _X.,n,Dial(PJSIP/${EXTEN})
exten => _X.,n,Hangup()
```
This dialplan may be utilized to accept calls to extensions, which then dial a
numbered device name configured in one of the channel configuration files (such
as sip.conf, iax.conf, etc...) (see [Proper Device Naming] for more information
as pjsip.conf, iax.conf, etc...) (see [Proper Device Naming] for more information
on why this approach is flawed).
The example we've given above looks harmless enough until you take into
consideration that several channel technologies accept characters that could
be utilized in a clever attack. For example, instead of just sending a request
to dial extension 500 (which in our example above would create the string
SIP/500 and is then used by the Dial() application to place a call), someone
could potentially send a string like "500&SIP/itsp/14165551212".
PJSIP/500 and is then used by the Dial() application to place a call), someone
could potentially send a string like "500&PJSIP/itsp/14165551212".
The string "500&SIP/itsp/14165551212" would then be contained within the
The string "500&PJSIP/itsp/14165551212" would then be contained within the
${EXTEN} channel variable, which is then utilized by the Dial() application in
our example, thereby giving you the dialplan line of:
```INI
exten => _X.,n,Dial(SIP/500&SIP/itsp/14165551212)
exten => _X.,n,Dial(PJSIP/500&PJSIP/itsp/14165551212)
```
Our example above has now provided someone with a method to place calls out of
@ -98,7 +98,7 @@ to only accept three digit extensions, we could change our pattern match to
be:
```INI
exten => _XXX,n,Dial(SIP/${EXTEN})
exten => _XXX,n,Dial(PJSIP/${EXTEN})
```
In this way, we have minimized our impact because we're not allowing anything
@ -124,7 +124,7 @@ we will accept to just numbers. Our example would then change to something like:
```INI
[incoming]
exten => _X.,1,Verbose(2,Incoming call to extension ${EXTEN})
exten => _X.,n,Dial(SIP/${FILTER(0-9,${EXTEN})})
exten => _X.,n,Dial(PJSIP/${FILTER(0-9,${EXTEN})})
exten => _X.,n,Hangup()
```
@ -141,7 +141,7 @@ necessary, and to handle error checking in a separate location.
[incoming]
exten => _X.,1,Verbose(2,Incoming call to extension ${EXTEN})
exten => _X.,n,Set(SAFE_EXTEN=${FILTER(0-9,${EXTEN})})
exten => _X.,n,Dial(SIP/${SAFE_EXTEN})
exten => _X.,n,Dial(PJSIP/${SAFE_EXTEN})
exten => _X.,n,Hangup()
```
@ -155,7 +155,7 @@ passed back by FILTER(), and to fail the call if things do not match.
exten => _X.,1,Verbose(2,Incoming call to extension ${EXTEN})
exten => _X.,n,Set(SAFE_EXTEN=${FILTER(0-9,${EXTEN})})
exten => _X.,n,GotoIf($[${EXTEN} != ${SAFE_EXTEN}]?error,1)
exten => _X.,n,Dial(SIP/${SAFE_EXTEN})
exten => _X.,n,Dial(PJSIP/${SAFE_EXTEN})
exten => _X.,n,Hangup()
exten => error,1,Verbose(2,Values of EXTEN and SAFE_EXTEN did not match.)
@ -170,7 +170,7 @@ we're expecting to get a SIP URI for dialing.
```INI
[incoming]
exten => _[0-9a-zA-Z].,1,Verbose(2,Incoming call to extension ${EXTEN})
exten => _[0-9a-zA-Z].,n,Dial(SIP/${FILTER(.@0-9a-zA-Z,${EXTEN})
exten => _[0-9a-zA-Z].,n,Dial(PJSIP/${FILTER(.@0-9a-zA-Z,${EXTEN})
exten => _[0-9a-zA-Z].,n,Hangup()
```
@ -201,13 +201,14 @@ It can also be a security hazard to name your devices with a number, as this can
open you up to brute force attacks. Many of the current exploits deal with
device configurations which utilize a number, and even worse, a password that
matches the devices name. For example, take a look at this poorly created device
in sip.conf:
in pjsip.conf:
```INI
[1000]
type=friend
context=international_dialing
secret=1000
type=auth
auth_type=userpass
password=1000
username=1000
```
As implied by the context, we've permitted a device named 1000 with a password
@ -223,9 +224,10 @@ Passwords). The following example would be more secure:
```INI
[0004f2040001]
type=friend
context=international_dialing
secret=aE3%B8*$jk^G
type=auth
auth_type=userpass
password=aE3%B8*$jk^G
username=0004f2040001
```
Then in your dialplan, you would reference the device via the MAC address of the
@ -323,7 +325,7 @@ the Originate manager command:
```
Action: Originate
Channel: SIP/foo
Channel: PJSIP/foo
Exten: s
Context: default
Priority: 1
@ -340,7 +342,7 @@ circumvent these checks. For example, take the following dialplan:
```INI
exten => s,1,Verbose(Incoming call)
same => n,MixMonitor(foo.wav,,${EXEC_COMMAND})
same => n,Dial(SIP/bar)
same => n,Dial(PJSIP/bar)
same => n,Hangup()
```

View File

@ -3248,7 +3248,7 @@ static char *handle_cli_ooh323_show_peer(struct ast_cli_entry *e, int cmd, struc
if (peer->t38support == T38_DISABLED) {
ast_cli(a->fd, "%s\n", "disabled");
} else if (peer->t38support == T38_FAXGW) {
ast_cli(a->fd, "%s\n", "faxgw/chan_sip compatible");
ast_cli(a->fd, "%s\n", "faxgw compatible");
}
if (peer->faxdetect == (FAXDETECT_CNG | FAXDETECT_T38)) {
ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "Yes");
@ -3386,7 +3386,7 @@ static char *handle_cli_ooh323_show_user(struct ast_cli_entry *e, int cmd, struc
if (user->t38support == T38_DISABLED) {
ast_cli(a->fd, "%s\n", "disabled");
} else if (user->t38support == T38_FAXGW) {
ast_cli(a->fd, "%s\n", "faxgw/chan_sip compatible");
ast_cli(a->fd, "%s\n", "faxgw compatible");
}
if (user->faxdetect == (FAXDETECT_CNG | FAXDETECT_T38)) {
ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "Yes");
@ -3633,7 +3633,7 @@ static char *handle_cli_ooh323_show_config(struct ast_cli_entry *e, int cmd, str
if (gT38Support == T38_DISABLED) {
ast_cli(a->fd, "%s\n", "disabled");
} else if (gT38Support == T38_FAXGW) {
ast_cli(a->fd, "%s\n", "faxgw/chan_sip compatible");
ast_cli(a->fd, "%s\n", "faxgw compatible");
}
if (gFAXdetect == (FAXDETECT_CNG | FAXDETECT_T38)) {
ast_cli(a->fd,"%-20s%s\n", "FAX Detect:", "Yes");

View File

@ -401,8 +401,6 @@
to send no cause. See the <filename>causes.h</filename> file for the
full list of valid causes and names.
</para>
<para>NOTE: chan_sip does not support setting the cause on a CANCEL to anything
other than ANSWERED_ELSEWHERE.</para>
</option>
<option name="r">
<para>Default: Indicate ringing to the calling party, even if the called party isn't actually ringing. Pass no audio to the calling

View File

@ -113,8 +113,7 @@
</para>
<note><para>The text encoding and transmission method is completely at the
discretion of the channel driver. chan_pjsip will use in-dialog SIP MESSAGE
messages always. chan_sip will use T.140 via RTP if a text media type was
negotiated and in-dialog SIP MESSAGE messages otherwise.</para></note>
messages always.</para></note>
<para>
</para>
<para>Examples:

View File

@ -26,13 +26,11 @@ endif
$(call MOD_ADD_C,chan_iax2,$(wildcard iax2/*.c))
iax2/parser.o: _ASTCFLAGS+=$(call get_menuselect_cflags,MALLOC_DEBUG)
$(call MOD_ADD_C,chan_sip,$(wildcard sip/*.c))
$(call MOD_ADD_C,chan_pjsip,$(wildcard pjsip/*.c))
$(call MOD_ADD_C,chan_dahdi,$(wildcard dahdi/*.c) sig_analog.c sig_pri.c sig_ss7.c)
chan_dahdi.o: _ASTCFLAGS+=$(call get_menuselect_cflags,LOTS_OF_SPANS)
chan_unistim.o: _ASTCFLAGS+=$(AST_NO_FORMAT_TRUNCATION)
chan_phone.o: _ASTCFLAGS+=$(AST_NO_FORMAT_TRUNCATION)
chan_sip.o: _ASTCFLAGS+=$(AST_NO_FORMAT_TRUNCATION)
$(call MOD_ADD_C,console_video.c vgrabbers.c console_board.c)

File diff suppressed because it is too large Load Diff

View File

@ -99,14 +99,20 @@ if the formats are equivalent. This will save some unnecessary format
conversion.
In order to handle video you need to add to sip.conf (and presumably
iax.conf too) the following:
In order to handle video you need to add the following to the endpoint in
pjsip.conf
[general](+)
videosupport=yes
allow=h263 ; this or other video formats
allow=h263p ; this or other video formats
(Presumably, iax.conf would require):
[general](+)
videosupport=yes
allow=h263 ; this or other video formats
allow=h263p ; this or other video formats
*/
/*

View File

@ -1,927 +0,0 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2010, Digium, Inc.
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*!
* \file
* \brief sip config parsing functions and unit tests
*/
/*** MODULEINFO
<support_level>deprecated</support_level>
***/
#include "asterisk.h"
#include "include/sip.h"
#include "include/config_parser.h"
#include "include/sip_utils.h"
/*! \brief Parse register=> line in sip.conf
*
* \retval 0 on success
* \retval -1 on failure
*/
int sip_parse_register_line(struct sip_registry *reg, int default_expiry, const char *value, int lineno)
{
int portnum = 0;
int domainport = 0;
enum ast_transport transport = AST_TRANSPORT_UDP;
char buf[256] = "";
char *userpart = NULL, *hostpart = NULL;
/* register => [peer?][transport://]user[@domain][:secret[:authuser]]@host[:port][/extension][~expiry] */
AST_DECLARE_APP_ARGS(pre1,
AST_APP_ARG(peer);
AST_APP_ARG(userpart);
);
AST_DECLARE_APP_ARGS(pre2,
AST_APP_ARG(transport);
AST_APP_ARG(blank);
AST_APP_ARG(userpart);
);
AST_DECLARE_APP_ARGS(user1,
AST_APP_ARG(userpart);
AST_APP_ARG(secret);
AST_APP_ARG(authuser);
);
AST_DECLARE_APP_ARGS(user2,
AST_APP_ARG(user);
AST_APP_ARG(domain);
);
AST_DECLARE_APP_ARGS(user3,
AST_APP_ARG(authuser);
AST_APP_ARG(domainport);
);
AST_DECLARE_APP_ARGS(host1,
AST_APP_ARG(hostpart);
AST_APP_ARG(expiry);
);
AST_DECLARE_APP_ARGS(host2,
AST_APP_ARG(hostpart);
AST_APP_ARG(extension);
);
AST_DECLARE_APP_ARGS(host3,
AST_APP_ARG(host);
AST_APP_ARG(port);
);
if (!reg) {
return -1;
}
reg->expire = -1;
reg->timeout = -1;
if (!value) {
return -1;
}
ast_copy_string(buf, value, sizeof(buf));
/*
* register => [peer?][transport://]user[@domain][:secret[:authuser]]@host[:port][/extension][~expiry]
* becomes
* userpart => [peer?][transport://]user[@domain][:secret[:authuser]]
* hostpart => host[:port][/extension][~expiry]
*/
if ((hostpart = strrchr(buf, '@'))) {
*hostpart++ = '\0';
userpart = buf;
}
if (ast_strlen_zero(userpart) || ast_strlen_zero(hostpart)) {
ast_log(LOG_WARNING, "Format for registration is [peer?][transport://]user[@domain][:secret[:authuser]]@host[:port][/extension][~expiry] at line %d\n", lineno);
return -1;
}
/*
* pre1.peer => peer
* pre1.userpart => [transport://]user[@domain][:secret[:authuser]]
* hostpart => host[:port][/extension][~expiry]
*/
AST_NONSTANDARD_RAW_ARGS(pre1, userpart, '?');
if (ast_strlen_zero(pre1.userpart)) {
pre1.userpart = pre1.peer;
pre1.peer = NULL;
}
/*
* pre1.peer => peer
* pre2.transport = transport
* pre2.userpart => user[@domain][:secret[:authuser]]
* hostpart => host[:port][/extension][~expiry]
*/
AST_NONSTANDARD_RAW_ARGS(pre2, pre1.userpart, '/');
if (ast_strlen_zero(pre2.userpart)) {
pre2.userpart = pre2.transport;
pre2.transport = NULL;
} else {
pre2.transport[strlen(pre2.transport) - 1] = '\0'; /* Remove trailing : */
}
if (!ast_strlen_zero(pre2.blank)) {
ast_log(LOG_WARNING, "Format for registration is [peer?][transport://]user[@domain][:secret[:authuser]]@host[:port][/extension][~expiry] at line %d\n", lineno);
return -1;
}
/*
* pre1.peer => peer
* pre2.transport = transport
* user1.userpart => user[@domain]
* user1.secret => secret
* user1.authuser => authuser
* hostpart => host[:port][/extension][~expiry]
*/
AST_NONSTANDARD_RAW_ARGS(user1, pre2.userpart, ':');
/*
* pre1.peer => peer
* pre2.transport = transport
* user1.userpart => user[@domain]
* user1.secret => secret
* user1.authuser => authuser
* host1.hostpart => host[:port][/extension]
* host1.expiry => [expiry]
*/
AST_NONSTANDARD_RAW_ARGS(host1, hostpart, '~');
/*
* pre1.peer => peer
* pre2.transport = transport
* user1.userpart => user[@domain]
* user1.secret => secret
* user1.authuser => authuser
* host2.hostpart => host[:port]
* host2.extension => [extension]
* host1.expiry => [expiry]
*/
AST_NONSTANDARD_RAW_ARGS(host2, host1.hostpart, '/');
/*
* pre1.peer => peer
* pre2.transport = transport
* user1.userpart => user[@domain]
* user1.secret => secret
* user1.authuser => authuser
* host3.host => host
* host3.port => port
* host2.extension => extension
* host1.expiry => expiry
*/
AST_NONSTANDARD_RAW_ARGS(host3, host2.hostpart, ':');
/*
* pre1.peer => peer
* pre2.transport = transport
* user2.user => user
* user2.domain => domain
* user1.secret => secret
* user1.authuser => authuser
* host3.host => host
* host3.port => port
* host2.extension => extension
* host1.expiry => expiry
*/
AST_NONSTANDARD_RAW_ARGS(user2, user1.userpart, '@');
/*
* pre1.peer => peer
* pre2.transport = transport
* user2.user => user
* user2.domain => domain
* user1.secret => secret
* user3.authuser => authuser
* user3.domainport => domainport
* host3.host => host
* host3.port => port
* host2.extension => extension
* host1.expiry => expiry
*/
AST_NONSTANDARD_RAW_ARGS(user3, user1.authuser, ':');
/* Reordering needed due to fields being [(:secret[:username])|(:regdomainport:secret:username)]
but parsing being [secret[:username[:regdomainport]]] */
if (user3.argc == 2) {
char *reorder = user3.domainport;
user3.domainport = user1.secret;
user1.secret = user3.authuser;
user3.authuser = reorder;
}
if (host3.port) {
if (!(portnum = port_str2int(host3.port, 0))) {
ast_log(LOG_NOTICE, "'%s' is not a valid port number on line %d of sip.conf. using default.\n", host3.port, lineno);
}
}
if (user3.domainport) {
if (!(domainport = port_str2int(user3.domainport, 0))) {
ast_log(LOG_NOTICE, "'%s' is not a valid domain port number on line %d of sip.conf. using default.\n", user3.domainport, lineno);
}
}
/* set transport type */
if (!pre2.transport) {
transport = AST_TRANSPORT_UDP;
} else if (!strncasecmp(pre2.transport, "tcp", 3)) {
transport = AST_TRANSPORT_TCP;
} else if (!strncasecmp(pre2.transport, "tls", 3)) {
transport = AST_TRANSPORT_TLS;
} else if (!strncasecmp(pre2.transport, "udp", 3)) {
transport = AST_TRANSPORT_UDP;
} else {
transport = AST_TRANSPORT_UDP;
ast_log(LOG_NOTICE, "'%.3s' is not a valid transport type on line %d of sip.conf. defaulting to udp.\n", pre2.transport, lineno);
}
/* if no portnum specified, set default for transport */
if (!portnum) {
if (transport == AST_TRANSPORT_TLS) {
portnum = STANDARD_TLS_PORT;
} else {
portnum = STANDARD_SIP_PORT;
}
}
/* copy into sip_registry object */
ast_string_field_set(reg, callback, ast_strip_quoted(S_OR(host2.extension, "s"), "\"", "\""));
ast_string_field_set(reg, username, ast_strip_quoted(S_OR(user2.user, ""), "\"", "\""));
ast_string_field_set(reg, hostname, ast_strip_quoted(S_OR(host3.host, ""), "\"", "\""));
ast_string_field_set(reg, authuser, ast_strip_quoted(S_OR(user3.authuser, ""), "\"", "\""));
ast_string_field_set(reg, secret, ast_strip_quoted(S_OR(user1.secret, ""), "\"", "\""));
ast_string_field_set(reg, peername, ast_strip_quoted(S_OR(pre1.peer, ""), "\"", "\""));
ast_string_field_set(reg, regdomain, ast_strip_quoted(S_OR(user2.domain, ""), "\"", "\""));
reg->transport = transport;
reg->portno = portnum;
reg->regdomainport = domainport;
reg->callid_valid = FALSE;
reg->ocseq = INITIAL_CSEQ;
reg->refresh = reg->expiry = reg->configured_expiry = (host1.expiry ? atoi(ast_strip_quoted(host1.expiry, "\"", "\"")) : default_expiry);
return 0;
}
#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(sip_parse_register_line_test)
{
int res = AST_TEST_PASS;
struct sip_registry *reg;
int default_expiry = 120;
const char *reg1 = "name@domain";
const char *reg2 = "name:pass@domain";
const char *reg3 = "name@namedomain:pass:authuser@domain";
const char *reg4 = "name@namedomain:pass:authuser@domain/extension";
const char *reg5 = "tcp://name@namedomain:pass:authuser@domain/extension";
const char *reg6 = "tls://name@namedomain:pass:authuser@domain/extension~111";
const char *reg7 = "peer?tcp://name@namedomain:pass:authuser@domain:1234/extension~111";
const char *reg8 = "peer?name@namedomain:pass:authuser@domain:1234/extension~111";
const char *reg9 = "peer?name:pass:authuser:1234/extension~111";
const char *reg10 = "@domin:1234";
const char *reg12 = "name@namedomain:4321:pass:authuser@domain";
const char *reg13 = "name@namedomain:4321::@domain";
switch (cmd) {
case TEST_INIT:
info->name = "sip_parse_register_line_test";
info->category = "/channels/chan_sip/";
info->summary = "tests sip register line parsing";
info->description =
"Tests parsing of various register line configurations. "
"Verifies output matches expected behavior.";
return AST_TEST_NOT_RUN;
case TEST_EXECUTE:
break;
}
/* ---Test reg 1, simple config --- */
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
goto alloc_fail;
} else if (
sip_parse_register_line(reg, default_expiry, reg1, 1) ||
strcmp(reg->callback, "s") ||
strcmp(reg->username, "name") ||
strcmp(reg->regdomain, "") ||
strcmp(reg->hostname, "domain") ||
strcmp(reg->authuser, "") ||
strcmp(reg->secret, "") ||
strcmp(reg->peername, "") ||
reg->transport != AST_TRANSPORT_UDP ||
reg->timeout != -1 ||
reg->expire != -1 ||
reg->refresh != default_expiry ||
reg->expiry != default_expiry ||
reg->configured_expiry != default_expiry ||
reg->portno != STANDARD_SIP_PORT ||
(reg->regdomainport) ||
reg->callid_valid != FALSE ||
reg->ocseq != INITIAL_CSEQ) {
ast_test_status_update(test, "Test 1: simple config failed\n");
res = AST_TEST_FAIL;
}
ast_string_field_free_memory(reg);
ast_free(reg);
/* ---Test reg 2, add secret --- */
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
goto alloc_fail;
} else if (
sip_parse_register_line(reg, default_expiry, reg2, 1) ||
strcmp(reg->callback, "s") ||
strcmp(reg->username, "name") ||
strcmp(reg->regdomain, "") ||
strcmp(reg->hostname, "domain") ||
strcmp(reg->authuser, "") ||
strcmp(reg->secret, "pass") ||
strcmp(reg->peername, "") ||
reg->transport != AST_TRANSPORT_UDP ||
reg->timeout != -1 ||
reg->expire != -1 ||
reg->refresh != default_expiry ||
reg->expiry != default_expiry ||
reg->configured_expiry != default_expiry ||
reg->portno != STANDARD_SIP_PORT ||
(reg->regdomainport) ||
reg->callid_valid != FALSE ||
reg->ocseq != INITIAL_CSEQ) {
ast_test_status_update(test, "Test 2: add secret failed\n");
res = AST_TEST_FAIL;
}
ast_string_field_free_memory(reg);
ast_free(reg);
/* ---Test reg 3, add userdomain and authuser --- */
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
goto alloc_fail;
} else if (
sip_parse_register_line(reg, default_expiry, reg3, 1) ||
strcmp(reg->callback, "s") ||
strcmp(reg->username, "name") ||
strcmp(reg->regdomain, "namedomain") ||
strcmp(reg->hostname, "domain") ||
strcmp(reg->authuser, "authuser") ||
strcmp(reg->secret, "pass") ||
strcmp(reg->peername, "") ||
reg->transport != AST_TRANSPORT_UDP ||
reg->timeout != -1 ||
reg->expire != -1 ||
reg->refresh != default_expiry ||
reg->expiry != default_expiry ||
reg->configured_expiry != default_expiry ||
reg->portno != STANDARD_SIP_PORT ||
(reg->regdomainport) ||
reg->callid_valid != FALSE ||
reg->ocseq != INITIAL_CSEQ) {
ast_test_status_update(test, "Test 3: add userdomain and authuser failed\n");
res = AST_TEST_FAIL;
}
ast_string_field_free_memory(reg);
ast_free(reg);
/* ---Test reg 4, add callback extension --- */
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
goto alloc_fail;
} else if (
sip_parse_register_line(reg, default_expiry, reg4, 1) ||
strcmp(reg->callback, "extension") ||
strcmp(reg->username, "name") ||
strcmp(reg->regdomain, "namedomain") ||
strcmp(reg->hostname, "domain") ||
strcmp(reg->authuser, "authuser") ||
strcmp(reg->secret, "pass") ||
strcmp(reg->peername, "") ||
reg->transport != AST_TRANSPORT_UDP ||
reg->timeout != -1 ||
reg->expire != -1 ||
reg->refresh != default_expiry ||
reg->expiry != default_expiry ||
reg->configured_expiry != default_expiry ||
reg->portno != STANDARD_SIP_PORT ||
(reg->regdomainport) ||
reg->callid_valid != FALSE ||
reg->ocseq != INITIAL_CSEQ) {
ast_test_status_update(test, "Test 4: add callback extension failed\n");
res = AST_TEST_FAIL;
}
ast_string_field_free_memory(reg);
ast_free(reg);
/* ---Test reg 5, add transport --- */
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
goto alloc_fail;
} else if (
sip_parse_register_line(reg, default_expiry, reg5, 1) ||
strcmp(reg->callback, "extension") ||
strcmp(reg->username, "name") ||
strcmp(reg->regdomain, "namedomain") ||
strcmp(reg->hostname, "domain") ||
strcmp(reg->authuser, "authuser") ||
strcmp(reg->secret, "pass") ||
strcmp(reg->peername, "") ||
reg->transport != AST_TRANSPORT_TCP ||
reg->timeout != -1 ||
reg->expire != -1 ||
reg->refresh != default_expiry ||
reg->expiry != default_expiry ||
reg->configured_expiry != default_expiry ||
reg->portno != STANDARD_SIP_PORT ||
(reg->regdomainport) ||
reg->callid_valid != FALSE ||
reg->ocseq != INITIAL_CSEQ) {
ast_test_status_update(test, "Test 5: add transport failed\n");
res = AST_TEST_FAIL;
}
ast_string_field_free_memory(reg);
ast_free(reg);
/* ---Test reg 6, change to tls transport, add expiry --- */
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
goto alloc_fail;
} else if (
sip_parse_register_line(reg, default_expiry, reg6, 1) ||
strcmp(reg->callback, "extension") ||
strcmp(reg->username, "name") ||
strcmp(reg->regdomain, "namedomain") ||
strcmp(reg->hostname, "domain") ||
strcmp(reg->authuser, "authuser") ||
strcmp(reg->secret, "pass") ||
strcmp(reg->peername, "") ||
reg->transport != AST_TRANSPORT_TLS ||
reg->timeout != -1 ||
reg->expire != -1 ||
reg->refresh != 111 ||
reg->expiry != 111 ||
reg->configured_expiry != 111 ||
reg->portno != STANDARD_TLS_PORT ||
(reg->regdomainport) ||
reg->callid_valid != FALSE ||
reg->ocseq != INITIAL_CSEQ) {
ast_test_status_update(test, "Test 6: change to tls transport and add expiry failed\n");
res = AST_TEST_FAIL;
}
ast_string_field_free_memory(reg);
ast_free(reg);
/* ---Test reg 7, change transport to tcp, add custom port, and add peer --- */
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
goto alloc_fail;
} else if (
sip_parse_register_line(reg, default_expiry, reg7, 1) ||
strcmp(reg->callback, "extension") ||
strcmp(reg->username, "name") ||
strcmp(reg->regdomain, "namedomain") ||
strcmp(reg->hostname, "domain") ||
strcmp(reg->authuser, "authuser") ||
strcmp(reg->secret, "pass") ||
strcmp(reg->peername, "peer") ||
reg->transport != AST_TRANSPORT_TCP ||
reg->timeout != -1 ||
reg->expire != -1 ||
reg->refresh != 111 ||
reg->expiry != 111 ||
reg->configured_expiry != 111 ||
reg->portno != 1234 ||
(reg->regdomainport) ||
reg->callid_valid != FALSE ||
reg->ocseq != INITIAL_CSEQ) {
ast_test_status_update(test, "Test 7, change transport to tcp, add custom port, and add peer failed.\n");
res = AST_TEST_FAIL;
}
ast_string_field_free_memory(reg);
ast_free(reg);
/* ---Test reg 8, remove transport --- */
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
goto alloc_fail;
} else if (
sip_parse_register_line(reg, default_expiry, reg8, 1) ||
strcmp(reg->callback, "extension") ||
strcmp(reg->username, "name") ||
strcmp(reg->regdomain, "namedomain") ||
strcmp(reg->hostname, "domain") ||
strcmp(reg->authuser, "authuser") ||
strcmp(reg->secret, "pass") ||
strcmp(reg->peername, "peer") ||
reg->transport != AST_TRANSPORT_UDP ||
reg->timeout != -1 ||
reg->expire != -1 ||
reg->refresh != 111 ||
reg->expiry != 111 ||
reg->configured_expiry != 111 ||
reg->portno != 1234 ||
(reg->regdomainport) ||
reg->callid_valid != FALSE ||
reg->ocseq != INITIAL_CSEQ) {
ast_test_status_update(test, "Test 8, remove transport failed.\n");
res = AST_TEST_FAIL;
}
ast_string_field_free_memory(reg);
ast_free(reg);
/* ---Test reg 9, missing domain, expected to fail --- */
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
goto alloc_fail;
} else if (!sip_parse_register_line(reg, default_expiry, reg9, 1)) {
ast_test_status_update(test,
"Test 9, missing domain, expected to fail but did not.\n");
res = AST_TEST_FAIL;
}
ast_string_field_free_memory(reg);
ast_free(reg);
/* ---Test reg 10, missing user, expected to fail --- */
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
goto alloc_fail;
} else if (!sip_parse_register_line(reg, default_expiry, reg10, 1)) {
ast_test_status_update(test,
"Test 10, missing user expected to fail but did not\n");
res = AST_TEST_FAIL;
}
ast_string_field_free_memory(reg);
ast_free(reg);
/* ---Test reg 11, no registry object, expected to fail--- */
if (!sip_parse_register_line(NULL, default_expiry, reg1, 1)) {
ast_test_status_update(test,
"Test 11, no registry object, expected to fail but did not.\n");
res = AST_TEST_FAIL;
}
/* ---Test reg 12, no registry line, expected to fail --- */
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
goto alloc_fail;
} else if (!sip_parse_register_line(reg, default_expiry, NULL, 1)) {
ast_test_status_update(test,
"Test 12, NULL register line expected to fail but did not.\n");
res = AST_TEST_FAIL;
}
ast_string_field_free_memory(reg);
ast_free(reg);
/* ---Test reg13, add domain port --- */
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
goto alloc_fail;
} else if (
sip_parse_register_line(reg, default_expiry, reg12, 1) ||
strcmp(reg->callback, "s") ||
strcmp(reg->username, "name") ||
strcmp(reg->regdomain, "namedomain") ||
strcmp(reg->hostname, "domain") ||
strcmp(reg->authuser, "authuser") ||
strcmp(reg->secret, "pass") ||
strcmp(reg->peername, "") ||
reg->transport != AST_TRANSPORT_UDP ||
reg->timeout != -1 ||
reg->expire != -1 ||
reg->refresh != default_expiry ||
reg->expiry != default_expiry ||
reg->configured_expiry != default_expiry ||
reg->portno != STANDARD_SIP_PORT ||
reg->regdomainport != 4321 ||
reg->callid_valid != FALSE ||
reg->ocseq != INITIAL_CSEQ) {
ast_test_status_update(test, "Test 13, add domain port failed.\n");
res = AST_TEST_FAIL;
}
ast_string_field_free_memory(reg);
ast_free(reg);
/* ---Test reg14, domain port without secret --- */
if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
goto alloc_fail;
} else if (
sip_parse_register_line(reg, default_expiry, reg13, 1) ||
strcmp(reg->callback, "s") ||
strcmp(reg->username, "name") ||
strcmp(reg->regdomain, "namedomain") ||
strcmp(reg->hostname, "domain") ||
strcmp(reg->authuser, "") ||
strcmp(reg->secret, "") ||
strcmp(reg->peername, "") ||
reg->transport != AST_TRANSPORT_UDP ||
reg->timeout != -1 ||
reg->expire != -1 ||
reg->refresh != default_expiry ||
reg->expiry != default_expiry ||
reg->configured_expiry != default_expiry ||
reg->portno != STANDARD_SIP_PORT ||
reg->regdomainport != 4321 ||
reg->callid_valid != FALSE ||
reg->ocseq != INITIAL_CSEQ) {
ast_test_status_update(test, "Test 14, domain port without secret failed.\n");
res = AST_TEST_FAIL;
}
ast_string_field_free_memory(reg);
ast_free(reg);
return res;
alloc_fail:
ast_test_status_update(test, "Out of memory. \n");
return res;
}
#endif
int sip_parse_host(char *line, int lineno, char **hostname, int *portnum, enum ast_transport *transport)
{
char *port;
if (ast_strlen_zero(line)) {
*hostname = NULL;
return -1;
}
if ((*hostname = strstr(line, "://"))) {
*hostname += 3;
if (!strncasecmp(line, "tcp", 3)) {
*transport = AST_TRANSPORT_TCP;
} else if (!strncasecmp(line, "tls", 3)) {
*transport = AST_TRANSPORT_TLS;
} else if (!strncasecmp(line, "udp", 3)) {
*transport = AST_TRANSPORT_UDP;
} else if (lineno) {
ast_log(LOG_NOTICE, "'%.3s' is not a valid transport type on line %d of sip.conf. defaulting to udp.\n", line, lineno);
} else {
ast_log(LOG_NOTICE, "'%.3s' is not a valid transport type in sip config. defaulting to udp.\n", line);
}
} else {
*hostname = line;
*transport = AST_TRANSPORT_UDP;
}
if ((line = strrchr(*hostname, '@')))
line++;
else
line = *hostname;
if (ast_sockaddr_split_hostport(line, hostname, &port, 0) == 0) {
if (lineno) {
ast_log(LOG_WARNING, "Cannot parse host '%s' on line %d of sip.conf.\n",
line, lineno);
} else {
ast_log(LOG_WARNING, "Cannot parse host '%s' in sip config.\n", line);
}
return -1;
}
if (port) {
if (!sscanf(port, "%5d", portnum)) {
if (lineno) {
ast_log(LOG_NOTICE, "'%s' is not a valid port number on line %d of sip.conf. using default.\n", port, lineno);
} else {
ast_log(LOG_NOTICE, "'%s' is not a valid port number in sip config. using default.\n", port);
}
port = NULL;
}
}
if (!port) {
if (*transport & AST_TRANSPORT_TLS) {
*portnum = STANDARD_TLS_PORT;
} else {
*portnum = STANDARD_SIP_PORT;
}
}
return 0;
}
#ifdef TEST_FRAMEWORK
AST_TEST_DEFINE(sip_parse_host_line_test)
{
int res = AST_TEST_PASS;
char *host;
int port;
enum ast_transport transport;
char host1[] = "www.blah.com";
char host2[] = "tcp://www.blah.com";
char host3[] = "tls://10.10.10.10";
char host4[] = "tls://10.10.10.10:1234";
char host5[] = "10.10.10.10:1234";
switch (cmd) {
case TEST_INIT:
info->name = "sip_parse_host_line_test";
info->category = "/channels/chan_sip/";
info->summary = "tests sip.conf host line parsing";
info->description =
"Tests parsing of various host line configurations. "
"Verifies output matches expected behavior.";
return AST_TEST_NOT_RUN;
case TEST_EXECUTE:
break;
}
/* test 1, simple host */
sip_parse_host(host1, 1, &host, &port, &transport);
if (port != STANDARD_SIP_PORT ||
ast_strlen_zero(host) || strcmp(host, "www.blah.com") ||
transport != AST_TRANSPORT_UDP) {
ast_test_status_update(test, "Test 1: simple host failed.\n");
res = AST_TEST_FAIL;
}
/* test 2, add tcp transport */
sip_parse_host(host2, 1, &host, &port, &transport);
if (port != STANDARD_SIP_PORT ||
ast_strlen_zero(host) || strcmp(host, "www.blah.com") ||
transport != AST_TRANSPORT_TCP) {
ast_test_status_update(test, "Test 2: tcp host failed.\n");
res = AST_TEST_FAIL;
}
/* test 3, add tls transport */
sip_parse_host(host3, 1, &host, &port, &transport);
if (port != STANDARD_TLS_PORT ||
ast_strlen_zero(host) || strcmp(host, "10.10.10.10") ||
transport != AST_TRANSPORT_TLS) {
ast_test_status_update(test, "Test 3: tls host failed. \n");
res = AST_TEST_FAIL;
}
/* test 4, add custom port with tls */
sip_parse_host(host4, 1, &host, &port, &transport);
if (port != 1234 || ast_strlen_zero(host) ||
strcmp(host, "10.10.10.10") ||
transport != AST_TRANSPORT_TLS) {
ast_test_status_update(test, "Test 4: tls host with custom port failed.\n");
res = AST_TEST_FAIL;
}
/* test 5, simple host with custom port */
sip_parse_host(host5, 1, &host, &port, &transport);
if (port != 1234 || ast_strlen_zero(host) ||
strcmp(host, "10.10.10.10") ||
transport != AST_TRANSPORT_UDP) {
ast_test_status_update(test, "Test 5: simple host with custom port failed.\n");
res = AST_TEST_FAIL;
}
/* test 6, expected failure with NULL input */
if (!sip_parse_host(NULL, 1, &host, &port, &transport)) {
ast_test_status_update(test, "Test 6: expected error on NULL input did not occur.\n");
res = AST_TEST_FAIL;
}
return res;
}
#endif
/*! \brief Parse the comma-separated nat= option values */
void sip_parse_nat_option(const char *value, struct ast_flags *mask, struct ast_flags *flags)
{
char *parse, *this;
if (!(parse = ast_strdupa(value))) {
return;
}
/* Since we need to completely override the general settings if we are being called
* later for a peer, always set the flags for all options on the mask */
ast_set_flag(&mask[0], SIP_NAT_FORCE_RPORT);
ast_set_flag(&mask[1], SIP_PAGE2_SYMMETRICRTP);
ast_set_flag(&mask[2], SIP_PAGE3_NAT_AUTO_RPORT);
ast_set_flag(&mask[2], SIP_PAGE3_NAT_AUTO_COMEDIA);
while ((this = strsep(&parse, ","))) {
if (ast_false(this)) {
ast_clear_flag(&flags[0], SIP_NAT_FORCE_RPORT);
ast_clear_flag(&flags[1], SIP_PAGE2_SYMMETRICRTP);
ast_clear_flag(&flags[2], SIP_PAGE3_NAT_AUTO_RPORT);
ast_clear_flag(&flags[2], SIP_PAGE3_NAT_AUTO_COMEDIA);
break; /* It doesn't make sense to have no + something else */
} else if (!strcasecmp(this, "yes")) {
ast_log(LOG_WARNING, "nat=yes is deprecated, use nat=force_rport,comedia instead\n");
ast_set_flag(&flags[0], SIP_NAT_FORCE_RPORT);
ast_set_flag(&flags[1], SIP_PAGE2_SYMMETRICRTP);
ast_clear_flag(&flags[2], SIP_PAGE3_NAT_AUTO_RPORT);
ast_clear_flag(&flags[2], SIP_PAGE3_NAT_AUTO_COMEDIA);
break; /* It doesn't make sense to have yes + something else */
} else if (!strcasecmp(this, "force_rport") && !ast_test_flag(&flags[2], SIP_PAGE3_NAT_AUTO_RPORT)) {
ast_set_flag(&flags[0], SIP_NAT_FORCE_RPORT);
} else if (!strcasecmp(this, "comedia") && !ast_test_flag(&flags[2], SIP_PAGE3_NAT_AUTO_COMEDIA)) {
ast_set_flag(&flags[1], SIP_PAGE2_SYMMETRICRTP);
} else if (!strcasecmp(this, "auto_force_rport")) {
ast_set_flag(&flags[2], SIP_PAGE3_NAT_AUTO_RPORT);
/* In case someone did something dumb like nat=force_rport,auto_force_rport */
ast_clear_flag(&flags[0], SIP_NAT_FORCE_RPORT);
} else if (!strcasecmp(this, "auto_comedia")) {
ast_set_flag(&flags[2], SIP_PAGE3_NAT_AUTO_COMEDIA);
/* In case someone did something dumb like nat=comedia,auto_comedia*/
ast_clear_flag(&flags[1], SIP_PAGE2_SYMMETRICRTP);
}
}
}
#ifdef TEST_FRAMEWORK
#define TEST_FORCE_RPORT 1 << 0
#define TEST_COMEDIA 1 << 1
#define TEST_AUTO_FORCE_RPORT 1 << 2
#define TEST_AUTO_COMEDIA 1 << 3
static int match_nat_options(int val, struct ast_flags *flags)
{
if ((!ast_test_flag(&flags[0], SIP_NAT_FORCE_RPORT)) != !(val & TEST_FORCE_RPORT)) {
return 0;
}
if (!ast_test_flag(&flags[1], SIP_PAGE2_SYMMETRICRTP) != !(val & TEST_COMEDIA)) {
return 0;
}
if (!ast_test_flag(&flags[2], SIP_PAGE3_NAT_AUTO_RPORT) != !(val & TEST_AUTO_FORCE_RPORT)) {
return 0;
}
if (!ast_test_flag(&flags[2], SIP_PAGE3_NAT_AUTO_COMEDIA) != !(val & TEST_AUTO_COMEDIA)) {
return 0;
}
return 1;
}
AST_TEST_DEFINE(sip_parse_nat_test)
{
int i, res = AST_TEST_PASS;
struct ast_flags mask[3] = {{0}}, flags[3] = {{0}};
struct {
const char *str;
int i;
} options[] = {
{ "yes", TEST_FORCE_RPORT | TEST_COMEDIA },
{ "no", 0 },
{ "force_rport", TEST_FORCE_RPORT },
{ "comedia", TEST_COMEDIA },
{ "auto_force_rport", TEST_AUTO_FORCE_RPORT },
{ "auto_comedia", TEST_AUTO_COMEDIA },
{ "force_rport,auto_force_rport", TEST_AUTO_FORCE_RPORT },
{ "auto_force_rport,force_rport", TEST_AUTO_FORCE_RPORT },
{ "comedia,auto_comedia", TEST_AUTO_COMEDIA },
{ "auto_comedia,comedia", TEST_AUTO_COMEDIA },
{ "force_rport,comedia", TEST_FORCE_RPORT | TEST_COMEDIA },
{ "force_rport,auto_comedia", TEST_FORCE_RPORT | TEST_AUTO_COMEDIA },
{ "force_rport,yes,no", TEST_FORCE_RPORT | TEST_COMEDIA },
{ "auto_comedia,no,yes", 0 },
};
switch (cmd) {
case TEST_INIT:
info->name = "sip_parse_nat_test";
info->category = "/channels/chan_sip/";
info->summary = "tests sip.conf nat line parsing";
info->description =
"Tests parsing of various nat line configurations. "
"Verifies output matches expected behavior.";
return AST_TEST_NOT_RUN;
case TEST_EXECUTE:
break;
}
for (i = 0; i < ARRAY_LEN(options); i++) {
sip_parse_nat_option(options[i].str, mask, flags);
if (!match_nat_options(options[i].i, flags)) {
ast_test_status_update(test, "Failed nat=%s\n", options[i].str);
res = AST_TEST_FAIL;
}
memset(flags, 0, sizeof(flags));
memset(mask, 0, sizeof(mask));
}
return res;
}
#endif
/*! \brief SIP test registration */
void sip_config_parser_register_tests(void)
{
AST_TEST_REGISTER(sip_parse_register_line_test);
AST_TEST_REGISTER(sip_parse_host_line_test);
AST_TEST_REGISTER(sip_parse_nat_test);
}
/*! \brief SIP test registration */
void sip_config_parser_unregister_tests(void)
{
AST_TEST_UNREGISTER(sip_parse_register_line_test);
AST_TEST_UNREGISTER(sip_parse_host_line_test);
AST_TEST_UNREGISTER(sip_parse_nat_test);
}

View File

@ -1,515 +0,0 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2010, Digium, Inc.
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*!
* \file
* \brief sip channel dialplan functions and unit tests
*/
/*** MODULEINFO
<support_level>deprecated</support_level>
***/
/*** DOCUMENTATION
<info name="CHANNEL" language="en_US" tech="SIP">
<enumlist>
<enum name="peerip">
<para>R/O Get the IP address of the peer.</para>
</enum>
<enum name="recvip">
<para>R/O Get the source IP address of the peer.</para>
</enum>
<enum name="recvport">
<para>R/O Get the source port of the peer.</para>
</enum>
<enum name="from">
<para>R/O Get the URI from the From: header.</para>
</enum>
<enum name="uri">
<para>R/O Get the URI from the Contact: header.</para>
</enum>
<enum name="ruri">
<para>R/O Get the Request-URI from the INVITE header.</para>
</enum>
<enum name="useragent">
<para>R/O Get the useragent.</para>
</enum>
<enum name="peername">
<para>R/O Get the name of the peer.</para>
</enum>
<enum name="t38passthrough">
<para>R/O <literal>1</literal> if T38 is offered or enabled in this channel,
otherwise <literal>0</literal></para>
</enum>
<enum name="rtpqos">
<para>R/O Get QOS information about the RTP stream</para>
<para> This option takes two additional arguments:</para>
<para> Argument 1:</para>
<para> <literal>audio</literal> Get data about the audio stream</para>
<para> <literal>video</literal> Get data about the video stream</para>
<para> <literal>text</literal> Get data about the text stream</para>
<para> Argument 2:</para>
<para> <literal>local_ssrc</literal> Local SSRC (stream ID)</para>
<para> <literal>local_lostpackets</literal> Local lost packets</para>
<para> <literal>local_jitter</literal> Local calculated jitter</para>
<para> <literal>local_maxjitter</literal> Local calculated jitter (maximum)</para>
<para> <literal>local_minjitter</literal> Local calculated jitter (minimum)</para>
<para> <literal>local_normdevjitter</literal>Local calculated jitter (normal deviation)</para>
<para> <literal>local_stdevjitter</literal> Local calculated jitter (standard deviation)</para>
<para> <literal>local_count</literal> Number of received packets</para>
<para> <literal>remote_ssrc</literal> Remote SSRC (stream ID)</para>
<para> <literal>remote_lostpackets</literal>Remote lost packets</para>
<para> <literal>remote_jitter</literal> Remote reported jitter</para>
<para> <literal>remote_maxjitter</literal> Remote calculated jitter (maximum)</para>
<para> <literal>remote_minjitter</literal> Remote calculated jitter (minimum)</para>
<para> <literal>remote_normdevjitter</literal>Remote calculated jitter (normal deviation)</para>
<para> <literal>remote_stdevjitter</literal>Remote calculated jitter (standard deviation)</para>
<para> <literal>remote_count</literal> Number of transmitted packets</para>
<para> <literal>rtt</literal> Round trip time</para>
<para> <literal>maxrtt</literal> Round trip time (maximum)</para>
<para> <literal>minrtt</literal> Round trip time (minimum)</para>
<para> <literal>normdevrtt</literal> Round trip time (normal deviation)</para>
<para> <literal>stdevrtt</literal> Round trip time (standard deviation)</para>
<para> <literal>all</literal> All statistics (in a form suited to logging,
but not for parsing)</para>
</enum>
<enum name="rtpdest">
<para>R/O Get remote RTP destination information.</para>
<para> This option takes one additional argument:</para>
<para> Argument 1:</para>
<para> <literal>audio</literal> Get audio destination</para>
<para> <literal>video</literal> Get video destination</para>
<para> <literal>text</literal> Get text destination</para>
<para> Defaults to <literal>audio</literal> if unspecified.</para>
</enum>
<enum name="rtpsource">
<para>R/O Get source RTP destination information.</para>
<para> This option takes one additional argument:</para>
<para> Argument 1:</para>
<para> <literal>audio</literal> Get audio destination</para>
<para> <literal>video</literal> Get video destination</para>
<para> <literal>text</literal> Get text destination</para>
<para> Defaults to <literal>audio</literal> if unspecified.</para>
</enum>
</enumlist>
</info>
***/
#include "asterisk.h"
#include <math.h>
#include "asterisk/channel.h"
#include "asterisk/rtp_engine.h"
#include "asterisk/pbx.h"
#include "asterisk/acl.h"
#include "include/sip.h"
#include "include/globals.h"
#include "include/dialog.h"
#include "include/dialplan_functions.h"
#include "include/sip_utils.h"
int sip_acf_channel_read(struct ast_channel *chan, const char *funcname, char *preparse, char *buf, size_t buflen)
{
struct sip_pvt *p = ast_channel_tech_pvt(chan);
char *parse = ast_strdupa(preparse);
int res = 0;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(param);
AST_APP_ARG(type);
AST_APP_ARG(field);
);
/* Check for zero arguments */
if (ast_strlen_zero(parse)) {
ast_log(LOG_ERROR, "Cannot call %s without arguments\n", funcname);
return -1;
}
AST_STANDARD_APP_ARGS(args, parse);
/* Sanity check */
if (!IS_SIP_TECH(ast_channel_tech(chan))) {
ast_log(LOG_ERROR, "Cannot call %s on a non-SIP channel\n", funcname);
return 0;
}
memset(buf, 0, buflen);
if (p == NULL) {
return -1;
}
if (!strcasecmp(args.param, "peerip")) {
ast_copy_string(buf, ast_sockaddr_isnull(&p->sa) ? "" : ast_sockaddr_stringify_addr(&p->sa), buflen);
} else if (!strcasecmp(args.param, "recvip")) {
ast_copy_string(buf, ast_sockaddr_isnull(&p->recv) ? "" : ast_sockaddr_stringify_addr(&p->recv), buflen);
} else if (!strcasecmp(args.param, "recvport")) {
ast_copy_string(buf, ast_sockaddr_isnull(&p->recv) ? "" : ast_sockaddr_stringify_port(&p->recv), buflen);
} else if (!strcasecmp(args.param, "from")) {
ast_copy_string(buf, p->from, buflen);
} else if (!strcasecmp(args.param, "uri")) {
ast_copy_string(buf, p->uri, buflen);
} else if (!strcasecmp(args.param, "ruri")) {
if (p->initreq.data) {
char *tmpruri = REQ_OFFSET_TO_STR(&p->initreq, rlpart2);
ast_copy_string(buf, tmpruri, buflen);
} else {
return -1;
}
} else if (!strcasecmp(args.param, "useragent")) {
ast_copy_string(buf, p->useragent, buflen);
} else if (!strcasecmp(args.param, "peername")) {
ast_copy_string(buf, p->peername, buflen);
} else if (!strcasecmp(args.param, "t38passthrough")) {
ast_copy_string(buf, (p->t38.state == T38_DISABLED) ? "0" : "1", buflen);
} else if (!strcasecmp(args.param, "rtpdest")) {
struct ast_sockaddr addr;
struct ast_rtp_instance *stream;
if (ast_strlen_zero(args.type))
args.type = "audio";
if (!strcasecmp(args.type, "audio"))
stream = p->rtp;
else if (!strcasecmp(args.type, "video"))
stream = p->vrtp;
else if (!strcasecmp(args.type, "text"))
stream = p->trtp;
else
return -1;
/* Return 0 to suppress a console warning message */
if (!stream) {
return 0;
}
ast_rtp_instance_get_remote_address(stream, &addr);
snprintf(buf, buflen, "%s", ast_sockaddr_stringify(&addr));
} else if (!strcasecmp(args.param, "rtpsource")) {
struct ast_sockaddr sa;
struct ast_rtp_instance *stream;
if (ast_strlen_zero(args.type))
args.type = "audio";
if (!strcasecmp(args.type, "audio"))
stream = p->rtp;
else if (!strcasecmp(args.type, "video"))
stream = p->vrtp;
else if (!strcasecmp(args.type, "text"))
stream = p->trtp;
else
return -1;
/* Return 0 to suppress a console warning message */
if (!stream) {
return 0;
}
ast_rtp_instance_get_local_address(stream, &sa);
if (ast_sockaddr_isnull(&sa)) {
struct ast_sockaddr dest_sa;
ast_rtp_instance_get_remote_address(stream, &dest_sa);
ast_ouraddrfor(&dest_sa, &sa);
}
snprintf(buf, buflen, "%s", ast_sockaddr_stringify(&sa));
} else if (!strcasecmp(args.param, "rtpqos")) {
struct ast_rtp_instance *rtp = NULL;
if (ast_strlen_zero(args.type)) {
args.type = "audio";
}
if (!strcasecmp(args.type, "audio")) {
rtp = p->rtp;
} else if (!strcasecmp(args.type, "video")) {
rtp = p->vrtp;
} else if (!strcasecmp(args.type, "text")) {
rtp = p->trtp;
} else {
return -1;
}
if (ast_strlen_zero(args.field) || !strcasecmp(args.field, "all")) {
char quality_buf[AST_MAX_USER_FIELD];
if (!ast_rtp_instance_get_quality(rtp, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, quality_buf, sizeof(quality_buf))) {
return -1;
}
ast_copy_string(buf, quality_buf, buflen);
return res;
} else {
struct ast_rtp_instance_stats stats;
int i;
struct {
const char *name;
enum { INT, DBL } type;
union {
unsigned int *i4;
double *d8;
};
} lookup[] = {
{ "txcount", INT, { .i4 = &stats.txcount, }, },
{ "rxcount", INT, { .i4 = &stats.rxcount, }, },
{ "txjitter", DBL, { .d8 = &stats.txjitter, }, },
{ "rxjitter", DBL, { .d8 = &stats.rxjitter, }, },
{ "remote_maxjitter", DBL, { .d8 = &stats.remote_maxjitter, }, },
{ "remote_minjitter", DBL, { .d8 = &stats.remote_minjitter, }, },
{ "remote_normdevjitter", DBL, { .d8 = &stats.remote_normdevjitter, }, },
{ "remote_stdevjitter", DBL, { .d8 = &stats.remote_stdevjitter, }, },
{ "local_maxjitter", DBL, { .d8 = &stats.local_maxjitter, }, },
{ "local_minjitter", DBL, { .d8 = &stats.local_minjitter, }, },
{ "local_normdevjitter", DBL, { .d8 = &stats.local_normdevjitter, }, },
{ "local_stdevjitter", DBL, { .d8 = &stats.local_stdevjitter, }, },
{ "txploss", INT, { .i4 = &stats.txploss, }, },
{ "rxploss", INT, { .i4 = &stats.rxploss, }, },
{ "remote_maxrxploss", DBL, { .d8 = &stats.remote_maxrxploss, }, },
{ "remote_minrxploss", DBL, { .d8 = &stats.remote_minrxploss, }, },
{ "remote_normdevrxploss", DBL, { .d8 = &stats.remote_normdevrxploss, }, },
{ "remote_stdevrxploss", DBL, { .d8 = &stats.remote_stdevrxploss, }, },
{ "local_maxrxploss", DBL, { .d8 = &stats.local_maxrxploss, }, },
{ "local_minrxploss", DBL, { .d8 = &stats.local_minrxploss, }, },
{ "local_normdevrxploss", DBL, { .d8 = &stats.local_normdevrxploss, }, },
{ "local_stdevrxploss", DBL, { .d8 = &stats.local_stdevrxploss, }, },
{ "rtt", DBL, { .d8 = &stats.rtt, }, },
{ "maxrtt", DBL, { .d8 = &stats.maxrtt, }, },
{ "minrtt", DBL, { .d8 = &stats.minrtt, }, },
{ "normdevrtt", DBL, { .d8 = &stats.normdevrtt, }, },
{ "stdevrtt", DBL, { .d8 = &stats.stdevrtt, }, },
{ "local_ssrc", INT, { .i4 = &stats.local_ssrc, }, },
{ "remote_ssrc", INT, { .i4 = &stats.remote_ssrc, }, },
{ NULL, },
};
if (ast_rtp_instance_get_stats(rtp, &stats, AST_RTP_INSTANCE_STAT_ALL)) {
return -1;
}
for (i = 0; !ast_strlen_zero(lookup[i].name); i++) {
if (!strcasecmp(args.field, lookup[i].name)) {
if (lookup[i].type == INT) {
snprintf(buf, buflen, "%u", *lookup[i].i4);
} else {
snprintf(buf, buflen, "%f", *lookup[i].d8);
}
return 0;
}
}
ast_log(LOG_WARNING, "Unrecognized argument '%s' to %s\n", preparse, funcname);
return -1;
}
} else if (!strcasecmp(args.param, "secure_signaling")) {
snprintf(buf, buflen, "%s", p->socket.type == AST_TRANSPORT_TLS ? "1" : "");
} else if (!strcasecmp(args.param, "secure_media")) {
snprintf(buf, buflen, "%s", p->srtp ? "1" : "");
} else {
res = -1;
}
return res;
}
#ifdef TEST_FRAMEWORK
static int test_sip_rtpqos_1_new(struct ast_rtp_instance *instance, struct ast_sched_context *sched, struct ast_sockaddr *addr, void *data)
{
/* Needed to pass sanity checks */
ast_rtp_instance_set_data(instance, data);
return 0;
}
static int test_sip_rtpqos_1_destroy(struct ast_rtp_instance *instance)
{
/* Needed to pass sanity checks */
return 0;
}
static struct ast_frame *test_sip_rtpqos_1_read(struct ast_rtp_instance *instance, int rtcp)
{
/* Needed to pass sanity checks */
return &ast_null_frame;
}
static int test_sip_rtpqos_1_write(struct ast_rtp_instance *instance, struct ast_frame *frame)
{
/* Needed to pass sanity checks */
return 0;
}
static int test_sip_rtpqos_1_get_stat(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat)
{
struct ast_rtp_instance_stats *s = ast_rtp_instance_get_data(instance);
memcpy(stats, s, sizeof(*stats));
return 0;
}
AST_TEST_DEFINE(test_sip_rtpqos_1)
{
int i, res = AST_TEST_PASS;
static struct ast_rtp_engine test_engine = {
.name = "test",
.new = test_sip_rtpqos_1_new,
.destroy = test_sip_rtpqos_1_destroy,
.read = test_sip_rtpqos_1_read,
.write = test_sip_rtpqos_1_write,
.get_stat = test_sip_rtpqos_1_get_stat,
};
struct ast_sockaddr sa = { {0, } };
struct ast_rtp_instance_stats mine = { 0, };
struct sip_pvt *p = NULL;
struct ast_channel *chan = NULL;
struct ast_str *varstr = NULL, *buffer = NULL;
struct {
const char *name;
enum { INT, DBL } type;
union {
unsigned int *i4;
double *d8;
};
} lookup[] = {
{ "txcount", INT, { .i4 = &mine.txcount, }, },
{ "rxcount", INT, { .i4 = &mine.rxcount, }, },
{ "txjitter", DBL, { .d8 = &mine.txjitter, }, },
{ "rxjitter", DBL, { .d8 = &mine.rxjitter, }, },
{ "remote_maxjitter", DBL, { .d8 = &mine.remote_maxjitter, }, },
{ "remote_minjitter", DBL, { .d8 = &mine.remote_minjitter, }, },
{ "remote_normdevjitter", DBL, { .d8 = &mine.remote_normdevjitter, }, },
{ "remote_stdevjitter", DBL, { .d8 = &mine.remote_stdevjitter, }, },
{ "local_maxjitter", DBL, { .d8 = &mine.local_maxjitter, }, },
{ "local_minjitter", DBL, { .d8 = &mine.local_minjitter, }, },
{ "local_normdevjitter", DBL, { .d8 = &mine.local_normdevjitter, }, },
{ "local_stdevjitter", DBL, { .d8 = &mine.local_stdevjitter, }, },
{ "txploss", INT, { .i4 = &mine.txploss, }, },
{ "rxploss", INT, { .i4 = &mine.rxploss, }, },
{ "remote_maxrxploss", DBL, { .d8 = &mine.remote_maxrxploss, }, },
{ "remote_minrxploss", DBL, { .d8 = &mine.remote_minrxploss, }, },
{ "remote_normdevrxploss", DBL, { .d8 = &mine.remote_normdevrxploss, }, },
{ "remote_stdevrxploss", DBL, { .d8 = &mine.remote_stdevrxploss, }, },
{ "local_maxrxploss", DBL, { .d8 = &mine.local_maxrxploss, }, },
{ "local_minrxploss", DBL, { .d8 = &mine.local_minrxploss, }, },
{ "local_normdevrxploss", DBL, { .d8 = &mine.local_normdevrxploss, }, },
{ "local_stdevrxploss", DBL, { .d8 = &mine.local_stdevrxploss, }, },
{ "rtt", DBL, { .d8 = &mine.rtt, }, },
{ "maxrtt", DBL, { .d8 = &mine.maxrtt, }, },
{ "minrtt", DBL, { .d8 = &mine.minrtt, }, },
{ "normdevrtt", DBL, { .d8 = &mine.normdevrtt, }, },
{ "stdevrtt", DBL, { .d8 = &mine.stdevrtt, }, },
{ "local_ssrc", INT, { .i4 = &mine.local_ssrc, }, },
{ "remote_ssrc", INT, { .i4 = &mine.remote_ssrc, }, },
{ NULL, },
};
switch (cmd) {
case TEST_INIT:
info->name = "test_sip_rtpqos";
info->category = "/channels/chan_sip/";
info->summary = "Test retrieval of SIP RTP QOS stats";
info->description =
"Verify values in the RTP instance structure can be accessed through the dialplan.";
return AST_TEST_NOT_RUN;
case TEST_EXECUTE:
break;
}
ast_rtp_engine_register(&test_engine);
/* Have to associate this with a SIP pvt and an ast_channel */
if (!(p = sip_alloc(0, NULL, 0, SIP_NOTIFY, NULL, 0))) {
res = AST_TEST_NOT_RUN;
goto done;
}
if (!(p->rtp = ast_rtp_instance_new("test", sched, &bindaddr, &mine))) {
res = AST_TEST_NOT_RUN;
goto done;
}
ast_rtp_instance_set_remote_address(p->rtp, &sa);
if (!(chan = ast_dummy_channel_alloc())) {
res = AST_TEST_NOT_RUN;
goto done;
}
ast_channel_tech_set(chan, &sip_tech);
ast_channel_tech_pvt_set(chan, dialog_ref(p, "Give the owner channel a reference to the dialog"));
p->owner = chan;
varstr = ast_str_create(16);
buffer = ast_str_create(16);
if (!varstr || !buffer) {
res = AST_TEST_NOT_RUN;
goto done;
}
/* Populate "mine" with values, then retrieve them with the CHANNEL dialplan function */
for (i = 0; !ast_strlen_zero(lookup[i].name); i++) {
ast_str_set(&varstr, 0, "${CHANNEL(rtpqos,audio,%s)}", lookup[i].name);
if (lookup[i].type == INT) {
int j;
char cmpstr[256];
for (j = 1; j < 25; j++) {
*lookup[i].i4 = j;
ast_str_substitute_variables(&buffer, 0, chan, ast_str_buffer(varstr));
snprintf(cmpstr, sizeof(cmpstr), "%d", j);
if (strcmp(cmpstr, ast_str_buffer(buffer))) {
res = AST_TEST_FAIL;
ast_test_status_update(test, "%s != %s != %s\n", ast_str_buffer(varstr), cmpstr, ast_str_buffer(buffer));
break;
}
}
} else {
double j, cmpdbl = 0.0;
for (j = 1.0; j < 10.0; j += 0.3) {
*lookup[i].d8 = j;
ast_str_substitute_variables(&buffer, 0, chan, ast_str_buffer(varstr));
if (sscanf(ast_str_buffer(buffer), "%lf", &cmpdbl) != 1 || fabs(j - cmpdbl) > .05) {
res = AST_TEST_FAIL;
ast_test_status_update(test, "%s != %f != %s\n", ast_str_buffer(varstr), j, ast_str_buffer(buffer));
break;
}
}
}
}
done:
ast_free(varstr);
ast_free(buffer);
/* This unlink and unref will take care of destroying the channel, RTP instance, and SIP pvt */
if (p) {
dialog_unlink_all(p);
dialog_unref(p, "Destroy test object");
}
if (chan) {
ast_channel_unref(chan);
}
ast_rtp_engine_unregister(&test_engine);
return res;
}
#endif
/*! \brief SIP test registration */
void sip_dialplan_function_register_tests(void)
{
AST_TEST_REGISTER(test_sip_rtpqos_1);
}
/*! \brief SIP test registration */
void sip_dialplan_function_unregister_tests(void)
{
AST_TEST_UNREGISTER(test_sip_rtpqos_1);
}

View File

@ -1,68 +0,0 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2010, Digium, Inc.
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*!
* \file
* \brief sip.conf parser header file
*/
#include "sip.h"
#ifndef _SIP_CONF_PARSE_H
#define _SIP_CONF_PARSE_H
/*!
* \brief Parse register=> line in sip.conf
*
* \retval 0 on success
* \retval -1 on failure
*/
int sip_parse_register_line(struct sip_registry *reg, int default_expiry, const char *value, int lineno);
/*!
* \brief parses a config line for a host with a transport
*
* An example input would be:
* <code>tls://www.google.com:8056</code>
*
* \retval 0 on success
* \retval -1 on failure
*/
int sip_parse_host(char *line, int lineno, char **hostname, int *portnum, enum ast_transport *transport);
/*! \brief Parse the comma-separated nat= option values
* \param value The comma-separated value
* \param mask An array of ast_flags that will be set by this function
* and used as a mask for copying the flags later
* \param flags An array of ast_flags that will be set by this function
*
* \note The nat-related values in both mask and flags are assumed to empty. This function
* will treat the first "yes" or "no" value in a list of values as overriding all other values
* and will stop parsing. Auto values will override their non-auto counterparts.
*/
void sip_parse_nat_option(const char *value, struct ast_flags *mask, struct ast_flags *flags);
/*!
* \brief register config parsing tests
*/
void sip_config_parser_register_tests(void);
/*!
* \brief unregister config parsing tests
*/
void sip_config_parser_unregister_tests(void);
#endif

View File

@ -1,82 +0,0 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2010, Digium, Inc.
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*!
* \file
* \brief sip dialog management header file
*/
#include "sip.h"
#ifndef _SIP_DIALOG_H
#define _SIP_DIALOG_H
/*! \brief
* when we create or delete references, make sure to use these
* functions so we keep track of the refcounts.
* To simplify the code, we allow a NULL to be passed to dialog_unref().
*/
#define dialog_ref(dialog, tag) ao2_t_bump(dialog, tag)
#define dialog_unref(dialog, tag) ({ ao2_t_cleanup(dialog, tag); (NULL); })
struct sip_pvt *__sip_alloc(ast_string_field callid, struct ast_sockaddr *sin,
int useglobal_nat, const int intended_method, struct sip_request *req, ast_callid logger_callid,
const char *file, int line, const char *func);
#define sip_alloc(callid, addr, useglobal_nat, intended_method, req, logger_callid) \
__sip_alloc(callid, addr, useglobal_nat, intended_method, req, logger_callid, __FILE__, __LINE__, __PRETTY_FUNCTION__)
/*!
* \brief Schedule final destruction of SIP dialog.
*
* \note This cannot be canceled.
*
* \details
* This function is used to keep a dialog around for a period of time in order
* to properly respond to any retransmits.
*/
void sip_scheddestroy_final(struct sip_pvt *p, int ms);
/*! \brief Schedule destruction of SIP dialog */
void sip_scheddestroy(struct sip_pvt *p, int ms);
/*! \brief Cancel destruction of SIP dialog. */
void sip_cancel_destroy(struct sip_pvt *pvt);
/*!
* \brief Unlink a dialog from the dialogs container, as well as any other places
* that it may be currently stored.
*
* \note A reference to the dialog must be held before calling
* this function, and this function does not release that
* reference.
*
* \note The dialog must not be locked when called.
*/
void dialog_unlink_all(struct sip_pvt *dialog);
/*! \brief Acknowledges receipt of a packet and stops retransmission
* called with p locked*/
int __sip_ack(struct sip_pvt *p, uint32_t seqno, int resp, int sipmethod);
/*! \brief Pretend to ack all packets
* called with p locked */
void __sip_pretend_ack(struct sip_pvt *p);
/*! \brief Acks receipt of packet, keep it around (used for provisional responses) */
int __sip_semi_ack(struct sip_pvt *p, uint32_t seqno, int resp, int sipmethod);
#endif /* defined(_SIP_DIALOG_H) */

View File

@ -1,41 +0,0 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2010, Digium, Inc.
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*!
* \file
* \brief SIP dialplan functions header file
*/
#include "sip.h"
#ifndef _SIP_DIALPLAN_FUNCTIONS_H
#define _SIP_DIALPLAN_FUNCTIONS_H
/*!
* \brief Channel read dialplan function for SIP
*/
int sip_acf_channel_read(struct ast_channel *chan, const char *funcname, char *preparse, char *buf, size_t buflen);
/*!
* \brief register dialplan function tests
*/
void sip_dialplan_function_register_tests(void);
/*!
* \brief unregister dialplan function tests
*/
void sip_dialplan_function_unregister_tests(void);
#endif /* !defined(_SIP_DIALPLAN_FUNCTIONS_H) */

View File

@ -1,41 +0,0 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2010, Digium, Inc.
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*!
* \file
* \brief sip global declaration header file
*/
#include "sip.h"
#ifndef _SIP_GLOBALS_H
#define _SIP_GLOBALS_H
extern struct ast_sockaddr bindaddr; /*!< UDP: The address we bind to */
extern struct ast_sched_context *sched; /*!< The scheduling context */
/*! \brief Definition of this channel for PBX channel registration */
extern struct ast_channel_tech sip_tech;
/*! \brief This version of the sip channel tech has no send_digit_begin
* callback so that the core knows that the channel does not want
* DTMF BEGIN frames.
* The struct is initialized just before registering the channel driver,
* and is for use with channels using SIP INFO DTMF.
*/
extern struct ast_channel_tech sip_tech_info;
#endif /* !defined(SIP_GLOBALS_H) */

View File

@ -1,250 +0,0 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2010, Digium, Inc.
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*!
* \file
* \brief sip request response parser header file
*/
#ifndef _SIP_REQRESP_H
#define _SIP_REQRESP_H
/*! \brief uri parameters */
struct uriparams {
char *transport;
char *user;
char *method;
char *ttl;
char *maddr;
int lr;
};
struct contact {
AST_LIST_ENTRY(contact) list;
char *name;
char *user;
char *pass;
char *hostport;
struct uriparams params;
char *headers;
char *expires;
char *q;
};
AST_LIST_HEAD_NOLOCK(contactliststruct, contact);
/*!
* \brief parses a URI in its components.
*
* \note
* - Multiple scheme's can be specified ',' delimited. ex: "sip:,sips:"
* - If a component is not requested, do not split around it. This means
* that if we don't have domain, we cannot split name:pass.
* - It is safe to call with ret_name, pass, hostport pointing all to
* the same place.
* - If no secret parameter is provided, ret_name will return with both
* parts, user:secret.
* - If the URI contains a port number, hostport will return with both
* parts, host:port.
* - This function overwrites the URI string.
*
* \retval 0 on success
* \retval -1 on error.
*
* \verbatim
* general form we are expecting is sip:user:password;user-parameters@host:port;uri-parameters?headers
* \endverbatim
*/
int parse_uri(char *uri, const char *scheme, char **ret_name, char **pass,
char **hostport, char **transport);
/*!
* \brief parses a URI in to all of its components and any trailing residue
*
* \retval 0 on success
* \retval -1 on error.
*
*/
int parse_uri_full(char *uri, const char *scheme, char **user, char **pass,
char **hostport, struct uriparams *params, char **headers,
char **residue);
/*!
* \brief Get caller id name from SIP headers, copy into output buffer
*
* \return input string pointer placed after display-name field if possible
*/
const char *get_calleridname(const char *input, char *output, size_t outputsize);
/*!
* \brief Get name and number from sip header
*
* \note name and number point to malloced memory on return and must be
* freed. If name or number is not found, they will be returned as NULL.
*
* \retval 0 success
* \retval -1 failure
*/
int get_name_and_number(const char *hdr, char **name, char **number);
/*! \brief Pick out text in brackets from character string
* \return pointer to terminated stripped string
* \param tmp input string that will be modified
*
* Examples:
* \verbatim
* "foo" <bar> valid input, returns bar
* foo returns the whole string
* < "foo ... > returns the string between brackets
* < "foo... bogus (missing closing bracket), returns the whole string
* \endverbatim
*/
char *get_in_brackets(char *tmp);
/*! \brief Get text in brackets on a const without copy
*
* \param src String to search
* \param[out] start Set to first character inside left bracket.
* \param[out] length Set to lenght of string inside brackets
* \retval 0 success
* \retval -1 failure
* \retval 1 no brackets so got all
*/
int get_in_brackets_const(const char *src,const char **start,int *length);
/*! \brief Get text in brackets and any trailing residue
*
* \retval 0 success
* \retval -1 failure
* \retval 1 no brackets so got all
*/
int get_in_brackets_full(char *tmp, char **out, char **residue);
/*! \brief Parse the ABNF structure
* name-andor-addr = name-addr / addr-spec
* into its components and return any trailing message-header parameters
*
* \retval 0 success
* \retval -1 failure
*/
int parse_name_andor_addr(char *uri, const char *scheme, char **name,
char **user, char **pass, char **domain,
struct uriparams *params, char **headers,
char **residue);
/*! \brief Parse all contact header contacts
* \retval 0 success
* \retval -1 failure
* \retval 1 all contacts (star)
*/
int get_comma(char *parse, char **out);
int parse_contact_header(char *contactheader, struct contactliststruct *contactlist);
/*!
* \brief register request parsing tests
*/
void sip_request_parser_register_tests(void);
/*!
* \brief unregister request parsing tests
*/
void sip_request_parser_unregister_tests(void);
/*!
* \brief Parse supported header in incoming packet
*
* \details This function parses through the options parameters and
* builds a bit field representing all the SIP options in that field. When an
* item is found that is not supported, it is copied to the unsupported
* out buffer.
*
* \param options list
* \param[in,out] unsupported buffer (optional)
* \param[in,out] unsupported_len buffer length
*
* \note Because this function can be called multiple times, it will append
* whatever options are specified in \c options to \c unsupported. Callers
* of this function should make sure the unsupported buffer is clear before
* calling this function.
*/
unsigned int parse_sip_options(const char *options, char *unsupported, size_t unsupported_len);
/*!
* \brief Compare two URIs as described in RFC 3261 Section 19.1.4
*
* \param input1 First URI
* \param input2 Second URI
* \retval 0 URIs match
* \retval nonzero URIs do not match or one or both is malformed
*/
int sip_uri_cmp(const char *input1, const char *input2);
/*!
* \brief initialize request and response parser data
*
* \retval 0 Success
* \retval -1 Failure
*/
int sip_reqresp_parser_init(void);
/*!
* \brief Free resources used by request and response parser
*/
void sip_reqresp_parser_exit(void);
/*!
* \brief Parse a Via header
*
* This function parses the Via header and processes it according to section
* 18.2 of RFC 3261 and RFC 3581. Since we don't have a transport layer, we
* only care about the maddr and ttl parms. The received and rport params are
* not parsed.
*
* \note This function fails to parse some odd combinations of SWS in parameter
* lists.
*
* \code
* VIA syntax. RFC 3261 section 25.1
* Via = ( "Via" / "v" ) HCOLON via-parm *(COMMA via-parm)
* via-parm = sent-protocol LWS sent-by *( SEMI via-params )
* via-params = via-ttl / via-maddr
* / via-received / via-branch
* / via-extension
* via-ttl = "ttl" EQUAL ttl
* via-maddr = "maddr" EQUAL host
* via-received = "received" EQUAL (IPv4address / IPv6address)
* via-branch = "branch" EQUAL token
* via-extension = generic-param
* sent-protocol = protocol-name SLASH protocol-version
* SLASH transport
* protocol-name = "SIP" / token
* protocol-version = token
* transport = "UDP" / "TCP" / "TLS" / "SCTP"
* / other-transport
* sent-by = host [ COLON port ]
* ttl = 1*3DIGIT ; 0 to 255
* \endcode
*/
struct sip_via *parse_via(const char *header);
/*!
* \brief Free parsed Via data.
*/
void free_via(struct sip_via *v);
#endif

View File

@ -1,117 +0,0 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2013, Digium, Inc.
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*!
* \file
* \brief sip_route header file
*/
#ifndef _SIP_ROUTE_H
#define _SIP_ROUTE_H
#include "asterisk/linkedlists.h"
#include "asterisk/strings.h"
/*!
* \brief Opaque storage of a sip route hop
*/
struct sip_route_hop;
/*!
* \internal \brief Internal enum to remember last calculated
*/
enum sip_route_type {
route_loose = 0, /*!< The first hop contains ;lr or does not exist */
route_strict, /*!< The first hop exists and does not contain ;lr */
route_invalidated, /*!< strict/loose routing needs to be rechecked */
};
/*!
* \brief Structure to store route information
*
* \note This must be zero-filled on allocation
*/
struct sip_route {
AST_LIST_HEAD_NOLOCK(, sip_route_hop) list;
enum sip_route_type type;
};
/*!
* \brief Add a new hop to the route
*
* \param route Route
* \param uri Address of this hop
* \param len Length of hop not including null terminator
* \param inserthead If true then inserted the new route to the top of the list
*
* \return Pointer to null terminated copy of URI on success
* \retval NULL on error
*/
const char *sip_route_add(struct sip_route *route, const char *uri, size_t len, int inserthead);
/*!
* \brief Add routes from header
*
* \note This procedure is for headers that require use of \<brackets\>.
*/
void sip_route_process_header(struct sip_route *route, const char *header, int inserthead);
/*!
* \brief copy route-set
*/
void sip_route_copy(struct sip_route *dst, const struct sip_route *src);
/*!
* \brief Free all routes in the list
*/
void sip_route_clear(struct sip_route *route);
/*!
* \brief Verbose dump of all hops for debugging
*/
void sip_route_dump(const struct sip_route *route);
/*!
* \brief Make the comma separated list of route hops
*
* \param route Source of route list
* \param formatcli Add's space after comma's, print's N/A if list is empty.
* \param skip Number of hops to skip
*
* \return an allocated struct ast_str on success
* \retval NULL on failure
*/
struct ast_str *sip_route_list(const struct sip_route *route, int formatcli, int skip)
__attribute__((__malloc__)) __attribute__((__warn_unused_result__));
/*!
* \brief Check if the route is strict
*
* \note The result is cached in route->type
*/
int sip_route_is_strict(struct sip_route *route);
/*!
* \brief Get the URI of the route's first hop
*/
const char *sip_route_first_uri(const struct sip_route *route);
/*!
* \brief Check if route has no URI's
*/
#define sip_route_empty(route) AST_LIST_EMPTY(&(route)->list)
#endif

View File

@ -1,44 +0,0 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2011, Digium, Inc.
*
* Michael L. Young <elgueromexicano@gmail.com>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*!
* \file
*
* \brief Generate security events in the SIP channel
*
* \author Michael L. Young <elgueromexicano@gmail.com>
*/
#include "sip.h"
#ifndef _SIP_SECURITY_EVENTS_H
#define _SIP_SECURITY_EVENTS_H
void sip_report_invalid_peer(const struct sip_pvt *p);
void sip_report_failed_acl(const struct sip_pvt *p, const char *aclname);
void sip_report_inval_password(const struct sip_pvt *p, const char *responsechallenge, const char *responsehash);
void sip_report_auth_success(const struct sip_pvt *p, uint32_t using_password);
void sip_report_session_limit(const struct sip_pvt *p);
void sip_report_failed_challenge_response(const struct sip_pvt *p, const char *response, const char *expected_response);
void sip_report_chal_sent(const struct sip_pvt *p);
void sip_report_inval_transport(const struct sip_pvt *p, const char *transport);
void sip_digest_parser(char *c, struct digestkeys *keys);
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);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,89 +0,0 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2010, Digium, Inc.
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*!
* \file
* \brief sip utils header file
*/
#ifndef _SIP_UTILS_H
#define _SIP_UTILS_H
/* wrapper macro to tell whether t points to one of the sip_tech descriptors */
#define IS_SIP_TECH(t) ((t) == &sip_tech || (t) == &sip_tech_info)
/*!
* \brief converts ascii port to int representation.
*
* \arg pt[in] string that contains a port.
* \arg standard[in] port to return in case the port string input is NULL
* or if there is a parsing error.
*
* \return An integer port representation.
*/
unsigned int port_str2int(const char *pt, unsigned int standard);
/*! \brief Locate closing quote in a string, skipping escaped quotes.
* optionally with a limit on the search.
* start must be past the first quote.
*/
const char *find_closing_quote(const char *start, const char *lim);
/*! \brief Convert SIP hangup causes to Asterisk hangup causes */
int hangup_sip2cause(int cause);
/*! \brief Convert Asterisk hangup causes to SIP codes
\verbatim
Possible values from causes.h
AST_CAUSE_NOTDEFINED AST_CAUSE_NORMAL AST_CAUSE_BUSY
AST_CAUSE_FAILURE AST_CAUSE_CONGESTION AST_CAUSE_UNALLOCATED
In addition to these, a lot of PRI codes is defined in causes.h
...should we take care of them too ?
Quote RFC 3398
ISUP Cause value SIP response
---------------- ------------
1 unallocated number 404 Not Found
2 no route to network 404 Not found
3 no route to destination 404 Not found
16 normal call clearing --- (*)
17 user busy 486 Busy here
18 no user responding 408 Request Timeout
19 no answer from the user 480 Temporarily unavailable
20 subscriber absent 480 Temporarily unavailable
21 call rejected 403 Forbidden (+)
22 number changed (w/o diagnostic) 410 Gone
22 number changed (w/ diagnostic) 301 Moved Permanently
23 redirection to new destination 410 Gone
26 non-selected user clearing 404 Not Found (=)
27 destination out of order 502 Bad Gateway
28 address incomplete 484 Address incomplete
29 facility rejected 501 Not implemented
31 normal unspecified 480 Temporarily unavailable
\endverbatim
*/
const char *hangup_cause2sip(int cause);
/*! \brief Return a string describing the force_rport value for the given flags */
const char *force_rport_string(struct ast_flags *flags);
/*! \brief Return a string describing the comedia value for the given flags */
const char *comedia_string(struct ast_flags *flags);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,203 +0,0 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2013, Digium, Inc.
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*!
* \file
* \brief sip_route functions
*/
/*** MODULEINFO
<support_level>deprecated</support_level>
***/
#include "asterisk.h"
#include "asterisk/utils.h"
#include "include/route.h"
#include "include/reqresp_parser.h"
/*!
* \brief Traverse route hops
*/
#define sip_route_traverse(route,elem) AST_LIST_TRAVERSE(&(route)->list, elem, list)
#define sip_route_first(route) AST_LIST_FIRST(&(route)->list)
/*!
* \brief Structure to save a route hop
*/
struct sip_route_hop {
AST_LIST_ENTRY(sip_route_hop) list;
char uri[0];
};
const char *sip_route_add(struct sip_route *route, const char *uri, size_t len, int inserthead)
{
struct sip_route_hop *hop;
if (!uri || len < 1 || uri[0] == '\0') {
return NULL;
}
/* Expand len to include null terminator */
len++;
/* ast_calloc is not needed because all fields are initialized in this block */
hop = ast_malloc(sizeof(struct sip_route_hop) + len);
if (!hop) {
return NULL;
}
ast_copy_string(hop->uri, uri, len);
if (inserthead) {
AST_LIST_INSERT_HEAD(&route->list, hop, list);
route->type = route_invalidated;
} else {
if (sip_route_empty(route)) {
route->type = route_invalidated;
}
AST_LIST_INSERT_TAIL(&route->list, hop, list);
hop->list.next = NULL;
}
return hop->uri;
}
void sip_route_process_header(struct sip_route *route, const char *header, int inserthead)
{
const char *hop;
int len = 0;
const char *uri;
if (!route) {
ast_log(LOG_ERROR, "sip_route_process_header requires non-null route");
ast_do_crash();
return;
}
while (!get_in_brackets_const(header, &uri, &len)) {
header = strchr(header, ',');
if (header >= uri && header <= (uri + len)) {
/* comma inside brackets */
const char *next_br = strchr(header, '<');
if (next_br && next_br <= (uri + len)) {
header++;
continue;
}
continue;
}
if ((hop = sip_route_add(route, uri, len, inserthead))) {
ast_debug(2, "sip_route_process_header: <%s>\n", hop);
}
header = strchr(uri + len + 1, ',');
if (header == NULL) {
/* No more field-values, we're done with this header */
break;
}
/* Advance past comma */
header++;
}
}
void sip_route_copy(struct sip_route *dst, const struct sip_route *src)
{
struct sip_route_hop *hop;
/* make sure dst is empty */
sip_route_clear(dst);
sip_route_traverse(src, hop) {
const char *uri = sip_route_add(dst, hop->uri, strlen(hop->uri), 0);
if (uri) {
ast_debug(2, "sip_route_copy: copied hop: <%s>\n", uri);
}
}
dst->type = src->type;
}
void sip_route_clear(struct sip_route *route)
{
struct sip_route_hop *hop;
while ((hop = AST_LIST_REMOVE_HEAD(&route->list, list))) {
ast_free(hop);
}
route->type = route_loose;
}
void sip_route_dump(const struct sip_route *route)
{
if (sip_route_empty(route)) {
ast_verbose("sip_route_dump: no route/path\n");
} else {
struct sip_route_hop *hop;
sip_route_traverse(route, hop) {
ast_verbose("sip_route_dump: route/path hop: <%s>\n", hop->uri);
}
}
}
struct ast_str *sip_route_list(const struct sip_route *route, int formatcli, int skip)
{
struct sip_route_hop *hop;
const char *comma;
struct ast_str *buf;
int i = 0 - skip;
buf = ast_str_create(64);
if (!buf) {
return NULL;
}
comma = formatcli ? ", " : ",";
sip_route_traverse(route, hop) {
if (i >= 0) {
ast_str_append(&buf, 0, "%s<%s>", i ? comma : "", hop->uri);
}
i++;
}
if (formatcli && i <= 0) {
ast_str_append(&buf, 0, "N/A");
}
return buf;
}
int sip_route_is_strict(struct sip_route *route)
{
if (!route) {
return 0;
}
if (route->type == route_invalidated) {
struct sip_route_hop *hop = sip_route_first(route);
int ret = hop && (strstr(hop->uri, ";lr") == NULL);
route->type = ret ? route_strict : route_loose;
return ret;
}
return (route->type == route_strict) ? 1 : 0;
}
const char *sip_route_first_uri(const struct sip_route *route)
{
struct sip_route_hop *hop = sip_route_first(route);
return hop ? hop->uri : NULL;
}

View File

@ -1,358 +0,0 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2012, Digium, Inc.
*
* Michael L. Young <elgueromexicano@gmail.com>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*!
* \file
*
* \brief Generate security events in the SIP channel
*
* \author Michael L. Young <elgueromexicano@gmail.com>
*/
/*** MODULEINFO
<support_level>deprecated</support_level>
***/
#include "asterisk.h"
#include "include/sip.h"
#include "include/security_events.h"
/*! \brief Determine transport type used to receive request*/
static enum ast_transport security_event_get_transport(const struct sip_pvt *p)
{
return p->socket.type;
}
void sip_report_invalid_peer(const struct sip_pvt *p)
{
char session_id[32];
struct ast_security_event_inval_acct_id inval_acct_id = {
.common.event_type = AST_SECURITY_EVENT_INVAL_ACCT_ID,
.common.version = AST_SECURITY_EVENT_INVAL_ACCT_ID_VERSION,
.common.service = "SIP",
.common.account_id = p->exten,
.common.local_addr = {
.addr = &p->ourip,
.transport = security_event_get_transport(p)
},
.common.remote_addr = {
.addr = &p->sa,
.transport = security_event_get_transport(p)
},
.common.session_id = session_id,
};
snprintf(session_id, sizeof(session_id), "%p", p);
ast_security_event_report(AST_SEC_EVT(&inval_acct_id));
}
void sip_report_failed_acl(const struct sip_pvt *p, const char *aclname)
{
char session_id[32];
struct ast_security_event_failed_acl failed_acl_event = {
.common.event_type = AST_SECURITY_EVENT_FAILED_ACL,
.common.version = AST_SECURITY_EVENT_FAILED_ACL_VERSION,
.common.service = "SIP",
.common.account_id = p->exten,
.common.local_addr = {
.addr = &p->ourip,
.transport = security_event_get_transport(p)
},
.common.remote_addr = {
.addr = &p->sa,
.transport = security_event_get_transport(p)
},
.common.session_id = session_id,
.acl_name = aclname,
};
snprintf(session_id, sizeof(session_id), "%p", p);
ast_security_event_report(AST_SEC_EVT(&failed_acl_event));
}
void sip_report_inval_password(const struct sip_pvt *p, const char *response_challenge, const char *response_hash)
{
char session_id[32];
struct ast_security_event_inval_password inval_password = {
.common.event_type = AST_SECURITY_EVENT_INVAL_PASSWORD,
.common.version = AST_SECURITY_EVENT_INVAL_PASSWORD_VERSION,
.common.service = "SIP",
.common.account_id = p->exten,
.common.local_addr = {
.addr = &p->ourip,
.transport = security_event_get_transport(p)
},
.common.remote_addr = {
.addr = &p->sa,
.transport = security_event_get_transport(p)
},
.common.session_id = session_id,
.challenge = p->nonce,
.received_challenge = response_challenge,
.received_hash = response_hash,
};
snprintf(session_id, sizeof(session_id), "%p", p);
ast_security_event_report(AST_SEC_EVT(&inval_password));
}
void sip_report_auth_success(const struct sip_pvt *p, uint32_t using_password)
{
char session_id[32];
struct ast_security_event_successful_auth successful_auth = {
.common.event_type = AST_SECURITY_EVENT_SUCCESSFUL_AUTH,
.common.version = AST_SECURITY_EVENT_SUCCESSFUL_AUTH_VERSION,
.common.service = "SIP",
.common.account_id = p->exten,
.common.local_addr = {
.addr = &p->ourip,
.transport = security_event_get_transport(p)
},
.common.remote_addr = {
.addr = &p->sa,
.transport = security_event_get_transport(p)
},
.common.session_id = session_id,
.using_password = using_password,
};
snprintf(session_id, sizeof(session_id), "%p", p);
ast_security_event_report(AST_SEC_EVT(&successful_auth));
}
void sip_report_session_limit(const struct sip_pvt *p)
{
char session_id[32];
struct ast_security_event_session_limit session_limit = {
.common.event_type = AST_SECURITY_EVENT_SESSION_LIMIT,
.common.version = AST_SECURITY_EVENT_SESSION_LIMIT_VERSION,
.common.service = "SIP",
.common.account_id = p->exten,
.common.local_addr = {
.addr = &p->ourip,
.transport = security_event_get_transport(p)
},
.common.remote_addr = {
.addr = &p->sa,
.transport = security_event_get_transport(p)
},
.common.session_id = session_id,
};
snprintf(session_id, sizeof(session_id), "%p", p);
ast_security_event_report(AST_SEC_EVT(&session_limit));
}
void sip_report_failed_challenge_response(const struct sip_pvt *p, const char *response, const char *expected_response)
{
char session_id[32];
char account_id[256];
struct ast_security_event_chal_resp_failed chal_resp_failed = {
.common.event_type = AST_SECURITY_EVENT_CHAL_RESP_FAILED,
.common.version = AST_SECURITY_EVENT_CHAL_RESP_FAILED_VERSION,
.common.service = "SIP",
.common.account_id = account_id,
.common.local_addr = {
.addr = &p->ourip,
.transport = security_event_get_transport(p)
},
.common.remote_addr = {
.addr = &p->sa,
.transport = security_event_get_transport(p)
},
.common.session_id = session_id,
.challenge = p->nonce,
.response = response,
.expected_response = expected_response,
};
if (!ast_strlen_zero(p->from)) { /* When dialing, show account making call */
ast_copy_string(account_id, p->from, sizeof(account_id));
} else {
ast_copy_string(account_id, p->exten, sizeof(account_id));
}
snprintf(session_id, sizeof(session_id), "%p", p);
ast_security_event_report(AST_SEC_EVT(&chal_resp_failed));
}
void sip_report_chal_sent(const struct sip_pvt *p)
{
char session_id[32];
char account_id[256];
struct ast_security_event_chal_sent chal_sent = {
.common.event_type = AST_SECURITY_EVENT_CHAL_SENT,
.common.version = AST_SECURITY_EVENT_CHAL_SENT_VERSION,
.common.service = "SIP",
.common.account_id = account_id,
.common.local_addr = {
.addr = &p->ourip,
.transport = security_event_get_transport(p)
},
.common.remote_addr = {
.addr = &p->sa,
.transport = security_event_get_transport(p)
},
.common.session_id = session_id,
.challenge = p->nonce,
};
if (!ast_strlen_zero(p->from)) { /* When dialing, show account making call */
ast_copy_string(account_id, p->from, sizeof(account_id));
} else {
ast_copy_string(account_id, p->exten, sizeof(account_id));
}
snprintf(session_id, sizeof(session_id), "%p", p);
ast_security_event_report(AST_SEC_EVT(&chal_sent));
}
void sip_report_inval_transport(const struct sip_pvt *p, const char *transport)
{
char session_id[32];
struct ast_security_event_inval_transport inval_transport = {
.common.event_type = AST_SECURITY_EVENT_INVAL_TRANSPORT,
.common.version = AST_SECURITY_EVENT_INVAL_TRANSPORT_VERSION,
.common.service = "SIP",
.common.account_id = p->exten,
.common.local_addr = {
.addr = &p->ourip,
.transport = security_event_get_transport(p)
},
.common.remote_addr = {
.addr = &p->sa,
.transport = security_event_get_transport(p)
},
.common.session_id = session_id,
.transport = transport,
};
snprintf(session_id, sizeof(session_id), "%p", p);
ast_security_event_report(AST_SEC_EVT(&inval_transport));
}
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 sip_peer *peer_report;
enum check_auth_result res_report = res;
struct ast_str *buf;
char *c;
const char *authtoken;
char *reqheader, *respheader;
int result = 0;
char aclname[256];
struct digestkeys keys[] = {
[K_RESP] = { "response=", "" },
[K_URI] = { "uri=", "" },
[K_USER] = { "username=", "" },
[K_NONCE] = { "nonce=", "" },
[K_LAST] = { NULL, NULL}
};
peer_report = sip_find_peer(peer, addr, TRUE, FINDPEERS, FALSE, p->socket.type);
switch(res_report) {
case AUTH_DONT_KNOW:
break;
case AUTH_SUCCESSFUL:
if (peer_report) {
if (ast_strlen_zero(peer_report->secret) && ast_strlen_zero(peer_report->md5secret)) {
sip_report_auth_success(p, 0);
} else {
sip_report_auth_success(p, 1);
}
}
break;
case AUTH_CHALLENGE_SENT:
sip_report_chal_sent(p);
break;
case AUTH_SECRET_FAILED:
case AUTH_USERNAME_MISMATCH:
sip_auth_headers(WWW_AUTH, &respheader, &reqheader);
authtoken = sip_get_header(req, reqheader);
buf = ast_str_thread_get(&check_auth_buf, CHECK_AUTH_BUF_INITLEN);
ast_str_set(&buf, 0, "%s", authtoken);
c = ast_str_buffer(buf);
sip_digest_parser(c, keys);
if (res_report == AUTH_SECRET_FAILED) {
sip_report_inval_password(p, keys[K_NONCE].s, keys[K_RESP].s);
} else {
if (peer_report) {
sip_report_failed_challenge_response(p, keys[K_USER].s, peer_report->username);
}
}
break;
case AUTH_NOT_FOUND:
/* with sip_cfg.alwaysauthreject on, generates 2 events */
sip_report_invalid_peer(p);
break;
case AUTH_UNKNOWN_DOMAIN:
snprintf(aclname, sizeof(aclname), "domain_must_match");
sip_report_failed_acl(p, aclname);
break;
case AUTH_PEER_NOT_DYNAMIC:
snprintf(aclname, sizeof(aclname), "peer_not_dynamic");
sip_report_failed_acl(p, aclname);
break;
case AUTH_ACL_FAILED:
/* with sip_cfg.alwaysauthreject on, generates 2 events */
snprintf(aclname, sizeof(aclname), "device_must_match_acl");
sip_report_failed_acl(p, aclname);
break;
case AUTH_BAD_TRANSPORT:
sip_report_inval_transport(p, sip_get_transport(req->socket.type));
break;
case AUTH_RTP_FAILED:
break;
case AUTH_SESSION_LIMIT:
sip_report_session_limit(p);
break;
}
if (peer_report) {
sip_unref_peer(peer_report, "sip_report_security_event: sip_unref_peer: from handle_incoming");
}
return result;
}

View File

@ -1,49 +0,0 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 1999 - 2012, Digium, Inc.
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*!
* \file
* \brief Utility functions for chan_sip
*
* \author Terry Wilson <twilson@digium.com>
*/
/*** MODULEINFO
<support_level>deprecated</support_level>
***/
#include "asterisk.h"
#include "asterisk/utils.h"
#include "asterisk/cli.h"
#include "include/sip.h"
#include "include/sip_utils.h"
const char *force_rport_string(struct ast_flags *flags)
{
if (ast_test_flag(&flags[2], SIP_PAGE3_NAT_AUTO_RPORT)) {
return ast_test_flag(&flags[0], SIP_NAT_FORCE_RPORT) ? "Auto (Yes)" : "Auto (No)";
}
return AST_CLI_YESNO(ast_test_flag(&flags[0], SIP_NAT_FORCE_RPORT));
}
const char *comedia_string(struct ast_flags *flags)
{
if (ast_test_flag(&flags[2], SIP_PAGE3_NAT_AUTO_COMEDIA)) {
return ast_test_flag(&flags[1], SIP_PAGE2_SYMMETRICRTP) ? "Auto (Yes)" : "Auto (No)";
}
return AST_CLI_YESNO(ast_test_flag(&flags[1], SIP_PAGE2_SYMMETRICRTP));
}

View File

@ -7,6 +7,5 @@
; Any commands listed in this section will get automatically executed
; when Asterisk starts as a daemon or foreground process (-c).
;
;sip set debug on = yes
;core set verbose 3 = yes
;core set debug 1 = yes

View File

@ -137,8 +137,6 @@ show queue=queue show
add queue member=queue add member
remove queue member=queue remove member
ael no debug=ael nodebug
sip debug=sip set debug
sip no debug=sip set debug off
show voicemail users=voicemail show users
show voicemail zones=voicemail show zones
iax2 trunk debug=iax2 set debug trunk
@ -173,7 +171,6 @@ core set chanvar=dialplan set chanvar
agi dumphtml=agi dump html
ael debug=ael set debug
funcdevstate list=devstate list
sip history=sip set history on
abort shutdown=core abort shutdown
stop now=core stop now
stop gracefully=core stop gracefully

View File

@ -30,7 +30,7 @@ default_perm=permit ; To leave asterisk working as normal
; This list is read in the sequence that is being written, so
; In this example the user 'eliel' is allow to run only the following
; commands:
; sip show peer
; pjsip show endpoints
; core set debug
; core set verbose
; If the user is not specified, the default_perm option will be apply to
@ -39,14 +39,14 @@ default_perm=permit ; To leave asterisk working as normal
; Notice that you can also use regular expressions to allow or deny access to a
; certain command like: 'core show application D*'. In this example the user will be
; allowed to view the documentation for all the applications starting with 'D'.
; Another regular expression could be: 'channel originate SIP/[0-9]* extension *'
; allowing the user to use 'channel originate' on a sip channel and with the 'extension'
; Another regular expression could be: 'channel originate PJSIP/[0-9]* extension *'
; allowing the user to use 'channel originate' on a pjsip channel and with the 'extension'
; parameter and avoiding the use of the 'application' parameter.
;
; We can also use the templates syntax:
; [supportTemplate](!)
; deny=all
; permit=sip show ; all commands starting with 'sip show' will be allowed
; permit=pjsip show ; all commands starting with 'pjsip show' will be allowed
; permit=core show
;
; You can specify permissions for a local group instead of a user,
@ -55,20 +55,20 @@ default_perm=permit ; To leave asterisk working as normal
;
;[@adm]
;deny=all
;permit=sip
;permit=pjsip
;permit=core
;
;
;[eliel]
;deny=all
;permit=sip show peer
;deny=sip show peers
;permit=pjsip show endpoint
;deny=pjsip show endpoints
;permit=core set
;
;
;User 'tommy' inherits from template 'supportTemplate':
; deny=all
; permit=sip show
; permit=pjsip show
; permit=core show
;[tommy](supportTemplate)
;permit=core set debug

View File

@ -83,10 +83,10 @@ genericplc_on_equal_codecs => false
; Once this config file is loaded, silk8 can be used anywhere a
; peer's codec capabilities are defined.
;
; In sip.conf 'silk8' can be defined as a capability for a peer.
; [peer1]
; In pjsip.conf 'silk8' can be defined as a capability for an endpoint.
; [endpoint1]
; type=peer
; host=dynamic
; aor=endpoint1
; disallow=all
; allow=silk8 ;custom codec defined in codecs.conf
;

View File

@ -76,8 +76,6 @@
;
;iaxusers => odbc,asterisk
;iaxpeers => odbc,asterisk
;sippeers => odbc,asterisk
;sipregs => odbc,asterisk ; (avoid sipregs if possible, e.g. by using a view)
;ps_endpoints => odbc,asterisk
;ps_auths => odbc,asterisk
;ps_aors => odbc,asterisk

View File

@ -129,7 +129,7 @@ context ael-dundi-e164-customers {
//
// If you are an ITSP or Reseller, list your customers here.
//
//_12564286000 => Dial(SIP/customer1);
//_12564286000 => Dial(PJSIP/customer1);
//_12564286001 => Dial(IAX2/customer2);
};
@ -143,7 +143,7 @@ context ael-dundi-e164-via-pstn {
context ael-dundi-e164-local {
//
// Context to put your dundi IAX2 or SIP user in for
// Context to put your dundi or IAX2 user in for
// full access
//
includes {
@ -396,11 +396,8 @@ context ael-default {
};
//
// Extensions like the two below can be used for FWD, Nikotel, sipgate etc.
// Note that you must have a [sipprovider] section in sip.conf whereas
// the otherprovider.net example does not require such a peer definition
//
//_41X. => Dial(SIP/${EXTEN:2}@sipprovider,,r);
//_42X. => Dial(SIP/user:passwd@${EXTEN:2}@otherprovider.net,30,rT);
//_42X. => Dial(PJSIP/user:passwd@${EXTEN:2}@otherprovider.net,30,rT);
// Real extensions would go here. Generally you want real extensions to be
// 4 or 5 digits long (although there is no such requirement) and start with a
@ -409,8 +406,8 @@ context ael-default {
// them with names, too, and use global variables
// 6245 => {
// hint(SIP/Grandstream1&SIP/Xlite1,Joe Schmoe); // Channel hints for presence
// Dial(SIP/Grandstream1,20,rt); // permit transfer
// hint(PJSIP/Grandstream1&PJSIP/Xlite1,Joe Schmoe); // Channel hints for presence
// Dial(PJSIP/Grandstream1,20,rt); // permit transfer
// Dial(${HINT}/5245},20,rtT); // Use hint as listed
// switch(${DIALSTATUS}) {
// case BUSY:

View File

@ -426,14 +426,14 @@ exten => _X!,1,Verbose(2,Performing ISN lookup for ${EXTEN})
same => n,GotoIf($["${FILTER(0-9,${SUFFIX})}" != "${SUFFIX}"]?fn-CONGESTION,1)
; filter out bad characters per the README-SERIOUSLY.best-practices.txt document
same => n,Set(TIMEOUT(absolute)=10800)
same => n,Set(isnresult=${ENUMLOOKUP(${EXTEN},sip,,1,freenum.org)}) ; perform our lookup with freenum.org
same => n,Set(isnresult=${ENUMLOOKUP(${EXTEN},pjsip,,1,freenum.org)}) ; perform our lookup with freenum.org
same => n,GotoIf($["${isnresult}" != ""]?from)
same => n,Set(DIALSTATUS=CONGESTION)
same => n,Goto(fn-CONGESTION,1)
same => n(from),Set(__SIPFROMUSER=${CALLERID(num)})
same => n,GotoIf($["${GLOBAL(FREENUMDOMAIN)}" = ""]?dial) ; check if we set the FREENUMDOMAIN global variable in [global]
same => n,Set(__SIPFROMDOMAIN=${GLOBAL(FREENUMDOMAIN)}) ; if we did set it, then we'll use it for our outbound dialing domain
same => n(dial),Dial(SIP/${isnresult},40)
same => n(dial),Dial(PJSIP/${isnresult},40)
same => n,Goto(fn-${DIALSTATUS},1)
exten => fn-BUSY,1,Busy()
@ -661,9 +661,7 @@ exten => _X.,1,Gosub(sub-page,s,1(SIP/${EXTEN}))
[public]
;
; ATTENTION: If your Asterisk is connected to the internet and you do
; not have allowguest=no in sip.conf, everybody out there may use your
; public context without authentication. In that case you want to
; ATTENTION: If your Asterisk is connected to the internet,
; double check which services you offer to the world.
;
include => demo
@ -675,20 +673,14 @@ include => demo
;
include => demo
;
; An extension like the one below can be used for FWD, Nikotel, sipgate etc.
; Note that you must have a [sipprovider] section in sip.conf
;
;exten => _41X.,1,Dial(SIP/${FILTER(0-9,${EXTEN:2})}@sipprovider,,r)
; Real extensions would go here. Generally you want real extensions to be
; 4 or 5 digits long (although there is no such requirement) and start with a
; single digit that is fairly large (like 6 or 7) so that you have plenty of
; room to overlap extensions and menu options without conflict. You can alias
; them with names, too, and use global variables
;exten => 6245,hint,SIP/Grandstream1&SIP/Xlite1(Joe Schmoe) ; Channel hints for presence
;exten => 6245,1,Dial(SIP/Grandstream1,20,rt) ; permit transfer
;exten => 6245,hint,PJSIP/Grandstream1&PJSIP/Xlite1(Joe Schmoe) ; Channel hints for presence
;exten => 6245,1,Dial(PJSIP/Grandstream1,20,rt) ; permit transfer
;exten => 6245,n(dial),Dial(${HINT},20,rtT) ; Use hint as listed
;exten => 6245,n,VoiceMail(6245,u) ; Voicemail (unavailable)
;exten => 6245,s+1,Hangup ; s+1, same as n
@ -708,7 +700,7 @@ include => demo
;exten => wil,1,Goto(6236,1)
;If you want to subscribe to the status of a parking space, this is
;how you do it. Subscribe to extension 6600 in sip, and you will see
;how you do it. Subscribe to extension 6600, and you will see
;the status of the first parking lot with this extensions' help
;exten => 6600,hint,park:701@parkedcalls
;exten => 6600,1,noop
@ -758,7 +750,7 @@ include => demo
;
;exten => t,1,Goto(s,goodbye)
;
; this is the context our internal SIP hardphones use (see sip.conf)
; this is the context our internal SIP hardphones use
;
;[acme-internal]
;exten => s,1,Answer()
@ -799,28 +791,6 @@ include => demo
; ...
; include => time
;
; Note: if you're geographically spread out, you can have SIP extensions
; specify their own local timezone in sip.conf as:
;
; [boi]
; type=friend
; context=acme-internal
; callerid="Boise Ofc. <2083451111>"
; ...
; ; use system-wide default timezone of MST7MDT
;
; [lws]
; type=friend
; context=acme-internal
; callerid="Lewiston Ofc. <2087431111>"
; ...
; setvar=timezone=PST8PDT
;
; "timezone" isn't a 'reserved' name in any way, and other places where
; the timezone is significant (e.g. calls to "SayUnixTime()", etc) will
; require modification as well. Note that voicemail.conf already has
; a mechanism for timezones.
;
[time]
exten => _X.,30000(time),NoOp(Time: ${EXTEN} ${timezone})
@ -831,7 +801,6 @@ exten => _X.,30000(time),NoOp(Time: ${EXTEN} ${timezone})
same => n,Set(FUTURETIME=$[${EPOCH} + 12])
same => n,SayUnixTime(${FUTURETIME},Zulu,HNS)
same => n,SayPhonetic(z)
; use the timezone associated with the extension (sip only), or system-wide
; default if one hasn't been set.
same => n,SayUnixTime(${FUTURETIME},${timezone},HNS)
same => n,Playback(spy-local)

View File

@ -215,9 +215,7 @@ extensions = {
};
public = {
-- ATTENTION: If your Asterisk is connected to the internet and you do
-- not have allowguest=no in sip.conf, everybody out there may use your
-- public context without authentication. In that case you want to
-- ATTENTION: If your Asterisk is connected to the internet
-- double check which services you offer to the world.
--
include = {"demo"};

View File

@ -27,9 +27,8 @@ capture_id = 1234 ; A unique integer identifier for this
; with each packet from this server.
uuid_type = call-id ; Specify the preferred source for the Homer
; correlation UUID. Valid options are:
; - 'call-id' for the PJSIP or chan_sip SIP
; Call-ID
; - 'call-id' for the PJSIP
; - 'channel' for the Asterisk channel name
; Note: If 'call-id' is specified but the
; channel is not PJSIP or chan_sip then the
; Asterisk channel name will be used instead.
; channel is not PJSIP then the Asterisk
; channel name will be used instead.

View File

@ -43,9 +43,6 @@ noload = res_hep.so
noload = res_hep_pjsip.so
noload = res_hep_rtcp.so
;
; Do not load chan_sip by default, it may conflict with res_pjsip.
noload = chan_sip.so
;
; Load one of the voicemail modules as they are mutually exclusive.
; By default, load app_voicemail only (automatically).
;

View File

@ -1,16 +1,15 @@
[general]
; This section applies only to the default sip.conf/users.conf config provider
; This section applies only to the default users.conf config provider
; embedded in res_phoneprov. Other providers may provide their own default settings.
; The default behavior of res_phoneprov will be to set the SERVER template variable to
; the IP address that the phone uses to contact the provisioning server and the
; SERVER_PORT variable to the bindport setting in sip.conf. Unless you have a very
; unusual setup, you should not need to set serveraddr, serveriface, or serverport.
; the IP address that the phone uses to contact the provisioning server. Unless you have
; an unusual setup, you should not need to set serveraddr, serveriface, or serverport.
;serveraddr=192.168.1.1 ; Override address to send to the phone to use as server address.
;serveriface=eth0 ; Same as above, except an ethernet interface.
; Useful for when the interface uses DHCP and the asterisk http
; server listens on a different IP than chan_sip.
; server listens on a different IP than sip.
;serverport=5060 ; Override port to send to the phone to use as server port.
default_profile=polycom ; The default profile to use if none specified in users.conf

View File

@ -17,7 +17,7 @@
; and writes should be performed to the same database.
;
; For example, in extconfig.conf, you could specify a line like:
; sippeers => mysql,readhost.asterisk/writehost.asterisk,sippeers
; queue_members => mysql,readhost.asterisk/writehost.asterisk,queue_members
; and then define the contexts [readhost.asterisk] and [writehost.asterisk]
; below.
;

View File

@ -7,9 +7,7 @@
; In order to use this module, you start
; in extconfig.conf with a configuration like this:
;
; sippeers = ldap,"dc=myDomain,dc=myDomainExt",sip
; extensions = ldap,"dc=myDomain,dc=myDomainExt",extensions
; sip.conf = ldap,"dc=myDomain,dc=myDomainExt",config
;
; In the case of LDAP the last keyword in each line above specifies
; a section in this file.
@ -70,60 +68,6 @@ app = AstExtensionApplication
appdata = AstExtensionApplicationData
additionalFilter=(objectClass=AstExtension)
;
; Sip Users Table
;
[sip]
name = cn ; We use the "cn" as the default value for name on the line above
; because objectClass=AsteriskSIPUser does not include a uid as an allowed field
; If your entry combines other objectClasses and uid is available, you may
; prefer to change the line to be name = uid, especially if your LDAP entries
; contain spaces in the cn field.
; You may also find it appropriate to use something completely different.
; This is possible by changing the line above to name = AstAccountName (or whatever you
; prefer).
;
amaflags = AstAccountAMAFlags
callgroup = AstAccountCallGroup
callerid = AstAccountCallerID
directmedia = AstAccountDirectMedia
context = AstAccountContext
dtmfmode = AstAccountDTMFMode
fromuser = AstAccountFromUser
fromdomain = AstAccountFromDomain
fullcontact = AstAccountFullContact
fullcontact = gecos
host = AstAccountHost
insecure = AstAccountInsecure
mailbox = AstAccountMailbox
md5secret = AstAccountRealmedPassword ; Must be an MD5 hash. Field value can start with
; {md5} but it is not required.
; Generate the password via the md5sum command, e.g.
; echo "my_password" | md5sum
nat = AstAccountNAT
deny = AstAccountDeny
permit = AstAccountPermit
pickupgroup = AstAccountPickupGroup
port = AstAccountPort
qualify = AstAccountQualify
restrictcid = AstAccountRestrictCID
rtptimeout = AstAccountRTPTimeout
rtpholdtimeout = AstAccountRTPHoldTimeout
type = AstAccountType
disallow = AstAccountDisallowedCodec
allow = AstAccountAllowedCodec
MusicOnHold = AstAccountMusicOnHold
regseconds = AstAccountExpirationTimestamp
regcontext = AstAccountRegistrationContext
regexten = AstAccountRegistrationExten
CanCallForward = AstAccountCanCallForward
ipaddr = AstAccountIPAddress
defaultuser = AstAccountDefaultUser
regserver = AstAccountRegistrationServer
lastms = AstAccountLastQualifyMilliseconds
supportpath = AstAccountPathSupport
additionalFilter=(objectClass=AsteriskSIPUser)
;
; IAX Users Table
;

View File

@ -6,11 +6,10 @@
; provided by the STUN server an event is sent out internally within Asterisk
; to alert all listeners to that event of the change.
; The current default listeners for the network change event include chan_sip
; and chan_iax. Both of these channel drivers by default react to this event
; by renewing all outbound registrations. This allows the endpoints Asterisk
; is registering with to become aware of the address change and know the new
; location.
; The current default listeners for the network change event include chan_iax.
; Both of these channel drivers by default react to this event by renewing all
; outbound registrations. This allows the endpoints Asterisk is registering with
; to become aware of the address change and know the new location.
;
[general]
;

File diff suppressed because it is too large Load Diff

View File

@ -1,57 +0,0 @@
; rfc3842
; put empty "Content=>" at the end to have CRLF after last body line
[clear-mwi]
Event=>message-summary
Content-type=>application/simple-message-summary
Content=>Messages-Waiting: no
Content=>Message-Account: sip:asterisk@127.0.0.1
Content=>Voice-Message: 0/0 (0/0)
Content=>
; Aastra
[aastra-check-cfg]
Event=>check-sync
[aastra-xml]
Event=>aastra-xml
; Digium
[digium-check-cfg]
Event=>check-sync
; Linksys
[linksys-cold-restart]
Event=>reboot_now
[linksys-warm-restart]
Event=>restart_now
; Polycom
[polycom-check-cfg]
Event=>check-sync
; Sipura
[sipura-check-cfg]
Event=>resync
[sipura-get-report]
Event=>report
; snom
[snom-check-cfg]
Event=>check-sync\;reboot=false
[snom-reboot]
Event=>check-sync\;reboot=true
; Cisco
[cisco-check-cfg]
Event=>check-sync

View File

@ -4,12 +4,12 @@
; Creating entries in users.conf is a "shorthand" for creating individual
; entries in each configuration file. Using users.conf is not intended to
; provide you with as much flexibility as using the separate configuration
; files (e.g. sip.conf, iax.conf, etc) but is intended to accelerate the
; files (e.g. iax.conf, etc) but is intended to accelerate the
; simple task of adding users. Note that creating individual items (e.g.
; custom SIP peers, IAX friends, etc.) will allow you to override specific
; parameters within this file. Parameter names here are the same as they
; appear in the other configuration files. There is no way to change the
; value of a parameter here for just one subsystem.
; IAX friends, etc.) will allow you to override specific parameters within
; this file. Parameter names here are the same as they appear in the
; other configuration files. There is no way to change the value of a
; parameter here for just one subsystem.
;
[general]
@ -30,10 +30,6 @@ hasvoicemail = yes
;
vmsecret = 1234
;
; Create SIP Peer
;
hassip = yes
;
; Create IAX friend
;
hasiax = yes
@ -94,7 +90,6 @@ pickupgroup = 1
;dahdichan = 1
;hasvoicemail = yes
;vmsecret = 1234
;hassip = yes
;hasiax = no
;hash323 = no
;hasmanager = no

View File

@ -15,7 +15,7 @@ SYNOPSIS
$prog [ --help ] | [ [ --reset ] | [
[ --uniqueid="<uniqueid>" ]
[ --pjsip-debug=<on|off> ] [ --sip-debug=<on|off> ]
[ --pjsip-debug=<on|off> ]
[ --iax2-debug=<on|off> ]
[ --agi-debug=<on|off> ] [ --ami-debug=<on|off> ]
@ -26,7 +26,7 @@ SYNOPSIS
[ --dtmf-debug=<on|off> ] [ --fax-debug=<on|off> ]
[ --security-debug=<on|off> ]
[ --pjsip-history=<on|off> ] [ --sip-history=<on|off> ]
[ --pjsip-history=<on|off> ]
[ --verbose=<level> ] [ --debug=<level> ]
] ]
@ -51,7 +51,7 @@ DESCRIPTION
on/off commands will use the same uniqueid. Use the --reset
option to reset it (and everything else).
--pjsip-debug --sip-debug --iax2-debug --agi-debug --ami-debug
--pjsip-debug --iax2-debug --agi-debug --ami-debug
--ari-debug --cdr-debug --channel-debug --rtp-debug --rtcp-debug
Issues the subsystem appropriate command to turn on
or off debugging. These are usually functional debug messages
@ -62,10 +62,10 @@ DESCRIPTION
These subsystems set up their own log channels so if turned
on, log files will be created in \$astlogdir for them.
--pjsip-history --sip-history
The pjsip and sip channels have the ability to output an
abbreviated, one-line, packet summary. If enabled, the summaries
will be written to \$astlogdir/pjsip_history.\$UNIQUEID and
--pjsip-history
The pjsip channels have the ability to output an abbreviated,
one-line, packet summary. If enabled, the summaries will be
written to \$astlogdir/pjsip_history.\$UNIQUEID and
\$astlogdir/sip_history.\$UNIQUEID.
--verbose-level --debug-level
@ -114,7 +114,6 @@ RESET=false
declare -A DEBUG_COMMANDS=(
[PJSIP,on]="pjsip set logger on" [PJSIP,off]="pjsip set logger off"
[SIP,on]="sip set debug on" [SIP,off]="sip set debug off"
[IAX2,on]="iax2 set debug on" [IAX2,off]="iax2 set debug off"
[ARI,on]="ari set debug all on" [ARI,off]="ari set debug all off"
[AMI,on]="manager set debug on" [AMI,off]="manager set debug off"
@ -152,8 +151,6 @@ for a in "$@" ; do
DEBUGS=true
;;
--pjsip-history=*)
;&
--sip-history=*)
subsystem=${a%-history=*}
subsystem=${subsystem#--}
if [[ ${a#*=} =~ ^[Yy].* ]] ; then
@ -224,8 +221,6 @@ if $RESET ; then
asterisk -rx "core set debug 0"
asterisk -rx "pjsip set logger off"
asterisk -rx "pjsip set history off"
asterisk -rx "sip set debug off"
asterisk -rx "sip set history off"
asterisk -rx "iax2 set debug off"
asterisk -rx "manager set debug off"
asterisk -rx "ari set debug all off"
@ -259,9 +254,6 @@ if ! grep -q "; --START DEBUG_LOGGING-- ;" $CLI_CONF ; then
[pjsip_debug](!)
pjsip set logger on = yes
[sip_debug](!)
sip set debug on = yes
[iax2_debug](!)
iax2 set debug on = yes
@ -299,10 +291,6 @@ if ! grep -q "; --START DEBUG_LOGGING-- ;" $CLI_CONF ; then
logger add channel $PJSIP_HISTORY_LOG PJSIP_HISTORY = yes
pjsip set history on = yes
[sip_history](!)
logger add channel $SIP_HISTORY_LOG SIP_HISTORY = yes
sip set history on = yes
[verbose_level](!)
core set verbose 3 = yes
@ -327,13 +315,12 @@ else
VERBOSE_LOG=$(sed -n -r -e "s@logger add channel ($LOG_DIR/message\..+)\s+NOTICE.*@\1@p" "$CLI_CONF")
DEBUG_LOG=$(sed -n -r -e "s@logger add channel ($LOG_DIR/debug\..+)\s+DEBUG.*@\1@p" "$CLI_CONF")
PJSIP_HISTORY_LOG=$(sed -n -r -e "s@logger add channel ($LOG_DIR/pjsip_history\..+)\s+PJSIP.*@\1@p" "$CLI_CONF")
SIP_HISTORY_LOG=$(sed -n -r -e "s@logger add channel ($LOG_DIR/sip_history\..+)\s+SIP.*@\1@p" "$CLI_CONF")
DTMF_LOG=$(sed -n -r -e "s@logger add channel ($LOG_DIR/dtmf\..+)\s+DTMF.*@\1@p" "$CLI_CONF")
FAX_LOG=$(sed -n -r -e "s@logger add channel ($LOG_DIR/fax\..+)\s+FAX.*@\1@p" "$CLI_CONF")
SECURITY_LOG=$(sed -n -r -e "s@logger add channel ($LOG_DIR/security\..+)\s+SECURITY.*@\1@p" "$CLI_CONF")
fi
for x in PJSIP SIP ARI AMI AGI ARI IAX2 CDR RTP RTCP ; do
for x in PJSIP ARI AMI AGI ARI IAX2 CDR RTP RTCP ; do
if eval \$${x}_DEBUG_SPECIFIED ; then
if eval \$${x}_DEBUG ; then
if $ASTERISK_IS_RUNNING ; then
@ -367,7 +354,7 @@ for x in DTMF FAX SECURITY ; do
fi
done
for x in PJSIP SIP ; do
for x in PJSIP ; do
if eval \$${x}_HISTORY_SPECIFIED ; then
if eval \$${x}_HISTORY ; then
if $ASTERISK_IS_RUNNING ; then

View File

@ -192,7 +192,6 @@ if [ -e /var/run/asterisk.ctl ] || [ -e /var/run/asterisk/asterisk.ctl ]; then
"core show uptime" "core show settings" "core show sysinfo" "core show channels" \
"pri show spans" "dahdi show status" "dahdi show channels" "dahdi show channel 1" \
"pjsip show endpoints" "pjsip show registrations" "pjsip list channels" \
"sip show peers" "sip show registry" "sip show channels" "sip show subscriptions" "sip show settings" \
"show g729" "g729 show version" "g729 show licenses" "g729 show hostid" \
"digium_phones show version" "digium_phones show alerts" "digium_phones show applications" \
"digium_phones show firmwares" "digium_phones show lines" "digium_phones show networks" \

View File

@ -1,92 +0,0 @@
#!/usr/bin/perl -Tw
# Retrieves the sip user/peer entries from the database
# Use these commands to create the appropriate tables in MySQL
#
#CREATE TABLE sip (id INT(11) DEFAULT -1 NOT NULL,keyword VARCHAR(20) NOT NULL,data VARCHAR(50) NOT NULL, flags INT(1) DEFAULT 0 NOT NULL,PRIMARY KEY (id,keyword));
#
# if flags = 1 then the records are not included in the output file
use DBI;
################### BEGIN OF CONFIGURATION ####################
# the name of the extensions table
$table_name = "sip";
# the path to the extensions.conf file
# WARNING: this file will be substituted by the output of this program
$sip_conf = "/etc/asterisk/sip_additional.conf";
# the name of the box the MySQL database is running on
$hostname = "localhost";
# the name of the database our tables are kept
$database = "sip";
# username to connect to the database
$username = "root";
# password to connect to the database
$password = "";
################### END OF CONFIGURATION #######################
$additional = "";
open EXTEN, ">$sip_conf" || die "Cannot create/overwrite extensions file: $sip_conf\n";
$dbh = DBI->connect("dbi:mysql:dbname=$database;host=$hostname", "$username", "$password");
$statement = "SELECT keyword,data from $table_name where id=0 and keyword <> 'account' and flags <> 1";
my $result = $dbh->selectall_arrayref($statement);
unless ($result) {
# check for errors after every single database call
print "dbh->selectall_arrayref($statement) failed!\n";
print "DBI::err=[$DBI::err]\n";
print "DBI::errstr=[$DBI::errstr]\n";
exit;
}
my @resultSet = @{$result};
if ( $#resultSet > -1 ) {
foreach $row (@{ $result }) {
my @result = @{ $row };
$additional .= $result[0]."=".$result[1]."\n";
}
}
$statement = "SELECT data,id from $table_name where keyword='account' and flags <> 1 group by data";
$result = $dbh->selectall_arrayref($statement);
unless ($result) {
# check for errors after every single database call
print "dbh->selectall_arrayref($statement) failed!\n";
print "DBI::err=[$DBI::err]\n";
print "DBI::errstr=[$DBI::errstr]\n";
}
@resultSet = @{$result};
if ( $#resultSet == -1 ) {
print "No sip accounts defined in $table_name\n";
exit;
}
foreach my $row ( @{ $result } ) {
my $account = @{ $row }[0];
my $id = @{ $row }[1];
print EXTEN "[$account]\n";
$statement = "SELECT keyword,data from $table_name where id=$id and keyword <> 'account' and flags <> 1 order by keyword";
my $result = $dbh->selectall_arrayref($statement);
unless ($result) {
# check for errors after every single database call
print "dbh->selectall_arrayref($statement) failed!\n";
print "DBI::err=[$DBI::err]\n";
print "DBI::errstr=[$DBI::errstr]\n";
exit;
}
my @resSet = @{$result};
if ( $#resSet == -1 ) {
print "no results\n";
exit;
}
foreach my $row ( @{ $result } ) {
my @result = @{ $row };
print EXTEN "$result[0]=$result[1]\n";
}
print EXTEN "$additional\n";
}
exit 0;

View File

@ -1,67 +0,0 @@
#!/bin/sh
# sip_nat_settings: generate NAT settings for sip.conf of an Asterisk system
# that is behind a NAT router.
#
# This is a script to generate sane defaults for externip and localnet
# of sip.conf. The output should be included in the [general] section of
# sip.conf .
#
# Multiple network interfaces: If you have multiple network interfaces,
# this script will generate a 'localnet' line for each of them that has a
# broadcast (ipv4) address, except the loopback interface (lo). You can
# later rem-out all of those you don't need.
#
# Alternatively, provide a network interface as a parameter an a localnet
# line will only be generated for its network.
#
# Copyright (C) 2005 by Tzafrir Cohen <tzafrir.cohen@xorcom.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# see http://unix.stackexchange.com/q/22615
externip=`dig @resolver1.opendns.com -4 myip.opendns.com A +short`
# optional parameter: network interface to use. By default: none.
IFACE="$1"
OS=`uname -s`
case "$OS" in
Linux)
echo "externip = $externip"
if [ -x "${IFACE}" ]; then
ip --brief -family inet address show scope global up dev $IFACE | awk '{print "localnet = " $3}'
else
ip --brief -family inet address show scope global up | awk '{print "localnet = " $3}'
fi
;;
OpenBSD|FreeBSD)
if [ "${OS}" = "FreeBSD" ]; then
VER=`uname -r | cut -d . -f 1`
if [ ${VER} -lt 7 ]; then
echo "Unsupported OS"
exit 1
fi
fi
echo "externip = $externip"
ip=`/sbin/ifconfig $IFACE | awk '/\tinet .* broadcast/{print $6}'`
x=`/sbin/ifconfig $IFACE | awk '/\tinet .* broadcast/{print $4}'`
printf 'localnet = %s/%u.%u.%u.%u\n' $ip $(($x>>24&0xff)) $(($x>>16&0xff)) $(($x>>8&0xff)) $(($x&0xff))
;;
*)
echo >&2 "$0: Unsupported OS $OS"
exit 1
;;
esac

View File

@ -17,10 +17,6 @@ ListenStream=0.0.0.0:5039
ListenStream=127.0.0.1:8088
# HTTPS
ListenStream=127.0.0.1:8089
# chan_sip TCP
ListenStream=0.0.0.0:5060
# chan_sip TLS
ListenStream=0.0.0.0:5061
[Install]
WantedBy=sockets.target

View File

@ -0,0 +1,6 @@
Subject: chan_sip
Master-Only: True
This module was deprecated in Asterisk 17
and is now being removed in accordance with
the Asterisk Module Deprecation policy.

View File

@ -57,7 +57,7 @@
<parameter name="number" required="true" />
<parameter name="method-type">
<para>If no <replaceable>method-type</replaceable> is given, the default will be
<literal>sip</literal>.</para>
<literal>pjsip</literal>.</para>
</parameter>
<parameter name="zone-suffix">
<para>If no <replaceable>zone-suffix</replaceable> is given, the default will be
@ -96,7 +96,7 @@
<parameter name="number" required="true" />
<parameter name="method-type">
<para>If no <replaceable>method-type</replaceable> is given, the default will be
<literal>sip</literal>.</para>
<literal>pjsip</literal>.</para>
</parameter>
<parameter name="options">
<optionlist>
@ -185,7 +185,7 @@ static int function_enum(struct ast_channel *chan, const char *cmd, char *data,
if (args.tech && !ast_strlen_zero(args.tech)) {
ast_copy_string(tech,args.tech, sizeof(tech));
} else {
ast_copy_string(tech,"sip",sizeof(tech));
ast_copy_string(tech,"pjsip",sizeof(tech));
}
if (!args.zone) {
@ -279,7 +279,7 @@ static int enum_query_read(struct ast_channel *chan, const char *cmd, char *data
if (!args.zone)
args.zone = "e164.zone";
ast_copy_string(tech, args.tech ? args.tech : "sip", sizeof(tech));
ast_copy_string(tech, args.tech ? args.tech : "pjsip", sizeof(tech));
if (!(erds = ast_calloc(1, sizeof(*erds))))
goto finish;

View File

@ -518,7 +518,7 @@ struct ast_cc_monitor {
* \details
* When issuing a CC recall, some technologies will require
* that a name other than the device name is dialed. For instance,
* with SIP, a specific URI will be used which chan_sip will be able
* with SIP, a specific URI will be used which sip will be able
* to recognize as being a CC recall. Similarly, ISDN will need a specific
* dial string to know that the call is a recall.
*/

View File

@ -616,7 +616,7 @@ struct ast_msg_data;
* Structure to describe a channel "technology", ie a channel driver
* See for examples:
* \arg chan_iax2.c - The Inter-Asterisk exchange protocol
* \arg chan_sip.c - The SIP channel driver
* \arg chan_pjsip.c - The SIP channel driver
* \arg chan_dahdi.c - PSTN connectivity (TDM, PRI, T1/E1, FXO, FXS)
*
* \details

View File

@ -124,8 +124,8 @@ struct aco_type {
const char *name; /*!< The name of this type (must match XML documentation) */
const char *category; /*!< A regular expression for matching categories to be allowed or denied */
const char *matchfield; /*!< An option name to match for this type (i.e. a 'type'-like column) */
const char *matchvalue; /*!< The value of the option to require for matching (i.e. 'peer' for type= in sip.conf) */
aco_matchvalue_func matchfunc; /*!< A function for determining whether the option value matches (i.e. hassip= requires ast_true()) */
const char *matchvalue; /*!< The value of the option to require for matching (i.e. 'peer') */
aco_matchvalue_func matchfunc; /*!< A function for determining whether the option value matches */
enum aco_category_op category_match; /*!< Whether the following category regex is a whitelist or blacklist */
size_t item_offset; /*!< The offset in the config snapshot for the global config or item config container */
unsigned int hidden; /*!< Type is for internal purposes only and it and all options should not be visible to users */

View File

@ -497,7 +497,7 @@ Example dialplan:
<code>exten => 5551212,n,Hangup()</code><br/>
-# <b>Call Setup:</b> An incoming SIP INVITE begins this scenario. It is received by
the SIP channel driver (chan_sip.c). Specifically, the monitor thread in chan_sip
the SIP channel driver (chan_pjsip.c). Specifically, the monitor thread in chan_pjsip
is responsible for handling this incoming request. Further, the monitor thread
is responsible for completing any handshake necessary to complete the call setup
process.
@ -517,8 +517,8 @@ Example dialplan:
code simply executes the ast_answer() API call. This API call operates on an
ast_channel. It handles generic ast_channel hangup processing, as well as executes
the answer callback function defined in the associated ast_channel_tech for the
active channel. In this case, the sip_answer() function in chan_sip.c will get
executed to handle the SIP specific operations required to answer a call.
active channel. In this case, the chan_pjsip_answer() function in chan_pjsip.c will
get executed to handle the SIP specific operations required to answer a call.
-# <b>Play the File:</b> The next step of the dialplan says to play back a %sound file
to the caller. The <code>Playback()</code> application will be executed.
The code for this application is in apps/app_playback.c. The code in the application
@ -562,7 +562,7 @@ Example dialplan:
<code>exten => 5551212,n,Dial(IAX2/mypeer)</code><br/>
-# <b>Call Setup:</b> An incoming SIP INVITE begins this scenario. It is received by
the SIP channel driver (chan_sip.c). Specifically, the monitor thread in chan_sip
the SIP channel driver (chan_pjsip.c). Specifically, the monitor thread in chan_pjsip
is responsible for handling this incoming request. Further, the monitor thread
is responsible for completing any handshake necessary to complete the call setup
process.

View File

@ -250,7 +250,7 @@
/*!
* \page Config_rtp RTP configuration
* \arg Implemented in \ref rtp.c
* Used in \ref chan_sip.c (and various H.323 channels)
* Used in various H.323 channels
* \section rtpconf rtp.conf
* \verbinclude rtp.conf.sample
*/

View File

@ -242,7 +242,7 @@ int ast_update_module_list_condition(int (*modentry)(const char *module, const c
/*!
* \brief Check if module with the name given is loaded
* \param name Module name, like "chan_sip.so"
* \param name Module name, like "chan_pjsip.so"
* \retval 1 if true
* \retval 0 if false
*/

View File

@ -112,7 +112,7 @@ struct ast_channel_snapshot_base {
);
struct timeval creationtime; /*!< The time of channel creation */
int tech_properties; /*!< Properties of the channel's technology */
AST_STRING_FIELD_EXTENDED(protocol_id); /*!< Channel driver protocol id (i.e. Call-ID for chan_sip/chan_pjsip) */
AST_STRING_FIELD_EXTENDED(protocol_id); /*!< Channel driver protocol id (i.e. Call-ID for chan_pjsip) */
};
/*!

View File

@ -26,7 +26,7 @@
* in or out the DO_SSL macro.
*
* TLS/SSL support is basically implemented by reading from a config file
* (currently manager.conf, http.conf and sip.conf) the names of the certificate
* (currently manager.conf, http.conf and pjsip.conf) the names of the certificate
* files and cipher to use, and then run ssl_setup() to create an appropriate
* data structure named ssl_ctx.
*

View File

@ -273,7 +273,6 @@ static struct ast_ha *ast_duplicate_ha(struct ast_ha *original)
}
/* Create duplicate HA link list */
/* Used in chan_sip2 templates */
struct ast_ha *ast_duplicate_ha_list(struct ast_ha *original)
{
struct ast_ha *start = original;

View File

@ -3053,10 +3053,7 @@ static int reload_module(void)
if (!driver || !database)
continue;
if (!strcasecmp(v->name, "sipfriends")) {
ast_log(LOG_WARNING, "The 'sipfriends' table is obsolete, update your config to use sippeers instead.\n");
ast_realtime_append_mapping("sippeers", driver, database, table ? table : "sipfriends", pri);
} else if (!strcasecmp(v->name, "iaxfriends")) {
if (!strcasecmp(v->name, "iaxfriends")) {
ast_log(LOG_WARNING, "The 'iaxfriends' table is obsolete, update your config to use iaxusers and iaxpeers, though they can point to the same table.\n");
ast_realtime_append_mapping("iaxusers", driver, database, table ? table : "iaxfriends", pri);
ast_realtime_append_mapping("iaxpeers", driver, database, table ? table : "iaxfriends", pri);

View File

@ -1760,7 +1760,7 @@ static int find_unused_payload(const struct ast_rtp_codecs *codecs)
* in Asterisk because when Compact Headers are activated, no rtpmap is
* send for those below 35. If you want to use 35 and below
* A) do not use Compact Headers,
* B) remove that code in chan_sip/res_pjsip, or
* B) remove that code in res_pjsip, or
* C) add a flag that this RTP Payload Type got reassigned dynamically
* and requires a rtpmap even with Compact Headers enabled.
*/

View File

@ -36,14 +36,12 @@
* \page T38fax_udptl T.38 support :: UDPTL
*
* Asterisk supports T.38 fax passthrough, origination and termination. It does
* not support gateway operation. The only channel driver that supports T.38 at
* this time is chan_sip.
* not support gateway operation.
*
* UDPTL is handled very much like RTP. It can be reinvited to go directly between
* the endpoints, without involving Asterisk in the media stream.
*
* \b References:
* - chan_sip.c
* - udptl.c
* - app_fax.c
*/
@ -1317,7 +1315,7 @@ static void *udptl_snapshot_alloc(void)
static int removed_options_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
{
if (!strcasecmp(var->name, "t38faxudpec")) {
ast_log(LOG_WARNING, "t38faxudpec in udptl.conf is no longer supported; use the t38pt_udptl configuration option in sip.conf instead.\n");
ast_log(LOG_WARNING, "t38faxudpec in udptl.conf is no longer supported.\n");
} else if (!strcasecmp(var->name, "t38faxmaxdatagram")) {
ast_log(LOG_WARNING, "t38faxmaxdatagram in udptl.conf is no longer supported; value is now supplied by T.38 applications.\n");
}

View File

@ -195,8 +195,6 @@
</member>
<member name="chan_local" displayname="Local Proxy Channel" remove_on_change="channels/chan_local.o channels/chan_local.so">
</member>
<member name="chan_sip" displayname="Session Initiation Protocol (SIP)" remove_on_change="channels/chan_sip.o channels/chan_sip.so">
</member>
<member name="chan_zap" displayname="Zapata Telephony" remove_on_change="channels/chan_zap.o channels/chan_zap.so">
<depend>zaptel</depend>
</member>

View File

@ -225,9 +225,6 @@
</member>
<member name="chan_local" displayname="Local Proxy Channel (Note: used internally by other modules)" remove_on_change="channels/chan_local.o channels/chan_local.so">
</member>
<member name="chan_sip" displayname="Session Initiation Protocol (SIP)" remove_on_change="channels/chan_sip.o channels/chan_sip.so">
<depend>chan_local</depend>
</member>
<member name="chan_unistim" displayname="UNISTIM Protocol (USTM)" remove_on_change="channels/chan_unistim.o channels/chan_unistim.so">
</member>
<member name="chan_usbradio" displayname="usb Console Channel Driver" remove_on_change="channels/chan_usbradio.o channels/chan_usbradio.so">

View File

@ -6,7 +6,7 @@ context default
switch(${StatusCode}) {
case 1:
Dial(SIP/706,12);
Dial(PJSIP/706,12);
switch(${DIALSTATUS}) {
case BUSY:
Voicemail(b706);

View File

@ -2004,7 +2004,7 @@ macro ciddial(dialnum, lookup, waittime, dialopts, ddev)
{
BackGround(try_voip);
CALLERID(num)=7075679201;
Dial(SIP/1${lookup}@tctwest,${waittime},${dialopts});
Dial(PJSIP/1${lookup}@tctwest,${waittime},${dialopts});
if( "${DIALSTATUS}" = "CHANUNAVAIL" )
{
BackGround(try_cell);
@ -2033,7 +2033,7 @@ macro ciddial2(dialnum, lookup, waittime, dialopts, ddev) // give priority to tc
Set(cidnu=${CALLERID(num)});
Set(CALLERID(name)=${cidn});
Set(CALLERID(num)=7075679201);
Dial(SIP/1${lookup}@tctwest,${waittime},${dialopts});
Dial(PJSIP/1${lookup}@tctwest,${waittime},${dialopts});
if( "${DIALSTATUS}" = "CHANUNAVAIL" )
{
Set(CALLERID(num)=${cidnu}); // put the original number back

View File

@ -116,11 +116,11 @@ context huntsville-calling {
macro dialout( number ) {
Realtime(call_info,exten,${CALLERIDNUM:5},mon_);
if ("${mon_monitor}" = "YES") {
Dial(SIP/${number}@zgw1.zvbwu.edu,,wW);
Dial(SIP/${number}@zgw2.zvbwu.edu,,wW);
Dial(PJSIP/${number}@zgw1.zvbwu.edu,,wW);
Dial(PJSIP/${number}@zgw2.zvbwu.edu,,wW);
} else {
Dial(SIP/${number}@zgw1.zvbwu.edu);
Dial(SIP/${number}@zgw2.zvbwu.edu);
Dial(PJSIP/${number}@zgw1.zvbwu.edu);
Dial(PJSIP/${number}@zgw2.zvbwu.edu);
};
return;
};
@ -143,9 +143,9 @@ macro stdexten( ext ) {
&checkcf(${ext});
Realtime(call_info,exten,${CALLERIDNUM:5},mon_);
if ("${mon_monitor}" = "YES") {
Dial(SIP/${info_forwardto},25,wW);
Dial(PJSIP/${info_forwardto},25,wW);
} else {
Dial(SIP/${info_forwardto},25);
Dial(PJSIP/${info_forwardto},25);
};
switch ("${DIALSTATUS}") {
case "BUSY":
@ -183,7 +183,7 @@ macro stdexten( ext ) {
};
macro uvm( ext ) {
Dial(SIP/u${ext}@ixtlchochitl.zvbwu.edu);
Dial(PJSIP/u${ext}@ixtlchochitl.zvbwu.edu);
Playback(im-sorry);
Playback(voice-mail-system);
Playback(down);
@ -192,7 +192,7 @@ macro uvm( ext ) {
};
macro bvm( ext ) {
Dial(SIP/b${ext}@ixtlchochitl.zvbwu.edu);
Dial(PJSIP/b${ext}@ixtlchochitl.zvbwu.edu);
Playback(im-sorry);
Playback(voice-mail-system);
Playback(down);
@ -213,7 +213,7 @@ macro checkcf( ext ) {
if ("${ext}" = "43974") {
Set(info_forwardto=${ext}&SCCP/${ext});
} else {
Set(info_forwardto=${ext}&SIP/${ext}w);
Set(info_forwardto=${ext}&PJSIP/${ext}w);
};
return;
};
@ -344,14 +344,14 @@ context local1 {
context from-scm2 {
_4XXXX => {
NoOp(DIALING SIP EXTENSION ${EXTEN} - FROM ${CALLERIDNUM});
Dial(SIP/${EXTEN},20,wW);
NoOp(DIALING PJSIP EXTENSION ${EXTEN} - FROM ${CALLERIDNUM});
Dial(PJSIP/${EXTEN},20,wW);
Hangup;
};
_6XXXX => {
NoOp(DIALING SIP EXTENSION ${EXTEN} - FROM ${CALLERIDNUM});
Dial(SIP/${EXTEN},20,wW);
NoOp(DIALING PJSIP EXTENSION ${EXTEN} - FROM ${CALLERIDNUM});
Dial(PJSIP/${EXTEN},20,wW);
Hangup;
};
};
@ -803,7 +803,7 @@ context vm-include {
context vm-direct {
s => {
Dial(SIP/5555@ixtlchochitl.zvbwu.edu,20);
Dial(PJSIP/5555@ixtlchochitl.zvbwu.edu,20);
Playback(im-sorry);
Playback(voice-mail-system);
Playback(down);
@ -815,7 +815,7 @@ context vm-direct {
context vm-extension {
s => {
Dial(SIP/62100@ixtlchochitl.zvbwu.edu,20);
Dial(PJSIP/62100@ixtlchochitl.zvbwu.edu,20);
Playback(im-sorry);
Playback(voice-mail-system);
Playback(down);
@ -827,7 +827,7 @@ context vm-extension {
context vm-directory {
5556 => {
Dial(SIP/5556@ixtlchochitl.zvbwu.edu);
Dial(PJSIP/5556@ixtlchochitl.zvbwu.edu);
Playback(im-sorry);
Playback(voice-mail-system);
Playback(down);

View File

@ -116,11 +116,11 @@ context huntsville-calling {
macro dialout( number ) {
Realtime(call_info|exten|${CALLERIDNUM:5}|mon_);
if ("${mon_monitor}" = "YES") {
Dial(SIP/${number}@sgw1.shsu.edu,,wW);
Dial(SIP/${number}@sgw2.shsu.edu,,wW);
Dial(PJSIP/${number}@sgw1.shsu.edu,,wW);
Dial(PJSIP/${number}@sgw2.shsu.edu,,wW);
} else {
Dial(SIP/${number}@sgw1.shsu.edu);
Dial(SIP/${number}@sgw2.shsu.edu);
Dial(PJSIP/${number}@sgw1.shsu.edu);
Dial(PJSIP/${number}@sgw2.shsu.edu);
};
};
@ -142,9 +142,9 @@ macro stdexten( ext ) {
&checkcf(${ext});
Realtime(call_info|exten|${CALLERIDNUM:5}|mon_);
if ("${mon_monitor}" = "YES") {
Dial(SIP/${info_forwardto},25,wW);
Dial(PJSIP/${info_forwardto},25,wW);
} else {
Dial(SIP/${info_forwardto},25);
Dial(PJSIP/${info_forwardto},25);
};
switch ("${DIALSTATUS}") {
case "BUSY":
@ -182,7 +182,7 @@ macro stdexten( ext ) {
};
macro uvm( ext ) {
Dial(SIP/u${ext}@svm1.shsu.edu);
Dial(PJSIP/u${ext}@svm1.shsu.edu);
Playback(im-sorry);
Playback(voice-mail-system);
Playback(down);
@ -191,7 +191,7 @@ macro uvm( ext ) {
};
macro bvm( ext ) {
Dial(SIP/b${ext}@svm1.shsu.edu);
Dial(PJSIP/b${ext}@svm1.shsu.edu);
Playback(im-sorry);
Playback(voice-mail-system);
Playback(down);
@ -211,7 +211,7 @@ macro checkcf( ext ) {
if ("${ext}" = "43974") {
Set(info_forwardto=${ext}&SCCP/${ext});
} else {
Set(info_forwardto=${ext}&SIP/${ext}w);
Set(info_forwardto=${ext}&PJSIP/${ext}w);
};
};
@ -340,14 +340,14 @@ context local1 {
context from-scm2 {
_4XXXX => {
NoOp(DIALING SIP EXTENSION ${EXTEN} - FROM ${CALLERIDNUM});
Dial(SIP/${EXTEN},20,wW);
NoOp(DIALING PJSIP EXTENSION ${EXTEN} - FROM ${CALLERIDNUM});
Dial(PJSIP/${EXTEN},20,wW);
Hangup;
};
_6XXXX => {
NoOp(DIALING SIP EXTENSION ${EXTEN} - FROM ${CALLERIDNUM});
Dial(SIP/${EXTEN},20,wW);
NoOp(DIALING PJSIP EXTENSION ${EXTEN} - FROM ${CALLERIDNUM});
Dial(PJSIP/${EXTEN},20,wW);
Hangup;
};
};
@ -798,7 +798,7 @@ context vm-include {
context vm-direct {
s => {
Dial(SIP/5555@svm1.shsu.edu,20);
Dial(PJSIP/5555@svm1.shsu.edu,20);
Playback(im-sorry);
Playback(voice-mail-system);
Playback(down);
@ -810,7 +810,7 @@ context vm-direct {
context vm-extension {
s => {
Dial(SIP/62100@svm1.shsu.edu,20);
Dial(PJSIP/62100@svm1.shsu.edu,20);
Playback(im-sorry);
Playback(voice-mail-system);
Playback(down);
@ -822,7 +822,7 @@ context vm-extension {
context vm-directory {
5556 => {
Dial(SIP/5556@svm1.shsu.edu);
Dial(PJSIP/5556@svm1.shsu.edu);
Playback(im-sorry);
Playback(voice-mail-system);
Playback(down);

View File

@ -141,9 +141,9 @@ repeat:
Wait(1);
Hangup;
};
1 => &stdexten(1,SIP/1);
2 => &stdexten(2,SIP/2);
3 => &stdexten(3,SIP/3);
1 => &stdexten(1,PJSIP/1);
2 => &stdexten(2,PJSIP/2);
3 => &stdexten(3,PJSIP/3);
2271653 => jump 1;
7322271653 => jump 1;
@ -166,7 +166,7 @@ repeat:
17322271677 => jump 3;
galka => jump 3;
911 => Dial(${PSTNPROTO}/911@${PSTN},60,);
380 => Dial(SIP/topspeen@212.40.38.70,60,T);
380 => Dial(PJSIP/topspeen@212.40.38.70,60,T);
// Fun stuff
100 => {

View File

@ -6,7 +6,7 @@ context default
switch(${StatusCode}) {
case 1:
Dial(SIP/706,12);
Dial(PJSIP/706,12);
switch(${DIALSTATUS}) {
case BUSY:
Voicemail(b706);

View File

@ -2003,7 +2003,7 @@ macro ciddial(dialnum, lookup, waittime, dialopts, ddev)
{
BackGround(try_voip);
CALLERID(num)=7075679201;
Dial(SIP/1${lookup}@tctwest,${waittime},${dialopts});
Dial(PJSIP/1${lookup}@tctwest,${waittime},${dialopts});
if( "${DIALSTATUS}" = "CHANUNAVAIL" )
{
BackGround(try_cell);
@ -2032,7 +2032,7 @@ macro ciddial2(dialnum, lookup, waittime, dialopts, ddev) // give priority to tc
Set(cidnu=${CALLERID(num)});
Set(CALLERID(name)=${cidn});
Set(CALLERID(num)=7075679201);
Dial(SIP/1${lookup}@tctwest,${waittime},${dialopts});
Dial(PJSIP/1${lookup}@tctwest,${waittime},${dialopts});
if( "${DIALSTATUS}" = "CHANUNAVAIL" )
{
Set(CALLERID(num)=${cidnu}); // put the original number back

View File

@ -2131,7 +2131,7 @@ exten => ~~s~~,9,Dial(${ddev}/${dialnum}|${waittime}|${dialopts})
exten => ~~s~~,10,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL" ]?11:19)
exten => ~~s~~,11,BackGround(try_voip)
exten => ~~s~~,12,Set(CALLERID(num)=$[7075679201])
exten => ~~s~~,13,Dial(SIP/1${lookup}@tctwest,${waittime},${dialopts})
exten => ~~s~~,13,Dial(PJSIP/1${lookup}@tctwest,${waittime},${dialopts})
exten => ~~s~~,14,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL" ]?15:18)
exten => ~~s~~,15,BackGround(try_cell)
exten => ~~s~~,16,Set(CALLERID(num)=$[${cidnu}])
@ -2168,7 +2168,7 @@ exten => ~~s~~,6,Set(cidn=${DB(cidname/${lookup})})
exten => ~~s~~,7,Set(cidnu=${CALLERID(num)})
exten => ~~s~~,8,Set(CALLERID(name)=${cidn})
exten => ~~s~~,9,Set(CALLERID(num)=7075679201)
exten => ~~s~~,10,Dial(SIP/1${lookup}@tctwest,${waittime},${dialopts})
exten => ~~s~~,10,Dial(PJSIP/1${lookup}@tctwest,${waittime},${dialopts})
exten => ~~s~~,11,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL" ]?12:19)
exten => ~~s~~,12,Set(CALLERID(num)=${cidnu})
exten => ~~s~~,13,BackGround(try_zap)

View File

@ -1998,10 +1998,6 @@ static void pbx_load_users(void)
if (!strcasecmp(cat, "general"))
continue;
iface[0] = '\0';
if (ast_true(ast_config_option(cfg, cat, "hassip"))) {
snprintf(tmp, sizeof(tmp), "SIP/%s", cat);
append_interface(iface, sizeof(iface), tmp);
}
if (ast_true(ast_config_option(cfg, cat, "hasiax"))) {
snprintf(tmp, sizeof(tmp), "IAX2/%s", cat);
append_interface(iface, sizeof(iface), tmp);

View File

@ -52,9 +52,9 @@ struct ast_ari_endpoints_list_args {
void ast_ari_endpoints_list(struct ast_variable *headers, struct ast_ari_endpoints_list_args *args, struct ast_ari_response *response);
/*! Argument struct for ast_ari_endpoints_send_message() */
struct ast_ari_endpoints_send_message_args {
/*! The endpoint resource or technology specific URI to send the message to. Valid resources are sip, pjsip, and xmpp. */
/*! The endpoint resource or technology specific URI to send the message to. Valid resources are pjsip, and xmpp. */
const char *to;
/*! The endpoint resource or technology specific identity to send this message from. Valid resources are sip, pjsip, and xmpp. */
/*! The endpoint resource or technology specific identity to send this message from. Valid resources are pjsip, and xmpp. */
const char *from;
/*! The body of the message */
const char *body;
@ -81,7 +81,7 @@ int ast_ari_endpoints_send_message_parse_body(
void ast_ari_endpoints_send_message(struct ast_variable *headers, struct ast_ari_endpoints_send_message_args *args, struct ast_ari_response *response);
/*! Argument struct for ast_ari_endpoints_list_by_tech() */
struct ast_ari_endpoints_list_by_tech_args {
/*! Technology of the endpoints (sip,iax2,...) */
/*! Technology of the endpoints (iax2,...) */
const char *tech;
};
/*!
@ -113,7 +113,7 @@ struct ast_ari_endpoints_send_message_to_endpoint_args {
const char *tech;
/*! ID of the endpoint */
const char *resource;
/*! The endpoint resource or technology specific identity to send this message from. Valid resources are sip, pjsip, and xmpp. */
/*! The endpoint resource or technology specific identity to send this message from. Valid resources are pjsip, and xmpp. */
const char *from;
/*! The body of the message */
const char *body;

View File

@ -29,7 +29,7 @@
* \author George Joseph <george.joseph@fairview5.com>
*/
/*! \li \ref res_phoneprov.c uses the configuration file \ref phoneprov.conf and \ref users.conf and \ref sip.conf
/*! \li \ref res_phoneprov.c uses the configuration file \ref phoneprov.conf and \ref users.conf
* \addtogroup configuration_file Configuration Files
*/
@ -1234,11 +1234,6 @@ static struct varshead *get_defaults(void)
}
value = ast_variable_retrieve(phoneprov_cfg, "general", pp_general_lookup[AST_PHONEPROV_STD_SERVER_PORT]);
if (!value) {
if ((cfg = ast_config_load("sip.conf", config_flags)) && cfg != CONFIG_STATUS_FILEINVALID) {
value = ast_variable_retrieve(cfg, "general", "bindport");
}
}
var = ast_var_assign(variable_lookup[AST_PHONEPROV_STD_SERVER_PORT], S_OR(value, "5060"));
if (cfg && cfg != CONFIG_STATUS_FILEINVALID) {
ast_config_destroy(cfg);
@ -1384,7 +1379,7 @@ static int unload_module(void)
ast_custom_function_unregister(&pp_each_extension_function);
ast_cli_unregister_multiple(pp_cli, ARRAY_LEN(pp_cli));
/* This cleans up the sip.conf/users.conf provider (called specifically for clarity) */
/* This cleans up the users.conf provider (called specifically for clarity) */
ast_phoneprov_provider_unregister(SIPUSERS_PROVIDER_NAME);
/* This cleans up the framework which also cleans up the providers. */
@ -1449,9 +1444,9 @@ static int load_module(void)
goto error;
}
/* Register ourselves as the provider for sip.conf/users.conf */
/* Register ourselves as the provider for users.conf */
if (ast_phoneprov_provider_register(SIPUSERS_PROVIDER_NAME, load_users)) {
ast_log(LOG_WARNING, "Unable register sip/users config provider. Others may succeed.\n");
ast_log(LOG_WARNING, "Unable register users config provider. Others may succeed.\n");
}
ast_http_uri_link(&phoneprovuri);

View File

@ -439,9 +439,7 @@
<para>This setting allows to choose the DTMF mode for endpoint communication.</para>
<enumlist>
<enum name="rfc4733">
<para>DTMF is sent out of band of the main audio stream. This
supercedes the older <emphasis>RFC-2833</emphasis> used within
the older <literal>chan_sip</literal>.</para>
<para>DTMF is sent out of band of the main audio stream.</para>
</enum>
<enum name="inband">
<para>DTMF is sent as part of audio stream.</para>

View File

@ -242,8 +242,7 @@ static pj_status_t send_options_response(pjsip_rx_data *rdata, int code)
/*
* XXX TODO: pjsip doesn't care a lot about either of these headers -
* while it provides specific methods to create them, they are defined
* to be the standard string header creation. We never did add them
* in chan_sip, although RFC 3261 says they SHOULD. Hard coded here.
* to be the standard string header creation. Hard coded here.
*/
ast_sip_add_header(tdata, "Accept-Encoding", DEFAULT_ENCODING);
ast_sip_add_header(tdata, "Accept-Language", DEFAULT_LANGUAGE);

View File

@ -63,8 +63,7 @@ static int options_incoming_request(struct ast_sip_session *session, pjsip_rx_da
/*
* XXX TODO: pjsip doesn't care a lot about either of these headers -
* while it provides specific methods to create them, they are defined
* to be the standard string header creation. We never did add them
* in chan_sip, although RFC 3261 says they SHOULD. Hard coded here.
* to be the standard string header creation. Hard coded here.
*/
ast_sip_add_header(tdata, "Accept-Encoding", DEFAULT_ENCODING);
ast_sip_add_header(tdata, "Accept-Language", DEFAULT_LANGUAGE);

View File

@ -2129,7 +2129,7 @@
"protocol_id": {
"required": true,
"type": "string",
"description": "Protocol id from underlying channel driver (i.e. Call-ID for chan_sip/chan_pjsip; will be empty if not applicable or not implemented by driver)."
"description": "Protocol id from underlying channel driver (i.e. Call-ID for chan_pjsip; will be empty if not applicable or not implemented by driver)."
},
"name": {
"required": true,

View File

@ -31,7 +31,7 @@
"parameters": [
{
"name": "to",
"description": "The endpoint resource or technology specific URI to send the message to. Valid resources are sip, pjsip, and xmpp.",
"description": "The endpoint resource or technology specific URI to send the message to. Valid resources are pjsip, and xmpp.",
"paramType": "query",
"required": true,
"allowMultiple": false,
@ -39,7 +39,7 @@
},
{
"name": "from",
"description": "The endpoint resource or technology specific identity to send this message from. Valid resources are sip, pjsip, and xmpp.",
"description": "The endpoint resource or technology specific identity to send this message from. Valid resources are pjsip, and xmpp.",
"paramType": "query",
"required": true,
"allowMultiple": false,
@ -55,7 +55,7 @@
},
{
"name": "variables",
"descriptioni": "The \"variables\" key in the body object holds technology specific key/value pairs to append to the message. These can be interpreted and used by the various resource types; for example, pjsip and sip resource types will add the key/value pairs as SIP headers,",
"descriptioni": "The \"variables\" key in the body object holds technology specific key/value pairs to append to the message. These can be interpreted and used by the various resource types; for example, pjsip resource types will add the key/value pairs as SIP headers,",
"paramType": "body",
"required": false,
"dataType": "containers",
@ -87,7 +87,7 @@
"parameters": [
{
"name": "tech",
"description": "Technology of the endpoints (sip,iax2,...)",
"description": "Technology of the endpoints (pjsip,iax2,...)",
"paramType": "path",
"dataType": "string"
}
@ -161,7 +161,7 @@
},
{
"name": "from",
"description": "The endpoint resource or technology specific identity to send this message from. Valid resources are sip, pjsip, and xmpp.",
"description": "The endpoint resource or technology specific identity to send this message from. Valid resources are pjsip and xmpp.",
"paramType": "query",
"required": true,
"allowMultiple": false,
@ -177,7 +177,7 @@
},
{
"name": "variables",
"descriptioni": "The \"variables\" key in the body object holds technology specific key/value pairs to append to the message. These can be interpreted and used by the various resource types; for example, pjsip and sip resource types will add the key/value pairs as SIP headers,",
"descriptioni": "The \"variables\" key in the body object holds technology specific key/value pairs to append to the message. These can be interpreted and used by the various resource types; for example, pjsip resource types will add the key/value pairs as SIP headers,",
"paramType": "body",
"required": false,
"dataType": "containers",
@ -239,12 +239,12 @@
"properties": {
"from": {
"type": "string",
"description": "A technology specific URI specifying the source of the message. For sip and pjsip technologies, any SIP URI can be specified. For xmpp, the URI must correspond to the client connection being used to send the message.",
"description": "A technology specific URI specifying the source of the message. For pjsip technology, any SIP URI can be specified. For xmpp, the URI must correspond to the client connection being used to send the message.",
"required": true
},
"to": {
"type": "string",
"description": "A technology specific URI specifying the destination of the message. Valid technologies include sip, pjsip, and xmp. The destination of a message should be an endpoint.",
"description": "A technology specific URI specifying the destination of the message. Valid technologies include pjsip, and xmp. The destination of a message should be an endpoint.",
"required": true
},
"body": {

View File

@ -36,18 +36,6 @@
"runTestsuiteOptions": "--test-timeout=180",
"testcmd": "--test-regex=tests/channels/pjsip/[s-z]"
},
{
"name": "sip1",
"dir": "tests/CI/output/sip1",
"runTestsuiteOptions": "--test-timeout=240",
"testcmd": "--test-regex=tests/channels/SIP/[Sa-r]"
},
{
"name": "sip2",
"dir": "tests/CI/output/sip2",
"runTestsuiteOptions": "--test-timeout=240",
"testcmd": "--test-regex=tests/channels/SIP/[s-z]"
},
{
"name": "iax ",
"dir": "tests/CI/output/iax2_local",

View File

@ -17,12 +17,6 @@
"runTestsuiteOptions": "--test-timeout=180",
"testcmd": "-t tests/channels/pjsip"
},
{
"name": "sip ",
"dir": "tests/CI/output/sip",
"runTestsuiteOptions": "--test-timeout=240",
"testcmd": "-t tests/channels/SIP"
},
{
"name": "iax ",
"dir": "tests/CI/output/iax2_local",

View File

@ -9,11 +9,6 @@
"dir": "tests/CI/output/pjsip",
"testcmd": "-t tests/channels/pjsip"
},
{
"name": "sip ",
"dir": "tests/CI/output/sip",
"testcmd": "-t tests/channels/SIP"
},
{
"name": "iax ",
"dir": "tests/CI/output/iax2_local",