1*7c478bd9Sstevel@tonic-gate #include "ipf.h"
2*7c478bd9Sstevel@tonic-gate
3*7c478bd9Sstevel@tonic-gate /*
4*7c478bd9Sstevel@tonic-gate * This is meant to work without the IPv6 header files being present or
5*7c478bd9Sstevel@tonic-gate * the inet_ntop() library.
6*7c478bd9Sstevel@tonic-gate */
printpacket6(ip)7*7c478bd9Sstevel@tonic-gate void printpacket6(ip)
8*7c478bd9Sstevel@tonic-gate struct ip *ip;
9*7c478bd9Sstevel@tonic-gate {
10*7c478bd9Sstevel@tonic-gate u_char *buf, p;
11*7c478bd9Sstevel@tonic-gate u_short plen, *addrs;
12*7c478bd9Sstevel@tonic-gate tcphdr_t *tcp;
13*7c478bd9Sstevel@tonic-gate u_32_t flow;
14*7c478bd9Sstevel@tonic-gate
15*7c478bd9Sstevel@tonic-gate buf = (u_char *)ip;
16*7c478bd9Sstevel@tonic-gate tcp = (tcphdr_t *)(buf + 40);
17*7c478bd9Sstevel@tonic-gate p = buf[6];
18*7c478bd9Sstevel@tonic-gate flow = ntohl(*(u_32_t *)buf);
19*7c478bd9Sstevel@tonic-gate flow &= 0xfffff;
20*7c478bd9Sstevel@tonic-gate plen = ntohs(*((u_short *)buf +2));
21*7c478bd9Sstevel@tonic-gate addrs = (u_short *)buf + 4;
22*7c478bd9Sstevel@tonic-gate
23*7c478bd9Sstevel@tonic-gate printf("ip6/%d %d %#x %d", buf[0] & 0xf, plen, flow, p);
24*7c478bd9Sstevel@tonic-gate printf(" %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
25*7c478bd9Sstevel@tonic-gate ntohs(addrs[0]), ntohs(addrs[1]), ntohs(addrs[2]),
26*7c478bd9Sstevel@tonic-gate ntohs(addrs[3]), ntohs(addrs[4]), ntohs(addrs[5]),
27*7c478bd9Sstevel@tonic-gate ntohs(addrs[6]), ntohs(addrs[7]));
28*7c478bd9Sstevel@tonic-gate if (plen >= 4)
29*7c478bd9Sstevel@tonic-gate if (p == IPPROTO_TCP || p == IPPROTO_UDP)
30*7c478bd9Sstevel@tonic-gate (void)printf(",%d", ntohs(tcp->th_sport));
31*7c478bd9Sstevel@tonic-gate printf(" >");
32*7c478bd9Sstevel@tonic-gate addrs += 8;
33*7c478bd9Sstevel@tonic-gate printf(" %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
34*7c478bd9Sstevel@tonic-gate ntohs(addrs[0]), ntohs(addrs[1]), ntohs(addrs[2]),
35*7c478bd9Sstevel@tonic-gate ntohs(addrs[3]), ntohs(addrs[4]), ntohs(addrs[5]),
36*7c478bd9Sstevel@tonic-gate ntohs(addrs[6]), ntohs(addrs[7]));
37*7c478bd9Sstevel@tonic-gate if (plen >= 4)
38*7c478bd9Sstevel@tonic-gate if (p == IPPROTO_TCP || p == IPPROTO_UDP)
39*7c478bd9Sstevel@tonic-gate (void)printf(",%d", ntohs(tcp->th_dport));
40*7c478bd9Sstevel@tonic-gate putchar('\n');
41*7c478bd9Sstevel@tonic-gate }
42