author | mjm <mjm> | 2002-11-27 21:17:27 (UTC) |
---|---|---|
committer | mjm <mjm> | 2002-11-27 21:17:27 (UTC) |
commit | 5092fbe20ceade42de6fb37b2ca1d1cd935bcf2a (patch) (unidiff) | |
tree | cd7a2c28a74e2537a596373c95723a532f5cacac /noncore/net | |
parent | e16163a106d5f814e9774f6a630cdb2ee488a616 (diff) | |
download | opie-5092fbe20ceade42de6fb37b2ca1d1cd935bcf2a.zip opie-5092fbe20ceade42de6fb37b2ca1d1cd935bcf2a.tar.gz opie-5092fbe20ceade42de6fb37b2ca1d1cd935bcf2a.tar.bz2 |
wrote protocol, at least some kind of
-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/source/proto.cc | 104 | ||||
-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/source/proto.hh | 28 |
2 files changed, 132 insertions, 0 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/proto.cc b/noncore/net/wellenreiter/libwellenreiter/source/proto.cc new file mode 100644 index 0000000..359bdb5 --- a/dev/null +++ b/noncore/net/wellenreiter/libwellenreiter/source/proto.cc | |||
@@ -0,0 +1,104 @@ | |||
1 | /* | ||
2 | * Communication protocol | ||
3 | * | ||
4 | * $Id$ | ||
5 | */ | ||
6 | |||
7 | #include "proto.hh" | ||
8 | #include "sock.hh" | ||
9 | |||
10 | /* Send found network to GUI */ | ||
11 | int send_network_found (const char *guihost, int guiport, void *structure) | ||
12 | { | ||
13 | wl_network_t *ptr; | ||
14 | char buffer[2048]; | ||
15 | char temp[4]; | ||
16 | |||
17 | ptr = (wl_network_t *)structure; | ||
18 | |||
19 | memset(buffer, 0, 2048); | ||
20 | |||
21 | /* Type = Found new net */ | ||
22 | memcpy(buffer, "01", 2); | ||
23 | |||
24 | /* Set Net-type */ | ||
25 | memset(temp, 0, sizeof(temp)); | ||
26 | snprintf(temp, 2, "%d", ptr->net_type); | ||
27 | memcpy(buffer + 2, temp, 1); | ||
28 | |||
29 | /* Set channel */ | ||
30 | memset(temp, 0, sizeof(temp)); | ||
31 | |||
32 | if(ptr->channel < 10) | ||
33 | snprintf(temp, 3, "0%d", ptr->channel); | ||
34 | else | ||
35 | snprintf(temp, 3, "%d", ptr->channel); | ||
36 | |||
37 | memcpy(buffer + 3, temp, 2); | ||
38 | |||
39 | /* Set WEP y/n */ | ||
40 | memset(temp, 0, sizeof(temp)); | ||
41 | snprintf(temp, 2, "%d", ptr->wep); | ||
42 | memcpy(buffer + 5, temp, 1); | ||
43 | |||
44 | /* Set MAC address */ | ||
45 | memcpy(buffer + 6, ptr->mac, 17); | ||
46 | |||
47 | /* Set lenght of ssid */ | ||
48 | memset(temp, 0, sizeof(temp)); | ||
49 | |||
50 | if(ptr->ssid_len > 99) | ||
51 | snprintf(temp, 4, "%d", ptr->ssid_len); | ||
52 | else if(ptr->ssid_len < 10) | ||
53 | snprintf(temp, 4, "00%d", ptr->ssid_len); | ||
54 | else | ||
55 | snprintf(temp, 4, "0%d", ptr->ssid_len); | ||
56 | |||
57 | memcpy(buffer + 23, temp, 3); | ||
58 | |||
59 | /* Set ssid */ | ||
60 | memcpy(buffer + 26, ptr->bssid, ptr->ssid_len); | ||
61 | |||
62 | /* Send prepared buffer to GUI */ | ||
63 | sendcomm(guihost, guiport, buffer); | ||
64 | |||
65 | return 1; | ||
66 | } | ||
67 | |||
68 | /* Fill buffer into structur */ | ||
69 | int get_network_found (void *structure, const char *buffer) | ||
70 | { | ||
71 | wl_network_t *ptr; | ||
72 | char temp[512]; | ||
73 | |||
74 | ptr = (wl_network_t *)structure; | ||
75 | |||
76 | /* Get net type */ | ||
77 | memset(temp, 0, sizeof(temp)); | ||
78 | memcpy(temp, buffer + 2, 1); | ||
79 | ptr->net_type = atoi(temp); | ||
80 | |||
81 | /* Get channel */ | ||
82 | memset(temp, 0, sizeof(temp)); | ||
83 | memcpy(temp, buffer + 3, 2); | ||
84 | ptr->channel = atoi(temp); | ||
85 | |||
86 | /* Set WEP y/n */ | ||
87 | memset(temp, 0, sizeof(temp)); | ||
88 | memcpy(temp, buffer + 5, 1); | ||
89 | ptr->wep = atoi(temp); | ||
90 | |||
91 | /* Set MAC address */ | ||
92 | memcpy(ptr->mac, buffer + 6, 17); | ||
93 | ptr->mac[17]='\0'; | ||
94 | |||
95 | /* Set lenght of ssid */ | ||
96 | memset(temp, 0, sizeof(temp)); | ||
97 | memcpy(temp, buffer + 23, 3); | ||
98 | ptr->ssid_len = atoi(temp); | ||
99 | |||
100 | /* Set ssid */ | ||
101 | memcpy(ptr->bssid, buffer + 26, ptr->ssid_len + 1); | ||
102 | |||
103 | return 1; | ||
104 | } | ||
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/proto.hh b/noncore/net/wellenreiter/libwellenreiter/source/proto.hh new file mode 100644 index 0000000..e3e9f50 --- a/dev/null +++ b/noncore/net/wellenreiter/libwellenreiter/source/proto.hh | |||
@@ -0,0 +1,28 @@ | |||
1 | /* $Id$ */ | ||
2 | |||
3 | #ifndef PROTO_HH | ||
4 | #define PROTO_HH | ||
5 | |||
6 | #include <stdio.h> | ||
7 | #include <string.h> | ||
8 | #include <stdlib.h> | ||
9 | |||
10 | /* Type definitions, to be continued */ | ||
11 | #define NETFOUND 01 | ||
12 | #define NETLOST 02 | ||
13 | #define STARTSNIFF 98 | ||
14 | #define STOPSNIFF 99 | ||
15 | |||
16 | int send_network_found (const char *, int, void *); | ||
17 | int get_network_found (void *, const char *); | ||
18 | |||
19 | typedef struct { | ||
20 | int net_type; /* 1 = Accesspoint ; 2 = Ad-Hoc */ | ||
21 | int ssid_len; /* Length of SSID */ | ||
22 | int channel; /* Channel */ | ||
23 | int wep; /* 1 = WEP enabled ; 0 = disabled */ | ||
24 | char mac[64]; /* MAC address of Accesspoint */ | ||
25 | char bssid[128]; /* BSSID of Accesspoint */ | ||
26 | } wl_network_t; | ||
27 | |||
28 | #endif /* PROTO_HH */ | ||