Kea
1.9.9-git
|
Socket wrapper structure. More...
#include <perf_socket.h>
Public Member Functions | |
PerfSocket (CommandOptions &options) | |
Constructor of socket wrapper class. More... | |
virtual | ~PerfSocket () |
Destructor of the socket wrapper class. More... | |
virtual dhcp::IfacePtr | getIface () override |
Get interface from IfaceMgr. More... | |
virtual dhcp::Pkt4Ptr | receive4 (uint32_t timeout_sec, uint32_t timeout_usec) override |
Receive DHCPv4 packet from interface. More... | |
virtual dhcp::Pkt6Ptr | receive6 (uint32_t timeout_sec, uint32_t timeout_usec) override |
Receive DHCPv6 packet from interface. More... | |
virtual bool | send (const dhcp::Pkt4Ptr &pkt) override |
Send DHCPv4 packet through interface. More... | |
virtual bool | send (const dhcp::Pkt6Ptr &pkt) override |
Send DHCPv6 packet through interface. More... | |
Public Member Functions inherited from isc::perfdhcp::BasePerfSocket | |
BasePerfSocket () | |
Default constructor of BasePerfSocket. More... | |
virtual | ~BasePerfSocket ()=default |
Destructor of the socket wrapper class. More... | |
Public Member Functions inherited from isc::dhcp::SocketInfo | |
SocketInfo (const isc::asiolink::IOAddress &addr, const uint16_t port, const int sockfd, const int fallbackfd=-1) | |
SocketInfo constructor. More... | |
Protected Member Functions | |
void | initSocketData () |
Initialize socket data. More... | |
int | openSocket (CommandOptions &options) const |
Open socket to communicate with DHCP server. More... | |
Additional Inherited Members | |
Public Attributes inherited from isc::perfdhcp::BasePerfSocket | |
uint16_t | ifindex_ |
Interface index. More... | |
Public Attributes inherited from isc::dhcp::SocketInfo | |
isc::asiolink::IOAddress | addr_ |
int | fallbackfd_ |
Fallback socket descriptor. More... | |
uint16_t | family_ |
socket port More... | |
uint16_t | port_ |
bound address More... | |
int | sockfd_ |
IPv4 or IPv6. More... | |
Socket wrapper structure.
This is the wrapper that holds descriptor of the socket used to run DHCP test. The wrapped socket is closed in the destructor. This prevents resource leaks when function that created the socket ends (normally or when exception occurs). This structure extends parent structure with new field ifindex_ that holds interface index where socket is bound to.
Definition at line 64 of file perf_socket.h.
isc::perfdhcp::PerfSocket::PerfSocket | ( | CommandOptions & | options | ) |
Constructor of socket wrapper class.
This constructor uses provided socket descriptor to find the name of the interface where socket has been bound to.
Definition at line 23 of file perf_socket.cc.
|
virtual |
Destructor of the socket wrapper class.
Destructor closes wrapped socket.
Definition at line 128 of file perf_socket.cc.
References isc::dhcp::IfaceMgr::getIface(), and isc::dhcp::IfaceMgr::instance().
|
overridevirtual |
Get interface from IfaceMgr.
Implements isc::perfdhcp::BasePerfSocket.
Definition at line 190 of file perf_socket.cc.
References isc::dhcp::IfaceMgr::instance().
|
protected |
Initialize socket data.
This method initializes members of the class that Interface Manager holds: interface name, local address.
isc::BadValue | if interface for specified socket descriptor does not exist. |
Definition at line 136 of file perf_socket.cc.
References isc::dhcp::IfaceMgr::instance(), and isc_throw.
|
protected |
Open socket to communicate with DHCP server.
Method opens socket and binds it to local address. Function will use either interface name, local address or server address to create a socket, depending on what is available (specified from the command line). If socket can't be created for any reason, exception is thrown. If destination address is broadcast (for DHCPv4) or multicast (for DHCPv6) than broadcast or multicast option is set on the socket. Opened socket is registered and managed by IfaceMgr.
isc::BadValue | if socket can't be created for given interface, local address or remote address. |
isc::InvalidOperation | if broadcast option can't be set for the v4 socket or if multicast option can't be set for the v6 socket. |
isc::Unexpected | if internal unexpected error occurred. |
Definition at line 30 of file perf_socket.cc.
References isc::asiolink::IOAddress::getFamily(), isc::dhcp::IfaceMgr::getIface(), isc::perfdhcp::CommandOptions::getIpVersion(), isc::perfdhcp::CommandOptions::getLocalName(), isc::perfdhcp::CommandOptions::getLocalPort(), isc::perfdhcp::CommandOptions::getServerName(), isc::dhcp::IfaceMgr::instance(), isc::perfdhcp::CommandOptions::isBroadcast(), isc_throw, isc::perfdhcp::CommandOptions::isInterface(), isc::perfdhcp::CommandOptions::isUseRelayedV6(), isc::asiolink::IOAddress::isV6Multicast(), isc::dhcp::IfaceMgr::openSocketFromAddress(), isc::dhcp::IfaceMgr::openSocketFromIface(), and isc::dhcp::IfaceMgr::openSocketFromRemoteAddress().
|
overridevirtual |
Receive DHCPv4 packet from interface.
timeout_sec | number of seconds for waiting for a packet, |
timeout_usec | number of microseconds for waiting for a packet, |
Implements isc::perfdhcp::BasePerfSocket.
Definition at line 150 of file perf_socket.cc.
References isc::dhcp::IfaceMgr::instance(), and isc::dhcp::IfaceMgr::receive4().
|
overridevirtual |
Receive DHCPv6 packet from interface.
timeout_sec | number of seconds for waiting for a packet, |
timeout_usec | number of microseconds for waiting for a packet, |
Implements isc::perfdhcp::BasePerfSocket.
Definition at line 165 of file perf_socket.cc.
References isc::dhcp::IfaceMgr::instance(), and isc::dhcp::IfaceMgr::receive6().
|
overridevirtual |
Send DHCPv4 packet through interface.
pkt | a packet for sending |
Implements isc::perfdhcp::BasePerfSocket.
Definition at line 180 of file perf_socket.cc.
References isc::dhcp::IfaceMgr::instance(), and isc::dhcp::IfaceMgr::send().
|
overridevirtual |
Send DHCPv6 packet through interface.
pkt | a packet for sending |
Implements isc::perfdhcp::BasePerfSocket.
Definition at line 185 of file perf_socket.cc.
References isc::dhcp::IfaceMgr::instance(), and isc::dhcp::IfaceMgr::send().