2b779d5532
- Implement secure transport mechanisms in `gateway_knx_secure_transport.cpp` for handling secure sessions, including AES encryption, session key generation, and secure packet wrapping and unwrapping. - Introduce `OamRouterRuntime` in `oam_router_runtime.cpp` to manage OAM router identity, individual addresses, and tunnel frame handling. - Enhance secure session management with functions for session allocation, authentication, and secure packet processing. - Ensure compatibility with existing KNXnet/IP protocols while adding support for secure communications. Signed-off-by: Tony <tonylu@tony-cloud.com>
64 lines
1.6 KiB
C++
64 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include "esp_idf_platform.h"
|
|
#include "ets_memory_loader.h"
|
|
|
|
#include "esp_netif.h"
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "knx/cemi_frame.h"
|
|
#include "knx/device_object.h"
|
|
#include "knx/platform.h"
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <functional>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#if defined(ENABLE_BAU091A_PERSONA)
|
|
#include "knx/bau091A.h"
|
|
#endif
|
|
|
|
namespace gateway::openknx {
|
|
|
|
class OamRouterRuntime {
|
|
public:
|
|
using CemiFrameSender = std::function<void(const uint8_t* data, size_t len)>;
|
|
|
|
OamRouterRuntime(std::string nvs_namespace,
|
|
uint16_t fallback_individual_address,
|
|
uint16_t tunnel_client_address = 0);
|
|
~OamRouterRuntime();
|
|
|
|
bool available() const;
|
|
uint16_t individualAddress() const;
|
|
uint16_t tunnelClientAddress() const;
|
|
bool configured() const;
|
|
bool programmingMode() const;
|
|
void setProgrammingMode(bool enabled);
|
|
void toggleProgrammingMode();
|
|
EtsMemorySnapshot snapshot() const;
|
|
|
|
DeviceObject* deviceObject();
|
|
Platform* platform();
|
|
void setNetworkInterface(esp_netif_t* netif);
|
|
bool handleTunnelFrame(const uint8_t* data, size_t len, CemiFrameSender sender);
|
|
void loop();
|
|
|
|
private:
|
|
static bool HandleOutboundCemiFrame(CemiFrame& frame, void* context);
|
|
static void EmitTunnelFrame(CemiFrame& frame, void* context);
|
|
static uint16_t DefaultTunnelClientAddress(uint16_t individual_address);
|
|
bool shouldConsumeTunnelFrame(CemiFrame& frame) const;
|
|
|
|
std::string nvs_namespace_;
|
|
CemiFrameSender sender_;
|
|
#if defined(ENABLE_BAU091A_PERSONA)
|
|
EspIdfPlatform platform_;
|
|
Bau091A device_;
|
|
#endif
|
|
};
|
|
|
|
} // namespace gateway::openknx
|