blob: f9e3c3dd97164b2487353aacfc9fd1bea985bce9 [file] [log] [blame]
Benny Prijono4d79b0f2009-10-25 09:02:07 +00001/* $Id$ */
2/*
3 * Copyright (C) 2009 Teluu Inc. (http://www.teluu.com)
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#include <pj/sock_qos.h>
20#include "os_symbian.h"
21
22PJ_DEF(pj_status_t) pj_sock_set_qos_params(pj_sock_t sock,
23 pj_qos_params *param)
24{
25 CPjSocket *pjsock = (CPjSocket*)sock;
26 RSocket & rsock = pjsock->Socket();
27 pj_status_t last_err = PJ_ENOTSUP;
28
29 /* SO_PRIORITY and WMM are not supported */
Benny Prijono610973a2009-10-25 10:50:17 +000030 param->flags &= ~(PJ_QOS_PARAM_HAS_SO_PRIO | PJ_QOS_PARAM_HAS_WMM);
Benny Prijono4d79b0f2009-10-25 09:02:07 +000031
32 if (param->flags & PJ_QOS_PARAM_HAS_DSCP) {
33 TInt err;
34
35 err = rsock.SetOpt(KSoIpTOS, KProtocolInetIp,
36 (param->dscp_val << 2));
37 if (err != KErrNone) {
38 last_err = PJ_RETURN_OS_ERROR(err);
39 param->flags &= ~(PJ_QOS_PARAM_HAS_DSCP);
40 }
41 }
42
43 return param->flags ? PJ_SUCCESS : last_err;
44}
45
46PJ_DEF(pj_status_t) pj_sock_set_qos_type(pj_sock_t sock,
47 pj_qos_type type)
48{
49 pj_qos_params param;
50 pj_status_t status;
51
52 status = pj_qos_get_params(type, &param);
53 if (status != PJ_SUCCESS)
54 return status;
55
56 return pj_sock_set_qos_params(sock, &param);
57}
58
59
60PJ_DEF(pj_status_t) pj_sock_get_qos_params(pj_sock_t sock,
61 pj_qos_params *p_param)
62{
63 CPjSocket *pjsock = (CPjSocket*)sock;
64 RSocket & rsock = pjsock->Socket();
65 TInt err, dscp;
66
67 pj_bzero(p_param, sizeof(*p_param));
68
69 err = rsock.GetOpt(KSoIpTOS, KProtocolInetIp, dscp);
70 if (err == KErrNone) {
71 p_param->flags |= PJ_QOS_PARAM_HAS_DSCP;
72 p_param->dscp_val = (dscp >> 2);
73 return PJ_SUCCESS;
74 } else {
75 return PJ_RETURN_OS_ERROR(err);
76 }
77}
78
79PJ_DEF(pj_status_t) pj_sock_get_qos_type(pj_sock_t sock,
80 pj_qos_type *p_type)
81{
82 pj_qos_params param;
83 pj_status_t status;
84
85 status = pj_sock_get_qos_params(sock, &param);
86 if (status != PJ_SUCCESS)
87 return status;
88
89 return pj_qos_get_type(&param, p_type);
90}
91