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