RMM API 2.0.0
Loading...
Searching...
No Matches
RMMUDPCore.h
1#pragma once
2
3#include <iostream>
4#include <json.hpp>
5#include <string>
6
7#include "RMMRegisterAccess.h"
8#include "RMMUtils.h"
9using json = nlohmann::json;
10
14struct ArpLut {
15 std::string destinationIP;
16 std::string destinationMAC;
17 uint32_t destinationPort;
18};
19
24 std::string sourceMAC;
25 std::string sourceIP;
26 uint32_t sourcePort;
29 std::map<uint8_t, ArpLut> lut;
30};
31
40 public:
42 void configUDPCore();
43 rmmStatus arpStatus(const int index, std::unordered_map<std::string, int>* status);
45 rmmStatus getUdpCoreData(UDPCoreData* result);
46 void processMap();
47 bool fillUDPMutexes(uint8_t index);
48 void fillUdpCoreFromJson(json& udpCoreCfg);
49
50 private:
51 RMMRegisterAccess& RMMRegs;
52 uint32_t base_address;
53 UDPCoreData udpCore;
54
55 void disableARP();
56 void enableARP();
57 void writeUDPCoreReg(std::string reg, uint32_t data, int index = -1);
58 uint32_t readUDPCoreReg(std::string reg, int index = -1);
59 uint32_t getUDPCoreAbsAddr(std::string reg, int index = -1);
60 void setARPTimeouts(float refresh_timeout = 1228.7, float reply_timeout = 25.5);
61 void clearDestinationLUTARP();
62 void addDestinationLUTEntry(uint8_t index, std::string ip, uint32_t port, std::string mac_str = "");
63};
Class for managing and writing log messages to different log levels and files.
Definition RMMLog.h:47
Class to handle register access over the ESS Readout Master Module.
Definition RMMRegisterAccess.h:57
RMMLog rmmLog
Log handler for RMMUDPCore messages.
Definition RMMUDPCore.h:44
rmmStatus arpStatus(const int index, std::unordered_map< std::string, int > *status)
Get the ARP status.
Definition RMMUDPCore.cpp:139
void processMap()
Initializes mutexes for each known UDP Core register.
Definition RMMUDPCore.cpp:36
bool fillUDPMutexes(uint8_t index)
Initializes mutexes for each UDP core register related to LUT.
Definition RMMUDPCore.cpp:67
void fillUdpCoreFromJson(json &udpCoreCfg)
Fills the UDP core data from a JSON configuration.
Definition RMMUDPCore.cpp:186
RMMUDPCore(RMMRegisterAccess &RMMRegs)
Constructor for the RMMUDPCore class.
Definition RMMUDPCore.cpp:28
void configUDPCore()
Configure the UDP Core with the configuration storaged into udpCore struct.
Definition RMMUDPCore.cpp:214
rmmStatus getUdpCoreData(UDPCoreData *result)
Retrieve the UDP core configuration data.
Definition RMMUDPCore.cpp:91
Struct to hold ARP lookup table entry.
Definition RMMUDPCore.h:14
std::string destinationIP
Destination IP Address in string format (eg "192.168.2.12")
Definition RMMUDPCore.h:15
std::string destinationMAC
Destination MAC address for using LUT without ARP.
Definition RMMUDPCore.h:16
uint32_t destinationPort
Destination UDP Port.
Definition RMMUDPCore.h:17
Struct to hold data related to the UDP core.
Definition RMMUDPCore.h:23
float arpRefreshTimeout
Seconds before new ARP request is sent to refresh ARP table.
Definition RMMUDPCore.h:27
uint32_t sourcePort
Source UDP port.
Definition RMMUDPCore.h:26
std::string sourceIP
Source IP address in string format (e.g., "192.168.1.1").
Definition RMMUDPCore.h:25
std::map< uint8_t, ArpLut > lut
Lookup table for ARP entries, mapping index to ArpLut structure.
Definition RMMUDPCore.h:29
float arpReplyTimeout
Seconds before new ARP request is sent when no ARP reply is received.
Definition RMMUDPCore.h:28
std::string sourceMAC
Source MAC address.
Definition RMMUDPCore.h:24