//根据已获取的MAC地址设置IP
bool NetworkInterface::GetCurrentIP()
{
	if(GetCurrentIP(srcMAC, srcIP4))
		return true;
	else
		return false;
}
Exemple #2
0
int ICACHE_FLASH_ATTR JoinGropMDNS()
{
	uint32_t ip = GetCurrentIP();
	if( ip )
	{
		struct ip_addr grpip;
		grpip.addr = MDNS_BRD;
		printf( "IGMP Joining: %08x %08x\n", ip, grpip.addr );
		ets_memcpy( igmp_bound, &grpip.addr, 4 ); 
		espconn_igmp_join( (ip_addr_t *)&ip, &grpip);
		return 0;
	}
	return 1;
}
//打开指定网卡,packet外部处理函数需另外设定
int NetworkInterface::OpenAdapter(int adapterIndex)
{
	if(adapterIndex < 0 || adapterIndex >= AdapterList.size())
	{
		return -1;
	}
	if(GetAdapterStat() == 1)		//如果网卡已打开则不再继续操作
		return 1;
	InitAdapterCommon(AdapterList[adapterIndex].AdapterName);
	SetRecvTimeout(20);
	SetRecvMode(NDIS_PACKET_TYPE_DIRECTED);
	SetLocalMAC();
	GetCurrentIP();
	ReadyForCapture();
	return 0;
}