2023-05-03 14:01:32 +03:00
|
|
|
|
/*
|
|
|
|
|
|
* eth_ip.hpp
|
|
|
|
|
|
*
|
2023-06-08 12:27:49 +03:00
|
|
|
|
* Created on: 13 <EFBFBD><EFBFBD><EFBFBD>. 2023 <EFBFBD>.
|
2023-05-03 14:01:32 +03:00
|
|
|
|
* Author: sychev
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef FREE_RTOS_ETHERNET_IP_ETH_IP_HPP_
|
|
|
|
|
|
#define FREE_RTOS_ETHERNET_IP_ETH_IP_HPP_
|
|
|
|
|
|
|
2023-10-24 14:02:04 +03:00
|
|
|
|
#include <networking/enet/utils/include/enet_apputils.h>
|
|
|
|
|
|
|
2023-06-26 18:22:30 +03:00
|
|
|
|
#include "free_rtos/handler_store/handler_store.hpp"
|
|
|
|
|
|
#include "free_rtos/ethernet_ip/eth_stack_iface.hpp"
|
|
|
|
|
|
#include "free_rtos/ethernet/eth_frame.h"
|
|
|
|
|
|
#include "free_rtos/ethernet_ip/eth_arp_iface.hpp"
|
|
|
|
|
|
#include "free_rtos/ethernet_ip/eth_ip_iface.hpp"
|
2023-05-03 14:01:32 +03:00
|
|
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
|
|
|
|
namespace free_rtos {
|
|
|
|
|
|
|
|
|
|
|
|
class EthIp : public Handler, public EthIpIface {
|
|
|
|
|
|
public:
|
|
|
|
|
|
EthIp(EthStackIface& eth_stack, EthArpIface& arp);
|
|
|
|
|
|
|
|
|
|
|
|
void setSelfIpAddr(uint32_t ip) {self_ip_ = ip;};
|
2023-10-24 14:02:04 +03:00
|
|
|
|
void setSelfMac(uint64_t mac) {self_mac_ = mac;};
|
2023-05-03 14:01:32 +03:00
|
|
|
|
|
|
|
|
|
|
virtual uint32_t getSelfIpAddr() override {return self_ip_;};
|
|
|
|
|
|
|
|
|
|
|
|
virtual bool send(TEthMacPorts port_id, uint32_t dest_ip, uint8_t prot_id, TEthPkt& pkt) override;
|
2023-10-24 14:02:04 +03:00
|
|
|
|
virtual bool send(IpHandlerArgs& handlerArgs) override;
|
|
|
|
|
|
|
|
|
|
|
|
virtual int32_t Process(uint8_t * p_data, uint32_t len) override;
|
2023-10-26 10:21:41 +03:00
|
|
|
|
virtual uint16_t Sender(HandlerArgs& handlerArgs, size_t scatter_segment) override;
|
2023-05-03 14:01:32 +03:00
|
|
|
|
|
|
|
|
|
|
bool Register(uint8_t prot_id, Handler * p_handler);
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
HandlerStore handlers_;
|
|
|
|
|
|
|
|
|
|
|
|
EthStackIface& eth_stack_;
|
|
|
|
|
|
EthArpIface& arp_;
|
|
|
|
|
|
|
2023-06-08 12:27:49 +03:00
|
|
|
|
uint32_t self_ip_; /// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ip-<2D><><EFBFBD><EFBFBD><EFBFBD>
|
2023-10-24 14:02:04 +03:00
|
|
|
|
uint64_t self_mac_;
|
|
|
|
|
|
|
|
|
|
|
|
uint16_t ip_indet_; /// \u043f\u0457\u0405\u043f\u0457\u0405\u043f\u0457\u0405\u043f\u0457\u0405 ip_id
|
|
|
|
|
|
|
2023-10-26 17:59:51 +03:00
|
|
|
|
inline uint16_t fillIpHeader(IpHandlerArgs& ipHandlerArgs);
|
2023-10-26 10:21:41 +03:00
|
|
|
|
inline uint16_t fillEthFrameHeader(IpHandlerArgs& ipHandlerArgs);
|
2023-05-03 14:01:32 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* FREE_RTOS_ETHERNET_IP_ETH_IP_HPP_ */
|