-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
75 lines (63 loc) · 1.77 KB
/
main.c
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
#include <stdio.h>
#include "KernelConnector.h"
#include "Commands.h"
#include <string.h>
#include <errno.h>
int main(void)
{
char ssid[256];
char passwd[256];
int code;
char is_encrypted;
printf("1-Connect, 2-Disconnect, 3-AP List: ");
scanf("%d", &code);
switch (code)
{
case COM_JOIN: {
printf("SSID: ");
scanf("%s", ssid);
fflush(stdin);
do
{
printf("Does it have password? (Y/N): ");
scanf("%c", &is_encrypted);
} while (is_encrypted != 'Y' && is_encrypted != 'N'
&& is_encrypted != 'y' && is_encrypted != 'n');
switch (is_encrypted)
{
case 'Y':
case 'y':
printf("Password: ");
scanf("%s", passwd);
break;
case 'N':
case 'n':
passwd[0] = '\0';
break;
}
int a = send_join_ssid(ssid, passwd);
printf("%s", strerror(a));
break;
}
case COM_DISCON: {
int a = send_disconnect();
printf("%s", strerror(a));
break;
}
case COM_GETLIST: {
struct node_data_ary ary;
int a = get_nodes(&ary);
if (a)
printf("%s", strerror(a));
else
{
for (int i=0; i<ary.len; i++)
{
struct node_data *node = ary.node + i;
printf("SSID: %-30s\tBSSID: %s\tRSSI: %d\n", node->essid, node->bssid, node->rssi);
}
}
}
}
return 0;
}