Myra Canyon  v0.0.1-768
network control
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Myra::L2 Namespace Reference

Layer 2 (ethernet). More...

Classes

struct  Header
 Layer 2, Ethernet frame. More...
 
struct  Header_with_VLAN
 Layer 2 can also have an optional 802.1Q VLAN tag, which pushes fields out by 4 bytes. More...
 

Enumerations

enum  Ethertype {
  Ethertype::Unknown = 0x0000,
  Ethertype::IPv4 = 0x0008,
  Ethertype::ARP = 0x0608,
  Ethertype::IPv6 = 0xdd86
}
 The Ethertype in network byte order. More...
 

Functions

const Headerget_header (const uint8_t *ptr)
 Get the layer 2 header. More...
 
Ethertype get_ethertype (const Header *header)
 Get the ethertype. More...
 
const uint8_t * get_L3_pointer (const Header *header)
 Get the layer 3 pointer. More...
 
std::string to_string (const Ethertype &type)
 Convert the type to a short text string. More...
 
bool is_known_ethertype (const Ethertype &type)
 Determine if the Ethertype is known. More...
 
bool is_known_ethertype (const Header *header)
 Determine if the Ethertype is known. More...
 
bool is_unknown_ethertype (const Ethertype &type)
 Determine if the Ethertype is unknown. More...
 
bool is_unknown_ethertype (const Header *header)
 Determine if the Ethertype is unknown. More...
 
bool ethertype_is_ARP (const L2::Ethertype type)
 Determine if a packet's layer 3 is ARP. More...
 
bool ethertype_is_ARP (const L2::Header *l2)
 Determine if a packet's layer 3 is ARP. More...
 
bool ethertype_is_IP (const L2::Ethertype type)
 Determine if a packet's layer 3 is IP. More...
 
bool ethertype_is_IP (const L2::Header *l2)
 Determine if a packet's layer 3 is IP. More...
 
bool ethertype_is_IPv4 (const L2::Ethertype type)
 Determine if a packet's layer 3 is IPv4. More...
 
bool ethertype_is_IPv4 (const L2::Header *l2)
 Determine if a packet's layer 3 is IPv4. More...
 
bool ethertype_is_IPv6 (const L2::Ethertype type)
 Determine if a packet's layer 3 is IPv6. More...
 
bool ethertype_is_IPv6 (const L2::Header *l2)
 Determine if a packet's layer 3 is IPv6. More...
 

Detailed Description

Layer 2 (ethernet).

Enumeration Type Documentation

enum Myra::L2::Ethertype
strong

The Ethertype in network byte order.

Note
If you add a new type, also update Myra::DB::update_ethertypes() to ensure it gets written to the database.
Enumerator
Unknown 
IPv4 

host 0x0800, net 0x0008, aka ETHERTYPE_IP

ARP 

host 0x0806, net 0x0608, aka ETHERTYPE_ARP

IPv6 

host 0x86dd, net 0xdd86, aka ETHERTYPE_IPV6

Function Documentation

bool Myra::L2::ethertype_is_ARP ( const L2::Ethertype  type)
inline

Determine if a packet's layer 3 is ARP.

Here is the caller graph for this function:

bool Myra::L2::ethertype_is_ARP ( const L2::Header *  l2)
inline

Determine if a packet's layer 3 is ARP.

Here is the call graph for this function:

bool Myra::L2::ethertype_is_IP ( const L2::Ethertype  type)
inline

Determine if a packet's layer 3 is IP.

See also
L2::ethertype_is_IPv4()
L2::ethertype_is_IPv6()

Here is the caller graph for this function:

bool Myra::L2::ethertype_is_IP ( const L2::Header *  l2)
inline

Determine if a packet's layer 3 is IP.

See also
L2::ethertype_is_IPv4()
L2::ethertype_is_IPv6()

Here is the call graph for this function:

bool Myra::L2::ethertype_is_IPv4 ( const L2::Ethertype  type)
inline

Determine if a packet's layer 3 is IPv4.

Here is the caller graph for this function:

bool Myra::L2::ethertype_is_IPv4 ( const L2::Header *  l2)
inline

Determine if a packet's layer 3 is IPv4.

Here is the call graph for this function:

bool Myra::L2::ethertype_is_IPv6 ( const L2::Ethertype  type)
inline

Determine if a packet's layer 3 is IPv6.

Here is the caller graph for this function:

bool Myra::L2::ethertype_is_IPv6 ( const L2::Header *  l2)
inline

Determine if a packet's layer 3 is IPv6.

Here is the call graph for this function:

Ethertype Myra::L2::get_ethertype ( const Header *  header)
inline

Get the ethertype.

Here is the caller graph for this function:

const Header* Myra::L2::get_header ( const uint8_t *  ptr)
inline

Get the layer 2 header.

Here is the caller graph for this function:

const uint8_t* Myra::L2::get_L3_pointer ( const Header *  header)
inline

Get the layer 3 pointer.

Here is the caller graph for this function:

bool Myra::L2::is_known_ethertype ( const Ethertype &  type)
inline

Determine if the Ethertype is known.

Returns
true if the Ethertype value maps to one of the Myra::L2::Ethertype enums

Here is the call graph for this function:

Here is the caller graph for this function:

bool Myra::L2::is_known_ethertype ( const Header *  header)
inline

Determine if the Ethertype is known.

Returns
true if the Ethertype value maps to one of the Myra::L2::Ethertype enums

Here is the call graph for this function:

bool Myra::L2::is_unknown_ethertype ( const Ethertype &  type)
inline

Determine if the Ethertype is unknown.

Returns
true if the Ethertype value does not map to one of the Myra::L2::Ethertype enums

Here is the call graph for this function:

bool Myra::L2::is_unknown_ethertype ( const Header *  header)
inline

Determine if the Ethertype is unknown.

Returns
true if the Ethertype value does not map to one of the Myra::L2::Ethertype enums

Here is the call graph for this function:

std::string Myra::L2::to_string ( const Ethertype &  type)
inline

Convert the type to a short text string.

For example:

Input Output
L2::Ethertype::IPv4 "IPv4"
L2::Ethertype::ARP "ARP"
L2::Ethertype::IPv6 "IPv6"
anything else "unknown"

Here is the caller graph for this function: