/**************************************************************************/1/* upnp_miniupnp.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#ifndef WEB_ENABLED3334#include "upnp.h"3536#include <miniupnpc/miniupnpc.h>3738class UPNPMiniUPNP : public UPNP {39GDCLASS(UPNPMiniUPNP, UPNP);4041private:42static UPNP *_create(bool p_notify_postinitialize) { return static_cast<UPNP *>(ClassDB::creator<UPNPMiniUPNP>(p_notify_postinitialize)); }4344String discover_multicast_if = "";45int discover_local_port = 0;46bool discover_ipv6 = false;4748Vector<Ref<UPNPDevice>> devices;4950bool is_common_device(const String &dev) const;51void add_device_to_list(UPNPDev *dev, UPNPDev *devlist);52void parse_igd(Ref<UPNPDevice> dev, UPNPDev *devlist);53char *load_description(const String &url, int *size, int *status_code) const;5455public:56static void make_default();5758static int upnp_result(int in);5960virtual int get_device_count() const override;61virtual Ref<UPNPDevice> get_device(int index) const override;62virtual void add_device(Ref<UPNPDevice> device) override;63virtual void set_device(int index, Ref<UPNPDevice> device) override;64virtual void remove_device(int index) override;65virtual void clear_devices() override;6667virtual Ref<UPNPDevice> get_gateway() const override;6869virtual int discover(int timeout = 2000, int ttl = 2, const String &device_filter = "InternetGatewayDevice") override;7071virtual String query_external_address() const override;7273virtual int add_port_mapping(int port, int port_internal = 0, String desc = "", String proto = "UDP", int duration = 0) const override;74virtual int delete_port_mapping(int port, String proto = "UDP") const override;7576virtual void set_discover_multicast_if(const String &m_if) override;77virtual String get_discover_multicast_if() const override;7879virtual void set_discover_local_port(int port) override;80virtual int get_discover_local_port() const override;8182virtual void set_discover_ipv6(bool ipv6) override;83virtual bool is_discover_ipv6() const override;8485UPNPMiniUPNP() {}86virtual ~UPNPMiniUPNP() {}87};8889#endif // WEB_ENABLED909192