Skip to content

Commit

Permalink
More ticket #950 (QoS):
Browse files Browse the repository at this point in the history
 - fixed wrong DSCP field operation with sock_qos_bsd.c backend
 - tested on Linux for SIP (UDP/TCP), UDP RTP/RTCP, and ICE
 - renamed 801_1_P names to SO_PRIO
 - changed a bit of doxygen documentation (the title etc)


git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@2967 74dad513-b988-da41-8d7b-12977e46ad98
  • Loading branch information
bennylp committed Oct 25, 2009
1 parent 4d79b0f commit 610973a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
12 changes: 6 additions & 6 deletions pjlib/include/pj/sock_qos.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ PJ_BEGIN_DECL


/**
* @defgroup socket_qos Socket Quality of Service (QoS) API
* @defgroup socket_qos Socket Quality of Service (QoS) API: TOS, DSCP, WMM, IEEE 802.1p
* @ingroup PJ_SOCK
* @{
Expand Down Expand Up @@ -63,7 +63,7 @@ PJ_BEGIN_DECL
At the Internet layer, you can use Differentiated Services/Diffserv and
set the value of the Differentiated Services Code Point (DSCP) in the
IP header. As defined in RFC 2472, the DSCP value is the high-order 6 bits
IP header. As defined in RFC 2474, the DSCP value is the high-order 6 bits
of the IP version 4 (IPv4) TOS field and the IP version 6 (IPv6) Traffic
Class field.
Expand Down Expand Up @@ -179,7 +179,7 @@ PJ_BEGIN_DECL
typedef enum pj_qos_flag
{
PJ_QOS_PARAM_HAS_DSCP = 1,
PJ_QOS_PARAM_HAS_802_1_P = 2,
PJ_QOS_PARAM_HAS_SO_PRIO = 2,
PJ_QOS_PARAM_HAS_WMM = 4
} pj_qos_flag;
Expand All @@ -195,7 +195,7 @@ PJ_BEGIN_DECL
{
pj_uint8_t flags; // Determines which values to
// set, bitmask of pj_qos_flag
pj_uint8_t dscp_val; // DSCP value to set
pj_uint8_t dscp_val; // The 6 bits DSCP value to set
pj_uint8_t so_prio; // SO_PRIORITY value
pj_qos_wmm_prio wmm_prio; // WMM priority value
} pj_qos_params;
Expand Down Expand Up @@ -248,7 +248,7 @@ typedef enum pj_qos_type
typedef enum pj_qos_flag
{
PJ_QOS_PARAM_HAS_DSCP = 1, /**< DSCP field is set. */
PJ_QOS_PARAM_HAS_802_1_P = 2, /**< IEEE 802.1p field is set */
PJ_QOS_PARAM_HAS_SO_PRIO = 2, /**< Socket SO_PRIORITY */
PJ_QOS_PARAM_HAS_WMM = 4 /**< WMM field is set. */
} pj_qos_flag;

Expand All @@ -272,7 +272,7 @@ typedef struct pj_qos_params
{
pj_uint8_t flags; /**< Determines which values to
set, bitmask of pj_qos_flag */
pj_uint8_t dscp_val; /**< DSCP value to set */
pj_uint8_t dscp_val; /**< The 6 bits DSCP value to set */
pj_uint8_t so_prio; /**< SO_PRIORITY value */
pj_qos_wmm_prio wmm_prio; /**< WMM priority value */
} pj_qos_params;
Expand Down
12 changes: 7 additions & 5 deletions pjlib/src/pj/sock_qos_bsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ PJ_DEF(pj_status_t) pj_sock_set_qos_params(pj_sock_t sock,

/* Set TOS/DSCP */
if (param->flags & PJ_QOS_PARAM_HAS_DSCP) {
int val = param->dscp_val;
/* Value is dscp_val << 2 */
int val = (param->dscp_val << 2);
status = pj_sock_setsockopt(sock, pj_SOL_IP(), pj_IP_TOS(),
&val, sizeof(val));
if (status != PJ_SUCCESS) {
Expand All @@ -51,12 +52,12 @@ PJ_DEF(pj_status_t) pj_sock_set_qos_params(pj_sock_t sock,
}

/* Set SO_PRIORITY */
if (param->flags & PJ_QOS_PARAM_HAS_802_1_P) {
if (param->flags & PJ_QOS_PARAM_HAS_SO_PRIO) {
int val = param->so_prio;
status = pj_sock_setsockopt(sock, pj_SOL_SOCKET(), pj_SO_PRIORITY(),
&val, sizeof(val));
if (status != PJ_SUCCESS) {
param->flags &= ~(PJ_QOS_PARAM_HAS_802_1_P);
param->flags &= ~(PJ_QOS_PARAM_HAS_SO_PRIO);
last_err = status;
}
}
Expand Down Expand Up @@ -93,7 +94,7 @@ PJ_DEF(pj_status_t) pj_sock_get_qos_params(pj_sock_t sock,
&val, &optlen);
if (status == PJ_SUCCESS) {
p_param->flags |= PJ_QOS_PARAM_HAS_DSCP;
p_param->dscp_val = (pj_uint8_t)val;
p_param->dscp_val = (pj_uint8_t)(val >> 2);
} else {
last_err = status;
}
Expand All @@ -103,7 +104,7 @@ PJ_DEF(pj_status_t) pj_sock_get_qos_params(pj_sock_t sock,
status = pj_sock_getsockopt(sock, pj_SOL_SOCKET(), pj_SO_PRIORITY(),
&val, &optlen);
if (status == PJ_SUCCESS) {
p_param->flags |= PJ_QOS_PARAM_HAS_802_1_P;
p_param->flags |= PJ_QOS_PARAM_HAS_SO_PRIO;
p_param->so_prio = (pj_uint8_t)val;
} else {
last_err = status;
Expand All @@ -128,3 +129,4 @@ PJ_DEF(pj_status_t) pj_sock_get_qos_type(pj_sock_t sock,
}

#endif /* PJ_QOS_IMPLEMENTATION */

4 changes: 2 additions & 2 deletions pjlib/src/pj/sock_qos_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <pj/string.h>

#define THIS_FILE "sock_qos_common.c"
#define ALL_FLAGS (PJ_QOS_PARAM_HAS_DSCP | PJ_QOS_PARAM_HAS_802_1_P | \
#define ALL_FLAGS (PJ_QOS_PARAM_HAS_DSCP | PJ_QOS_PARAM_HAS_SO_PRIO | \
PJ_QOS_PARAM_HAS_WMM)

/* "Standard" mapping between traffic type and QoS params */
Expand Down Expand Up @@ -66,7 +66,7 @@ PJ_DEF(pj_status_t) pj_qos_get_type( const pj_qos_params *param,
++count;
}

if (param->flags & PJ_QOS_PARAM_HAS_802_1_P) {
if (param->flags & PJ_QOS_PARAM_HAS_SO_PRIO) {
for (i=0; i<=PJ_QOS_TYPE_CONTROL; ++i) {
if (param->so_prio >= qos_map[i].so_prio)
prio_type = (pj_qos_type)i;
Expand Down
2 changes: 1 addition & 1 deletion pjlib/src/pj/sock_qos_symbian.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ PJ_DEF(pj_status_t) pj_sock_set_qos_params(pj_sock_t sock,
pj_status_t last_err = PJ_ENOTSUP;

/* SO_PRIORITY and WMM are not supported */
param->flags &= ~(PJ_QOS_PARAM_HAS_802_1_P | PJ_QOS_PARAM_HAS_WMM);
param->flags &= ~(PJ_QOS_PARAM_HAS_SO_PRIO | PJ_QOS_PARAM_HAS_WMM);

if (param->flags & PJ_QOS_PARAM_HAS_DSCP) {
TInt err;
Expand Down

0 comments on commit 610973a

Please sign in to comment.