summaryrefslogtreecommitdiff
authormjm <mjm>2002-12-28 15:40:30 (UTC)
committer mjm <mjm>2002-12-28 15:40:30 (UTC)
commitb8ade08c754775d594192e79f33ea9ecc1a3686c (patch) (unidiff)
tree9037709b052c04b7c9aab6a645cf7bcb020fc82b
parent94ac3da47b0b36316cff680d319dab23c9339308 (diff)
downloadopie-b8ade08c754775d594192e79f33ea9ecc1a3686c.zip
opie-b8ade08c754775d594192e79f33ea9ecc1a3686c.tar.gz
opie-b8ade08c754775d594192e79f33ea9ecc1a3686c.tar.bz2
stupidity error
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc b/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc
index ae6d406..3d5a923 100644
--- a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc
+++ b/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc
@@ -1,123 +1,123 @@
1/* 1/*
2 * Communication protocol 2 * Communication protocol
3 * 3 *
4 * $Id$ 4 * $Id$
5 */ 5 */
6 6
7#include "wl_proto.hh" 7#include "wl_proto.hh"
8#include "wl_log.hh" 8#include "wl_log.hh"
9#include "wl_sock.hh" 9#include "wl_sock.hh"
10 10
11/* Adds a field to the buffer */ 11/* Adds a field to the buffer */
12int add_field(char *buffer, char *string, int len) 12int add_field(char *buffer, char *string, int len)
13{ 13{
14 char newlen[5]; 14 char newlen[5];
15 15
16 /* 3 Byte = Length */ 16 /* 3 Byte = Length */
17 snprintf(newlen, sizeof(newlen) - 1, "%.3d", len); 17 snprintf(newlen, sizeof(newlen) - 1, "%.3d", len);
18 memcpy(buffer, newlen, 3); 18 memcpy(buffer, newlen, 3);
19 19
20 /* Length bytes = Value */ 20 /* Length bytes = Value */
21 memcpy(buffer + 3, string, atoi(newlen)); 21 memcpy(buffer + 3, string, atoi(newlen));
22 22
23 /* Return length of attached field */ 23 /* Return length of attached field */
24 return (atoi(newlen) + 3); 24 return (atoi(newlen) + 3);
25} 25}
26 26
27int get_field(const char *buffer, char *out) 27int get_field(const char *buffer, char *out)
28{ 28{
29 char len[5]; 29 char len[5];
30 30
31 /* Get length of value */ 31 /* Get length of value */
32 memcpy(len, buffer, 3); 32 memcpy(len, buffer, 3);
33 33
34 /* Copy buffer to out pointer */ 34 /* Copy buffer to out pointer */
35 memset(out, 0, atoi(len) + 1); 35 memset(out, 0, atoi(len) + 1);
36 memcpy(out, buffer + 3, atoi(len)); 36 memcpy(out, buffer + 3, atoi(len));
37 37
38 /* Return length of whole field (including 3 byte length) */ 38 /* Return length of whole field (including 3 byte length) */
39 return (atoi(len) + 3); 39 return (atoi(len) + 3);
40} 40}
41 41
42/* Send found network to UI */ 42/* Send found network to UI */
43int send_network_found (const char *guihost, int guiport, void *structure) 43int send_network_found (const char *guihost, int guiport, void *structure)
44{ 44{
45 wl_network_t *ptr; 45 wl_network_t *ptr;
46 char buffer[2048], temp[5]; 46 char buffer[2048], temp[5];
47 int len = 0; 47 unsigned int len = 0;
48 48
49 ptr = (wl_network_t *)structure; 49 ptr = (wl_network_t *)structure;
50 50
51 /* Type = Found new net (without length field) */ 51 /* Type = Found new net (without length field) */
52 memset(temp, 0, sizeof(temp)); 52 memset(temp, 0, sizeof(temp));
53 snprintf(temp, sizeof(temp), "%.2d", NETFOUND); 53 snprintf(temp, sizeof(temp), "%.2d", NETFOUND);
54 memcpy(buffer, temp, 2); 54 memcpy(buffer, temp, 2);
55 len += 2; 55 len += 2;
56 56
57 /* Set Net-type */ 57 /* Set Net-type */
58 memset(temp, 0, sizeof(temp)); 58 memset(temp, 0, sizeof(temp));
59 snprintf(temp, sizeof(temp), "%d", ptr->net_type); 59 snprintf(temp, sizeof(temp), "%d", ptr->net_type);
60 len += add_field(buffer + len, temp, 1); 60 len += add_field(buffer + len, temp, 1);
61 61
62 /* Set channel */ 62 /* Set channel */
63 memset(temp, 0, sizeof(temp)); 63 memset(temp, 0, sizeof(temp));
64 snprintf(temp, sizeof(temp), "%.2d", ptr->channel); 64 snprintf(temp, sizeof(temp), "%.2d", ptr->channel);
65 len += add_field(buffer + len, temp, 2); 65 len += add_field(buffer + len, temp, 2);
66 66
67 /* Set WEP y/n */ 67 /* Set WEP y/n */
68 memset(temp, 0, sizeof(temp)); 68 memset(temp, 0, sizeof(temp));
69 snprintf(temp, sizeof(temp), "%d", ptr->wep); 69 snprintf(temp, sizeof(temp), "%d", ptr->wep);
70 len += add_field(buffer + len, temp, 1); 70 len += add_field(buffer + len, temp, 1);
71 71
72 /* Set Mac */ 72 /* Set Mac */
73 len += add_field(buffer + len, ptr->mac, 17); 73 len += add_field(buffer + len, ptr->mac, 17);
74 74
75 /* Set ssid */ 75 /* Set ssid */
76 if(len + ptr->ssid_len < sizeof(buffer) - 1) 76 if(len + ptr->ssid_len < sizeof(buffer) - 1)
77 len += add_field(buffer + len, ptr->bssid, ptr->ssid_len); 77 len += add_field(buffer + len, ptr->bssid, ptr->ssid_len);
78 else 78 else
79 len += add_field(buffer + len, ptr->bssid, sizeof(buffer) - len - 1); 79 len += add_field(buffer + len, ptr->bssid, sizeof(buffer) - len - 1);
80 80
81 /* Send prepared buffer to UI */ 81 /* Send prepared buffer to UI */
82#ifdef DEBUG 82#ifdef DEBUG
83 wl_loginfo("Sending network to UI: '%s'", buffer); 83 wl_loginfo("Sending network to UI: '%s'", buffer);
84#endif 84#endif
85 85
86 return ((!wl_send(guihost, guiport, buffer)) ? 0 : 1); 86 return ((!wl_send(guihost, guiport, buffer)) ? 0 : 1);
87} 87}
88 88
89/* Fill buffer into structur */ 89/* Fill buffer into structur */
90int get_network_found (void *structure, const char *buffer) 90int get_network_found (void *structure, const char *buffer)
91{ 91{
92 wl_network_t *ptr; 92 wl_network_t *ptr;
93 char temp[5]; 93 char temp[5];
94 int len = 0; 94 unsigned int len = 0;
95 95
96 ptr = (wl_network_t *)structure; 96 ptr = (wl_network_t *)structure;
97 97
98 /* packet type already determined, skip check */ 98 /* packet type already determined, skip check */
99 len += 2; 99 len += 2;
100 100
101 /* Get net type (accesspoint || ad-hoc || ...) */ 101 /* Get net type (accesspoint || ad-hoc || ...) */
102 memset(temp, 0, sizeof(temp)); 102 memset(temp, 0, sizeof(temp));
103 len += get_field(buffer + len, temp); 103 len += get_field(buffer + len, temp);
104 ptr->net_type = atoi(temp); 104 ptr->net_type = atoi(temp);
105 105
106 /* Get channel */ 106 /* Get channel */
107 memset(temp, 0, sizeof(temp)); 107 memset(temp, 0, sizeof(temp));
108 len += get_field(buffer + len, temp); 108 len += get_field(buffer + len, temp);
109 ptr->channel = atoi(temp); 109 ptr->channel = atoi(temp);
110 110
111 /* Set WEP y/n */ 111 /* Set WEP y/n */
112 memset(temp, 0, sizeof(temp)); 112 memset(temp, 0, sizeof(temp));
113 len += get_field(buffer + len, temp); 113 len += get_field(buffer + len, temp);
114 ptr->wep = atoi(temp); 114 ptr->wep = atoi(temp);
115 115
116 /* Set MAC address */ 116 /* Set MAC address */
117 len += get_field(buffer + len, ptr->mac); 117 len += get_field(buffer + len, ptr->mac);
118 118
119 /* Set BSSID */ 119 /* Set BSSID */
120 len += get_field(buffer + len, ptr->bssid); 120 len += get_field(buffer + len, ptr->bssid);
121 121
122 return 1; 122 return 1;
123} 123}