1 /* 2 * Copyright (c) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 3 * 2002, 2003, 2004 4 * Ohio University. 5 * 6 * --- 7 * 8 * Starting with the release of tcptrace version 6 in 2001, tcptrace 9 * is licensed under the GNU General Public License (GPL). We believe 10 * that, among the available licenses, the GPL will do the best job of 11 * allowing tcptrace to continue to be a valuable, freely-available 12 * and well-maintained tool for the networking community. 13 * 14 * Previous versions of tcptrace were released under a license that 15 * was much less restrictive with respect to how tcptrace could be 16 * used in commercial products. Because of this, I am willing to 17 * consider alternate license arrangements as allowed in Section 10 of 18 * the GNU GPL. Before I would consider licensing tcptrace under an 19 * alternate agreement with a particular individual or company, 20 * however, I would have to be convinced that such an alternative 21 * would be to the greater benefit of the networking community. 22 * 23 * --- 24 * 25 * This file is part of Tcptrace. 26 * 27 * Tcptrace was originally written and continues to be maintained by 28 * Shawn Ostermann with the help of a group of devoted students and 29 * users (see the file 'THANKS'). The work on tcptrace has been made 30 * possible over the years through the generous support of NASA GRC, 31 * the National Science Foundation, and Sun Microsystems. 32 * 33 * Tcptrace is free software; you can redistribute it and/or modify it 34 * under the terms of the GNU General Public License as published by 35 * the Free Software Foundation; either version 2 of the License, or 36 * (at your option) any later version. 37 * 38 * Tcptrace is distributed in the hope that it will be useful, but 39 * WITHOUT ANY WARRANTY; without even the implied warranty of 40 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 41 * General Public License for more details. 42 * 43 * You should have received a copy of the GNU General Public License 44 * along with Tcptrace (in the file 'COPYING'); if not, write to the 45 * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 46 * MA 02111-1307 USA 47 * 48 * Author: Shawn Ostermann 49 * School of Electrical Engineering and Computer Science 50 * Ohio University 51 * Athens, OH 52 * ostermann@cs.ohiou.edu 53 * http://www.tcptrace.org/ 54 */ 55 static char const GCC_UNUSED rcsid_ipv6[] = 56 "@(#)$Header$"; 57 58 59 /* 60 * ipv6.h: 61 * 62 * Structures for IPv6 packets 63 * 64 */ 65 #include <sys/types.h> 66 67 #ifndef ETHERTYPE_IPV6 68 #define ETHERTYPE_IPV6 0x86DD /* Ethernet type for ipv6 */ 69 #endif 70 71 /* just guessing... */ 72 #if !defined(IPPROTO_NONE) && !defined(IPPROTO_FRAGMENT) && !defined(IPPROTO_DSTOPTS) && !defined(INET6_ADDRSTRLEN) 73 /* when IPv6 is more widely/standardly deployed, these constants won't need to be 74 here. In the mean time, here's the stuff we need... */ 75 #define IPV6NOTFOUND 76 77 /* header types */ 78 #define IPPROTO_HOPOPTS 0 /* Hop by hop header for v6 */ 79 #define IPPROTO_IPV6 41 /* IPv6 encapsulated in IP */ 80 #define IPPROTO_ROUTING 43 /* Routing header for IPv6 */ 81 #define IPPROTO_FRAGMENT 44 /* Fragment header for IPv6 */ 82 #define IPPROTO_ICMPV6 58 /* ICMP for IPv6 */ 83 #define IPPROTO_NONE 59 /* No next header for IPv6 */ 84 #define IPPROTO_DSTOPTS 60 /* Destinations options */ 85 86 /* other constants we need */ 87 #define INET6_ADDRSTRLEN 46 /* IPv6 Address length in a string format*/ 88 89 /* this is SOMETIMES already defined */ 90 #ifndef AF_INET6 91 #define AF_INET6 24 /* Internet Protocol, V6 */ 92 #endif /* AF_INET6 */ 93 94 95 96 /* 97 * IPv6 address data structure. 98 */ 99 #ifdef __WIN32 100 typedef struct in6_addr { 101 u_char s6_addr[16]; /* IPv6 address */ 102 } in6_addr; 103 #endif /* __WIN32 */ 104 105 #endif /* notdef IPPROTO_NONE */ 106 107 108 /* 109 * IPv6 datagram header 110 */ 111 struct ipv6 { 112 u_int ip6_ver_tc_flabel; /* first 4 bits = version #, 113 next 8 bits = Trafic class, 114 next 20 bits = flow label */ 115 u_short ip6_lngth; /* Payload length */ 116 u_char ip6_nheader; /* Next Header */ 117 u_char ip6_hlimit; /* Hop Limit */ 118 struct in6_addr ip6_saddr; /* Source Address */ 119 struct in6_addr ip6_daddr; /* Destination Address */ 120 }; 121 122 123 /* IPv6 extension header format */ 124 struct ipv6_ext { 125 u_char ip6ext_nheader; /* Next Header */ 126 u_char ip6ext_len; /* number of bytes in this header */ 127 u_char ip6ext_data[2]; /* optional data */ 128 }; 129 130 131 /* IPv6 fragmentation header */ 132 struct ipv6_ext_frag { 133 u_char ip6ext_fr_nheader; /* Next Header */ 134 u_char ip6ext_fr_res; /* (reserved) */ 135 u_short ip6ext_fr_offset; /* fragment offset(13),res(2),M(1) */ 136 u_long ip6ext_fr_ID; /* ID field */ 137 }; 138 139 140 /* tcptrace's IPv6 access routines */ 141 int gettcp(struct ip *pip, struct tcphdr **pptcp, void **pplast); 142 int getudp(struct ip *pip, struct udphdr **ppudp, void **pplast); 143 int getroutingheader(struct ip *pip, struct ipv6_ext **ppipv6_ext, void **pplast); 144 int gethdrlength (struct ip *pip, void *plast); 145 int getpayloadlength (struct ip *pip, void *plast); 146 struct ipv6_ext *ipv6_nextheader(void *pheader0, u_char *pnextheader); 147 char *ipv6_header_name(u_char nextheader); 148 char *my_inet_ntop(int af, const char *src, char *dst, size_t size); 149 int total_length_ext_headers(struct ipv6 *pip6); 150 151