Diffstat (limited to 'noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc | 46 |
1 files changed, 19 insertions, 27 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc b/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc index 5317f52..ae6d406 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc +++ b/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc | |||
@@ -43,11 +43,8 @@ int get_field(const char *buffer, char *out) | |||
43 | int send_network_found (const char *guihost, int guiport, void *structure) | 43 | int 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]; | 46 | char buffer[2048], temp[5]; |
47 | char temp[128]; | 47 | int len = 0; |
48 | int retval=0, len=0; | ||
49 | |||
50 | memset(temp, 0, sizeof(temp)); | ||
51 | 48 | ||
52 | ptr = (wl_network_t *)structure; | 49 | ptr = (wl_network_t *)structure; |
53 | 50 | ||
@@ -60,27 +57,26 @@ int send_network_found (const char *guihost, int guiport, void *structure) | |||
60 | /* Set Net-type */ | 57 | /* Set Net-type */ |
61 | memset(temp, 0, sizeof(temp)); | 58 | memset(temp, 0, sizeof(temp)); |
62 | snprintf(temp, sizeof(temp), "%d", ptr->net_type); | 59 | snprintf(temp, sizeof(temp), "%d", ptr->net_type); |
63 | retval = add_field(buffer + len, temp, 1); | 60 | len += add_field(buffer + len, temp, 1); |
64 | len += retval; | ||
65 | 61 | ||
66 | /* Set channel */ | 62 | /* Set channel */ |
67 | memset(temp, 0, sizeof(temp)); | 63 | memset(temp, 0, sizeof(temp)); |
68 | snprintf(temp, sizeof(temp), "%.2d", ptr->channel); | 64 | snprintf(temp, sizeof(temp), "%.2d", ptr->channel); |
69 | retval = add_field(buffer + len, temp, 2); | 65 | len += add_field(buffer + len, temp, 2); |
70 | len += retval; | ||
71 | 66 | ||
72 | /* Set WEP y/n */ | 67 | /* Set WEP y/n */ |
73 | memset(temp, 0, sizeof(temp)); | 68 | memset(temp, 0, sizeof(temp)); |
74 | snprintf(temp, sizeof(temp), "%d", ptr->wep); | 69 | snprintf(temp, sizeof(temp), "%d", ptr->wep); |
75 | retval = add_field(buffer + len, temp, 1); | 70 | len += add_field(buffer + len, temp, 1); |
76 | len += retval; | ||
77 | 71 | ||
78 | /* Set Mac */ | 72 | /* Set Mac */ |
79 | retval = add_field(buffer + len, ptr->mac, 17); | 73 | len += add_field(buffer + len, ptr->mac, 17); |
80 | len += retval; | ||
81 | 74 | ||
82 | /* Set ssid */ | 75 | /* Set ssid */ |
83 | retval = add_field(buffer + len, ptr->bssid, ptr->ssid_len); | 76 | if(len + ptr->ssid_len < sizeof(buffer) - 1) |
77 | len += add_field(buffer + len, ptr->bssid, ptr->ssid_len); | ||
78 | else | ||
79 | len += add_field(buffer + len, ptr->bssid, sizeof(buffer) - len - 1); | ||
84 | 80 | ||
85 | /* Send prepared buffer to UI */ | 81 | /* Send prepared buffer to UI */ |
86 | #ifdef DEBUG | 82 | #ifdef DEBUG |
@@ -94,38 +90,34 @@ int send_network_found (const char *guihost, int guiport, void *structure) | |||
94 | int get_network_found (void *structure, const char *buffer) | 90 | int get_network_found (void *structure, const char *buffer) |
95 | { | 91 | { |
96 | wl_network_t *ptr; | 92 | wl_network_t *ptr; |
97 | char temp[512]; | 93 | char temp[5]; |
98 | int retval=0, len=0; | 94 | int len = 0; |
99 | 95 | ||
100 | ptr = (wl_network_t *)structure; | 96 | ptr = (wl_network_t *)structure; |
101 | 97 | ||
102 | /* packet type already determined */ | 98 | /* packet type already determined, skip check */ |
103 | len += 2; | 99 | len += 2; |
104 | 100 | ||
105 | /* Get net type */ | 101 | /* Get net type (accesspoint || ad-hoc || ...) */ |
106 | memset(temp, 0, sizeof(temp)); | 102 | memset(temp, 0, sizeof(temp)); |
107 | retval = get_field(buffer + len, temp); | 103 | len += get_field(buffer + len, temp); |
108 | len += retval; | ||
109 | ptr->net_type = atoi(temp); | 104 | ptr->net_type = atoi(temp); |
110 | 105 | ||
111 | /* Get channel */ | 106 | /* Get channel */ |
112 | memset(temp, 0, sizeof(temp)); | 107 | memset(temp, 0, sizeof(temp)); |
113 | retval = get_field(buffer + len, temp); | 108 | len += get_field(buffer + len, temp); |
114 | len += retval; | ||
115 | ptr->channel = atoi(temp); | 109 | ptr->channel = atoi(temp); |
116 | 110 | ||
117 | /* Set WEP y/n */ | 111 | /* Set WEP y/n */ |
118 | memset(temp, 0, sizeof(temp)); | 112 | memset(temp, 0, sizeof(temp)); |
119 | retval = get_field(buffer + len, temp); | 113 | len += get_field(buffer + len, temp); |
120 | len += retval; | ||
121 | ptr->wep = atoi(temp); | 114 | ptr->wep = atoi(temp); |
122 | 115 | ||
123 | /* Set MAC address */ | 116 | /* Set MAC address */ |
124 | retval = get_field(buffer + len, ptr->mac); | 117 | len += get_field(buffer + len, ptr->mac); |
125 | len += retval; | ||
126 | 118 | ||
127 | /* Set BSSID */ | 119 | /* Set BSSID */ |
128 | retval = get_field(buffer + len, ptr->bssid); | 120 | len += get_field(buffer + len, ptr->bssid); |
129 | 121 | ||
130 | return 1; | 122 | return 1; |
131 | } | 123 | } |