Address comments from Mark Michelson
authorSean Bright <sean@malleable.com>
Mon, 27 Feb 2012 17:03:46 +0000 (17:03 +0000)
committerSean Bright <sean@malleable.com>
Mon, 27 Feb 2012 17:03:46 +0000 (17:03 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@357014 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_iax2.c
main/netsock.c

index 24f49d8..fab2752 100644 (file)
@@ -12270,7 +12270,7 @@ static int check_srcaddr(struct ast_sockaddr *addr)
 {
        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) {
                ast_log(LOG_ERROR, "Socket: %s\n", strerror(errno));
                return -1;
@@ -12302,8 +12302,7 @@ static int peer_set_srcaddr(struct iax2_peer *peer, const char *srcaddr)
        if (!(tmp = ast_strdupa(srcaddr)))
                return -1;
 
-       host = strsep(&tmp, ":");
-       portstr = tmp;
+       ast_sockaddr_split_hostport(tmp, &host, &portstr, 0);
 
        if (portstr) {
                port = atoi(portstr);
index 334617d..994afc6 100644 (file)
@@ -167,6 +167,11 @@ struct ast_netsock *ast_netsock_bind(struct ast_netsock_list *list, struct io_co
        struct ast_sockaddr addr;
 
        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)) {
                        ast_sockaddr_set_port(&addr, defaultport);
                }