Mail Archives: cygwin/2009/03/27/00:16:55
--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 -