Re: ipv6


Arkadiusz Mi¶kiewicz (misiek@misiek.eu.org)
Fri, 20 Aug 1999 12:17:55 +0200


On Wed, 18 Aug 1999, Arkadiusz Mi¶kiewicz wrote:

> And one more thing ... we don't bind to local address in get_rfc1413_data().
> What for was that binding ???
Oki, I know what for is it :)

this time small fix for get_rfc1413_data() in my IPv6 patch....
1) we are using 'ip_address' instead 'remote_addr'
2) we are bind()ing to 'local_addr'
3) added mising alarm(), snprintf() when connect() fail in get_rfc1413_data()

I tested this with my pidentd-3.1a14 (IPv6 ready)
- it works :-)

ps. full ipv6 patch is at
http://www.misiek.eu.org/ipv6/cfingerd-1.4.0-ipv6-190899.patch.gz

-- 
   arkadiusz mi¶kiewicz        [misiek@misiek.eu.org]
PLD/Linux with IPv6 support   http://www.misiek.eu.org/
http://www.ipv6.pld.org.pl/    http://www.pld.org.pl/

Index: rfc1413.c =================================================================== RCS file: /CVSROOT/cfingerd/src/rfc1413.c,v retrieving revision 1.8 retrieving revision 1.17 diff -u -r1.8 -r1.17 --- rfc1413.c 1999/08/18 10:26:19 1.8 +++ rfc1413.c 1999/08/19 12:29:25 1.17 @@ -38,13 +38,9 @@ memset(bleah, 0, BUFLEN); memset(&hints, 0, sizeof(hints)); - /* If IPv4-mapped IPv6 address use AF_INET family */ - if ((local_addr.__ss_family == AF_INET6) && IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)&local_addr)->sin6_addr)) - hints.ai_family = AF_INET; - else - hints.ai_family = local_addr.__ss_family; + hints.ai_family = local_addr.__ss_family; hints.ai_socktype = SOCK_STREAM; - if((err = getaddrinfo(remote_addr, "113", &hints, &res0)) < 0) { + if((err = getaddrinfo(ip_address, "113", &hints, &res0)) < 0) { syslog(LOG_ERR, "rfc1413-getaddrinfo: %s", gai_strerror(err)); snprintf(bleah, BUFLEN, "unknown@%s", remote_addr); alarm(0); @@ -56,6 +52,15 @@ for (res = res0; res; res = res->ai_next) { if ((j = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0) continue; + switch(local_addr.__ss_family) { + case AF_INET: + ((struct sockaddr_in *)&local_addr)->sin_port = 0; + break; + case AF_INET6: + ((struct sockaddr_in6 *)&local_addr)->sin6_port = 0; + break; + } + bind(j, (struct sockaddr *)&local_addr, SA_LEN((struct sockaddr *)&local_addr)); if (connect(j, res->ai_addr, res->ai_addrlen) < 0) close(j); else { @@ -64,6 +69,12 @@ } } freeaddrinfo(res0); + if (errcon < 0) { + syslog(LOG_ERR, "rfc1413-socket-or-connect problem"); + snprintf(bleah, BUFLEN, "unknown@%s", remote_addr); + alarm(0); + return(bleah); + } snprintf(buffer, sizeof(buffer), "%d,%d\n", remote_port, local_port); write(j, buffer, strlen(buffer));

--82I3+IH0IqGh5yIs--



This archive was generated by hypermail 2.0b3 on Fri Aug 20 1999 - 12:25:05 CEST