Beispiel #1
0
/**
 * Handle a possible change in the network configuration.
 *
 * If there is an AutoIP address configured, take the interface down
 * and begin probing with the same address.
 */
void ICACHE_FLASH_ATTR
autoip_network_changed(struct netif *netif)
{
  if (netif->autoip && netif->autoip->state != AUTOIP_STATE_OFF) {
    netif_set_down(netif);
    autoip_start_probing(netif);
  }
}
/**
  * @brief  This function notify user about link status changement.
  * @param  netif: the network interface
  * @retval None
  */
void ethernetif_notify_conn_changed(struct netif *netif)
{
  struct ip_addr ipaddr;
  struct ip_addr netmask;
  struct ip_addr gw;

  if(netif_is_link_up(netif))
  {
#ifdef USE_DHCP
#ifdef USE_LCD
    LCD_UsrLog ("The network cable is now connected \n");
#else
    BSP_LED_Off(LED2);
    BSP_LED_On(LED1);
#endif /* USE_LCD */
    /* Update DHCP state machine */
    DHCP_state = DHCP_START;
#else
    IP4_ADDR(&ipaddr, IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3);
    IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1 , NETMASK_ADDR2, NETMASK_ADDR3);
    IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);    

#ifdef USE_LCD        
    uint8_t iptxt[20];
    
    sprintf((char*)iptxt, "%d.%d.%d.%d", IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3);
    
    LCD_UsrLog ("The network cable is now connected \n");
    LCD_UsrLog ("Static IP address: %s\n", iptxt);
#else
    BSP_LED_Off(LED2);
    BSP_LED_On(LED1);
#endif /* USE_LCD */
#endif /* USE_DHCP */   
    
    netif_set_addr(netif, &ipaddr , &netmask, &gw);
    
    /* When the netif is fully configured this function must be called.*/
    netif_set_up(netif);     
  }
  else
  {
#ifdef USE_DHCP
    /* Update DHCP state machine */
    DHCP_state = DHCP_LINK_DOWN;
#endif /* USE_DHCP */
    
    /*  When the netif link is down this function must be called.*/
    netif_set_down(netif);
    
#ifdef USE_LCD
    LCD_UsrLog ("The network cable is not connected \n");
#else
    BSP_LED_Off(LED1);
    BSP_LED_On(LED2);
#endif /* USE_LCD */    
  }
}
Beispiel #3
0
/**
  * @brief  Initializes the lwIP stack
  * @param  None
  * @retval None
  */
static void Netif_Config(void)
{
  struct ip_addr ipaddr;
  struct ip_addr netmask;
  struct ip_addr gw;	
  
  /* IP address setting */
  IP4_ADDR(&ipaddr, IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3);
  IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1 , NETMASK_ADDR2, NETMASK_ADDR3);
  IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);
  
  /* - netif_add(struct netif *netif, struct ip_addr *ipaddr,
  struct ip_addr *netmask, struct ip_addr *gw,
  void *state, err_t (* init)(struct netif *netif),
  err_t (* input)(struct pbuf *p, struct netif *netif))
  
  Adds your network interface to the netif_list. Allocate a struct
  netif and pass a pointer to this structure as the first argument.
  Give pointers to cleared ip_addr structures when using DHCP,
  or fill them with sane numbers otherwise. The state pointer may be NULL.
  
  The init function pointer must point to a initialization function for
  your ethernet netif interface. The following code illustrates it's use.*/
  
  netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, &ethernetif_init, &tcpip_input);
  
  /*  Registers the default network interface. */
  netif_set_default(&gnetif);
  
  if (netif_is_link_up(&gnetif))
  {
    /* When the netif is fully configured this function must be called.*/
    netif_set_up(&gnetif);
  }
  else
  {
    /* When the netif link is down this function must be called */
    netif_set_down(&gnetif);
  }

  /* Set the link callback function, this function is called on change of link status*/
  netif_set_link_callback(&gnetif, ethernetif_update_config);
  
  /* create a binary semaphore used for informing ethernetif of frame reception */
  osSemaphoreDef(Netif_SEM);
  Netif_LinkSemaphore = osSemaphoreCreate(osSemaphore(Netif_SEM) , 1 );
  
  link_arg.netif = &gnetif;
  link_arg.semaphore = Netif_LinkSemaphore;
  /* Create the Ethernet link handler thread */
#if defined(__GNUC__)
  osThreadDef(LinkThr, ethernetif_set_link, osPriorityNormal, 0, configMINIMAL_STACK_SIZE * 5);
#else
  osThreadDef(LinkThr, ethernetif_set_link, osPriorityNormal, 0, configMINIMAL_STACK_SIZE * 2);
#endif

  osThreadCreate (osThread(LinkThr), &link_arg);
}
Beispiel #4
0
/* \brief Is the link still up? Also updates the interface status if the link has gone down
 *
 */
bool ethernet_link_established(void)
{
	if (!ethernetif_link_established())
	{
		netif_set_down(&gs_net_if);
		return false;
	}
	return true;
}
Beispiel #5
0
static void mbed_lwip_netif_link_irq(struct netif *lwip_netif)
{
    if (netif_is_link_up(lwip_netif)) {

        nsapi_error_t dhcp_status = mbed_set_dhcp(lwip_netif);

        if (lwip_blocking && dhcp_status == NSAPI_ERROR_OK) {
            sys_sem_signal(&lwip_netif_linked);
        } else if (dhcp_status != NSAPI_ERROR_OK) {
            netif_set_down(lwip_netif);
        }


    } else {
        sys_sem_signal(&lwip_netif_unlinked);
        netif_set_down(lwip_netif);
    }
}
STATIC void wiznet5k_send_ethernet(wiznet5k_obj_t *self, size_t len, const uint8_t *buf) {
    uint8_t ip[4] = {1, 1, 1, 1}; // dummy
    int ret = WIZCHIP_EXPORT(sendto)(0, (byte*)buf, len, ip, 11); // dummy port
    if (ret != len) {
        printf("wiznet5k_send_ethernet: fatal error %d\n", ret);
        netif_set_link_down(&self->netif);
        netif_set_down(&self->netif);
    }
}
Beispiel #7
0
static void lwip_set_link(struct vmm_netport *port)
{
	struct lwip_netstack *lns = port->priv;

	if (port->flags & VMM_NETPORT_LINK_UP) {
		netif_set_up(&lns->nif);
	} else {
		netif_set_down(&lns->nif);
	}
}
void EthernetDeepSleep()
{
    netif_set_down(&g_STM32F4_ETH_NetIF);
    STM32F4_ETH_LWIP_close(FALSE);
    LwipNetworkStatus = 0;
    eth_powerUpPhy(FALSE);

    DeInitContinuations();
    CPU_INTC_DeactivateInterrupt(ETH_IRQn);
}
Beispiel #9
0
//Shutdown a layer3 interface.
BOOL lwipShutdownInterface(LPVOID pL3Interface)
{
	struct netif* pif = (struct netif*)pL3Interface;
	if (NULL == pif)
	{
		BUG();
	}
	netif_set_down(pif);
	return TRUE;
}
Beispiel #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;
}
Beispiel #12
0
int EthernetInterface::disconnect() {
    if (use_dhcp) {
        dhcp_release(&netif);
        dhcp_stop(&netif);
    } else {
        netif_set_down(&netif);
    }
    
    eth_arch_disable_interrupts();
    
    return 0;
}
Beispiel #13
0
int EthernetInterface::disconnect() {
    if (use_dhcp) {
        dhcp_release(&lpcNetif);
        dhcp_stop(&lpcNetif);
    } else {
        netif_set_down(&lpcNetif);
    }
    
    NVIC_DisableIRQ(ENET_IRQn);
    
    return 0;
}
Beispiel #14
0
/**
 * Remove a network interface from the list of lwIP netifs.
 *
 * @param netif the network interface to remove
 */
void
netif_remove(struct netif *netif)
{
  if (netif == NULL) {
    return;
  }

#if LWIP_IGMP
  /* stop IGMP processing */
  if (netif->flags & NETIF_FLAG_IGMP) {
    igmp_stop(netif);
  }
#endif /* LWIP_IGMP */
#if LWIP_IPV6 && LWIP_IPV6_MLD
  /* stop MLD processing */
  mld6_stop(netif);
#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */
  if (netif_is_up(netif)) {
    /* set netif down before removing (call callback function) */
    netif_set_down(netif);
  }

  snmp_delete_ipaddridx_tree(netif);

  /*  is it the first netif? */
  if (netif_list == netif) {
    netif_list = netif->next;
  } else {
    /*  look for netif further down the list */
    struct netif * tmpNetif;
    for (tmpNetif = netif_list; tmpNetif != NULL; tmpNetif = tmpNetif->next) {
      if (tmpNetif->next == netif) {
        tmpNetif->next = netif->next;
        break;
      }
    }
    if (tmpNetif == NULL)
      return; /*  we didn't find any netif today */
  }
  snmp_dec_iflist();
  /* this netif is default? */
  if (netif_default == netif) {
    /* reset default netif */
    netif_set_default(NULL);
  }
#if LWIP_NETIF_REMOVE_CALLBACK
  if (netif->remove_callback) {
    netif->remove_callback(netif);
  }
#endif /* LWIP_NETIF_REMOVE_CALLBACK */
  LWIP_DEBUGF( NETIF_DEBUG, ("netif_remove: removed netif\n") );
}
Beispiel #15
0
nsapi_error_t mbed_lwip_bringdown_2(bool ppp)
{
    // Check if we've connected
    if (lwip_connected == NSAPI_STATUS_DISCONNECTED) {
        return NSAPI_ERROR_PARAMETER;
    }

#if LWIP_DHCP
    // Disconnect from the network
    if (lwip_dhcp) {
        dhcp_release(&lwip_netif);
        dhcp_stop(&lwip_netif);
        lwip_dhcp = false;
        lwip_dhcp_has_to_be_set = false;
    }
#endif

    if (ppp) {
        /* this is a blocking call, returns when PPP is properly closed */
       err_t err = ppp_lwip_disconnect();
       if (err) {
           return mbed_lwip_err_remap(err);
       }
       MBED_ASSERT(!netif_is_link_up(&lwip_netif));
       /*if (netif_is_link_up(&lwip_netif)) {
           if (sys_arch_sem_wait(&lwip_netif_unlinked, 15000) == SYS_ARCH_TIMEOUT) {
               return NSAPI_ERROR_DEVICE_ERROR;
           }
       }*/
    } else {
        netif_set_down(&lwip_netif);
    }

#if LWIP_IPV6
    mbed_lwip_clear_ipv6_addresses(&lwip_netif);
#endif

    sys_sem_free(&lwip_netif_has_any_addr);
    sys_sem_new(&lwip_netif_has_any_addr, 0);
#if PREF_ADDR_TIMEOUT
    sys_sem_free(&lwip_netif_has_pref_addr);
    sys_sem_new(&lwip_netif_has_pref_addr, 0);
#endif
#if BOTH_ADDR_TIMEOUT
    sys_sem_free(&lwip_netif_has_both_addr);
    sys_sem_new(&lwip_netif_has_both_addr, 0);
#endif
    lwip_has_addr_state = 0;
    lwip_connected = NSAPI_STATUS_DISCONNECTED;
    return 0;
}
Beispiel #16
0
static void
test_ip6_ll_addr_iter(int expected_ctr1, int expected_ctr2)
{
  fail_unless(linkoutput_ctr == 0);

  /* test that nothing is sent with link uo but netif down */
  netif_set_link_up(&test_netif6);
  ip6_test_handle_timers(500);
  fail_unless(linkoutput_ctr == 0);
  netif_set_link_down(&test_netif6);
  fail_unless(linkoutput_ctr == 0);

  /* test that nothing is sent with link down but netif up */
  netif_set_up(&test_netif6);
  ip6_test_handle_timers(500);
  fail_unless(linkoutput_ctr == 0);
  netif_set_down(&test_netif6);
  fail_unless(linkoutput_ctr == 0);

  /* test what is sent with link up + netif up */
  netif_set_link_up(&test_netif6);
  netif_set_up(&test_netif6);
  ip6_test_handle_timers(500);
  fail_unless(linkoutput_ctr == expected_ctr1);
  netif_set_down(&test_netif6);
  netif_set_link_down(&test_netif6);
  fail_unless(linkoutput_ctr == expected_ctr1);
  linkoutput_ctr = 0;

  netif_set_up(&test_netif6);
  netif_set_link_up(&test_netif6);
  ip6_test_handle_timers(500);
  fail_unless(linkoutput_ctr == expected_ctr2);
  netif_set_link_down(&test_netif6);
  netif_set_down(&test_netif6);
  fail_unless(linkoutput_ctr == expected_ctr2);
  linkoutput_ctr = 0;
}
int STM32F4_ETH_LWIP_Driver::Open(int index)
{
    /* Network interface variables */
    struct ip_addr ipaddr, subnetmask, gateway;
    struct netif *pNetIF;
    int len;
    const SOCK_NetworkConfiguration *iface;

    EthernetPrepareZero();
    
    /* Enable Phy Powerdown on Deepsleep */
    STM32F4_SetPowerHandlers(EthernetDeepSleep, EthernetWakeUp);
    
    /* Apply network configuration */
    iface = &g_NetworkConfig.NetworkInterfaces[index];
    
    len = g_STM32F4_ETH_NetIF.hwaddr_len;
    if (len == 0 || iface->macAddressLen < len)
    {
        len = iface->macAddressLen;
        g_STM32F4_ETH_NetIF.hwaddr_len = len;
    }
    memcpy(g_STM32F4_ETH_NetIF.hwaddr, iface->macAddressBuffer, len);
    
    ipaddr.addr = iface->ipaddr;
    gateway.addr = iface->gateway;
    subnetmask.addr = iface->subnetmask;
      
    pNetIF = netif_add( &g_STM32F4_ETH_NetIF, &ipaddr, &subnetmask, &gateway, NULL, STM32F4_ETH_ethhw_init, ethernet_input );
    
    CPU_INTC_ActivateInterrupt(ETH_IRQn, (HAL_CALLBACK_FPN)STM32F4_ETH_LWIP_interrupt, &g_STM32F4_ETH_NetIF);
    
    netif_set_default( pNetIF );

    if (LwipNetworkStatus)
    {
        netif_set_up( pNetIF );
    }
    else
    {
        netif_set_down( pNetIF);
    }
    
    /* Initialize the continuation routine for the driver interrupt and receive */    
    InitContinuations( pNetIF );
    
    /* Return LWIP's net interface number */
    return g_STM32F4_ETH_NetIF.num;    
}
Beispiel #18
0
/**
 * Start AutoIP client
 *
 * @param netif network interface on which start the AutoIP client
 */
err_t
autoip_start(struct netif *netif)
{
    struct autoip *autoip = netif->autoip;
    err_t result = ERR_OK;

    if(netif_is_up(netif)) {
        netif_set_down(netif);
    }

    /* Set IP-Address, Netmask and Gateway to 0 to make sure that
     * ARP Packets are formed correctly
     */
    netif->ip_addr.addr = 0;
    netif->netmask.addr = 0;
    netif->gw.addr      = 0;

    LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE,
                ("autoip_start(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0],
                 netif->name[1], (u16_t)netif->num));
    if(autoip == NULL) {
        /* no AutoIP client attached yet? */
        LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE,
                    ("autoip_start(): starting new AUTOIP client\n"));
        autoip = mem_malloc(sizeof(struct autoip));
        if(autoip == NULL) {
            LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE,
                        ("autoip_start(): could not allocate autoip\n"));
            return ERR_MEM;
        }
        memset( autoip, 0, sizeof(struct autoip));
        /* store this AutoIP client in the netif */
        netif->autoip = autoip;
        LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, ("autoip_start(): allocated autoip"));
    } else {
        autoip->state = AUTOIP_STATE_OFF;
        autoip->ttw = 0;
        autoip->sent_num = 0;
        memset(&autoip->llipaddr, 0, sizeof(struct ip_addr));
        autoip->lastconflict = 0;
    }

    autoip_create_addr(netif, &(autoip->llipaddr));
    autoip->tried_llipaddr++;
    autoip_start_probing(netif);

    return result;
}
Beispiel #19
0
/* init function */
void MX_LWIP_Init(void)
{
  IP_ADDRESS[0] = 192;
  IP_ADDRESS[1] = 168;
  IP_ADDRESS[2] = 203;
  IP_ADDRESS[3] = 36;
  NETMASK_ADDRESS[0] = 255;
  NETMASK_ADDRESS[1] = 255;
  NETMASK_ADDRESS[2] = 255;
  NETMASK_ADDRESS[3] = 0;
  GATEWAY_ADDRESS[0] = 192;
  GATEWAY_ADDRESS[1] = 168;
  GATEWAY_ADDRESS[2] = 203;
  GATEWAY_ADDRESS[3] = 2;
   
  tcpip_init( NULL, NULL );	
 
  IP4_ADDR(&ipaddr, IP_ADDRESS[0], IP_ADDRESS[1], IP_ADDRESS[2], IP_ADDRESS[3]);
  IP4_ADDR(&netmask, NETMASK_ADDRESS[0], NETMASK_ADDRESS[1] , NETMASK_ADDRESS[2], NETMASK_ADDRESS[3]);
  IP4_ADDR(&gw, GATEWAY_ADDRESS[0], GATEWAY_ADDRESS[1], GATEWAY_ADDRESS[2], GATEWAY_ADDRESS[3]);  
  

  /* add the network interface */
  netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, &ethernetif_init, &tcpip_input);
 
 
  /*  Registers the default network interface */
  netif_set_default(&gnetif);

  if (netif_is_link_up(&gnetif))
  {
    /* When the netif is fully configured this function must be called */
    netif_set_up(&gnetif);
  }
  else
  {
    /* When the netif link is down this function must be called */
       netif_set_down(&gnetif);
  }  
  

/* USER CODE BEGIN 3 */

/* USER CODE END 3 */
}
// Stores the frame in self->eth_frame and returns number of bytes in the frame, 0 for no frame
STATIC uint16_t wiznet5k_recv_ethernet(wiznet5k_obj_t *self) {
    uint16_t len = getSn_RX_RSR(0);
    if (len == 0) {
        return 0;
    }

    byte ip[4];
    uint16_t port;
    int ret = WIZCHIP_EXPORT(recvfrom)(0, self->eth_frame, 1514, ip, &port);
    if (ret <= 0) {
        printf("wiznet5k_lwip_poll: fatal error len=%u ret=%d\n", len, ret);
        netif_set_link_down(&self->netif);
        netif_set_down(&self->netif);
        return 0;
    }

    return ret;
}
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;
}
/**
  * @brief  This function notify user about link status changement.
  * @param  netif: the network interface
  * @retval None
  */
void ethernetif_notify_conn_changed(struct netif *netif)
{
  struct ip_addr ipaddr;
  struct ip_addr netmask;
  struct ip_addr gw;

  if(netif_is_link_up(netif))
  {
    /* IP address setting */
    IP4_ADDR(&ipaddr, ip_address[3], ip_address[2], ip_address[1], ip_address[0]);
    IP4_ADDR(&netmask, sn_mask[3], sn_mask[2] , sn_mask[1], sn_mask[0]);
    IP4_ADDR(&gw, gw_address[3], gw_address[2], gw_address[1], gw_address[0]);
    
    netif_set_addr(netif, &ipaddr , &netmask, &gw);
    
    /* When the netif is fully configured this function must be called.*/
    netif_set_up(netif);
    
    _VNCServer_Notify(NOTIFY_SERVER_NETIF_UP);

    /* If DHCP: re-start process */
    if (_DHCPClinet_TCB != 0)
    {
      /* Update DHCP state machine */
      DHCP_state = DHCP_START;
    }
  }
  else
  {   
    /*  When the netif link is down this function must be called.*/
    netif_set_down(netif);
    
    _VNCServer_Notify(NOTIFY_SERVER_NETIF_DOWN);
    
    /* If DHCP: stop process */
    if (_DHCPClinet_TCB != 0)
    {
      /* Update DHCP state machine */
      DHCP_state = DHCP_LINK_DOWN;
    }
  }
  /* Clear IO Expander Interrupt flag */
  BSP_IO_ITClear();
}
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;
}
static snmp_err_t
interfaces_Table_set_value(struct snmp_node_instance* instance, u16_t len, void *value)
{
  struct netif *netif = (struct netif*)instance->reference.ptr;
  s32_t *sint_ptr = (s32_t*)value;

  /* stack should never call this method for another column,
  because all other columns are set to readonly */
  LWIP_ASSERT("Invalid column", (SNMP_TABLE_GET_COLUMN_FROM_OID(instance->instance_oid.id) == 7));
  LWIP_UNUSED_ARG(len);

  if (*sint_ptr == 1) {
    netif_set_up(netif);
  } else if (*sint_ptr == 2) {
    netif_set_down(netif);
  }

  return SNMP_ERR_NOERROR;
}
Beispiel #25
0
//Set the network address of a given L3 interface.
BOOL lwipSetIPAddress(LPVOID pL3Intface, __ETH_IP_CONFIG* pConfig)
{
	struct netif* pif = (struct netif*)pL3Intface;
	ip_addr_t addr, mask, gw;

	if ((NULL == pif) || (NULL == pConfig))
	{
		return FALSE;
	}
	//Convert common network address to IP address.
	addr.addr = pConfig->ipaddr.Address.ipv4_addr;
	mask.addr = pConfig->mask.Address.ipv4_addr;
	gw.addr = pConfig->defgw.Address.ipv4_addr;

	//Config the IP parameters into interface.
	netif_set_down(pif);
	netif_set_addr(pif, &addr, &mask, &gw);
	netif_set_up(pif);
	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;
}
Beispiel #27
0
static void
wl_cm_disconn_cb(void* ctx)
{
	struct ctx_server* hs = ctx;

	LINK_LED_OFF();
	INFO_INIT("Disconnection cb...\n");

    if (hs->net_cfg.dhcp_running) {
    	printk("link down, release dhcp\n");
        dhcp_release(hs->net_cfg.netif);
        dhcp_stop(hs->net_cfg.netif);
        hs->net_cfg.dhcp_running = 0;
     } else {
    	 printk("link down\n");
    	 netif_set_down(hs->net_cfg.netif);
     }

     set_result_cmd(WL_FAILURE);
}
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;
}
STATIC mp_obj_t wiznet5k_active(size_t n_args, const mp_obj_t *args) {
    wiznet5k_obj_t *self = MP_OBJ_TO_PTR(args[0]);
    if (n_args == 1) {
        return mp_obj_new_bool(self->netif.flags & NETIF_FLAG_UP);
    } else {
        if (mp_obj_is_true(args[1])) {
            if (!(self->netif.flags & NETIF_FLAG_UP)) {
                wiznet5k_init();
                netif_set_link_up(&self->netif);
                netif_set_up(&self->netif);
            }
        } else {
            if (self->netif.flags & NETIF_FLAG_UP) {
                netif_set_down(&self->netif);
                netif_set_link_down(&self->netif);
                wiznet5k_deinit();
            }
        }
        return mp_const_none;
    }
}
Beispiel #30
0
/**
  * @brief  Initializes the lwIP stack
  * @param  None
  * @retval None
  */
static void Netif_Config(void)
{
  struct ip_addr ipaddr;
  struct ip_addr netmask;
  struct ip_addr gw;	
  
  /* IP address setting */
  IP4_ADDR(&ipaddr, IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3);
  IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1 , NETMASK_ADDR2, NETMASK_ADDR3);
  IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);
  
  /* - netif_add(struct netif *netif, struct ip_addr *ipaddr,
  struct ip_addr *netmask, struct ip_addr *gw,
  void *state, err_t (* init)(struct netif *netif),
  err_t (* input)(struct pbuf *p, struct netif *netif))
  
  Adds your network interface to the netif_list. Allocate a struct
  netif and pass a pointer to this structure as the first argument.
  Give pointers to cleared ip_addr structures when using DHCP,
  or fill them with sane numbers otherwise. The state pointer may be NULL.
  
  The init function pointer must point to a initialization function for
  your ethernet netif interface. The following code illustrates it's use.*/
  
  netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, &ethernetif_init, &tcpip_input);
  
  /*  Registers the default network interface. */
  netif_set_default(&gnetif);
  
  if (netif_is_link_up(&gnetif))
  {
    /* When the netif is fully configured this function must be called.*/
    netif_set_up(&gnetif);
  }
  else
  {
    /* When the netif link is down this function must be called */
    netif_set_down(&gnetif);
  }
}