[tuxdroid-svn] r441 - daemon/trunk/libs
Status: Beta
Brought to you by:
ks156
From: neimad <c2m...@c2...> - 2007-06-24 16:20:10
|
Author: neimad Date: 2007-06-24 18:19:37 +0200 (Sun, 24 Jun 2007) New Revision: 441 Modified: daemon/trunk/libs/USBDaemon_command_tux.c Log: * wifi_channel is an int; no point in using unsigned char. * Added check in avoid_wifi_channel() to ensure the given wifi channel is in the valid range. Modified: daemon/trunk/libs/USBDaemon_command_tux.c =================================================================== --- daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-24 14:56:03 UTC (rev 440) +++ daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-24 16:19:37 UTC (rev 441) @@ -48,7 +48,7 @@ static int id_lookup(uint16_t *id); static int change_id(uint16_t id); static int wakeup_tux(const uint16_t id); -static int avoid_wifi_channel(unsigned char wifi_channel); +static int avoid_wifi_channel(int wifi_channel); static int random_tux_connection(void); static void sub_daemon_cmd_struct(unsigned char const data[], @@ -727,7 +727,7 @@ result[1] = TUX_CONNECTION_NACK; break; case TUX_CONNECTION_WIRELESS_CHANNEL: - if (avoid_wifi_channel(data[1]) >= 0) + if (avoid_wifi_channel(data[1]) == 0) result[1] = TUX_CONNECTION_ACK; else result[1] = TUX_CONNECTION_NACK; @@ -1034,7 +1034,7 @@ * * \return 0 if successful, -1 otherwise */ -static int avoid_wifi_channel(unsigned char wifi_channel) +static int avoid_wifi_channel(int wifi_channel) { /* * Conversion of the lower and higher frequencies of a wifi channel into @@ -1046,6 +1046,9 @@ static const uint8_t higher_ATR_channel[15] = {2, 26, 32, 38, 43, 49, 55, 61, 67, 72, 78, 84, 90, 92, 92}; + if (wifi_channel < 0 || wifi_channel > 14) + return -1; + if (send_usb_dongle_cmd(USB_TUX_CONNECTION_CMD, USB_TUX_CONNECTION_CHANGE_ID, lower_ATR_channel[wifi_channel], higher_ATR_channel[wifi_channel]) == USB_FRAME_SIZE) |