static void arp_announce_func(void** state) { // 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 = 0x10c37b9309d1; __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); uint32_t spa = 0xc0a80a6f; arp_announce(__nics[0], spa); Packet* packet = fifo_pop(__nics[0]->output_buffer); assert_memory_equal(packet->buffer + packet->start, arp_announce_packet, 46); destroy_memory_pool(malloc_pool); free(malloc_pool); malloc_pool = NULL; }
void ipv4ll_start(void *arg) { struct interface *ifp = arg; struct dhcp_state *state = D_STATE(ifp); uint32_t addr; eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); state->probes = 0; state->claims = 0; if (state->addr.s_addr) { state->conflicts = 0; if (IN_LINKLOCAL(htonl(state->addr.s_addr))) { arp_announce(ifp); return; } } if (state->offer == NULL) addr = 0; else { addr = state->offer->yiaddr; free(state->offer); } /* We maybe rebooting an IPv4LL address. */ if (!IN_LINKLOCAL(htonl(addr))) { syslog(LOG_INFO, "%s: probing for an IPv4LL address", ifp->name); addr = 0; } if (addr == 0) state->offer = ipv4ll_find_lease(addr); else state->offer = ipv4ll_make_lease(addr); if (state->offer == NULL) syslog(LOG_ERR, "%s: %m", __func__); else { state->lease.frominfo = 0; arp_probe(ifp); } }