*** Makefile.in.ORIG Fri Jul 30 10:42:50 2010 --- Makefile.in Fri Jul 30 10:43:02 2010 *************** *** 25,31 **** bindir = $(prefix)/bin datadir = $(prefix)/share ! mandir = $(datadir)/man BINDIR_INSTALL = $(prefix)/bin MANDIR_INSTALL = $(mandir)/man8 --- 25,31 ---- bindir = $(prefix)/bin datadir = $(prefix)/share ! mandir = $(prefix)/man BINDIR_INSTALL = $(prefix)/bin MANDIR_INSTALL = $(mandir)/man8 *** ./ngrep.c.ORIG Fri Jul 30 10:55:34 2010 --- ./ngrep.c Fri Jul 30 10:49:39 2010 *************** *** 43,48 **** --- 43,51 ---- #endif #if defined(AIX) + #if defined(_AIX51) && !defined(_AIX53) + #define STEVENS_API + #endif #include #include #include *************** *** 49,54 **** --- 52,58 ---- #include #include #include + #include #endif #if defined(_WIN32) *************** *** 620,626 **** uint32_t ip_ver; uint8_t ip_proto = 0; ! uint32_t ip_hl = 0; uint32_t ip_off = 0; uint8_t fragmented = 0; --- 624,630 ---- uint32_t ip_ver; uint8_t ip_proto = 0; ! uint32_t aix_ip_hl = 0; uint32_t ip_off = 0; uint8_t fragmented = 0; *************** *** 648,656 **** case 4: { #if defined(AIX) #undef ip_hl ! ip_hl = ip4_pkt->ip_ff.ip_fhl * 4; #else ! ip_hl = ip4_pkt->ip_hl * 4; #endif ip_proto = ip4_pkt->ip_p; ip_off = ntohs(ip4_pkt->ip_off); --- 652,660 ---- case 4: { #if defined(AIX) #undef ip_hl ! aix_ip_hl = ip4_pkt->ip_ff.ip_fhl * 4; #else ! aix_ip_hl = ip4_pkt->ip_hl * 4; #endif ip_proto = ip4_pkt->ip_p; ip_off = ntohs(ip4_pkt->ip_off); *************** *** 665,678 **** #if USE_IPv6 case 6: { ! ip_hl = sizeof(struct ip6_hdr); ip_proto = ip6_pkt->ip6_nxt; if (ip_proto == IPPROTO_FRAGMENT) { struct ip6_frag *ip6_fraghdr; ! ip6_fraghdr = (struct ip6_frag *)((unsigned char *)(ip6_pkt) + ip_hl); ! ip_hl += sizeof(struct ip6_frag); ip_proto = ip6_fraghdr->ip6f_nxt; fragmented = 1; --- 669,682 ---- #if USE_IPv6 case 6: { ! aix_ip_hl = sizeof(struct ip6_hdr); ip_proto = ip6_pkt->ip6_nxt; if (ip_proto == IPPROTO_FRAGMENT) { struct ip6_frag *ip6_fraghdr; ! ip6_fraghdr = (struct ip6_frag *)((unsigned char *)(ip6_pkt) + aix_ip_hl); ! aix_ip_hl += sizeof(struct ip6_frag); ip_proto = ip6_fraghdr->ip6f_nxt; fragmented = 1; *************** *** 693,703 **** switch (ip_proto) { case IPPROTO_TCP: { ! struct tcphdr *tcp_pkt = (struct tcphdr *)((unsigned char *)(ip4_pkt) + ip_hl); uint16_t tcphdr_offset = (frag_offset) ? 0 : (tcp_pkt->th_off * 4); data = (unsigned char *)(tcp_pkt) + tcphdr_offset; ! len -= link_offset + ip_hl + tcphdr_offset; #if USE_IPv6 if (ip_ver == 6) --- 697,707 ---- switch (ip_proto) { case IPPROTO_TCP: { ! struct tcphdr *tcp_pkt = (struct tcphdr *)((unsigned char *)(ip4_pkt) + aix_ip_hl); uint16_t tcphdr_offset = (frag_offset) ? 0 : (tcp_pkt->th_off * 4); data = (unsigned char *)(tcp_pkt) + tcphdr_offset; ! len -= link_offset + aix_ip_hl + tcphdr_offset; #if USE_IPv6 if (ip_ver == 6) *************** *** 713,723 **** } break; case IPPROTO_UDP: { ! struct udphdr *udp_pkt = (struct udphdr *)((unsigned char *)(ip4_pkt) + ip_hl); uint16_t udphdr_offset = (frag_offset) ? 0 : sizeof(*udp_pkt); data = (unsigned char *)(udp_pkt) + udphdr_offset; ! len -= link_offset + ip_hl + udphdr_offset; #if USE_IPv6 if (ip_ver == 6) --- 717,727 ---- } break; case IPPROTO_UDP: { ! struct udphdr *udp_pkt = (struct udphdr *)((unsigned char *)(ip4_pkt) + aix_ip_hl); uint16_t udphdr_offset = (frag_offset) ? 0 : sizeof(*udp_pkt); data = (unsigned char *)(udp_pkt) + udphdr_offset; ! len -= link_offset + aix_ip_hl + udphdr_offset; #if USE_IPv6 if (ip_ver == 6) *************** *** 737,747 **** } break; case IPPROTO_ICMP: { ! struct icmp *icmp4_pkt = (struct icmp *)((unsigned char *)(ip4_pkt) + ip_hl); uint16_t icmp4hdr_offset = (frag_offset) ? 0 : 4; data = (unsigned char *)(icmp4_pkt) + icmp4hdr_offset; ! len -= link_offset + ip_hl + icmp4hdr_offset; if ((int32_t)len < 0) len = 0; --- 741,751 ---- } break; case IPPROTO_ICMP: { ! struct icmp *icmp4_pkt = (struct icmp *)((unsigned char *)(ip4_pkt) + aix_ip_hl); uint16_t icmp4hdr_offset = (frag_offset) ? 0 : 4; data = (unsigned char *)(icmp4_pkt) + icmp4hdr_offset; ! len -= link_offset + aix_ip_hl + icmp4hdr_offset; if ((int32_t)len < 0) len = 0; *************** *** 753,763 **** #if USE_IPv6 case IPPROTO_ICMPV6: { ! struct icmp6_hdr *icmp6_pkt = (struct icmp6_hdr *)((unsigned char *)(ip6_pkt) + ip_hl); uint16_t icmp6hdr_offset = (frag_offset) ? 0 : 4; data = (unsigned char *)(icmp6_pkt) + icmp6hdr_offset; ! len -= link_offset + ip_hl + ntohs(ip6_pkt->ip6_plen) + icmp6hdr_offset; if ((int32_t)len < 0) len = 0; --- 757,767 ---- #if USE_IPv6 case IPPROTO_ICMPV6: { ! struct icmp6_hdr *icmp6_pkt = (struct icmp6_hdr *)((unsigned char *)(ip6_pkt) + aix_ip_hl); uint16_t icmp6hdr_offset = (frag_offset) ? 0 : 4; data = (unsigned char *)(icmp6_pkt) + icmp6hdr_offset; ! len -= link_offset + aix_ip_hl + ntohs(ip6_pkt->ip6_plen) + icmp6hdr_offset; if ((int32_t)len < 0) len = 0; *************** *** 769,779 **** #endif case IPPROTO_IGMP: { ! struct igmp *igmp_pkt = (struct igmp *)((unsigned char *)(ip4_pkt) + ip_hl); uint16_t igmphdr_offset = (frag_offset) ? 0 : 4; data = (unsigned char *)(igmp_pkt) + igmphdr_offset; ! len -= link_offset + ip_hl + igmphdr_offset; if ((int32_t)len < 0) len = 0; --- 773,783 ---- #endif case IPPROTO_IGMP: { ! struct igmp *igmp_pkt = (struct igmp *)((unsigned char *)(ip4_pkt) + aix_ip_hl); uint16_t igmphdr_offset = (frag_offset) ? 0 : 4; data = (unsigned char *)(igmp_pkt) + igmphdr_offset; ! len -= link_offset + aix_ip_hl + igmphdr_offset; if ((int32_t)len < 0) len = 0; *************** *** 784,791 **** } break; default: { ! data = (unsigned char *)(ip4_pkt) + ip_hl; ! len -= link_offset + ip_hl; if ((int32_t)len < 0) len = 0; --- 788,795 ---- } break; default: { ! data = (unsigned char *)(ip4_pkt) + aix_ip_hl; ! len -= link_offset + aix_ip_hl; if ((int32_t)len < 0) len = 0;