Software TSN Switch
A software switch to connect VMs and Containers to a TSN network
Loading...
Searching...
No Matches
Topology.h
Go to the documentation of this file.
1#pragma once
2
3#include <map>
4#include <memory>
5#include <mutex>
6#include <string>
7#include <vector>
8
9#include "CncTypes.h"
10
18class Topology {
19 public:
24 std::vector<CncNode_t> nodes;
25
30 void buildIndex();
31
37 CncNode_t* getNode(const std::string& nodeName);
38
44 ietfInterface_t* getInterface(const LldpNeighbor_t& neighborInfo);
45
51 std::mutex& getNodeMutex(const std::string& nodeName);
52
53 private:
58 std::map<std::string, CncNode_t*> nodeLookup;
59
64 std::map<std::string, std::unique_ptr<std::mutex>> nodeMutexes;
65
69 std::mutex mapMutex;
70};
Stores and provides lookup access to the controller's in-memory network topology.
Definition Topology.h:18
std::map< std::string, CncNode_t * > nodeLookup
Internal helper for fast lookups. Avoids looping through the vector every time if searching for a nod...
Definition Topology.h:58
std::vector< CncNode_t > nodes
The main database storing all network nodes (Switches/End-Devices). This vector owns the memory of th...
Definition Topology.h:24
CncNode_t * getNode(const std::string &nodeName)
Retrieves a node by its hostname.
Definition Topology.cpp:12
ietfInterface_t * getInterface(const LldpNeighbor_t &neighborInfo)
Retrieves an interface based on LLDP neighbor information.
Definition Topology.cpp:20
std::mutex & getNodeMutex(const std::string &nodeName)
Retrieves a mutex for synchronizing access to a specific node.
Definition Topology.cpp:36
std::map< std::string, std::unique_ptr< std::mutex > > nodeMutexes
Mutexes for synchronizing access to individual nodes. The map is protected by 'mapMutex' to ensure th...
Definition Topology.h:64
void buildIndex()
Creates an index for fast node lookup by hostname Must be called after populating the 'nodes' vector.
Definition Topology.cpp:3
std::mutex mapMutex
Mutex to protect access to the 'nodeMutexes' map when adding new nodes or retrieving mutexes.
Definition Topology.h:69
This struct is used on the CNC side to represent one host with all its interfaces as well as its PTP ...
Definition CncTypes.h:512
Struct that represents the basic information about a system connected to an LLDP-port on a host....
Definition CncTypes.h:223
Struct to hold information about an interface, inspired by the ietf-interfaces yang model.
Definition CncTypes.h:256