aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--channels/chan_sip.c19
-rw-r--r--doc/extconfig.txt6
-rw-r--r--doc/realtime.txt10
3 files changed, 28 insertions, 7 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index c5f221111..1856c9af2 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -2175,12 +2175,20 @@ static int sip_sendtext(struct ast_channel *ast, const char *text)
return 0;
}
-/*! \brief Update peer object in realtime storage */
+/*! \brief Update peer object in realtime storage
+ If the Asterisk system name is set in asterisk.conf, we will use
+ that name and store that in the "regserver" field in the sippeers
+ table to facilitate multi-server setups.
+*/
static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, const char *username, const char *fullcontact, int expirey)
{
char port[10];
char ipaddr[20];
char regseconds[20];
+
+ char *sysname = ast_config_AST_SYSTEM_NAME;
+ char *syslabel = NULL;
+
time_t nowtime = time(NULL) + expirey;
const char *fc = fullcontact ? "fullcontact" : NULL;
@@ -2188,9 +2196,14 @@ static void realtime_update_peer(const char *peername, struct sockaddr_in *sin,
ast_inet_ntoa(ipaddr, sizeof(ipaddr), sin->sin_addr);
snprintf(port, sizeof(port), "%d", ntohs(sin->sin_port));
+ if (ast_strlen_zero(sysname)) /* No system name, disable this */
+ sysname = NULL;
+ else
+ syslabel = "regserver";
+
ast_update_realtime("sippeers", "name", peername, "ipaddr", ipaddr,
"port", port, "regseconds", regseconds,
- "username", username, fc, fullcontact, NULL); /* note fc _can_ be NULL */
+ "username", username, fc, fullcontact, syslabel, sysname, NULL); /* note fc _can_ be NULL */
}
/*! \brief Automatically add peer extension to dial plan */
@@ -7141,7 +7154,7 @@ static void destroy_association(struct sip_peer *peer)
{
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", "", NULL);
+ ast_update_realtime("sippeers", "name", peer->name, "fullcontact", "", "ipaddr", "", "port", "", "regseconds", "0", "username", "", "regserver", "", NULL);
else
ast_db_del("SIP/Registry", peer->name);
}
diff --git a/doc/extconfig.txt b/doc/extconfig.txt
index c52eb4796..0a95997ce 100644
--- a/doc/extconfig.txt
+++ b/doc/extconfig.txt
@@ -54,6 +54,12 @@ A SIP table would look more like this:
in order to store appropriate parameters required for SIP.
+In addition to this, if you add a field named "regserver" to the
+SIP peers table and have the system name set in asterisk.conf,
+Asterisk will store the system name that the user registered on in
+the database. This can be used to direct calls to go through the server
+that holds the registration (for NAT traversal purposes).
+
A Voicemail table would look more like this:
+----------+---------+----------+----------+-----------+---------------+
diff --git a/doc/realtime.txt b/doc/realtime.txt
index 6f5271d31..bdcf50513 100644
--- a/doc/realtime.txt
+++ b/doc/realtime.txt
@@ -49,9 +49,8 @@ voicemail notification and NAT keepalives for these peers. Other than that,
most of the functionality works the same way for realtime friends as for
the ones in static configuration.
-There is some work to create a solution for Realtime SIP devices that
-loads from database and stays in memory for the duration of a call or
-a registration, but that work is not integrated into Asterisk yet.
+With caching, the device stays in memory for a specified time. More
+information about this is to be found in the sip.conf sample file.
* New function in the dial plan: The Realtime Switch
----------------------------------------------------
@@ -94,8 +93,11 @@ driver.
Defined well-known family names are:
* sippeers, sipusers SIP peers and users
-* iaxfriends IAX2 peers
+* iaxpeers, iaxusers IAX2 peers and users
* voicemail Voicemail accounts
+* queues Queues
+* queue_members Queue members
+* extensions Realtime extensions (switch)
There is documentation of the SQL database in the file
doc/extconfig.txt in your Asterisk source code tree.