Debian Codegraph @

modules/upnp/upnp.h

raw symbols SCIP
1 /**************************************************************************/
2 /* upnp.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 #include "upnp_device.h"
34
35 #include "core/object/ref_counted.h"
36
37 class UPNP : public RefCounted {
38 GDCLASS(UPNP, RefCounted);
39
40 protected:
41 static void _bind_methods();
42
43 static UPNP *(*_create)(bool p_notify_postinitialize);
44
45 public:
46 enum UPNPResult {
47 UPNP_RESULT_SUCCESS,
48 UPNP_RESULT_NOT_AUTHORIZED,
49 UPNP_RESULT_PORT_MAPPING_NOT_FOUND,
50 UPNP_RESULT_INCONSISTENT_PARAMETERS,
51 UPNP_RESULT_NO_SUCH_ENTRY_IN_ARRAY,
52 UPNP_RESULT_ACTION_FAILED,
53 UPNP_RESULT_SRC_IP_WILDCARD_NOT_PERMITTED,
54 UPNP_RESULT_EXT_PORT_WILDCARD_NOT_PERMITTED,
55 UPNP_RESULT_INT_PORT_WILDCARD_NOT_PERMITTED,
56 UPNP_RESULT_REMOTE_HOST_MUST_BE_WILDCARD,
57 UPNP_RESULT_EXT_PORT_MUST_BE_WILDCARD,
58 UPNP_RESULT_NO_PORT_MAPS_AVAILABLE,
59 UPNP_RESULT_CONFLICT_WITH_OTHER_MECHANISM,
60 UPNP_RESULT_CONFLICT_WITH_OTHER_MAPPING,
61 UPNP_RESULT_SAME_PORT_VALUES_REQUIRED,
62 UPNP_RESULT_ONLY_PERMANENT_LEASE_SUPPORTED,
63 UPNP_RESULT_INVALID_GATEWAY,
64 UPNP_RESULT_INVALID_PORT,
65 UPNP_RESULT_INVALID_PROTOCOL,
66 UPNP_RESULT_INVALID_DURATION,
67 UPNP_RESULT_INVALID_ARGS,
68 UPNP_RESULT_INVALID_RESPONSE,
69 UPNP_RESULT_INVALID_PARAM,
70 UPNP_RESULT_HTTP_ERROR,
71 UPNP_RESULT_SOCKET_ERROR,
72 UPNP_RESULT_MEM_ALLOC_ERROR,
73 UPNP_RESULT_NO_GATEWAY,
74 UPNP_RESULT_NO_DEVICES,
75 UPNP_RESULT_UNKNOWN_ERROR,
76 };
77
78 static UPNP *create(bool p_notify_postinitialize = true) {
79 if (!_create) {
80 return nullptr;
81 }
82 return _create(p_notify_postinitialize);
83 }
84
85 virtual int get_device_count() const = 0;
86 virtual Ref<UPNPDevice> get_device(int index) const = 0;
87 virtual void add_device(Ref<UPNPDevice> device) = 0;
88 virtual void set_device(int index, Ref<UPNPDevice> device) = 0;
89 virtual void remove_device(int index) = 0;
90 virtual void clear_devices() = 0;
91
92 virtual Ref<UPNPDevice> get_gateway() const = 0;
93
94 virtual int discover(int timeout = 2000, int ttl = 2, const String &device_filter = "InternetGatewayDevice") = 0;
95
96 virtual String query_external_address() const = 0;
97
98 virtual int add_port_mapping(int port, int port_internal = 0, String desc = "", String proto = "UDP", int duration = 0) const = 0;
99 virtual int delete_port_mapping(int port, String proto = "UDP") const = 0;
100
101 virtual void set_discover_multicast_if(const String &m_if) = 0;
102 virtual String get_discover_multicast_if() const = 0;
103
104 virtual void set_discover_local_port(int port) = 0;
105 virtual int get_discover_local_port() const = 0;
106
107 virtual void set_discover_ipv6(bool ipv6) = 0;
108 virtual bool is_discover_ipv6() const = 0;
109
110 UPNP() {}
111 virtual ~UPNP() {}
112 };
113
114 VARIANT_ENUM_CAST(UPNP::UPNPResult)