mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-20 17:52:52 +00:00
ethernet: rework type for ethernet type value
Encapsulate the enum into a struct so that it is named Ethernet_frame::Type::Enum, give it the correct storage type uint16_t, and remove those values that are (AFAIK) not used by now (genode, world). Ref #2490
This commit is contained in:
parent
3f269b773d
commit
7b55d4d5d9
@ -299,7 +299,7 @@ class Net::Arp_packet
|
||||
*/
|
||||
bool ethernet_ipv4() const {
|
||||
return ( host_to_big_endian(_hw_addr_type) == ETHERNET
|
||||
&& host_to_big_endian(_prot_addr_type) == Ethernet_frame::IPV4
|
||||
&& host_to_big_endian(_prot_addr_type) == (Genode::uint16_t)Ethernet_frame::Type::IPV4
|
||||
&& _hw_addr_sz == Ethernet_frame::ADDR_LEN
|
||||
&& _prot_addr_sz == Ipv4_packet::ADDR_LEN);
|
||||
}
|
||||
|
@ -68,45 +68,9 @@ class Net::Ethernet_frame
|
||||
/**
|
||||
* Id representing encapsulated protocol.
|
||||
*/
|
||||
enum Ether_type {
|
||||
IPV4 = 0x0800,
|
||||
ARP = 0x0806,
|
||||
WAKE_ON_LAN = 0x0842,
|
||||
SYN3 = 0x1337,
|
||||
RARP = 0x8035,
|
||||
APPLETALK = 0x809B,
|
||||
AARP = 0x80F3,
|
||||
VLAN_TAGGED = 0x8100,
|
||||
IPX = 0x8137,
|
||||
NOVELL = 0x8138,
|
||||
IPV6 = 0x86DD,
|
||||
MAC_CONTROL = 0x8808,
|
||||
SLOW = 0x8809,
|
||||
COBRANET = 0x8819,
|
||||
MPLS_UNICAST = 0x8847,
|
||||
MPLS_MULTICAST = 0x8848,
|
||||
PPPOE_DISCOVERY = 0x8863,
|
||||
PPPOE_STAGE = 0x8864,
|
||||
NLB = 0x886F,
|
||||
JUMBO_FRAMES = 0x8870,
|
||||
EAP = 0x888E,
|
||||
PROFINET = 0x8892,
|
||||
HYPERSCSI = 0x889A,
|
||||
ATAOE = 0x88A2,
|
||||
ETHERCAT = 0x88A4,
|
||||
PROVIDER_BRIDGING = 0x88A8,
|
||||
POWERLINK = 0x88AB,
|
||||
LLDP = 0x88CC,
|
||||
SERCOS_III = 0x88CD,
|
||||
CESOE = 0x88D8,
|
||||
HOMEPLUG = 0x88E1,
|
||||
MAC_SEC = 0x88E5,
|
||||
PRECISION_TIME = 0x88F7,
|
||||
CFM = 0x8902,
|
||||
FCOE = 0x8906,
|
||||
FCOE_Init = 0x8914,
|
||||
Q_IN_Q = 0x9100,
|
||||
LLT = 0xCAFE
|
||||
enum class Type : Genode::uint16_t {
|
||||
IPV4 = 0x0800,
|
||||
ARP = 0x0806,
|
||||
};
|
||||
|
||||
|
||||
@ -138,7 +102,7 @@ class Net::Ethernet_frame
|
||||
/**
|
||||
* \return EtherType - type of encapsulated protocol.
|
||||
*/
|
||||
Genode::uint16_t type() const { return host_to_big_endian(_type); }
|
||||
Type type() const { return (Type)host_to_big_endian(_type); }
|
||||
|
||||
/**
|
||||
* \return payload data.
|
||||
@ -170,7 +134,7 @@ class Net::Ethernet_frame
|
||||
*
|
||||
* \param type the EtherType to be set.
|
||||
*/
|
||||
void type(Genode::uint16_t type) { _type = host_to_big_endian(type); }
|
||||
void type(Type type) { _type = host_to_big_endian((Genode::uint16_t)type); }
|
||||
|
||||
|
||||
/***************
|
||||
@ -208,7 +172,7 @@ class Net::Ethernet_frame_sized : public Ethernet_frame
|
||||
public:
|
||||
|
||||
Ethernet_frame_sized(Mac_address dst_in, Mac_address src_in,
|
||||
Ether_type type_in)
|
||||
Type type_in)
|
||||
:
|
||||
Ethernet_frame(sizeof(Ethernet_frame))
|
||||
{
|
||||
|
@ -24,11 +24,11 @@ void Net::Ethernet_frame::print(Genode::Output &output) const
|
||||
{
|
||||
Genode::print(output, "\033[32mETH\033[0m ", src(), " > ", dst(), " ");
|
||||
switch (type()) {
|
||||
case Ethernet_frame::ARP:
|
||||
case Ethernet_frame::Type::ARP:
|
||||
Genode::print(output,
|
||||
*reinterpret_cast<Arp_packet const *>(data<void>()));
|
||||
break;
|
||||
case Ethernet_frame::IPV4:
|
||||
case Ethernet_frame::Type::IPV4:
|
||||
Genode::print(output,
|
||||
*reinterpret_cast<Ipv4_packet const *>(data<void>()));
|
||||
break;
|
||||
|
@ -81,10 +81,10 @@ void Packet_handler::handle_ethernet(void* src, Genode::size_t size)
|
||||
/* parse ethernet frame header */
|
||||
Ethernet_frame *eth = new (src) Ethernet_frame(size);
|
||||
switch (eth->type()) {
|
||||
case Ethernet_frame::ARP:
|
||||
case Ethernet_frame::Type::ARP:
|
||||
if (!handle_arp(eth, size)) return;
|
||||
break;
|
||||
case Ethernet_frame::IPV4:
|
||||
case Ethernet_frame::Type::IPV4:
|
||||
if(!handle_ip(eth, size)) return;
|
||||
break;
|
||||
default:
|
||||
|
@ -406,7 +406,7 @@ void Interface::_handle_ip(Ethernet_frame ð,
|
||||
void Interface::_broadcast_arp_request(Ipv4_address const &ip)
|
||||
{
|
||||
using Ethernet_arp = Ethernet_frame_sized<sizeof(Arp_packet)>;
|
||||
Ethernet_arp eth_arp(Mac_address(0xff), _router_mac, Ethernet_frame::ARP);
|
||||
Ethernet_arp eth_arp(Mac_address(0xff), _router_mac, Ethernet_frame::Type::ARP);
|
||||
void *const eth_data = eth_arp.data<void>();
|
||||
size_t const arp_size = sizeof(eth_arp) - sizeof(Ethernet_frame);
|
||||
Arp_packet &arp = *new (eth_data) Arp_packet(arp_size);
|
||||
@ -536,8 +536,8 @@ void Interface::_handle_eth(void *const eth_base,
|
||||
log("at ", _domain, " handle ", *eth); }
|
||||
|
||||
switch (eth->type()) {
|
||||
case Ethernet_frame::ARP: _handle_arp(*eth, eth_size); break;
|
||||
case Ethernet_frame::IPV4: _handle_ip(*eth, eth_size, pkt); break;
|
||||
case Ethernet_frame::Type::ARP: _handle_arp(*eth, eth_size); break;
|
||||
case Ethernet_frame::Type::IPV4: _handle_ip(*eth, eth_size, pkt); break;
|
||||
default: throw Bad_network_protocol(); }
|
||||
}
|
||||
catch (Ethernet_frame::No_ethernet_frame) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user