SatCat5
eth_protocol.cc
1 // Copyright 2023-2024 The Aerospace Corporation.
3 // This file is a part of SatCat5, licensed under CERN-OHL-W v2 or later.
5 
6 #include <satcat5/eth_dispatch.h>
7 #include <satcat5/eth_protocol.h>
8 
13 using satcat5::net::Type;
14 
16  Dispatch* dispatch,
17  const MacType& ethertype,
18  const VlanTag& vtag)
19  : satcat5::net::Protocol(Type(vtag.vid(), ethertype.value))
20  , m_iface(dispatch)
21  , m_etype(ethertype)
22 {
23  if (m_iface) m_iface->add(this);
24 }
25 
26 #if SATCAT5_ALLOW_DELETION
27 satcat5::eth::Protocol::~Protocol()
28 {
29  if (m_iface) m_iface->remove(this);
30 }
31 #endif
Send packets to a specific Ethernet address.
Definition: eth_address.h:17
Implemention of "net::Dispatch" for Ethernet frames.
Definition: eth_dispatch.h:21
Accept incoming Ethernet packets by EtherType.
Definition: eth_protocol.h:24
satcat5::eth::Dispatch *const m_iface
Parent interface (e.g., for address and I/O)
Definition: eth_protocol.h:38
Protocol(satcat5::eth::Dispatch *dispatch, const satcat5::eth::MacType &ethertype, const satcat5::eth::VlanTag &vtag=satcat5::eth::VTAG_NONE)
Register or unregister this handler with the Dispatcher.
Definition: eth_protocol.cc:15
void add(satcat5::net::Protocol *proto)
Register a Protocol object.
Definition: net_dispatch.h:55
EtherType field (uint16) is used a protocol-ID [1536..65535].
Definition: eth_header.h:96
Header contents for an 802.1Q Virtual-LAN tag.
Definition: eth_header.h:124
Multipurpose filter for matching fields in network packets.
Definition: net_type.h:38