blob: 1e4946f5cc8f08043ae47f5f6cd064221911e0df [file] [log] [blame]
Emeric Vigier2f625822012-08-06 11:09:52 -04001// Copyright (C) 2002-2010 Christian Prochnow <cproch@seculogix.de>
2//
3// This program is free software; you can redistribute it and/or modify
4// it under the terms of the GNU General Public License as published by
5// the Free Software Foundation; either version 2 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16//
17// As a special exception, you may use this file as part of a free software
18// library without restriction. Specifically, if other files instantiate
19// templates or use macros or inline functions from this file, or you compile
20// this file and link it with other files to produce an executable, this
21// file does not by itself cause the resulting executable to be covered by
22// the GNU General Public License. This exception does not however
23// invalidate any other reasons why the executable file might be covered by
24// the GNU General Public License.
25//
26// This exception applies only to the code released under the name GNU
27// Common C++. If you copy code from other releases into a copy of GNU
28// Common C++, as the General Public License permits, the exception does
29// not apply to the code that you add in this way. To avoid misleading
30// anyone as to the status of such modified files, you must delete
31// this exception notice from them.
32//
33// If you write modifications of your own for GNU Common C++, it is your choice
34// whether to permit this exception to apply to your modifications.
35// If you do not wish that, delete this exception notice.
36//
37
38/**
39 * @file network.h
40 * @short Network subsystem and device interface related classes.
41 **/
42
43
44#ifndef CCXX_NETWORK_H_
45#define CCXX_NETWORK_H_
46
47#ifndef CCXX_MISSING_H_
48#include <cc++/missing.h>
49#endif
50
51#ifndef CCXX_SOCKET_H_
52#include <cc++/socket.h>
53#endif
54
55#ifndef CCXX_STRING_H_
56#include <cc++/string.h>
57#endif
58
59#include <vector>
60
61#ifdef CCXX_NAMESPACES
62namespace ost {
63#endif
64
65
66//! Network device information class
67/*!
68 This class is used to hold various informations about a TCP/IP
69 network device. Which can be obtained by a call to enumNetworkDevices()
70 \author Christian Prochnow <cproch@seculogix.de>
71*/
72class __EXPORT NetworkDeviceInfo
73{
74private:
75 String _name;
76 InetHostAddress _addr;
77 BroadcastAddress _broadcast;
78 InetMaskAddress _netmask;
79 int _mtu;
80
81protected:
82 NetworkDeviceInfo(const String& name, const InetHostAddress& addr,
83 const BroadcastAddress& broadcast,
84 const InetMaskAddress& netmask, int mtu);
85
86public:
87 NetworkDeviceInfo(const NetworkDeviceInfo& ndi);
88 ~NetworkDeviceInfo();
89
90 //! Returns the Name of the network device
91 inline const String& name() const
92 { return _name; }
93
94 //! Returns the Address of the network device
95 inline const InetHostAddress& address() const
96 { return _addr; }
97
98 //! Returns the Broadcast address of the network device
99 inline const BroadcastAddress& broadcast() const
100 { return _broadcast; }
101
102 //! Returns the Netmask of the network device
103 inline const InetMaskAddress& netmask() const
104 { return _netmask; }
105
106 //! Returns the MTU
107 inline const int mtu() const
108 { return _mtu; }
109
110 //! Enumerate all available network devices
111 friend __EXPORT bool enumNetworkDevices(std::vector<NetworkDeviceInfo>& devs);
112};
113
114#ifdef CCXX_NAMESPACES
115}
116#endif
117
118#endif
119/** EMACS **
120 * Local variables:
121 * mode: c++
122 * c-basic-offset: 4
123 * End:
124 */