4 * Copyright (C) 1993-2001 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
8 * $Id: printpacket.c,v 1.12.4.2 2005/12/04 09:33:06 darrenr Exp $
14 # define IP_OFFMASK 0x3fff
27 len = ntohs(((u_short *)ip)[2]) + 40;
29 off = ntohs(ip->ip_off);
30 len = ntohs(ip->ip_len);
33 if ((opts & OPT_HEX) == OPT_HEX) {
37 for (s = (u_char *)ip, i = 0; i < len; i++) {
38 printf("%02x", *s++ & 0xff);
41 printf("%02x", *s++ & 0xff);
54 tcp = (struct tcphdr *)((char *)ip + (IP_HL(ip) << 2));
55 printf("ip #%d %d(%d) %d", ntohs(ip->ip_id), ntohs(ip->ip_len),
56 IP_HL(ip) << 2, ip->ip_p);
58 printf(" @%d", off << 3);
59 printf(" %s", inet_ntoa(ip->ip_src));
60 if (!(off & IP_OFFMASK))
61 if (ip->ip_p == IPPROTO_TCP || ip->ip_p == IPPROTO_UDP)
62 printf(",%d", ntohs(tcp->th_sport));
64 printf("%s", inet_ntoa(ip->ip_dst));
65 if (!(off & IP_OFFMASK)) {
66 if (ip->ip_p == IPPROTO_TCP || ip->ip_p == IPPROTO_UDP)
67 printf(",%d", ntohs(tcp->th_dport));
68 if ((ip->ip_p == IPPROTO_TCP) && (tcp->th_flags != 0)) {
70 if (tcp->th_flags & TH_FIN)
72 if (tcp->th_flags & TH_SYN)
74 if (tcp->th_flags & TH_RST)
76 if (tcp->th_flags & TH_PUSH)
78 if (tcp->th_flags & TH_ACK)
80 if (tcp->th_flags & TH_URG)
82 if (tcp->th_flags & TH_ECN)
84 if (tcp->th_flags & TH_CWR)