Kea: isc::dhcp::PktFilterLPF Class Reference

| Kea 2.2.0

Public Member Functions | List of all members
isc::dhcp::PktFilterLPF Class Reference

Packet handling class using Linux Packet Filtering. More...

`#include <pkt_filter_lpf.h>`

Inheritance diagram for isc::dhcp::PktFilterLPF:
[legend]

## Public Member Functions
virtual bool | isDirectResponseSupported () const
| Check if packet can be sent to the host without address directly. More...
virtual SocketInfo | openSocket (Iface &iface, const isc::asiolink::IOAddress &addr, const uint16_t port, const bool receive_bcast, const bool send_bcast)
| Open primary and fallback socket. More...
virtual Pkt4Ptr | receive (Iface &iface, const SocketInfo &socket_info)
| Receive packet over specified socket. More...
virtual int | send (const Iface &iface, uint16_t sockfd, const Pkt4Ptr &pkt)
| Send packet over specified socket. More...
Public Member Functions inherited from isc::dhcp::PktFilter
virtual | ~PktFilter ()
| Virtual Destructor. More...
virtual bool | isDirectResponseSupported () const =0
| Check if packet can be sent to the host without address directly. More...
virtual SocketInfo | openSocket (Iface &iface, const isc::asiolink::IOAddress &addr, const uint16_t port, const bool receive_bcast, const bool send_bcast)=0
| Open primary and fallback socket. More...
virtual Pkt4Ptr | receive (Iface &iface, const SocketInfo &socket_info)=0
| Receive packet over specified socket. More...
virtual int | send (const Iface &iface, uint16_t sockfd, const Pkt4Ptr &pkt)=0
| Send packet over specified socket. More...

## Additional Inherited Members
Protected Member Functions inherited from isc::dhcp::PktFilter
virtual int | openFallbackSocket (const isc::asiolink::IOAddress &addr, const uint16_t port)
| Default implementation to open a fallback socket. More...

## Detailed Description

Packet handling class using Linux Packet Filtering.

This class provides methods to send and receive DHCPv4 messages using raw sockets and Linux Packet Filtering. It is used by `isc::dhcp::IfaceMgr` to send DHCPv4 messages to the hosts which don't have an IPv4 address assigned yet.

Definition at line 23 of file pkt_filter_lpf.h.

## Member Function Documentation

## ◆ isDirectResponseSupported()

virtual bool isc::dhcp::PktFilterLPF::isDirectResponseSupported | ( |  | ) | const
| inlinevirtual

Check if packet can be sent to the host without address directly.

This class supports direct responses to the host without address.

Returns
  true always.

Implements isc::dhcp::PktFilter.

Definition at line 31 of file pkt_filter_lpf.h.

## ◆ openSocket()

SocketInfo isc::dhcp::PktFilterLPF::openSocket | ( | Iface & | iface,
|  | const isc::asiolink::IOAddress & | addr,
|  | const uint16_t | port,
|  | const bool | receive_bcast,
|  | const bool | send_bcast
| ) |  |
| virtual

Open primary and fallback socket.

Parameters

  iface | Interface descriptor.
  addr | Address on the interface to be used to send packets.
  port | Port number.
  receive_bcast | Configure socket to receive broadcast messages
  send_bcast | Configure socket to send broadcast messages.

Returns
  A structure describing a primary and fallback socket.

Implements isc::dhcp::PktFilter.

Definition at line 132 of file pkt_filter_lpf.cc.

References isc::dhcp::Iface::getIndex(), isc::dhcp::Iface::getName(), isc_throw, isc::dhcp::PktFilter::openFallbackSocket(), and isc::asiolink::IOAddress::toUint32().

Here is the call graph for this function:

## ◆ receive()

Pkt4Ptr isc::dhcp::PktFilterLPF::receive | ( | Iface & | iface,
|  | const SocketInfo & | socket_info
| ) |  |
| virtual

Receive packet over specified socket.

Parameters

  iface | interface
  socket_info | structure holding socket information

Exceptions

  isc::NotImplemented | always

Returns
  Received packet

Implements isc::dhcp::PktFilter.

Definition at line 217 of file pkt_filter_lpf.cc.

References isc::dhcp::decodeEthernetHeader(), isc::dhcp::decodeIpUdpHeader(), isc::dhcp::DHCPDISCOVER, isc::dhcp::SocketInfo::fallbackfd_, isc::dhcp::Iface::getIndex(), isc::util::InputBuffer::getLength(), isc::dhcp::Iface::getName(), isc::util::InputBuffer::getPosition(), isc::dhcp::IfaceMgr::RCVBUFSIZE, isc::util::InputBuffer::readVector(), and isc::dhcp::SocketInfo::sockfd_.

Here is the call graph for this function:

## ◆ send()

int isc::dhcp::PktFilterLPF::send | ( | const Iface & | iface,
|  | uint16_t | sockfd,
|  | const Pkt4Ptr & | pkt
| ) |  |
| virtual

Send packet over specified socket.

Parameters

  iface | interface to be used to send packet
  sockfd | socket descriptor
  pkt | packet to be sent

Exceptions

  isc::NotImplemented | always

Returns
  result of sending a packet. It is 0 if successful.

Implements isc::dhcp::PktFilter.

Definition at line 292 of file pkt_filter_lpf.cc.

References isc::util::OutputBuffer::getData(), isc::dhcp::Iface::getHWType(), isc::dhcp::Iface::getIndex(), isc::util::OutputBuffer::getLength(), isc::dhcp::Iface::getMac(), isc::dhcp::Iface::getMacLen(), isc_throw, isc::util::OutputBuffer::writeData(), isc::dhcp::writeEthernetHeader(), and isc::dhcp::writeIpUdpHeader().

Here is the call graph for this function:

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

- pkt_filter_lpf.h
- pkt_filter_lpf.cc