summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatteo Brancaleoni <mbrancaleoni@espia.it>2003-02-17 06:00:19 +0000
committerMatteo Brancaleoni <mbrancaleoni@espia.it>2003-02-17 06:00:19 +0000
commit9ea88c182549a8b4961b3fdd7dd63bd364671d52 (patch)
treef602fc12bd9e91f8c54447507168d8ffd7dacb74
parent1c156b82d16bf1fa2013cafe900f3081415aab9a (diff)
Mon Feb 17 07:00:01 CET 2003
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@617 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rwxr-xr-xCHANGES1
-rwxr-xr-xchannels/chan_sip.c12
-rwxr-xr-xconfigs/sip.conf.sample5
3 files changed, 15 insertions, 3 deletions
diff --git a/CHANGES b/CHANGES
index d190dd4bf..ff89f86f0 100755
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,4 @@
+ -- Allow SIP registration to provide an alternative contact
-- Make HOLD on SIP make use of asterisk MOH
-- Add supervised transfer (tested with Pingtel only)
-- Allow maxexpirey and defaultexpirey to be runtime configurable for SIP
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index a057eb89e..0f8869de4 100755
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -252,6 +252,7 @@ struct sip_registry {
struct sockaddr_in addr; /* Who we connect to for registration purposes */
char username[80];
char secret[80]; /* Password or key name in []'s */
+ char contact[80]; /* Contact extension */
char random[80];
int expire; /* Sched ID of expiration */
int timeout; /* sched id of sip_reg_timeout */
@@ -1060,6 +1061,7 @@ static int sip_register(char *value, int lineno)
char copy[256] = "";
char *username, *hostname, *secret;
char *porta;
+ char *contact;
char *stringp=NULL;
struct hostent *hp;
@@ -1076,9 +1078,14 @@ static int sip_register(char *value, int lineno)
stringp=username;
username = strsep(&stringp, ":");
secret = strsep(&stringp, ":");
+ stringp = hostname;
+ hostname = strsep(&stringp, "/");
+ contact = strsep(&stringp, "/");
+ if (!contact || !strlen(contact))
+ contact = "s";
stringp=hostname;
hostname = strsep(&stringp, ":");
- porta = strsep(&stringp, ";");
+ porta = strsep(&stringp, ":");
if (porta && !atoi(porta)) {
ast_log(LOG_WARNING, "%s is not a valid port number at line %d\n", porta, lineno);
@@ -1092,6 +1099,7 @@ static int sip_register(char *value, int lineno)
reg = malloc(sizeof(struct sip_registry));
if (reg) {
memset(reg, 0, sizeof(struct sip_registry));
+ strncpy(reg->contact, contact, sizeof(reg->contact) - 1);
strncpy(reg->username, username, sizeof(reg->username)-1);
if (secret)
strncpy(reg->secret, secret, sizeof(reg->secret)-1);
@@ -1840,7 +1848,7 @@ static int transmit_register(struct sip_registry *r, char *cmd, char *auth)
add_header(&req, "To", to);
{
char contact[256];
- snprintf(contact, sizeof(contact), "<sip:s@%s:%d;transport=udp>", inet_ntoa(p->ourip), ourport);
+ snprintf(contact, sizeof(contact), "<sip:%s@%s:%d;transport=udp>", r->contact, inet_ntoa(p->ourip), ourport);
add_header(&req, "Contact", contact);
}
add_header(&req, "Call-ID", p->callid);
diff --git a/configs/sip.conf.sample b/configs/sip.conf.sample
index dad7c1501..d91b2b343 100755
--- a/configs/sip.conf.sample
+++ b/configs/sip.conf.sample
@@ -9,7 +9,10 @@ context = default ; Default for incoming calls
;tos=184
;maxexpirey=3600 ; Max length of incoming registration we allow
;defaultexpirey=120 ; Default length of incoming/outoing registration
-
+;
+;register => 1234@mysipprovider.com ; Register with a SIP provider
+;register => 2345@mysipprovider.com/1234 ; Register 2345 at sip provider as 1234 here.
+;
;[snomsip]
;type=friend
;secret=blah