-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPInformation.cpp
More file actions
88 lines (76 loc) · 1.43 KB
/
Copy pathAPInformation.cpp
File metadata and controls
88 lines (76 loc) · 1.43 KB
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
/*
* APInformation.cpp
*
*/
#include "APInformation.h"
using namespace std;
void APInformation::SetAPInformation(int type, string value) {
switch (type) {
case AP_ID:
m_ID.assign(value);
break;
case AP_IP:
m_IP.assign(value);
break;
case AP_SSID:
break;
case AP_DESCRIPTION:
break;
default:
break;
}
}
string APInformation::GetAPInformation(int type) {
switch (type) {
case AP_ID:
return m_ID;
case AP_IP:
return m_IP;
case AP_SSID:
return m_SSID;
case AP_DESCRIPTION:
return m_Description;
default:
break;
}
}
void APInformation::UpdateAPInformation(){
FILE *fp;
char buf[64];
string output;
string temp;
// Get ID
fp = popen("ifconfig br-lan | grep HWaddr", "r");
while (!feof(fp)) {
fread(buf, 1, 64, fp);
}
temp.assign(buf);
output = temp.substr(temp.find("HWaddr")+7, 17);
m_ID = output;
output.clear();
temp.clear();
pclose(fp);
// Get IP
fp = popen("ifconfig br-lan | grep inet", "r");
fread(buf, 1, 64, fp);
temp.assign(buf);
output = temp.substr(temp.find("addr:")+5);
output.erase(output.find(" "));
m_IP = output;
output.clear();
temp.clear();
pclose(fp);
// Get SSID
fp = popen("uci get wireless.@wifi-iface[0].ssid", "r");
while (!feof(fp)) {
fread(buf, 1, 64, fp);
}
temp.assign(buf);
output = temp.substr(0, temp.find('\n'));
m_SSID = output;
output.clear();
temp.clear();
pclose(fp);
//For Description
m_Description.assign("Test date: 2015.10.18");
}