From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.tuxteam.de (mail.tuxteam.de [5.199.139.25]) by sourceware.org (Postfix) with ESMTPS id 9A2AC38582A2 for ; Mon, 4 Jul 2022 18:23:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9A2AC38582A2 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tuxteam.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tuxteam.de DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=From:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=BzE/7/tp/fCi60DVMuklYOSCpPvp3/KY7k7oJlTdiVY=; b=PccMxLtbleGFnCSRDBg1wWbfg6 3CuKozCtfXw4miyzWvrTeLPJyVcLw8wqQ1F//cVFoO5k4s/28jwG32usa/UeNpWky9W9XrjoKEMww 665mlGnGJxTuT5qWYQt6aeF4qURw390Sucg+6JTSndfzjUa9XXNpwAyuBXu9hrSgbKQEyaiwNty6B nhdysNmeiUyzoy+yQvNg7YiUffjW2tbLIYtTj5o+BiYd7VqDKyFvSTy1zH7BiPCLblCVmA0xo4bUP ErgwYDdmmi+6sWbSrn3gmGx7SfnvNa2wl/2YNkFntOt5ogQoH0CV/8spgI4uQpEPNp083Zg4eyE9+ ZLfVdFDw==; Received: from tomas by mail.tuxteam.de with local (Exim 4.94.2) (envelope-from ) id 1o8Qjg-0004W2-R6; Mon, 04 Jul 2022 20:23:52 +0200 Date: Mon, 4 Jul 2022 20:23:52 +0200 To: Ian Pilcher Cc: libc-help@sourceware.org Subject: Re: inet_net_pton() alternative for IPv6 Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="sz5+Xd7ygXX8mCyj" Content-Disposition: inline In-Reply-To: From: X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-help@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-help mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2022 18:23:56 -0000 --sz5+Xd7ygXX8mCyj Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jul 04, 2022 at 01:07:59PM -0500, Ian Pilcher via Libc-help wrote: > I am searching for the best way to parse both IPv4 and IPv6 CIDR- > formatted addresses. I have found inet_net_pton(), but it only supports > IPv4 (AF_INET) addresses. I never tried it, but this is what my version [1] of the libc docs say: -- Function: int inet_pton (int AF, const char *CP, void *BUF) Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX Safety Concepts::. This function converts an Internet address (either IPv4 or IPv6) from presentation (textual) to network (binary) format. AF should be either =E2=80=98AF_INET=E2=80=99 or =E2=80=98AF_INET6=E2=80=99, as = appropriate for the type of address being converted. CP is a pointer to the input string, and BUF is a pointer to a buffer for the result. It is the caller=E2=80= =99s responsibility to make sure the buffer is large enough. -- Function: const char * inet_ntop (int AF, const void *CP, char *BUF, socklen_t LEN) Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX Safety Concepts::. This function converts an Internet address (either IPv4 or IPv6) from network (binary) to presentation (textual) form. AF should be either =E2=80=98AF_INET=E2=80=99 or =E2=80=98AF_INET6=E2=80=99, as app= ropriate. CP is a pointer to the address to be converted. BUF should be a pointer to a buffer to hold the result, and LEN is the length of this buffer. The return value from the function will be this buffer address. so they seem to cover your needs? > Needless to say, this is pretty disappointing in 2022. Is there an > alternative API that I should be using, or am I stuck writing my own? C'm on. Be nice :) Cheers [1] This is =E2=80=98The GNU C Library Reference Manual=E2=80=99, for Versi= on (Debian glibc-doc-reference 2.31-1) of the GNU C Library. --=20 t --sz5+Xd7ygXX8mCyj Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCYsMwMgAKCRAFyCz1etHa RjNAAJ44CpJHkWoMYt/KT9O3eDgnEh4C6QCeNVYuLcmwIQXBNWr+S2svxLSFbJU= =DmFc -----END PGP SIGNATURE----- --sz5+Xd7ygXX8mCyj--