From 4c9fbd14de1ea36c638df692c1b1fd235c106d25 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Thu, 1 Feb 2007 00:33:12 +0000 Subject: Implement ticket #83: socket TOS abstraction git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@920 74dad513-b988-da41-8d7b-12977e46ad98 --- aconfigure.ac | 1 + pjlib/include/pj/compat/os_auto.h.in | 1 + pjlib/include/pj/compat/socket.h | 5 +++++ pjlib/include/pj/sock.h | 24 ++++++++++++++++++++++++ pjlib/src/pj/sock_bsd.c | 33 ++++++++++++++++++++++++++++++++- 5 files changed, 63 insertions(+), 1 deletion(-) diff --git a/aconfigure.ac b/aconfigure.ac index 14f2dd34..cfa74921 100644 --- a/aconfigure.ac +++ b/aconfigure.ac @@ -127,6 +127,7 @@ AC_CHECK_HEADER(linux/socket.h,[AC_DEFINE(PJ_HAS_LINUX_SOCKET_H,1)]) AC_CHECK_HEADER(malloc.h,[AC_DEFINE(PJ_HAS_MALLOC_H,1)]) AC_CHECK_HEADER(netdb.h,[AC_DEFINE(PJ_HAS_NETDB_H,1)]) AC_CHECK_HEADER(netinet/in.h,[AC_DEFINE(PJ_HAS_NETINET_IN_H,1)]) +AC_CHECK_HEADER(netinet/ip.h,[AC_DEFINE(PJ_HAS_NETINET_IP_H,1)]) AC_CHECK_HEADER(setjmp.h,[AC_DEFINE(PJ_HAS_SETJMP_H,1)]) AC_CHECK_HEADER(stdarg.h,[AC_DEFINE(PJ_HAS_STDARG_H,1)]) AC_CHECK_HEADER(stddef.h,[AC_DEFINE(PJ_HAS_STDDEF_H,1)]) diff --git a/pjlib/include/pj/compat/os_auto.h.in b/pjlib/include/pj/compat/os_auto.h.in index 51481388..b1292373 100644 --- a/pjlib/include/pj/compat/os_auto.h.in +++ b/pjlib/include/pj/compat/os_auto.h.in @@ -50,6 +50,7 @@ #undef PJ_HAS_MALLOC_H #undef PJ_HAS_NETDB_H #undef PJ_HAS_NETINET_IN_H +#undef PJ_HAS_NETINET_IP_H #undef PJ_HAS_SETJMP_H #undef PJ_HAS_STDARG_H #undef PJ_HAS_STDDEF_H diff --git a/pjlib/include/pj/compat/socket.h b/pjlib/include/pj/compat/socket.h index e95bc125..e64afe8f 100644 --- a/pjlib/include/pj/compat/socket.h +++ b/pjlib/include/pj/compat/socket.h @@ -52,6 +52,11 @@ # include #endif +#if defined(PJ_HAS_NETINET_IP_H) && PJ_HAS_NETINET_IP_H != 0 +/* To pull in IPTOS_* constants */ +# include +#endif + #if defined(PJ_HAS_ARPA_INET_H) && PJ_HAS_ARPA_INET_H != 0 # include #endif diff --git a/pjlib/include/pj/sock.h b/pjlib/include/pj/sock.h index 7321c5de..80d2ab7d 100644 --- a/pjlib/include/pj/sock.h +++ b/pjlib/include/pj/sock.h @@ -93,6 +93,30 @@ extern const pj_uint16_t PJ_SOL_TCP; /**< TCP level. */ extern const pj_uint16_t PJ_SOL_UDP; /**< UDP level. */ extern const pj_uint16_t PJ_SOL_IPV6; /**< IP version 6 */ + +/* IP_TOS + * + * Note: + * TOS CURRENTLY DOES NOT WORK IN Windows 2000 and above! + * See http://support.microsoft.com/kb/248611 + */ +extern const pj_uint16_t PJ_IP_TOS; /**< IP_TOS optname in setsockopt() */ + + +/* + * IP TOS related constats. + * + * Note: + * TOS CURRENTLY DOES NOT WORK IN Windows 2000 and above! + * See http://support.microsoft.com/kb/248611 + */ +extern const pj_uint16_t PJ_IPTOS_LOWDELAY; /**< Minimize delays */ +extern const pj_uint16_t PJ_IPTOS_THROUGHPUT; /**< Optimize throughput */ +extern const pj_uint16_t PJ_IPTOS_RELIABILITY; /**< Optimize for reliability*/ +extern const pj_uint16_t PJ_IPTOS_MINCOST; /**< "filler data" where slow + transmission does't matter */ + + /** * Values to be specified as \c optname when calling #pj_sock_setsockopt() * or #pj_sock_getsockopt(). diff --git a/pjlib/src/pj/sock_bsd.c b/pjlib/src/pj/sock_bsd.c index 61745308..e75ea776 100644 --- a/pjlib/src/pj/sock_bsd.c +++ b/pjlib/src/pj/sock_bsd.c @@ -46,7 +46,7 @@ const pj_uint16_t PJ_AF_IRDA = 0xFFFF; * Socket types conversion. * The values here are indexed based on pj_sock_type */ -const pj_uint16_t PJ_SOCK_STREAM = SOCK_STREAM; +const pj_uint16_t PJ_SOCK_STREAM= SOCK_STREAM; const pj_uint16_t PJ_SOCK_DGRAM = SOCK_DGRAM; const pj_uint16_t PJ_SOCK_RAW = SOCK_RAW; const pj_uint16_t PJ_SOCK_RDM = SOCK_RDM; @@ -76,6 +76,37 @@ const pj_uint16_t PJ_SOL_IPV6 = SOL_IPV6; const pj_uint16_t PJ_SOL_IPV6 = 0xFFFF; #endif +/* IP_TOS */ +#ifdef IP_TOS +const pj_uint16_t PJ_IP_TOS = IP_TOS; +#else +const pj_uint16_t PJ_IP_TOS = 1; +#endif + + +/* TOS settings (declared in netinet/ip.h) */ +#ifdef IPTOS_LOWDELAY +const pj_uint16_t PJ_IPTOS_LOWDELAY = IPTOS_LOWDELAY; +#else +const pj_uint16_t PJ_IPTOS_LOWDELAY = 0x10; +#endif +#ifdef IPTOS_THROUGHPUT +const pj_uint16_t PJ_IPTOS_THROUGHPUT = IPTOS_THROUGHPUT; +#else +const pj_uint16_t PJ_IPTOS_THROUGHPUT = 0x08; +#endif +#ifdef IPTOS_RELIABILITY +const pj_uint16_t PJ_IPTOS_RELIABILITY = IPTOS_RELIABILITY; +#else +const pj_uint16_t PJ_IPTOS_RELIABILITY = 0x04; +#endif +#ifdef IPTOS_MINCOST +const pj_uint16_t PJ_IPTOS_MINCOST = IPTOS_MINCOST; +#else +const pj_uint16_t PJ_IPTOS_MINCOST = 0x02; +#endif + + /* optname values. */ const pj_uint16_t PJ_SO_TYPE = SO_TYPE; const pj_uint16_t PJ_SO_RCVBUF = SO_RCVBUF; -- cgit v1.2.3