-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from LiquidFenrir/fixrestore
Huge rewrite, fix restoring
- Loading branch information
Showing
23 changed files
with
661 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2017 LiquidFenrir | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# WifiManager | ||
|
||
WifiManager is a simple 3ds homebrew meant to help you backup and restore your console's WiFi slots. | ||
It could prove useful if you travel a lot and need to connect to new wifi networks all the time, or if only 3 slots is really too few for you. | ||
|
||
## CRC | ||
|
||
WifiManager uses `include/checksum.h` and `src/crc16.c` from [libcrc 2.0](https://github.com/lammertb/libcrc/tree/v2.0) by lammertb, licensed under the MIT license, which were modified to remove the functions and data unused by this application. | ||
|
||
# License | ||
|
||
WifiManager is licensed under the MIT license, a copy of which can be found in the `LICENSE.txt` file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#pragma once | ||
|
||
#include <3ds.h> | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
#include <string.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "blocks.h" | ||
#include "checksum.h" | ||
|
||
Result getWifiSlot(int selected_slot, wifiBlock * slotData) | ||
{ | ||
Result ret = CFG_GetConfigInfoBlk8(CFG_WIFI_SLOT_SIZE, CFG_WIFI_BLKID+selected_slot, (u8*)slotData); | ||
if (ret) printf("CFG_GetConfigInfoBlk8\nresult: 0x%.8lx\n", ret); | ||
return ret; | ||
} | ||
|
||
Result setWifiSlot(int selected_slot, wifiBlock * slotData) | ||
{ | ||
Result ret = CFG_SetConfigInfoBlk8(CFG_WIFI_SLOT_SIZE, CFG_WIFI_BLKID+selected_slot, (u8*)slotData); | ||
if (ret) printf("CFG_GetConfigInfoBlk8\nresult: 0x%.8lx\n", ret); | ||
return ret; | ||
} | ||
|
||
void fixSlotCRC(wifiBlock * slotData) | ||
{ | ||
printf("Previous CRC-16 checksum: %.4X\n", slotData->checksum); | ||
slotData->checksum = crc_16((u8*)(&(slotData->network)), 0x410); | ||
printf("New CRC-16 checksum: %.4X\n", slotData->checksum); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#pragma once | ||
|
||
#include "basic.h" | ||
|
||
#define CFG_WIFI_BLKID (u32 )0x00080000 | ||
#define CFG_WIFI_SLOTS 3 | ||
#define CFG_WIFI_SLOT_SIZE (u32 )0xC00 | ||
|
||
typedef struct { | ||
bool exists; | ||
bool use; | ||
bool second; | ||
u8 padding1; | ||
char SSID[0x20]; | ||
u8 SSID_length; | ||
u8 AP_encryption_type; | ||
u16 padding2; | ||
char password[0x40]; //plaintext, blank for a network set up with WPS | ||
u8 passwordPSK[0x20]; | ||
} networkStruct; | ||
|
||
typedef struct { | ||
bool exists; | ||
u8 padding1; | ||
u16 checksum; //crc-16 of the next 0x410 bytes, with initval 0: https://github.com/lammertb/libcrc/blob/v2.0/src/crc16.c#L43-L76 | ||
//if the network is set "normally", 'use' is 1 | ||
//if the network is set by WPS, 'use' is 0 | ||
//'second' is 0 | ||
//if setting multiple networks with WPS in the same session, only the last set will have this. others will have completely 0x00 except for 'exists' | ||
networkStruct network; | ||
u8 padding2[0x20]; | ||
//completely 0x00 if the network was set "normally", otherwise (set by WPS) normal but 'use' and 'second' are 1 | ||
networkStruct network_WPS; | ||
u8 padding3[0x20C]; | ||
|
||
bool auto_obtain_IP; //defaults to 1 | ||
bool auto_obtain_DNS; //defaults to 1 | ||
u16 padding4; | ||
|
||
u8 IP_address[4]; | ||
u8 gateway_address[4]; | ||
u8 subnet_mask[4]; | ||
|
||
u8 primary_DNS[4]; | ||
u8 secondary_DNS[4]; | ||
|
||
// if setting multiple networks in the same session, only the last set will have these. others will have completely 0x00 | ||
u8 unk1[4]; | ||
u8 IP_to_use[4]; | ||
u8 MAC_address[6]; | ||
u8 channel; | ||
u8 padding5; | ||
|
||
bool use_proxy; //defaults to 0 | ||
bool basic_authentication; //defaults to 0 | ||
u16 port_number; //defaults to 1 | ||
char proxy_address[0x30]; //including ending nullbyte | ||
u8 padding6[0x34]; | ||
char proxy_username[0x20]; //including ending nullbyte | ||
char proxy_password[0x20]; //including ending nullbyte | ||
u16 padding7; | ||
u16 MTU_value; //defaults to 1400, range [576;1500] | ||
|
||
//nothing beyond this point (0x414), but each slot is 0xC00 big... | ||
u8 padding8[0x7EC]; | ||
} wifiBlock; | ||
|
||
Result getWifiSlot(int selected_slot, wifiBlock * slotData); | ||
Result setWifiSlot(int selected_slot, wifiBlock * slotData); | ||
|
||
void fixSlotCRC(wifiBlock * slotData); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Library: libcrc | ||
* File: include/checksum.h | ||
* Author: Lammert Bies | ||
* | ||
* This file is licensed under the MIT License as stated below | ||
* | ||
* Copyright (c) 1999-2016 Lammert Bies | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
* | ||
* Description | ||
* ----------- | ||
* The headerfile include/checksum.h contains the definitions and prototypes | ||
* for routines that can be used to calculate several kinds of checksums. | ||
*/ | ||
|
||
#ifndef DEF_LIBCRC_CHECKSUM_H | ||
#define DEF_LIBCRC_CHECKSUM_H | ||
|
||
#include <stdint.h> | ||
|
||
/* | ||
* #define CRC_POLY_xxxx | ||
* | ||
* The constants of the form CRC_POLY_xxxx define the polynomials for some well | ||
* known CRC calculations. | ||
*/ | ||
|
||
#define CRC_POLY_16 0xA001 | ||
|
||
/* | ||
* #define CRC_START_xxxx | ||
* | ||
* The constants of the form CRC_START_xxxx define the values that are used for | ||
* initialization of a CRC value for common used calculation methods. | ||
*/ | ||
|
||
#define CRC_START_16 0x0000 | ||
|
||
/* | ||
* Prototype list of global functions | ||
*/ | ||
|
||
uint16_t crc_16( const unsigned char *input_str, size_t num_bytes ); | ||
|
||
#endif // DEF_LIBCRC_CHECKSUM_H |
Oops, something went wrong.