IBR-DTNSuite
0.10
Main Page
Namespaces
Classes
Files
File List
File Members
vaddress.h
Go to the documentation of this file.
1
/*
2
* vaddress.h
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
#ifndef VADDRESS_H_
23
#define VADDRESS_H_
24
25
#include "
ibrcommon/Exceptions.h
"
26
#include <sys/socket.h>
27
28
namespace
ibrcommon
29
{
30
class
vaddress
31
{
32
public
:
33
class
address_exception
:
public
Exception
34
{
35
public
:
36
address_exception
(
string
error
=
"unspecific address error"
) :
Exception
(
error
)
37
{};
38
};
39
40
class
address_not_set
:
public
address_exception
41
{
42
public
:
43
address_not_set
(
string
error
=
"address is not specified"
) :
address_exception
(
error
)
44
{};
45
};
46
47
class
service_not_set
:
public
address_exception
48
{
49
public
:
50
service_not_set
(
string
error
=
"service is not specified"
) :
address_exception
(
error
)
51
{};
52
};
53
54
class
scope_not_set
:
public
address_exception
55
{
56
public
:
57
scope_not_set
(
string
error
=
"scope is not specified"
) :
address_exception
(
error
)
58
{};
59
};
60
61
const
static
std::string
SCOPE_GLOBAL
;
62
const
static
std::string
SCOPE_LINKLOCAL
;
63
64
const
static
std::string
VADDR_LOCALHOST
;
65
const
static
std::string
VADDR_ANY
;
66
67
vaddress
();
68
vaddress
(
const
int
port, sa_family_t
family
= AF_UNSPEC);
69
vaddress
(
const
std::string &
address
,
const
int
port, sa_family_t
family
= AF_UNSPEC);
70
vaddress
(
const
std::string &
address
,
const
std::string &
service
, sa_family_t
family
= AF_UNSPEC);
71
vaddress
(
const
std::string &
address
,
const
std::string &
service
,
const
std::string &
scope
, sa_family_t
family
= AF_UNSPEC);
72
virtual
~vaddress
();
73
74
bool
isLocal
()
const
;
75
bool
isAny
()
const
;
76
77
sa_family_t
family
()
const
throw (
address_exception
);
78
std::
string
scope
() const throw (
scope_not_set
);
79
const std::
string
address
() const throw (
address_not_set
);
80
const std::
string
service
() const throw (
service_not_set
);
81
82
void
setService
(const std::
string
&
service
);
83
84
bool
operator<(const
vaddress
&dhs) const;
85
bool
operator!=(const
vaddress
&obj) const;
86
bool
operator==(const
vaddress
&obj) const;
87
88
const std::
string
toString
() const;
89
90
private:
91
std::
string
_address;
92
std::
string
_service;
93
std::
string
_scope;
94
sa_family_t _family;
95
};
96
}
97
98
#endif
/* VADDRESS_H_ */
ibrcommon
ibrcommon
net
vaddress.h
Generated on Mon Jul 22 2013 15:16:00 for IBR-DTNSuite by
1.8.3.1