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 4C8B7A034C; Tue, 14 Dec 2021 18:31:17 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 353C341140; Tue, 14 Dec 2021 18:31:17 +0100 (CET) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id 617CB4113E for ; Tue, 14 Dec 2021 18:31:16 +0100 (CET) X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: [PATCH 02/12] net: add function to pretty print IPv4 Date: Tue, 14 Dec 2021 18:31:15 +0100 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35D86D6F@smartserver.smartshare.dk> In-Reply-To: <20211214141242.3383831-3-ronan.randles@intel.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH 02/12] net: add function to pretty print IPv4 Thread-Index: Adfw9LjTV56x0R25SkiTy0w+v+l/ZQAGWcYA References: <20211214141242.3383831-1-ronan.randles@intel.com> <20211214141242.3383831-3-ronan.randles@intel.com> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: "Ronan Randles" , Cc: 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 > From: Ronan Randles [mailto:ronan.randles@intel.com] > Sent: Tuesday, 14 December 2021 15.13 >=20 > 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. >=20 > Signed-off-by: Ronan Randles [snip] > 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); >=20 > + > +/** > + * 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); > + In continuation of my email reply about the IPv4 parse function... I have a few suggestions to the IPv4 print function too: The return value should be the number of characters written to the = output string, and still -1 on error. With this modification, you could = use the return type ssize_t instead of int32_t. 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 added to = the ip_addr. -Morten