source: trunk/src/plugins/bearer/icd/wlan-utils.h

Last change on this file was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 3.9 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation (qt-info@nokia.com)
6**
7** This file is part of the plugins of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at qt-info@nokia.com.
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42
43#ifndef WLAN_UTILS_H
44#define WLAN_UTILS_H
45
46/** Originally taken from: libicd-network-wlan-dev.h*/
47
48#include <glib.h>
49#include <dbus/dbus.h>
50#include <wlancond.h>
51#include <icd/network_api_defines.h>
52
53/* capability bits inside network attributes var */
54#define NWATTR_WPS_MASK 0x0000F000
55#define NWATTR_ALGORITHM_MASK 0x00000F00
56#define NWATTR_WPA2_MASK 0x00000080
57#define NWATTR_METHOD_MASK 0x00000078
58#define NWATTR_MODE_MASK 0x00000007
59
60#define CAP_LOCALMASK 0x0FFFE008
61
62/* how much to shift between capability and network attributes var */
63#define CAP_SHIFT_WPS 3
64#define CAP_SHIFT_ALGORITHM 20
65#define CAP_SHIFT_WPA2 1
66#define CAP_SHIFT_METHOD 1
67#define CAP_SHIFT_MODE 0
68#define CAP_SHIFT_ALWAYS_ONLINE 26
69
70/* ------------------------------------------------------------------------- */
71/* From combined to capability */
72static inline dbus_uint32_t nwattr2cap(guint nwattrs, dbus_uint32_t *cap)
73{
74 guint oldval = *cap;
75
76 *cap &= CAP_LOCALMASK; /* clear old capabilities */
77 *cap |=
78 ((nwattrs & ICD_NW_ATTR_ALWAYS_ONLINE) >> CAP_SHIFT_ALWAYS_ONLINE) |
79 ((nwattrs & NWATTR_WPS_MASK) >> CAP_SHIFT_WPS) |
80 ((nwattrs & NWATTR_ALGORITHM_MASK) << CAP_SHIFT_ALGORITHM) |
81 ((nwattrs & NWATTR_WPA2_MASK) << CAP_SHIFT_WPA2) |
82 ((nwattrs & NWATTR_METHOD_MASK) << CAP_SHIFT_METHOD) |
83 (nwattrs & NWATTR_MODE_MASK);
84
85 return oldval;
86}
87
88
89/* ------------------------------------------------------------------------- */
90/* From capability to combined */
91static inline guint cap2nwattr(dbus_uint32_t cap, guint *nwattrs)
92{
93 guint oldval = *nwattrs;
94
95 *nwattrs &= ~ICD_NW_ATTR_LOCALMASK; /* clear old capabilities */
96 *nwattrs |=
97#ifdef WLANCOND_WPS_MASK
98 ((cap & WLANCOND_WPS_MASK) << CAP_SHIFT_WPS) |
99#endif
100 ((cap & (WLANCOND_ENCRYPT_ALG_MASK |
101 WLANCOND_ENCRYPT_GROUP_ALG_MASK)) >> CAP_SHIFT_ALGORITHM)|
102 ((cap & WLANCOND_ENCRYPT_WPA2_MASK) >> CAP_SHIFT_WPA2) |
103 ((cap & WLANCOND_ENCRYPT_METHOD_MASK) >> CAP_SHIFT_METHOD) |
104 (cap & WLANCOND_MODE_MASK);
105
106 return oldval;
107}
108
109
110#endif
Note: See TracBrowser for help on using the repository browser.