Previous topicNext topic
Help > XEngine_HelpComponents > HelpComponents_WBlackList > WBlackList_IPV4Addr >
WBlackList_IPV4Addr_Init

函数

WBlackList_IPV4Addr_Init

功能

初始化黑名单处理函数

语法

BOOL WBlackList_IPV4Addr_Init(XNETHANDLE *pxhNet)

参数

函数功能:初始化黑名单处理函数
 参数.一:pxhNet
  In/Out:Out
  类型:网络句柄
  可空:N
  意思:导出句柄

返回值

类型:逻辑型
意思:是否成功

备注

 

示例

int Test_IPV4BlackList()
{
    XNETHANDLE xhNet;
    LPCTSTR lpszStartAddr1 = _T("192.168.1.115");
    LPCTSTR lpszStartAddr2 = _T("192.168.2.2");
    LPCTSTR lpszEndAddr2 = _T("192.168.2.115");
    LPCTSTR lpszExist1 = _T("192.168.2.2");
    LPCTSTR lpszExist2 = _T("192.168.2.118");

    if (!WBlackList_IPV4Addr_Init(&xhNet))
    {
        return -1;
    }
    WBlackList_IPV4Addr_Add(xhNet, lpszStartAddr1);
    WBlackList_IPV4Addr_Add(xhNet, lpszStartAddr2, lpszEndAddr2, TRUE);
    WBlackList_IPV4Addr_Add(xhNet, lpszExist1, lpszExist2, TRUE);
    WBlackList_IPV4Addr_Add(xhNet, "192.168.1.1", "192.168.2.255", TRUE);
    WBlackList_IPV4Addr_Add(xhNet, "1.1.1.1", "195.222.2.255", FALSE);
    WBlackList_IPV4Addr_Add(xhNet, "200.1.2.2", "200.1.10.255", TRUE);
    WBlackList_IPV4Addr_Add(xhNet, "200.1.-1.2");

    int nBlackCount = 0;
    BLACKLIST_IPV4ADDR **ppSt_ListBlack;

    WBlackList_IPV4Addr_GetList(xhNet, &ppSt_ListBlack, &nBlackCount);
    for (int i = 0; i < nBlackCount; i++)
    {
        printf("%s -> %s\n", ppSt_ListBlack[i]->tszAddrStart, ppSt_ListBlack[i]->tszAddrEnd);
    }

    if (WBlackList_IPV4Addr_IsExistBlack(xhNet, "200.1.2.30"))
    {
        printf("找到\n");
    }
    else
    {
        printf("没找到\n");
    }

    WBlackList_IPV4Addr_AddWhite(xhNet, "200.1.2.30");
    if (WBlackList_IPV4Addr_IsExistBlack(xhNet, "200.1.2.30"))
    {
        printf("找到\n");
    }
    else
    {
        printf("没找到\n");
    }
    WBlackList_IPV4Addr_Destory(xhNet);
    return 0;
}