2 * Copyright (C) 1993-2001 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
6 * $Id: printpacket.c,v 1.12.4.1 2005/02/21 05:09:24 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);
52 tcp
= (struct tcphdr
*)((char *)ip
+ (IP_HL(ip
) << 2));
53 printf("ip %d(%d) %d", ntohs(ip
->ip_len
), IP_HL(ip
) << 2, ip
->ip_p
);
55 printf(" @%d", off
<< 3);
56 printf(" %s", inet_ntoa(ip
->ip_src
));
57 if (!(off
& IP_OFFMASK
))
58 if (ip
->ip_p
== IPPROTO_TCP
|| ip
->ip_p
== IPPROTO_UDP
)
59 printf(",%d", ntohs(tcp
->th_sport
));
61 printf("%s", inet_ntoa(ip
->ip_dst
));
62 if (!(off
& IP_OFFMASK
)) {
63 if (ip
->ip_p
== IPPROTO_TCP
|| ip
->ip_p
== IPPROTO_UDP
)
64 printf(",%d", ntohs(tcp
->th_dport
));
65 if ((ip
->ip_p
== IPPROTO_TCP
) && (tcp
->th_flags
!= 0)) {
67 if (tcp
->th_flags
& TH_FIN
)
69 if (tcp
->th_flags
& TH_SYN
)
71 if (tcp
->th_flags
& TH_RST
)
73 if (tcp
->th_flags
& TH_PUSH
)
75 if (tcp
->th_flags
& TH_ACK
)
77 if (tcp
->th_flags
& TH_URG
)
79 if (tcp
->th_flags
& TH_ECN
)
81 if (tcp
->th_flags
& TH_CWR
)