fun with sockaddr...
Andreas Bauer
baueran at in.tum.de
Sun Sep 15 09:05:45 EST 2002
> For example:
> h1[0] = h2[0] = '\0';
> if (getnameinfo((struct sockaddr *)&ss[0],
> ((struct sockaddr *)&ss[0])->sa_len, h1, sizeof(h1),
> p, sizeof(p), niflag) != 0)
> return 0;
>
> As far as I can tell, sockaddr doesn't have a sa_len element (and the compiler
> agrees). The man page for getnameinfo() doesn't help me much - it also uses
> the sa_len approach.
I used this stuff a bit in Mailfilter and I believe sa_len returned the
size of the sockaddr_xyz struct. Glibc used to have a macro called
SA_LEN(sa), but that's gone now, as far as I can tell. So, you can
define your own along the lines of
#ifndef SA_LEN
#define SA_LEN(sa) sizeof(struct sockaddr_xyz)
#endif
You get the idea, I hope.
Andi.
--
(o_ Andreas Bauer, baueran at in.tum.de, http://home.in.tum.de/baueran/
//\ "Should've bought a Holden, Frank!" -- Ozzie in Bad Taste
V_/_
More information about the linux
mailing list