On Dec 8, 2008, at Dec 8, 2008, 2:26 PM, Steve Dickson wrote:
Steinar H. Gunderson wrote:
On Mon, Dec 08, 2008 at 08:46:36AM -0500, Steve Dickson wrote:
typedef struct {
char **hostname;
struct sockaddr_in saddr;
struct pmap pmap;
} clnt_addr_t;
Why isn't saddr a struct sockaddr instead of a struct sockaddr_in?
It seems at the beginning of each routine saddr is always being
typecast into a struct sockaddr pointer.... So wouldn't be easier
and cleaner to simply make sadd a struct sockaddr or am I missing
something?
I'm sure most people here know this, but still, be careful: If you
ever
intend to store an IPv6 address somewhere, the field in the struct
should be
a sockaddr_storage. sockaddr (or sockaddr_in, for that matter) is
not big
enough to store a sockaddr_in6.
Understood... But isn't a struct sockaddr large enough to store
a IPv6 address?
No, they aren't: IPv6 addresses are larger than sockaddr_in's.
sockaddr's happen to be the same size as sockaddr_in's. I think this
is defined by POSIX, but I could be incorrect.
Its no biggie... but what caught my eye was usually
struct sockaddr are typecast into sockaddr_in, not the other away
around.
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html