This repository has been archived by the owner on Dec 4, 2020. It is now read-only.
/
netif.cpp
634 lines (527 loc) · 19.8 KB
/
netif.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
/***************************************************************************
* Copyright (C) 2008 by Tim McCormick *
* tim@pcbsd.org *
* *
* Permission is hereby granted, free of charge, to any person obtaining *
* a copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to *
* the following conditions: *
* *
* The above copyright notice and this permission notice shall be *
* included in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR *
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
* OTHER DEALINGS IN THE SOFTWARE. *
***************************************************************************/
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/sysctl.h>
#include <unistd.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <net/if_media.h>
#include <ifaddrs.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <qregexp.h>
#include <QDebug>
#include <QFile>
#include <qstring.h>
//#include <QMessageBox> //for debugging purposes
#include "pcbsd-netif.h"
#include "pcbsd-utils.h"
using namespace pcbsd;
QStringList NetworkInterface::getInterfaces()
{
QStringList result;
struct ifaddrs *ifap;
getifaddrs(&ifap);
char ifName[IFNAMSIZ];
while (ifap != NULL)
{
strncpy(ifName, ifap->ifa_name, IFNAMSIZ);
if (result.contains(ifName) == 0) result += ifName;
ifap = ifap->ifa_next;
}
freeifaddrs(ifap);
return result;
}
NetworkInterface::NetworkInterface(QString devName)
{
name = devName;
}
QString NetworkInterface::ipAsString()
{
struct ifreq ifr;
memset(&ifr, 0, sizeof(struct ifreq));
strncpy(ifr.ifr_name, name.toAscii(), IFNAMSIZ);
int s = socket(PF_INET, SOCK_DGRAM, 0);
ioctl(s, SIOCGIFADDR, &ifr);
struct in_addr in = ((sockaddr_in *) &ifr.ifr_addr)->sin_addr;
return QString(inet_ntoa(in));
}
QString NetworkInterface::netmaskAsString()
{
struct ifreq ifr;
memset(&ifr, 0, sizeof(struct ifreq));
strncpy(ifr.ifr_name, name.toAscii(), IFNAMSIZ);
int s = socket(PF_INET, SOCK_DGRAM, 0);
ioctl(s, SIOCGIFNETMASK, &ifr);
struct in_addr in = ((sockaddr_in *) &ifr.ifr_addr)->sin_addr;
return QString(inet_ntoa(in));
}
QString NetworkInterface::macAsString()
{
int mib[6];
size_t len;
char *buf;
struct sockaddr_dl *sdl;
char *ptr;
mib[0] = CTL_NET;
mib[1] = AF_ROUTE;
mib[2] = 0;
mib[3] = AF_LINK;
mib[4] = NET_RT_IFLIST;
mib[5] = if_nametoindex(name.toAscii());
//First find the size of the return, so we can adjust buf accordingly
sysctl(mib, 6, NULL, &len, NULL, 0);
buf = (char *) malloc(len);
sysctl(mib, 6, buf, &len, NULL, 0);
sdl = (sockaddr_dl *)(((if_msghdr *)buf)+1);
ptr = (char *) LLADDR(sdl);
QString mac;
for (uint i=0; i < 6; i++)
{
mac += QString::number(*(ptr+i), 16).right(2).rightJustified(2, '0');
if (i<5) mac += ":";
}
return mac;
}
QString NetworkInterface::mediaStatusAsString()
{
struct ifmediareq ifm;
memset(&ifm, 0, sizeof(struct ifmediareq));
strncpy(ifm.ifm_name, name.toAscii(), IFNAMSIZ);
int s = socket(AF_INET, SOCK_DGRAM, 0);
ioctl(s, SIOCGIFMEDIA, &ifm);
QString status;
switch (IFM_TYPE(ifm.ifm_active))
{
case IFM_FDDI:
case IFM_TOKEN:
if (ifm.ifm_status & IFM_ACTIVE) status = "inserted";
else status = "no ring";
break;
case IFM_IEEE80211:
if (ifm.ifm_status & IFM_ACTIVE) status = "associated";
else status = "no carrier";
break;
default:
if (ifm.ifm_status & IFM_ACTIVE) status = "active";
else status = "no carrier";
}
return status;
}
QString NetworkInterface::desc()
{
return Utils::sysctl("dev." + devName() + "." + QString::number(devNum()) + ".%desc");
}
QString NetworkInterface::devName()
{
uint pos = name.indexOf(QRegExp("[0-9]+$"));
QString result = name;
result.truncate(pos);
return result;
}
bool NetworkInterface::isWireless()
{
struct ifmediareq ifm;
memset(&ifm, 0, sizeof(struct ifmediareq));
strncpy(ifm.ifm_name, name.toAscii(), IFNAMSIZ);
int s = socket(AF_INET, SOCK_DGRAM, 0);
ioctl(s, SIOCGIFMEDIA, &ifm);
return IFM_TYPE(ifm.ifm_active) == IFM_IEEE80211;
}
bool NetworkInterface::isUp()
{
struct ifreq ifr;
memset(&ifr, 0, sizeof(struct ifreq));
strncpy(ifr.ifr_name, name.toAscii(), IFNAMSIZ);
int s = socket(AF_INET, SOCK_DGRAM, 0);
ioctl(s, SIOCGIFFLAGS, &ifr);
return (ifr.ifr_flags & IFF_UP) ? 1 : 0;
}
long NetworkInterface::packetsRx()
{
int mib[6];
size_t len;
char *buf;
struct if_msghdr *ifm;
mib[0] = CTL_NET;
mib[1] = AF_ROUTE;
mib[2] = 0;
mib[3] = AF_LINK;
mib[4] = NET_RT_IFLIST;
mib[5] = if_nametoindex(name.toAscii());
//First find the size of the return, so we can adjust buf accordingly
sysctl(mib, 6, NULL, &len, NULL, 0);
buf = (char *) malloc(len);
sysctl(mib, 6, buf, &len, NULL, 0);
ifm = (if_msghdr *) buf;
return ifm->ifm_data.ifi_ipackets;
}
long NetworkInterface::packetsTx()
{
int mib[6];
size_t len;
char *buf;
struct if_msghdr *ifm;
mib[0] = CTL_NET;
mib[1] = AF_ROUTE;
mib[2] = 0;
mib[3] = AF_LINK;
mib[4] = NET_RT_IFLIST;
mib[5] = if_nametoindex(name.toAscii());
//First find the size of the return, so we can adjust buf accordingly
sysctl(mib, 6, NULL, &len, NULL, 0);
buf = (char *) malloc(len);
sysctl(mib, 6, buf, &len, NULL, 0);
ifm = (if_msghdr *) buf;
return ifm->ifm_data.ifi_opackets;
}
long NetworkInterface::errorsRx()
{
int mib[6];
size_t len;
char *buf;
struct if_msghdr *ifm;
mib[0] = CTL_NET;
mib[1] = AF_ROUTE;
mib[2] = 0;
mib[3] = AF_LINK;
mib[4] = NET_RT_IFLIST;
mib[5] = if_nametoindex(name.toAscii());
//First find the size of the return, so we can adjust buf accordingly
sysctl(mib, 6, NULL, &len, NULL, 0);
buf = (char *) malloc(len);
sysctl(mib, 6, buf, &len, NULL, 0);
ifm = (if_msghdr *) buf;
return ifm->ifm_data.ifi_ierrors;
}
long NetworkInterface::errorsTx()
{
int mib[6];
size_t len;
char *buf;
struct if_msghdr *ifm;
mib[0] = CTL_NET;
mib[1] = AF_ROUTE;
mib[2] = 0;
mib[3] = AF_LINK;
mib[4] = NET_RT_IFLIST;
mib[5] = if_nametoindex(name.toAscii());
//First find the size of the return, so we can adjust buf accordingly
sysctl(mib, 6, NULL, &len, NULL, 0);
buf = (char *) malloc(len);
sysctl(mib, 6, buf, &len, NULL, 0);
ifm = (if_msghdr *) buf;
return ifm->ifm_data.ifi_oerrors;
}
uint NetworkInterface::devNum()
{
uint pos = name.indexOf(QRegExp("[0-9]+$"));
return name.mid(pos).toInt();
}
void NetworkInterface::restart(){
//restart all network connections
system("(sync; ifconfig lagg0 destroy; route -n flush; /etc/rc.d/netif restart) &");
}
QStringList NetworkInterface::parseWifiScanLine( QString linein, bool isverbose){
/*
This function works given a single line of the command:
"ifconfig (wifi device) list scan" (verbose or not)
Output: QStringList[ssid,bssid,channel,rate,signal%,INT,CAPS,etc]
*/
int n; //index for end of the SSID section
if(isverbose){n=33;} //verbose can display full ssid names between 16-33 characters long
else{n=16;}
QString line = linein; //make sure we do not change the line outside the function
//Parse the line into its components
QString ssid = line.left(n); //Entire SSID/MESH ID column
ssid = ssid.trimmed(); //remove excess whitespace at the ends
line.remove(0,n); //remove the ssid from the line (multiple words mess up later parts otherwise)
QString bssid = line.section(" ",0,0,QString::SectionSkipEmpty); //BSSID column
QString chan = line.section(" ",1,1,QString::SectionSkipEmpty); //CHAN column
QString rate = line.section(" ",2,2,QString::SectionSkipEmpty); //RATE column
QString signoise = line.section(" ",3,3,QString::SectionSkipEmpty); //S:G column
QString inte = line.section(" ",4,4,QString::SectionSkipEmpty); //INT column
QString caps = line.section(" ",5,5,QString::SectionSkipEmpty); //CAPS column
QString etc = line.section(" ",6,50,QString::SectionSkipEmpty); //Everything at the end (security info)
//change signoise into signal strength(%)
QString sig = signoise.section(":",0,0); //determine signal
QString noise = signoise.section(":",1,1); //determine noise
//determine the signal strength
int signal = ( sig.toInt()-noise.toInt() )*4;
if(signal<0){signal=0;}
if(signal>100){signal=100;}
//output result as a QString percentage
QString strength = QString::number(signal);
strength.append("%");
//get the security type
QString secType = parseWifiSecurity(caps,etc);
//put into QStringList for output
QStringList out;
out << ssid << bssid << chan << rate << strength << inte << secType;
return out;
}
QString NetworkInterface::getWifiSecurity( QString SSID, QString deviceName ){
//Make sure the SSID is short enough (non verbose will be used to search)
QString smSSID;
if(SSID.size() > 10){
smSSID = SSID.left(10);
}else{
smSSID = SSID;
}
//Scan the wifi to determine the security type
//If there are multiple wifi's with the same SSID, it will use the first one only
QString command = "ifconfig " + deviceName + " list scan";
QString ifconfOut = Utils::runShellCommandSearch(command,smSSID);
QStringList parsed = NetworkInterface::parseWifiScanLine(ifconfOut,false);
//get the security type
QString output = parsed[6];
return output;
}
QString NetworkInterface::parseWifiSecurity( QString caps, QString etc ){
// INPUT: caps and etc are the last two fields output from "ifconfig (device) list scan"
QStringList secure = etc.split(" "); //put each security type in a different list element
//Examine the CAPS and Security data to determine the wifi encryption type
bool isDisabled = !caps.contains("P") && caps.contains("ES"); //CAPS = "ES" only -> no wifi encryption
bool isWEP = caps.contains("EP"); //CAPS = "EP" or "EPS" only (could also be RADIUS security type)
bool isWPA = secure.contains("WPA"); //both WPA personal and enterprise
bool isWPA2 = secure.contains("RSN"); //both WPA2 personal and enterprise
//qDebug() << "caps: "+caps+"\netc: "+etc;
//Output the security type
QString securityType;
if(isDisabled){
securityType = "None";
}else if(isWPA2){
securityType = "WPA2";
}else if(isWPA){
securityType = "WPA";
}else if(isWEP){
securityType = "WEP";
}else{
securityType = "ERROR";
}
return securityType;
}
QString NetworkInterface::getFirstWiredDevice()
{
QString tmp;
QStringList ifs = getInterfaces();
for ( QStringList::Iterator it = ifs.begin(); it != ifs.end(); ++it )
{
// List of devices to exclude not real ethernet
QString tmpDev = *it;
if (tmpDev.indexOf("lo0") == -1
&& tmpDev.indexOf("lagg") == -1
&& tmpDev.indexOf("lo1") == -1
&& tmpDev.indexOf("lo2") == -1
&& tmpDev.indexOf("lo3") == -1
&& tmpDev.indexOf("fwe") == -1
&& tmpDev.indexOf("plip") == -1
&& tmpDev.indexOf("pfsync") == -1
&& tmpDev.indexOf("pflog") == -1
&& tmpDev.indexOf("ipfw") == -1
&& tmpDev.indexOf("tun") == -1
&& tmpDev.indexOf("usbus") == -1
&& tmpDev.indexOf("vboxnet") == -1
&& tmpDev.indexOf("wlan") == -1 )
{
NetworkInterface ifr(tmpDev);
if (! ifr.isWireless()) {
return tmpDev;
}
}
}
return tmp;
}
QString NetworkInterface::getWifiParent(QString dev)
{
dev.remove(0, dev.size() -1 );
QString DevNum = dev;
return Utils::sysctl("net.wlan." + DevNum + ".%parent");
}
void NetworkInterface::wifiQuickConnect(QString SSID, QString netKey, QString DeviceName){
/*
This function uses a set of defaults to connect to a wifi access point with a minimum
of information from the user. It does *NOT* (currently) support the WPA-Enterprise encryption
*/
//do nothing if no SSID given
if( SSID.isEmpty() ){
return;
}
QString tmp;
QString ifConfigLine;
//Set defaults for quick-connect
ifConfigLine="SYNCDHCP"; //Use DHCP
//setup for not using the lagg interface
Utils::setConfFileValue( "/etc/rc.conf", "ifconfig_lagg0", "", -1);
Utils::setConfFileValue( "/etc/rc.conf", "ifconfig_" + DeviceName, \
"ifconfig_" + DeviceName + "=\"WPA " + ifConfigLine + "\"", -1);
//Determine if the wpa_supplicant file exists already or is empty
bool newWPASup = true;
bool existingSSID = false;
QStringList tmpFileList;
QString tmpEntry;
QFile fileout( "/etc/wpa_supplicant.conf" );
if( fileout.open( QIODevice::ReadOnly ) ){
QTextStream streamtmp(&fileout);
streamtmp.setCodec("UTF-8");
QString line;
bool inEntry = false;
bool eStart, eEnd;
while ( !streamtmp.atEnd() ) {
eStart = false;
eEnd = false;
line = streamtmp.readLine();
if ( line.contains("ctrl_interface=/var/run/wpa_supplicant") ) {
newWPASup = false;
}else if(line.contains("ssid=") && line.contains(SSID)){
existingSSID=true;
}else if(line.contains("network={")){eStart = true;}
else if(line.contains("}")){eEnd = true; }
//Save the file by entry temporarily
if(eStart){ tmpEntry = line; inEntry = true; }
else if(eEnd){ tmpEntry.append(" ::: "+line); tmpFileList << tmpEntry; inEntry=false; }
else if(inEntry){ tmpEntry.append(" ::: "+line); }
else{ tmpFileList << line; }
}
fileout.close();
}
//If the desired SSID already has an entry, remove it from wpa_supplicant.conf
if(existingSSID){
QFile tmpFile( "/etc/wpa_supplicant.conf.tmp" );
if(tmpFile.open(QIODevice::WriteOnly | QIODevice::Text )){
QTextStream oStr(&tmpFile);
for(int i=0; i<tmpFileList.length(); i++){
if(tmpFileList[i].contains("network={")){
QStringList tmp = tmpFileList[i].split(" ::: ");
//skip it if the new SSID
int idx = tmp.indexOf("ssid=");
if( (idx!= -1) && !tmp[idx].contains(SSID) ){
for(int j=0; j<tmp.length(); j++){
oStr << tmp[j] + "\n";
}
}
}else{
oStr << tmpFileList[i] + "\n";
}
}
}
tmpFile.close();
Utils::runShellCommand("mv /etc/wpa_supplicant.conf.tmp /etc/wpa_supplicant.conf");
}
// Create the wpa_supplicant file based on saved configuration
if ( fileout.open( QIODevice::Append ) ) {
QTextStream streamout( &fileout );
// Fix to prevent kernel panic
if(newWPASup)
streamout << "ctrl_interface=/var/run/wpa_supplicant\n\n";
//Use SSID for network connection
streamout << "\nnetwork={\n ssid=\"" + SSID + "\"\n";
streamout << " priority=" << 146 << "\n";
streamout << " scan_ssid=1\n";
//Determine the security type for the given SSID
QString SecType = getWifiSecurity(SSID,DeviceName);
//Configure the wifi Security Settings for the proper type
if ( SecType.contains("None") ){
streamout << " key_mgmt=NONE\n";
} else if ( SecType.contains("WEP") ) {
//Set WEP Defaults
int WEPIndex = 0;
// Default to plain-text WEP keys..
// This needs to be fixed to figure it out automatically
bool WEPHex = false;
streamout << " key_mgmt=NONE\n";
streamout << " wep_tx_keyidx=" + tmp.setNum(WEPIndex) + "\n";
// Check if we are using a plaintext WEP or not
if ( WEPHex ) {
streamout << " wep_key" + tmp.setNum(WEPIndex) + "=" + netKey + "\n";
} else {
streamout << " wep_key" + tmp.setNum(WEPIndex) + "=\"" + netKey + "\"\n";
}
} else if ( SecType.contains("WPA") ) {
streamout << " psk=\"" + netKey + "\"\n";
}
streamout << "}\n\n";
fileout.close();
}
// Flush to disk, so that when we restart network it picks up the changes
sync();
Utils::restartNetworking();
return;
}
// Function which sets up the lagg0 interface for the specified wlan[0-9] device
void NetworkInterface::enableLagg(QString dev)
{
// Get the first wired device, we will enable lagg0 to use it
QString wiredDev, wifiParent, wifiConf, tmp, newWifiConf;
wiredDev = NetworkInterface::getFirstWiredDevice();
wifiParent = NetworkInterface::getWifiParent(dev);
// If no wired device on this box or no valid wifi parent we can return, no need to setup lagg
if ( wiredDev.isEmpty() || wifiParent.isEmpty() )
return;
// Get the config for this wifi device
wifiConf = Utils::getConfFileValue( "/etc/rc.conf", "ifconfig_" + dev + "=", 1 );
if ( wifiConf.isEmpty() )
wifiConf = Utils::getConfFileValue( "/etc/rc.conf", "ifconfig_lagg0=", 1 );
else if ( wifiConf == "WPA" ) {
// If it just equals WPA, check if anything already exists in lagg0 line
tmp = Utils::getConfFileValue( "/etc/rc.conf", "ifconfig_lagg0=", 1 );
if ( ! tmp.isEmpty() )
wifiConf = tmp;
}
// No valid config? We can't save this..
if ( wifiConf.isEmpty() )
return;
// Setup the ethernet mac address cloning for this device
Utils::setConfFileValue( "/etc/rc.conf", "ifconfig_" + wifiParent, "ifconfig_" + wifiParent + "=\"`ifconfig " + wiredDev + " ether`\"", 1);
Utils::setConfFileValue( "/etc/rc.conf", "ifconfig_" + wifiParent, "ifconfig_" + wifiParent + "=\"ether ${ifconfig_" + wifiParent + "##*ether }\"", 2);
Utils::setConfFileValue( "/etc/rc.conf", "wlans_" + wifiParent, "wlans_" + wifiParent + "=\"" + dev + "\"", -1);
wifiConf = wifiConf.simplified();
// Check if we have a WPA setting, and put it in the right device slot
if ( wifiConf.indexOf("WPA") != -1 )
{
newWifiConf="WPA";
wifiConf = wifiConf.replace("WPA", "");
}
// Check if we have a Country code setting, and put it in the right device slot
if ( wifiConf.indexOf("country ") != -1 )
{
tmp = wifiConf;
tmp.remove(0, tmp.lastIndexOf("country") + 8);
tmp = tmp.section(" ", 0,0);
newWifiConf+=" country " + tmp;
wifiConf = wifiConf.remove(wifiConf.indexOf("country"), wifiConf.indexOf("country") + 10 );
}
// Save the new wifi config line
newWifiConf = newWifiConf.simplified();
Utils::setConfFileValue( "/etc/rc.conf", "ifconfig_" + dev, "ifconfig_" + dev + "=\"" + newWifiConf + "\"", -1);
// Set the wired device to UP
Utils::setConfFileValue( "/etc/rc.conf", "ifconfig_" + wiredDev, "ifconfig_" + wiredDev + "=\"UP\"", -1);
// Enable the lagg0 interface
wifiConf = wifiConf.simplified();
Utils::setConfFileValue( "/etc/rc.conf", "cloned_interfaces", "cloned_interfaces=\"lagg0\"", -1);
Utils::setConfFileValue( "/etc/rc.conf", "ifconfig_lagg0", "ifconfig_lagg0=\"laggproto failover laggport " + wiredDev + " laggport " + dev + " " + wifiConf + "\"", -1);
}