码迷,mamicode.com
首页 > 其他好文 > 详细

LwIP与IPv6

时间:2017-10-08 19:39:26      阅读:401      评论:0      收藏:0      [点我收藏+]

标签:address   没有   color   win   snmp   write   ssi   dhcp   sub   

2.0.0中才开始支持IPv6,在此版本中改写了SNMP,但还没有IPv6的统计量。目前最新版本是2.0.2,其中SNMP也没有IPv6统计量(哪些?与IP的统计量有何区别?)

1.4.1中虽然有ip6.c,但是非常简单。

(2.0.0)

  ++ Application changes:

  * Changed netif "up" flag handling to be an administrative flag (as opposed to the previous meaning of
    "ip4-address-valid", a netif will now not be used for transmission if not up) -> even a DHCP netif
    has to be set "up" before starting the DHCP client
  * Added IPv6 support (dual-stack or IPv4/IPv6 only)
  * Changed ip_addr_t to be a union in dual-stack mode (use ip4_addr_t where referring to IPv4 only).
  * Major rewrite of SNMP (added MIB parser that creates code stubs for custom MIBs);
    supports SNMPv2c (experimental v3 support)
  * Moved some core applications from contrib repository to src/apps (and include/lwip/apps)

两个版本netif结构体的对比:IPv6每个接口可以配置多个地址(默认3个),地址有状态区分

/** Generic data structure used for all lwIP network interfaces.
 *  The following fields should be filled in by the initialization
 *  function for the device driver: hwaddr_len, hwaddr[], mtu, flags */
struct netif {
  /** pointer to next in linked list */
  struct netif *next;

  /** IP address configuration in network byte order */
  ip_addr_t ip_addr;
  ip_addr_t netmask;
  ip_addr_t gw;

/** Generic data structure used for all lwIP network interfaces.
 *  The following fields should be filled in by the initialization
 *  function for the device driver: hwaddr_len, hwaddr[], mtu, flags */
struct netif {
  /** pointer to next in linked list */
  struct netif *next;

#if LWIP_IPV4
  /** IP address configuration in network byte order */
  ip_addr_t ip_addr;
  ip_addr_t netmask;
  ip_addr_t gw;
#endif /* LWIP_IPV4 */
#if LWIP_IPV6
  /** Array of IPv6 addresses for this netif. */
  ip_addr_t ip6_addr[LWIP_IPV6_NUM_ADDRESSES];
  /** The state of each IPv6 address (Tentative, Preferred, etc).
   * @see ip6_addr.h */
  u8_t ip6_addr_state[LWIP_IPV6_NUM_ADDRESSES];
#endif /* LWIP_IPV6 */

两个版本IPv6路由函数对比,新版本会判断是否是link local地址等等。

/* ip_route:
 *
 * Finds the appropriate network interface for a given IP address. It searches the
 * list of network interfaces linearly. A match is found if the masked IP address of
 * the network interface equals the masked IP address given to the function.
 */
struct netif *
ip_route(struct ip_addr *dest)
{
  struct netif *netif;

  for(netif = netif_list; netif != NULL; netif = netif->next) {
    if (ip_addr_netcmp(dest, &(netif->ip_addr), &(netif->netmask))) {
      return netif;
    }
  }
  return netif_default;
}


/**
 * Finds the appropriate network interface for a given IPv6 address. It tries to select
 * a netif following a sequence of heuristics:
 * 1) if there is only 1 netif, return it
 * 2) if the destination is a link-local address, try to match the src address to a netif.
 *    this is a tricky case because with multiple netifs, link-local addresses only have
 *    meaning within a particular subnet/link.
 * 3) tries to match the destination subnet to a configured address
 * 4) tries to find a router
 * 5) tries to match the source address to the netif
 * 6) returns the default netif, if configured
 *
 * @param src the source IPv6 address, if known
 * @param dest the destination IPv6 address for which to find the route
 * @return the netif on which to send to reach dest
 */
struct netif *
ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest)

 

LwIP与IPv6

标签:address   没有   color   win   snmp   write   ssi   dhcp   sub   

原文地址:http://www.cnblogs.com/yanhc/p/7638167.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!