Link local address. More...

#include <senf/Socket/Protocols/Raw/LLAddressing.hh>

Inheritance diagram for senf::LLSocketAddress:

Public Types

enum  PktType {
  Undefined = 0, Host = PACKET_HOST, Broadcast = PACKET_BROADCAST, Multicast = PACKET_MULTICAST,
  OtherHost = PACKET_OTHERHOST, Outgoing = PACKET_OUTGOING
}
 Valid pkttype() values. More...
 

Public Member Functions

MACAddress address () const
 Return address. More...
 
std::string interface () const
 Return interface name. More...
 
unsigned protocol () const
 Return address protocol (ethertype) More...
 
unsigned arptype () const
 Return the arptype field (ARP hardware type) More...
 
PktType pkttype () const
 Return type of packet. More...
 
void address (MACAddress const &addr)
 Change address. More...
 
void interface (std::string const &iface)
 Change interface. More...
 
void protocol (unsigned prot)
 Change protocol. More...
 
- Public Member Functions inherited from senf::BSDSocketAddress
bool operator== (BSDSocketAddress const &other) const
 Compare two arbitrary addresses. More...
 
bool operator< (BSDSocketAddress const &other) const
 Compare two arbitrary addresses. More...
 
bool boolean_test () const
 Return true, if address is not empty. More...
 
short family () const
 Return the address family. More...
 
struct sockaddr const * sockaddr_p () const
 
socklen_t socklen () const
 
socklen_t const * socklen_p () const
 
- Public Member Functions inherited from senf::comparable_safe_bool< BSDSocketAddress >
 operator bool_type () const
 
bool operator! () const
 

Static Public Attributes

static short const addressFamily = AF_PACKET
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &os, LLSocketAddress const &llAddr)
 Write link layer address. More...
 

Structors and default members

 LLSocketAddress ()
 Create empty address. More...
 
 LLSocketAddress (unsigned proto, std::string const &iface="")
 Create address for bind() More...
 
 LLSocketAddress (std::string const &iface)
 Create address for bind() More...
 
 LLSocketAddress (MACAddress const &addr, std::string const &iface="")
 Create address valid to send raw packets. More...
 
 LLSocketAddress (LLSocketAddress const &other)
 
LLSocketAddressoperator= (LLSocketAddress const &other)
 

Additional Inherited Members

- Protected Types inherited from senf::safe_bool_base
typedef void(safe_bool_base::* bool_type) () const
 
- Protected Member Functions inherited from senf::BSDSocketAddress
 BSDSocketAddress (socklen_t len, short family)
 
 BSDSocketAddress (BSDSocketAddress const &other)
 
BSDSocketAddressoperator= (BSDSocketAddress const &other)
 
struct sockaddr * sockaddr_p ()
 
socklen_t * socklen_p ()
 
void socklen (socklen_t len)
 
- Protected Member Functions inherited from senf::comparable_safe_bool< BSDSocketAddress >
 ~comparable_safe_bool ()
 
- Protected Member Functions inherited from senf::safe_bool_base
void this_type_does_not_support_comparisons () const
 
 safe_bool_base ()
 
 safe_bool_base (const safe_bool_base &)
 
safe_bool_baseoperator= (const safe_bool_base &)
 
 ~safe_bool_base ()
 

Detailed Description

Link local address.

LLSocketAddress wraps the standard sockaddr_ll data type. An LLSocketAddress provides quite some information, only part of which is necessary for sending packets. The LLSocketAddress class only allows changing those fields which need to be changed. The other fields are read-only. They are filled by the operating system when receiving a packet

Definition at line 46 of file LLAddressing.hh.

Member Enumeration Documentation

◆ PktType

Valid pkttype() values.

These are the possible values returned by pkttype()

Enumerator
Undefined 
Host 

Packet destined for this host

Broadcast 

Packet sent to the broadcast address

Multicast 

Packet sent to a (link local) multicast address

OtherHost 

Packet sent to another host (promisc)

Outgoing 

Packet sent out from this host

Definition at line 56 of file LLAddressing.hh.

Constructor & Destructor Documentation

◆ LLSocketAddress() [1/5]

senf::LLSocketAddress::LLSocketAddress ( )

Create empty address.

◆ LLSocketAddress() [2/5]

senf::LLSocketAddress::LLSocketAddress ( unsigned  proto,
std::string const &  iface = "" 
)
explicit

Create address for bind()

This constructs an LLSocketAddress valid for calling PacketSocketHandle::bind() with.

Parameters
[in]protoProtocol (Ethertype) to listen for
[in]ifaceInterface name to bind to

◆ LLSocketAddress() [3/5]

senf::LLSocketAddress::LLSocketAddress ( std::string const &  iface)
explicit

Create address for bind()

This constructs an LLSocketAddress valid for calling PacketSocketHandle::bind() with.

Parameters
[in]ifaceInterface name to bind to
Exceptions
UnknownInterfaceExceptionif iface is not a valid interface name.

◆ LLSocketAddress() [4/5]

senf::LLSocketAddress::LLSocketAddress ( MACAddress const &  addr,
std::string const &  iface = "" 
)
explicit

Create address valid to send raw packets.

Addresses created with this constructor are valid for use with PacketSocketHandle::sendto() on a SOCK_DGRAM packet socket.

Parameters
addrAddress to send data to
ifaceInterface to send packet from
Exceptions
UnknownInterfaceExceptionif iface is not a valid interface name.

◆ LLSocketAddress() [5/5]

senf::LLSocketAddress::LLSocketAddress ( LLSocketAddress const &  other)

Member Function Documentation

◆ address() [1/2]

MACAddress senf::LLSocketAddress::address ( ) const

Return address.

◆ address() [2/2]

void senf::LLSocketAddress::address ( MACAddress const &  addr)

Change address.

◆ arptype()

unsigned senf::LLSocketAddress::arptype ( ) const

Return the arptype field (ARP hardware type)

◆ interface() [1/2]

std::string senf::LLSocketAddress::interface ( ) const

Return interface name.

Definition at line 34 of file LLAddressing.cc.

◆ interface() [2/2]

void senf::LLSocketAddress::interface ( std::string const &  iface)

Change interface.

Exceptions
UnknownInterfaceExceptionif iface is not a valid interface name.

Definition at line 46 of file LLAddressing.cc.

◆ operator=()

LLSocketAddress& senf::LLSocketAddress::operator= ( LLSocketAddress const &  other)

◆ pkttype()

PktType senf::LLSocketAddress::pkttype ( ) const

Return type of packet.

◆ protocol() [1/2]

unsigned senf::LLSocketAddress::protocol ( ) const

Return address protocol (ethertype)

◆ protocol() [2/2]

void senf::LLSocketAddress::protocol ( unsigned  prot)

Change protocol.

Friends And Related Function Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream &  os,
LLSocketAddress const &  llAddr 
)
related

Write link layer address.

Member Data Documentation

◆ addressFamily

short const senf::LLSocketAddress::addressFamily = AF_PACKET
static

Definition at line 50 of file LLAddressing.hh.


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