network: hide miniupnpc behind a #def. use static buffer for udp data

This commit is contained in:
Flyinghead 2021-05-21 12:51:29 +02:00
parent 4cced8ffa0
commit c68f3bcc42
4 changed files with 20 additions and 1 deletions

View File

@ -211,6 +211,8 @@
#define HOST_64BIT_CPU
#endif
#define USE_MINIUPNPC
// Compiler Related
#ifndef _MSC_VER

View File

@ -16,6 +16,8 @@
You should have received a copy of the GNU General Public License
along with Flycast. If not, see <https://www.gnu.org/licenses/>.
*/
#include "build.h"
#ifdef USE_MINIUPNPC
#include <miniupnpc.h>
#include <upnpcommands.h>
#include "types.h"
@ -79,3 +81,4 @@ bool MiniUPnP::AddPortMapping(int port, bool tcp)
mappedPorts.emplace_back(portStr, tcp);
return true;
}
#endif

View File

@ -19,6 +19,7 @@
#pragma once
#include <vector>
#include <utility>
#ifdef USE_MINIUPNPC
#include <miniupnpc/miniupnpc.h>
class MiniUPnP
@ -44,3 +45,16 @@ private:
std::vector<std::pair<std::string, bool>> mappedPorts;
};
#else
class MiniUPnP
{
public:
bool Init() { return true; }
void Term() {}
bool AddPortMapping(int port, bool tcp) { return true; }
const char *localAddress() const { return ""; }
const char *externalAddress() const { return ""; }
};
#endif

View File

@ -616,7 +616,7 @@ static void read_native_sockets()
}
}
char buf[1500];
static char buf[1500];
pico_msginfo msginfo;
// Read UDP sockets