OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DhcpHandler Class Reference

#include <dhcp_handler.h>

Inheritance diagram for DhcpHandler:
Collaboration diagram for DhcpHandler:

Classes

struct  DhcpRequestData
 
struct  Dhcpv4OptionHandler
 

Public Member Functions

 DhcpHandler (Agent *agent, boost::shared_ptr< PktInfo > info, boost::asio::io_context &io)
 
virtual ~DhcpHandler ()
 
bool Run ()
 
- Public Member Functions inherited from DhcpHandlerBase
 DhcpHandlerBase (Agent *agent, boost::shared_ptr< PktInfo > info, boost::asio::io_context &io)
 
virtual ~DhcpHandlerBase ()
 
- Public Member Functions inherited from ProtoHandler
 ProtoHandler (Agent *agent, boost::shared_ptr< PktInfo > info, boost::asio::io_context &io)
 
virtual ~ProtoHandler ()
 
void Send (uint32_t itf, uint32_t vrf, uint16_t, PktHandler::PktModuleName)
 
void Send (uint32_t itf, uint32_t vrf, uint16_t cmd, uint32_t param1, uint32_t param2, PktHandler::PktModuleName mod)
 
int EthHdr (const MacAddress &src, const MacAddress &dest, const uint16_t proto)
 
int EthHdr (char *buff, uint16_t len, const MacAddress &src, const MacAddress &dest, const uint16_t proto, uint16_t vlan_id)
 
int EthHdr (char *buff, uint16_t len, const Interface *interface, const MacAddress &src, const MacAddress &dest, const uint16_t proto)
 
int EthHdr (char *buff, uint16_t len, uint32_t ifindex, const MacAddress &src, const MacAddress &dest, const uint16_t proto)
 
void VlanHdr (uint8_t *ptr, uint16_t tci)
 
void IpHdr (uint16_t len, in_addr_t src, in_addr_t dest, uint8_t protocol, uint16_t id, uint8_t ttl)
 
uint16_t IpHdr (char *buff, uint16_t buf_len, uint16_t len, in_addr_t src, in_addr_t dest, uint8_t protocol, uint16_t id, uint8_t ttl)
 
void Ip6Hdr (ip6_hdr *ip, uint16_t plen, uint8_t next_header, uint8_t hlim, uint8_t *src, uint8_t *dest)
 
void UdpHdr (uint16_t len, in_addr_t src, uint16_t src_port, in_addr_t dest, uint16_t dest_port)
 
void UdpHdr (udphdr *hdr, uint16_t len, const uint8_t *src, uint16_t src_port, const uint8_t *dest, uint16_t dest_port, uint8_t next_hdr)
 
void UdpHdr (uint16_t len, const uint8_t *src, uint16_t src_port, const uint8_t *dest, uint16_t dest_port, uint8_t next_hdr)
 
uint16_t UdpHdr (udphdr *udp, uint16_t buf_len, uint16_t len, in_addr_t src, uint16_t src_port, in_addr_t dest, uint16_t dest_port)
 
uint16_t IcmpHdr (char *buff, uint16_t buf_len, uint8_t type, uint8_t code, uint16_t word1, uint16_t word2)
 
void IcmpChecksum (char *buff, uint16_t buf_len)
 
void IgmpChecksum (char *buff, uint16_t buf_len)
 
uint32_t Sum (uint16_t *, std::size_t, uint32_t) const
 
uint16_t Csum (uint16_t *, std::size_t, uint32_t) const
 
uint16_t UdpCsum (in_addr_t, in_addr_t, std::size_t, udphdr *) const
 
uint16_t Ipv6Csum (const uint8_t *src, const uint8_t *dest, uint16_t plen, uint8_t next_hdr, uint16_t *hdr) const
 
uint16_t Icmpv6Csum (const uint8_t *src, const uint8_t *dest, icmp6_hdr *icmp, uint16_t plen) const
 
Agentagent () const
 
uint32_t GetVrfIndex () const
 
uint32_t GetInterfaceIndex () const
 
uint16_t GetLength () const
 
uint32_t GetCmdParam () const
 
PktInfopkt_info () const
 
uint32_t EncapHeaderLen () const
 

Private Member Functions

bool HandleVmRequest ()
 
bool HandleMessage ()
 
bool HandleDhcpFromFabric ()
 
bool ReadOptions (int16_t opt_rem_len)
 
bool GetGatewayInterfaceLease ()
 
void ReleaseGatewayInterfaceLease ()
 
bool FindLeaseData ()
 
void FillDhcpInfo (Ip4Address &addr, int plen, Ip4Address &gw, Ip4Address &dns)
 
void WriteOption82 (Dhcpv4Options *opt, uint16_t *optlen)
 
bool ReadOption82 (Dhcpv4Options *opt)
 
bool CreateRelayPacket ()
 
bool CreateRelayResponsePacket ()
 
void RelayRequestToFabric ()
 
void RelayResponseFromFabric ()
 
uint16_t DhcpHdr (in_addr_t, in_addr_t)
 
uint16_t AddIP (uint16_t opt_len, const std::string &input)
 
uint16_t AddDomainNameOption (uint16_t opt_len)
 
uint16_t FillDhcpResponse (const MacAddress &dest_mac, in_addr_t src_ip, in_addr_t dest_ip, in_addr_t siaddr, in_addr_t yiaddr)
 
void SendDhcpResponse ()
 
bool IsOptionRequested (uint8_t option)
 
bool IsRouterOptionNeeded ()
 
void UpdateStats ()
 
DhcpHandler::DhcpOptionCategory OptionCategory (uint32_t option) const
 
uint32_t OptionCode (const std::string &option) const
 
void DhcpTrace (const std::string &msg) const
 
 DISALLOW_COPY_AND_ASSIGN (DhcpHandler)
 

Private Attributes

dhcphdrdhcp_
 
uint8_t msg_type_
 
uint8_t out_msg_type_
 
std::string parameters_
 
std::string nak_msg_
 
DhcpRequestData request_
 

Additional Inherited Members

- Public Types inherited from DhcpHandlerBase
enum  DhcpOptionCategory {
  None, NoData, Bool, Byte,
  ByteArray, ByteString, ByteOneIPPlus, String,
  Int32bit, Uint32bit, Uint16bit, Uint16bitArray,
  OneIPv4, ZeroIPv4Plus, OneIPv4Plus, TwoIPv4Plus,
  OneIPv6, OneIPv6Plus, ClasslessRoute, NameCompression,
  NameCompressionArray, ByteNameCompression
}
 
enum  DhcpOptionLevel { Invalid, InterfaceLevel, SubnetLevel, IpamLevel }
 
- Protected Member Functions inherited from DhcpHandlerBase
uint16_t AddNoDataOption (uint32_t option, uint16_t opt_len)
 
uint16_t AddByteOption (uint32_t option, uint16_t opt_len, const std::string &input)
 
uint16_t AddByteArrayOption (uint32_t option, uint16_t opt_len, const std::string &input)
 
uint16_t AddByteStringOption (uint32_t option, uint16_t opt_len, const std::string &input)
 
uint16_t AddByteIPOption (uint32_t option, uint16_t opt_len, const std::string &input)
 
uint16_t AddStringOption (uint32_t option, uint16_t opt_len, const std::string &input)
 
uint16_t AddIntegerOption (uint32_t option, uint16_t opt_len, const std::string &input)
 
uint16_t AddShortArrayOption (uint32_t option, uint16_t opt_len, const std::string &input, bool array)
 
bool IsValidIpOption (uint32_t option, const std::string &ipstr, bool is_v4)
 
bool IsValidDnsOption (uint32_t option, const std::string &ipstr)
 
uint16_t AddIpv4Option (uint32_t option, uint16_t opt_len, const std::string &input, uint8_t min_count, uint8_t max_count, uint8_t multiples)
 
uint16_t AddIpv6Option (uint32_t option, uint16_t opt_len, const std::string &input, bool list)
 
uint16_t AddCompressedNameOption (uint32_t option, uint16_t opt_len, const std::string &input, bool list)
 
uint16_t AddByteCompressedNameOption (uint32_t option, uint16_t opt_len, const std::string &input)
 
uint16_t AddCompressedName (uint16_t opt_len, const std::string &input)
 
uint16_t AddDnsServers (uint16_t opt_len)
 
void ReadClasslessRoute (uint32_t option, uint16_t opt_len, const std::string &input)
 
uint16_t AddClasslessRouteOption (uint16_t opt_len)
 
uint16_t AddConfigDhcpOptions (uint16_t opt_len, bool is_v6)
 
uint16_t AddDhcpOptions (uint16_t opt_len, std::vector< autogen::DhcpOptionType > &options, DhcpOptionLevel level)
 
void FindDomainName (const IpAddress &vm_addr)
 
bool CanOverrideWithBytes (DhcpOptionCategory category)
 
bool is_flag_set (uint8_t flag) const
 
void set_flag (uint8_t flag)
 
bool is_dns_enabled () const
 
 DISALLOW_COPY_AND_ASSIGN (DhcpHandlerBase)
 
- Protected Attributes inherited from DhcpHandlerBase
VmInterfacevm_itf_
 
uint32_t vm_itf_index_
 
ConfigRecord config_
 
boost::scoped_ptr
< DhcpOptionHandler
option_
 
std::bitset< 256 > flags_
 
bool dns_enable_
 
std::string routers_
 
std::vector
< OperDhcpOptions::HostRoute
host_routes_
 
DhcpOptionLevel host_routes_level_
 
std::string ipam_name_
 
autogen::IpamType ipam_type_
 
autogen::VirtualDnsType vdns_type_
 
uint32_t siaddr_tftp_
 
- Protected Attributes inherited from ProtoHandler
Agentagent_
 
boost::shared_ptr< PktInfopkt_info_
 
boost::asio::io_context & io_
 

Detailed Description

Definition at line 261 of file dhcp_handler.h.

Constructor & Destructor Documentation

DhcpHandler::DhcpHandler ( Agent agent,
boost::shared_ptr< PktInfo info,
boost::asio::io_context &  io 
)

Definition at line 327 of file dhcp_handler.cc.

DhcpHandler::~DhcpHandler ( )
virtual

Definition at line 335 of file dhcp_handler.cc.

Member Function Documentation

uint16_t DhcpHandler::AddDomainNameOption ( uint16_t  opt_len)
private

Definition at line 939 of file dhcp_handler.cc.

Here is the call graph for this function:

uint16_t DhcpHandler::AddIP ( uint16_t  opt_len,
const std::string &  input 
)
privatevirtual

Implements DhcpHandlerBase.

Definition at line 924 of file dhcp_handler.cc.

bool DhcpHandler::CreateRelayPacket ( )
private

Definition at line 739 of file dhcp_handler.cc.

Here is the call graph for this function:

bool DhcpHandler::CreateRelayResponsePacket ( )
private

Definition at line 820 of file dhcp_handler.cc.

Here is the call graph for this function:

uint16_t DhcpHandler::DhcpHdr ( in_addr_t  yiaddr,
in_addr_t  siaddr 
)
private

Definition at line 950 of file dhcp_handler.cc.

Here is the call graph for this function:

void DhcpHandler::DhcpTrace ( const std::string &  msg) const
privatevirtual

Implements DhcpHandlerBase.

Definition at line 1203 of file dhcp_handler.cc.

DhcpHandler::DISALLOW_COPY_AND_ASSIGN ( DhcpHandler  )
private
void DhcpHandler::FillDhcpInfo ( Ip4Address addr,
int  plen,
Ip4Address gw,
Ip4Address dns 
)
private

Definition at line 577 of file dhcp_handler.cc.

uint16_t DhcpHandler::FillDhcpResponse ( const MacAddress dest_mac,
in_addr_t  src_ip,
in_addr_t  dest_ip,
in_addr_t  siaddr,
in_addr_t  yiaddr 
)
private

Definition at line 1051 of file dhcp_handler.cc.

Here is the call graph for this function:

bool DhcpHandler::FindLeaseData ( )
private

Definition at line 626 of file dhcp_handler.cc.

Here is the call graph for this function:

bool DhcpHandler::GetGatewayInterfaceLease ( )
private

Definition at line 589 of file dhcp_handler.cc.

Here is the call graph for this function:

bool DhcpHandler::HandleDhcpFromFabric ( )
private

Definition at line 493 of file dhcp_handler.cc.

Here is the call graph for this function:

bool DhcpHandler::HandleMessage ( )
private

Definition at line 477 of file dhcp_handler.cc.

Here is the call graph for this function:

bool DhcpHandler::HandleVmRequest ( )
private

Definition at line 348 of file dhcp_handler.cc.

Here is the call graph for this function:

bool DhcpHandler::IsOptionRequested ( uint8_t  option)
private

Definition at line 1123 of file dhcp_handler.cc.

bool DhcpHandler::IsRouterOptionNeeded ( )
private

Definition at line 1131 of file dhcp_handler.cc.

Here is the call graph for this function:

DhcpHandler::DhcpOptionCategory DhcpHandler::OptionCategory ( uint32_t  option) const
privatevirtual

Implements DhcpHandlerBase.

Definition at line 1153 of file dhcp_handler.cc.

uint32_t DhcpHandler::OptionCode ( const std::string &  option) const
privatevirtual

Implements DhcpHandlerBase.

Definition at line 1160 of file dhcp_handler.cc.

bool DhcpHandler::ReadOption82 ( Dhcpv4Options opt)
private

Definition at line 705 of file dhcp_handler.cc.

Here is the call graph for this function:

bool DhcpHandler::ReadOptions ( int16_t  opt_rem_len)
private

Definition at line 512 of file dhcp_handler.cc.

Here is the call graph for this function:

void DhcpHandler::RelayRequestToFabric ( )
private

Definition at line 893 of file dhcp_handler.cc.

Here is the call graph for this function:

void DhcpHandler::RelayResponseFromFabric ( )
private

Definition at line 901 of file dhcp_handler.cc.

Here is the call graph for this function:

void DhcpHandler::ReleaseGatewayInterfaceLease ( )
private

Definition at line 616 of file dhcp_handler.cc.

Here is the call graph for this function:

bool DhcpHandler::Run ( void  )
virtual

Implements ProtoHandler.

Definition at line 338 of file dhcp_handler.cc.

Here is the call graph for this function:

void DhcpHandler::SendDhcpResponse ( )
private

Definition at line 1078 of file dhcp_handler.cc.

Here is the call graph for this function:

void DhcpHandler::UpdateStats ( )
private

Definition at line 1145 of file dhcp_handler.cc.

Here is the call graph for this function:

void DhcpHandler::WriteOption82 ( Dhcpv4Options opt,
uint16_t *  optlen 
)
private

Definition at line 693 of file dhcp_handler.cc.

Here is the call graph for this function:

Member Data Documentation

dhcphdr* DhcpHandler::dhcp_
private

Definition at line 344 of file dhcp_handler.h.

uint8_t DhcpHandler::msg_type_
private

Definition at line 345 of file dhcp_handler.h.

std::string DhcpHandler::nak_msg_
private

Definition at line 349 of file dhcp_handler.h.

uint8_t DhcpHandler::out_msg_type_
private

Definition at line 346 of file dhcp_handler.h.

std::string DhcpHandler::parameters_
private

Definition at line 348 of file dhcp_handler.h.

DhcpRequestData DhcpHandler::request_
private

Definition at line 350 of file dhcp_handler.h.


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