[asterisk-commits] russell: branch russell/ais r78190 - in /team/russell/ais: ./ apps/ channels/...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Aug 6 12:23:41 CDT 2007
Author: russell
Date: Mon Aug 6 12:23:41 2007
New Revision: 78190
URL: http://svn.digium.com/view/asterisk?view=rev&rev=78190
Log:
resolve conflict, sync with trunk
Modified:
team/russell/ais/ (props changed)
team/russell/ais/apps/app_externalivr.c
team/russell/ais/channels/chan_sip.c
team/russell/ais/channels/chan_skinny.c
team/russell/ais/configs/skinny.conf.sample
team/russell/ais/configure
team/russell/ais/configure.ac
team/russell/ais/include/asterisk/config.h
team/russell/ais/include/asterisk/linkedlists.h
team/russell/ais/main/config.c
team/russell/ais/main/rtp.c
Propchange: team/russell/ais/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.
Propchange: team/russell/ais/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Aug 6 12:23:41 2007
@@ -1,1 +1,1 @@
-/trunk:1-78149
+/trunk:1-78189
Modified: team/russell/ais/apps/app_externalivr.c
URL: http://svn.digium.com/view/asterisk/team/russell/ais/apps/app_externalivr.c?view=diff&rev=78190&r1=78189&r2=78190
==============================================================================
--- team/russell/ais/apps/app_externalivr.c (original)
+++ team/russell/ais/apps/app_externalivr.c Mon Aug 6 12:23:41 2007
@@ -250,7 +250,6 @@
int res = -1;
int gen_active = 0;
int pid;
- char *argv[32];
char *buf, *command;
FILE *child_commands = NULL;
FILE *child_errors = NULL;
@@ -325,8 +324,8 @@
dup2(child_stderr[1], STDERR_FILENO);
for (i = STDERR_FILENO + 1; i < 1024; i++)
close(i);
- execv(argv[0], argv);
- fprintf(stderr, "Failed to execute '%s': %s\n", argv[0], strerror(errno));
+ execv(args.cmd[0], args.cmd);
+ fprintf(stderr, "Failed to execute '%s': %s\n", args.cmd[0], strerror(errno));
_exit(1);
} else {
/* parent process */
Modified: team/russell/ais/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/russell/ais/channels/chan_sip.c?view=diff&rev=78190&r1=78189&r2=78190
==============================================================================
--- team/russell/ais/channels/chan_sip.c (original)
+++ team/russell/ais/channels/chan_sip.c Mon Aug 6 12:23:41 2007
@@ -1651,12 +1651,15 @@
static enum parse_register_result parse_register_contact(struct sip_pvt *pvt, struct sip_peer *p, struct sip_request *req);
static void reg_source_db(struct sip_peer *peer);
static void destroy_association(struct sip_peer *peer);
+static void set_insecure_flags(struct ast_flags *flags, const char *value, int lineno);
static int handle_common_options(struct ast_flags *flags, struct ast_flags *mask, struct ast_variable *v);
/* Realtime device support */
static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, const char *username, const char *fullcontact, int expirey);
static struct sip_user *realtime_user(const char *username);
static void update_peer(struct sip_peer *p, int expiry);
+static struct ast_variable *get_insecure_variable_from_config(struct ast_config *config);
+static const char *get_name_from_variable(struct ast_variable *var, const char *newpeername);
static struct sip_peer *realtime_peer(const char *peername, struct sockaddr_in *sin);
static char *sip_prune_realtime(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
@@ -2933,12 +2936,36 @@
}
}
+static struct ast_variable *get_insecure_variable_from_config(struct ast_config *config)
+{
+ struct ast_variable *var;
+ struct ast_flags flags = {0};
+ char *cat = NULL;
+ const char *insecure;
+ while ((cat = ast_category_browse(config, cat))) {
+ insecure = ast_variable_retrieve(config, cat, "insecure");
+ set_insecure_flags(&flags, insecure, -1);
+ if (ast_test_flag(&flags, SIP_INSECURE_PORT)) {
+ var = ast_category_root(config, cat);
+ break;
+ }
+ }
+ return var;
+}
+
+static const char *get_name_from_variable(struct ast_variable *var, const char *newpeername)
+{
+ struct ast_variable *tmp;
+ for (tmp = var; tmp; tmp = tmp->next) {
+ if (!newpeername && !strcasecmp(tmp->name, "name"))
+ newpeername = tmp->value;
+ }
+ return newpeername;
+}
/*! \brief realtime_peer: Get peer from realtime storage
* Checks the "sippeers" realtime family from extconfig.conf
* Checks the "sipregs" realtime family from extconfig.conf if it's configured.
- * \todo Consider adding check of port address when matching here to follow the same
- * algorithm as for static peers. Will we break anything by adding that?
*/
static struct sip_peer *realtime_peer(const char *newpeername, struct sockaddr_in *sin)
{
@@ -2946,7 +2973,11 @@
struct ast_variable *var = NULL;
struct ast_variable *varregs = NULL;
struct ast_variable *tmp;
+ struct ast_config *peerlist = NULL;
char ipaddr[INET_ADDRSTRLEN];
+ char portstring[6]; /*up to 5 digits plus null terminator*/
+ char *cat = NULL;
+ unsigned short portnum;
int realtimeregs = ast_check_realtime("sipregs");
/* First check on peer name */
@@ -2956,39 +2987,87 @@
varregs = ast_load_realtime("sipregs", "name", newpeername, NULL);
} else if (sin) { /* Then check on IP address for dynamic peers */
ast_copy_string(ipaddr, ast_inet_ntoa(sin->sin_addr), sizeof(ipaddr));
- var = ast_load_realtime("sippeers", "host", ipaddr, NULL); /* First check for fixed IP hosts */
+ portnum = ntohs(sin->sin_port);
+ sprintf(portstring, "%u", portnum);
+ var = ast_load_realtime("sippeers", "host", ipaddr, "port", portstring, NULL); /* First check for fixed IP hosts */
if (var) {
if (realtimeregs) {
- for (tmp = var; tmp; tmp = tmp->next) {
- if (!newpeername && !strcasecmp(tmp->name, "name"))
- newpeername = tmp->value;
- }
+ newpeername = get_name_from_variable(var, newpeername);
varregs = ast_load_realtime("sipregs", "name", newpeername, NULL);
}
} else {
if (realtimeregs)
- varregs = ast_load_realtime("sipregs", "ipaddr", ipaddr, NULL); /* Then check for registered hosts */
+ varregs = ast_load_realtime("sipregs", "ipaddr", ipaddr, "port", portstring, NULL); /* Then check for registered hosts */
else
- var = ast_load_realtime("sippeers", "ipaddr", ipaddr, NULL); /* Then check for registered hosts */
+ var = ast_load_realtime("sippeers", "ipaddr", ipaddr, "port", portstring, NULL); /* Then check for registered hosts */
if (varregs) {
- for (tmp = varregs; tmp; tmp = tmp->next) {
- if (!newpeername && !strcasecmp(tmp->name, "name"))
- newpeername = tmp->value;
- }
+ newpeername = get_name_from_variable(varregs, newpeername);
var = ast_load_realtime("sippeers", "name", newpeername, NULL);
}
}
- }
-
- if (!var)
+ if(!var) { /*We couldn't match on ipaddress and port, so we need to check if port is insecure*/
+ peerlist = ast_load_realtime_multientry("sippeers", "host", ipaddr, NULL);
+ if (peerlist) {
+ var = get_insecure_variable_from_config(peerlist);
+ if(var) {
+ if (realtimeregs) {
+ newpeername = get_name_from_variable(var, newpeername);
+ varregs = ast_load_realtime("sipregs", "name", newpeername, NULL);
+ }
+ } else { /*var wasn't found in the list of "hosts", so try "ipaddr"*/
+ peerlist = NULL;
+ cat = NULL;
+ peerlist = ast_load_realtime_multientry("sippeers", "ipaddr", ipaddr, NULL);
+ if(peerlist) {
+ var = get_insecure_variable_from_config(peerlist);
+ if(var) {
+ if (realtimeregs) {
+ newpeername = get_name_from_variable(var, newpeername);
+ varregs = ast_load_realtime("sipregs", "name", newpeername, NULL);
+ }
+ }
+ }
+ }
+ } else {
+ if(realtimeregs) {
+ peerlist = ast_load_realtime_multientry("sipregs", "ipaddr", ipaddr, NULL);
+ if (peerlist) {
+ varregs = get_insecure_variable_from_config(peerlist);
+ if (varregs) {
+ newpeername = get_name_from_variable(varregs, newpeername);
+ var = ast_load_realtime("sippeers", "name", newpeername, NULL);
+ }
+ }
+ } else {
+ peerlist = ast_load_realtime_multientry("sippeers", "ipaddr", ipaddr, NULL);
+ if (peerlist) {
+ var = get_insecure_variable_from_config(peerlist);
+ if (var) {
+ newpeername = get_name_from_variable(var, newpeername);
+ varregs = ast_load_realtime("sipregs", "name", newpeername, NULL);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!var) {
+ if (peerlist)
+ ast_config_destroy(peerlist);
return NULL;
+ }
for (tmp = var; tmp; tmp = tmp->next) {
/* If this is type=user, then skip this object. */
if (!strcasecmp(tmp->name, "type") &&
!strcasecmp(tmp->value, "user")) {
- ast_variables_destroy(var);
- ast_variables_destroy(varregs);
+ if(peerlist)
+ ast_config_destroy(peerlist);
+ else {
+ ast_variables_destroy(var);
+ ast_variables_destroy(varregs);
+ }
return NULL;
} else if (!newpeername && !strcasecmp(tmp->name, "name")) {
newpeername = tmp->value;
@@ -2997,7 +3076,10 @@
if (!newpeername) { /* Did not find peer in realtime */
ast_log(LOG_WARNING, "Cannot Determine peer name ip=%s\n", ipaddr);
- ast_variables_destroy(var);
+ if(peerlist)
+ ast_config_destroy(peerlist);
+ else
+ ast_variables_destroy(var);
return NULL;
}
@@ -3005,8 +3087,12 @@
/* Peer found in realtime, now build it in memory */
peer = build_peer(newpeername, var, varregs, !ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS));
if (!peer) {
- ast_variables_destroy(var);
- ast_variables_destroy(varregs);
+ if(peerlist)
+ ast_config_destroy(peerlist);
+ else {
+ ast_variables_destroy(var);
+ ast_variables_destroy(varregs);
+ }
return NULL;
}
@@ -3025,8 +3111,12 @@
} else {
peer->is_realtime = 1;
}
- ast_variables_destroy(var);
- ast_variables_destroy(varregs);
+ if (peerlist)
+ ast_config_destroy(peerlist);
+ else {
+ ast_variables_destroy(var);
+ ast_variables_destroy(varregs);
+ }
return peer;
}
@@ -9471,7 +9561,7 @@
(With a forking SIP proxy, several call legs share the
call id, but have different tags)
*/
- if (pedanticsipchecking && (strcmp(fromtag, sip_pvt_ptr->theirtag) || strcmp(totag, ourtag)))
+ if (pedanticsipchecking && (strcmp(fromtag, sip_pvt_ptr->theirtag) || (!ast_strlen_zero(totag) && strcmp(totag, ourtag))))
match = 0;
if (!match) {
@@ -16656,6 +16746,25 @@
return tmpc;
}
+static void set_insecure_flags (struct ast_flags *flags, const char *value, int lineno)
+{
+ if (!ast_false(value)) {
+ char buf[64];
+ char *word, *next;
+
+ ast_copy_string(buf, value, sizeof(buf));
+ next = buf;
+ while ((word = strsep(&next, ","))) {
+ if (!strcasecmp(word, "port"))
+ ast_set_flag(&flags[0], SIP_INSECURE_PORT);
+ else if (!strcasecmp(word, "invite"))
+ ast_set_flag(&flags[0], SIP_INSECURE_INVITE);
+ else
+ ast_log(LOG_WARNING, "Unknown insecure mode '%s' on line %d\n", value, lineno);
+ }
+ }
+}
+
/*!
\brief Handle flag-type options common to configuration of devices - users and peers
\param flags array of two struct ast_flags
@@ -16729,21 +16838,7 @@
} else if (!strcasecmp(v->name, "insecure")) {
ast_set_flag(&mask[0], SIP_INSECURE);
ast_clear_flag(&flags[0], SIP_INSECURE);
- if (!ast_false(v->value)) {
- char buf[64];
- char *word, *next;
-
- ast_copy_string(buf, v->value, sizeof(buf));
- next = buf;
- while ((word = strsep(&next, ","))) {
- if (!strcasecmp(word, "port"))
- ast_set_flag(&flags[0], SIP_INSECURE_PORT);
- else if (!strcasecmp(word, "invite"))
- ast_set_flag(&flags[0], SIP_INSECURE_INVITE);
- else
- ast_log(LOG_WARNING, "Unknown insecure mode '%s' on line %d\n", v->value, v->lineno);
- }
- }
+ set_insecure_flags(&flags[0], v->value, v->lineno);
} else if (!strcasecmp(v->name, "progressinband")) {
ast_set_flag(&mask[0], SIP_PROG_INBAND);
ast_clear_flag(&flags[0], SIP_PROG_INBAND);
Modified: team/russell/ais/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/team/russell/ais/channels/chan_skinny.c?view=diff&rev=78190&r1=78189&r2=78190
==============================================================================
--- team/russell/ais/channels/chan_skinny.c (original)
+++ team/russell/ais/channels/chan_skinny.c Mon Aug 6 12:23:41 2007
@@ -1020,6 +1020,7 @@
struct skinny_subchannel *sub;
struct skinny_line *next;
struct skinny_device *parent;
+ struct ast_variable *chanvars; /*!< Channel variables to set for inbound call */
};
struct skinny_speeddial {
@@ -1316,6 +1317,24 @@
return tmpl;
}
+/*!
+ * implement the setvar config line
+ */
+static struct ast_variable *add_var(const char *buf, struct ast_variable *list)
+{
+ struct ast_variable *tmpvar = NULL;
+ char *varname = ast_strdupa(buf), *varval = NULL;
+
+ if ((varval = strchr(varname,'='))) {
+ *varval++ = '\0';
+ if ((tmpvar = ast_variable_new(varname, varval))) {
+ tmpvar->next = list;
+ list = tmpvar;
+ }
+ }
+ return list;
+}
+
/* It's quicker/easier to find the subchannel when we know the instance number too */
static struct skinny_subchannel *find_subchannel_by_instance_reference(struct skinny_device *d, int instance, int reference)
{
@@ -2279,6 +2298,7 @@
struct skinny_speeddial *sd;
struct skinny_addon *a;
char device_vmexten[AST_MAX_EXTENSION];
+ struct ast_variable *chanvars = NULL;
int lineInstance = 1;
int speeddialInstance = 1;
int y = 0;
@@ -2362,6 +2382,8 @@
mwiblink = ast_true(v->value);
} else if (!strcasecmp(v->name, "linelabel")) {
ast_copy_string(linelabel, v->value, sizeof(linelabel));
+ } else if (!strcasecmp(v->name, "setvar")) {
+ chanvars = add_var(v->value, chanvars);
} else if (!strcasecmp(v->name, "speeddial")) {
if (!(sd = ast_calloc(1, sizeof(*sd)))) {
return NULL;
@@ -2422,6 +2444,7 @@
ast_verb(3, "Setting mailbox '%s' on %s@%s\n", mailbox, d->name, l->name);
if (!ast_strlen_zero(device_vmexten))
ast_copy_string(l->vmexten, device_vmexten, sizeof(vmexten));
+ l->chanvars = chanvars;
l->msgstate = -1;
l->capability = d->capability;
l->prefs = d->prefs;
@@ -3009,6 +3032,7 @@
struct ast_channel *tmp;
struct skinny_subchannel *sub;
struct skinny_device *d = l->parent;
+ struct ast_variable *v = NULL;
int fmt;
tmp = ast_channel_alloc(1, state, l->cid_num, l->cid_name, l->accountcode, l->exten, l->context, l->amaflags, "Skinny/%s@%s-%d", l->name, d->name, callnums);
@@ -3078,6 +3102,10 @@
if (sub->rtp)
ast_jb_configure(tmp, &global_jbconf);
+
+ /* Set channel variables for this call from configuration */
+ for (v = l->chanvars ; v ; v = v->next)
+ pbx_builtin_setvar_helper(tmp, v->name, v->value);
if (state != AST_STATE_DOWN) {
if (ast_pbx_start(tmp)) {
Modified: team/russell/ais/configs/skinny.conf.sample
URL: http://svn.digium.com/view/asterisk/team/russell/ais/configs/skinny.conf.sample?view=diff&rev=78190&r1=78189&r2=78190
==============================================================================
--- team/russell/ais/configs/skinny.conf.sample (original)
+++ team/russell/ais/configs/skinny.conf.sample Mon Aug 6 12:23:41 2007
@@ -72,6 +72,7 @@
;permit=192.168.0/24 ; Optional, used for authentication
;nat=yes
;callerid="George W. Bush" <202-456-1414>
+;setvar=CUSTID=5678 ; Channel variable to be set for all calls from this device
;mailbox=500
;callwaiting=yes
;transfer=yes
Modified: team/russell/ais/configure
URL: http://svn.digium.com/view/asterisk/team/russell/ais/configure?view=diff&rev=78190&r1=78189&r2=78190
==============================================================================
--- team/russell/ais/configure (original)
+++ team/russell/ais/configure Mon Aug 6 12:23:41 2007
@@ -15177,7 +15177,8 @@
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-#include <netdb.h>
+#include <stdlib.h>
+ #include <netdb.h>
int
main ()
{
@@ -15231,7 +15232,8 @@
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-#include <netdb.h>
+#include <stdlib.h>
+ #include <netdb.h>
int
main ()
{
Modified: team/russell/ais/configure.ac
URL: http://svn.digium.com/view/asterisk/team/russell/ais/configure.ac?view=diff&rev=78190&r1=78189&r2=78190
==============================================================================
--- team/russell/ais/configure.ac (original)
+++ team/russell/ais/configure.ac Mon Aug 6 12:23:41 2007
@@ -290,7 +290,8 @@
AC_MSG_CHECKING(for gethostbyname_r with 6 arguments)
AC_LINK_IFELSE(
- AC_LANG_PROGRAM([#include <netdb.h>],
+ AC_LANG_PROGRAM([#include <stdlib.h>
+ #include <netdb.h>],
[struct hostent *he = gethostbyname_r((const char *)NULL, (struct hostent *)NULL, (char *)NULL, (int)0, (struct hostent **)NULL, (int *)NULL);]),
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_GETHOSTBYNAME_R_6], 1, [Define to 1 if your system has gethostbyname_r with 6 arguments.]),
@@ -299,7 +300,8 @@
AC_MSG_CHECKING(for gethostbyname_r with 5 arguments)
AC_LINK_IFELSE(
- AC_LANG_PROGRAM([#include <netdb.h>],
+ AC_LANG_PROGRAM([#include <stdlib.h>
+ #include <netdb.h>],
[struct hostent *he = gethostbyname_r((const char *)NULL, (struct hostent *)NULL, (char *)NULL, (int)0, (int *)NULL);]),
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_GETHOSTBYNAME_R_5], 1, [Define to 1 if your system has gethostbyname_r with 5 arguments.]),
Modified: team/russell/ais/include/asterisk/config.h
URL: http://svn.digium.com/view/asterisk/team/russell/ais/include/asterisk/config.h?view=diff&rev=78190&r1=78189&r2=78190
==============================================================================
--- team/russell/ais/include/asterisk/config.h (original)
+++ team/russell/ais/include/asterisk/config.h Mon Aug 6 12:23:41 2007
@@ -83,8 +83,15 @@
*/
void ast_config_destroy(struct ast_config *config);
-/*!
- * \brief Goes through categories
+/*! \brief returns the root ast_variable of a config
+ * \param config pointer to an ast_config data structure
+ * \param cat name of the category for which you want the root
+ *
+ * Returns the category specified
+ */
+struct ast_variable *ast_category_root(struct ast_config *config, char *cat);
+
+/*! \brief Goes through categories
* \param config Which config structure you wish to "browse"
* \param prev A pointer to a previous category.
* This funtion is kind of non-intuitive in it's use. To begin, one passes NULL as the second arguement. It will return a pointer to the string of the first category in the file. From here on after, one must then pass the previous usage's return value as the second pointer, and it will return a pointer to the category name afterwards.
Modified: team/russell/ais/include/asterisk/linkedlists.h
URL: http://svn.digium.com/view/asterisk/team/russell/ais/include/asterisk/linkedlists.h?view=diff&rev=78190&r1=78189&r2=78190
==============================================================================
--- team/russell/ais/include/asterisk/linkedlists.h (original)
+++ team/russell/ais/include/asterisk/linkedlists.h Mon Aug 6 12:23:41 2007
@@ -748,7 +748,7 @@
while (curelm && (curelm->field.next != (elm))) \
curelm = curelm->field.next; \
if (curelm) { \
- __res = curelm; \
+ __res = (elm); \
curelm->field.next = (elm)->field.next; \
if ((head)->last == (elm)) \
(head)->last = curelm; \
Modified: team/russell/ais/main/config.c
URL: http://svn.digium.com/view/asterisk/team/russell/ais/main/config.c?view=diff&rev=78190&r1=78189&r2=78190
==============================================================================
--- team/russell/ais/main/config.c (original)
+++ team/russell/ais/main/config.c Mon Aug 6 12:23:41 2007
@@ -354,6 +354,14 @@
for (; cat && cat->ignored; cat = cat->next);
return cat;
+}
+
+struct ast_variable *ast_category_root(struct ast_config *config, char *cat)
+{
+ struct ast_category *category = ast_category_get(config, cat);
+ if (category)
+ return category->root;
+ return NULL;
}
char *ast_category_browse(struct ast_config *config, const char *prev)
@@ -851,9 +859,8 @@
while ((comment_p = strchr(new_buf, COMMENT_META))) {
if ((comment_p > new_buf) && (*(comment_p-1) == '\\')) {
- /* Yuck, gotta memmove */
- memmove(comment_p - 1, comment_p, strlen(comment_p) + 1);
- new_buf = comment_p;
+ /* Escaped semicolons aren't comments. */
+ new_buf = comment_p + 1;
} else if (comment_p[1] == COMMENT_TAG && comment_p[2] == COMMENT_TAG && (comment_p[3] != '-')) {
/* Meta-Comment start detected ";--" */
if (comment < MAX_NESTED_COMMENTS) {
Modified: team/russell/ais/main/rtp.c
URL: http://svn.digium.com/view/asterisk/team/russell/ais/main/rtp.c?view=diff&rev=78190&r1=78189&r2=78190
==============================================================================
--- team/russell/ais/main/rtp.c (original)
+++ team/russell/ais/main/rtp.c Mon Aug 6 12:23:41 2007
@@ -59,7 +59,7 @@
#include "asterisk/unaligned.h"
#include "asterisk/utils.h"
-#define MAX_TIMESTAMP_SKEW 640
+#define MAX_TIMESTAMP_SKEW 20
#define RTP_SEQ_MOD (1<<16) /*!< A sequence number can't be more than 16 bits */
#define RTCP_DEFAULT_INTERVALMS 5000 /*!< Default milli-seconds between RTCP reports we send */
More information about the asterisk-commits
mailing list