delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/03/27/00:16:55

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_43,SPF_HELO_PASS,SPF_SOFTFAIL
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
Message-ID: <18892.24881.513832.816162@amman.clic.cs.columbia.edu>
Date: Fri, 27 Mar 2009 01:16:33 -0400
To: cygwin AT cygwin DOT com
Subject: [1.7] cygwin inet_ntop prints IPv6 addresses in upper-case.
From: lennox AT cs DOT columbia DOT edu
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

--yZ0oXOXqxO
Content-Type: text/plain; charset=us-ascii
Content-Description: message body and .signature
Content-Transfer-Encoding: 7bit

This is fairly superficial, but I noticed that cygwin 1.7's inet_ntop
function prints hex bytes in IPv6 addresses in upper-case.

This is inconsistent with what inet_ntop does on every other platform I've
tested, and a recent Internet-Draft
<http://www.ietf.org/internet-drafts/draft-kawamura-ipv6-text-representation-00.txt>
also recommends printing IPv6 addresses in lower-case, among other reasons
because upper-case "D" is harder to distinguish visually from "0".

It looks like _small_sprintf in winsup/cygwin/smallprint.c doesn't have any
code to print lower-case hex, though.

Cygwin:

$ ~/inet-ntop-test.exe 2002:8281:52fc:5:34cb:4e60:950b:82b5
2002:8281:52fc:5:34cb:4e60:950b:82b5 -> 2002:8281:52FC:5:34CB:4E60:950B:82B5

Linux:

$ ./inet-ntop-test 2002:8281:52fc:5:34cb:4e60:950b:82b5
2002:8281:52fc:5:34cb:4e60:950b:82b5 -> 2002:8281:52fc:5:34cb:4e60:950b:82b5

-- 
Jonathan Lennox
lennox at cs dot columbia dot edu


--yZ0oXOXqxO
Content-Type: text/plain
Content-Disposition: inline;
	filename="inet-ntop-test.c"
Content-Transfer-Encoding: 7bit

#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>

#include <string.h>
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
	int i;

	for (i = 1; i < argc; i++) {
		struct sockaddr_in6 sin6;
		char pres_buf[INET6_ADDRSTRLEN];

		memset(&sin6, 0, sizeof(sin6));
		sin6.sin6_family = AF_INET6;

		if (inet_pton(AF_INET6, argv[i], &sin6.sin6_addr) != 1) {
			fprintf(stderr, "%s: did not parse as AF_INET6\n", argv[i]);
			continue;
		}

		if (inet_ntop(AF_INET6, &sin6.sin6_addr, pres_buf, sizeof(pres_buf)) == NULL) {
			fprintf(stderr, "%s: could not encode as AF_INET6\n", argv[i]);
			continue;
		}

		printf("%s -> %s\n", argv[i], pres_buf);
	}

	exit(0);
}


--yZ0oXOXqxO
Content-Type: text/plain; charset=us-ascii

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/
--yZ0oXOXqxO--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019