From patchwork Tue May 3 13:34:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashijeet Acharya X-Patchwork-Id: 9003811 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E7391BF29F for ; Tue, 3 May 2016 13:35:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 41490200E8 for ; Tue, 3 May 2016 13:35:42 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 94612200C1 for ; Tue, 3 May 2016 13:35:41 +0000 (UTC) Received: from localhost ([::1]:41391 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axaUA-0007bH-Ua for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 May 2016 09:35:34 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=tj/jspmmLIP4xyIXi1EaDLvd9JZYaB1cz1WxUYf9bc4=; b=uQu7qfWtVlr39BMSP08k/zrelSIxp3mbXwqF5AGaMtHs9/6MSCpt/K050fOgKX6Hxd 8FVxhrrRSlWnBAaJmvPE4zrQ3pB5uoFVf5rQ9858FFQdCN6wAOv4z1I/en9kEsf9HEms oiIxOXx2WSK8vPpQ9le4994v4JMqGb85AHbGmwZLN0h+Kw26TT76ykgUaDHsyXtmQH0x tTAgjc9X7lsO8bM6RAjGvCpIYZlGpR1Hi4+fvbnYWr8w38++JWwTSJGiml6mZWhYKJgS /SpG1vhFu0ciW4xLN9GNWoZcSWZif99hk8fYik4lPPccYcQMQVzyOitQH6jDatjx9r4v 99FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=tj/jspmmLIP4xyIXi1EaDLvd9JZYaB1cz1WxUYf9bc4=; b=QSqBtxLXY3RlubjwDUzPFX+HEzQbbFdHLO6edC0aw0Oe2synVpDmNDY2J19jOX2Ccx 8Q//ToFc6kdZhWFsgwMHyxxIV6nq/7Nbs3PXhoWAzl/2Umtc6fkSmpRFJPvLr8PLkuzX cy9oILNPDCV3XYl3Jwz2wgre14LqlliDrb6cL48CIsY+VMl/HdaEZ2wHsvVj/Dex2slJ fhXL9N0ie+HzL/+RPOuIZTGjxVVMhSWlGxNhUkNVpbnjxxEX+A+BtQeYxk5LJY110+00 ZmYDBVaPrTbUi2bbZIrNNidKTvVK0ZY62KWLFDM8USs3eRvDGHhK8gBGTrWTzL441ngu yE8w== X-Gm-Message-State: AOPr4FXeb6pxLw0yBtobEZbmZZ5WHbW5lW89lf/AUvsoUNtUBc0iX9XGTb8Q6aynBoKFOQ== X-Received: by 10.66.21.102 with SMTP id u6mr3532189pae.118.1462282485641; Tue, 03 May 2016 06:34:45 -0700 (PDT) Received: from localhost.localdomain ([27.251.197.194]) by smtp.gmail.com with ESMTPSA id d186sm6135905pfa.45.2016.05.03.06.34.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 May 2016 06:34:44 -0700 (PDT) From: Ashijeet Acharya To: jasowang@redhat.com Date: Tue, 3 May 2016 19:04:17 +0530 Message-Id: <1462282457-24574-1-git-send-email-ashijeetacharya@gmail.com> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c03::242 Subject: [Qemu-devel] [PATCH] Modify net/socket.c to use functions from include/qemu/sockets.h X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Ashijeet Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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; }