|
@@ -47,6 +47,7 @@ namespace GLOBAL
|
|
TCHAR g_szPython27Dir[MAX_PATH] = {0};
|
|
TCHAR g_szPython27Dir[MAX_PATH] = {0};
|
|
TCHAR g_szPython27ResourceConfig[MAX_PATH] = { 0 };
|
|
TCHAR g_szPython27ResourceConfig[MAX_PATH] = { 0 };
|
|
std::string g_strIPAddress;
|
|
std::string g_strIPAddress;
|
|
|
|
+ std::vector<std::string> g_vtIPAddress;
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////
|
|
std::string g_strMacs;
|
|
std::string g_strMacs;
|
|
@@ -1229,7 +1230,7 @@ namespace GLOBAL
|
|
free(old_locale); //还原区域设定;
|
|
free(old_locale); //还原区域设定;
|
|
}
|
|
}
|
|
|
|
|
|
- std::string GetLocalAddress(int nType/*= MIB_IF_TYPE_ETHERNET*/)
|
|
|
|
|
|
+ std::string GetLocalAddress(/*int nType= MIB_IF_TYPE_ETHERNET*/)
|
|
{
|
|
{
|
|
int nCardNo = 1;
|
|
int nCardNo = 1;
|
|
// PIP_ADAPTER_INFO结构体指针存储本机网卡信息
|
|
// PIP_ADAPTER_INFO结构体指针存储本机网卡信息
|
|
@@ -1263,12 +1264,13 @@ namespace GLOBAL
|
|
{
|
|
{
|
|
// 可能网卡有多IP,因此通过循环去判断
|
|
// 可能网卡有多IP,因此通过循环去判断
|
|
IP_ADDR_STRING*pIpAddrString = &(pIpAdapterInfo->IpAddressList);
|
|
IP_ADDR_STRING*pIpAddrString = &(pIpAdapterInfo->IpAddressList);
|
|
- if ( pIpAdapterInfo->Type == nType )
|
|
|
|
|
|
+#if 0
|
|
|
|
+ if ( pIpAdapterInfo->Type == MIB_IF_TYPE_ETHERNET )
|
|
{
|
|
{
|
|
g_strIPAddress = pIpAddrString->IpAddress.String;
|
|
g_strIPAddress = pIpAddrString->IpAddress.String;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
-#if 0
|
|
|
|
|
|
+#else
|
|
switch(pIpAdapterInfo->Type)
|
|
switch(pIpAdapterInfo->Type)
|
|
{
|
|
{
|
|
case MIB_IF_TYPE_OTHER:
|
|
case MIB_IF_TYPE_OTHER:
|
|
@@ -1279,12 +1281,13 @@ namespace GLOBAL
|
|
case MIB_IF_TYPE_LOOPBACK:
|
|
case MIB_IF_TYPE_LOOPBACK:
|
|
case MIB_IF_TYPE_SLIP:
|
|
case MIB_IF_TYPE_SLIP:
|
|
{
|
|
{
|
|
- strAddress = pIpAddrString->IpAddress.String;
|
|
|
|
|
|
+ std::string strAddress = pIpAddrString->IpAddress.String;
|
|
// 需要注意的是有时可能获取的IP地址是0.0.0.0,这时需要过滤掉
|
|
// 需要注意的是有时可能获取的IP地址是0.0.0.0,这时需要过滤掉
|
|
if(std::string("0.0.0.0") == strAddress)
|
|
if(std::string("0.0.0.0") == strAddress)
|
|
break;
|
|
break;
|
|
- std::cout<<_T("第")<<nCardNo<<_T("张网卡的IP地址是")<<strAddress<<std::endl;
|
|
|
|
|
|
+ std::cout << _T("第") << nCardNo << _T("张网卡的IP地址是:") << strAddress << _T(" 类型是:") << pIpAdapterInfo->Type <<std::endl;
|
|
nCardNo++;
|
|
nCardNo++;
|
|
|
|
+ g_vtIPAddress.push_back(strAddress);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
default:
|
|
default:
|
|
@@ -1295,12 +1298,16 @@ namespace GLOBAL
|
|
pIpAdapterInfo = pIpAdapterInfo->Next;
|
|
pIpAdapterInfo = pIpAdapterInfo->Next;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
// 释放内存空间
|
|
// 释放内存空间
|
|
if (pIpAdapterInfo)
|
|
if (pIpAdapterInfo)
|
|
{
|
|
{
|
|
delete pIpAdapterInfo;
|
|
delete pIpAdapterInfo;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 默认使用第一个ip地址;
|
|
|
|
+ if ( g_vtIPAddress.size() )
|
|
|
|
+ g_strIPAddress = g_vtIPAddress.front();
|
|
WriteTextLog(SAT_NOR, "【当前主机IP地址:%s】", g_strIPAddress.c_str());
|
|
WriteTextLog(SAT_NOR, "【当前主机IP地址:%s】", g_strIPAddress.c_str());
|
|
|
|
|
|
return g_strIPAddress;
|
|
return g_strIPAddress;
|
|
@@ -1341,12 +1348,14 @@ namespace GLOBAL
|
|
{
|
|
{
|
|
HANDLE hDeviceFile;
|
|
HANDLE hDeviceFile;
|
|
BOOL isOK = FALSE;
|
|
BOOL isOK = FALSE;
|
|
- if (_tcsnicmp(DeviceInterfaceDetailData->DevicePath + 4, TEXT("pci"), 3) != 0)
|
|
|
|
|
|
+ // 不保留swd调试网卡,root系统网卡.只保留usb和pci
|
|
|
|
+ if (_tcsnicmp(DeviceInterfaceDetailData->DevicePath + 4, TEXT("pci"), 3) != 0 && _tcsnicmp(DeviceInterfaceDetailData->DevicePath + 4, TEXT("usb"), 3) != 0)
|
|
{
|
|
{
|
|
free(DeviceInterfaceDetailData);
|
|
free(DeviceInterfaceDetailData);
|
|
DeviceInterfaceDetailData = NULL;
|
|
DeviceInterfaceDetailData = NULL;
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
+
|
|
MacAddress tagMacAddress;
|
|
MacAddress tagMacAddress;
|
|
tagMacAddress.nNICKind = NIC_PCI;
|
|
tagMacAddress.nNICKind = NIC_PCI;
|
|
_stprintf_s(tagMacAddress.szNICKind, _T("%s"), _T("NIC_PCI"));
|
|
_stprintf_s(tagMacAddress.szNICKind, _T("%s"), _T("NIC_PCI"));
|
|
@@ -1380,6 +1389,7 @@ namespace GLOBAL
|
|
_stprintf_s(&tagMacAddress.szMacAddress[i * 3], MAX_PATH - (i * 3), (i != dwByteRet - 1) ? _T("%02X-") : _T("%02X"), ucData[i]);
|
|
_stprintf_s(&tagMacAddress.szMacAddress[i * 3], MAX_PATH - (i * 3), (i != dwByteRet - 1) ? _T("%02X-") : _T("%02X"), ucData[i]);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ WriteTextLog(SAT_NOR, _T("类型=%d, 路径=%s, MAC=%s, NICKind=%s"), tagMacAddress.nNICKind, tagMacAddress.szDevicePath, tagMacAddress.szMacAddress, tagMacAddress.szNICKind);
|
|
g_vtMac.push_back(tagMacAddress);
|
|
g_vtMac.push_back(tagMacAddress);
|
|
}
|
|
}
|
|
CloseHandle(hDeviceFile);
|
|
CloseHandle(hDeviceFile);
|
|
@@ -1393,14 +1403,10 @@ namespace GLOBAL
|
|
SetupDiDestroyDeviceInfoList(hDevInfo);
|
|
SetupDiDestroyDeviceInfoList(hDevInfo);
|
|
|
|
|
|
#if 1
|
|
#if 1
|
|
|
|
+ // 默认使用第一个mac;
|
|
g_strMacs.clear();
|
|
g_strMacs.clear();
|
|
- std::vector<MacAddress>::iterator it = g_vtMac.begin();
|
|
|
|
- for (; it != g_vtMac.end(); it++)
|
|
|
|
- {
|
|
|
|
- g_strMacs.append(it->szMacAddress);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ if ( g_vtMac.size() )
|
|
|
|
+ g_strMacs = g_vtMac.front().szMacAddress;
|
|
WriteTextLog(SAT_NOR, "【当前主机MAC地址:%s】", g_strMacs.c_str());
|
|
WriteTextLog(SAT_NOR, "【当前主机MAC地址:%s】", g_strMacs.c_str());
|
|
#endif
|
|
#endif
|
|
|
|
|