| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#include <pj/sock_qos.h> |
| 19 |
#include <pj/assert.h> |
| 20 |
#include <pj/errno.h> |
| 21 |
#include <pj/log.h> |
| 22 |
|
| 23 |
#include <winsock.h> |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
#if defined(PJ_QOS_IMPLEMENTATION) && PJ_QOS_IMPLEMENTATION==PJ_QOS_WM |
| 29 |
|
| 30 |
#define THIS_FILE "sock_qos_wm.c" |
| 31 |
|
| 32 |
|
| 33 |
static const int dscp_map[] = |
| 34 |
{ |
| 35 |
DSCPBestEffort, |
| 36 |
DSCPBackground, |
| 37 |
DSCPVideo, |
| 38 |
DSCPAudio, |
| 39 |
DSCPControl |
| 40 |
}; |
| 41 |
|
| 42 |
PJ_DEF(pj_status_t) pj_sock_set_qos_params(pj_sock_t sock, |
| 43 |
pj_qos_params *param) |
| 44 |
{ |
| 45 |
PJ_UNUSED_ARG(sock); |
| 46 |
PJ_UNUSED_ARG(param); |
| 47 |
|
| 48 |
PJ_LOG(4,(THIS_FILE, "pj_sock_set_qos_params() is not implemented " |
| 49 |
"for this platform")); |
| 50 |
return PJ_ENOTSUP; |
| 51 |
} |
| 52 |
|
| 53 |
PJ_DEF(pj_status_t) pj_sock_set_qos_type(pj_sock_t sock, |
| 54 |
pj_qos_type type) |
| 55 |
{ |
| 56 |
int value; |
| 57 |
|
| 58 |
PJ_ASSERT_RETURN(type < PJ_ARRAY_SIZE(dscp_map), PJ_EINVAL); |
| 59 |
|
| 60 |
value = dscp_map[type]; |
| 61 |
return pj_sock_setsockopt(sock, IPPROTO_IP, IP_DSCP_TRAFFIC_TYPE, |
| 62 |
&value, sizeof(value)); |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
PJ_DEF(pj_status_t) pj_sock_get_qos_params(pj_sock_t sock, |
| 67 |
pj_qos_params *p_param) |
| 68 |
{ |
| 69 |
PJ_UNUSED_ARG(sock); |
| 70 |
PJ_UNUSED_ARG(p_param); |
| 71 |
|
| 72 |
PJ_LOG(4,(THIS_FILE, "pj_sock_get_qos_params() is not implemented " |
| 73 |
"for this platform")); |
| 74 |
return PJ_ENOTSUP; |
| 75 |
} |
| 76 |
|
| 77 |
PJ_DEF(pj_status_t) pj_sock_get_qos_type(pj_sock_t sock, |
| 78 |
pj_qos_type *p_type) |
| 79 |
{ |
| 80 |
pj_status_t status; |
| 81 |
int value, optlen; |
| 82 |
unsigned i; |
| 83 |
|
| 84 |
optlen = sizeof(value); |
| 85 |
value = 0; |
| 86 |
status = pj_sock_getsockopt(sock, IPPROTO_IP, IP_DSCP_TRAFFIC_TYPE, |
| 87 |
&value, &optlen); |
| 88 |
if (status != PJ_SUCCESS) |
| 89 |
return status; |
| 90 |
|
| 91 |
*p_type = PJ_QOS_TYPE_BEST_EFFORT; |
| 92 |
for (i=0; i<PJ_ARRAY_SIZE(dscp_map); ++i) { |
| 93 |
if (value == dscp_map[i]) { |
| 94 |
*p_type = (pj_qos_type)i; |
| 95 |
break; |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
return PJ_SUCCESS; |
| 100 |
} |
| 101 |
|
| 102 |
#endif |