Software TSN Switch
A software switch to connect VMs and Containers to a TSN network
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CncServiceImpl Class Referencefinal

#include <CncServiceImpl.h>

Inheritance diagram for CncServiceImpl:
Inheritance graph
Collaboration diagram for CncServiceImpl:
Collaboration graph

Public Member Functions

 CncServiceImpl (const std::string &inventoryFilePath)
 
 ~CncServiceImpl ()
 
grpc::Status GetNetworkState (grpc::ServerContext *context, const cnc::rpc::EmptyRequest *request, cnc::rpc::Topology *response) override
 gRPC method implementation to retrieve the entire network topology, including nodes, interfaces, and their associated LLDP/PTP data.
 
grpc::Status GetAllPtpData (grpc::ServerContext *context, const cnc::rpc::EmptyRequest *request, cnc::rpc::AllPtpDataResponse *response) override
 gRPC method implementation to retrieve all PTP data across all nodes and interfaces in the network.
 
grpc::Status GetAllLldpData (grpc::ServerContext *context, const cnc::rpc::EmptyRequest *request, cnc::rpc::AllLldpDataResponse *response) override
 gRPC method implementation to retrieve all LLDP data across all nodes and interfaces in the network.
 
grpc::Status GetNodePtpData (grpc::ServerContext *context, const cnc::rpc::NodeRequest *request, cnc::rpc::PtpNode *response) override
 gRPC method implementation to retrieve node-specific PTP data for a given node identified by its hostname.
 
grpc::Status GetNodeLldpData (grpc::ServerContext *context, const cnc::rpc::NodeRequest *request, cnc::rpc::LldpNode *response) override
 gRPC method implementation to retrieve node-specific LLDP data for a given node identified by its hostname.
 
grpc::Status GetInterfacePtpData (grpc::ServerContext *context, const cnc::rpc::InterfaceRequest *request, cnc::rpc::PtpPort *response) override
 gRPC method implementation to retrieve interface-specific PTP data for a given interface identified by node hostname and interface name.
 
grpc::Status GetInterfaceLldpData (grpc::ServerContext *context, const cnc::rpc::InterfaceRequest *request, cnc::rpc::LldpPort *response) override
 gRPC method implementation to retrieve interface-specific LLDP data for a given interface identified by node hostname and interface name.
 
grpc::Status GetInterfaceGcl (grpc::ServerContext *context, const cnc::rpc::InterfaceRequest *request, cnc::rpc::GclConfig *response) override
 gRPC method implementation to retrieve GCL (Gate Control List) data for a specific interface identified by node hostname and interface name.
 
grpc::Status GetInterfaceAdminGcl (grpc::ServerContext *context, const cnc::rpc::InterfaceRequest *request, cnc::rpc::AdminGclResponse *response) override
 gRPC method implementation to retrieve administrative GCL (Gate Control List) data for a specific interface identified by node hostname and interface name.
 
grpc::Status GetInterfaceOperGcl (grpc::ServerContext *context, const cnc::rpc::InterfaceRequest *request, cnc::rpc::OperGclResponse *response) override
 gRPC method implementation to retrieve operational GCL (Gate Control List) data for a specific interface identified by node hostname and interface name.
 
grpc::Status SetNodeSchedule (grpc::ServerContext *context, const cnc::rpc::SetNodeScheduleRequest *request, cnc::rpc::SetNodeScheduleResponse *response)
 gRPC method implementation to set schedules for all interfaces on a specific node identified by its hostname.
 
grpc::Status SetInterfaceSchedule (grpc::ServerContext *context, const cnc::rpc::SetInterfaceScheduleRequest *request, cnc::rpc::IetfInterface *response)
 gRPC method implementation to set the schedule for a specific interface identified by node hostname and interface name.
 
grpc::Status GetTopologyGraph (grpc::ServerContext *context, const cnc::rpc::EmptyRequest *request, cnc::rpc::TopologyGraph *response)
 gRPC method implementation to retrieve the topology graph of the network, which includes the nodes and their interconnections based on LLDP data.
 

Private Member Functions

CncNode_t * FindNode (const std::string &hostName)
 
void MapInterface (const ietfInterface_t &internalIface, cnc::rpc::IetfInterface *protoIface)
 Maps an internal CncNode_t structure to a cnc::rpc::Node protobuf message.
 
void MapPtpNode (const PtpNode_t &internalPtp, cnc::rpc::PtpNode *protoPtp)
 Maps an internal PtpNode_t structure to a cnc::rpc::PtpNode protobuf message.
 
void MapLldpNode (const LldpNode_t &internalLldp, cnc::rpc::LldpNode *protoLldp)
 Maps an internal LldpNode_t structure to a cnc::rpc::LldpNode protobuf message.
 
void MapPtpPort (const PtpPort_t &internalPort, cnc::rpc::PtpPort *protoPort)
 Maps an internal PtpPort_t structure to a cnc::rpc::PtpPort protobuf message.
 
void MapLldpPort (const LldpPort_t &internalPort, cnc::rpc::LldpPort *protoPort)
 Maps an internal LldpPort_t structure to a cnc::rpc::LldpPort protobuf message.
 
void ptpBackgroundTask ()
 Background task that periodically fetches PTP data for all nodes. This function runs in a separate thread and updates the topology with the latest PTP data at regular intervals (every 15 minutes). It uses a condition variable to wait for the next fetch interval or to be notified when the service is shutting down.
 

Private Attributes

Topology topology
 
std::unique_ptr< cnc::NetworkManager > networkManager
 
std::shared_mutex topologyMutex
 
std::thread ptpTimerThread
 
std::atomic< bool > stopTimer {false}
 
std::condition_variable timerCV
 
std::mutex timerMutex
 

Constructor & Destructor Documentation

◆ CncServiceImpl()

CncServiceImpl::CncServiceImpl ( const std::string &  inventoryFilePath)

◆ ~CncServiceImpl()

CncServiceImpl::~CncServiceImpl ( )

Member Function Documentation

◆ FindNode()

CncNode_t * CncServiceImpl::FindNode ( const std::string &  hostName)
private

◆ GetAllLldpData()

grpc::Status CncServiceImpl::GetAllLldpData ( grpc::ServerContext *  context,
const cnc::rpc::EmptyRequest *  request,
cnc::rpc::AllLldpDataResponse *  response 
)
override

gRPC method implementation to retrieve all LLDP data across all nodes and interfaces in the network.

Parameters
contextthe gRPC server context for the request
requestan empty request message (no parameters needed)
responsethe protobuf message to be filled with all LLDP data from the network to be returned to the client
Returns
a gRPC status indicating the success or failure of the operation

◆ GetAllPtpData()

grpc::Status CncServiceImpl::GetAllPtpData ( grpc::ServerContext *  context,
const cnc::rpc::EmptyRequest *  request,
cnc::rpc::AllPtpDataResponse *  response 
)
override

gRPC method implementation to retrieve all PTP data across all nodes and interfaces in the network.

Parameters
contextthe gRPC server context for the request
requestan empty request message (no parameters needed)
responsethe protobuf message to be filled with all PTP data from the network to be returned to the client
Returns
a gRPC status indicating the success or failure of the operation

◆ GetInterfaceAdminGcl()

grpc::Status CncServiceImpl::GetInterfaceAdminGcl ( grpc::ServerContext *  context,
const cnc::rpc::InterfaceRequest *  request,
cnc::rpc::AdminGclResponse *  response 
)
override

gRPC method implementation to retrieve administrative GCL (Gate Control List) data for a specific interface identified by node hostname and interface name.

Parameters
contextthe gRPC server context for the request
requestthe protobuf message InterfaceRequest containing the hostname of the node and the name of the interface for which administrative GCL data is requested
responsethe protobuf message to be filled with the administrative GCL data of the specified interface to be returned to the client
Returns
a gRPC status indicating the success or failure of the operation

◆ GetInterfaceGcl()

grpc::Status CncServiceImpl::GetInterfaceGcl ( grpc::ServerContext *  context,
const cnc::rpc::InterfaceRequest *  request,
cnc::rpc::GclConfig *  response 
)
override

gRPC method implementation to retrieve GCL (Gate Control List) data for a specific interface identified by node hostname and interface name.

Parameters
contextthe gRPC server context for the request
requestthe protobuf message InterfaceRequest containing the hostname of the node and the name of the interface for which GCL data is requested
responsethe protobuf message to be filled with the GCL data of the specified interface to be returned to the client
Returns
a gRPC status indicating the success or failure of the operation

◆ GetInterfaceLldpData()

grpc::Status CncServiceImpl::GetInterfaceLldpData ( grpc::ServerContext *  context,
const cnc::rpc::InterfaceRequest *  request,
cnc::rpc::LldpPort *  response 
)
override

gRPC method implementation to retrieve interface-specific LLDP data for a given interface identified by node hostname and interface name.

Parameters
contextthe gRPC server context for the request
requestthe protobuf message InterfaceRequest containing the hostname of the node and the name of the interface for which LLDP data is requested
responsethe protobuf message to be filled with the LLDP data of the specified interface to be returned to the client
Returns
a gRPC status indicating the success or failure of the operation

◆ GetInterfaceOperGcl()

grpc::Status CncServiceImpl::GetInterfaceOperGcl ( grpc::ServerContext *  context,
const cnc::rpc::InterfaceRequest *  request,
cnc::rpc::OperGclResponse *  response 
)
override

gRPC method implementation to retrieve operational GCL (Gate Control List) data for a specific interface identified by node hostname and interface name.

Parameters
contextthe gRPC server context for the request
requestthe protobuf message InterfaceRequest containing the hostname of the node and the name of the interface for which operational GCL data is requested
responsethe protobuf message to be filled with the operational GCL data of the specified interface to be returned to the client
Returns
a gRPC status indicating the success or failure of the operation

◆ GetInterfacePtpData()

grpc::Status CncServiceImpl::GetInterfacePtpData ( grpc::ServerContext *  context,
const cnc::rpc::InterfaceRequest *  request,
cnc::rpc::PtpPort *  response 
)
override

gRPC method implementation to retrieve interface-specific PTP data for a given interface identified by node hostname and interface name.

Parameters
contextthe gRPC server context for the request
requestthe protobuf message InterfaceRequest containing the hostname of the node and the name of the interface for which PTP data is requested
responsethe protobuf message to be filled with the PTP data of the specified interface to be returned to the client
Returns
a gRPC status indicating the success or failure of the operation

◆ GetNetworkState()

grpc::Status CncServiceImpl::GetNetworkState ( grpc::ServerContext *  context,
const cnc::rpc::EmptyRequest *  request,
cnc::rpc::Topology *  response 
)
override

gRPC method implementation to retrieve the entire network topology, including nodes, interfaces, and their associated LLDP/PTP data.

Parameters
contextthe gRPC server context for the request
requestan empty request message (no parameters needed)
responsethe protobuf message to be filled with the complete network topology data to be returned to the client
Returns
a gRPC status indicating the success or failure of the operation

◆ GetNodeLldpData()

grpc::Status CncServiceImpl::GetNodeLldpData ( grpc::ServerContext *  context,
const cnc::rpc::NodeRequest *  request,
cnc::rpc::LldpNode *  response 
)
override

gRPC method implementation to retrieve node-specific LLDP data for a given node identified by its hostname.

Parameters
contextthe gRPC server context for the request
requestthe protobuf message NodeRequest containing the hostname of the node for which LLDP data is requested
responsethe protobuf message to be filled with the LLDP data of the specified node to be returned to the client
Returns
a gRPC status indicating the success or failure of the operation

◆ GetNodePtpData()

grpc::Status CncServiceImpl::GetNodePtpData ( grpc::ServerContext *  context,
const cnc::rpc::NodeRequest *  request,
cnc::rpc::PtpNode *  response 
)
override

gRPC method implementation to retrieve node-specific PTP data for a given node identified by its hostname.

Parameters
contextthe gRPC server context for the request
requestthe protobuf message NodeRequest containing the hostname of the node for which PTP data is requested
responsethe protobuf message to be filled with the PTP data of the specified node to be returned to the client
Returns
a gRPC status indicating the success or failure of the operation

◆ GetTopologyGraph()

grpc::Status CncServiceImpl::GetTopologyGraph ( grpc::ServerContext *  context,
const cnc::rpc::EmptyRequest *  request,
cnc::rpc::TopologyGraph *  response 
)

gRPC method implementation to retrieve the topology graph of the network, which includes the nodes and their interconnections based on LLDP data.

Parameters
contextthe gRPC server context for the request
requestan empty request message (no parameters needed)
responsethe protobuf message to be filled with the topology graph data (nodes and their connections) to be returned to the client
Returns
a gRPC status indicating the success or failure of the operation

◆ MapInterface()

void CncServiceImpl::MapInterface ( const ietfInterface_t &  internalIface,
cnc::rpc::IetfInterface *  protoIface 
)
private

Maps an internal CncNode_t structure to a cnc::rpc::Node protobuf message.

Parameters
internalIfacethe internal ietfInterface_t structure containing the interface data to be mapped
protoIfacethe protobuf message to be filled with the mapped data from internalIface

◆ MapLldpNode()

void CncServiceImpl::MapLldpNode ( const LldpNode_t &  internalLldp,
cnc::rpc::LldpNode *  protoLldp 
)
private

Maps an internal LldpNode_t structure to a cnc::rpc::LldpNode protobuf message.

Parameters
internalLldpthe internal LldpNode_t structure containing the LLDP data to be mapped
protoLldpthe protobuf message to be filled with the mapped data from internalLldp

◆ MapLldpPort()

void CncServiceImpl::MapLldpPort ( const LldpPort_t &  internalPort,
cnc::rpc::LldpPort *  protoPort 
)
private

Maps an internal LldpPort_t structure to a cnc::rpc::LldpPort protobuf message.

Parameters
internalPortthe internal LldpPort_t structure containing the LLDP port data to be mapped
protoPortthe protobuf message to be filled with the mapped data from internalPort

◆ MapPtpNode()

void CncServiceImpl::MapPtpNode ( const PtpNode_t &  internalPtp,
cnc::rpc::PtpNode *  protoPtp 
)
private

Maps an internal PtpNode_t structure to a cnc::rpc::PtpNode protobuf message.

Parameters
internalPtpthe internal PtpNode_t structure containing the PTP data to be mapped
protoPtpthe protobuf message to be filled with the mapped data from internalPtp

◆ MapPtpPort()

void CncServiceImpl::MapPtpPort ( const PtpPort_t &  internalPort,
cnc::rpc::PtpPort *  protoPort 
)
private

Maps an internal PtpPort_t structure to a cnc::rpc::PtpPort protobuf message.

Parameters
internalPortthe internal PtpPort_t structure containing the PTP port data to be mapped
protoPortthe protobuf message to be filled with the mapped data from internalPort

◆ ptpBackgroundTask()

void CncServiceImpl::ptpBackgroundTask ( )
private

Background task that periodically fetches PTP data for all nodes. This function runs in a separate thread and updates the topology with the latest PTP data at regular intervals (every 15 minutes). It uses a condition variable to wait for the next fetch interval or to be notified when the service is shutting down.

◆ SetInterfaceSchedule()

grpc::Status CncServiceImpl::SetInterfaceSchedule ( grpc::ServerContext *  context,
const cnc::rpc::SetInterfaceScheduleRequest *  request,
cnc::rpc::IetfInterface *  response 
)

gRPC method implementation to set the schedule for a specific interface identified by node hostname and interface name.

Parameters
contextthe gRPC server context for the request
requestthe protobuf message SetInterfaceScheduleRequest containing the hostname of the node, the name of the interface, and the schedule data to be set for that specific interface
responsethe protobuf message to be filled with the result of the schedule setting operation (e.g., success status, error messages) to be returned to the client
Returns
a gRPC status indicating the success or failure of the operation

◆ SetNodeSchedule()

grpc::Status CncServiceImpl::SetNodeSchedule ( grpc::ServerContext *  context,
const cnc::rpc::SetNodeScheduleRequest *  request,
cnc::rpc::SetNodeScheduleResponse *  response 
)

gRPC method implementation to set schedules for all interfaces on a specific node identified by its hostname.

Parameters
contextthe gRPC server context for the request
requestthe protobuf message SetNodeScheduleRequest containing the hostname of the node and the schedule data to be set for all interfaces on that node
responsethe protobuf message to be filled with the result of the schedule setting operation (e.g., success status, error messages) to be returned to the client
Returns
a gRPC status indicating the success or failure of the operation

Member Data Documentation

◆ networkManager

std::unique_ptr<cnc::NetworkManager> CncServiceImpl::networkManager
private

◆ ptpTimerThread

std::thread CncServiceImpl::ptpTimerThread
private

◆ stopTimer

std::atomic<bool> CncServiceImpl::stopTimer {false}
private

◆ timerCV

std::condition_variable CncServiceImpl::timerCV
private

◆ timerMutex

std::mutex CncServiceImpl::timerMutex
private

◆ topology

Topology CncServiceImpl::topology
private

◆ topologyMutex

std::shared_mutex CncServiceImpl::topologyMutex
private

The documentation for this class was generated from the following files: