Debian Codegraph @

modules/upnp/upnp_miniupnp.h

raw symbols SCIP
1 /**************************************************************************/
2 /* upnp_miniupnp.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #ifndef WEB_ENABLED
34
35 #include "upnp.h"
36
37 #include <miniupnpc/miniupnpc.h>
38
39 class UPNPMiniUPNP : public UPNP {
40 GDCLASS(UPNPMiniUPNP, UPNP);
41
42 private:
43 static UPNP *_create(bool p_notify_postinitialize) { return static_cast<UPNP *>(ClassDB::creator<UPNPMiniUPNP>(p_notify_postinitialize)); }
44
45 String discover_multicast_if = "";
46 int discover_local_port = 0;
47 bool discover_ipv6 = false;
48
49 Vector<Ref<UPNPDevice>> devices;
50
51 bool is_common_device(const String &dev) const;
52 void add_device_to_list(UPNPDev *dev, UPNPDev *devlist);
53 void parse_igd(Ref<UPNPDevice> dev, UPNPDev *devlist);
54 char *load_description(const String &url, int *size, int *status_code) const;
55
56 public:
57 static void make_default();
58
59 static int upnp_result(int in);
60
61 virtual int get_device_count() const override;
62 virtual Ref<UPNPDevice> get_device(int index) const override;
63 virtual void add_device(Ref<UPNPDevice> device) override;
64 virtual void set_device(int index, Ref<UPNPDevice> device) override;
65 virtual void remove_device(int index) override;
66 virtual void clear_devices() override;
67
68 virtual Ref<UPNPDevice> get_gateway() const override;
69
70 virtual int discover(int timeout = 2000, int ttl = 2, const String &device_filter = "InternetGatewayDevice") override;
71
72 virtual String query_external_address() const override;
73
74 virtual int add_port_mapping(int port, int port_internal = 0, String desc = "", String proto = "UDP", int duration = 0) const override;
75 virtual int delete_port_mapping(int port, String proto = "UDP") const override;
76
77 virtual void set_discover_multicast_if(const String &m_if) override;
78 virtual String get_discover_multicast_if() const override;
79
80 virtual void set_discover_local_port(int port) override;
81 virtual int get_discover_local_port() const override;
82
83 virtual void set_discover_ipv6(bool ipv6) override;
84 virtual bool is_discover_ipv6() const override;
85
86 UPNPMiniUPNP() {}
87 virtual ~UPNPMiniUPNP() {}
88 };
89
90 #endif // WEB_ENABLED