summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2008-01-30 23:10:23 +0000
committerMark Michelson <mmichelson@digium.com>2008-01-30 23:10:23 +0000
commit4d00d175c3d2fa4110fa443f4890cd1225e09516 (patch)
tree1807d21cf709ac30e93a6c5ba523d3297866f87b /channels
parent9d07e7e9ee90aef47b4a794f9af61b8426296bf1 (diff)
The deprecation of "username" in favor of "defaultuser" for SIP peers unfortunately
broke realtime configurations which still used the "username" field. This was taken care of properly when reading from realtime but was not handled properly when updating a realtime peer. This change also adds a deprecation NOTICE CLI message that will print if using the deprecated "username" field. (closes issue #11880) Reported by: cabal95 Patches: 11880.patch uploaded by putnopvut (license 60) Tested by: cabal95 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@101344 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index deeaae123..5b8b08742 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -1495,6 +1495,7 @@ struct sip_peer {
struct sip_st_cfg stimer; /*!< SIP Session-Timers */
int timer_t1; /*!< The maximum T1 value for the peer */
int timer_b; /*!< The maximum timer B (transaction timeouts) */
+ int deprecated_username; /*!< If it's a realtime peer, are they using the deprecated "username" instead of "defaultuser" */
};
@@ -1896,7 +1897,7 @@ static void set_insecure_flags(struct ast_flags *flags, const char *value, int l
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 void realtime_update_peer(const char *peername, struct sockaddr_in *sin, const char *username, const char *fullcontact, int expirey, int deprecated_username);
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);
@@ -3288,7 +3289,7 @@ static int sip_sendtext(struct ast_channel *ast, const char *text)
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 *defaultuser, const char *fullcontact, int expirey)
+static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, const char *defaultuser, const char *fullcontact, int expirey, int deprecated_username)
{
char port[10];
char ipaddr[INET_ADDRSTRLEN];
@@ -3317,11 +3318,11 @@ static void realtime_update_peer(const char *peername, struct sockaddr_in *sin,
if (fc)
ast_update_realtime(tablename, "name", peername, "ipaddr", ipaddr,
"port", port, "regseconds", regseconds,
- "defaultuser", defaultuser, fc, fullcontact, syslabel, sysname, NULL); /* note fc and syslabel _can_ be NULL */
+ deprecated_username ? "username" : "defaultuser", defaultuser, fc, fullcontact, syslabel, sysname, NULL); /* note fc and syslabel _can_ be NULL */
else
ast_update_realtime(tablename, "name", peername, "ipaddr", ipaddr,
"port", port, "regseconds", regseconds,
- "defaultuser", defaultuser, syslabel, sysname, NULL); /* note syslabel _can_ be NULL */
+ deprecated_username ? "username" : "defaultuser", defaultuser, syslabel, sysname, NULL); /* note syslabel _can_ be NULL */
}
/*! \brief Automatically add peer extension to dial plan */
@@ -3431,7 +3432,7 @@ static void update_peer(struct sip_peer *p, int expiry)
int rtcachefriends = ast_test_flag(&p->flags[1], SIP_PAGE2_RTCACHEFRIENDS);
if (sip_cfg.peer_rtupdate &&
(p->is_realtime || rtcachefriends)) {
- realtime_update_peer(p->name, &p->addr, p->username, rtcachefriends ? p->fullcontact : NULL, expiry);
+ realtime_update_peer(p->name, &p->addr, p->username, rtcachefriends ? p->fullcontact : NULL, expiry, p->deprecated_username);
}
}
@@ -9325,7 +9326,7 @@ static void destroy_association(struct sip_peer *peer)
if (!sip_cfg.ignore_regexpire) {
if (peer->rt_fromcontact)
- ast_update_realtime(tablename, "name", peer->name, "fullcontact", "", "ipaddr", "", "port", "", "regseconds", "0", "defaultuser", "", "regserver", "", NULL);
+ ast_update_realtime(tablename, "name", peer->name, "fullcontact", "", "ipaddr", "", "port", "", "regseconds", "0", peer->deprecated_username ? "username" : "defaultuser", "", "regserver", "", NULL);
else
ast_db_del("SIP/Registry", peer->name);
}
@@ -19447,6 +19448,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
struct ast_flags mask[2] = {{(0)}};
char callback[256] = "";
const char *srvlookup = NULL;
+ static int deprecation_warning = 1;
if (!realtime)
/* Note we do NOT use find_peer here, to avoid realtime recursion */
@@ -19589,8 +19591,15 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
peer->callingpres = ast_parse_caller_presentation(v->value);
if (peer->callingpres == -1)
peer->callingpres = atoi(v->value);
- } else if (!strcasecmp(v->name, "username") | !strcmp(v->name, "defaultuser")) { /* "username" is deprecated */
+ } else if (!strcasecmp(v->name, "username") || !strcmp(v->name, "defaultuser")) { /* "username" is deprecated */
ast_copy_string(peer->username, v->value, sizeof(peer->username));
+ if (!strcasecmp(v->name, "username")) {
+ if (deprecation_warning) {
+ ast_log(LOG_NOTICE, "The 'username' field for sip peers has been deprecated in favor of the term 'defaultuser'\n");
+ deprecation_warning = 0;
+ }
+ peer->deprecated_username = 1;
+ }
} else if (!strcasecmp(v->name, "language")) {
ast_copy_string(peer->language, v->value, sizeof(peer->language));
} else if (!strcasecmp(v->name, "regexten")) {