From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56553) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axaTt-0007KF-RA for qemu-devel@nongnu.org; Tue, 03 May 2016 09:35:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1axaTh-0006Ce-6C for qemu-devel@nongnu.org; Tue, 03 May 2016 09:35:12 -0400 Received: from mail-pa0-x242.google.com ([2607:f8b0:400e:c03::242]:36492) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axaTf-00064j-Tn for qemu-devel@nongnu.org; Tue, 03 May 2016 09:35:05 -0400 Received: by mail-pa0-x242.google.com with SMTP id i5so1776130pag.3 for ; Tue, 03 May 2016 06:34:49 -0700 (PDT) From: Ashijeet Acharya Date: Tue, 3 May 2016 19:04:17 +0530 Message-Id: <1462282457-24574-1-git-send-email-ashijeetacharya@gmail.com> Subject: [Qemu-devel] [PATCH] Modify net/socket.c to use functions from include/qemu/sockets.h List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: jasowang@redhat.com Cc: qemu-devel@nongnu.org, Ashijeet From: Ashijeet Replaced connect()/listen()/parse_host_port() in net/socket.c with inet_connect()/inet_listen/inet_parse() in include/qemu/sockets.h. Signed-off-by: Ashijeet Acharya --- net/socket.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/net/socket.c b/net/socket.c index 9fa2cd8..20cc1d2 100644 --- a/net/socket.c +++ b/net/socket.c @@ -524,8 +524,9 @@ static int net_socket_listen_init(NetClientState *peer, NetSocketState *s; struct sockaddr_in saddr; int fd, ret; + Error *local_error = NULL; - if (parse_host_port(&saddr, host_str) < 0) + if (inet_parse(host_str, &local_error) < 0) return -1; fd = qemu_socket(PF_INET, SOCK_STREAM, 0); @@ -543,7 +544,7 @@ static int net_socket_listen_init(NetClientState *peer, closesocket(fd); return -1; } - ret = listen(fd, 0); + ret = inet_listen(host_str, NULL, 256, SOCK_STREAM, 0, &local_error); if (ret < 0) { perror("listen"); closesocket(fd); @@ -568,8 +569,9 @@ static int net_socket_connect_init(NetClientState *peer, NetSocketState *s; int fd, connected, ret; struct sockaddr_in saddr; + Error *local_error = NULL; - if (parse_host_port(&saddr, host_str) < 0) + if (inet_parse(host_str, &local_error) < 0) return -1; fd = qemu_socket(PF_INET, SOCK_STREAM, 0); @@ -581,7 +583,7 @@ static int net_socket_connect_init(NetClientState *peer, connected = 0; for(;;) { - ret = connect(fd, (struct sockaddr *)&saddr, sizeof(saddr)); + ret = inet_connect(host_str, &local_error); if (ret < 0) { if (errno == EINTR || errno == EWOULDBLOCK) { /* continue */ @@ -618,8 +620,8 @@ static int net_socket_mcast_init(NetClientState *peer, int fd; struct sockaddr_in saddr; struct in_addr localaddr, *param_localaddr; - - if (parse_host_port(&saddr, host_str) < 0) + Error *local_error = NULL; + if (inet_parse(host_str, &local_error) < 0) return -1; if (localaddr_str != NULL) { @@ -656,12 +658,13 @@ static int net_socket_udp_init(NetClientState *peer, NetSocketState *s; int fd, ret; struct sockaddr_in laddr, raddr; + Error *local_error = NULL; - if (parse_host_port(&laddr, lhost) < 0) { + if (inet_parse(lhost, &local_error) < 0) { return -1; } - if (parse_host_port(&raddr, rhost) < 0) { + if (inet_parse(rhost, &local_error) < 0) { return -1; } -- 1.9.1