Address comments from Mark Michelson

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@357014 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Sean Bright
2012-02-27 17:03:46 +00:00
parent 1fac2fba4b
commit c20cfcdcf0
2 changed files with 7 additions and 3 deletions

View File

@@ -12270,7 +12270,7 @@ static int check_srcaddr(struct ast_sockaddr *addr)
{ {
int sd; int sd;
sd = socket(ast_sockaddr_is_ipv4(addr) ? AF_INET : AF_INET6, SOCK_DGRAM, 0); sd = socket(addr->ss.ss_family, SOCK_DGRAM, 0);
if (sd < 0) { if (sd < 0) {
ast_log(LOG_ERROR, "Socket: %s\n", strerror(errno)); ast_log(LOG_ERROR, "Socket: %s\n", strerror(errno));
return -1; return -1;
@@ -12302,8 +12302,7 @@ static int peer_set_srcaddr(struct iax2_peer *peer, const char *srcaddr)
if (!(tmp = ast_strdupa(srcaddr))) if (!(tmp = ast_strdupa(srcaddr)))
return -1; return -1;
host = strsep(&tmp, ":"); ast_sockaddr_split_hostport(tmp, &host, &portstr, 0);
portstr = tmp;
if (portstr) { if (portstr) {
port = atoi(portstr); port = atoi(portstr);

View File

@@ -167,6 +167,11 @@ struct ast_netsock *ast_netsock_bind(struct ast_netsock_list *list, struct io_co
struct ast_sockaddr addr; struct ast_sockaddr addr;
if (ast_sockaddr_parse(&addr, bindinfo, 0)) { if (ast_sockaddr_parse(&addr, bindinfo, 0)) {
if (!ast_sockaddr_is_ipv4(&addr)) {
ast_log(LOG_WARNING, "Only IPv4 addresses are supported at this time.\n");
return NULL;
}
if (!ast_sockaddr_port(&addr)) { if (!ast_sockaddr_port(&addr)) {
ast_sockaddr_set_port(&addr, defaultport); ast_sockaddr_set_port(&addr, defaultport);
} }