-
Notifications
You must be signed in to change notification settings - Fork 0
/
igd.h
106 lines (80 loc) · 2.23 KB
/
igd.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
bubba-igd - http://www.excito.com/
Igd.h - this file is part of bubba-igd.
Copyright (C) 2009 Tor Krill <[email protected]>
Copyright (C) 2011 Carl Fürstenberg <[email protected]>
bubba-easyfind is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
bubba-easyfind is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
version 2 along with bubba-easyfind if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef IGD_H_
#define IGD_H_
#include <map>
#include <string>
#include <vector>
#include <exception>
#include <libgupnp/gupnp-control-point.h>
#include <boost/thread.hpp>
#include <boost/program_options.hpp>
typedef struct{
std::string wanip;
std::string lanip;
void* proxy;
} igdevice;
typedef std::map<std::string, igdevice> IgMap;
class no_valid_interface_exception: public std::runtime_error {
public:
no_valid_interface_exception(const std::string msg): std::runtime_error(msg) {}
};
class IGD{
private:
boost::thread m_Thread;
std::string interface;
bool do_portforward;
bool do_easyfind;
std::vector<int> ports;
IgMap igmap;
GMainLoop *main_loop;
IGD(const IGD&);
IGD& operator=(const IGD&);
void registerPortMappings(std::string udn);
void unregisterPortMappings(std::string udn);
void updateEasyfind();
void run();
public:
IGD(){}
void start(boost::program_options::variables_map vm);
void join();
void stop();
void addDevice(
std::string udn,
std::string host
);
void addService(
std::string udn,
std::string host,
GUPnPServiceProxy* proxy
);
void addPortMapping(
std::string localhost,
int publicport,
int localport,
std::string type
);
void removePortMapping(
int publicport,
std::string type
);
void removeDevice(std::string udn);
void removeService(std::string udn);
void dumpMap();
virtual ~IGD(){}
};
#endif