sitara_depot/components/free_rtos/ethernet_ip/eth_stack.hpp
algin ae3cac8a7d feat: First commit
Adds sitara_depot/free_rtos

Original one is on server_gorbunov/SmartForce4.0/sitara_depot
2023-05-03 14:01:32 +03:00

72 lines
1.6 KiB
C++

/*
* eth_stack.hpp
*
* Created on: 14 ìàð. 2023 ã.
* Author: sychev
*/
#ifndef FREE_RTOS_ETHERNET_IP_ETH_STACK_HPP_
#define FREE_RTOS_ETHERNET_IP_ETH_STACK_HPP_
#include "ethernet_ip/eth_arp.hpp"
#include "ethernet_ip/eth_ip.hpp"
#include "ethernet_ip/eth_icmp.hpp"
#include "ethernet_ip/eth_udp_server.hpp"
#include "ethernet_ip/eth_stack_iface.hpp"
#include "handler_store/handler_store.hpp"
#include "ethernet/eth_types.h"
#include "ethernet/eth_tx_flow_iface.hpp"
namespace free_rtos {
class EthStack : public EthStackIface {
public:
struct Settings {
uint64_t mac_addr_be; /// big endian
uint32_t ip_addr_be; /// big endian
TEthMacPorts mac_port;
};
EthStack(EthTxFlowIface& tx_flow);
bool init(Settings& sett);
virtual void set_mac_address(uint64_t mac_be) override;
virtual void rx_handler(uint8_t * p_data, uint32_t len) override;
virtual bool send_pkt(TEthMacPorts port_id, uint64_t mac_dst, uint16_t prot_id, TEthPkt& pkt) override;
EthUdpServerIface * getUdpServerPtr() {return &udp_;}
/*
* Ðåãèñòðàöèÿ îáðàáîò÷èêà ïðîòîêîëà íà óðîâíå ethernet
*/
virtual bool Register(uint32_t prot_id, Handler * p_handler) override;
private:
struct EthData {
uint64_t self_mac_; /// Ñîáñòâåííûé ìàê àäðåñ
TEthMacPorts mac_port_;
uint32_t self_ip_;
};
EthTxFlowIface& tx_flow_;
HandlerStore rx_pkt_handler_;
EthData eth_;
EthArp arp_;
EthIp ip_;
EthIcmp icmp_;
EthUdpServer udp_;
};
}
#endif /* FREE_RTOS_ETHERNET_IP_ETH_STACK_HPP_ */