IBR-DTNSuite
0.10
Main Page
Namespaces
Classes
Files
File List
File Members
IBR-DTNSuite
Namespaces
Classes
Files
File List
daemon
ibrcommon
ibrcommon
data
link
net
ieee802154.h
lowpansocket.cpp
lowpansocket.h
lowpanstream.cpp
lowpanstream.h
socket.cpp
socket.h
socketstream.cpp
socketstream.h
stopandwait.cpp
stopandwait.h
vaddress.cpp
vaddress.h
vinterface.cpp
vinterface.h
vsocket.cpp
vsocket.h
ssl
thread
xml
appstreambuf.cpp
appstreambuf.h
config.h
Exceptions.h
ibrcommon.h
Iterator.h
Logger.cpp
Logger.h
refcnt_ptr.h
SyslogStream.cpp
SyslogStream.h
TimeMeasurement.cpp
TimeMeasurement.h
TLSExceptions.h
ibrdtn
tools
File Members
vinterface.cpp
Go to the documentation of this file.
1
/*
2
* vinterface.cpp
3
*
4
* Copyright (C) 2011 IBR, TU Braunschweig
5
*
6
* Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7
*
8
* Licensed under the Apache License, Version 2.0 (the "License");
9
* you may not use this file except in compliance with the License.
10
* You may obtain a copy of the License at
11
*
12
* http://www.apache.org/licenses/LICENSE-2.0
13
*
14
* Unless required by applicable law or agreed to in writing, software
15
* distributed under the License is distributed on an "AS IS" BASIS,
16
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
* See the License for the specific language governing permissions and
18
* limitations under the License.
19
*
20
*/
21
22
#include "
ibrcommon/config.h
"
23
#include "
ibrcommon/net/vinterface.h
"
24
#include "
ibrcommon/net/vsocket.h
"
25
#include <net/if.h>
26
27
namespace
ibrcommon
28
{
29
const
std::string
vinterface::LOOPBACK
=
"loopback"
;
30
const
std::string
vinterface::ANY
=
"any"
;
31
32
vinterface::vinterface
()
33
: _name()
34
{
35
}
36
37
vinterface::vinterface
(std::string name)
38
: _name(name)
39
{
40
}
41
42
vinterface::~vinterface
()
43
{
44
}
45
46
const
std::string
vinterface::toString
()
const
47
{
48
if
(_name.length() == 0)
return
"<any>"
;
49
return
_name;
50
}
51
52
bool
vinterface::isLoopback
()
const
53
{
54
return
(_name ==
LOOPBACK
);
55
}
56
57
bool
vinterface::isAny
()
const
58
{
59
return
(_name ==
ANY
);
60
}
61
62
uint32_t
vinterface::getIndex
()
const
63
{
64
return ::if_nametoindex(_name.c_str());
65
}
66
67
const
std::list<vaddress>
vinterface::getAddresses
(
const
std::string &scope)
const
68
{
69
if
(
empty
())
throw
interface_not_set
();
70
return
ibrcommon::LinkManager::getInstance
().
getAddressList
(*
this
, scope);
71
}
72
73
bool
vinterface::up
()
const
{
74
return
!
getAddresses
().empty();
75
}
76
77
bool
vinterface::operator<
(
const
vinterface
&obj)
const
78
{
79
return
(_name < obj._name);
80
}
81
82
bool
vinterface::operator==
(
const
vinterface
&obj)
const
83
{
84
return
(obj._name == _name);
85
}
86
87
bool
vinterface::operator!=
(
const
vinterface
&obj)
const
88
{
89
return
(obj._name != _name);
90
}
91
92
bool
vinterface::empty
()
const
93
{
94
return
(_name.length() == 0);
95
}
96
}
ibrcommon
ibrcommon
net
vinterface.cpp
Generated on Mon Jul 22 2013 15:16:00 for IBR-DTNSuite by
1.8.3.1