0

Code

I was trying to implement this code:

void findNameServers(domain, nsList, nsNum)
char *domain;
char *nsList[];
int  *nsNum;
{
    union {
        HEADER hdr;              /* defined in resolv.h */
        u_char buf[NS_PACKETSZ]; /* defined in arpa/nameser.h */
    } response;                  /* response buffers */
    int responseLen;             /* buffer length */

Issue

It seems that 'HEADER' is not defined in resolv.h header file because I am getting this error:

error: unknown type name 'HEADER'
        HEADER hdr;              /* defined in resolv.h */

Are there any older versions of this header file?

Community
  • 1
  • 1
rlorez
  • 9
  • 2
  • 1
    You must have exceptional reasons to be writing a K&R-style function. Use prototype notation only in new code. – Jonathan Leffler Oct 24 '19 at 10:28
  • 2
    What is `HEADER`? Where is it supposed to be defined? Why do you think it should be defined in the `resolv.h` header file? – Some programmer dude Oct 24 '19 at 10:30
  • I was running this program to retrieve SOA records from server http://web.mit.edu/~mkgray/afs/bar/afs/net/project/bind/8.4.4/contrib/nutshell/ch14.check_soa.v8.c It seems to be the only error I am getting. I tried looking up this on some other files but to no avail. – rlorez Oct 24 '19 at 10:56
  • Can you supply the a minimal self-container code sample which demonstrates your problem? resolv.h does not contain definition to 'HEADER' type. – Eliyahu Machluf Oct 24 '19 at 11:12
  • The example you link to include many header files, what makes you think that `HEADER` is define in just `resolv.h` and not in any of the others? – Some programmer dude Oct 24 '19 at 11:22

1 Answers1

0

HEADER type is defined at arpa/nameser_compat.h

try adding the following include to your program

#include <arpa/nameser_compat.h>
Eliyahu Machluf
  • 1,251
  • 8
  • 17