SatCat5
eth_socket.cc
1 // Copyright 2021-2025 The Aerospace Corporation.
3 // This file is a part of SatCat5, licensed under CERN-OHL-W v2 or later.
5 
6 #include <satcat5/eth_socket.h>
7 
10 
12  : SocketCore(iface,
13  m_txbuff, SATCAT5_ESOCK_BUFFSIZE, SATCAT5_ESOCK_PACKETS,
14  m_rxbuff, SATCAT5_ESOCK_BUFFSIZE, SATCAT5_ESOCK_PACKETS)
15 {
16  // No other initialization required.
17 }
18 
20  : SocketCore(iface,
21  nullptr, 0, 0,
22  m_rxbuff, SATCAT5_ESOCK_BUFFSIZE, SATCAT5_ESOCK_PACKETS)
23 {
24  // No other initialization required.
25 }
26 
28  : SocketCore(iface,
29  m_txbuff, SATCAT5_ESOCK_BUFFSIZE, SATCAT5_ESOCK_PACKETS,
30  nullptr, 0, 0)
31 {
32  // No other initialization required.
33 }
34 
37  u8* txbuff, unsigned txbytes, unsigned txpkt,
38  u8* rxbuff, unsigned rxbytes, unsigned rxpkt)
39  : satcat5::eth::AddressContainer(iface)
40  , satcat5::net::SocketCore(&m_addr,
41  txbuff, txbytes, txpkt,
42  rxbuff, rxbytes, rxpkt)
43 {
44  // No other initialization required.
45 }
46 
48  const satcat5::eth::MacType& lcltype,
49  const satcat5::eth::VlanTag& vtag)
50 {
51  m_addr.close(); // Unbind Tx
52  m_filter = Type(vtag.vid(), lcltype.value); // Rebind Rx
53 }
54 
56  const satcat5::eth::MacAddr& dstmac,
57  const satcat5::eth::MacType& dsttype,
58  const satcat5::eth::MacType& lcltype,
59  const satcat5::eth::VlanTag& vtag)
60 {
61  m_addr.connect(dstmac, dsttype, vtag); // Rebind Tx
62  m_filter = Type(vtag.vid(), lcltype.value); // Rebind Rx
63 }
Inheritable container for a eth::Address.
Definition: eth_address.h:60
void close() override
Close any open connections and revert to idle.
Definition: eth_address.cc:37
void connect(const satcat5::eth::MacAddr &addr, const satcat5::eth::MacType &type, const satcat5::eth::VlanTag &vtag=satcat5::eth::VTAG_NONE)
Connect to the designated address.
Definition: eth_address.cc:19
Implemention of "net::Dispatch" for Ethernet frames.
Definition: eth_dispatch.h:21
BufferedIO wrapper for two-way Ethernet communication.
Definition: eth_socket.h:30
SocketCore(satcat5::eth::Dispatch *iface, u8 *txbuff, unsigned txbytes, unsigned txpkt, u8 *rxbuff, unsigned rxbytes, unsigned rxpkt)
Child must provide transmit and receive working buffers.
Definition: eth_socket.cc:35
void bind(const satcat5::eth::MacType &lcltype, const satcat5::eth::VlanTag &vtag=satcat5::eth::VTAG_NONE)
Listening mode only (no remote address).
Definition: eth_socket.cc:47
void connect(const satcat5::eth::MacAddr &dstmac, const satcat5::eth::MacType &dsttype, const satcat5::eth::MacType &lcltype=satcat5::eth::ETYPE_NONE, const satcat5::eth::VlanTag &vtag=satcat5::eth::VTAG_NONE)
Two-way connection.
Definition: eth_socket.cc:55
Socket(satcat5::eth::Dispatch *iface)
Link this socket to a network interface.
Definition: eth_socket.cc:11
SocketRx(satcat5::eth::Dispatch *iface)
Connect this Socket to a network interface.
Definition: eth_socket.cc:19
SocketTx(satcat5::eth::Dispatch *iface)
Connect this Socket to a network interface.
Definition: eth_socket.cc:27
satcat5::net::Type m_filter
Incoming packet filter.
Definition: net_protocol.h:52
An Ethernet MAC address (with serializable interface).
Definition: eth_header.h:29
EtherType field (uint16) is used a protocol-ID [1536..65535].
Definition: eth_header.h:96
u16 value
The 16-bit value is stored in processor-native order.
Definition: eth_header.h:98
Header contents for an 802.1Q Virtual-LAN tag.
Definition: eth_header.h:124
u16 vid() const
Accessors for each individual field.
Definition: eth_header.h:135
Multipurpose filter for matching fields in network packets.
Definition: net_type.h:38