mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Parse mac addresses in one place.
This commit is contained in:
parent
ade18848f7
commit
c83a7e0029
7 changed files with 68 additions and 54 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
// TODO: Add license
|
||||||
|
|
||||||
|
#include "util/text/parsers.h"
|
||||||
#include "proAdhoc.h"
|
#include "proAdhoc.h"
|
||||||
|
|
||||||
uint32_t fakePoolSize = 0;
|
uint32_t fakePoolSize = 0;
|
||||||
|
@ -499,10 +502,12 @@ int getLocalIp(sockaddr_in * SocketAddress){
|
||||||
}
|
}
|
||||||
|
|
||||||
void getLocalMac(SceNetEtherAddr * addr){
|
void getLocalMac(SceNetEtherAddr * addr){
|
||||||
//MAC Adress from config
|
// Read MAC Address from config
|
||||||
uint8_t mac[ETHER_ADDR_LEN];
|
uint8_t mac[ETHER_ADDR_LEN] = {0};
|
||||||
sscanf(g_Config.localMacAddress.c_str(), "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",&mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
|
if (!ParseMacAddress(g_Config.localMacAddress.c_str(), mac)) {
|
||||||
memcpy(addr,mac,ETHER_ADDR_LEN);
|
ERROR_LOG(SCENET, "Error parsing mac address %s", g_Config.localMacAddress.c_str());
|
||||||
|
}
|
||||||
|
memcpy(addr, mac, ETHER_ADDR_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
int getPTPSocketCount(void) {
|
int getPTPSocketCount(void) {
|
||||||
|
|
|
@ -1,27 +1,19 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Common/ChunkFile.h"
|
#include "base/timeutil.h"
|
||||||
#include "../Config.h"
|
#include "base/mutex.h"
|
||||||
#include "Core/HLE/HLE.h"
|
#include "thread/thread.h"
|
||||||
#include "../CoreTiming.h"
|
|
||||||
#include "Core/HLE/sceNetAdhoc.h"
|
|
||||||
#include "native/base/timeutil.h"
|
|
||||||
#include "native/base/mutex.h"
|
|
||||||
#include "native/thread/thread.h"
|
|
||||||
|
|
||||||
#include "sceKernel.h"
|
|
||||||
#include "sceKernelThread.h"
|
|
||||||
#include "sceKernelMutex.h"
|
|
||||||
#include "sceUtility.h"
|
|
||||||
#include "net/resolve.h"
|
#include "net/resolve.h"
|
||||||
|
|
||||||
/*
|
#include "Common/ChunkFile.h"
|
||||||
#ifdef _MSC_VER
|
#include "Core/Config.h"
|
||||||
#include <thread.h>
|
#include "Core/CoreTiming.h"
|
||||||
#else
|
#include "Core/HLE/HLE.h"
|
||||||
#include <thread>
|
#include "Core/HLE/sceNetAdhoc.h"
|
||||||
#endif
|
#include "Core/HLE/sceKernel.h"
|
||||||
*/
|
#include "Core/HLE/sceKernelThread.h"
|
||||||
|
#include "Core/HLE/sceKernelMutex.h"
|
||||||
|
#include "Core/HLE/sceUtility.h"
|
||||||
|
|
||||||
// Net stuff
|
// Net stuff
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
|
@ -15,18 +15,19 @@
|
||||||
// Official git repository and contact information can be found at
|
// Official git repository and contact information can be found at
|
||||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||||
|
|
||||||
|
#include "net/resolve.h"
|
||||||
|
#include "util/text/parsers.h"
|
||||||
|
|
||||||
#include "Common/ChunkFile.h"
|
#include "Common/ChunkFile.h"
|
||||||
#include "HLE.h"
|
#include "Core/HLE/HLE.h"
|
||||||
#include "../MIPS/MIPS.h"
|
#include "Core/MIPS/MIPS.h"
|
||||||
#include "../Config.h"
|
#include "Core/Config.h"
|
||||||
|
|
||||||
#include "sceKernel.h"
|
#include "sceKernel.h"
|
||||||
#include "sceKernelThread.h"
|
#include "sceKernelThread.h"
|
||||||
#include "sceKernelMutex.h"
|
#include "sceKernelMutex.h"
|
||||||
#include "sceUtility.h"
|
#include "sceUtility.h"
|
||||||
|
|
||||||
#include "net/resolve.h"
|
|
||||||
|
|
||||||
static bool netInited;
|
static bool netInited;
|
||||||
static bool netInetInited;
|
static bool netInetInited;
|
||||||
static bool netApctlInited;
|
static bool netApctlInited;
|
||||||
|
@ -131,13 +132,14 @@ u32 sceNetTerm() {
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 sceWlanGetEtherAddr(u32 addrAddr) {
|
u32 sceWlanGetEtherAddr(u32 addrAddr) {
|
||||||
//MAC Adress from config
|
// Read MAC Address from config
|
||||||
uint8_t mac[6];
|
uint8_t mac[6] = {0};
|
||||||
sscanf(g_Config.localMacAddress.c_str(), "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",&mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
|
if (!ParseMacAddress(g_Config.localMacAddress.c_str(), mac)) {
|
||||||
|
ERROR_LOG(SCENET, "Error parsing mac address %s", g_Config.localMacAddress.c_str());
|
||||||
|
}
|
||||||
DEBUG_LOG(SCENET, "sceWlanGetEtherAddr(%08x)", addrAddr);
|
DEBUG_LOG(SCENET, "sceWlanGetEtherAddr(%08x)", addrAddr);
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
Memory::Write_U8(mac[i], addrAddr + i);
|
Memory::Write_U8(mac[i], addrAddr + i);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
native
2
native
|
@ -1 +1 @@
|
||||||
Subproject commit 26821c5f9f30d4afd381e4a78a013b611707e740
|
Subproject commit 26eaba2157a44338e6c085065ca0471b2b4dea7d
|
|
@ -34,6 +34,7 @@
|
||||||
#include "Common/ArmEmitter.h"
|
#include "Common/ArmEmitter.h"
|
||||||
#include "ext/disarm.h"
|
#include "ext/disarm.h"
|
||||||
#include "math/math_util.h"
|
#include "math/math_util.h"
|
||||||
|
#include "util/text/parsers.h"
|
||||||
|
|
||||||
#define EXPECT_TRUE(a) if (!(a)) { printf(__FUNCTION__ ":%i: Test Fail\n", __LINE__); return false; }
|
#define EXPECT_TRUE(a) if (!(a)) { printf(__FUNCTION__ ":%i: Test Fail\n", __LINE__); return false; }
|
||||||
#define EXPECT_FALSE(a) if ((a)) { printf(__FUNCTION__ ":%i: Test Fail\n", __LINE__); return false; }
|
#define EXPECT_FALSE(a) if ((a)) { printf(__FUNCTION__ ":%i: Test Fail\n", __LINE__); return false; }
|
||||||
|
@ -107,9 +108,23 @@ bool TestMathUtil() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TestParsers() {
|
||||||
|
const char *macstr = "01:02:03:ff:fe:fd";
|
||||||
|
uint8_t mac[6];
|
||||||
|
ParseMacAddress(macstr, mac);
|
||||||
|
EXPECT_TRUE(mac[0] == 1);
|
||||||
|
EXPECT_TRUE(mac[1] == 2);
|
||||||
|
EXPECT_TRUE(mac[2] == 3);
|
||||||
|
EXPECT_TRUE(mac[3] == 255);
|
||||||
|
EXPECT_TRUE(mac[4] == 254);
|
||||||
|
EXPECT_TRUE(mac[5] == 253);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, const char *argv[])
|
int main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
TestArmEmitter();
|
TestArmEmitter();
|
||||||
TestMathUtil();
|
TestMathUtil();
|
||||||
|
TestParsers();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue