[PATCH] ipv6 support for getaddrinfo.c

Started by R, Rajesh (STSD)almost 20 years ago2 messages
#1R, Rajesh (STSD)
rajesh.r2@hp.com
1 attachment(s)

Patch for getaddrinfo.c to recognize ipv6 addresses.
Used inet_pton to achieve that.

On machines that don't have getaddrinfo function, Client authenciation
fails
for ipv6 addresses if pgsql uses getaddrinfo implemented in this.

This is a fix for that.

Rajesh R
--
This space intentionally left non-blank.

Attachments:

ipv6-getaddrinfo.patchapplication/octet-stream; name=ipv6-getaddrinfo.patchDownload
$ diff -r getaddrinfo.c getaddrinfo.new.c
34c34
<  * get address info for ipv4 sockets.
---
>  * get address info for ipv4/v6 sockets.
50c50,52
<
---
>     char hap[16];
>       struct sockaddr_in6 *psin6;
>     int isipv6 = 0;
79,80c81,89
<                       if (!inet_aton(node, &sin.sin_addr))
<                               return EAI_FAIL;
---
>                       if (!inet_aton(node, &sin.sin_addr)){
>                          if(inet_pton(AF_INET6,node,hap)){
>                                  isipv6 = 1;
>                                  psin6->sin6_family = AF_INET6;
>                                  memcpy(&psin6->sin6_addr,hap,16);
>                          }
>                          else
>                                  return EAI_FAIL;
>                       }
124c133
<       if (service)
---
>       if (service){
126c135,137
<
---
>         if(isipv6)
>             psin6->sin6_port= sin.sin_port;
>       }
145c156
<       ai->ai_family = AF_INET;
---
>
147a159,160
>       if(!isipv6){
>       ai->ai_family = AF_INET;
150c163,169
<       ai->ai_canonname = NULL;
---
>       }
>       else{
>       ai->ai_family = AF_INET6;
>       ai->ai_addrlen = sizeof(*psin6);
>       ai->ai_addr = (struct sockaddr_in6 *) psin6;
>     }
>     ai->ai_canonname = NULL;
157d175
<
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: R, Rajesh (STSD) (#1)
Re: [PATCH] ipv6 support for getaddrinfo.c

"R, Rajesh (STSD)" <rajesh.r2@hp.com> writes:

Patch for getaddrinfo.c to recognize ipv6 addresses.

Is this really interesting? Are there machines out there that have
usable support for IPv6 and yet haven't got getaddrinfo?

We've deliberately avoided trying to support ipv6 in our src/port/
substitute routines, on the grounds that this scenario wasn't important
in the real world. I'd just as soon not add this unless really
necessary.

The patch as written is quite unusable anyway, as (a) it's not -c
format, (b) it appears not to be against any version close to CVS HEAD,
(c) it breaks the code entirely on machines without struct sockaddr_in6
or inet_pton (which begs the question even more about scope of
applicability).

Also please note that proposed patches go to pgsql-patches --- they are
certainly far off-topic for pgsql-general.

regards, tom lane