third_party/lwip/repo/lwip/src/core/netif.c
/**
 * This function allows for the addition of a new IPv6 address to an interface
 * along with a prefix len to add a route to the routing table.
 *
 * @param netif netif to add the address on
 * @param ip6addr address to add
 * @prefix_len the prefix length for the route corresponding to the address
 * @param chosen_idx if != NULL, the chosen IPv6 address index will be stored here
 */
This function allows for the addition of a new IPv6 address to an interface
along with a prefix len to add a route to the routing table.

@param netif netif to add the address on
@param ip6addr address to add
@prefix_len the prefix length for the route corresponding to the address
@param chosen_idx if != NULL, the chosen IPv6 address index will be stored here
This function allows for the addition of a new IPv6 address to an interface along with a prefix len to add a route to the routing table . @param netif netif to add the address on @param ip6addr address to add @prefix_len the prefix length for the route corresponding to the address @param chosen_idx if ! = NULL the chosen IPv6 address index will be stored here
err_t
netif_add_ip6_address_with_route(struct netif *netif, ip6_addr_t *ip6addr, 
                                 u8_t prefix_len, s8_t *chosen_idx)
{
  s8_t retval = ERR_OK;
#if LWIP_IPV6_ROUTE_TABLE_SUPPORT
  struct ip6_prefix ip6_pref;
  if (!ip6_prefix_valid(prefix_len)) {
    retval = ERR_ARG;
    goto fail;
  }
#else
  if (prefix_len != 64 && prefix_len != 128) {
    retval = ERR_ARG;
    goto fail;
  }
#endif
  if ((retval = netif_add_ip6_address(netif, ip6addr, chosen_idx)) !=
                ERR_OK) {
    goto fail;
  }
#if LWIP_IPV6_ROUTE_TABLE_SUPPORT
  if (prefix_len > 0 && prefix_len < IP6_MAX_PREFIX_LEN) {
    ip6_addr_copy(ip6_pref.addr, *ip6addr);
    ip6_pref.prefix_len = prefix_len;
    if ((retval = ip6_add_route_entry(&ip6_pref, netif, NULL, NULL)) != 
                  ERR_OK) {
      goto fail;
    }
  }
#endif 
fail:
  return retval;
}
err_t netif_add_ip6_address_with_route ( struct netif * netif , ip6_addr_t * ip6addr , u8_t prefix_len , s8_t * chosen_idx ) { s8_t retval = ERR_OK ; #if LWIP_IPV6_ROUTE_TABLE_SUPPORT struct ip6_prefix ip6_pref ; if ( ! ip6_prefix_valid ( prefix_len ) ) { retval = ERR_ARG ; goto fail ; } #else if ( prefix_len != 64 && prefix_len != 128 ) { retval = ERR_ARG ; goto fail ; } #endif if ( ( retval = netif_add_ip6_address ( netif , ip6addr , chosen_idx ) ) != ERR_OK ) { goto fail ; } #if LWIP_IPV6_ROUTE_TABLE_SUPPORT if ( prefix_len > 0 && prefix_len < IP6_MAX_PREFIX_LEN ) { ip6_addr_copy ( ip6_pref . addr , * ip6addr ) ; ip6_pref . prefix_len = prefix_len ; if ( ( retval = ip6_add_route_entry ( & ip6_pref , netif , NULL , NULL ) ) != ERR_OK ) { goto fail ; } } #endif fail : return retval ; }
This function allows for the addition of a new IPv6 address to an interface
 along with a prefix len to add a route to the routing table.
This function allows for the addition of a new IPv6 address to an interface along with a prefix len to add a route to the routing table .
/* Add a route in routing table for the prefix len. Ignore adding route if
   * prefix_len is zero(default route) or prefix_len is 128(host route) 
   */ /* LWIP_IPV6_ROUTE_TABLE_SUPPORT */