<resolv.h> requires <netinet/in.h>

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

<resolv.h> requires <netinet/in.h>

Yaakov (Cygwin/X)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

This affects both minires-1.02 and Cygwin 1.7.0-34.  STC based on a
configure test:

$ cat > test-resolv.c <<EOF
#include <resolv.h>

int
main (void) {
    return res_ninit (&_res);
}
EOF

$ gcc -Wall -o test-resolv.exe test-resolv.c
In file included from test-resolv.c:1:
/usr/include/resolv.h:162: error: field `nsaddr_list' has incomplete type
/usr/include/resolv.h:172: error: field `addr' has incomplete type
/usr/include/resolv.h:195: error: field `sin' has incomplete type

The missing typedef is sockaddr_in.  Patch attached.


Yaakov
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEAREIAAYFAkk9o3AACgkQpiWmPGlmQSNjeACg3/FBU9KSNBTigpifYBq4YX3Y
zAMAn2yGnzZryM0g1Qbz0AKq4NnOFjQZ
=NM7d
-----END PGP SIGNATURE-----

2008-Dec-08  Yaakov Selkowitz  <[hidden email]>

        * resolv.h: #include <netinet/in.h> for sockaddr_in typedef.


Index: resolv.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/include/resolv.h,v
retrieving revision 1.2
diff -u -r1.2 resolv.h
--- resolv.h 17 Jun 2008 10:05:28 -0000 1.2
+++ resolv.h 8 Dec 2008 22:42:27 -0000
@@ -66,6 +66,7 @@
 #include <sys/socket.h>
 #include <stdio.h>
 #include <arpa/nameser.h>
+#include <netinet/in.h>
 
 /*
  * Revision information.  This is the release date in YYYYMMDD format.
Reply | Threaded
Open this post in threaded view
|

Re: <resolv.h> requires <netinet/in.h>

Pierre A. Humblet-2

----- Original Message -----
From: "Yaakov (Cygwin/X)"
To: <cygwin-patches>
Sent: Monday, December 08, 2008 5:45 PM
Subject: <resolv.h> requires <netinet/in.h>


| -----BEGIN PGP SIGNED MESSAGE-----
| Hash: SHA256
|
| This affects both minires-1.02 and Cygwin 1.7.0-34.  STC based on a
| configure test:

**************

This is far from the 1st time that this issue comes up.
resolv.h is completely standard, it comes from a bind distribution.

Every version of man resolver that I have ever seen specifies:

SYNOPSIS
     #include <sys/types.h>
     #include <netinet/in.h>
     #include <arpa/nameser.h>
     #include <resolv.h>

So it's up to the user to include the right files.
Sure we can make an exception for Cygwin, but the same program can then fail elsewhere.

Pierre

Reply | Threaded
Open this post in threaded view
|

Re: <resolv.h> requires <netinet/in.h>

Yaakov (Cygwin/X)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Pierre A. Humblet wrote:
> Every version of man resolver that I have ever seen specifies:
>
> SYNOPSIS
>      #include <sys/types.h>
>      #include <netinet/in.h>
>      #include <arpa/nameser.h>
>      #include <resolv.h>
>
> So it's up to the user to include the right files.

Perhaps so, but:

1) <resolv.h> already #includes all of those headers *except* for
<netinet/in.h>.

2) this does not match Linux behaviour:

http://sourceware.org/cgi-bin/cvsweb.cgi/libc/resolv/resolv.h?cvsroot=glibc

As I stated, my STC was based on a configure test which works on other
platforms; I don't see why we shouldn't match that.

> Sure we can make an exception for Cygwin, but the same program can then fail elsewhere.

I agree that for portability, a program should not assume that #include
<resolv.h> automatically #include <netinet/in.h> and use the latter's
functions or typedefs.  But the bottom line here is that <resolv.h>
requires struct sockaddr_in, so it needs that #include.


Yaakov
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEAREIAAYFAkk9s0YACgkQpiWmPGlmQSMO/ACg1fIAqsvbkNC3CF3XnM/hQmBD
emwAn3jFN6zrj55wieyYvNawpI/HOkD4
=uV4z
-----END PGP SIGNATURE-----
Reply | Threaded
Open this post in threaded view
|

Re: <resolv.h> requires <netinet/in.h>

Corinna Vinschen-2
On Dec  8 17:52, Yaakov (Cygwin/X) wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Pierre A. Humblet wrote:
> > Every version of man resolver that I have ever seen specifies:
> >
> > SYNOPSIS
> >      #include <sys/types.h>
> >      #include <netinet/in.h>
> >      #include <arpa/nameser.h>
> >      #include <resolv.h>
> >
> > So it's up to the user to include the right files.
>
> Perhaps so, but:
>
> 1) <resolv.h> already #includes all of those headers *except* for
> <netinet/in.h>.
>
> 2) this does not match Linux behaviour:
>
> http://sourceware.org/cgi-bin/cvsweb.cgi/libc/resolv/resolv.h?cvsroot=glibc
>
> As I stated, my STC was based on a configure test which works on other
> platforms; I don't see why we shouldn't match that.
>
> > Sure we can make an exception for Cygwin, but the same program can then fail elsewhere.
>
> I agree that for portability, a program should not assume that #include
> <resolv.h> automatically #include <netinet/in.h> and use the latter's
> functions or typedefs.  But the bottom line here is that <resolv.h>
> requires struct sockaddr_in, so it needs that #include.

Good point.  Pierre?


Corinna

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat
Reply | Threaded
Open this post in threaded view
|

Re: <resolv.h> requires <netinet/in.h>

Pierre A. Humblet-2

----- Original Message -----
From: "Corinna Vinschen" <[hidden email]>
To: <[hidden email]>
Sent: Tuesday, December 09, 2008 4:23 AM
Subject: Re: <resolv.h> requires <netinet/in.h>


| On Dec  8 17:52, Yaakov (Cygwin/X) wrote:
| > -----BEGIN PGP SIGNED MESSAGE-----
| > Hash: SHA256
| >
| > Pierre A. Humblet wrote:
| > > Every version of man resolver that I have ever seen specifies:
| > >
| > > SYNOPSIS
| > >      #include <sys/types.h>
| > >      #include <netinet/in.h>
| > >      #include <arpa/nameser.h>
| > >      #include <resolv.h>
| > >
| > > So it's up to the user to include the right files.
| >
| > Perhaps so, but:
| >
| > 1) <resolv.h> already #includes all of those headers *except* for
| > <netinet/in.h>.
| >
| > 2) this does not match Linux behaviour:
| >
| > http://sourceware.org/cgi-bin/cvsweb.cgi/libc/resolv/resolv.h?cvsroot=glibc
| >
| > As I stated, my STC was based on a configure test which works on other
| > platforms; I don't see why we shouldn't match that.
| >
| > > Sure we can make an exception for Cygwin, but the same program can then fail elsewhere.
| >
| > I agree that for portability, a program should not assume that #include
| > <resolv.h> automatically #include <netinet/in.h> and use the latter's
| > functions or typedefs.  But the bottom line here is that <resolv.h>
| > requires struct sockaddr_in, so it needs that #include.
|
| Good point.  Pierre?

I don't know why the original resolv.h didn't include netinet/in.h and
I have no problem adding it in Cygwin, given it was added in Linux.
The minires package is nearing its life end, so I would make the change
starting with the built-in resolver.

Pierre
 
Reply | Threaded
Open this post in threaded view
|

Re: <resolv.h> requires <netinet/in.h>

Corinna Vinschen-2
On Dec  9 10:12, Pierre A. Humblet wrote:
> I don't know why the original resolv.h didn't include netinet/in.h and
> I have no problem adding it in Cygwin, given it was added in Linux.
> The minires package is nearing its life end, so I would make the change
> starting with the built-in resolver.

Ok.  I applied Yaakov's patch.


Thanks,
Corinna

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat