9 有线网络的封装

概述

        IPC设备一般都带有网口,支持以有线网络方式接入NVR和其他平台。有线网络的使用比较简单,主要操作有:设置IP地址、子网掩码、网关、DHCP等。在封装有线网络前,我们需要先封装DHCP客户端管理类,用于管理各种网络的DHCP功能。

DHCP客户端管理类

        DHCP客户端管理类的头文件如下:

#pragma once

#include <string>
#include <map>

#include <HP_Base/HP_BaseThread.h>
#include <HP_Base/HP_Mutex.h>

typedef void(*CALLBACK_DHCP_IP_ADDR_GOT)(const std::string &strNetName, unsigned int uiIP, void *pContext);

typedef struct _TDhcpClientManagerParam 
{
    _TDhcpClientManagerParam()
    {
        pCbDhcpIPGot = NULL;
        pCbContext = NULL;
    }

    std::string strScriptFile;
    CALLBACK_DHCP_IP_ADDR_GOT pCbDhcpIPGot;
    void *pCbContext;
}TDhcpClientManagerParam;

class CDhcpClientManager : public CHP_BaseThread
{
public:
    static void Open();
    static CDhcpClientManager *&Singleton();
    static void Close();

    int Init(const TDhcpClientMan

猜你喜欢

转载自blog.csdn.net/hope_wisdom/article/details/129331811