summaryrefslogtreecommitdiffstats
blob: e4b2f371d8cb094b32db2c378db6df6e57326462 (plain)
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
/*
 * Copyright (c) 2011 Tobias Markmann
 * Licensed under the simplified BSD license.
 * See Documentation/Licenses/BSD-simplified.txt for more information.
 */

#pragma once

#include <vector>

#include <Swiften/Base/boost_bsignals.h>

#include <Swiften/Network/NetworkEnvironment.h>
#include <Swiften/Network/NetworkInterface.h>

namespace Swift {

class UnixNetworkEnvironment : public NetworkEnvironment {
	class UnixNetworkInterface : public NetworkInterface {
	public:
		typedef boost::shared_ptr<UnixNetworkInterface> ref;

	public:
		UnixNetworkInterface(std::string name) : name(name), loopback(false) { }

		std::vector<HostAddress> getAddresses() {
			return addresses;
		}

		std::string getName() {
			return name;
		}

		bool isLoopback() {
			return loopback;
		}

	private:
		void addHostAddress(HostAddress address) {
			addresses.push_back(address);
		}

		void setLoopback(bool loopback) {
			this->loopback = loopback;
		}

	private:
		friend class UnixNetworkEnvironment;
		std::vector<HostAddress> addresses;
		std::string name;
		InterfaceType type;
		bool loopback;
	};

public:
	std::vector<NetworkInterface::ref> getNetworkInterfaces();
};

}