Debian Codegraph @

Xpjproject/pjlib/src/pj/sock_qos_wm.c

raw symbols SCIP
1 /*
2 * Copyright (C) 2009-2011 Teluu Inc. (http://www.teluu.com)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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 /* QoS implementation for Windows Mobile 6, must be enabled explicitly
26 * (this is controlled by pjlib's config.h)
27 */
28 #if defined(PJ_QOS_IMPLEMENTATION) && PJ_QOS_IMPLEMENTATION==PJ_QOS_WM
29
30 #define THIS_FILE "sock_qos_wm.c"
31
32 /* Mapping between our traffic type and WM's DSCP traffic types */
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 /* PJ_QOS_IMPLEMENTATION */