/* * Copyright (c) 2023 joshua stein * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __WIFI_H__ #define __WIFI_H__ #include #include "util.h" #define DA_HEIGHT 25 #define DA_WIDTH 180 #define MAIN_MENU_ID 1 #define MAIN_MENU_ABOUT_ID 1 #define MAIN_MENU_QUIT_ID 3 #define PROMPT_DIALOG_ID 1 #define PROMPT_DIALOG_INPUT_FIELD_ID 3 #define PROMPT_DIALOG_PASSWORD_STORAGE_ID 4 #define PROMPT_DIALOG_INPUT_LABEL_ID 5 #define PROMPT_DIALOG_TITLE_LABEL_ID 6 #define ABOUT_DIALOG_ID 2 #define STR_BASE_ID 0 #define STR_FINDING_WIFI_ID 1 #define STR_NO_DEVICE_FOUND_ID 2 #define STR_NO_NETWORK_ID 3 #define STR_OTHER_NETWORK_ID 4 #define STR_DEBUG_LOGS_ID 5 #define STR_CONTINUE_ID 6 #define STR_CANCEL_ID 7 #define STR_SSID_DIALOG_TITLE_ID 8 #define STR_ENTER_SSID_ID 9 #define STR_SSID_ID 10 #define STR_PASSWORD_DIALOG_TITLE_ID 11 #define STR_REQUIRES_PASSWORD_ID 12 #define STR_PASSWORD_ID 13 #define STR_ABOUT_WIFI_ID 14 #define BLUESCSI_NETWORK_WIFI_CMD 0x1c #define BLUESCSI_NETWORK_WIFI_CMD_SCAN 0x01 #define BLUESCSI_NETWORK_WIFI_CMD_COMPLETE 0x02 #define BLUESCSI_NETWORK_WIFI_CMD_SCAN_RESULTS 0x03 #define BLUESCSI_NETWORK_WIFI_CMD_INFO 0x04 #define BLUESCSI_NETWORK_WIFI_CMD_JOIN 0x05 #define hiword(x) (((short *)&(x))[0]) #define loword(x) (((short *)&(x))[1]) typedef short SICN[16]; typedef SICN **SICNHandle; enum state { STATE_CLOSED = 0, STATE_INIT, STATE_FINDING, STATE_SCANNING, STATE_IDLE }; enum signal_icon_id { SIGNAL_NO_DEVICE = 0, SIGNAL_FINDING_DEVICE = 1, SIGNAL_NONE = 2, SIGNAL_1 = 3, SIGNAL_2 = 4, SIGNAL_3 = 5, SIGNAL_4 = 6 }; struct wifi_da { short state; short str_res_id; WindowPtr win; Rect bounds; ControlHandle ssid_list; MenuHandle ssid_menu; Rect ssid_menu_rect; SICNHandle signal_icons; Rect icon_rect; BitMap win_shadow; WindowPtr logger; }; extern struct wifi_da wifi_da; struct wifi_network_entry { char ssid[64]; unsigned char bssid[6]; char rssi; unsigned char channel; unsigned char flags; #define WIFI_NETWORK_FLAG_AUTH (1 << 0) /* our own flag */ #define WIFI_NETWORK_FLAG_HIDDEN (1 << 7) char _padding; }; struct wifi_join_request { char ssid[64]; char key[64]; unsigned char channel; unsigned char _padding; }; extern DCtlPtr dce; extern short wifi_scsi_id; enum { WIFI_SCSI_ID_FINDING = -1, WIFI_SCSI_ID_NONE = -2 }; extern unsigned long wifi_scan_started; extern struct wifi_network_entry wifi_cur_info; #define MAX_WIFI_NETWORKS 10 extern struct wifi_network_entry wifi_scan_networks[MAX_WIFI_NETWORKS]; extern short nwifi_scan_networks; extern Cursor watch; void wifi_about(void); short find_str_res_id(void); void logger_printf(const char *format, ...); void create_window(short ctlrefnum); void update_window(bool force); void update_wifi_cur_info(void); void update_wifi_ssid_list(bool update_networks); void destroy_windows(void); void activate_window(bool activate); void window_mousedown(Point p); short scsi_find_wifi(void); bool scsi_wifi_scan(short lun); bool scsi_wifi_scan_finished(short lun); bool scsi_wifi_info(short lun, struct wifi_network_entry *resp); short scsi_wifi_scan_results(short scsi_id, struct wifi_network_entry *resp, short count); bool scsi_wifi_join(short scsi_id, struct wifi_join_request *wjr); #endif