if_inet6.h
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:4k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /*
  2.  * inet6 interface/address list definitions
  3.  * Linux INET6 implementation 
  4.  *
  5.  * Authors:
  6.  * Pedro Roque <roque@di.fc.ul.pt>
  7.  *
  8.  *
  9.  * This program is free software; you can redistribute it and/or
  10.  *      modify it under the terms of the GNU General Public License
  11.  *      as published by the Free Software Foundation; either version
  12.  *      2 of the License, or (at your option) any later version.
  13.  */
  14. #ifndef _NET_IF_INET6_H
  15. #define _NET_IF_INET6_H
  16. #define IF_RA_RCVD 0x20
  17. #define IF_RS_SENT 0x10
  18. #ifdef __KERNEL__
  19. struct inet6_ifaddr 
  20. {
  21. struct in6_addr addr;
  22. __u32 prefix_len;
  23. __u32 valid_lft;
  24. __u32 prefered_lft;
  25. unsigned long tstamp;
  26. atomic_t refcnt;
  27. spinlock_t lock;
  28. __u8 probes;
  29. __u8 flags;
  30. __u16 scope;
  31. struct timer_list timer;
  32. struct inet6_dev *idev;
  33. struct inet6_ifaddr *lst_next;      /* next addr in addr_lst */
  34. struct inet6_ifaddr *if_next;       /* next addr in inet6_dev */
  35. int dead;
  36. };
  37. struct ipv6_mc_socklist
  38. {
  39. struct in6_addr addr;
  40. int ifindex;
  41. struct ipv6_mc_socklist *next;
  42. };
  43. #define MAF_TIMER_RUNNING 0x01
  44. #define MAF_LAST_REPORTER 0x02
  45. #define MAF_LOADED 0x04
  46. struct ifmcaddr6
  47. {
  48. struct in6_addr mca_addr;
  49. struct inet6_dev *idev;
  50. struct ifmcaddr6 *next;
  51. struct timer_list mca_timer;
  52. unsigned mca_flags;
  53. int mca_users;
  54. atomic_t mca_refcnt;
  55. spinlock_t mca_lock;
  56. };
  57. #define IFA_HOST IPV6_ADDR_LOOPBACK
  58. #define IFA_LINK IPV6_ADDR_LINKLOCAL
  59. #define IFA_SITE IPV6_ADDR_SITELOCAL
  60. #define IFA_GLOBAL 0x0000U
  61. struct ipv6_devconf
  62. {
  63. int forwarding;
  64. int hop_limit;
  65. int mtu6;
  66. int accept_ra;
  67. int accept_redirects;
  68. int autoconf;
  69. int dad_transmits;
  70. int rtr_solicits;
  71. int rtr_solicit_interval;
  72. int rtr_solicit_delay;
  73. void *sysctl;
  74. };
  75. struct inet6_dev 
  76. {
  77. struct net_device *dev;
  78. struct inet6_ifaddr *addr_list;
  79. struct ifmcaddr6 *mc_list;
  80. rwlock_t lock;
  81. atomic_t refcnt;
  82. __u32 if_flags;
  83. int dead;
  84. struct neigh_parms *nd_parms;
  85. struct inet6_dev *next;
  86. struct ipv6_devconf cnf;
  87. };
  88. extern struct ipv6_devconf ipv6_devconf;
  89. static inline void ipv6_eth_mc_map(struct in6_addr *addr, char *buf)
  90. {
  91. /*
  92.  * +-------+-------+-------+-------+-------+-------+
  93.  *      |   33  |   33  | DST13 | DST14 | DST15 | DST16 |
  94.  *      +-------+-------+-------+-------+-------+-------+
  95.  */
  96. buf[0]= 0x33;
  97. buf[1]= 0x33;
  98. memcpy(buf + 2, &addr->s6_addr32[3], sizeof(__u32));
  99. }
  100. static inline void ipv6_tr_mc_map(struct in6_addr *addr, char *buf)
  101. {
  102. /* All nodes FF01::1, FF02::1, FF02::1:FFxx:xxxx */
  103. if (((addr->s6_addr[0] == 0xFF) &&
  104.     ((addr->s6_addr[1] == 0x01) || (addr->s6_addr[1] == 0x02)) &&
  105.      (addr->s6_addr16[1] == 0) &&
  106.      (addr->s6_addr32[1] == 0) &&
  107.      (addr->s6_addr32[2] == 0) &&
  108.      (addr->s6_addr16[6] == 0) &&
  109.      (addr->s6_addr[15] == 1)) ||
  110.     ((addr->s6_addr[0] == 0xFF) &&
  111.      (addr->s6_addr[1] == 0x02) &&
  112.      (addr->s6_addr16[1] == 0) &&
  113.      (addr->s6_addr32[1] == 0) &&
  114.      (addr->s6_addr16[4] == 0) &&
  115.      (addr->s6_addr[10] == 0) &&
  116.      (addr->s6_addr[11] == 1) &&
  117.      (addr->s6_addr[12] == 0xff)))
  118. {
  119. buf[0]=0xC0;
  120. buf[1]=0x00;
  121. buf[2]=0x01;
  122. buf[3]=0x00;
  123. buf[4]=0x00;
  124. buf[5]=0x00;
  125. /* All routers FF0x::2 */
  126. } else if ((addr->s6_addr[0] ==0xff) &&
  127. ((addr->s6_addr[1] & 0xF0) == 0) &&
  128. (addr->s6_addr16[1] == 0) &&
  129. (addr->s6_addr32[1] == 0) &&
  130. (addr->s6_addr32[2] == 0) &&
  131. (addr->s6_addr16[6] == 0) &&
  132. (addr->s6_addr[15] == 2))
  133. {
  134. buf[0]=0xC0;
  135. buf[1]=0x00;
  136. buf[2]=0x02;
  137. buf[3]=0x00;
  138. buf[4]=0x00;
  139. buf[5]=0x00;
  140. } else {
  141. unsigned char i ; 
  142. i = addr->s6_addr[15] & 7 ; 
  143. buf[0]=0xC0;
  144. buf[1]=0x00;
  145. buf[2]=0x00;
  146. buf[3]=0x01 << i ; 
  147. buf[4]=0x00;
  148. buf[5]=0x00;
  149. }
  150. }
  151. #endif
  152. #endif