qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Ashijeet Acharya <ashijeetacharya@gmail.com>
To: jasowang@redhat.com
Cc: qemu-devel@nongnu.org, Ashijeet <ashijeetacharya@gmail.com>
Subject: [Qemu-devel] [PATCH] Modify net/socket.c to use functions from include/qemu/sockets.h
Date: Tue,  3 May 2016 19:04:17 +0530	[thread overview]
Message-ID: <1462282457-24574-1-git-send-email-ashijeetacharya@gmail.com> (raw)

From: Ashijeet <ashijeetacharya@gmail.com>

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 <ashijeetacharya@gmail.com>
---
 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

             reply	other threads:[~2016-05-03 13:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-03 13:34 Ashijeet Acharya [this message]
2016-05-03 14:01 ` [Qemu-devel] [PATCH] Modify net/socket.c to use functions from include/qemu/sockets.h Daniel P. Berrange
2016-05-03 18:13   ` Ashi
2016-05-04  8:39     ` Daniel P. Berrange
2016-05-12  9:09       ` Ashi
2016-05-12  9:18         ` Daniel P. Berrange

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1462282457-24574-1-git-send-email-ashijeetacharya@gmail.com \
    --to=ashijeetacharya@gmail.com \
    --cc=jasowang@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).