mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
Use a function to check for loopback address
This commit is contained in:
parent
3a83b96f1a
commit
e3228ca1b5
@ -1897,6 +1897,10 @@ bool isPrivateIP(uint32_t ip) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isLoopbackIP(uint32_t ip) {
|
||||
return ((uint8_t*)&ip)[0] == 0x7f;
|
||||
}
|
||||
|
||||
void getLocalMac(SceNetEtherAddr * addr){
|
||||
// Read MAC Address from config
|
||||
uint8_t mac[ETHER_ADDR_LEN] = {0};
|
||||
@ -2143,8 +2147,9 @@ int initNetwork(SceNetAdhocctlAdhocId *adhoc_id){
|
||||
|
||||
// If Server is at localhost Try to Bind socket to specific adapter before connecting to prevent 2nd instance being recognized as already existing 127.0.0.1 by AdhocServer
|
||||
// (may not works in WinXP/2003 for IPv4 due to "Weak End System" model)
|
||||
if (((uint8_t*)&g_adhocServerIP.in.sin_addr.s_addr)[0] == 0x7f) { // (serverIp.S_un.S_un_b.s_b1 == 0x7f)
|
||||
if (isLoopbackIP(g_adhocServerIP.in.sin_addr.s_addr)) {
|
||||
int on = 1;
|
||||
// Not sure what is this SO_DONTROUTE supposed to fix, but i do remembered there were issue related to multiple-instances without SO_DONTROUTE, but forgot how to reproduce it :(
|
||||
setsockopt(metasocket, SOL_SOCKET, SO_DONTROUTE, (const char*)&on, sizeof(on));
|
||||
setSockReuseAddrPort(metasocket);
|
||||
|
||||
|
@ -1279,6 +1279,11 @@ uint32_t getLocalIp(int sock);
|
||||
*/
|
||||
bool isPrivateIP(uint32_t ip);
|
||||
|
||||
/*
|
||||
* Check if an IP (big-endian/network order) is Loopback IP
|
||||
*/
|
||||
bool isLoopbackIP(uint32_t ip);
|
||||
|
||||
/*
|
||||
* Get Number of bytes available in buffer to be Received
|
||||
* @param sock fd
|
||||
|
Loading…
Reference in New Issue
Block a user