Index: channels/chan_iax2.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_iax2.c,v retrieving revision 1.174 diff -u -r1.174 chan_iax2.c --- channels/chan_iax2.c 24 Jul 2004 02:50:11 -0000 1.174 +++ channels/chan_iax2.c 30 Jul 2004 08:54:09 -0000 @@ -2059,7 +2060,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 +2101,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 +2188,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 +2230,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 +2275,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 +5897,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 +6049,7 @@ } /* Populate our address from the given */ - if (create_addr(&sin, &capability, &sendani, &maxtime, hostname, NULL, &trunk, ¬ransfer, NULL, 0, &found, NULL)) { + if (create_addr(&sin, &capability, &sendani, &maxtime, hostname, NULL, &trunk, ¬ransfer, NULL, 0, NULL, 0, &found, NULL)) { return NULL; } if (portno) { @@ -6825,7 +6830,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);