4 * Copyright (C) 2002 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
8 * Id: printpacket6.c,v 1.3.4.1 2006/06/16 17:21:13 darrenr Exp
14 * This is meant to work without the IPv6 header files being present or
15 * the inet_ntop() library.
26 tcp
= (tcphdr_t
*)(buf
+ 40);
28 flow
= ntohl(*(u_32_t
*)buf
);
30 plen
= ntohs(*((u_short
*)buf
+2));
31 addrs
= (u_short
*)buf
+ 4;
33 printf("ip6/%d %d %#x %d", buf
[0] & 0xf, plen
, flow
, p
);
34 printf(" %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
35 ntohs(addrs
[0]), ntohs(addrs
[1]), ntohs(addrs
[2]),
36 ntohs(addrs
[3]), ntohs(addrs
[4]), ntohs(addrs
[5]),
37 ntohs(addrs
[6]), ntohs(addrs
[7]));
39 if (p
== IPPROTO_TCP
|| p
== IPPROTO_UDP
)
40 (void)printf(",%d", ntohs(tcp
->th_sport
));
43 printf(" %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
44 ntohs(addrs
[0]), ntohs(addrs
[1]), ntohs(addrs
[2]),
45 ntohs(addrs
[3]), ntohs(addrs
[4]), ntohs(addrs
[5]),
46 ntohs(addrs
[6]), ntohs(addrs
[7]));
48 if (p
== IPPROTO_TCP
|| p
== IPPROTO_UDP
)
49 (void)printf(",%d", ntohs(tcp
->th_dport
));