Ejemplo n.º 1
0
/************************************************************************
* NAME: fnet_eth_timer
*
* DESCRIPTION: 
*************************************************************************/
static void fnet_eth_timer( void *cookie )
{
    fnet_netif_t *netif = (fnet_netif_t *) cookie;
    int connection_flag = ((fnet_eth_if_t *)(netif->if_ptr))->connection_flag;


    if(fnet_netif_connected(netif) != connection_flag) /* Is any change in connection. */
    {
        if(connection_flag == 0)  /* Connected. */
        {
            fnet_eth_change_addr_notify(netif);
        }
            
        ((fnet_eth_if_t *)(netif->if_ptr))->connection_flag = connection_flag ^ 1;
    }
}
Ejemplo n.º 2
0
/************************************************************************
* NAME: fapp_info_print
*
* DESCRIPTION: Display detailed information about the stack.
************************************************************************/
static void fapp_info_print( fnet_shell_desc_t desc )
{
    fnet_char_t                mac_str[FNET_MAC_ADDR_STR_SIZE];
    fnet_mac_addr_t     macaddr;
    fnet_netif_desc_t   netif = fnet_netif_get_default();         

    fapp_netif_info_print(desc, netif);

    /* HW address, if any */
    if(fnet_netif_get_hw_addr(netif, macaddr, sizeof(fnet_mac_addr_t)) == FNET_OK)
    {
        fnet_shell_println(desc, FAPP_SHELL_INFO_FORMAT_S, "MAC Address", fnet_mac_to_str(macaddr, mac_str));
    }    
    fnet_shell_println(desc, FAPP_SHELL_INFO_FORMAT_D, "MTU", fnet_netif_get_mtu(netif));    
    fnet_shell_println(desc, FAPP_SHELL_INFO_FORMAT_S, "Link Status", fnet_netif_connected(netif) ? "connected" : "unconnected");
    fnet_shell_println(desc, FAPP_SHELL_INFO_FORMAT_D, "Free Heap", fnet_free_mem_status());

#if FAPP_CFG_HTTP_CMD && FNET_CFG_HTTP
    fapp_http_info(desc);
#endif

#if FAPP_CFG_DHCP_CMD && FNET_CFG_DHCP && FNET_CFG_IP4
    fapp_dhcp_info(desc);
#endif

#if FAPP_CFG_TELNET_CMD && FNET_CFG_TELNET
    fapp_telnet_info(desc);
#endif   

#if FAPP_CFG_TFTPS_CMD && FNET_CFG_TFTP_SRV
    fapp_tftps_info(desc);
#endif 

#if FAPP_CFG_LLMNR_CMD && FNET_CFG_LLMNR
    fapp_llmnr_info(desc);
#endif 
}
Ejemplo n.º 3
0
/************************************************************************
* NAME: fnet_eth_init
*
* DESCRIPTION: Do initialization for an Ethernet-type interface.
*************************************************************************/
int fnet_eth_init( fnet_netif_t *netif)
{
    int result;

#if !FNET_CFG_CPU_ETH_MIB 
    /* Clear Ethernet statistics. */
    fnet_memset_zero(&((fnet_eth_if_t *)(netif->if_ptr))->statistics, sizeof(struct fnet_netif_statistics));
#endif 

#if FNET_CFG_IP4   
    result = fnet_arp_init(netif); /* Init ARP for this interface.*/
#else
    result = FNET_OK;    
#endif /* FNET_CFG_IP4 */

    if(result == FNET_OK)
    {

    #if FNET_CFG_IP6  
        #if FNET_CFG_IP6_PMTU_DISCOVERY  
            fnet_netif_pmtu_init(netif);
        #endif
        
        /* Init Neighbor Discovery.*/
        if( ( result = fnet_nd6_init (netif, &((fnet_eth_if_t *)(netif->if_ptr))->nd6_if) ) == FNET_OK)
        {
            /* RFC4861 6.3.3: The host joins the all-nodes multicast address on all 
             * multicastcapable interfaces.
             */
            fnet_netif_join_ip6_multicast ( (fnet_netif_desc_t)netif, &fnet_ip6_addr_linklocal_allnodes );

            /* To speed the autoconfiguration process, a host may generate its linklocal
             * address (and verify its uniqueness) in parallel with waiting
             * for a Router Advertisement. Because a router may delay responding to
             * a Router Solicitation for a few seconds, the total time needed to
             * complete autoconfiguration can be significantly longer if the two
             * steps are done serially.
             */


            /* Link-Local Address Generation/Auto configuration.
             * It comprises of '1111111010' as the first ten bits followed by 54 zeroes 
             * and a 64 bit interface identifier.
             * For all autoconfiguration types, a link-local address is always configured. 
             */
            fnet_netif_bind_ip6_addr_prv( netif, (fnet_ip6_addr_t *)&fnet_ip6_addr_any, FNET_NETIF_IP6_ADDR_TYPE_AUTOCONFIGURABLE, 
                                                FNET_NETIF_IP6_ADDR_LIFETIME_INFINITE /*in seconds*/, FNET_ND6_PREFIX_LENGTH_DEFAULT /* bits */ );

            /* RFC4862: The next phase of autoconfiguration involves obtaining a Router
             * Advertisement or determining that no routers are present.  If routers
             * are present, they will send Router Advertisements that specify what
             * sort of autoconfiguration a host can do.
             * To obtain an advertisement quickly, a host sends one or more Router
             * Solicitations to the all-routers multicast group.
             */
            fnet_nd6_rd_start(netif); 
        }    
    #endif /* FNET_CFG_IP6 */
        
        /* Set connection flag. */
        ((fnet_eth_if_t *)(netif->if_ptr))->connection_flag = fnet_netif_connected(netif);
        
        ((fnet_eth_if_t *)(netif->if_ptr))->eth_timer = 
                            fnet_timer_new((FNET_ETH_TIMER_PERIOD / FNET_TIMER_PERIOD_MS), fnet_eth_timer, netif);
        
        fnet_eth_number++;
    }
    
    return result;
}