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;
}