mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
Parse mac addresses in one place.
This commit is contained in:
parent
ade18848f7
commit
c83a7e0029
@ -295,8 +295,8 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
|
||||
|
||||
IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam");
|
||||
pspConfig->Get("NickName", &sNickName, "PPSSPP");
|
||||
pspConfig->Get("proAdhocServer", &proAdhocServer, "localhost");
|
||||
pspConfig->Get("MacAddress", &localMacAddress, "01:02:03:04:05:06");
|
||||
pspConfig->Get("proAdhocServer", &proAdhocServer, "localhost");
|
||||
pspConfig->Get("MacAddress", &localMacAddress, "01:02:03:04:05:06");
|
||||
pspConfig->Get("Language", &iLanguage, PSP_SYSTEMPARAM_LANGUAGE_ENGLISH);
|
||||
pspConfig->Get("TimeFormat", &iTimeFormat, PSP_SYSTEMPARAM_TIME_FORMAT_24HR);
|
||||
pspConfig->Get("DateFormat", &iDateFormat, PSP_SYSTEMPARAM_DATE_FORMAT_YYYYMMDD);
|
||||
|
@ -201,8 +201,8 @@ public:
|
||||
|
||||
// SystemParam
|
||||
std::string sNickName;
|
||||
std::string proAdhocServer;
|
||||
std::string localMacAddress;
|
||||
std::string proAdhocServer;
|
||||
std::string localMacAddress;
|
||||
int iLanguage;
|
||||
int iTimeFormat;
|
||||
int iDateFormat;
|
||||
|
@ -1,3 +1,6 @@
|
||||
// TODO: Add license
|
||||
|
||||
#include "util/text/parsers.h"
|
||||
#include "proAdhoc.h"
|
||||
|
||||
uint32_t fakePoolSize = 0;
|
||||
@ -478,31 +481,33 @@ int getActivePeerCount(void) {
|
||||
|
||||
int getLocalIp(sockaddr_in * SocketAddress){
|
||||
#ifdef _MSC_VER
|
||||
// Get local host name
|
||||
char szHostName[128] = "";
|
||||
// Get local host name
|
||||
char szHostName[128] = "";
|
||||
|
||||
if(::gethostname(szHostName, sizeof(szHostName))) {
|
||||
// Error handling
|
||||
}
|
||||
// Get local IP addresses
|
||||
struct hostent *pHost = 0;
|
||||
pHost = ::gethostbyname(szHostName);
|
||||
if(pHost) {
|
||||
memcpy(&SocketAddress->sin_addr, pHost->h_addr_list[0], pHost->h_length);
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
if(::gethostname(szHostName, sizeof(szHostName))) {
|
||||
// Error handling
|
||||
}
|
||||
// Get local IP addresses
|
||||
struct hostent *pHost = 0;
|
||||
pHost = ::gethostbyname(szHostName);
|
||||
if(pHost) {
|
||||
memcpy(&SocketAddress->sin_addr, pHost->h_addr_list[0], pHost->h_length);
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
#else
|
||||
SocketAddress->sin_addr.s_addr = inet_addr("192.168.12.1");
|
||||
return 0;
|
||||
SocketAddress->sin_addr.s_addr = inet_addr("192.168.12.1");
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void getLocalMac(SceNetEtherAddr * addr){
|
||||
//MAC Adress from config
|
||||
uint8_t mac[ETHER_ADDR_LEN];
|
||||
sscanf(g_Config.localMacAddress.c_str(), "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",&mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
|
||||
memcpy(addr,mac,ETHER_ADDR_LEN);
|
||||
// Read MAC Address from config
|
||||
uint8_t mac[ETHER_ADDR_LEN] = {0};
|
||||
if (!ParseMacAddress(g_Config.localMacAddress.c_str(), mac)) {
|
||||
ERROR_LOG(SCENET, "Error parsing mac address %s", g_Config.localMacAddress.c_str());
|
||||
}
|
||||
memcpy(addr, mac, ETHER_ADDR_LEN);
|
||||
}
|
||||
|
||||
int getPTPSocketCount(void) {
|
||||
|
@ -1,27 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "Common/ChunkFile.h"
|
||||
#include "../Config.h"
|
||||
#include "Core/HLE/HLE.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 "base/timeutil.h"
|
||||
#include "base/mutex.h"
|
||||
#include "thread/thread.h"
|
||||
#include "net/resolve.h"
|
||||
|
||||
/*
|
||||
#ifdef _MSC_VER
|
||||
#include <thread.h>
|
||||
#else
|
||||
#include <thread>
|
||||
#endif
|
||||
*/
|
||||
#include "Common/ChunkFile.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/CoreTiming.h"
|
||||
#include "Core/HLE/HLE.h"
|
||||
#include "Core/HLE/sceNetAdhoc.h"
|
||||
#include "Core/HLE/sceKernel.h"
|
||||
#include "Core/HLE/sceKernelThread.h"
|
||||
#include "Core/HLE/sceKernelMutex.h"
|
||||
#include "Core/HLE/sceUtility.h"
|
||||
|
||||
// Net stuff
|
||||
#ifdef _MSC_VER
|
||||
|
@ -15,18 +15,19 @@
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include "net/resolve.h"
|
||||
#include "util/text/parsers.h"
|
||||
|
||||
#include "Common/ChunkFile.h"
|
||||
#include "HLE.h"
|
||||
#include "../MIPS/MIPS.h"
|
||||
#include "../Config.h"
|
||||
#include "Core/HLE/HLE.h"
|
||||
#include "Core/MIPS/MIPS.h"
|
||||
#include "Core/Config.h"
|
||||
|
||||
#include "sceKernel.h"
|
||||
#include "sceKernelThread.h"
|
||||
#include "sceKernelMutex.h"
|
||||
#include "sceUtility.h"
|
||||
|
||||
#include "net/resolve.h"
|
||||
|
||||
static bool netInited;
|
||||
static bool netInetInited;
|
||||
static bool netApctlInited;
|
||||
@ -131,13 +132,14 @@ u32 sceNetTerm() {
|
||||
}
|
||||
|
||||
u32 sceWlanGetEtherAddr(u32 addrAddr) {
|
||||
//MAC Adress from config
|
||||
uint8_t mac[6];
|
||||
sscanf(g_Config.localMacAddress.c_str(), "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",&mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
|
||||
// Read MAC Address from config
|
||||
uint8_t mac[6] = {0};
|
||||
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);
|
||||
for (int i = 0; i < 6; i++)
|
||||
Memory::Write_U8(mac[i], addrAddr + i);
|
||||
|
||||
Memory::Write_U8(mac[i], addrAddr + i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
2
native
2
native
@ -1 +1 @@
|
||||
Subproject commit 26821c5f9f30d4afd381e4a78a013b611707e740
|
||||
Subproject commit 26eaba2157a44338e6c085065ca0471b2b4dea7d
|
@ -34,6 +34,7 @@
|
||||
#include "Common/ArmEmitter.h"
|
||||
#include "ext/disarm.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_FALSE(a) if ((a)) { printf(__FUNCTION__ ":%i: Test Fail\n", __LINE__); return false; }
|
||||
@ -107,9 +108,23 @@ bool TestMathUtil() {
|
||||
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[])
|
||||
{
|
||||
TestArmEmitter();
|
||||
TestMathUtil();
|
||||
TestParsers();
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user