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

xoraddr(struct sockaddr_in6 *sin) {
	register u_long accu = 0;
	register int i;

	for(i = 0; i < sizeof(struct in6_addr); i++)
		accu ^= ((u_char *)&sin->sin6_addr)[i];
	return(accu);
}

main() {
	register char *cp;
	char buf[256];
	struct sockaddr_in6 s;
#define addr &s.sin6_addr
	int n;

	for (;;) {
		printf("> ");
		fflush(stdout);
		if ((cp = (char *)gets(buf)) == NULL)
			break;

		if ((n = inet_pton(AF_INET6, cp, addr)) <= 0) {
			printf("inet_pton failed\n");
			continue;
		}
		printf("\n");
		
		printf("%s -> %02x\n",
		       inet_ntop(AF_INET6, addr, buf, sizeof(buf)),
		       xoraddr(&s));
	}		
}
