*** ./ngrep.c.ORIG Thu Sep 7 23:28:35 2017 --- ./ngrep.c Mon Jun 3 10:29:14 2019 *************** *** 41,52 **** --- 41,56 ---- #endif #if defined(AIX) + #if defined(_AIX51) && !defined(_AIX53) + #define STEVENS_API + #endif #include #include #include #include #include #include + #include #endif #if defined(_WIN32) *************** *** 729,735 **** uint32_t ip_ver; uint8_t ip_proto = 0; ! uint32_t ip_hl = 0; uint32_t ip_off = 0; uint8_t fragmented = 0; --- 733,739 ---- uint32_t ip_ver; uint8_t ip_proto = 0; ! uint32_t aix_ip_hl = 0; uint32_t ip_off = 0; uint8_t fragmented = 0; *************** *** 759,767 **** 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); --- 763,771 ---- 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); *************** *** 776,789 **** #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; --- 780,793 ---- #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; *************** *** 804,814 **** 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 ((int32_t)len < 0) len = 0; --- 808,818 ---- 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 ((int32_t)len < 0) len = 0; *************** *** 819,829 **** } 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 ((int32_t)len < 0) len = 0; --- 823,833 ---- } 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 ((int32_t)len < 0) len = 0; *************** *** 834,844 **** } 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; --- 838,848 ---- } 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; *************** *** 850,860 **** #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 + icmp6hdr_offset; if ((int32_t)len < 0) len = 0; --- 854,864 ---- #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 + icmp6hdr_offset; if ((int32_t)len < 0) len = 0; *************** *** 866,876 **** #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; --- 870,880 ---- #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; *************** *** 881,888 **** } break; default: { ! data = (unsigned char *)(ip4_pkt) + ip_hl; ! len -= link_offset + ip_hl; if ((int32_t)len < 0) len = 0; --- 885,892 ---- } break; default: { ! data = (unsigned char *)(ip4_pkt) + aix_ip_hl; ! len -= link_offset + aix_ip_hl; if ((int32_t)len < 0) len = 0; *** ./Makefile.in.ORIG Thu Sep 7 23:28:35 2017 --- ./Makefile.in Mon Jun 3 10:12:22 2019 *************** *** 21,27 **** bindir = $(prefix)/bin datadir = $(prefix)/share ! mandir = $(datadir)/man BINDIR_INSTALL = $(prefix)/bin MANDIR_INSTALL = $(mandir)/man8 --- 21,27 ---- bindir = $(prefix)/bin datadir = $(prefix)/share ! mandir = $(prefix)/man BINDIR_INSTALL = $(prefix)/bin MANDIR_INSTALL = $(mandir)/man8