/************************************************************************ * NAME: fnet_netif_bind_ip6_addr * * DESCRIPTION: This is USER API function binds the IPv6 address to a hardware interface. *************************************************************************/ int fnet_netif_bind_ip6_addr(fnet_netif_desc_t netif_desc, fnet_ip6_addr_t *addr, fnet_netif_ip6_addr_type_t addr_type) { fnet_netif_t *netif = (fnet_netif_t *)netif_desc; return fnet_netif_bind_ip6_addr_prv(netif, addr, addr_type, FNET_NETIF_IP6_ADDR_LIFETIME_INFINITE, FNET_ND6_PREFIX_LENGTH_DEFAULT); }
/************************************************************************ * NAME: fnet_eth_init * * DESCRIPTION: Do initialization for an Ethernet-type interface. *************************************************************************/ fnet_return_t fnet_eth_init( fnet_netif_t *netif) { fnet_return_t result = FNET_ERR; fnet_eth_if_t *eth_if = (fnet_eth_if_t *)(netif->if_ptr); if(eth_if) { #if !FNET_CFG_CPU_ETH_MIB /* Clear Ethernet statistics. */ fnet_memset_zero(ð_if->statistics, sizeof(struct fnet_netif_statistics)); #endif #if FNET_CFG_IP4 result = fnet_arp_init(netif, ð_if->arp_if); /* 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, ð_if->nd6_if) ) == FNET_OK) { /* RFC4861 6.3.3: The host joins the all-nodes multicast address on all * multicastcapable interfaces. */ fnet_ip6_multicast_join(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_any, FNET_NETIF_IP_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. */ eth_if->connection_flag = fnet_netif_is_connected(netif); eth_if->eth_timer = fnet_timer_new((FNET_ETH_TIMER_PERIOD / FNET_TIMER_PERIOD_MS), fnet_eth_timer, (fnet_uint32_t)netif); fnet_eth_number++; } } return result; }