diff options
author | Benny Prijono <bennylp@teluu.com> | 2007-12-01 08:52:57 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2007-12-01 08:52:57 +0000 |
commit | 2e6a62f43b622320d69971cfc07a68ab59e29f1b (patch) | |
tree | e123dbdeb138f64618e9c5bba112798becec5547 /pjlib/include/pj/compat | |
parent | 4ee49ed9e7fda6b2150c400cbe5a10dda99867db (diff) |
More ticket #415: more IPv6 and some reorganization of the source codes
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1601 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/include/pj/compat')
-rw-r--r-- | pjlib/include/pj/compat/socket.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/pjlib/include/pj/compat/socket.h b/pjlib/include/pj/compat/socket.h index f44a623c..989cda5d 100644 --- a/pjlib/include/pj/compat/socket.h +++ b/pjlib/include/pj/compat/socket.h @@ -185,6 +185,28 @@ typedef int socklen_t; #endif +/* Regarding sin_len member of sockaddr_in: + * BSD systems (including MacOS X requires that the sin_len member of + * sockaddr_in be set to sizeof(sockaddr_in), while other systems (Windows + * and Linux included) do not. + * + * To maintain compatibility between systems, PJLIB will automatically + * set this field before invoking native OS socket API, and it will + * always reset the field to zero before returning pj_sockaddr_in to + * application (such as in pj_getsockname() and pj_recvfrom()). + * + * Application MUST always set this field to zero. + * + * This way we can avoid hard to find problem such as when the socket + * address is used as hash table key. + */ +#if defined(PJ_SOCKADDR_HAS_LEN) && PJ_SOCKADDR_HAS_LEN!=0 +# define PJ_SOCKADDR_SET_LEN(addr,len) (((pj_addr_hdr*)(addr))->sa_zero_len=(len)) +# define PJ_SOCKADDR_RESET_LEN(addr) (((pj_addr_hdr*)(addr))->sa_zero_len=0) +#else +# define PJ_SOCKADDR_SET_LEN(addr,len) +# define PJ_SOCKADDR_RESET_LEN(addr) +#endif #endif /* __PJ_COMPAT_SOCKET_H__ */ |