Debian Codegraph @

Xpjproject/pjlib/src/pj/sock_qos_symbian.cpp

raw
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 "os_symbian.h"
20
21 PJ_DEF(pj_status_t) pj_sock_set_qos_params(pj_sock_t sock,
22 pj_qos_params *param)
23 {
24 PJ_ASSERT_RETURN(sock!=0 && sock!=PJ_INVALID_SOCKET, PJ_EINVAL);
25
26 CPjSocket *pjsock = (CPjSocket*)sock;
27 RSocket & rsock = pjsock->Socket();
28 pj_status_t last_err = PJ_ENOTSUP;
29
30 /* SO_PRIORITY and WMM are not supported */
31 param->flags &= ~(PJ_QOS_PARAM_HAS_SO_PRIO | PJ_QOS_PARAM_HAS_WMM);
32
33 if (param->flags & PJ_QOS_PARAM_HAS_DSCP) {
34 TInt err;
35
36 err = rsock.SetOpt(KSoIpTOS, KProtocolInetIp,
37 (param->dscp_val << 2));
38 if (err != KErrNone) {
39 last_err = PJ_RETURN_OS_ERROR(err);
40 param->flags &= ~(PJ_QOS_PARAM_HAS_DSCP);
41 }
42 }
43
44 return param->flags ? PJ_SUCCESS : last_err;
45 }
46
47 PJ_DEF(pj_status_t) pj_sock_set_qos_type(pj_sock_t sock,
48 pj_qos_type type)
49 {
50 pj_qos_params param;
51 pj_status_t status;
52
53 status = pj_qos_get_params(type, &param);
54 if (status != PJ_SUCCESS)
55 return status;
56
57 return pj_sock_set_qos_params(sock, &param);
58 }
59
60
61 PJ_DEF(pj_status_t) pj_sock_get_qos_params(pj_sock_t sock,
62 pj_qos_params *p_param)
63 {
64 PJ_ASSERT_RETURN(sock!=0 && sock!=PJ_INVALID_SOCKET, PJ_EINVAL);
65
66 CPjSocket *pjsock = (CPjSocket*)sock;
67 RSocket & rsock = pjsock->Socket();
68 TInt err, dscp;
69
70 pj_bzero(p_param, sizeof(*p_param));
71
72 err = rsock.GetOpt(KSoIpTOS, KProtocolInetIp, dscp);
73 if (err == KErrNone) {
74 p_param->flags |= PJ_QOS_PARAM_HAS_DSCP;
75 p_param->dscp_val = (dscp >> 2);
76 return PJ_SUCCESS;
77 } else {
78 return PJ_RETURN_OS_ERROR(err);
79 }
80 }
81
82 PJ_DEF(pj_status_t) pj_sock_get_qos_type(pj_sock_t sock,
83 pj_qos_type *p_type)
84 {
85 pj_qos_params param;
86 pj_status_t status;
87
88 status = pj_sock_get_qos_params(sock, &param);
89 if (status != PJ_SUCCESS)
90 return status;
91
92 return pj_qos_get_type(&param, p_type);
93 }
94