SatCat5
ip_stack.cc
1 // Copyright 2022-2024 The Aerospace Corporation.
3 // This file is a part of SatCat5, licensed under CERN-OHL-W v2 or later.
5 
6 #include <satcat5/ip_stack.h>
7 
10 
11 Stack::Stack(
12  const satcat5::eth::MacAddr& local_mac, // Local MAC address
13  const satcat5::ip::Addr& local_ip, // Local IP address
14  satcat5::io::Writeable* dst, // Ethernet port (Tx)
15  satcat5::io::Readable* src, // Ethernet port (Rx)
16  satcat5::util::TimeRef* timer) // Time reference
17  : m_eth(local_mac, dst, src)
18  , m_route()
19  , m_ip(local_ip, &m_eth, &m_route)
20  , m_udp(&m_ip)
21  , m_echo(&m_udp)
22  , m_ping(&m_ip)
23 {
24  // If user provides a reference, set the global system time.
25  timekeeper.suggest_clock(timer);
26 }
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
All-in-one Internet Protocol stack with all basic services.
Definition: ip_stack.h:32
void suggest_clock(satcat5::util::TimeRef *timer)
Compare the provided reference to the current TimeRef, and keep whichever is "better" by an internal ...
Definition: polling.cc:257
The TimeRef API provides access to a monotonic time-counter.
Definition: timeref.h:142
Timekeeper timekeeper
There is a single global instance of the Timekeeper class.
Definition: polling.cc:50
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