mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Add a new "Net" log category, do assorted cleanup
This commit is contained in:
1 parent
64c7da1253
commit
95ce95e489
8 files changed
+78
-68
No files matched your search
@@ -58,6 +58,7 @@ enum class Log {
|
||||
UI,
|
||||
IAP,
|
||||
CwCheats,
|
||||
Net, // Non-sce related networking logs.
|
||||
|
||||
sceAudio,
|
||||
sceCtrl,
|
||||
|
||||
@@ -97,6 +97,7 @@ static const char * const g_logTypeNames[] = {
|
||||
"UI",
|
||||
"IAP",
|
||||
"CWCHEATS",
|
||||
"NET",
|
||||
"SCEAUDIO",
|
||||
"SCECTRL",
|
||||
"SCEDISP",
|
||||
|
||||
@@ -96,20 +96,20 @@ std::shared_ptr<Request> RequestManager::StartDownload(std::string_view url, con
|
||||
// to modify the calling code.
|
||||
std::string contents;
|
||||
if (File::ReadBinaryFileToString(cacheFile, &contents)) {
|
||||
INFO_LOG(Log::sceNet, "Returning cached file for %.*s: %s", (int)url.size(), url.data(), cacheFile.c_str());
|
||||
INFO_LOG(Log::HTTP, "Returning cached file for %.*s: %s", (int)url.size(), url.data(), cacheFile.c_str());
|
||||
// All is well, but we've indented a bit much here.
|
||||
std::shared_ptr<Request> dl(new CachedRequest(RequestMethod::GET, url, KeepAfterLast(url, '/'), nullptr, flags, contents));
|
||||
newDownloads_.push_back(dl);
|
||||
dl->SetCallback(callback);
|
||||
return dl;
|
||||
} else {
|
||||
INFO_LOG(Log::sceNet, "Failed reading from cache, proceeding with request");
|
||||
INFO_LOG(Log::HTTP, "Failed reading from cache, proceeding with request");
|
||||
}
|
||||
} else {
|
||||
INFO_LOG(Log::sceNet, "Cached file too old, proceeding with request");
|
||||
INFO_LOG(Log::HTTP, "Cached file too old, proceeding with request");
|
||||
}
|
||||
} else {
|
||||
INFO_LOG(Log::sceNet, "Failed to check time modified. Proceeding with request.");
|
||||
INFO_LOG(Log::HTTP, "Failed to check time modified. Proceeding with request.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ class Buffer : public ::Buffer {
|
||||
public:
|
||||
bool FlushSocket(uintptr_t sock, double timeout, bool *cancelled = nullptr);
|
||||
|
||||
// If you know the size of the file to read, pass it in knownSize, for best performance and for progress reporting.
|
||||
bool ReadAllWithProgress(int fd, int knownSize, RequestProgress *progress);
|
||||
|
||||
// < 0: error
|
||||
@@ -30,4 +31,4 @@ public:
|
||||
int Read(int fd, size_t sz);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace net
|
||||
+28
-33
@@ -33,7 +33,7 @@ void Init() {
|
||||
// WSA does its own internal reference counting, no need to keep track of if we inited or not.
|
||||
WSADATA wsaData{};
|
||||
if (FAILED(WSAStartup(MAKEWORD(2, 2), &wsaData))) {
|
||||
ERROR_LOG(Log::sceNet, "WSAStartup failed");
|
||||
ERROR_LOG(Log::Net, "WSAStartup failed");
|
||||
} else {
|
||||
g_wsaInitialized = true;
|
||||
}
|
||||
@@ -59,10 +59,6 @@ void Shutdown() {
|
||||
#endif
|
||||
}
|
||||
|
||||
// This checks whether a TCP connection to host : port can be established within a given timeout.
|
||||
// It does this by attempting a new, non - blocking TCP connect() and waiting for it to succeed or time out.
|
||||
// The socket is closed immediately after the check.
|
||||
// It does not inspect or detect existing connections from other applications; it only tests reachability by making its own connection attempt.
|
||||
bool HostPortExists(const std::string &host, int port, int timeout_ms) {
|
||||
if (host.empty() || (port <= 0 || port > 65535) || timeout_ms < 0) return false;
|
||||
|
||||
@@ -254,8 +250,7 @@ bool DNSResolve(const std::string &host, const std::string &service, addrinfo **
|
||||
return true;
|
||||
}
|
||||
|
||||
void DNSResolveFree(addrinfo *res)
|
||||
{
|
||||
void DNSResolveFree(addrinfo *res) {
|
||||
if (res)
|
||||
freeaddrinfo(res);
|
||||
}
|
||||
@@ -264,7 +259,7 @@ bool GetLocalIP4List(std::vector<std::string> &IP4s) {
|
||||
char ipstr[INET6_ADDRSTRLEN]; // We use IPv6 length since it's longer than IPv4
|
||||
// getifaddrs first appeared in glibc 2.3, On Android officially supported since __ANDROID_API__ >= 24
|
||||
#if defined(_IFADDRS_H_) || (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3) || (__ANDROID_API__ >= 24)
|
||||
INFO_LOG(Log::sceNet, "GetIPList from getifaddrs");
|
||||
INFO_LOG(Log::Net, "GetIPList from getifaddrs");
|
||||
struct ifaddrs* ifAddrStruct = NULL;
|
||||
struct ifaddrs* ifa = NULL;
|
||||
|
||||
@@ -292,7 +287,7 @@ bool GetLocalIP4List(std::vector<std::string> &IP4s) {
|
||||
return true;
|
||||
}
|
||||
#elif defined(SIOCGIFCONF) // Better detection on Linux/UNIX/MacOS/some Android
|
||||
INFO_LOG(Log::IO, "GetIPList from SIOCGIFCONF");
|
||||
INFO_LOG(Log::Net, "GetIPList from SIOCGIFCONF");
|
||||
static struct ifreq ifreqs[32];
|
||||
struct ifconf ifc{};
|
||||
ifc.ifc_req = ifreqs;
|
||||
@@ -300,13 +295,13 @@ bool GetLocalIP4List(std::vector<std::string> &IP4s) {
|
||||
|
||||
int sd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (sd < 0) {
|
||||
ERROR_LOG(Log::IO, "GetIPList failed to create socket (result = %i, errno = %i)", sd, socket_errno);
|
||||
ERROR_LOG(Log::Net, "GetIPList failed to create socket (result = %i, errno = %i)", sd, socket_errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
int r = ioctl(sd, SIOCGIFCONF, (char*)&ifc);
|
||||
if (r != 0) {
|
||||
ERROR_LOG(Log::IO, "GetIPList failed ioctl/SIOCGIFCONF (result = %i, errno = %i)", r, socket_errno);
|
||||
ERROR_LOG(Log::Net, "GetIPList failed ioctl/SIOCGIFCONF (result = %i, errno = %i)", r, socket_errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -322,7 +317,7 @@ bool GetLocalIP4List(std::vector<std::string> &IP4s) {
|
||||
r = ioctl(sd, SIOCGIFADDR, item);
|
||||
if (r != 0)
|
||||
{
|
||||
ERROR_LOG(Log::IO, "GetIPList failed ioctl/SIOCGIFADDR (i = %i, result = %i, errno = %i)", i, r, socket_errno);
|
||||
ERROR_LOG(Log::Net, "GetIPList failed ioctl/SIOCGIFADDR (i = %i, result = %i, errno = %i)", i, r, socket_errno);
|
||||
}
|
||||
|
||||
if (ifreqs[i].ifr_addr.sa_family == AF_INET) {
|
||||
@@ -342,7 +337,7 @@ bool GetLocalIP4List(std::vector<std::string> &IP4s) {
|
||||
close(sd);
|
||||
return true;
|
||||
#else // Fallback to POSIX/Cross-platform way but may not work well on Linux (ie. only shows 127.0.0.1)
|
||||
DEBUG_LOG(Log::IO, "GetIPList from fallback method");
|
||||
DEBUG_LOG(Log::Net, "GetIPList from fallback method");
|
||||
struct addrinfo hints, * res, * p;
|
||||
memset(&hints, 0, sizeof hints);
|
||||
hints.ai_family = AF_UNSPEC; // AF_INET or AF_INET6 to force version
|
||||
@@ -498,13 +493,13 @@ static bool parse_dns_response(unsigned char *buffer, size_t response_len, uint3
|
||||
DNSHeader *dns = (DNSHeader *)buffer;
|
||||
unsigned char *ptr = buffer + sizeof(struct DNSHeader);
|
||||
|
||||
DEBUG_LOG(Log::sceNet, "DNS Response:");
|
||||
DEBUG_LOG(Log::sceNet, "ID: 0x%x", ntohs(dns->id));
|
||||
DEBUG_LOG(Log::sceNet, "Flags: 0x%x", ntohs(dns->flags));
|
||||
DEBUG_LOG(Log::sceNet, "Questions: %d", ntohs(dns->q_count));
|
||||
DEBUG_LOG(Log::sceNet, "Answers: %d", ntohs(dns->ans_count));
|
||||
DEBUG_LOG(Log::sceNet, "Authority Records: %d", ntohs(dns->auth_count));
|
||||
DEBUG_LOG(Log::sceNet, "Additional Records: %d", ntohs(dns->add_count));
|
||||
DEBUG_LOG(Log::Net, "DNS Response:");
|
||||
DEBUG_LOG(Log::Net, "ID: 0x%x", ntohs(dns->id));
|
||||
DEBUG_LOG(Log::Net, "Flags: 0x%x", ntohs(dns->flags));
|
||||
DEBUG_LOG(Log::Net, "Questions: %d", ntohs(dns->q_count));
|
||||
DEBUG_LOG(Log::Net, "Answers: %d", ntohs(dns->ans_count));
|
||||
DEBUG_LOG(Log::Net, "Authority Records: %d", ntohs(dns->auth_count));
|
||||
DEBUG_LOG(Log::Net, "Additional Records: %d", ntohs(dns->add_count));
|
||||
|
||||
// Skip over the question section
|
||||
const int q_count = ntohs(dns->q_count);
|
||||
@@ -520,7 +515,7 @@ static bool parse_dns_response(unsigned char *buffer, size_t response_len, uint3
|
||||
// Parse the answer section
|
||||
const int ans_count = ntohs(dns->ans_count);
|
||||
for (int i = 0; i < ans_count; i++) {
|
||||
DEBUG_LOG(Log::sceNet, "Answer %d:\n", i + 1);
|
||||
DEBUG_LOG(Log::Net, "Answer %d:\n", i + 1);
|
||||
|
||||
// Skip the name (can be a pointer or a sequence)
|
||||
if ((*ptr & 0xC0) == 0xC0) {
|
||||
@@ -540,16 +535,16 @@ static bool parse_dns_response(unsigned char *buffer, size_t response_len, uint3
|
||||
uint16_t data_len = ntohs(*((uint16_t *)ptr));
|
||||
ptr += 2;
|
||||
|
||||
DEBUG_LOG(Log::sceNet, " Type: %d", type);
|
||||
DEBUG_LOG(Log::sceNet, " Class: %d", clazz);
|
||||
DEBUG_LOG(Log::sceNet, " TTL: %u", ttl);
|
||||
DEBUG_LOG(Log::sceNet, " Data length: %d", (int)data_len);
|
||||
DEBUG_LOG(Log::Net, " Type: %d", type);
|
||||
DEBUG_LOG(Log::Net, " Class: %d", clazz);
|
||||
DEBUG_LOG(Log::Net, " TTL: %u", ttl);
|
||||
DEBUG_LOG(Log::Net, " Data length: %d", (int)data_len);
|
||||
|
||||
if (type == DNS_QUERY_TYPE_A && data_len == 4) {
|
||||
// IPv4 address
|
||||
char ip[INET_ADDRSTRLEN];
|
||||
inet_ntop(AF_INET, ptr, ip, sizeof(ip));
|
||||
DEBUG_LOG(Log::sceNet, " IPV4 Address: %s", ip);
|
||||
DEBUG_LOG(Log::Net, " IPV4 Address: %s", ip);
|
||||
memcpy(output, ptr, 4);
|
||||
// Skipping further responses.
|
||||
return true;
|
||||
@@ -571,12 +566,12 @@ static std::map<std::string, DNSCacheEntry> g_directDNSCache;
|
||||
|
||||
bool DirectDNSLookupIPV4(const char *dns_server_ip, const char *domain, uint32_t *ipv4_addr) {
|
||||
if (!strlen(dns_server_ip)) {
|
||||
WARN_LOG(Log::sceNet, "Direct lookup: DNS server not specified");
|
||||
WARN_LOG(Log::Net, "Direct lookup: DNS server not specified");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!strlen(domain)) {
|
||||
ERROR_LOG(Log::sceNet, "Direct lookup: Can't look up an empty domain");
|
||||
ERROR_LOG(Log::Net, "Direct lookup: Can't look up an empty domain");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -584,7 +579,7 @@ bool DirectDNSLookupIPV4(const char *dns_server_ip, const char *domain, uint32_t
|
||||
|
||||
auto iter = g_directDNSCache.find(key);
|
||||
if (iter != g_directDNSCache.end()) {
|
||||
INFO_LOG(Log::sceNet, "Returning cached response from direct DNS request for '%s' to DNS server '%s", domain, dns_server_ip);
|
||||
INFO_LOG(Log::Net, "Returning cached response from direct DNS request for '%s' to DNS server '%s", domain, dns_server_ip);
|
||||
*ipv4_addr = iter->second.ipv4Address;
|
||||
return true;
|
||||
}
|
||||
@@ -592,7 +587,7 @@ bool DirectDNSLookupIPV4(const char *dns_server_ip, const char *domain, uint32_t
|
||||
SOCKET sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
// Create UDP socket
|
||||
if (sockfd < 0) {
|
||||
ERROR_LOG(Log::sceNet, "Socket creation for direct DNS failed");
|
||||
ERROR_LOG(Log::Net, "Socket creation for direct DNS failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -601,7 +596,7 @@ bool DirectDNSLookupIPV4(const char *dns_server_ip, const char *domain, uint32_t
|
||||
server_addr.sin_port = htons(DNS_PORT);
|
||||
|
||||
if (net::inet_pton(AF_INET, dns_server_ip, &server_addr.sin_addr) <= 0) {
|
||||
ERROR_LOG(Log::sceNet,"Invalid DNS server IP address %s", dns_server_ip);
|
||||
ERROR_LOG(Log::Net,"Invalid DNS server IP address %s", dns_server_ip);
|
||||
closesocket(sockfd);
|
||||
return false;
|
||||
}
|
||||
@@ -623,7 +618,7 @@ bool DirectDNSLookupIPV4(const char *dns_server_ip, const char *domain, uint32_t
|
||||
// Send DNS query
|
||||
size_t query_len = sizeof(DNSHeader) + (qinfo - buffer) + 4;
|
||||
if (sendto(sockfd, (const char *)buffer, (int)query_len, 0, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) {
|
||||
ERROR_LOG(Log::sceNet, "Failed to send DNS query");
|
||||
ERROR_LOG(Log::Net, "Failed to send DNS query");
|
||||
closesocket(sockfd);
|
||||
return false;
|
||||
}
|
||||
@@ -632,7 +627,7 @@ bool DirectDNSLookupIPV4(const char *dns_server_ip, const char *domain, uint32_t
|
||||
socklen_t server_len = sizeof(server_addr);
|
||||
size_t response_len;
|
||||
if ((response_len = recvfrom(sockfd, (char *)buffer, sizeof(buffer), 0, (struct sockaddr *)&server_addr, &server_len)) < 0) {
|
||||
ERROR_LOG(Log::sceNet, "Failed to receive DNS response");
|
||||
ERROR_LOG(Log::Net, "Failed to receive DNS response");
|
||||
closesocket(sockfd);
|
||||
return false;
|
||||
}
|
||||
|
||||
+14
-2
@@ -8,7 +8,7 @@ struct addrinfo;
|
||||
|
||||
namespace net {
|
||||
|
||||
// Strictly only required on Win32, but all platforms should call it.
|
||||
// All platforms should call these on process start and end.
|
||||
void Init();
|
||||
void Shutdown();
|
||||
|
||||
@@ -18,15 +18,27 @@ enum class DNSType {
|
||||
IPV6 = 2,
|
||||
};
|
||||
|
||||
// This checks whether a TCP connection to host : port can be established within a given timeout.
|
||||
// It does this by attempting a new, non - blocking TCP connect() and waiting for it to succeed or time out.
|
||||
// The socket is closed immediately after the check.
|
||||
// It does not inspect or detect existing connections from other applications; it only tests reachability by making its own connection attempt.
|
||||
bool HostPortExists(const std::string &host, int port, int timeout_ms);
|
||||
|
||||
// Uses OS getaddrinfo to resolve an address. Blocking.
|
||||
bool DNSResolve(const std::string &host, const std::string &service, addrinfo **res, std::string &error, DNSType type = DNSType::ANY);
|
||||
// Call this when you're done using the result of DNSResolve.
|
||||
void DNSResolveFree(addrinfo *res);
|
||||
|
||||
// Uses tricks like getifaddrs to get a list of local IPv4 addresses. Returns false on failure, true on success (even if the list is empty).
|
||||
bool GetLocalIP4List(std::vector<std::string>& IP4s);
|
||||
|
||||
// IP address parser.
|
||||
int inet_pton(int af, const char* src, void* dst);
|
||||
|
||||
// Does a DNS lookup without involving the OS, so you can hit any DNS server.
|
||||
// Does a DNS lookup without involving the OS, so you can ask any DNS server you want, instead of
|
||||
// just the one configured in the OS. Also blocking, currently.
|
||||
// NOTE: This contains an internal cache that cannot be invalidated currently. TODO: At least add a timeout,
|
||||
// although a process restart will clear it up anyway so maybe not that important...
|
||||
bool DirectDNSLookupIPV4(const char *dnsServer, const char *host, uint32_t *ipv4_addr);
|
||||
|
||||
} // namespace net
|
||||
@@ -59,7 +59,7 @@ int PSPNetconfDialog::Init(u32 paramAddr) {
|
||||
if (ReadStatus() != SCE_UTILITY_STATUS_NONE)
|
||||
return SCE_ERROR_UTILITY_INVALID_STATUS;
|
||||
|
||||
NOTICE_LOG(Log::sceNet, "PSPNetConfDialog Init");
|
||||
NOTICE_LOG(Log::sceUtility, "PSPNetConfDialog Init");
|
||||
jsonReady_ = false;
|
||||
// Kick off a request to the infra-dns.json since we'll need it later.
|
||||
StartInfraJsonDownload();
|
||||
|
||||
+27
-27
@@ -66,7 +66,7 @@ void PortManager::Shutdown() {
|
||||
}
|
||||
|
||||
void PortManager::Terminate() {
|
||||
VERBOSE_LOG(Log::sceNet, "PortManager::Terminate()");
|
||||
VERBOSE_LOG(Log::Net, "PortManager::Terminate()");
|
||||
if (urls) {
|
||||
#ifdef WITH_UPNP
|
||||
FreeUPNPUrls(urls);
|
||||
@@ -100,9 +100,9 @@ bool PortManager::Initialize(const unsigned int timeout) {
|
||||
unsigned char ttl = 2; // defaulting to 2
|
||||
int error = 0;
|
||||
|
||||
VERBOSE_LOG(Log::sceNet, "PortManager::Initialize(%d)", timeout);
|
||||
VERBOSE_LOG(Log::Net, "PortManager::Initialize(%d)", timeout);
|
||||
if (!g_Config.bEnableUPnP) {
|
||||
ERROR_LOG(Log::sceNet, "PortManager::Initialize - UPnP is Disabled on Networking Settings");
|
||||
ERROR_LOG(Log::Net, "PortManager::Initialize - UPnP is Disabled on Networking Settings");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -110,12 +110,12 @@ bool PortManager::Initialize(const unsigned int timeout) {
|
||||
switch (m_InitState)
|
||||
{
|
||||
case UPNP_INITSTATE_BUSY: {
|
||||
WARN_LOG(Log::sceNet, "PortManager - Initialization already in progress");
|
||||
WARN_LOG(Log::Net, "PortManager - Initialization already in progress");
|
||||
return false;
|
||||
}
|
||||
// Should we redetect UPnP? just in case the player switched to a different network in the middle
|
||||
case UPNP_INITSTATE_DONE: {
|
||||
WARN_LOG(Log::sceNet, "PortManager - Already Initialized");
|
||||
WARN_LOG(Log::Net, "PortManager - Already Initialized");
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
@@ -149,7 +149,7 @@ bool PortManager::Initialize(const unsigned int timeout) {
|
||||
if (!dev)
|
||||
dev = devlist; // defaulting to first device
|
||||
|
||||
INFO_LOG(Log::sceNet, "PortManager - UPnP device: [desc: %s] [st: %s]", dev->descURL, dev->st);
|
||||
INFO_LOG(Log::Net, "PortManager - UPnP device: [desc: %s] [st: %s]", dev->descURL, dev->st);
|
||||
|
||||
descXML = (char*)miniwget(dev->descURL, &descXMLsize, dev->scope_id, &descXMLstatus);
|
||||
if (descXML)
|
||||
@@ -175,15 +175,15 @@ bool PortManager::Initialize(const unsigned int timeout) {
|
||||
int status = UPNP_GetValidIGD(devlist, urls, datas, lanaddr, sizeof(lanaddr));
|
||||
#endif
|
||||
m_lanip = std::string(lanaddr);
|
||||
INFO_LOG(Log::sceNet, "PortManager - Detected LAN IP: %s (status=%d)", m_lanip.c_str(), status);
|
||||
INFO_LOG(Log::Net, "PortManager - Detected LAN IP: %s (status=%d)", m_lanip.c_str(), status);
|
||||
|
||||
// Additional Info
|
||||
char connectionType[64] = "";
|
||||
if (UPNP_GetConnectionTypeInfo(urls->controlURL, datas->first.servicetype, connectionType) != UPNPCOMMAND_SUCCESS) {
|
||||
WARN_LOG(Log::sceNet, "PortManager - GetConnectionTypeInfo failed");
|
||||
WARN_LOG(Log::Net, "PortManager - GetConnectionTypeInfo failed");
|
||||
}
|
||||
else {
|
||||
INFO_LOG(Log::sceNet, "PortManager - Connection Type: %s", connectionType);
|
||||
INFO_LOG(Log::Net, "PortManager - Connection Type: %s", connectionType);
|
||||
}
|
||||
|
||||
// Using Game ID & Player Name as default description for mapping
|
||||
@@ -198,7 +198,7 @@ bool PortManager::Initialize(const unsigned int timeout) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ERROR_LOG(Log::sceNet, "PortManager - upnpDiscover failed (error: %i) or No UPnP device detected", error);
|
||||
ERROR_LOG(Log::Net, "PortManager - upnpDiscover failed (error: %i) or No UPnP device detected", error);
|
||||
if (g_Config.bEnableUPnP) {
|
||||
auto n = GetI18NCategory(I18NCat::NETWORKING);
|
||||
g_OSD.Show(OSDType::MESSAGE_ERROR, StringFromFormat("%s (%d)", n->T_cstr("Unable to find UPnP device"), error), 0.0f, "upnp_warning");
|
||||
@@ -221,11 +221,11 @@ bool PortManager::Add(const char* protocol, unsigned short port, unsigned short
|
||||
|
||||
if (intport == 0)
|
||||
intport = port;
|
||||
INFO_LOG(Log::sceNet, "PortManager::Add(%s, %d, %d)", protocol, port, intport);
|
||||
INFO_LOG(Log::Net, "PortManager::Add(%s, %d, %d)", protocol, port, intport);
|
||||
if (urls == NULL || urls->controlURL == NULL || urls->controlURL[0] == '\0')
|
||||
{
|
||||
if (g_Config.bEnableUPnP) {
|
||||
WARN_LOG(Log::sceNet, "PortManager::Add - the init was not done !");
|
||||
WARN_LOG(Log::Net, "PortManager::Add - the init was not done !");
|
||||
g_OSD.Show(OSDType::MESSAGE_INFO, n->T("UPnP need to be reinitialized"));
|
||||
}
|
||||
Terminate();
|
||||
@@ -253,7 +253,7 @@ bool PortManager::Add(const char* protocol, unsigned short port, unsigned short
|
||||
}
|
||||
if (r != 0)
|
||||
{
|
||||
ERROR_LOG(Log::sceNet, "PortManager - AddPortMapping failed (error: %i)", r);
|
||||
ERROR_LOG(Log::Net, "PortManager - AddPortMapping failed (error: %i)", r);
|
||||
if (r == UPNPCOMMAND_HTTP_ERROR) {
|
||||
if (g_Config.bEnableUPnP) {
|
||||
g_OSD.Show(OSDType::MESSAGE_INFO, n->T("UPnP need to be reinitialized"));
|
||||
@@ -277,11 +277,11 @@ bool PortManager::Remove(const char* protocol, unsigned short port) {
|
||||
char port_str[16];
|
||||
auto n = GetI18NCategory(I18NCat::NETWORKING);
|
||||
|
||||
INFO_LOG(Log::sceNet, "PortManager::Remove(%s, %d)", protocol, port);
|
||||
INFO_LOG(Log::Net, "PortManager::Remove(%s, %d)", protocol, port);
|
||||
if (urls == NULL || urls->controlURL == NULL || urls->controlURL[0] == '\0')
|
||||
{
|
||||
if (g_Config.bEnableUPnP) {
|
||||
WARN_LOG(Log::sceNet, "PortManager::Remove - the init was not done !");
|
||||
WARN_LOG(Log::Net, "PortManager::Remove - the init was not done !");
|
||||
g_OSD.Show(OSDType::MESSAGE_INFO, n->T("UPnP need to be reinitialized"));
|
||||
}
|
||||
Terminate();
|
||||
@@ -291,7 +291,7 @@ bool PortManager::Remove(const char* protocol, unsigned short port) {
|
||||
int r = UPNP_DeletePortMapping(urls->controlURL, datas->first.servicetype, port_str, protocol, NULL);
|
||||
if (r != 0)
|
||||
{
|
||||
ERROR_LOG(Log::sceNet, "PortManager - DeletePortMapping failed (error: %i)", r);
|
||||
ERROR_LOG(Log::Net, "PortManager - DeletePortMapping failed (error: %i)", r);
|
||||
if (r == UPNPCOMMAND_HTTP_ERROR) {
|
||||
if (g_Config.bEnableUPnP) {
|
||||
g_OSD.Show(OSDType::MESSAGE_INFO, n->T("UPnP need to be reinitialized"));
|
||||
@@ -312,10 +312,10 @@ bool PortManager::Remove(const char* protocol, unsigned short port) {
|
||||
bool PortManager::Restore() {
|
||||
#ifdef WITH_UPNP
|
||||
int r;
|
||||
VERBOSE_LOG(Log::sceNet, "PortManager::Restore()");
|
||||
VERBOSE_LOG(Log::Net, "PortManager::Restore()");
|
||||
if (urls == NULL || urls->controlURL == NULL || urls->controlURL[0] == '\0')
|
||||
{
|
||||
if (g_Config.bEnableUPnP) WARN_LOG(Log::sceNet, "PortManager::Remove - the init was not done !");
|
||||
if (g_Config.bEnableUPnP) WARN_LOG(Log::Net, "PortManager::Remove - the init was not done !");
|
||||
return false;
|
||||
}
|
||||
for (auto it = m_otherPortList.begin(); it != m_otherPortList.end(); ++it) {
|
||||
@@ -331,7 +331,7 @@ bool PortManager::Restore() {
|
||||
m_portList.erase(el_it);
|
||||
}
|
||||
else {
|
||||
ERROR_LOG(Log::sceNet, "PortManager::Restore - DeletePortMapping failed (error: %i)", r);
|
||||
ERROR_LOG(Log::Net, "PortManager::Restore - DeletePortMapping failed (error: %i)", r);
|
||||
if (r == UPNPCOMMAND_HTTP_ERROR)
|
||||
return false; // Might be better not to exit here, but exiting a loop will avoid long timeouts in the case the router is no longer reachable
|
||||
}
|
||||
@@ -343,7 +343,7 @@ bool PortManager::Restore() {
|
||||
it->taken = false;
|
||||
}
|
||||
else {
|
||||
ERROR_LOG(Log::sceNet, "PortManager::Restore - AddPortMapping failed (error: %i)", r);
|
||||
ERROR_LOG(Log::Net, "PortManager::Restore - AddPortMapping failed (error: %i)", r);
|
||||
if (r == UPNPCOMMAND_HTTP_ERROR)
|
||||
return false; // Might be better not to exit here, but exiting a loop will avoid long timeouts in the case the router is no longer reachable
|
||||
}
|
||||
@@ -369,10 +369,10 @@ bool PortManager::Clear() {
|
||||
char rHost[64];
|
||||
char duration[16];
|
||||
|
||||
VERBOSE_LOG(Log::sceNet, "PortManager::Clear()");
|
||||
VERBOSE_LOG(Log::Net, "PortManager::Clear()");
|
||||
if (urls == NULL || urls->controlURL == NULL || urls->controlURL[0] == '\0')
|
||||
{
|
||||
if (g_Config.bEnableUPnP) WARN_LOG(Log::sceNet, "PortManager::Clear - the init was not done !");
|
||||
if (g_Config.bEnableUPnP) WARN_LOG(Log::Net, "PortManager::Clear - the init was not done !");
|
||||
return false;
|
||||
}
|
||||
//unsigned int num = 0;
|
||||
@@ -394,7 +394,7 @@ bool PortManager::Clear() {
|
||||
int r2 = UPNP_DeletePortMapping(urls->controlURL, datas->first.servicetype, extPort, protocol, rHost);
|
||||
if (r2 != 0)
|
||||
{
|
||||
ERROR_LOG(Log::sceNet, "PortManager::Clear - DeletePortMapping(%s, %s) failed (error: %i)", extPort, protocol, r2);
|
||||
ERROR_LOG(Log::Net, "PortManager::Clear - DeletePortMapping(%s, %s) failed (error: %i)", extPort, protocol, r2);
|
||||
if (r2 == UPNPCOMMAND_HTTP_ERROR)
|
||||
return false;
|
||||
}
|
||||
@@ -427,10 +427,10 @@ bool PortManager::RefreshPortList() {
|
||||
char rHost[64];
|
||||
char duration[16];
|
||||
|
||||
INFO_LOG(Log::sceNet, "PortManager::RefreshPortList()");
|
||||
INFO_LOG(Log::Net, "PortManager::RefreshPortList()");
|
||||
if (urls == NULL || urls->controlURL == NULL || urls->controlURL[0] == '\0')
|
||||
{
|
||||
if (g_Config.bEnableUPnP) WARN_LOG(Log::sceNet, "PortManager::RefreshPortList - the init was not done !");
|
||||
if (g_Config.bEnableUPnP) WARN_LOG(Log::Net, "PortManager::RefreshPortList - the init was not done !");
|
||||
return false;
|
||||
}
|
||||
m_portList.clear();
|
||||
@@ -472,7 +472,7 @@ bool PortManager::RefreshPortList() {
|
||||
|
||||
int upnpService(const unsigned int timeout) {
|
||||
SetCurrentThreadName("UPnPService");
|
||||
INFO_LOG(Log::sceNet, "UPnPService: Begin of UPnPService Thread");
|
||||
INFO_LOG(Log::Net, "UPnPService: Begin of UPnPService Thread");
|
||||
|
||||
// Service Loop
|
||||
while (upnpServiceRunning) {
|
||||
@@ -520,7 +520,7 @@ int upnpService(const unsigned int timeout) {
|
||||
upnpReqs.clear();
|
||||
upnpLock.unlock();
|
||||
|
||||
INFO_LOG(Log::sceNet, "UPnPService: End of UPnPService Thread");
|
||||
INFO_LOG(Log::Net, "UPnPService: End of UPnPService Thread");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user