/dev/net/wd/command: Difference between revisions
Clarified note about sending frames in illegal states, added wd_scanparam struct. |
Removed wd_scan_input. |
||
Line 55: | Line 55: | ||
|- | |- | ||
| 0x100A | | 0x100A | ||
| 1 | | 1 | ||
| 1 | | 1 | ||
| WD_Scan | | WD_Scan | ||
Line 93: | Line 93: | ||
WD_Scan input | WD_Scan input buffer: | ||
<source lang="c"> | <source lang="c"> | ||
typedef struct _wd_scanparam | typedef struct _wd_scanparam//size 0x60 bytes | ||
{ | { | ||
u16 channelBitmap; | u16 channelBitmap; |
Revision as of 23:44, 28 May 2009
This device in the wd driver is responsible for managing configuration of the driver, probably mostly to handle communications with the Nintendo DS (e.g. downloading demos).
Ioctl | Inputs | Outputs | Function |
---|---|---|---|
0x1001 | 0 | 0 | WD_GetState |
0x1002 | 1 | 0 | WD_SetLinkState |
0x1003 | 0 | 0 | WD_GetStatus |
0x1004 | 3 | 0 | WD_SetConfig |
0x1005 | 3 | 0 | WD_GetConfig |
0x1006 | 2 | 0 | ? |
0x1007 | 1 | 0 | ? |
0x1008 | 2 | 0 | ? |
0x1009 | 1 | 0 | send frame? |
0x100A | 1 | 1 | WD_Scan |
0x100C | ? | ? | switch to raw mode? |
0x100E | 0 | 1 (0x90 bytes) | GetInfo ? |
0x100F | ? | ? | ? |
0x1010 | 1 | 0 | ? |
0x8000 | 0 | 1 | ? |
0x8001 | 0 | 1 | ? |
WD_Scan input buffer:
typedef struct _wd_scanparam//size 0x60 bytes
{
u16 channelBitmap;
u16 maxChannelTime;
u16 unk4;
u16 unk6;
u16 unk8;
u16 scanType;//only 0/1 permitted.
u16 ssidLength;
char ssid[32];//?
u8 unk[32];
} wd_scanparam;
s32 WD_SetConfig(wd_config *config, u32 flags1, u32 flags0); flags0 | flags1 must be non-zero. Each bit in the flags corresponds to a field or struct in config. The associated bits and fields/structs are listed in the below wd_config struct. If clear, nothing is done for that field/struct, otherwise the field/struct may be verified; not all are verified. All bits and their associated fields/structs are verified,(if they have verification code) before updating the internal configuration. WD_GetConfig is similar to WD_SetConfig, except the configuration from the internal config is copied to the input wd_config structure based on the flags.
WD_GetState always returns a value less than 7 and greater than 1. WD_GetState should always return state 3, any other states are illegal states. Frames can't be sent with ioctl 0x1009 in illegal states. WD_GetStatus returns 0 or 1, depending on different flags for each state. For state 3, this returns 0 when wireless is disabled, 1 when enabled. Ioctl 0x1009 input is a buffer/len pair.
Configuration and info structs:
//wd_privacy and wd_config fields are little-endian.
typedef struct _wd_privacy//When verified, only the mode and keyId/keyLen are verified. Size 72 bytes.
{
u16 mode;//0 = None, 1 = WEP40, 2 = WEP104, 3 = invalid mode, 4 = WPA-PSK(TKIP), 5 = WPA2-PSK(AES), 6 = WPA-PSK(AES)
u16 unk;
union//mode and keyId/keyLen are verified when flags0 bit 20 is set.
{
//mode 0 is none.
struct//mode 1
{
u16 keyId;//Must be less than 4.
}wep40;
struct//mode 2
{
u16 keyId;//Must be less than 4.
}wep104;
//mode 3 is an invalid mode.
struct//mode 5/6
{
u16 keyLen;//Must be in range 8-64.
}aes;
struct//mode 4
{
u16 keyLen;//Must be in range 8-64.
}tkip;
};
u8 unkpriva1[66];
} wd_privacy;
typedef struct _wd_config//size 384 bytes.
{
u16 diversityMode;//flags0 bit 0. Antenna diversity. Can't be greater than 1. Debug for 0: "OFF, use a antenna MAIN", debug for 1: "OFF, use a antenna SUB".
u16 useAntenna;//flags0 bit 1. Must be less than 2; 0 or 1.
u16 shortRetryLimit;//flags0 bit 2. Must be no larger than 255.
u16 longRetryLimit;//flags0 bit 3. Must be no larger than 255.
u16 unk4;//flags0 bit 4.
u16 rtsThreshold;//flags0 bit 5. Must be greater than 0.
u16 fragThreshold;//flags0 bit 6. Must be greater than 0.
u16 supportRateSet;//flags0 bit 7. First 20 bits must not be all zero.
u16 basicRateSet;//flags0 bit 8. First 20 bits must not be all zero.
u16 enable_channel;//? flags0 bit 9. Current channel?
struct
{
wd_privacy essSta_privacy;//flags0 bit 20.
char ssid[32];//? flags0 bit 16.
u8 unka2[32];//flags0 bit 17.
u8 ssidLength;//flags0 bit 18. must be less than 33.
u8 unka;//flags0 bit 21, not checked.
u16 maxChannelTime;//flags0 bit 19. Must not be less than 1000.
u8 bssid[6];//?
u8 somemac[6];//?
} essSta;//Infrastructure?
struct
{
u16 connectionTimeout;//flags 1 fields start here. Must be larger than 0.
u16 beaconPeriod;//Must be greater than 1000.
u8 maxNodes;//Must be less than 16.
u8 authAlgorithm;//Must be less than 2. 0 = Open, 1 = Shared.
u16 unk1_4;//unk field 4 of flags 1 fields.
u8 channel;//Not verified if 0, but when non-zero, must be an available Nitro Allowed Channel. See _wd_info.ntr_allowed_channels.
u8 unka4[131];
wd_privacy mpParent_privacy;//Mode 3, tkip, and aes crypto modes are removed, leaving only modes none, WEP40, and WEP104.
} mpParent;//Ad-Hoc?
} wd_config;
typedef struct _wd_info
{
u8 mac[6];
u16 ntr_allowed_channels;//Bit 0 is unused. Bit 1 means channel 1 is available, and so on.
u8 filler[136];
} wd_info;
WD Errors
Error code | POSIX equivalent | Notes |
---|---|---|
-2147450879 | EINVAL | Invalid input |