Skip to content
Snippets Groups Projects
Commit 9572ee68 authored by Olle Johansson's avatar Olle Johansson
Browse files

Cleaning up code

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@46649 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent f003df13
No related branches found
No related tags found
No related merge requests found
...@@ -2740,33 +2740,33 @@ static int create_addr(struct sip_pvt *dialog, const char *opeer) ...@@ -2740,33 +2740,33 @@ static int create_addr(struct sip_pvt *dialog, const char *opeer)
{ {
struct hostent *hp; struct hostent *hp;
struct ast_hostent ahp; struct ast_hostent ahp;
struct sip_peer *p; struct sip_peer *peer;
char *port; char *port;
int portno; int portno;
char host[MAXHOSTNAMELEN], *hostn; char host[MAXHOSTNAMELEN], *hostn;
char peer[256]; char peername[256];
   
ast_copy_string(peer, opeer, sizeof(peer)); ast_copy_string(peername, opeer, sizeof(peername));
port = strchr(peer, ':'); port = strchr(peername, ':');
if (port) if (port)
*port++ = '\0'; *port++ = '\0';
dialog->sa.sin_family = AF_INET; dialog->sa.sin_family = AF_INET;
dialog->timer_t1 = 500; /* Default SIP retransmission timer T1 (RFC 3261) */ dialog->timer_t1 = 500; /* Default SIP retransmission timer T1 (RFC 3261) */
p = find_peer(peer, NULL, 1); peer = find_peer(peername, NULL, 1);
   
if (p) { if (peer) {
int res = create_addr_from_peer(dialog, p); int res = create_addr_from_peer(dialog, peer);
ASTOBJ_UNREF(p, sip_destroy_peer); ASTOBJ_UNREF(peer, sip_destroy_peer);
return res; return res;
} }
hostn = peer; hostn = peername;
portno = port ? atoi(port) : STANDARD_SIP_PORT; portno = port ? atoi(port) : STANDARD_SIP_PORT;
if (srvlookup) { if (srvlookup) {
char service[MAXHOSTNAMELEN]; char service[MAXHOSTNAMELEN];
int tportno; int tportno;
int ret; int ret;
   
snprintf(service, sizeof(service), "_sip._udp.%s", peer); snprintf(service, sizeof(service), "_sip._udp.%s", peername);
ret = ast_get_srv(NULL, host, sizeof(host), &tportno, service); ret = ast_get_srv(NULL, host, sizeof(host), &tportno, service);
if (ret > 0) { if (ret > 0) {
hostn = host; hostn = host;
...@@ -2775,10 +2775,10 @@ static int create_addr(struct sip_pvt *dialog, const char *opeer) ...@@ -2775,10 +2775,10 @@ static int create_addr(struct sip_pvt *dialog, const char *opeer)
} }
hp = ast_gethostbyname(hostn, &ahp); hp = ast_gethostbyname(hostn, &ahp);
if (!hp) { if (!hp) {
ast_log(LOG_WARNING, "No such host: %s\n", peer); ast_log(LOG_WARNING, "No such host: %s\n", peername);
return -1; return -1;
} }
ast_string_field_set(dialog, tohost, peer); ast_string_field_set(dialog, tohost, peername);
memcpy(&dialog->sa.sin_addr, hp->h_addr, sizeof(dialog->sa.sin_addr)); memcpy(&dialog->sa.sin_addr, hp->h_addr, sizeof(dialog->sa.sin_addr));
dialog->sa.sin_port = htons(portno); dialog->sa.sin_port = htons(portno);
dialog->recv = dialog->sa; dialog->recv = dialog->sa;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment