PracticeDev/study_clang/Mimic/test_judge/include/CNetManager.h

102 lines
3.0 KiB
C
Raw Normal View History

2022-12-20 17:31:11 +08:00
/*************************************************************************
> File Name : CNetManager.h
> Author : FengChao
> EMail : smile.fengchao@gmail.com
> Created Time : Fri 17 Jul 2020 09:31:31 AM CST
************************************************************************/
#ifndef CNETMANAGER_H
#define CNETMANAGER_H
#include <string>
#include "CTypedef.h"
#include "CUdpServer.h"
#include "CUdpClient.h"
#include "CZeroMQ.h"
#include "CJudgeUtils.h"
#define PORT_BIND_SET_HOST 10014
#define PORT_BIND_GET_HOST 10013
#define PORT_BIND_SET_KERNEL 10012
#define PORT_BIND_GET_KERNEL 10011
#define PORT_SET_HOST 10004
#define PORT_GET_HOST 10003
#define PORT_SET_KERNEL 10002
#define PORT_GET_KERNEL 10001
class CNetManager : public CSingleton<CNetManager>
{
public:
CNetManager();
virtual ~CNetManager();
public:
int RecvDataToConfManagerHost(void *pvBuff, unsigned int uiBuffLen);
int SendDataToConfManagerHost(const void *pvData, unsigned int uiDataLen);
int RecvDataToConfManagerKernel(void *pvBuff, unsigned int uiBuffLen);
int SendDataToConfManagerKernel(const void *pvData, unsigned int uiDataLen);
int SendHostDataToAllNos(const void *pvData, unsigned int uiDataLen);
int SendHostDataToNos(int iNosIdx, const void *pvData, unsigned int uiDataLen);
int SendKernelDataToAllNos(const void *pvData, unsigned int uiDataLen);
int SendKernelDataToNos(int iNosIdx, const void *pvData, unsigned int uiDataLen);
int SendDataToShd(const void *pvData, unsigned int uiDataLen);
int RecvDataFromShd(void *pvBuff, unsigned int uiBuffLen);
int SendDataToPCtl(const void *pvData, unsigned int uiDataLen);
int RecvDataFromPCtl(void *pvBuff, unsigned int uiBuffLen);
void RecvNosDataHost();
void RecvNosDataKernel();
void RecvNosStateFromShd();
int GetNosStateById(int iIdx);
int SetNosNetInfoHost(unsigned int uiIdx, const SOCKADDR_IN_T *pstInfo);
int GetNosNetInfoHost(unsigned int uiIdx, SOCKADDR_IN_T *pstInfo);
int SetNosNetInfoKernel(unsigned int uiIdx, const SOCKADDR_IN_T *pstInfo);
int GetNosNetInfoKernel(unsigned int uiIdx, SOCKADDR_IN_T *pstInfo);
void TransNosHostData();
void TransNosKernelData();
void TransBroadcastDataToOther();
void SendPluginsCtrl();
private:
int GetNosIdxBySock(SOCKADDR_IN_T *pstSockAddrIn);
private:
pthread_mutex_t m_NosNetInfoHostMutex;
pthread_mutex_t m_NosNetInfoKernelMutex;
SOCKADDR_IN_T m_stNosNetInfoHost[NOS_MAX_NUM];
SOCKADDR_IN_T m_stNosNetInfoKernel[NOS_MAX_NUM];
CUdpClient m_ConfigManagerHost;
CUdpClient m_ConfigManagerKernel;
CUdpServer m_NosDataHost;
CUdpServer m_NosDataKernel;
CZMQReqRep *m_pShdClient;
CZMQReqRep *m_pPCtlClient;
CZMQSubscriber *m_pNosStateSub;
NosState_T m_stNosState[NOS_MAX_NUM];
CUdpServer m_NosHostTrans;
CUdpServer m_NosKernelTrans;
CUdpServer m_BroadcastDataTrans;
};
#endif /*CNETMANAGER_H*/