Kea  2.1.7-git
isc::dhcp::Dhcp4o6IpcBase Class Referenceabstract

This class implements the communication between the DHCPv4 and DHCPv6 servers to allow for transmission of the DHCPv4 query and DHCPv4 response messages. More...

#include <dhcp4o6_ipc.h>

+ Inheritance diagram for isc::dhcp::Dhcp4o6IpcBase:

Public Types

enum  EndpointType { ENDPOINT_TYPE_V4 = 4, ENDPOINT_TYPE_V6 = 6 }
 Endpoint type: DHCPv4 or DHCPv6 server. More...
 

Public Member Functions

void close ()
 Close communication socket. More...
 
virtual void open ()=0
 Open communication socket (for derived classes). More...
 
Pkt6Ptr receive ()
 Receive message over IPC. More...
 
void send (const Pkt6Ptr &pkt)
 Send message over IPC. More...
 

Protected Member Functions

 Dhcp4o6IpcBase ()
 Constructor. More...
 
virtual ~Dhcp4o6IpcBase ()
 Destructor. More...
 
int open (uint16_t port, EndpointType endpoint_type)
 Open communication socket (from base class). More...
 

Protected Attributes

uint16_t port_
 Port number configured for IPC communication. More...
 
int socket_fd_
 Socket descriptor. More...
 

Detailed Description

This class implements the communication between the DHCPv4 and DHCPv6 servers to allow for transmission of the DHCPv4 query and DHCPv4 response messages.

When the DHCPv6 server receives the DHCPv4 query message it needs to forward it to the DHCPv4 server for processing. The DHCPv4 server processes the message and answers with the DHCPv4 response message to the DHCPv6 server. The server forwards it back to the client. This class implements the communication between the DHCPv4 and DHCPv6 servers to allow for transmission of the DHCPv4 query and DHCPv6 response messages.

This class creates a socket (when open is called) and binds it to a port, depending on the configuration. The port number is explicitly specified in the server configuration. This explicit port value is used directly on the DHCPv6 server side. The DHCPv4 server uses the port specified + 1.

The DHCPv4 and DHCPv6 servers use distinct instances of classes derived from this base class. Each of these instances is used to send and receive messages sent by the other server.

In order to make address allocation decisions, the DHCPv4 server requires information about the interface and the source address of the original DHCPv4 query message sent by the client. This information is known by the DHCPv6 server and needs to be conveyed to the DHCPv4 server. The IPC conveys it in the ISC_V6_4O6_INTERFACE, ISC_V6_4O6_SRC_ADDRESS and ISC_V6_4O6_SRC_PORT options within the Vendor Specific Information option, with ISC enterprise id. These options are added by the IPC sender and removed by the IPC receiver.

Definition at line 61 of file dhcp4o6_ipc.h.

Member Enumeration Documentation

◆ EndpointType

Endpoint type: DHCPv4 or DHCPv6 server.

Enumerator
ENDPOINT_TYPE_V4 
ENDPOINT_TYPE_V6 

Definition at line 65 of file dhcp4o6_ipc.h.

Constructor & Destructor Documentation

◆ Dhcp4o6IpcBase()

isc::dhcp::Dhcp4o6IpcBase::Dhcp4o6IpcBase ( )
protected

Constructor.

Default constructor

Definition at line 33 of file dhcp4o6_ipc.cc.

◆ ~Dhcp4o6IpcBase()

isc::dhcp::Dhcp4o6IpcBase::~Dhcp4o6IpcBase ( )
protectedvirtual

Destructor.

Definition at line 35 of file dhcp4o6_ipc.cc.

References close().

+ Here is the call graph for this function:

Member Function Documentation

◆ close()

void isc::dhcp::Dhcp4o6IpcBase::close ( )

◆ open() [1/2]

int isc::dhcp::Dhcp4o6IpcBase::open ( uint16_t  port,
EndpointType  endpoint_type 
)
protected

Open communication socket (from base class).

Parameters
portPort number to use. The socket is bound to this port if the endpoint type is DHCPv6 server, otherwise the port + 1 value is used.
endpoint_typeEndpoint type (DHCPv4 or DHCPv6 server).
Returns
New socket descriptor.
Exceptions
isc::dhcp::Dhcp4o6IpcErroron system call errors.

Definition at line 39 of file dhcp4o6_ipc.cc.

References close(), ENDPOINT_TYPE_V6, isc_throw, port_, and socket_fd_.

+ Here is the call graph for this function:

◆ open() [2/2]

virtual void isc::dhcp::Dhcp4o6IpcBase::open ( )
pure virtual

Open communication socket (for derived classes).

Implemented in isc::dhcp::Dhcp4to6Ipc, and isc::dhcp::Dhcp6to4Ipc.

Referenced by isc::dhcp::Dhcp6to4Ipc::open(), and isc::dhcp::Dhcp4to6Ipc::open().

◆ receive()

Pkt6Ptr isc::dhcp::Dhcp4o6IpcBase::receive ( )

Receive message over IPC.

Returns
a pointer to a DHCPv6 message with interface and remote address set from the IPC message
Exceptions
isc::dhcp::Dhcp4o6IpcErroron system call error or malformed packets.

Definition at line 127 of file dhcp4o6_ipc.cc.

References D6O_VENDOR_OPTS, isc_throw, and socket_fd_.

Referenced by isc::dhcp::Dhcp6to4Ipc::handler(), and isc::dhcp::Dhcp4to6Ipc::handler().

◆ send()

void isc::dhcp::Dhcp4o6IpcBase::send ( const Pkt6Ptr pkt)

Send message over IPC.

The IPC uses ISC_V6_4O6_INTERFACE, ISC_V6_4O6_SRC_ADDRESS and ISC_V6_4O6_SRC_PORT options conveyed within the Vendor Specific Information option, with ISC enterprise id, to communicate the client remote address and the interface on which the DHCPv4 query was received. These options will be removed by the receiver.

Parameters
pktPointer to a DHCPv6 message with interface and remote address.
Exceptions
isc::dhcp::Dhcp4o6IpcError.

Definition at line 226 of file dhcp4o6_ipc.cc.

References D6O_VENDOR_OPTS, isc_throw, and socket_fd_.

Referenced by isc::dhcp::Dhcp4to6Ipc::handler(), and isc::dhcp::Dhcpv6Srv::processDhcp4Query().

Member Data Documentation

◆ port_

uint16_t isc::dhcp::Dhcp4o6IpcBase::port_
protected

Port number configured for IPC communication.

Definition at line 122 of file dhcp4o6_ipc.h.

Referenced by close(), and open().

◆ socket_fd_

int isc::dhcp::Dhcp4o6IpcBase::socket_fd_
protected

Socket descriptor.

Definition at line 125 of file dhcp4o6_ipc.h.

Referenced by close(), isc::dhcp::Dhcp6to4Ipc::open(), isc::dhcp::Dhcp4to6Ipc::open(), open(), receive(), and send().


The documentation for this class was generated from the following files: