diff options
author | Benny Prijono <bennylp@teluu.com> | 2009-10-15 03:48:20 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2009-10-15 03:48:20 +0000 |
commit | 02dba30b6c6c5b420d25f629024736ebbca0755f (patch) | |
tree | 7ff3dc91b804d0fbf951972b174b58f5a0d269bb /pjlib | |
parent | 4533e1452749d9c4060d63971eabc7a6baeb9e1e (diff) |
Ticket #972: setsockopt compatibility problems on Windows (thanks Yann and John Ridges for the reports)
- set PJ_SOL_IP, PJ_SOL_TCP, and PJ_SOL_UDP to IPPROTO_IP, IPPROTO_TCP, and IPPROTO_UDP respectively on Windows
- also added PJ_TCP_NODELAY and PJ_SO_REUSEADDR
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2946 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib')
-rw-r--r-- | pjlib/include/pj/sock.h | 19 | ||||
-rw-r--r-- | pjlib/src/pj/sock_bsd.c | 18 | ||||
-rw-r--r-- | pjlib/src/pj/sock_common.c | 10 | ||||
-rw-r--r-- | pjlib/src/pj/sock_symbian.cpp | 6 | ||||
-rw-r--r-- | pjlib/src/pjlib-test/sock.c | 16 |
5 files changed, 66 insertions, 3 deletions
diff --git a/pjlib/include/pj/sock.h b/pjlib/include/pj/sock.h index ecc23691..a72b63e3 100644 --- a/pjlib/include/pj/sock.h +++ b/pjlib/include/pj/sock.h @@ -290,6 +290,13 @@ extern const pj_uint16_t PJ_SO_RCVBUF; /** Buffer size for send. @see pj_SO_SNDBUF() */ extern const pj_uint16_t PJ_SO_SNDBUF; +/** Disables the Nagle algorithm for send coalescing. @see pj_TCP_NODELAY */ +extern const pj_uint16_t PJ_TCP_NODELAY; + +/** Allows the socket to be bound to an address that is already in use. + * @see pj_SO_REUSEADDR */ +extern const pj_uint16_t PJ_SO_REUSEADDR; + /** IP multicast interface. @see pj_IP_MULTICAST_IF() */ extern const pj_uint16_t PJ_IP_MULTICAST_IF; @@ -316,6 +323,12 @@ extern const pj_uint16_t PJ_IP_DROP_MEMBERSHIP; /** Get #PJ_SO_SNDBUF constant */ PJ_DECL(pj_uint16_t) pj_SO_SNDBUF(void); + /** Get #PJ_TCP_NODELAY constant */ + PJ_DECL(pj_uint16_t) pj_TCP_NODELAY(void); + + /** Get #PJ_SO_REUSEADDR constant */ + PJ_DECL(pj_uint16_t) pj_SO_REUSEADDR(void); + /** Get #PJ_IP_MULTICAST_IF constant */ PJ_DECL(pj_uint16_t) pj_IP_MULTICAST_IF(void); @@ -340,6 +353,12 @@ extern const pj_uint16_t PJ_IP_DROP_MEMBERSHIP; /** Get #PJ_SO_SNDBUF constant */ # define pj_SO_SNDBUF() PJ_SO_SNDBUF + /** Get #PJ_TCP_NODELAY constant */ +# define pj_TCP_NODELAY() PJ_TCP_NODELAY + + /** Get #PJ_SO_REUSEADDR constant */ +# define pj_SO_REUSEADDR() PJ_SO_REUSEADDR + /** Get #PJ_IP_MULTICAST_IF constant */ # define pj_IP_MULTICAST_IF() PJ_IP_MULTICAST_IF diff --git a/pjlib/src/pj/sock_bsd.c b/pjlib/src/pj/sock_bsd.c index b5a30fad..eabd2bb2 100644 --- a/pjlib/src/pj/sock_bsd.c +++ b/pjlib/src/pj/sock_bsd.c @@ -60,26 +60,37 @@ const pj_uint16_t PJ_SOCK_RDM = SOCK_RDM; const pj_uint16_t PJ_SOL_SOCKET = SOL_SOCKET; #ifdef SOL_IP const pj_uint16_t PJ_SOL_IP = SOL_IP; +#elif defined(PJ_WIN32) && PJ_WIN32 +const pj_uint16_t PJ_SOL_IP = IPPROTO_IP; #else const pj_uint16_t PJ_SOL_IP = 0xFFFF; #endif /* SOL_IP */ + #if defined(SOL_TCP) const pj_uint16_t PJ_SOL_TCP = SOL_TCP; #elif defined(IPPROTO_TCP) const pj_uint16_t PJ_SOL_TCP = IPPROTO_TCP; +#elif defined(PJ_WIN32) && PJ_WIN32 +const pj_uint16_t PJ_SOL_TCP = IPPROTO_TCP; #else const pj_uint16_t PJ_SOL_TCP = 0xFFFF; #endif /* SOL_TCP */ + #ifdef SOL_UDP const pj_uint16_t PJ_SOL_UDP = SOL_UDP; +#elif defined(PJ_WIN32) && PJ_WIN32 +const pj_uint16_t PJ_SOL_UDP = IPPROTO_UDP; #else const pj_uint16_t PJ_SOL_UDP = 0xFFFF; -#endif +#endif /* SOL_UDP */ + #ifdef SOL_IPV6 const pj_uint16_t PJ_SOL_IPV6 = SOL_IPV6; +#elif defined(PJ_WIN32) && PJ_WIN32 +const pj_uint16_t PJ_SOL_IPV6 = IPPROTO_IPV6; #else const pj_uint16_t PJ_SOL_IPV6 = 0xFFFF; -#endif +#endif /* SOL_IPV6 */ /* IP_TOS */ #ifdef IP_TOS @@ -116,6 +127,9 @@ const pj_uint16_t PJ_IPTOS_MINCOST = 0x02; const pj_uint16_t PJ_SO_TYPE = SO_TYPE; const pj_uint16_t PJ_SO_RCVBUF = SO_RCVBUF; const pj_uint16_t PJ_SO_SNDBUF = SO_SNDBUF; +const pj_uint16_t PJ_TCP_NODELAY= TCP_NODELAY; +const pj_uint16_t PJ_SO_REUSEADDR= SO_REUSEADDR; + /* Multicasting is not supported e.g. in PocketPC 2003 SDK */ #ifdef IP_MULTICAST_IF const pj_uint16_t PJ_IP_MULTICAST_IF = IP_MULTICAST_IF; diff --git a/pjlib/src/pj/sock_common.c b/pjlib/src/pj/sock_common.c index 48435196..0e098c48 100644 --- a/pjlib/src/pj/sock_common.c +++ b/pjlib/src/pj/sock_common.c @@ -1062,6 +1062,16 @@ PJ_DEF(pj_uint16_t) pj_SO_SNDBUF(void) return PJ_SO_SNDBUF; } +PJ_DEF(pj_uint16_t) pj_TCP_NODELAY(void) +{ + return PJ_TCP_NODELAY; +} + +PJ_DEF(pj_uint16_t) pj_SO_REUSEADDR(void) +{ + return PJ_SO_REUSEADDR; +} + PJ_DEF(pj_uint16_t) pj_IP_MULTICAST_IF(void) { return PJ_IP_MULTICAST_IF; diff --git a/pjlib/src/pj/sock_symbian.cpp b/pjlib/src/pj/sock_symbian.cpp index 60621724..138ee867 100644 --- a/pjlib/src/pj/sock_symbian.cpp +++ b/pjlib/src/pj/sock_symbian.cpp @@ -47,7 +47,7 @@ const pj_uint16_t PJ_SOCK_DGRAM = KSockDatagram; const pj_uint16_t PJ_SOCK_RAW = 0xFFFF; const pj_uint16_t PJ_SOCK_RDM = 0xFFFF; -/* setsockop() is not really supported. */ +/* we don't support setsockopt(), these are just dummy values */ const pj_uint16_t PJ_SOL_SOCKET = 0xFFFF; const pj_uint16_t PJ_SOL_IP = 0xFFFF; const pj_uint16_t PJ_SOL_TCP = 0xFFFF; @@ -61,6 +61,10 @@ const pj_uint16_t PJ_IPTOS_THROUGHPUT = 0; const pj_uint16_t PJ_IPTOS_RELIABILITY = 0; const pj_uint16_t PJ_IPTOS_MINCOST = 0; +/* Misc */ +const pj_uint16_t PJ_TCP_NODELAY = 0xFFFF; +const pj_uint16_t PJ_SO_REUSEADDR = 0xFFFF; + /* ioctl() is also not supported. */ const pj_uint16_t PJ_SO_TYPE = 0xFFFF; const pj_uint16_t PJ_SO_RCVBUF = 0xFFFF; diff --git a/pjlib/src/pjlib-test/sock.c b/pjlib/src/pjlib-test/sock.c index ec911177..e6060715 100644 --- a/pjlib/src/pjlib-test/sock.c +++ b/pjlib/src/pjlib-test/sock.c @@ -167,6 +167,22 @@ static int format_test(void) /* pj_gethostaddr() */ + /* Various constants */ +#if !defined(PJ_SYMBIAN) || PJ_SYMBIAN==0 + if (PJ_SOL_IP==0xFFFF) return -5500; + if (PJ_SOL_TCP==0xFFFF) return -5510; + if (PJ_SOL_UDP==0xFFFF) return -5520; + if (PJ_SOL_IPV6==0xFFFF) return -5530; + + if (PJ_SO_TYPE==0xFFFF) return -5540; + if (PJ_SO_RCVBUF==0xFFFF) return -5550; + if (PJ_SO_SNDBUF==0xFFFF) return -5560; + if (PJ_TCP_NODELAY==0xFFFF) return -5570; + if (PJ_SO_REUSEADDR==0xFFFF) return -5580; + + if (PJ_MSG_OOB==0xFFFF) return -5590; + if (PJ_MSG_PEEK==0xFFFF) return -5600; +#endif return 0; } |