4 * Copyright (C) 2012 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
14 # define IP_OFFMASK 0x3fff
31 len = ntohs(((ip6_t *)ip)->ip6_plen);
33 len = ntohs(((u_short *)ip)[2]);
37 len = ntohs(ip->ip_len);
39 ASSERT(len == msgdsize(m));
41 if ((opts & OPT_HEX) == OPT_HEX) {
45 for (; m != NULL; m = m->mb_next) {
47 for (s = (u_char *)m->mb_data, i = 0; i < len; i++) {
48 PRINTF("%02x", *s++ & 0xff);
51 PRINTF("%02x", *s++ & 0xff);
71 PRINTF("%s ", IFNAME(m->mb_ifp));
73 off = ntohs(ip->ip_off);
74 tcp = (struct tcphdr *)((char *)ip + (IP_HL(ip) << 2));
75 PRINTF("ip #%d %d(%d) %d", ntohs(ip->ip_id), ntohs(ip->ip_len),
76 IP_HL(ip) << 2, ip->ip_p);
78 PRINTF(" @%d", off << 3);
79 PRINTF(" %s", inet_ntoa(ip->ip_src));
80 if (!(off & IP_OFFMASK))
81 if (ip->ip_p == IPPROTO_TCP || ip->ip_p == IPPROTO_UDP)
82 PRINTF(",%d", ntohs(tcp->th_sport));
84 PRINTF("%s", inet_ntoa(ip->ip_dst));
85 if (!(off & IP_OFFMASK)) {
86 if (ip->ip_p == IPPROTO_TCP || ip->ip_p == IPPROTO_UDP)
87 PRINTF(",%d", ntohs(tcp->th_dport));
88 if ((ip->ip_p == IPPROTO_TCP) && (tcp->th_flags != 0)) {
90 if (tcp->th_flags & TH_FIN)
92 if (tcp->th_flags & TH_SYN)
94 if (tcp->th_flags & TH_RST)
96 if (tcp->th_flags & TH_PUSH)
98 if (tcp->th_flags & TH_ACK)
100 if (tcp->th_flags & TH_URG)
102 if (tcp->th_flags & TH_ECN)
104 if (tcp->th_flags & TH_CWR)