Exemplo n.º 1
0
static void fapp_set_cmd_mac(fnet_shell_desc_t desc, char *value)
{
    fnet_mac_addr_t macaddr;

    if((fnet_str_to_mac(value, macaddr) != FNET_OK) ||
            (fnet_netif_set_hw_addr(fapp_default_netif, macaddr, sizeof(fnet_mac_addr_t)) != FNET_OK))
    {
            fnet_shell_println(desc, FAPP_PARAM_ERR, value);
    }
}
Exemplo n.º 2
0
/************************************************************************
* NAME: fnet_netif_init
*
* DESCRIPTION: This function installs & inits a network interface.
*************************************************************************/
int fnet_netif_init( fnet_netif_t *netif, unsigned char *hw_addr, unsigned int hw_addr_size )
{
    int result = FNET_OK;
    
    if(netif && netif->api)
    {
        fnet_os_mutex_lock();   
        
        fnet_isr_lock();
        
        netif->next = fnet_netif_list;

        if(netif->next != 0)
            netif->next->prev = netif;

        netif->prev = 0;
        fnet_netif_list = netif;
        
        fnet_netif_assign_scope_id( netif ); /* Asign Scope ID.*/
        
        netif->features = FNET_NETIF_FEATURE_NONE;


        /* Interface HW initialization.*/
        if(netif->api->init && ((result = netif->api->init(netif)) == FNET_OK))
        {
            #if FNET_CFG_IGMP && FNET_CFG_IP4       
                /**************************************************************
                 * RFC1112 7.2
                 *   To support IGMP, every level 2 host must
                 *   join the "all-hosts" group (address 224.0.0.1) on each network
                 *   interface at initialization time and must remain a member for as long
                 *   as the host is active.
                 *
                 * NOTE:(224.0.0.1) membership is never reported by IGMP.
                 **************************************************************/
                 /* Join HW interface. */
                fnet_netif_join_ip4_multicast ( netif, FNET_IP4_ADDR_INIT(224, 0, 0, 1) );
            #endif  /* FNET_CFG_IGMP */
            
            /* Set HW Address.*/    
            fnet_netif_set_hw_addr(netif, hw_addr, hw_addr_size);
                
            /* Interface-Type specific initialisation. */ 
            switch(netif->api->type)
            {
            #if (FNET_CFG_CPU_ETH0 ||FNET_CFG_CPU_ETH1)
                case (FNET_NETIF_TYPE_ETHERNET):
                    result = fnet_eth_init(netif);
                    break;
            #endif /* FNET_CFG_ETH */
                default:
                    break;
            
            }
        }

        fnet_printf("ETH - Initialization: %s, ID:%d\n", netif->name, netif->scope_id);
        fnet_printf("	 - IP: %x, GW: %x\n", netif->ip4_addr.address, netif->ip4_addr.gateway);
        fnet_printf("	 - MASK: %x, DHCP?: %d\n", netif->ip4_addr.netmask, netif->ip4_addr.is_automatic);
        fnet_printf("	 - MTU: %d\n", netif->mtu);
        fnet_printf("	 - MTU: %x\n", netif->if_ptr);



        fnet_isr_unlock();
        
        fnet_os_mutex_unlock();
    }
    
    return result;
}