[Asterisk-cvs] asterisk/channels chan_iax2.c,1.174,1.175

markster at lists.digium.com markster at lists.digium.com
Fri Jul 30 11:13:53 CDT 2004


Update of /usr/cvsroot/asterisk/channels
In directory localhost.localdomain:/tmp/cvs-serv32122/channels

Modified Files:
	chan_iax2.c 
Log Message:
Add default username patch (bug #2178)


Index: chan_iax2.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_iax2.c,v
retrieving revision 1.174
retrieving revision 1.175
diff -u -d -r1.174 -r1.175
--- chan_iax2.c	24 Jul 2004 02:50:11 -0000	1.174
+++ chan_iax2.c	30 Jul 2004 14:59:56 -0000	1.175
@@ -2059,7 +2059,7 @@
 }
 #endif /* MYSQL_FRIENDS */
 
-static int create_addr(struct sockaddr_in *sin, int *capability, int *sendani, int *maxtime, char *peer, char *context, int *trunk, int *notransfer, char *secret, int seclen, int *ofound, char *peercontext)
+static int create_addr(struct sockaddr_in *sin, int *capability, int *sendani, int *maxtime, char *peer, char *context, int *trunk, int *notransfer, char *username, int usernlen, char *secret, int seclen, int *ofound, char *peercontext)
 {
 	struct ast_hostent ahp; struct hostent *hp;
 	struct iax2_peer *p;
@@ -2100,6 +2100,8 @@
 				*trunk = p->trunk;
 			if (capability)
 				*capability = p->capability;
+			if (username)
+				strncpy(username, p->username, usernlen);
 			if (secret)
 				strncpy(secret, p->secret, seclen); /* safe */
 			if (p->addr.sin_addr.s_addr) {
@@ -2185,7 +2187,7 @@
 	char *opts = "";
 	unsigned short callno = PTR_TO_CALLNO(c->pvt->pvt);
 	char *stringp=NULL;
-	char storedsecret[80];
+	char storedusern[80], storedsecret[80];
 	if ((c->_state != AST_STATE_DOWN) && (c->_state != AST_STATE_RESERVED)) {
 		ast_log(LOG_WARNING, "Line is already in use (%s)?\n", c->name);
 		return -1;
@@ -2227,7 +2229,7 @@
 		strsep(&stringp, ":");
 		portno = strsep(&stringp, ":");
 	}
-	if (create_addr(&sin, NULL, NULL, NULL, hname, context, NULL, NULL, storedsecret, sizeof(storedsecret) - 1, NULL, peercontext)) {
+	if (create_addr(&sin, NULL, NULL, NULL, hname, context, NULL, NULL, storedusern, sizeof(storedusern) - 1, storedsecret, sizeof(storedsecret) - 1, NULL, peercontext)) {
 		ast_log(LOG_WARNING, "No address associated with '%s'\n", hname);
 		return -1;
 	}
@@ -2272,6 +2274,8 @@
 		iax_ie_append_str(&ied, IAX_IE_CALLED_CONTEXT, rcontext);
 	else if (strlen(peercontext))
 		iax_ie_append_str(&ied, IAX_IE_CALLED_CONTEXT, peercontext);
+	if (!username && !ast_strlen_zero(storedusern))
+		username = storedusern;
 	if (username)
 		iax_ie_append_str(&ied, IAX_IE_USERNAME, username);
 	if (!secret && !ast_strlen_zero(storedsecret))
@@ -5892,7 +5896,7 @@
 	if (end)
 		memcpy(&sin, end, sizeof(sin));
 	else {
-		if (create_addr(&sin, NULL, NULL, NULL, dest, NULL, NULL, NULL, NULL, 0, NULL, NULL))
+		if (create_addr(&sin, NULL, NULL, NULL, dest, NULL, NULL, NULL, NULL, 0, NULL, 0, NULL, NULL))
 			return -1;
 	}
 	/* Build the rest of the message */
@@ -6044,7 +6048,7 @@
 	}							
 
 	/* Populate our address from the given */
-	if (create_addr(&sin, &capability, &sendani, &maxtime, hostname, NULL, &trunk, &notransfer, NULL, 0, &found, NULL)) {
+	if (create_addr(&sin, &capability, &sendani, &maxtime, hostname, NULL, &trunk, &notransfer, NULL, 0, NULL, 0, &found, NULL)) {
 		return NULL;
 	}
 	if (portno) {
@@ -6825,7 +6829,7 @@
 		host = st;
 	}
 	/* Populate our address from the given */
-	if (create_addr(&sin, NULL, NULL, NULL, host, NULL, NULL, NULL, NULL, 0, NULL, NULL)) {
+	if (create_addr(&sin, NULL, NULL, NULL, host, NULL, NULL, NULL, NULL, 0, NULL, 0, NULL, NULL)) {
 		return -1;
 	}
 	ast_log(LOG_DEBUG, "host: %s, user: %s, password: %s, context: %s\n", host, username, password, context);




More information about the svn-commits mailing list