[svn-commits] rizzo: branch rizzo/astobj2 r57978 -
/team/rizzo/astobj2/channels/chan_sip.c
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Tue Mar 6 01:32:17 MST 2007
Author: rizzo
Date: Tue Mar 6 02:32:16 2007
New Revision: 57978
URL: http://svn.digium.com/view/asterisk?view=rev&rev=57978
Log:
merge from trunk svn 54574
Modified:
team/rizzo/astobj2/channels/chan_sip.c
Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=57978&r1=57977&r2=57978
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Tue Mar 6 02:32:16 2007
@@ -2790,12 +2790,16 @@
char port[10];
char ipaddr[INET_ADDRSTRLEN];
char regseconds[20];
+ char *tablename = NULL;
char *sysname = ast_config_AST_SYSTEM_NAME;
char *syslabel = NULL;
time_t nowtime = time(NULL) + expirey;
const char *fc = fullcontact ? "fullcontact" : NULL;
+ int realtimeregs = ast_check_realtime("sipregs");
+
+ tablename = realtimeregs ? "sipregs" : "sippeers";
snprintf(regseconds, sizeof(regseconds), "%d", (int)nowtime); /* Expiration time */
ast_copy_string(ipaddr, ast_inet_ntoa(sin->sin_addr), sizeof(ipaddr));
@@ -2807,11 +2811,11 @@
syslabel = "regserver";
if (fc)
- ast_update_realtime("sippeers", "name", peername, "ipaddr", ipaddr,
+ ast_update_realtime(tablename, "name", peername, "ipaddr", ipaddr,
"port", port, "regseconds", regseconds,
"username", username, fc, fullcontact, syslabel, sysname, NULL); /* note fc and syslabel _can_ be NULL */
else
- ast_update_realtime("sippeers", "name", peername, "ipaddr", ipaddr,
+ ast_update_realtime(tablename, "name", peername, "ipaddr", ipaddr,
"port", port, "regseconds", regseconds,
"username", username, syslabel, sysname, NULL); /* note syslabel _can_ be NULL */
}
@@ -2905,6 +2909,7 @@
/*! \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?
*/
@@ -2912,17 +2917,38 @@
{
struct sip_peer *peer;
struct ast_variable *var = NULL;
+ struct ast_variable *varregs = NULL;
struct ast_variable *tmp;
char ipaddr[INET_ADDRSTRLEN];
+ int realtimeregs = ast_check_realtime("sipregs");
/* First check on peer name */
- if (newpeername)
+ if (newpeername) {
var = ast_load_realtime("sippeers", "name", newpeername, NULL);
- else if (sin) { /* Then check on IP address for dynamic peers */
+ if (realtimeregs)
+ 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 */
- if (!var)
- var = ast_load_realtime("sippeers", "ipaddr", ipaddr, NULL); /* Then check for registred hosts */
+ if (var && realtimeregs) {
+ for (tmp = var; tmp; tmp = tmp->next) {
+ if (!newpeername && !strcasecmp(tmp->name, "name"))
+ newpeername = tmp->value;
+ }
+ varregs = ast_load_realtime("sipregs", "name", newpeername, NULL);
+ } else {
+ if (realtimeregs)
+ varregs = ast_load_realtime("sipregs", "ipaddr", ipaddr, NULL); /* Then check for registered hosts */
+ else
+ var = ast_load_realtime("sippeers", "ipaddr", ipaddr, NULL); /* Then check for registered hosts */
+ if (varregs) {
+ for (tmp = varregs; tmp; tmp = tmp->next) {
+ if (!newpeername && !strcasecmp(tmp->name, "name"))
+ newpeername = tmp->value;
+ }
+ var = ast_load_realtime("sippeers", "name", newpeername, NULL);
+ }
+ }
}
if (!var)
@@ -2933,6 +2959,7 @@
if (!strcasecmp(tmp->name, "type") &&
!strcasecmp(tmp->value, "user")) {
ast_variables_destroy(var);
+ ast_variables_destroy(varregs);
return NULL;
} else if (!newpeername && !strcasecmp(tmp->name, "name")) {
newpeername = tmp->value;
@@ -2947,9 +2974,10 @@
/* Peer found in realtime, now build it in memory */
- peer = build_peer(newpeername, var, NULL, !ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS));
+ 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);
return NULL;
}
@@ -8372,9 +8400,12 @@
/*! \brief Remove registration data from realtime database or AST/DB when registration expires */
static void destroy_association(struct sip_peer *peer)
{
+ int realtimeregs = ast_check_realtime("sipregs");
+ char *tablename = (realtimeregs) ? "sipregs" : "sippeers";
+
if (!ast_test_flag(&global_flags[1], SIP_PAGE2_IGNOREREGEXPIRE)) {
if (ast_test_flag(&peer->flags[1], SIP_PAGE2_RT_FROMCONTACT))
- ast_update_realtime("sippeers", "name", peer->name, "fullcontact", "", "ipaddr", "", "port", "", "regseconds", "0", "username", "", "regserver", "", NULL);
+ ast_update_realtime(tablename, "name", peer->name, "fullcontact", "", "ipaddr", "", "port", "", "regseconds", "0", "username", "", "regserver", "", NULL);
else
ast_db_del("SIP/Registry", peer->name);
}
@@ -11271,10 +11302,12 @@
{
int realtimepeers;
int realtimeusers;
+ int realtimeregs;
char codec_buf[BUFSIZ];
realtimepeers = ast_check_realtime("sippeers");
realtimeusers = ast_check_realtime("sipusers");
+ realtimeregs = ast_check_realtime("sipregs");
if (argc != 3)
return RESULT_SHOWUSAGE;
@@ -11321,7 +11354,7 @@
ast_cli(fd, " Jitterbuffer resync: %ld\n", global_jbconf.resync_threshold);
ast_cli(fd, " Jitterbuffer impl: %s\n", global_jbconf.impl);
ast_cli(fd, " Jitterbuffer log: %s\n", ast_test_flag(&global_jbconf, AST_JB_LOG) ? "Yes" : "No");
- if (!realtimepeers && !realtimeusers)
+ if (!realtimepeers && !realtimeusers && !realtimeregs)
ast_cli(fd, " SIP realtime: Disabled\n" );
else
ast_cli(fd, " SIP realtime: Enabled\n" );
@@ -11369,11 +11402,12 @@
ast_cli(fd, " Voice Mail Extension: %s\n", default_vmexten);
- if (realtimepeers || realtimeusers) {
+ if (realtimepeers || realtimeusers || realtimeregs) {
ast_cli(fd, "\nRealtime SIP Settings:\n");
ast_cli(fd, "----------------------\n");
ast_cli(fd, " Realtime Peers: %s\n", realtimepeers ? "Yes" : "No");
ast_cli(fd, " Realtime Users: %s\n", realtimeusers ? "Yes" : "No");
+ ast_cli(fd, " Realtime Regs: %s\n", realtimeregs ? "Yes" : "No");
ast_cli(fd, " Cache Friends: %s\n", ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS) ? "Yes" : "No");
ast_cli(fd, " Update: %s\n", ast_test_flag(&global_flags[1], SIP_PAGE2_RTUPDATE) ? "Yes" : "No");
ast_cli(fd, " Ignore Reg. Expire: %s\n", ast_test_flag(&global_flags[1], SIP_PAGE2_IGNOREREGEXPIRE) ? "Yes" : "No");
More information about the svn-commits
mailing list