in6_var.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. /* $OpenBSD: in6_var.h,v 1.52 2015/07/08 08:48:34 mpi Exp $ */
  2. /* $KAME: in6_var.h,v 1.55 2001/02/16 12:49:45 itojun Exp $ */
  3. /*
  4. * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the project nor the names of its contributors
  16. * may be used to endorse or promote products derived from this software
  17. * without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22. * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
  23. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  24. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  25. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  26. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  27. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  28. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29. * SUCH DAMAGE.
  30. */
  31. /*
  32. * Copyright (c) 1985, 1986, 1993
  33. * The Regents of the University of California. All rights reserved.
  34. *
  35. * Redistribution and use in source and binary forms, with or without
  36. * modification, are permitted provided that the following conditions
  37. * are met:
  38. * 1. Redistributions of source code must retain the above copyright
  39. * notice, this list of conditions and the following disclaimer.
  40. * 2. Redistributions in binary form must reproduce the above copyright
  41. * notice, this list of conditions and the following disclaimer in the
  42. * documentation and/or other materials provided with the distribution.
  43. * 3. Neither the name of the University nor the names of its contributors
  44. * may be used to endorse or promote products derived from this software
  45. * without specific prior written permission.
  46. *
  47. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  48. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  49. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  50. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  51. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  52. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  53. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  54. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  55. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  56. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  57. * SUCH DAMAGE.
  58. *
  59. * @(#)in_var.h 8.1 (Berkeley) 6/10/93
  60. */
  61. #ifndef _NETINET6_IN6_VAR_H_
  62. #define _NETINET6_IN6_VAR_H_
  63. /*
  64. * Interface address, Internet version. One of these structures
  65. * is allocated for each interface with an Internet address.
  66. * The ifaddr structure contains the protocol-independent part
  67. * of the structure and is assumed to be first.
  68. */
  69. /*
  70. * pltime/vltime are just for future reference (required to implements 2
  71. * hour rule for hosts). they should never be modified by nd6_timeout or
  72. * anywhere else.
  73. * userland -> kernel: accept pltime/vltime
  74. * kernel -> userland: throw up everything
  75. * in kernel: modify preferred/expire only
  76. */
  77. struct in6_addrlifetime {
  78. time_t ia6t_expire; /* valid lifetime expiration time */
  79. time_t ia6t_preferred; /* preferred lifetime expiration time */
  80. u_int32_t ia6t_vltime; /* valid lifetime */
  81. u_int32_t ia6t_pltime; /* prefix lifetime */
  82. };
  83. #ifdef _KERNEL
  84. struct nd_ifinfo;
  85. struct in6_ifextra {
  86. struct in6_ifstat *in6_ifstat;
  87. struct icmp6_ifstat *icmp6_ifstat;
  88. struct nd_ifinfo *nd_ifinfo;
  89. void *rs_lhcookie;
  90. int nprefixes;
  91. int ndefrouters;
  92. };
  93. struct in6_ifaddr {
  94. struct ifaddr ia_ifa; /* protocol-independent info */
  95. #define ia_ifp ia_ifa.ifa_ifp
  96. #define ia_flags ia_ifa.ifa_flags
  97. struct sockaddr_in6 ia_addr; /* interface address */
  98. struct sockaddr_in6 ia_net; /* network number of interface */
  99. struct sockaddr_in6 ia_dstaddr; /* space for destination addr */
  100. struct sockaddr_in6 ia_prefixmask; /* prefix mask */
  101. TAILQ_ENTRY(in6_ifaddr) ia_list; /* list of IP6 addresses */
  102. int ia6_flags;
  103. struct in6_addrlifetime ia6_lifetime;
  104. time_t ia6_createtime; /* the creation time of this address, which is
  105. * currently used for temporary addresses only.
  106. */
  107. time_t ia6_updatetime;
  108. /* back pointer to the prefix (for all addresses, not just autoconf) */
  109. struct nd_prefix *ia6_ndpr;
  110. /* multicast addresses joined from the kernel */
  111. LIST_HEAD(, in6_multi_mship) ia6_memberships;
  112. };
  113. #endif /* _KERNEL */
  114. /*
  115. * IPv6 interface statistics, as defined in RFC2465 Ipv6IfStatsEntry (p12).
  116. */
  117. struct in6_ifstat {
  118. u_int64_t ifs6_in_receive; /* # of total input datagram */
  119. u_int64_t ifs6_in_hdrerr; /* # of datagrams with invalid hdr */
  120. u_int64_t ifs6_in_toobig; /* # of datagrams exceeded MTU */
  121. u_int64_t ifs6_in_noroute; /* # of datagrams with no route */
  122. u_int64_t ifs6_in_addrerr; /* # of datagrams with invalid dst */
  123. u_int64_t ifs6_in_protounknown; /* # of datagrams with unknown proto */
  124. /* NOTE: increment on final dst if */
  125. u_int64_t ifs6_in_truncated; /* # of truncated datagrams */
  126. u_int64_t ifs6_in_discard; /* # of discarded datagrams */
  127. /* NOTE: fragment timeout is not here */
  128. u_int64_t ifs6_in_deliver; /* # of datagrams delivered to ULP */
  129. /* NOTE: increment on final dst if */
  130. u_int64_t ifs6_out_forward; /* # of datagrams forwarded */
  131. /* NOTE: increment on outgoing if */
  132. u_int64_t ifs6_out_request; /* # of outgoing datagrams from ULP */
  133. /* NOTE: does not include forwrads */
  134. u_int64_t ifs6_out_discard; /* # of discarded datagrams */
  135. u_int64_t ifs6_out_fragok; /* # of datagrams fragmented */
  136. u_int64_t ifs6_out_fragfail; /* # of datagrams failed on fragment */
  137. u_int64_t ifs6_out_fragcreat; /* # of fragment datagrams */
  138. /* NOTE: this is # after fragment */
  139. u_int64_t ifs6_reass_reqd; /* # of incoming fragmented packets */
  140. /* NOTE: increment on final dst if */
  141. u_int64_t ifs6_reass_ok; /* # of reassembled packets */
  142. /* NOTE: this is # after reass */
  143. /* NOTE: increment on final dst if */
  144. u_int64_t ifs6_reass_fail; /* # of reass failures */
  145. /* NOTE: may not be packet count */
  146. /* NOTE: increment on final dst if */
  147. u_int64_t ifs6_in_mcast; /* # of inbound multicast datagrams */
  148. u_int64_t ifs6_out_mcast; /* # of outbound multicast datagrams */
  149. };
  150. /*
  151. * ICMPv6 interface statistics, as defined in RFC2466 Ipv6IfIcmpEntry.
  152. * XXX: I'm not sure if this file is the right place for this structure...
  153. */
  154. struct icmp6_ifstat {
  155. /*
  156. * Input statistics
  157. */
  158. /* ipv6IfIcmpInMsgs, total # of input messages */
  159. u_int64_t ifs6_in_msg;
  160. /* ipv6IfIcmpInErrors, # of input error messages */
  161. u_int64_t ifs6_in_error;
  162. /* ipv6IfIcmpInDestUnreachs, # of input dest unreach errors */
  163. u_int64_t ifs6_in_dstunreach;
  164. /* ipv6IfIcmpInAdminProhibs, # of input administratively prohibited errs */
  165. u_int64_t ifs6_in_adminprohib;
  166. /* ipv6IfIcmpInTimeExcds, # of input time exceeded errors */
  167. u_int64_t ifs6_in_timeexceed;
  168. /* ipv6IfIcmpInParmProblems, # of input parameter problem errors */
  169. u_int64_t ifs6_in_paramprob;
  170. /* ipv6IfIcmpInPktTooBigs, # of input packet too big errors */
  171. u_int64_t ifs6_in_pkttoobig;
  172. /* ipv6IfIcmpInEchos, # of input echo requests */
  173. u_int64_t ifs6_in_echo;
  174. /* ipv6IfIcmpInEchoReplies, # of input echo replies */
  175. u_int64_t ifs6_in_echoreply;
  176. /* ipv6IfIcmpInRouterSolicits, # of input router solicitations */
  177. u_int64_t ifs6_in_routersolicit;
  178. /* ipv6IfIcmpInRouterAdvertisements, # of input router advertisements */
  179. u_int64_t ifs6_in_routeradvert;
  180. /* ipv6IfIcmpInNeighborSolicits, # of input neighbor solicitations */
  181. u_int64_t ifs6_in_neighborsolicit;
  182. /* ipv6IfIcmpInNeighborAdvertisements, # of input neighbor advertisements */
  183. u_int64_t ifs6_in_neighboradvert;
  184. /* ipv6IfIcmpInRedirects, # of input redirects */
  185. u_int64_t ifs6_in_redirect;
  186. /* ipv6IfIcmpInGroupMembQueries, # of input MLD queries */
  187. u_int64_t ifs6_in_mldquery;
  188. /* ipv6IfIcmpInGroupMembResponses, # of input MLD reports */
  189. u_int64_t ifs6_in_mldreport;
  190. /* ipv6IfIcmpInGroupMembReductions, # of input MLD done */
  191. u_int64_t ifs6_in_mlddone;
  192. /*
  193. * Output statistics. We should solve unresolved routing problem...
  194. */
  195. /* ipv6IfIcmpOutMsgs, total # of output messages */
  196. u_int64_t ifs6_out_msg;
  197. /* ipv6IfIcmpOutErrors, # of output error messages */
  198. u_int64_t ifs6_out_error;
  199. /* ipv6IfIcmpOutDestUnreachs, # of output dest unreach errors */
  200. u_int64_t ifs6_out_dstunreach;
  201. /* ipv6IfIcmpOutAdminProhibs, # of output administratively prohibited errs */
  202. u_int64_t ifs6_out_adminprohib;
  203. /* ipv6IfIcmpOutTimeExcds, # of output time exceeded errors */
  204. u_int64_t ifs6_out_timeexceed;
  205. /* ipv6IfIcmpOutParmProblems, # of output parameter problem errors */
  206. u_int64_t ifs6_out_paramprob;
  207. /* ipv6IfIcmpOutPktTooBigs, # of output packet too big errors */
  208. u_int64_t ifs6_out_pkttoobig;
  209. /* ipv6IfIcmpOutEchos, # of output echo requests */
  210. u_int64_t ifs6_out_echo;
  211. /* ipv6IfIcmpOutEchoReplies, # of output echo replies */
  212. u_int64_t ifs6_out_echoreply;
  213. /* ipv6IfIcmpOutRouterSolicits, # of output router solicitations */
  214. u_int64_t ifs6_out_routersolicit;
  215. /* ipv6IfIcmpOutRouterAdvertisements, # of output router advertisements */
  216. u_int64_t ifs6_out_routeradvert;
  217. /* ipv6IfIcmpOutNeighborSolicits, # of output neighbor solicitations */
  218. u_int64_t ifs6_out_neighborsolicit;
  219. /* ipv6IfIcmpOutNeighborAdvertisements, # of output neighbor advertisements */
  220. u_int64_t ifs6_out_neighboradvert;
  221. /* ipv6IfIcmpOutRedirects, # of output redirects */
  222. u_int64_t ifs6_out_redirect;
  223. /* ipv6IfIcmpOutGroupMembQueries, # of output MLD queries */
  224. u_int64_t ifs6_out_mldquery;
  225. /* ipv6IfIcmpOutGroupMembResponses, # of output MLD reports */
  226. u_int64_t ifs6_out_mldreport;
  227. /* ipv6IfIcmpOutGroupMembReductions, # of output MLD done */
  228. u_int64_t ifs6_out_mlddone;
  229. };
  230. struct in6_ifreq {
  231. char ifr_name[IFNAMSIZ];
  232. union {
  233. struct sockaddr_in6 ifru_addr;
  234. struct sockaddr_in6 ifru_dstaddr;
  235. short ifru_flags;
  236. int ifru_flags6;
  237. int ifru_metric;
  238. caddr_t ifru_data;
  239. struct in6_addrlifetime ifru_lifetime;
  240. struct in6_ifstat ifru_stat;
  241. struct icmp6_ifstat ifru_icmp6stat;
  242. } ifr_ifru;
  243. };
  244. struct in6_aliasreq {
  245. char ifra_name[IFNAMSIZ];
  246. union {
  247. struct sockaddr_in6 ifrau_addr;
  248. int ifrau_align;
  249. } ifra_ifrau;
  250. #ifndef ifra_addr
  251. #define ifra_addr ifra_ifrau.ifrau_addr
  252. #endif
  253. struct sockaddr_in6 ifra_dstaddr;
  254. struct sockaddr_in6 ifra_prefixmask;
  255. int ifra_flags;
  256. struct in6_addrlifetime ifra_lifetime;
  257. };
  258. /* prefix type macro */
  259. #define IN6_PREFIX_ND 1
  260. #define IN6_PREFIX_RR 2
  261. /*
  262. * prefix related flags passed between kernel(NDP related part) and
  263. * user land command(ifconfig) and daemon(rtadvd).
  264. */
  265. struct prf_ra {
  266. u_int onlink : 1;
  267. u_int autonomous : 1;
  268. u_int router : 1;
  269. u_int reserved : 5;
  270. };
  271. struct in6_prflags {
  272. struct prf_ra prf_ra;
  273. u_char prf_reserved1;
  274. u_short prf_reserved2;
  275. /* want to put this on 4byte offset */
  276. struct prf_rr {
  277. u_int decrvalid : 1;
  278. u_int decrprefd : 1;
  279. u_int reserved : 6;
  280. } prf_rr;
  281. u_char prf_reserved3;
  282. u_short prf_reserved4;
  283. };
  284. struct in6_prefixreq {
  285. char ipr_name[IFNAMSIZ];
  286. u_char ipr_origin;
  287. u_char ipr_plen;
  288. u_int32_t ipr_vltime;
  289. u_int32_t ipr_pltime;
  290. struct in6_prflags ipr_flags;
  291. struct sockaddr_in6 ipr_prefix;
  292. };
  293. #define PR_ORIG_RA 0
  294. #define PR_ORIG_RR 1
  295. #define PR_ORIG_STATIC 2
  296. #define PR_ORIG_KERNEL 3
  297. #define ipr_raf_onlink ipr_flags.prf_ra.onlink
  298. #define ipr_raf_auto ipr_flags.prf_ra.autonomous
  299. #define ipr_statef_onlink ipr_flags.prf_state.onlink
  300. #define ipr_rrf_decrvalid ipr_flags.prf_rr.decrvalid
  301. #define ipr_rrf_decrprefd ipr_flags.prf_rr.decrprefd
  302. struct in6_rrenumreq {
  303. char irr_name[IFNAMSIZ];
  304. u_char irr_origin;
  305. u_char irr_m_len; /* match len for matchprefix */
  306. u_char irr_m_minlen; /* minlen for matching prefix */
  307. u_char irr_m_maxlen; /* maxlen for matching prefix */
  308. u_char irr_u_uselen; /* uselen for adding prefix */
  309. u_char irr_u_keeplen; /* keeplen from matching prefix */
  310. struct irr_raflagmask {
  311. u_int onlink : 1;
  312. u_int autonomous : 1;
  313. u_int reserved : 6;
  314. } irr_raflagmask;
  315. u_int32_t irr_vltime;
  316. u_int32_t irr_pltime;
  317. struct in6_prflags irr_flags;
  318. struct sockaddr_in6 irr_matchprefix;
  319. struct sockaddr_in6 irr_useprefix;
  320. };
  321. #define irr_raf_mask_onlink irr_raflagmask.onlink
  322. #define irr_raf_mask_auto irr_raflagmask.autonomous
  323. #define irr_raf_mask_reserved irr_raflagmask.reserved
  324. #define irr_raf_onlink irr_flags.prf_ra.onlink
  325. #define irr_raf_auto irr_flags.prf_ra.autonomous
  326. #define irr_statef_onlink irr_flags.prf_state.onlink
  327. #define irr_rrf irr_flags.prf_rr
  328. #define irr_rrf_decrvalid irr_flags.prf_rr.decrvalid
  329. #define irr_rrf_decrprefd irr_flags.prf_rr.decrprefd
  330. /*
  331. * Given a pointer to an in6_ifaddr (ifaddr),
  332. * return a pointer to the addr as a sockaddr_in6
  333. */
  334. #define IA6_IN6(ia) (&((ia)->ia_addr.sin6_addr))
  335. #define IA6_DSTIN6(ia) (&((ia)->ia_dstaddr.sin6_addr))
  336. #define IA6_MASKIN6(ia) (&((ia)->ia_prefixmask.sin6_addr))
  337. #define IA6_SIN6(ia) (&((ia)->ia_addr))
  338. #define IA6_DSTSIN6(ia) (&((ia)->ia_dstaddr))
  339. #define IFA_IN6(x) (&((struct sockaddr_in6 *)((x)->ifa_addr))->sin6_addr)
  340. #define IFA_DSTIN6(x) (&((struct sockaddr_in6 *)((x)->ifa_dstaddr))->sin6_addr)
  341. #ifdef _KERNEL
  342. #define IN6_ARE_MASKED_ADDR_EQUAL(d, a, m) ( \
  343. (((d)->s6_addr32[0] ^ (a)->s6_addr32[0]) & (m)->s6_addr32[0]) == 0 && \
  344. (((d)->s6_addr32[1] ^ (a)->s6_addr32[1]) & (m)->s6_addr32[1]) == 0 && \
  345. (((d)->s6_addr32[2] ^ (a)->s6_addr32[2]) & (m)->s6_addr32[2]) == 0 && \
  346. (((d)->s6_addr32[3] ^ (a)->s6_addr32[3]) & (m)->s6_addr32[3]) == 0 )
  347. #endif /* _KERNEL */
  348. #define SIOCSIFADDR_IN6 _IOW('i', 12, struct in6_ifreq)
  349. #define SIOCGIFADDR_IN6 _IOWR('i', 33, struct in6_ifreq)
  350. #ifdef _KERNEL
  351. /*
  352. * SIOCSxxx ioctls should be unused (see comments in in6.c), but
  353. * we do not shift numbers for binary compatibility.
  354. */
  355. #define SIOCSIFDSTADDR_IN6 _IOW('i', 14, struct in6_ifreq)
  356. #define SIOCSIFNETMASK_IN6 _IOW('i', 22, struct in6_ifreq)
  357. #endif /* _KERNEL */
  358. #define SIOCGIFDSTADDR_IN6 _IOWR('i', 34, struct in6_ifreq)
  359. #define SIOCGIFNETMASK_IN6 _IOWR('i', 37, struct in6_ifreq)
  360. #define SIOCDIFADDR_IN6 _IOW('i', 25, struct in6_ifreq)
  361. #define SIOCAIFADDR_IN6 _IOW('i', 26, struct in6_aliasreq)
  362. #define SIOCSIFPHYADDR_IN6 _IOW('i', 70, struct in6_aliasreq)
  363. #define SIOCGIFPSRCADDR_IN6 _IOWR('i', 71, struct in6_ifreq)
  364. #define SIOCGIFPDSTADDR_IN6 _IOWR('i', 72, struct in6_ifreq)
  365. #define SIOCGIFAFLAG_IN6 _IOWR('i', 73, struct in6_ifreq)
  366. #define SIOCGIFINFO_IN6 _IOWR('i', 108, struct in6_ndireq)
  367. #define SIOCSNDFLUSH_IN6 _IOWR('i', 77, struct in6_ifreq)
  368. #define SIOCGNBRINFO_IN6 _IOWR('i', 78, struct in6_nbrinfo)
  369. #define SIOCSPFXFLUSH_IN6 _IOWR('i', 79, struct in6_ifreq)
  370. #define SIOCSRTRFLUSH_IN6 _IOWR('i', 80, struct in6_ifreq)
  371. #define SIOCGIFALIFETIME_IN6 _IOWR('i', 81, struct in6_ifreq)
  372. #define SIOCSIFALIFETIME_IN6 _IOWR('i', 82, struct in6_ifreq)
  373. #define SIOCGIFSTAT_IN6 _IOWR('i', 83, struct in6_ifreq)
  374. #define SIOCGIFSTAT_ICMP6 _IOWR('i', 84, struct in6_ifreq)
  375. #define SIOCSIFINFO_FLAGS _IOWR('i', 87, struct in6_ndireq) /* XXX */
  376. #define SIOCSIFPREFIX_IN6 _IOW('i', 100, struct in6_prefixreq) /* set */
  377. #define SIOCGIFPREFIX_IN6 _IOWR('i', 101, struct in6_prefixreq) /* get */
  378. #define SIOCDIFPREFIX_IN6 _IOW('i', 102, struct in6_prefixreq) /* del */
  379. #define SIOCAIFPREFIX_IN6 _IOW('i', 103, struct in6_rrenumreq) /* add */
  380. #define SIOCCIFPREFIX_IN6 _IOW('i', 104, \
  381. struct in6_rrenumreq) /* change */
  382. #define SIOCSGIFPREFIX_IN6 _IOW('i', 105, \
  383. struct in6_rrenumreq) /* set global */
  384. #define SIOCGETSGCNT_IN6 _IOWR('u', 106, \
  385. struct sioc_sg_req6) /* get s,g pkt cnt */
  386. #define SIOCGETMIFCNT_IN6 _IOWR('u', 107, \
  387. struct sioc_mif_req6) /* get pkt cnt per if */
  388. #define IN6_IFF_ANYCAST 0x01 /* anycast address */
  389. #define IN6_IFF_TENTATIVE 0x02 /* tentative address */
  390. #define IN6_IFF_DUPLICATED 0x04 /* DAD detected duplicate */
  391. #define IN6_IFF_DETACHED 0x08 /* may be detached from the link */
  392. #define IN6_IFF_DEPRECATED 0x10 /* deprecated address */
  393. #define IN6_IFF_NODAD 0x20 /* don't perform DAD on this address
  394. * (used only at first SIOC* call)
  395. */
  396. #define IN6_IFF_AUTOCONF 0x40 /* autoconfigurable address. */
  397. #define IN6_IFF_PRIVACY 0x80 /* RFC 4941 temporary address */
  398. /* do not input/output */
  399. #define IN6_IFF_NOTREADY (IN6_IFF_TENTATIVE|IN6_IFF_DUPLICATED)
  400. #ifdef _KERNEL
  401. #define IN6_ARE_SCOPE_CMP(a,b) ((a)-(b))
  402. #define IN6_ARE_SCOPE_EQUAL(a,b) ((a)==(b))
  403. TAILQ_HEAD(in6_ifaddrhead, in6_ifaddr);
  404. extern struct in6_ifaddrhead in6_ifaddr;
  405. extern struct icmp6stat icmp6stat;
  406. #define in6_ifstat_inc(ifp, tag) \
  407. do { \
  408. if (ifp) \
  409. ((struct in6_ifextra *)((ifp)->if_afdata[AF_INET6]))->in6_ifstat->tag++; \
  410. } while (0)
  411. /*
  412. * Multi-cast membership entry. One for each group/ifp that a PCB
  413. * belongs to.
  414. */
  415. struct in6_multi_mship {
  416. struct in6_multi *i6mm_maddr; /* Multicast address pointer */
  417. LIST_ENTRY(in6_multi_mship) i6mm_chain; /* multicast options chain */
  418. };
  419. struct in6_multi {
  420. struct ifmaddr in6m_ifma; /* Protocol-independent info */
  421. #define in6m_refcnt in6m_ifma.ifma_refcnt
  422. #define in6m_ifidx in6m_ifma.ifma_ifidx
  423. struct sockaddr_in6 in6m_sin; /* IPv6 multicast address */
  424. #define in6m_addr in6m_sin.sin6_addr
  425. u_int in6m_state; /* state of membership */
  426. u_int in6m_timer; /* MLD6 membership report timer */
  427. };
  428. static __inline struct in6_multi *
  429. ifmatoin6m(struct ifmaddr *ifma)
  430. {
  431. return ((struct in6_multi *)(ifma));
  432. }
  433. /*
  434. * Macros for looking up the in6_multi record for a given IP6 multicast
  435. * address on a given interface. If no matching record is found, "in6m"
  436. * returns NULL.
  437. */
  438. #define IN6_LOOKUP_MULTI(addr, ifp, in6m) \
  439. /* struct in6_addr addr; */ \
  440. /* struct ifnet *ifp; */ \
  441. /* struct in6_multi *in6m; */ \
  442. do { \
  443. struct ifmaddr *ifma; \
  444. \
  445. (in6m) = NULL; \
  446. TAILQ_FOREACH(ifma, &(ifp)->if_maddrlist, ifma_list) \
  447. if (ifma->ifma_addr->sa_family == AF_INET6 && \
  448. IN6_ARE_ADDR_EQUAL(&ifmatoin6m(ifma)->in6m_addr, \
  449. &(addr))) { \
  450. (in6m) = ifmatoin6m(ifma); \
  451. break; \
  452. } \
  453. } while (/* CONSTCOND */ 0)
  454. struct in6_multi *in6_addmulti(struct in6_addr *, struct ifnet *, int *);
  455. void in6_delmulti(struct in6_multi *);
  456. struct in6_multi_mship *in6_joingroup(struct ifnet *, struct in6_addr *, int *);
  457. int in6_leavegroup(struct in6_multi_mship *);
  458. int in6_control(struct socket *, u_long, caddr_t, struct ifnet *);
  459. int in6_update_ifa(struct ifnet *, struct in6_aliasreq *,
  460. struct in6_ifaddr *);
  461. void in6_purgeaddr(struct ifaddr *);
  462. int in6if_do_dad(struct ifnet *);
  463. void *in6_domifattach(struct ifnet *);
  464. void in6_domifdetach(struct ifnet *, void *);
  465. struct in6_ifaddr *in6ifa_ifpforlinklocal(struct ifnet *, int);
  466. struct in6_ifaddr *in6ifa_ifpwithaddr(struct ifnet *, struct in6_addr *);
  467. int in6_ifpprefix(const struct ifnet *, const struct in6_addr *);
  468. int in6_addr2scopeid(unsigned int, struct in6_addr *);
  469. int in6_matchlen(struct in6_addr *, struct in6_addr *);
  470. int in6_are_prefix_equal(struct in6_addr *, struct in6_addr *, int);
  471. void in6_prefixlen2mask(struct in6_addr *, int);
  472. void in6_purgeprefix(struct ifnet *);
  473. #endif /* _KERNEL */
  474. #endif /* _NETINET6_IN6_VAR_H_ */