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