network.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. #ifndef NETWORK_H
  17. #define NETWORK_H
  18. #ifdef BLUESCSI_NETWORK
  19. #include <sys/types.h>
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. #define SCSI_NETWORK_WIFI_CMD 0x1c // cdb opcode
  24. #define SCSI_NETWORK_WIFI_CMD_SCAN 0x01 // cdb[2]
  25. #define SCSI_NETWORK_WIFI_CMD_COMPLETE 0x02
  26. #define SCSI_NETWORK_WIFI_CMD_SCAN_RESULTS 0x03
  27. #define SCSI_NETWORK_WIFI_CMD_INFO 0x04
  28. #define SCSI_NETWORK_WIFI_CMD_JOIN 0x05
  29. // Patches to make the DaynaPORT (or whats left of it) work on the Amiga - RobSmithDev
  30. #define SCSI_NETWORK_WIFI_CMD_ALTREAD 0x08 // gvpscsi.device on AMIGA doesnt like the standard version
  31. #define SCSI_NETWORK_WIFI_CMD_GETMACADDRESS 0x09 // gvpscsi.device on AMIGA doesnt like the standard version
  32. #define AMIGASCSI_PATCH_24BYTE_BLOCKSIZE 0xA8 // In this mode, data written is rounded up to the nearest 24-byte boundary
  33. #define AMIGASCSI_PATCH_SINGLEWRITE_ONLY 0xA9 // In this mode, data written is always ONLY as one single write command
  34. #ifndef NETWORK_PACKET_QUEUE_SIZE
  35. # define NETWORK_PACKET_QUEUE_SIZE 20 // must be <= 255
  36. #endif
  37. #define NETWORK_PACKET_MAX_SIZE 1520
  38. struct __attribute__((packed)) wifi_network_entry {
  39. char ssid[64];
  40. char bssid[6];
  41. int8_t rssi;
  42. uint8_t channel;
  43. uint8_t flags;
  44. #define WIFI_NETWORK_FLAG_AUTH 0x1
  45. uint8_t _padding;
  46. };
  47. #define WIFI_NETWORK_LIST_ENTRY_COUNT 10
  48. extern struct wifi_network_entry wifi_network_list[WIFI_NETWORK_LIST_ENTRY_COUNT];
  49. struct __attribute__((packed)) wifi_join_request {
  50. char ssid[64];
  51. char key[64];
  52. uint8_t channel;
  53. uint8_t _padding;
  54. };
  55. int scsiNetworkCommand(void);
  56. int scsiNetworkEnqueue(const uint8_t *buf, size_t len);
  57. int scsiNetworkPurge(void);
  58. #ifdef __cplusplus
  59. }
  60. #endif
  61. #endif // BLUESCSI_NETWORK
  62. #endif // NETWORK_H