}
#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)
+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)
{
struct ast_hostent ahp; struct hostent *hp;
struct iax2_peer *p;
p = NULL;
}
}
+ if (ofound)
+ *ofound = found;
if (!p && !found) {
hp = ast_gethostbyname(peer, &ahp);
if (hp) {
strsep(&stringp, ":");
portno = strsep(&stringp, ":");
}
- if (create_addr(&sin, NULL, NULL, NULL, hname, context, NULL, NULL, storedsecret, sizeof(storedsecret) - 1)) {
+ if (create_addr(&sin, NULL, NULL, NULL, hname, context, NULL, NULL, storedsecret, sizeof(storedsecret) - 1, NULL)) {
ast_log(LOG_WARNING, "No address associated with '%s'\n", hname);
return -1;
}
int res;
int sendani;
int maxtime;
+ int found = 0;
int fmt, native;
struct sockaddr_in sin;
char s[256];
}
/* Populate our address from the given */
- if (create_addr(&sin, &capability, &sendani, &maxtime, hostname, NULL, &trunk, ¬ransfer, NULL, 0)) {
+ if (create_addr(&sin, &capability, &sendani, &maxtime, hostname, NULL, &trunk, ¬ransfer, NULL, 0, &found)) {
return NULL;
}
if (portno) {
iaxs[callno]->sendani = sendani;
iaxs[callno]->maxtime = maxtime;
iaxs[callno]->notransfer = notransfer;
+ if (found)
+ strncpy(iaxs[callno]->host, hostname, sizeof(iaxs[callno]->host) - 1);
c = ast_iax2_new(callno, AST_STATE_DOWN, capability);
ast_mutex_unlock(&iaxsl[callno]);
if (c) {
host = st;
}
/* Populate our address from the given */
- if (create_addr(&sin, NULL, NULL, NULL, host, NULL, NULL, NULL, NULL, 0)) {
+ if (create_addr(&sin, NULL, NULL, NULL, host, NULL, NULL, NULL, NULL, 0, NULL)) {
return -1;
}
ast_log(LOG_DEBUG, "host: %s, user: %s, password: %s, context: %s\n", host, username, password, context);