Esempio n. 1
0
static void
default_netif_remove(void)
{
  fail_unless(netif_default == &test_netif1);
  netif_remove(&test_netif1);
  netif_remove(&test_netif2);
  fail_unless(netif_default == NULL);
#if LWIP_HAVE_LOOPIF
  fail_unless(netif_list != NULL); /* the loopif */
  fail_unless(netif_list->next == NULL);
#else
  fail_unless(netif_list == NULL);
#endif
}
Esempio n. 2
0
/**
  * @brief  Clean up th ethernet services and free resources
  * @param  None
  * @retval None
  */
static void ETHERNET_Cleanup(void)
{
  EthernetSettings.DistantControlEnabled = 0;
  EthernetSettings.BackgroundEnabled = 0;
  EthernetSettings.InitDone = 0;
  ETH_Stop();

  vTaskPrioritySet(Task_Handle, (configMAX_PRIORITIES - 1));
  if(ETH_Task_Handle != NULL)
  {
    vTaskDelete(ETH_Task_Handle);
    ETH_Task_Handle = NULL;
  }

  vQueueDelete( Ethernet_xSemaphore );
  Ethernet_xSemaphore = NULL;

  if(TCPIP_Task_Handle != NULL)
  {
    vTaskSuspend(TCPIP_Task_Handle);
  }

  if(HTTP_Task_Handle != NULL)
  {
    vTaskDelete(HTTP_Task_Handle);
    HTTP_Task_Handle = NULL;
  }
  if(DHCP_Task_Handle != NULL)
  {
    vTaskDelete(DHCP_Task_Handle);
    DHCP_Task_Handle = NULL;
  }
  netif_remove(&xnetif);
}
Esempio n. 3
0
/**
 * Add a aodv network interface to the list of lwIP netifs.
 *
 * @param netif a pre-allocated netif structure
 * @param ipaddr IP address for the new netif
 * @param netmask network mask for the new netif
 * @param gw default gateway IP address for the new netif
 * @param state opaque data passed to the new netif
 * @param init callback function that initializes the interface
 * @param input callback function that is called to pass
 * ingress packets up in the protocol layer stack.
 *
 * @return netif, or NULL if failed.
 */
struct netif *aodv_netif_add (struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask,
                              ip_addr_t *gw, void *state, netif_init_fn init, netif_input_fn input)
{
  int i;
  static int aodv_proto_init = 0;
  
  if (aodv_proto_init == 0) {
    aodv_proto_init = 1;
    
    /* Intitialize the local sequence number an rreq_id to zero */
    aodv_host_state.seqno = 1; /* zero is invalid */
    aodv_host_state.rreq_id = 0;
    
    aodv_rt_init(); /* route table init */
#if AODV_MCAST
    aodv_mrt_init(); /* multicast route table init */
#endif
    aodv_hello_start();
    aodv_wait_on_reboot_init();
    aodv_timer_init_svr();
  }
  
  if (netif_add(netif, ipaddr, netmask, gw, state, init, input) == NULL) {
    return NULL;
  }
  
  for (i = 0; i < AODV_MAX_NETIF; i++) {
    if (aodv_netif[i] == NULL) {
      aodv_netif[i] = netif;
      break;
    }
  }
  LWIP_ERROR("i < AODV_MAX_NETIF", (i < AODV_MAX_NETIF), {netif_remove(netif); return NULL;});
BOOL ENC28J60_LWIP_Driver::Close( ENC28J60_LWIP_DRIVER_CONFIG* config, int index )
{
    NATIVE_PROFILE_HAL_DRIVERS_ETHERNET();

    if(config == NULL) return FALSE;

    LwipUpTimeCompletion.Abort();

    netif_set_link_down( &g_ENC28J60_NetIF );
    netif_set_down( &g_ENC28J60_NetIF );
    netif_remove( &g_ENC28J60_NetIF );

    /* Disable the INTERRUPT pin */                            
    CPU_GPIO_EnableInputPin2(config->INT_Pin, 
                              FALSE,                         /* Glitch filter enable */
                              NULL,                          /* ISR                  */
                              0,                             /* minor number         */
                              GPIO_INT_NONE,                 /* Interrupt edge       */
                              RESISTOR_PULLUP);              /* Resistor State       */

    InterruptTaskContinuation.Abort();

    LwipNetworkStatus = FALSE;
    
    enc28j60_lwip_close( &g_ENC28J60_NetIF );

    memset(&g_ENC28J60_NetIF, 0, sizeof(g_ENC28J60_NetIF));

    return TRUE;

}
void cbIP_removePanInterface(void)
{
    LWIP_PRINT("Interface down\n");

    dhcp_stop(&panIf.hInterface);
    netif_remove(&panIf.hInterface);
    dhcp_cleanup(&panIf.hInterface);
}
Esempio n. 6
0
void net_shutdown(void) {
	printf("Releasing DHCP lease...\n");
	dhcp_release(&eth);
	dhcp_stop(&eth);
	printf("Shutting down network...\n");
	netif_remove(&eth);
	gelicif_shutdown(&eth);
}
STATIC void wiznet5k_deinit(void) {
    for (struct netif *netif = netif_list; netif != NULL; netif = netif->next) {
        if (netif == &wiznet5k_obj.netif) {
            netif_remove(netif);
            netif->flags = 0;
            break;
        }
    }
}
Esempio n. 8
0
void eagle_lwip_if_free(struct ieee80211_conn *conn)
{
	if(conn->dhcps_if == 0) {
		netif_remove(conn->myif);
//		if(lwip_if_queues[0] != NULL)
			vPortFree(lwip_if_queues[0]);
	}
	else {
		if(dhcps_flag) dhcps_stop();
		netif_remove(conn->myif);
//		if(lwip_if_queues[1] != NULL)
			vPortFree(lwip_if_queues[1]);
	}
	if(conn->myif != NULL) {
		vPortFree(conn->myif);
		conn->myif = NULL;
	}
}
Esempio n. 9
0
void eagle_lwip_if_free(struct myif_state *state)
{
	if(state->dhcps_if == 0) {
		netif_remove(state->myif);
//		if(lwip_if_queues[0] != NULL)
			vPortFree(lwip_if_queues[0]);
	}
	else {
		if(dhcps_flag) dhcps_stop();
		netif_remove(state->myif);
//		if(lwip_if_queues[1] != NULL)
			vPortFree(lwip_if_queues[1]);
	}
	if(state->myif != NULL) {
		vPortFree(state->myif);
		state->myif = NULL;
	}
}
Esempio n. 10
0
void VBoxNetLwipNAT::onLwipTcpIpFini(void* arg)
{
    AssertPtrReturnVoid(arg);
    VBoxNetLwipNAT *pThis = (VBoxNetLwipNAT *)arg;

    /* XXX: proxy finalization */
    netif_set_link_down(&g_pLwipNat->m_LwipNetIf);
    netif_set_down(&g_pLwipNat->m_LwipNetIf);
    netif_remove(&g_pLwipNat->m_LwipNetIf);

}
BOOL LOOPBACK_LWIP_Driver::Close( )
{
    NATIVE_PROFILE_HAL_DRIVERS_ETHERNET();

    netif_set_down( &g_Loopback_NetIF );

    netif_remove( &g_Loopback_NetIF );
    
    memset(&g_Loopback_NetIF, 0, sizeof(g_Loopback_NetIF));
    
    return TRUE;
}
BOOL STM32F4_ETH_LWIP_Driver::Close(void)
{
    CPU_INTC_DeactivateInterrupt(ETH_IRQn);

    DeInitContinuations();

    LwipNetworkStatus = 0;
    eth_powerUpPhy(FALSE);
    
    netif_set_down( &g_STM32F4_ETH_NetIF );
    netif_remove( &g_STM32F4_ETH_NetIF );

    STM32F4_ETH_LWIP_close(TRUE);
  
    memset( &g_STM32F4_ETH_NetIF, 0, sizeof g_STM32F4_ETH_NetIF );

    return TRUE;
}
Esempio n. 13
0
/**
  * @brief  Return the module main menu from Webserver page
  * @param  None
  * @retval None
  */
static void return_from_webserver(void)
{
  EthernetSettings.WebserverEnabled = 0;
  EthernetSettings.InitDone = 0;
  ETH_Stop();

  vTaskPrioritySet(Task_Handle, (configMAX_PRIORITIES - 1));
  if(ETH_Task_Handle != NULL)
  {
    vTaskDelete(ETH_Task_Handle);
    ETH_Task_Handle = NULL;
  }

  if (Ethernet_xSemaphore != NULL)
  {
    vQueueDelete( Ethernet_xSemaphore );
    Ethernet_xSemaphore = NULL;
  }

  if(TCPIP_Task_Handle != NULL)
  {
    vTaskSuspend(TCPIP_Task_Handle);
  }

  if(HTTP_Task_Handle != NULL)
  {
    vTaskDelete(HTTP_Task_Handle);
    HTTP_Task_Handle = NULL;
  }
  if(DHCP_Task_Handle != NULL)
  {
    vTaskDelete(DHCP_Task_Handle);
    DHCP_Task_Handle = NULL;
  }

  DMA_Cmd(DMA2_Stream1, DISABLE);
  DCMI_Cmd(DISABLE);
  DCMI_CaptureCmd(DISABLE);

  netif_remove(&xnetif);

  ETHERNET_SwitchPage(EthernetWebServerPage, ETHERNET_MAIN_PAGE);
  EthernetWebServerPage = NULL;
}
Esempio n. 14
0
BOOL AT91_EMAC_LWIP_Driver::Close(void)
{
    LwipUpTimeCompletion.Abort();

    CPU_INTC_DeactivateInterrupt(AT91C_ID_EMAC);

    InterruptTaskContinuation.Abort();

    LwipNetworkStatus = 0;

    netif_set_down( &g_AT91_EMAC_NetIF );
    netif_remove( &g_AT91_EMAC_NetIF );

    AT91_EMAC_LWIP_close( &g_AT91_EMAC_NetIF );
    
    memset( &g_AT91_EMAC_NetIF, 0, sizeof g_AT91_EMAC_NetIF );

    return TRUE;
}
BOOL SH7264_SMSC_LWIP_Driver::Close(void)
{
    LwipUpTimeCompletion.Abort();

    //CPU_INTC_DeactivateInterrupt(SH7264C_ID_EDMAC);
    CPU_INTC_DeactivateInterrupt(81);

    InterruptTaskContinuation.Abort();

    LwipNetworkStatus = 0;

    netif_set_down( &g_SH7264_SMSC_NetIF );
    netif_remove( &g_SH7264_SMSC_NetIF );

    SH7264_SMSC_lwip_close( &g_SH7264_SMSC_NetIF );
    
    memset( &g_SH7264_SMSC_NetIF, 0, sizeof g_SH7264_SMSC_NetIF);

    return TRUE;
}
BOOL LPC24XX_EMAC_LWIP_Driver::Close( )
{
    LwipUpTimeCompletion.Abort();

    /* Disable the interrupt */
    CPU_INTC_DeactivateInterrupt(LPC24XX_VIC::c_IRQ_INDEX_EMAC);

    InterruptTaskContinuation.Abort();

    LwipNetworkStatus = 0;

    netif_set_down( &g_LPC24XX_EMAC_NetIF );
    netif_remove( &g_LPC24XX_EMAC_NetIF );

    LPC24XX_EMAC_lwip_close( &g_LPC24XX_EMAC_NetIF );
    
    memset( &g_LPC24XX_EMAC_NetIF, 0, sizeof g_LPC24XX_EMAC_NetIF);

    return TRUE;
}
Esempio n. 17
0
void stop_networking(void)
{
    struct netif *_netif = netif;
    struct netfront_dev *dev;
    struct netfrontif *nfi;

    if (!_netif)
        return;
    netif = NULL;

    tprintk("Stopping networking\n");

    netif_set_down(_netif);
    nfi = _netif->state;
    dev = nfi->dev;
    netif_remove(_netif);

    mem_free(nfi);
    mem_free(_netif);
    shutdown_netfront(dev);

    tprintk("Networking stopped\n");
}
Esempio n. 18
0
END_TEST

/*
 * Test case based on captured data where
 * replies are sent from a different IP than the
 * one the client unicasted to.
 */
START_TEST(test_dhcp_relayed)
{
  u8_t relay_offer[] = {
  0x00, 0x23, 0xc1, 0xde, 0xd0, 0x0d,
  0x00, 0x22, 0x93, 0x5a, 0xf7, 0x60,
  0x08, 0x00, 0x45, 0x00,
  0x01, 0x38, 0xfd, 0x53, 0x00, 0x00, 0x40, 0x11,
  0x78, 0x46, 0x4f, 0x8a, 0x32, 0x02, 0x4f, 0x8a,
  0x33, 0x05, 0x00, 0x43, 0x00, 0x44, 0x01, 0x24,
  0x00, 0x00, 0x02, 0x01, 0x06, 0x00, 0x51, 0x35,
  0xb6, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x4f, 0x8a, 0x33, 0x05, 0x00, 0x00,
  0x00, 0x00, 0x0a, 0xb5, 0x04, 0x01, 0x00, 0x23,
  0xc1, 0xde, 0xd0, 0x0d, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82,
  0x53, 0x63, 0x01, 0x04, 0xff, 0xff, 0xfe, 0x00,
  0x03, 0x04, 0x4f, 0x8a, 0x32, 0x01, 0x06, 0x08,
  0x4f, 0x8a, 0x00, 0xb4, 0x55, 0x08, 0x1f, 0xd1,
  0x1c, 0x04, 0x4f, 0x8a, 0x33, 0xff, 0x33, 0x04,
  0x00, 0x00, 0x54, 0x49, 0x35, 0x01, 0x02, 0x36,
  0x04, 0x0a, 0xb5, 0x04, 0x01, 0xff
  };

  u8_t relay_ack1[] = {
  0x00, 0x23, 0xc1, 0xde, 0xd0, 0x0d, 0x00, 0x22,
  0x93, 0x5a, 0xf7, 0x60, 0x08, 0x00, 0x45, 0x00,
  0x01, 0x38, 0xfd, 0x55, 0x00, 0x00, 0x40, 0x11,
  0x78, 0x44, 0x4f, 0x8a, 0x32, 0x02, 0x4f, 0x8a,
  0x33, 0x05, 0x00, 0x43, 0x00, 0x44, 0x01, 0x24,
  0x00, 0x00, 0x02, 0x01, 0x06, 0x00, 0x51, 0x35,
  0xb6, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x4f, 0x8a, 0x33, 0x05, 0x00, 0x00,
  0x00, 0x00, 0x0a, 0xb5, 0x04, 0x01, 0x00, 0x23,
  0xc1, 0xde, 0xd0, 0x0d, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82,
  0x53, 0x63, 0x01, 0x04, 0xff, 0xff, 0xfe, 0x00,
  0x03, 0x04, 0x4f, 0x8a, 0x32, 0x01, 0x06, 0x08,
  0x4f, 0x8a, 0x00, 0xb4, 0x55, 0x08, 0x1f, 0xd1,
  0x1c, 0x04, 0x4f, 0x8a, 0x33, 0xff, 0x33, 0x04,
  0x00, 0x00, 0x54, 0x49, 0x35, 0x01, 0x05, 0x36,
  0x04, 0x0a, 0xb5, 0x04, 0x01, 0xff
  };

  u8_t relay_ack2[] = {
  0x00, 0x23, 0xc1, 0xde, 0xd0, 0x0d,
  0x00, 0x22, 0x93, 0x5a, 0xf7, 0x60,
  0x08, 0x00, 0x45, 0x00,
  0x01, 0x38, 0xfa, 0x18, 0x00, 0x00, 0x40, 0x11,
  0x7b, 0x81, 0x4f, 0x8a, 0x32, 0x02, 0x4f, 0x8a,
  0x33, 0x05, 0x00, 0x43, 0x00, 0x44, 0x01, 0x24,
  0x00, 0x00, 0x02, 0x01, 0x06, 0x00, 0x49, 0x8b,
  0x6e, 0xab, 0x00, 0x00, 0x00, 0x00, 0x4f, 0x8a,
  0x33, 0x05, 0x4f, 0x8a, 0x33, 0x05, 0x00, 0x00,
  0x00, 0x00, 0x0a, 0xb5, 0x04, 0x01, 0x00, 0x23,
  0xc1, 0xde, 0xd0, 0x0d, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82,
  0x53, 0x63, 0x01, 0x04, 0xff, 0xff, 0xfe, 0x00,
  0x03, 0x04, 0x4f, 0x8a, 0x32, 0x01, 0x06, 0x08,
  0x4f, 0x8a, 0x00, 0xb4, 0x55, 0x08, 0x1f, 0xd1,
  0x1c, 0x04, 0x4f, 0x8a, 0x33, 0xff, 0x33, 0x04,
  0x00, 0x00, 0x54, 0x60, 0x35, 0x01, 0x05, 0x36,
  0x04, 0x0a, 0xb5, 0x04, 0x01, 0xff };

  const u8_t arp_resp[] = {
  0x00, 0x23, 0xc1, 0xde, 0xd0, 0x0d, /* DEST */
  0x00, 0x22, 0x93, 0x5a, 0xf7, 0x60, /* SRC */
  0x08, 0x06, /* Type: ARP */
  0x00, 0x01, /* HW: Ethernet */
  0x08, 0x00, /* PROTO: IP */
  0x06, /* HW size */
  0x04, /* PROTO size */
  0x00, 0x02, /* OPCODE: Reply */

  0x12, 0x34, 0x56, 0x78, 0x9a, 0xab, /* Target MAC */
  0x4f, 0x8a, 0x32, 0x01, /* Target IP */

  0x00, 0x23, 0xc1, 0x00, 0x06, 0x50, /* src mac */
  0x4f, 0x8a, 0x33, 0x05, /* src ip */

  /* Padding follows.. */
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00 };

  ip4_addr_t addr;
  ip4_addr_t netmask;
  ip4_addr_t gw;
  int i;
  u32_t xid;
  LWIP_UNUSED_ARG(_i);

  tcase = TEST_LWIP_DHCP_RELAY;
  setdebug(0);

  IP4_ADDR(&addr, 0, 0, 0, 0);
  IP4_ADDR(&netmask, 0, 0, 0, 0);
  IP4_ADDR(&gw, 0, 0, 0, 0);

  netif_add(&net_test, &addr, &netmask, &gw, &net_test, testif_init, ethernet_input);
  netif_set_up(&net_test);

  dhcp_start(&net_test);

  fail_unless(txpacket == 1); /* DHCP discover sent */

  /* IP addresses should be zero */
  fail_if(memcmp(&addr, &net_test.ip_addr, sizeof(ip4_addr_t)));
  fail_if(memcmp(&netmask, &net_test.netmask, sizeof(ip4_addr_t)));
  fail_if(memcmp(&gw, &net_test.gw, sizeof(ip4_addr_t)));

  fail_unless(txpacket == 1); /* Nothing more sent */
  xid = htonl(netif_dhcp_data(&net_test)->xid);
  memcpy(&relay_offer[46], &xid, 4); /* insert correct transaction id */
  send_pkt(&net_test, relay_offer, sizeof(relay_offer));

  /* request sent? */
  fail_unless(txpacket == 2, "txpkt = %d, should be 2", txpacket);
  xid = htonl(netif_dhcp_data(&net_test)->xid); /* xid updated */
  memcpy(&relay_ack1[46], &xid, 4); /* insert transaction id */
  send_pkt(&net_test, relay_ack1, sizeof(relay_ack1));

  for (i = 0; i < 25; i++) {
    tick_lwip();
  }
  fail_unless(txpacket == 5, "txpkt should be 5, is %d", txpacket); /* ARP requests sent */

  /* Interface up */
  fail_unless(netif_is_up(&net_test));

  /* Now it should have taken the IP */
  IP4_ADDR(&addr, 79, 138, 51, 5);
  IP4_ADDR(&netmask, 255, 255, 254, 0);
  IP4_ADDR(&gw, 79, 138, 50, 1);
  fail_if(memcmp(&addr, &net_test.ip_addr, sizeof(ip4_addr_t)));
  fail_if(memcmp(&netmask, &net_test.netmask, sizeof(ip4_addr_t)));
  fail_if(memcmp(&gw, &net_test.gw, sizeof(ip4_addr_t)));

  fail_unless(txpacket == 5, "txpacket = %d", txpacket);

  for (i = 0; i < 108000 - 25; i++) {
    tick_lwip();
  }

  fail_unless(netif_is_up(&net_test));
  fail_unless(txpacket == 6, "txpacket = %d", txpacket);

  /* We need to send arp response here.. */

  send_pkt(&net_test, arp_resp, sizeof(arp_resp));

  fail_unless(txpacket == 7, "txpacket = %d", txpacket);
  fail_unless(netif_is_up(&net_test));

  xid = htonl(netif_dhcp_data(&net_test)->xid); /* xid updated */
  memcpy(&relay_ack2[46], &xid, 4); /* insert transaction id */
  send_pkt(&net_test, relay_ack2, sizeof(relay_ack2));

  for (i = 0; i < 100000; i++) {
    tick_lwip();
  }

  fail_unless(txpacket == 7, "txpacket = %d", txpacket);

  netif_remove(&net_test);

}
Esempio n. 19
0
END_TEST

/*
 * Test that IP address is not taken and NAK is sent if someone
 * replies to ARP requests for the offered address.
 */
START_TEST(test_dhcp_nak)
{
  struct ip_addr addr;
  struct ip_addr netmask;
  struct ip_addr gw;
  u32_t xid;
  LWIP_UNUSED_ARG(_i);

  tcase = TEST_LWIP_DHCP;
  setdebug(0);

  IP4_ADDR(&addr, 0, 0, 0, 0);
  IP4_ADDR(&netmask, 0, 0, 0, 0);
  IP4_ADDR(&gw, 0, 0, 0, 0);

  netif_add(&net_test, &addr, &netmask, &gw, &net_test, testif_init, ethernet_input);

  dhcp_start(&net_test);

  fail_unless(txpacket == 1); // DHCP discover sent
  xid = net_test.dhcp->xid; // Write bad xid, not using htonl!
  memcpy(&dhcp_offer[46], &xid, 4);
  send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer));

  // Interface down
  fail_if(netif_is_up(&net_test));

  // IP addresses should be zero
  fail_if(memcmp(&addr, &net_test.ip_addr, sizeof(struct ip_addr)));
  fail_if(memcmp(&netmask, &net_test.netmask, sizeof(struct ip_addr)));
  fail_if(memcmp(&gw, &net_test.gw, sizeof(struct ip_addr)));

  fail_unless(txpacket == 1); // Nothing more sent
  xid = htonl(net_test.dhcp->xid);
  memcpy(&dhcp_offer[46], &xid, 4); // insert correct transaction id
  send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer));

  fail_unless(txpacket == 2); // DHCP request sent
  xid = net_test.dhcp->xid; // Write bad xid, not using htonl!
  memcpy(&dhcp_ack[46], &xid, 4);
  send_pkt(&net_test, dhcp_ack, sizeof(dhcp_ack));

  fail_unless(txpacket == 2); // No more sent
  xid = htonl(net_test.dhcp->xid); // xid updated
  memcpy(&dhcp_ack[46], &xid, 4); // insert transaction id
  send_pkt(&net_test, dhcp_ack, sizeof(dhcp_ack));

  fail_unless(txpacket == 3); // ARP request sent

  tcase = TEST_LWIP_DHCP_NAK; // Switch testcase

  // Send arp reply, mark offered IP as taken
  send_pkt(&net_test, arpreply, sizeof(arpreply));

  fail_unless(txpacket == 4); // DHCP nak sent

  netif_remove(&net_test);
}
Esempio n. 20
0
VOID
TCPUnregisterInterface(PIP_INTERFACE IF)
{
    netif_remove(IF->TCPContext);
}
static void
default_netif_remove(void)
{
  fail_unless(netif_default == &test_netif);
  netif_remove(&test_netif);
}
Esempio n. 22
0
END_TEST

START_TEST(test_dhcp_invalid_overload)
{
  u8_t dhcp_offer_invalid_overload[] = {
      0x00, 0x23, 0xc1, 0xde, 0xd0, 0x0d, /* To unit */
      0x00, 0x0F, 0xEE, 0x30, 0xAB, 0x22, /* From Remote host */
      0x08, 0x00, /* Protocol: IP */
      0x45, 0x10, 0x01, 0x48, 0x00, 0x00, 0x00, 0x00, 0x80, 0x11, 0x36, 0xcc, 0xc3, 0xaa, 0xbd, 0xab, 0xc3, 0xaa, 0xbd, 0xc8, /* IP header */
      0x00, 0x43, 0x00, 0x44, 0x01, 0x34, 0x00, 0x00, /* UDP header */

      0x02, /* Type == Boot reply */
      0x01, 0x06, /* Hw Ethernet, 6 bytes addrlen */
      0x00, /* 0 hops */
      0xAA, 0xAA, 0xAA, 0xAA, /* Transaction id, will be overwritten */
      0x00, 0x00, /* 0 seconds elapsed */
      0x00, 0x00, /* Flags (unicast) */
      0x00, 0x00, 0x00, 0x00, /* Client ip */
      0xc3, 0xaa, 0xbd, 0xc8, /* Your IP */
      0xc3, 0xaa, 0xbd, 0xab, /* DHCP server ip */
      0x00, 0x00, 0x00, 0x00, /* relay agent */
      0x00, 0x23, 0xc1, 0xde, 0xd0, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* MAC addr + padding */

      /* Empty server name */
      0x34, 0x01, 0x02, 0xff, /* Overload: SNAME + END */
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      /* Empty boot file name */
      0x34, 0x01, 0x01, 0xff, /* Overload FILE + END */
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

      0x63, 0x82, 0x53, 0x63, /* Magic cookie */
      0x35, 0x01, 0x02, /* Message type: Offer */
      0x36, 0x04, 0xc3, 0xaa, 0xbd, 0xab, /* Server identifier (IP) */
      0x33, 0x04, 0x00, 0x00, 0x00, 0x78, /* Lease time 2 minutes */
      0x03, 0x04, 0xc3, 0xaa, 0xbd, 0xab, /* Router IP */
      0x01, 0x04, 0xff, 0xff, 0xff, 0x00, /* Subnet mask */
      0x34, 0x01, 0x03, /* Overload: FILE + SNAME */
      0xff, /* End option */
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Padding */
  };
  ip4_addr_t addr;
  ip4_addr_t netmask;
  ip4_addr_t gw;
  u32_t xid;
  LWIP_UNUSED_ARG(_i);

  tcase = TEST_LWIP_DHCP_INVALID_OVERLOAD;
  setdebug(0);

  IP4_ADDR(&addr, 0, 0, 0, 0);
  IP4_ADDR(&netmask, 0, 0, 0, 0);
  IP4_ADDR(&gw, 0, 0, 0, 0);

  netif_add(&net_test, &addr, &netmask, &gw, &net_test, testif_init, ethernet_input);
  netif_set_up(&net_test);

  dhcp_start(&net_test);

  fail_unless(txpacket == 1); /* DHCP discover sent */
  xid = htonl(netif_dhcp_data(&net_test)->xid);
  memcpy(&dhcp_offer_invalid_overload[46], &xid, 4); /* insert correct transaction id */
  dhcp_offer_invalid_overload[311] = 3;
  send_pkt(&net_test, dhcp_offer_invalid_overload, sizeof(dhcp_offer_invalid_overload));
  /* IP addresses should be zero */
  fail_if(memcmp(&addr, &net_test.ip_addr, sizeof(ip4_addr_t)));
  fail_if(memcmp(&netmask, &net_test.netmask, sizeof(ip4_addr_t)));
  fail_if(memcmp(&gw, &net_test.gw, sizeof(ip4_addr_t)));
  fail_unless(txpacket == 1); /* Nothing more sent */

  dhcp_offer_invalid_overload[311] = 2;
  send_pkt(&net_test, dhcp_offer_invalid_overload, sizeof(dhcp_offer_invalid_overload));
  /* IP addresses should be zero */
  fail_if(memcmp(&addr, &net_test.ip_addr, sizeof(ip4_addr_t)));
  fail_if(memcmp(&netmask, &net_test.netmask, sizeof(ip4_addr_t)));
  fail_if(memcmp(&gw, &net_test.gw, sizeof(ip4_addr_t)));
  fail_unless(txpacket == 1); /* Nothing more sent */

  dhcp_offer_invalid_overload[311] = 1;
  send_pkt(&net_test, dhcp_offer_invalid_overload, sizeof(dhcp_offer_invalid_overload));
  /* IP addresses should be zero */
  fail_if(memcmp(&addr, &net_test.ip_addr, sizeof(ip4_addr_t)));
  fail_if(memcmp(&netmask, &net_test.netmask, sizeof(ip4_addr_t)));
  fail_if(memcmp(&gw, &net_test.gw, sizeof(ip4_addr_t)));
  fail_unless(txpacket == 1); /* Nothing more sent */

  dhcp_offer_invalid_overload[311] = 0;
  send_pkt(&net_test, dhcp_offer_invalid_overload, sizeof(dhcp_offer));

  fail_unless(netif_dhcp_data(&net_test)->state == DHCP_STATE_REQUESTING);

  fail_unless(txpacket == 2); /* No more sent */
  xid = htonl(netif_dhcp_data(&net_test)->xid); /* xid updated */

  netif_remove(&net_test);
}
Esempio n. 23
0
END_TEST

/*
 * Test that IP address is not taken and NAK is sent if someone
 * replies to ARP requests for the offered address.
 */
START_TEST(test_dhcp_nak)
{
  ip4_addr_t addr;
  ip4_addr_t netmask;
  ip4_addr_t gw;
  u32_t xid;
  LWIP_UNUSED_ARG(_i);

  tcase = TEST_LWIP_DHCP;
  setdebug(0);

  IP4_ADDR(&addr, 0, 0, 0, 0);
  IP4_ADDR(&netmask, 0, 0, 0, 0);
  IP4_ADDR(&gw, 0, 0, 0, 0);

  netif_add(&net_test, &addr, &netmask, &gw, &net_test, testif_init, ethernet_input);
  netif_set_up(&net_test);

  dhcp_start(&net_test);

  fail_unless(txpacket == 1); /* DHCP discover sent */
  xid = netif_dhcp_data(&net_test)->xid; /* Write bad xid, not using htonl! */
  memcpy(&dhcp_offer[46], &xid, 4);
  send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer));

  /* IP addresses should be zero */
  fail_if(memcmp(&addr, &net_test.ip_addr, sizeof(ip4_addr_t)));
  fail_if(memcmp(&netmask, &net_test.netmask, sizeof(ip4_addr_t)));
  fail_if(memcmp(&gw, &net_test.gw, sizeof(ip4_addr_t)));

  fail_unless(txpacket == 1); /* Nothing more sent */
  xid = htonl(netif_dhcp_data(&net_test)->xid);
  memcpy(&dhcp_offer[46], &xid, 4); /* insert correct transaction id */
  send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer));

  fail_unless(txpacket == 2); /* DHCP request sent */
  xid = netif_dhcp_data(&net_test)->xid; /* Write bad xid, not using htonl! */
  memcpy(&dhcp_ack[46], &xid, 4);
  send_pkt(&net_test, dhcp_ack, sizeof(dhcp_ack));

  fail_unless(txpacket == 2); /* No more sent */
  xid = htonl(netif_dhcp_data(&net_test)->xid); /* xid updated */
  memcpy(&dhcp_ack[46], &xid, 4); /* insert transaction id */
  send_pkt(&net_test, dhcp_ack, sizeof(dhcp_ack));

  fail_unless(txpacket == 3); /* ARP request sent */

  tcase = TEST_LWIP_DHCP_NAK; /* Switch testcase */

  /* Send arp reply, mark offered IP as taken */
  send_pkt(&net_test, arpreply, sizeof(arpreply));

  fail_unless(txpacket == 4); /* DHCP nak sent */

  netif_remove(&net_test);
}
Esempio n. 24
0
END_TEST

START_TEST(test_dhcp_nak_no_endmarker)
{
  ip4_addr_t addr;
  ip4_addr_t netmask;
  ip4_addr_t gw;

  u8_t dhcp_nack_no_endmarker[] = {
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x54, 0x75,
    0xd0, 0x26, 0xd0, 0x0d, 0x08, 0x00, 0x45, 0x00,
    0x01, 0x15, 0x38, 0x86, 0x00, 0x00, 0xff, 0x11,
    0xc0, 0xa8, 0xc0, 0xa8, 0x01, 0x01, 0xff, 0xff,
    0xff, 0xff, 0x00, 0x43, 0x00, 0x44, 0x01, 0x01,
    0x00, 0x00, 0x02, 0x01, 0x06, 0x00, 0x7a, 0xcb,
    0xba, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23,
    0xc1, 0xde, 0xd0, 0x0d, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82,
    0x53, 0x63, 0x35, 0x01, 0x06, 0x36, 0x04, 0xc0,
    0xa8, 0x01, 0x01, 0x31, 0xef, 0xad, 0x72, 0x31,
    0x43, 0x4e, 0x44, 0x30, 0x32, 0x35, 0x30, 0x43,
    0x52, 0x47, 0x44, 0x38, 0x35, 0x36, 0x3c, 0x08,
    0x4d, 0x53, 0x46, 0x54, 0x20, 0x35, 0x2e, 0x30,
    0x37, 0x0d, 0x01, 0x0f, 0x03, 0x06, 0x2c, 0x2e,
    0x2f, 0x1f, 0x21, 0x79, 0xf9, 0x2b, 0xfc, 0xff,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, 0x71,
    0xf3, 0x5b, 0xe2, 0x71, 0x2e, 0x01, 0x08, 0x03,
    0x04, 0xc0, 0xa8, 0x01, 0x01, 0xff, 0xeb, 0x1e,
    0x44, 0xec, 0xeb, 0x1e, 0x30, 0x37, 0x0c, 0x01,
    0x0f, 0x03, 0x06, 0x2c, 0x2e, 0x2f, 0x1f, 0x21,
    0x79, 0xf9, 0x2b, 0xff, 0x25, 0xc0, 0x09, 0xd6,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  };
  u32_t xid;
  LWIP_UNUSED_ARG(_i);

  tcase = TEST_LWIP_DHCP_NAK_NO_ENDMARKER;
  setdebug(0);

  IP4_ADDR(&addr, 0, 0, 0, 0);
  IP4_ADDR(&netmask, 0, 0, 0, 0);
  IP4_ADDR(&gw, 0, 0, 0, 0);

  netif_add(&net_test, &addr, &netmask, &gw, &net_test, testif_init, ethernet_input);
  netif_set_up(&net_test);

  dhcp_start(&net_test);

  fail_unless(txpacket == 1); /* DHCP discover sent */
  xid = netif_dhcp_data(&net_test)->xid; /* Write bad xid, not using htonl! */
  memcpy(&dhcp_offer[46], &xid, 4);
  send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer));

  /* IP addresses should be zero */
  fail_if(memcmp(&addr, &net_test.ip_addr, sizeof(ip4_addr_t)));
  fail_if(memcmp(&netmask, &net_test.netmask, sizeof(ip4_addr_t)));
  fail_if(memcmp(&gw, &net_test.gw, sizeof(ip4_addr_t)));

  fail_unless(txpacket == 1); /* Nothing more sent */
  xid = htonl(netif_dhcp_data(&net_test)->xid);
  memcpy(&dhcp_offer[46], &xid, 4); /* insert correct transaction id */
  send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer));
  
  fail_unless(netif_dhcp_data(&net_test)->state == DHCP_STATE_REQUESTING);

  fail_unless(txpacket == 2); /* No more sent */
  xid = htonl(netif_dhcp_data(&net_test)->xid); /* xid updated */
  memcpy(&dhcp_nack_no_endmarker[46], &xid, 4); /* insert transaction id */
  send_pkt(&net_test, dhcp_nack_no_endmarker, sizeof(dhcp_nack_no_endmarker));

  /* NAK should put us in another state for a while, no other way detecting it */
  fail_unless(netif_dhcp_data(&net_test)->state != DHCP_STATE_REQUESTING);

  netif_remove(&net_test);
}