Exemple #1
0
// liudf added 20160321
void
update_trusted_mac_status(t_trusted_mac *tmac)
{
	tmac->is_online = 0;

	if(tmac->ip == NULL) {
		tmac->ip = arp_get_ip(tmac->mac);
	}

	if(tmac->ip != NULL) {
		tmac->is_online = is_server_reachable(tmac->ip);
	}
}
Exemple #2
0
static void arp_get_ip_func(void** state) {
	//timer setting
	timer_init("IntelCore(TM) i5-4670 CPU @ 3.40GHz");

	// Nic initialization
	void* malloc_pool = malloc(POOL_SIZE);
	init_memory_pool(POOL_SIZE, malloc_pool, 0);

	__nics[0] = malloc(sizeof(NIC));
	__nic_count++;

	__nics[0]->mac = 0x74d4358f66cb;
	__nics[0]->pool_size = POOL_SIZE;
	__nics[0]->pool = malloc_pool;
	__nics[0]->output_buffer = fifo_create(8, malloc_pool);
	__nics[0]->config = map_create(8, NULL, NULL, __nics[0]->pool);

	Packet* packet = nic_alloc(__nics[0], 42);
	memcpy(packet->buffer + packet->start, arp_reply_packet, 42);

	Ether* ether = (Ether*)(packet->buffer + packet->start);
	ARP* arp = (ARP*)ether->payload;
	uint32_t addr = endian32(arp->tpa);

	nic_ip_add(__nics[0], addr);

	if(!arp_process(packet))
		return;

	uint32_t dpa = 0xc0a80a90;
	uint64_t tha = 0x74d4358f66cb;
	uint32_t comp_ip = arp_get_ip(__nics[0], tha);

	
	assert_memory_equal((uint8_t*)&dpa, (uint8_t*)&comp_ip, 4);

	destroy_memory_pool(malloc_pool);
	free(malloc_pool);
	malloc_pool = NULL;
}
Exemple #3
0
void ip_find(struct net_device *ndev)
{
	arp_get_ip(ndev);
}