SatCat5
ip_stack.h
1 // Copyright 2022-2025 The Aerospace Corporation.
3 // This file is a part of SatCat5, licensed under CERN-OHL-W v2 or later.
5 // All-in-one Internet Protocol stack with all basic services.
6 
7 #pragma once
8 
9 #include <satcat5/eth_chat.h>
10 #include <satcat5/eth_dispatch.h>
11 #include <satcat5/ip_dispatch.h>
12 #include <satcat5/ip_ping.h>
13 #include <satcat5/net_echo.h>
14 #include <satcat5/udp_dispatch.h>
15 
16 namespace satcat5 {
17  namespace ip {
32  class Stack {
33  public:
35  Stack(
36  const satcat5::eth::MacAddr& local_mac, // Local MAC address
37  const satcat5::ip::Addr& local_ip, // Local IP address
38  satcat5::io::Writeable* dst, // Ethernet port (Tx)
39  satcat5::io::Readable* src, // Ethernet port (Rx)
40  satcat5::util::TimeRef* timer = 0); // Time reference
41 
42  // Core protocol stack.
47 
48  // User services.
51 
52  // Other accessors:
53  inline satcat5::ip::Addr ipaddr() const
54  {return m_ip.ipaddr();}
55  inline satcat5::eth::MacAddr macaddr() const
56  {return m_ip.macaddr();}
57  inline void set_addr(const satcat5::ip::Addr& addr)
58  {m_ip.set_ipaddr(addr);}
59  inline void set_ipaddr(const satcat5::ip::Addr& addr)
60  {m_ip.set_ipaddr(addr);}
61  inline void set_macaddr(const satcat5::eth::MacAddr& macaddr)
62  {m_ip.set_macaddr(macaddr);}
63  };
64  }
65 }
Implemention of "net::Dispatch" for Ethernet frames.
Definition: eth_dispatch.h:21
Abstract API for reading byte-streams and packets.
Definition: io_readable.h:68
Abstract API for writing byte-streams and packets.
Definition: io_writeable.h:24
Protocol handler and dispatch unit for Internet Protocol v4 (IPv4).
Definition: ip_dispatch.h:43
Automatic "ping" functionality using an ICMP dispatch object A simplified wrapper for basic "ping" fu...
Definition: ip_ping.h:23
All-in-one Internet Protocol stack with all basic services.
Definition: ip_stack.h:32
satcat5::ip::Dispatch m_ip
IPv4 and ICMP layer.
Definition: ip_stack.h:45
satcat5::ip::Table m_route
IPv4 routing table.
Definition: ip_stack.h:44
satcat5::ip::Ping m_ping
Ping+Arping utilities.
Definition: ip_stack.h:50
satcat5::udp::Dispatch m_udp
UDP layer.
Definition: ip_stack.h:46
void set_addr(const satcat5::ip::Addr &addr)
DEPRECATED.
Definition: ip_stack.h:57
satcat5::udp::ProtoEcho m_echo
Echo on UDP port 7.
Definition: ip_stack.h:49
satcat5::eth::Dispatch m_eth
Ethernet layer.
Definition: ip_stack.h:43
Stack(const satcat5::eth::MacAddr &local_mac, const satcat5::ip::Addr &local_ip, satcat5::io::Writeable *dst, satcat5::io::Readable *src, satcat5::util::TimeRef *timer=0)
Create a complete IPv4/UDP protocol stack.
Definition: ip_stack.cc:11
IPv4 forwarding table.
Definition: ip_table.h:144
Dispatcher sorts incoming UDP messages by port index.
Definition: udp_dispatch.h:20
Thin wrapper for echo of UDP/IP frames through udp::Dispatch.
Definition: net_echo.h:56
The TimeRef API provides access to a monotonic time-counter.
Definition: timeref.h:142
Generic Echo service.
An Ethernet MAC address (with serializable interface).
Definition: eth_header.h:29
IPv4 address is a 32-bit unsigned integer.
Definition: ip_core.h:15