|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* To change this license header, choose License Headers in Project Properties. |
|
5
|
|
|
* To change this template file, choose Tools | Templates |
|
6
|
|
|
* and open the template in the editor. |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace devices\ms; |
|
10
|
|
|
|
|
11
|
|
|
class MsWlanProfile |
|
12
|
|
|
{ |
|
13
|
|
|
private $name; |
|
14
|
|
|
private $encryption; |
|
15
|
|
|
private $authentication; |
|
16
|
|
|
private $ssids; |
|
17
|
|
|
private $eapConfig; |
|
18
|
|
|
private $hs20 = false; |
|
19
|
|
|
private $domainName = ''; |
|
20
|
|
|
private $ois = []; |
|
21
|
|
|
|
|
22
|
|
|
const MS_ONEX_NS = 'http://www.microsoft.com/networking/OneX/v1'; |
|
23
|
|
|
|
|
24
|
|
|
public function setName($name) |
|
25
|
|
|
{ |
|
26
|
|
|
$this->name = $name; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
public function setEncryption($authentication, $encryption) |
|
31
|
|
|
{ |
|
32
|
|
|
$this->authentication = $authentication; |
|
33
|
|
|
$this->encryption = $encryption; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
/* |
|
38
|
|
|
* Prepare data for <SSIDConfig> element |
|
39
|
|
|
*/ |
|
40
|
|
|
public function setSSIDs($ssids) |
|
41
|
|
|
{ |
|
42
|
|
|
$this->ssids = $ssids; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/* |
|
46
|
|
|
* prepare data for the <EapConfig> element. The contents of this element |
|
47
|
|
|
* depends on the implementation of a particular EAP method and thus is |
|
48
|
|
|
* delivered by an EAP-specific class. |
|
49
|
|
|
*/ |
|
50
|
|
|
public function setEapConfig($eapConfig) |
|
51
|
|
|
{ |
|
52
|
|
|
$this->eapConfig = $eapConfig; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function setHS20($hs20) |
|
56
|
|
|
{ |
|
57
|
|
|
$this->hs20 = $hs20; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function setDomainName($domainName) |
|
61
|
|
|
{ |
|
62
|
|
|
$this->domainName = $domainName; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public function setOIs($ois) |
|
66
|
|
|
{ |
|
67
|
|
|
$this->ois = $ois; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function writeWLANprofile() |
|
71
|
|
|
{ |
|
72
|
|
|
$rootname = 'WLANProfile'; |
|
73
|
|
|
$dom = new \DOMDocument('1.0', 'utf-8'); |
|
74
|
|
|
$root = $dom->createElement($rootname); |
|
75
|
|
|
$dom->appendChild($root); |
|
76
|
|
|
$ns = $dom->createAttributeNS( null, 'xmlns' ); |
|
77
|
|
|
$ns->value = "http://www.microsoft.com/networking/WLAN/profile/v1"; |
|
78
|
|
|
$root->appendChild($ns); |
|
79
|
|
|
\core\DeviceXMLmain::marshalObject($dom, $root, 'WLANprofile', $this->getWLANprofile(), '', true); |
|
|
|
|
|
|
80
|
|
|
$dom->formatOutput = true; |
|
81
|
|
|
$xml = $dom->saveXML(); |
|
82
|
|
|
return($xml); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
private function getWLANprofile() |
|
86
|
|
|
{ |
|
87
|
|
|
$element = new \core\DeviceXMLmain(); |
|
88
|
|
|
$element->setChild('name', $this->name); |
|
89
|
|
|
$ssidElement = $this->getSSIDConfig(); |
|
90
|
|
|
if (!empty($ssidElement)) { |
|
91
|
|
|
$element->setChild('SSIDConfig', $this->getSSIDConfig()); |
|
92
|
|
|
} |
|
93
|
|
|
if ($this->hs20) { |
|
94
|
|
|
$element->setChild('Hotspot2', $this->getHotspot2()); |
|
95
|
|
|
} |
|
96
|
|
|
$element->setChild('connectionType', 'ESS'); |
|
97
|
|
|
$element->setChild('connectionMode', 'auto'); |
|
98
|
|
|
$element->setChild('autoSwitch', 'false'); |
|
99
|
|
|
$element->setChild('MSM', $this->getMSM()); |
|
100
|
|
|
return($element); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
private function getSSIDConfig() |
|
104
|
|
|
{ |
|
105
|
|
|
$ssids = $this->getSSID(); |
|
106
|
|
|
if (!empty($ssids)) { |
|
107
|
|
|
$element = new \core\DeviceXMLmain(); |
|
108
|
|
|
$element->setChild('SSID', $this->getSSID()); |
|
109
|
|
|
return($element); |
|
110
|
|
|
} else { |
|
111
|
|
|
return(NULL); |
|
112
|
|
|
} |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
private function getSSID() |
|
116
|
|
|
{ |
|
117
|
|
|
$retArray = []; |
|
118
|
|
|
foreach ($this->ssids as $ssid) { |
|
119
|
|
|
$element = new \core\DeviceXMLmain(); |
|
120
|
|
|
$element->setChild('name', $ssid); |
|
121
|
|
|
$retArray[] = $element; |
|
122
|
|
|
} |
|
123
|
|
|
return($retArray); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
private function getMSM() |
|
127
|
|
|
{ |
|
128
|
|
|
$element = new \core\DeviceXMLmain(); |
|
129
|
|
|
$element->setChild('security', $this->getSecurity()); |
|
130
|
|
|
return($element); |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
private function getSecurity() |
|
134
|
|
|
{ |
|
135
|
|
|
$element = new \core\DeviceXMLmain(); |
|
136
|
|
|
$oneX = new \devices\ms\MsOneX(); |
|
137
|
|
|
$element->setChild('authEncryption', $this->getAuthEncryption()); |
|
138
|
|
|
if ($this->authentication == 'WPA2') { |
|
139
|
|
|
$element->setChild('PMKCacheMode', 'enabled'); |
|
140
|
|
|
$element->setChild('PMKCacheTTL', 720); |
|
141
|
|
|
$element->setChild('PMKCacheSize', 128); |
|
142
|
|
|
$element->setChild('preAuthMode', 'disabled'); |
|
143
|
|
|
} |
|
144
|
|
|
$element->setChild('OneX', $oneX->getOneX($this->eapConfig), self::MS_ONEX_NS); |
|
145
|
|
|
return($element); |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
private function getAuthEncryption() |
|
149
|
|
|
{ |
|
150
|
|
|
$element = new \core\DeviceXMLmain(); |
|
151
|
|
|
$element->setChild('authentication', $this->authentication); |
|
152
|
|
|
$element->setChild('encryption', $this->encryption); |
|
153
|
|
|
$element->setChild('useOneX', 'true'); |
|
154
|
|
|
return($element); |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
private function getHotspot2() |
|
158
|
|
|
{ |
|
159
|
|
|
$element = new \core\DeviceXMLmain(); |
|
160
|
|
|
$element->setChild('DomainName', $this->domainName); |
|
161
|
|
|
$element->setChild('RoamingConsortium', $this->getRoamingConsortium()); |
|
162
|
|
|
return($element); |
|
163
|
|
|
|
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
private function getRoamingConsortium() |
|
167
|
|
|
{ |
|
168
|
|
|
$element = new \core\DeviceXMLmain(); |
|
169
|
|
|
foreach ($this->ois as $oi) { |
|
170
|
|
|
$element->setChild('OUI', $oi); |
|
171
|
|
|
} |
|
172
|
|
|
return($element); |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
|
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.