From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8FBC8A034C; Wed, 15 Dec 2021 04:21:00 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 14F1640041; Wed, 15 Dec 2021 04:21:00 +0100 (CET) Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by mails.dpdk.org (Postfix) with ESMTP id CD7034003C for ; Wed, 15 Dec 2021 04:20:58 +0100 (CET) Received: by mail-pg1-f177.google.com with SMTP id 200so10128994pgg.3 for ; Tue, 14 Dec 2021 19:20:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2vEReY2IY4t9BNaQR9eESRlIH9nbcQuJYJRnMGjS/d0=; b=Qh2fSuPbyhJjR1+dIrc5ewLtTAPAQZZTOkvIQZ+M+v7aZkPaYCTrtFnNIbDDWIz8et n97/e4YLAfSRSDHXeIfZjBza5qvObtwqtQ0IZ90nGaMPn/0A+Z6ohK5yPAHAAQAiPYnC FOHLLftHoUolYjHpl40DGv9tV0veuTh/QTY6jjxcsRFXujFkzgKbRbhdp58CP0xUstMA djTXMKWTD5qvK4iYwTUad+0gONlx4SyXPUpbyvwftEoETWyzEQ00iA6kWCUdUr+UYxuF S9poSFCro22gyufHBrcb8meJx7K4EMpId7Xb6uziYvhGZUPmLSYWqqJWwlU2imbxAF4I R+Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2vEReY2IY4t9BNaQR9eESRlIH9nbcQuJYJRnMGjS/d0=; b=FKtUAABrtl4LuRSt/Grp3KPXvPS4WXdlMev800Rz+hdzKNwIObhXkqwkAkf7xBu9+7 RHmnln+JJfPtKJvjlOeKChJzjYdkadCgCC8Jfcvctw23lCWwGg3h8Zn+6ER0JlIvhU82 LO3Kz6a17UEkVD46kwsTPk0Mw5+36PMfb5m24QfMOrKQBreF54ER27IBDZum6zgfvmc/ dL/Jh+f7Q3GL2WG1c9YWltRjsSzAHgBC3/tGhzhpIK4zfdf78PjetMKiXtD06LNlYesv BFvfkTS4nBi1Rwk7JsFdtW4v6tdcqeotH6tIjymc/BInQMFYUVZ6IzYSe/ROuntNU22j O48g== X-Gm-Message-State: AOAM531oXToFsVLMyTd+N6DlUx7Ex1VVNaoJFSXLkiPM0ge5uwp0gCa6 9kdD31P8dC+k8iGvWXf6wo2zUQ== X-Google-Smtp-Source: ABdhPJx8Ox2L6Vu0iLHlJnjfZVA5OOPnuadJMiPnT1uFDBVbLLg50Tal9Hr5RrxlWFYbdx2JbnxaFA== X-Received: by 2002:a63:8548:: with SMTP id u69mr6269003pgd.428.1639538457732; Tue, 14 Dec 2021 19:20:57 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id w20sm497422pfu.146.2021.12.14.19.20.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Dec 2021 19:20:57 -0800 (PST) Date: Tue, 14 Dec 2021 19:20:53 -0800 From: Stephen Hemminger To: "Ananyev, Konstantin" Cc: Morten =?UTF-8?B?QnLDuHJ1cA==?= , "Randles, Ronan" , "dev@dpdk.org" , "Van Haaren, Harry" Subject: Re: [PATCH 02/12] net: add function to pretty print IPv4 Message-ID: <20211214192053.54ea2f2f@hermes.local> In-Reply-To: References: <20211214141242.3383831-1-ronan.randles@intel.com> <20211214141242.3383831-3-ronan.randles@intel.com> <98CBD80474FA8B44BF855DF32C47DC35D86D6F@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Wed, 15 Dec 2021 01:06:14 +0000 "Ananyev, Konstantin" wrote: > > -----Original Message----- > > From: Morten Br=C3=B8rup > > Sent: Tuesday, December 14, 2021 5:31 PM > > To: Randles, Ronan ; dev@dpdk.org > > Cc: Van Haaren, Harry > > Subject: RE: [PATCH 02/12] net: add function to pretty print IPv4 > > =20 > > > From: Ronan Randles [mailto:ronan.randles@intel.com] > > > Sent: Tuesday, 14 December 2021 15.13 > > > > > > This function accepts an uint32_t representation of an IP address and > > > produces a string representation stored in a char * buffer. Realavent > > > unit tests also included. > > > > > > Signed-off-by: Ronan Randles =20 > >=20 > > [snip] > > =20 > > > diff --git a/lib/net/rte_ip.h b/lib/net/rte_ip.h > > > index 188054fda4..e46f0b41ba 100644 > > > --- a/lib/net/rte_ip.h > > > +++ b/lib/net/rte_ip.h > > > @@ -444,6 +444,26 @@ __rte_experimental > > > int32_t > > > rte_ip_parse_addr(const char *src_ip, uint32_t *output_addr); > > > > > > + > > > +/** > > > + * Print IP address from 32 bit int into char * buffer. > > > + * > > > + * @param ip_addr > > > + * ip address to be printed. > > > + * @param buffer > > > + * The buffer the string will be saved into. > > > + * @param buffer_size > > > + * size of buffer to be used. > > > + * > > > + * @retval 0 > > > + * Success. > > > + * @retval -1 > > > + * Failure due to invalid input arguments. > > > + */ > > > +__rte_experimental > > > +int32_t > > > +rte_ip_print_addr(uint32_t ip_addr, char *buffer, uint32_t > > > buffer_size); > > > + =20 > >=20 > > In continuation of my email reply about the IPv4 parse function... > >=20 > > I have a few suggestions to the IPv4 print function too: > >=20 > > The return value should be the number of characters written to the outp= ut string, and still -1 on error. With this modification, you could > > use the return type ssize_t instead of int32_t. > >=20 > > Furthermore, I would prefer having the parameters in the same order as = snprintf(): char *str, size_t size, const uint32_t ip_addr. Please > > also notice the suggested changed type for the size, and the const adde= d to the ip_addr. > > =20 > Honestly, I don't understand why we need to introduce such functions > inside DPDK at all. > What's wrong with existing standard ones: inet_ntop() and inet_pton()? Agreed, I see no added value in reinventing here