1570af302Sopenharmony_ci#ifndef _NETINET_IP6_H 2570af302Sopenharmony_ci#define _NETINET_IP6_H 3570af302Sopenharmony_ci 4570af302Sopenharmony_ci#ifdef __cplusplus 5570af302Sopenharmony_ciextern "C" { 6570af302Sopenharmony_ci#endif 7570af302Sopenharmony_ci 8570af302Sopenharmony_ci#include <stdint.h> 9570af302Sopenharmony_ci#include <netinet/in.h> 10570af302Sopenharmony_ci 11570af302Sopenharmony_cistruct ip6_hdr { 12570af302Sopenharmony_ci union { 13570af302Sopenharmony_ci struct ip6_hdrctl { 14570af302Sopenharmony_ci uint32_t ip6_un1_flow; 15570af302Sopenharmony_ci uint16_t ip6_un1_plen; 16570af302Sopenharmony_ci uint8_t ip6_un1_nxt; 17570af302Sopenharmony_ci uint8_t ip6_un1_hlim; 18570af302Sopenharmony_ci } ip6_un1; 19570af302Sopenharmony_ci uint8_t ip6_un2_vfc; 20570af302Sopenharmony_ci } ip6_ctlun; 21570af302Sopenharmony_ci struct in6_addr ip6_src; 22570af302Sopenharmony_ci struct in6_addr ip6_dst; 23570af302Sopenharmony_ci}; 24570af302Sopenharmony_ci 25570af302Sopenharmony_ci#define ip6_vfc ip6_ctlun.ip6_un2_vfc 26570af302Sopenharmony_ci#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow 27570af302Sopenharmony_ci#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen 28570af302Sopenharmony_ci#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt 29570af302Sopenharmony_ci#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim 30570af302Sopenharmony_ci#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim 31570af302Sopenharmony_ci 32570af302Sopenharmony_cistruct ip6_ext { 33570af302Sopenharmony_ci uint8_t ip6e_nxt; 34570af302Sopenharmony_ci uint8_t ip6e_len; 35570af302Sopenharmony_ci}; 36570af302Sopenharmony_ci 37570af302Sopenharmony_cistruct ip6_hbh { 38570af302Sopenharmony_ci uint8_t ip6h_nxt; 39570af302Sopenharmony_ci uint8_t ip6h_len; 40570af302Sopenharmony_ci}; 41570af302Sopenharmony_ci 42570af302Sopenharmony_cistruct ip6_dest { 43570af302Sopenharmony_ci uint8_t ip6d_nxt; 44570af302Sopenharmony_ci uint8_t ip6d_len; 45570af302Sopenharmony_ci}; 46570af302Sopenharmony_ci 47570af302Sopenharmony_cistruct ip6_rthdr { 48570af302Sopenharmony_ci uint8_t ip6r_nxt; 49570af302Sopenharmony_ci uint8_t ip6r_len; 50570af302Sopenharmony_ci uint8_t ip6r_type; 51570af302Sopenharmony_ci uint8_t ip6r_segleft; 52570af302Sopenharmony_ci}; 53570af302Sopenharmony_ci 54570af302Sopenharmony_cistruct ip6_rthdr0 { 55570af302Sopenharmony_ci uint8_t ip6r0_nxt; 56570af302Sopenharmony_ci uint8_t ip6r0_len; 57570af302Sopenharmony_ci uint8_t ip6r0_type; 58570af302Sopenharmony_ci uint8_t ip6r0_segleft; 59570af302Sopenharmony_ci uint8_t ip6r0_reserved; 60570af302Sopenharmony_ci uint8_t ip6r0_slmap[3]; 61570af302Sopenharmony_ci struct in6_addr ip6r0_addr[]; 62570af302Sopenharmony_ci}; 63570af302Sopenharmony_ci 64570af302Sopenharmony_cistruct ip6_frag { 65570af302Sopenharmony_ci uint8_t ip6f_nxt; 66570af302Sopenharmony_ci uint8_t ip6f_reserved; 67570af302Sopenharmony_ci uint16_t ip6f_offlg; 68570af302Sopenharmony_ci uint32_t ip6f_ident; 69570af302Sopenharmony_ci}; 70570af302Sopenharmony_ci 71570af302Sopenharmony_ci#if __BYTE_ORDER == __BIG_ENDIAN 72570af302Sopenharmony_ci#define IP6F_OFF_MASK 0xfff8 73570af302Sopenharmony_ci#define IP6F_RESERVED_MASK 0x0006 74570af302Sopenharmony_ci#define IP6F_MORE_FRAG 0x0001 75570af302Sopenharmony_ci#else 76570af302Sopenharmony_ci#define IP6F_OFF_MASK 0xf8ff 77570af302Sopenharmony_ci#define IP6F_RESERVED_MASK 0x0600 78570af302Sopenharmony_ci#define IP6F_MORE_FRAG 0x0100 79570af302Sopenharmony_ci#endif 80570af302Sopenharmony_ci 81570af302Sopenharmony_cistruct ip6_opt { 82570af302Sopenharmony_ci uint8_t ip6o_type; 83570af302Sopenharmony_ci uint8_t ip6o_len; 84570af302Sopenharmony_ci}; 85570af302Sopenharmony_ci 86570af302Sopenharmony_ci#define IP6OPT_TYPE(o) ((o) & 0xc0) 87570af302Sopenharmony_ci#define IP6OPT_TYPE_SKIP 0x00 88570af302Sopenharmony_ci#define IP6OPT_TYPE_DISCARD 0x40 89570af302Sopenharmony_ci#define IP6OPT_TYPE_FORCEICMP 0x80 90570af302Sopenharmony_ci#define IP6OPT_TYPE_ICMP 0xc0 91570af302Sopenharmony_ci#define IP6OPT_TYPE_MUTABLE 0x20 92570af302Sopenharmony_ci 93570af302Sopenharmony_ci#define IP6OPT_PAD1 0 94570af302Sopenharmony_ci#define IP6OPT_PADN 1 95570af302Sopenharmony_ci 96570af302Sopenharmony_ci#define IP6OPT_JUMBO 0xc2 97570af302Sopenharmony_ci#define IP6OPT_NSAP_ADDR 0xc3 98570af302Sopenharmony_ci#define IP6OPT_TUNNEL_LIMIT 0x04 99570af302Sopenharmony_ci#define IP6OPT_ROUTER_ALERT 0x05 100570af302Sopenharmony_ci 101570af302Sopenharmony_cistruct ip6_opt_jumbo { 102570af302Sopenharmony_ci uint8_t ip6oj_type; 103570af302Sopenharmony_ci uint8_t ip6oj_len; 104570af302Sopenharmony_ci uint8_t ip6oj_jumbo_len[4]; 105570af302Sopenharmony_ci}; 106570af302Sopenharmony_ci#define IP6OPT_JUMBO_LEN 6 107570af302Sopenharmony_ci 108570af302Sopenharmony_cistruct ip6_opt_nsap { 109570af302Sopenharmony_ci uint8_t ip6on_type; 110570af302Sopenharmony_ci uint8_t ip6on_len; 111570af302Sopenharmony_ci uint8_t ip6on_src_nsap_len; 112570af302Sopenharmony_ci uint8_t ip6on_dst_nsap_len; 113570af302Sopenharmony_ci}; 114570af302Sopenharmony_ci 115570af302Sopenharmony_cistruct ip6_opt_tunnel { 116570af302Sopenharmony_ci uint8_t ip6ot_type; 117570af302Sopenharmony_ci uint8_t ip6ot_len; 118570af302Sopenharmony_ci uint8_t ip6ot_encap_limit; 119570af302Sopenharmony_ci}; 120570af302Sopenharmony_ci 121570af302Sopenharmony_cistruct ip6_opt_router { 122570af302Sopenharmony_ci uint8_t ip6or_type; 123570af302Sopenharmony_ci uint8_t ip6or_len; 124570af302Sopenharmony_ci uint8_t ip6or_value[2]; 125570af302Sopenharmony_ci}; 126570af302Sopenharmony_ci 127570af302Sopenharmony_ci#if __BYTE_ORDER == __BIG_ENDIAN 128570af302Sopenharmony_ci#define IP6_ALERT_MLD 0x0000 129570af302Sopenharmony_ci#define IP6_ALERT_RSVP 0x0001 130570af302Sopenharmony_ci#define IP6_ALERT_AN 0x0002 131570af302Sopenharmony_ci#else 132570af302Sopenharmony_ci#define IP6_ALERT_MLD 0x0000 133570af302Sopenharmony_ci#define IP6_ALERT_RSVP 0x0100 134570af302Sopenharmony_ci#define IP6_ALERT_AN 0x0200 135570af302Sopenharmony_ci#endif 136570af302Sopenharmony_ci 137570af302Sopenharmony_ci#ifdef __cplusplus 138570af302Sopenharmony_ci} 139570af302Sopenharmony_ci#endif 140570af302Sopenharmony_ci 141570af302Sopenharmony_ci#endif 142