Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
d919490c
Commit
d919490c
authored
Apr 03, 2013
by
Marcin Siodelski
Browse files
[991] Pass Iface object to classes derived from PktFilter.
parent
d9b1da77
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcp/pkt_filter.h
View file @
d919490c
...
...
@@ -20,6 +20,9 @@
namespace
isc
{
namespace
dhcp
{
/// Forward declaration to the class representing interface
class
Iface
;
/// @brief Abstract packet handling class
///
/// This class represents low level method to send and receive DHCP packet.
...
...
@@ -39,14 +42,14 @@ public:
/// @brief Open socket.
///
/// @param interface
name
/// @param
iface
interface
descriptor
/// @param addr address on the interface to be used to send packets.
/// @param port port number.
/// @param receive_bcast configure socket to receive broadcast messages
/// @param send_bcast configure socket to send broadcast messages.
///
/// @return created socket's descriptor
virtual
int
openSocket
(
const
std
::
string
&
if
nam
e
,
virtual
int
openSocket
(
const
Iface
&
if
ac
e
,
const
isc
::
asiolink
::
IOAddress
&
addr
,
const
uint16_t
port
,
const
bool
receive_bcast
,
...
...
src/lib/dhcp/pkt_filter_inet.cc
View file @
d919490c
...
...
@@ -21,8 +21,10 @@ namespace isc {
namespace
dhcp
{
int
PktFilterInet
::
openSocket
(
const
std
::
string
&
ifname
,
const
isc
::
asiolink
::
IOAddress
&
addr
,
const
uint16_t
port
,
const
bool
receive_bcast
,
PktFilterInet
::
openSocket
(
const
Iface
&
iface
,
const
isc
::
asiolink
::
IOAddress
&
addr
,
const
uint16_t
port
,
const
bool
receive_bcast
,
const
bool
send_bcast
)
{
struct
sockaddr_in
addr4
;
...
...
@@ -41,8 +43,8 @@ PktFilterInet::openSocket(const std::string& ifname, const isc::asiolink::IOAddr
if
(
receive_bcast
)
{
// Bind to device so as we receive traffic on a specific interface.
if
(
setsockopt
(
sock
,
SOL_SOCKET
,
SO_BINDTODEVICE
,
if
n
ame
.
c_str
(),
if
n
ame
.
length
()
+
1
)
<
0
)
{
if
(
setsockopt
(
sock
,
SOL_SOCKET
,
SO_BINDTODEVICE
,
if
ace
.
getN
ame
()
.
c_str
(),
if
ace
.
getN
ame
()
.
length
()
+
1
)
<
0
)
{
close
(
sock
);
isc_throw
(
SocketConfigError
,
"Failed to set SO_BINDTODEVICE option"
<<
"on socket "
<<
sock
);
...
...
src/lib/dhcp/pkt_filter_inet.h
View file @
d919490c
...
...
@@ -29,14 +29,14 @@ public:
/// @brief Open socket.
///
/// @param interface
name
/// @param
iface
interface
descriptor
/// @param addr address on the interface to be used to send packets.
/// @param port port number.
/// @param receive_bcast configure socket to receive broadcast messages
/// @param send_bcast configure socket to send broadcast messages.
///
/// @return created socket's descriptor
virtual
int
openSocket
(
const
std
::
string
&
if
nam
e
,
virtual
int
openSocket
(
const
Iface
&
if
ac
e
,
const
isc
::
asiolink
::
IOAddress
&
addr
,
const
uint16_t
port
,
const
bool
receive_bcast
,
...
...
src/lib/dhcp/pkt_filter_lpf.cc
0 → 100644
View file @
d919490c
// Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#include <config.h>
#include <dhcp/iface_mgr.h>
#include <dhcp/pkt4.h>
#include <dhcp/pkt_filter_lpf.h>
namespace
isc
{
namespace
dhcp
{
int
PktFilterLPF
::
openSocket
(
const
std
::
string
&
ifname
,
const
isc
::
asiolink
::
IOAddress
&
addr
,
const
uint16_t
port
,
const
bool
receive_bcast
,
const
bool
send_bcast
)
{
return
(
-
1
);
}
}
// end of isc::dhcp namespace
}
// end of isc namespace
src/lib/dhcp/pkt_filter_lpf.h
0 → 100644
View file @
d919490c
// Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#ifndef PKT_FILTER_LPF_H
#define PKT_FILTER_LPF_H
#include <dhcp/pkt_filter.h>
namespace
isc
{
namespace
dhcp
{
/// @brief Packet handling class using Linux Packet Filtering
///
/// This class provides methods to send and recive packet using raw sockets
/// and Linux Packet Filtering.
class
PktFilterLPF
:
public
PktFilter
{
public:
/// @brief Open socket.
///
/// @param interface name
/// @param addr address on the interface to be used to send packets.
/// @param port port number.
/// @param receive_bcast configure socket to receive broadcast messages
/// @param send_bcast configure socket to send broadcast messages.
///
/// @return created socket's descriptor
virtual
int
openSocket
(
const
std
::
string
&
ifname
,
const
isc
::
asiolink
::
IOAddress
&
addr
,
const
uint16_t
port
,
const
bool
receive_bcast
,
const
bool
send_bcast
);
/// @brief Receive packet over specified socket.
///
/// @param sockfd descriptor of a socket to be used for packet reception
/// @param timeout_sec integral part of a timeout.
/// @param timeout_usec fractional part of a timeout (in microseconds).
///
/// @return Received packet
Pkt4Ptr
receive
(
uint16_t
sockfd
,
uint32_t
timeout_sec
,
uint32_t
timeout_usec
=
0
);
// bool send(const Pkt4Ptr& pkt) = 0;
};
}
// namespace isc::dhcp
}
// namespace isc
#endif // PKT_FILTER_LPF_H
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment