Line 1:
Line 1:
−
This device in the wd driver is repsonsible for managing configuration of the driver, probably mostly to handle communications with the Nintendo DS (e.g. downloading demos).
+
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).
Line 20:
Line 20:
|-
|-
| 0x1004
| 0x1004
−
| 2
+
| 3
| 0
| 0
−
| set config?
+
| WD_SetConfig
|-
|-
| 0x1006
| 0x1006
Line 93:
Line 93:
};
};
</source>
</source>
+
+
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.
+
+
Configuration and info structs:
+
<source lang="c">
+
//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;
+
</source>
+
+
== WD Errors ==
+
{| class="wikitable"
+
|-
+
! Error code
+
! POSIX equivalent
+
! Notes
+
|-
+
| -2147450879
+
| EINVAL
+
| Invalid input
+
|}