tcpdump mailing list archives
Re: about struct in_addr
From: Guy Harris <guy () alum mit edu>
Date: Fri, 05 May 2006 23:37:31 -0700
Lan Qing wrote:
hello, I read the fllowing words in the c header file <netinet/in.h>
I.e., the header that came with your OS, not the header that comes with tcpdump?
/* Internet address. */ typedef uint32_t in_addr_t; struct in_addr { in_addr_t s_addr; };" the struct in_addr have only one variable in it, is there any necessary to define a struct like that? why not use "typedef in_addr_t in_addr;" directly?
In BSD, it was originally a union that also included arrays of bytes so that code could look at the bytes, for dealing with class A, B, and C Internet addresses - as the comment in OS X, and other BSDs, says, it's "a structure for historical reasons", because code depended on there being an "s_addr" member (which was one of the members of the union).
- This is the tcpdump-workers list. Visit https://lists.sandelman.ca/ to unsubscribe.
Current thread:
- about struct in_addr Lan Qing (May 05)
- Re: about struct in_addr Hannes Gredler (May 06)
- Re: about struct in_addr Guy Harris (May 06)
- Re: about struct in_addr Sebastien Raveau (May 06)
- Re: about struct in_addr Lan Qing (May 08)