mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
Inspired by issue 6742, but solved in a different way.
(Yes, I like the system name setting) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@36177 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
@@ -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:
|
||||
|
||||
+----------+---------+----------+----------+-----------+---------------+
|
||||
|
@@ -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.
|
||||
|
Reference in New Issue
Block a user