2 * Copyright (C) 2000-2005 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
6 * $Id: printpacket.c,v 1.12.4.5 2007/09/09 22:15:30 darrenr Exp $
12 # define IP_OFFMASK 0x3fff
25 len = ntohs(((u_short *)ip)[2]) + 40;
27 off = ntohs(ip->ip_off);
28 len = ntohs(ip->ip_len);
31 if ((opts & OPT_HEX) == OPT_HEX) {
35 for (s = (u_char *)ip, i = 0; i < len; i++) {
36 printf("%02x", *s++ & 0xff);
39 printf("%02x", *s++ & 0xff);
53 tcp = (struct tcphdr *)((char *)ip + (IP_HL(ip) << 2));
54 printf("ip #%d %d(%d) %d", ntohs(ip->ip_id), ntohs(ip->ip_len),
55 IP_HL(ip) << 2, ip->ip_p);
57 printf(" @%d", (off & IP_OFFMASK) << 3);
58 printf(" %s", inet_ntoa(ip->ip_src));
59 if (!(off & IP_OFFMASK))
60 if (ip->ip_p == IPPROTO_TCP || ip->ip_p == IPPROTO_UDP)
61 printf(",%d", ntohs(tcp->th_sport));
63 printf("%s", inet_ntoa(ip->ip_dst));
64 if (!(off & IP_OFFMASK)) {
65 if (ip->ip_p == IPPROTO_TCP || ip->ip_p == IPPROTO_UDP)
66 printf(",%d", ntohs(tcp->th_dport));
67 if ((ip->ip_p == IPPROTO_TCP) && (tcp->th_flags != 0)) {
69 if (tcp->th_flags & TH_FIN)
71 if (tcp->th_flags & TH_SYN)
73 if (tcp->th_flags & TH_RST)
75 if (tcp->th_flags & TH_PUSH)
77 if (tcp->th_flags & TH_ACK)
79 if (tcp->th_flags & TH_URG)
81 if (tcp->th_flags & TH_ECN)
83 if (tcp->th_flags & TH_CWR)