Download
jcs
/wifi_da
/wi-fi.h
(View History)
jcs wi-fi: Turn debugging back off | Latest amendment: 31 on 2024-09-19 |
1 | /* |
2 | * Copyright (c) 2023 joshua stein <jcs@jcs.org> |
3 | * |
4 | * Permission to use, copy, modify, and distribute this software for any |
5 | * purpose with or without fee is hereby granted, provided that the above |
6 | * copyright notice and this permission notice appear in all copies. |
7 | * |
8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
15 | */ |
16 | |
17 | #ifndef __WIFI_H__ |
18 | #define __WIFI_H__ |
19 | |
20 | #include <stdlib.h> |
21 | #include "util.h" |
22 | |
23 | /* disable in production */ |
24 | //#define DEBUG_LOGGING 1 |
25 | |
26 | #define MAIN_MENU_ID 1 |
27 | #define MAIN_MENU_ABOUT_ID 1 |
28 | #define MAIN_MENU_QUIT_ID 3 |
29 | |
30 | #define ERROR_DIALOG_ID 0 |
31 | |
32 | #define PASSWORD_DIALOG_ID 1 |
33 | #define PASSWORD_DIALOG_PASSWORD_FIELD_ID 3 |
34 | #define PASSWORD_DIALOG_PASSWORD_STORAGE_ID 4 |
35 | |
36 | #define ABOUT_DIALOG_ID 2 |
37 | |
38 | #define SSID_DIALOG_ID 3 |
39 | #define SSID_DIALOG_NAME_FIELD_ID 3 |
40 | |
41 | #define BLUESCSI_NETWORK_WIFI_CMD 0x1c |
42 | #define BLUESCSI_NETWORK_WIFI_CMD_SCAN 0x01 |
43 | #define BLUESCSI_NETWORK_WIFI_CMD_COMPLETE 0x02 |
44 | #define BLUESCSI_NETWORK_WIFI_CMD_SCAN_RESULTS 0x03 |
45 | #define BLUESCSI_NETWORK_WIFI_CMD_INFO 0x04 |
46 | #define BLUESCSI_NETWORK_WIFI_CMD_JOIN 0x05 |
47 | |
48 | #define hiword(x) (((short *)&(x))[0]) |
49 | #define loword(x) (((short *)&(x))[1]) |
50 | |
51 | typedef short SICN[16]; |
52 | typedef SICN **SICNHandle; |
53 | |
54 | enum state { |
55 | STATE_CLOSED, |
56 | STATE_INIT, |
57 | STATE_FINDING, |
58 | STATE_SCANNING, |
59 | STATE_IDLE |
60 | }; |
61 | extern short da_state; |
62 | |
63 | enum signal_icon_id { |
64 | SIGNAL_NO_DEVICE = 0, |
65 | SIGNAL_FINDING_DEVICE = 1, |
66 | SIGNAL_NONE = 2, |
67 | SIGNAL_1 = 3, |
68 | SIGNAL_2 = 4, |
69 | SIGNAL_3 = 5, |
70 | SIGNAL_4 = 6 |
71 | }; |
72 | |
73 | struct wifi_network_entry { |
74 | char ssid[64]; |
75 | unsigned char bssid[6]; |
76 | char rssi; |
77 | unsigned char channel; |
78 | unsigned char flags; |
79 | #define WIFI_NETWORK_FLAG_AUTH (1 << 1) |
80 | #define WIFI_NETWORK_FLAG_HIDDEN (1 << 2) |
81 | char _padding; |
82 | }; |
83 | |
84 | struct wifi_join_request { |
85 | char ssid[64]; |
86 | char key[64]; |
87 | unsigned char channel; |
88 | unsigned char _padding; |
89 | }; |
90 | |
91 | extern WindowPtr win; |
92 | extern DCtlPtr dce; |
93 | |
94 | extern short wifi_scsi_id; |
95 | enum { |
96 | WIFI_SCSI_ID_FINDING = -1, |
97 | WIFI_SCSI_ID_NONE = -2 |
98 | }; |
99 | extern unsigned long wifi_scan_started; |
100 | extern struct wifi_network_entry wifi_cur_info; |
101 | extern struct wifi_network_entry wifi_scan_networks[10]; |
102 | extern short nwifi_scan_networks; |
103 | extern Cursor watch; |
104 | |
105 | void wifi_about(void); |
106 | |
107 | #if DEBUG_LOGGING |
108 | #define DEBUG_LOG(args) logger_printf args |
109 | void logger_printf(const char *format, ...); |
110 | #else |
111 | #define DEBUG_LOG(args) ((void)0) |
112 | #endif |
113 | |
114 | WindowPtr create_window(short ctlrefnum); |
115 | void update_window(bool force); |
116 | void update_wifi_cur_info(void); |
117 | void update_wifi_ssid_list(bool update_networks); |
118 | void destroy_window(void); |
119 | void activate_window(bool activate); |
120 | void window_mousedown(Point p); |
121 | |
122 | short scsi_find_wifi(void); |
123 | bool scsi_wifi_scan(short lun); |
124 | bool scsi_wifi_scan_finished(short lun); |
125 | bool scsi_wifi_info(short lun, struct wifi_network_entry *resp); |
126 | short scsi_wifi_scan_results(short scsi_id, |
127 | struct wifi_network_entry *resp, short count); |
128 | bool scsi_wifi_join(short scsi_id, struct wifi_join_request *wjr); |
129 | |
130 | #endif |