- Timestamp:
- Oct 5, 2016 9:07:17 AM (8 years ago)
- Location:
- pjproject/trunk/pjlib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/include/pj/sock.h
r4860 r5444 277 277 278 278 279 /** IPV6_TCLASS optname in setsockopt(). @see pj_IPV6_TCLASS() */ 280 extern const pj_uint16_t PJ_IPV6_TCLASS; 281 282 283 #if defined(PJ_DLL) 284 /** Get #PJ_IPV6_TCLASS constant */ 285 PJ_DECL(int) pj_IPV6_TCLASS(void); 286 #else 287 /** Get #PJ_IPV6_TCLASS constant */ 288 # define pj_IPV6_TCLASS() PJ_IPV6_TCLASS 289 #endif 290 291 279 292 /** 280 293 * Values to be specified as \c optname when calling #pj_sock_setsockopt() -
pjproject/trunk/pjlib/src/pj/sock_bsd.c
r5403 r5444 132 132 133 133 134 /* IPV6_TCLASS */ 135 #ifdef IPV6_TCLASS 136 const pj_uint16_t PJ_IPV6_TCLASS = IPV6_TCLASS; 137 #else 138 const pj_uint16_t PJ_IPV6_TCLASS = 0xFFFF; 139 #endif 140 141 134 142 /* optname values. */ 135 143 const pj_uint16_t PJ_SO_TYPE = SO_TYPE; -
pjproject/trunk/pjlib/src/pj/sock_common.c
r5092 r5444 1245 1245 } 1246 1246 1247 PJ_DEF(int) pj_IPV6_TCLASS(void) 1248 { 1249 return PJ_IPV6_TCLASS; 1250 } 1251 1247 1252 PJ_DEF(pj_uint16_t) pj_SO_TYPE(void) 1248 1253 { -
pjproject/trunk/pjlib/src/pj/sock_qos_bsd.c
r3553 r5444 23 23 24 24 /* This is the implementation of QoS with BSD socket's setsockopt(), 25 * using IP_TOS and SO_PRIORITY25 * using IP_TOS/IPV6_TCLASS and SO_PRIORITY 26 26 */ 27 27 #if !defined(PJ_QOS_IMPLEMENTATION) || PJ_QOS_IMPLEMENTATION==PJ_QOS_BSD … … 42 42 /* Set TOS/DSCP */ 43 43 if (param->flags & PJ_QOS_PARAM_HAS_DSCP) { 44 /* We need to know if the socket is IPv4 or IPv6 */ 45 pj_sockaddr sa; 46 int salen = sizeof(salen); 47 44 48 /* Value is dscp_val << 2 */ 45 49 int val = (param->dscp_val << 2); 46 status = pj_sock_setsockopt(sock, pj_SOL_IP(), pj_IP_TOS(), 47 &val, sizeof(val)); 50 51 status = pj_sock_getsockname(sock, &sa, &salen); 52 if (status != PJ_SUCCESS) 53 return status; 54 55 if (sa.addr.sa_family == pj_AF_INET()) { 56 /* In IPv4, the DS field goes in the TOS field */ 57 status = pj_sock_setsockopt(sock, pj_SOL_IP(), pj_IP_TOS(), 58 &val, sizeof(val)); 59 } else if (sa.addr.sa_family == pj_AF_INET6()) { 60 /* In IPv6, the DS field goes in the Traffic Class field */ 61 status = pj_sock_setsockopt(sock, pj_SOL_IPV6(), 62 pj_IPV6_TCLASS(), 63 &val, sizeof(val)); 64 } else { 65 status = PJ_EINVAL; 66 } 67 48 68 if (status != PJ_SUCCESS) { 49 69 param->flags &= ~(PJ_QOS_PARAM_HAS_DSCP); … … 85 105 pj_status_t last_err = PJ_ENOTSUP; 86 106 int val, optlen; 107 pj_sockaddr sa; 108 int salen = sizeof(salen); 87 109 pj_status_t status; 88 110 … … 90 112 91 113 /* Get DSCP/TOS value */ 92 optlen = sizeof(val); 93 status = pj_sock_getsockopt(sock, pj_SOL_IP(), pj_IP_TOS(), 94 &val, &optlen); 114 status = pj_sock_getsockname(sock, &sa, &salen); 95 115 if (status == PJ_SUCCESS) { 96 p_param->flags |= PJ_QOS_PARAM_HAS_DSCP; 97 p_param->dscp_val = (pj_uint8_t)(val >> 2); 116 optlen = sizeof(val); 117 if (sa.addr.sa_family == pj_AF_INET()) { 118 status = pj_sock_getsockopt(sock, pj_SOL_IP(), pj_IP_TOS(), 119 &val, &optlen); 120 } else if (sa.addr.sa_family == pj_AF_INET6()) { 121 status = pj_sock_getsockopt(sock, pj_SOL_IPV6(), 122 pj_IPV6_TCLASS(), 123 &val, &optlen); 124 } else { 125 status = PJ_EINVAL; 126 } 127 128 if (status == PJ_SUCCESS) { 129 p_param->flags |= PJ_QOS_PARAM_HAS_DSCP; 130 p_param->dscp_val = (pj_uint8_t)(val >> 2); 131 } else { 132 last_err = status; 133 } 98 134 } else { 99 135 last_err = status;
Note: See TracChangeset
for help on using the changeset viewer.