ipgrab-0.9.10/0000755000175000001440000000000010644764222012262 5ustar farooqusersipgrab-0.9.10/ChangeLog0000644000175000001440000024577710644710546014062 0ustar farooqusers2007-07-10 13:37 farooq-i-azam * doc/ipgrab.texi (1.23): Modified info page 2007-07-10 13:33 farooq-i-azam * doc/ipgrab.8 (1.3): Modified man page 2007-07-10 13:31 farooq-i-azam * TODO (1.18): [no log message] 2007-07-10 13:30 farooq-i-azam * README (1.5): Modified README 2007-07-10 13:28 farooq-i-azam * DEVELOPER-HOWTO (1.2): Modified DEVELOPER-HOWTO 2007-07-08 14:09 farooq-i-azam * doc/ipgrab.texi (1.22): Updated info page. 2007-07-08 13:59 farooq-i-azam * ChangeLog (1.13): Updated ChangeLog 2007-07-08 13:16 farooq-i-azam * DEVELOPER-HOWTO (1.1): Adding a Developer How To for educationla purposes and to facilitate new developers. 2007-07-03 18:34 farooq-i-azam * doc/ipgrab.texi (1.21): Update info page. 2007-07-03 18:31 farooq-i-azam * doc/ipgrab.8 (1.2): Updated man page. 2007-07-03 18:24 farooq-i-azam * TODO (1.17): A bit updated TODO file. It needs further updation. 2007-07-03 18:16 farooq-i-azam * README (1.4): Updated README file. 2007-07-03 18:15 farooq-i-azam * INSTALL (1.3): Updated INSTALL file. 2007-07-02 12:35 farooq-i-azam * src/Makefile.in (1.51): Makefile.in generated by automake 1.9.6. 2007-07-02 11:09 farooq-i-azam * autom4te.cache/: traces.0 (1.2), traces.1 (1.1): [no log message] 2007-07-02 11:06 farooq-i-azam * autom4te.cache/: output.0 (1.2), output.1 (1.1), requests (1.2): [no log message] 2007-07-02 10:33 farooq-i-azam * doc/Makefile.in (1.9): Makefile.in generated by automake 1.9.6 2007-07-02 10:09 farooq-i-azam * doc/Makefile.am (1.3): Updated makefile.am to install man pages as well. 2007-07-02 10:03 farooq-i-azam * doc/ipgrab.8 (1.1): Copying man page to doc folder. 2007-07-02 09:52 farooq-i-azam * ipgrab.8 (1.2): The man page should be in the doc folder along with info page. Therefore, removed it from the root folder. 2007-06-26 08:36 farooq-i-azam * AUTHORS (1.7): [no log message] 2007-06-26 08:31 farooq-i-azam * Makefile.in (1.14): New Makefile.in generagted by GNU Automake version 1.9.6. 2007-06-26 07:53 farooq-i-azam * configure (1.29): New configure script generated by GNU Autoconf 2.61 for ipgrab 0.9.10. 2007-06-26 07:49 farooq-i-azam * aclocal.m4 (1.10): New aclocal.m4 generated by aclocal version 1.9.6 2007-06-26 07:44 farooq-i-azam * configure.ac (1.2): Version information is changed to 0.9.10 2007-06-25 13:09 farooq-i-azam * src/file.c (1.5): Fixed a bug so that filter strings now also work when reading packets from file. 2007-06-25 13:08 farooq-i-azam * src/l2tp.c (1.11): Fix of a very minor problem. 2007-06-25 13:06 farooq-i-azam * src/ripng.h (1.6): Fixed bug related to byte order. 2007-06-25 13:04 farooq-i-azam * src/rip.h (1.6): Fixed bugs related to byte order. 2007-06-25 13:03 farooq-i-azam * src/isakmp.c (1.11): Fix of a minor problem. 2007-06-25 13:00 farooq-i-azam * src/dhcp.h (1.8): Corrected header definition of dhcp in struct dhcp_header. 2007-06-25 12:57 farooq-i-azam * src/dhcp.c (1.22): Fixed minor problems and more options in the headr are being decoded now. 2007-06-25 12:53 farooq-i-azam * src/netbios_ns.c (1.9): Fixed a bug related to the displaying of flags. These are now being correctly displayed. 2007-06-25 12:47 farooq-i-azam * src/radius.c (1.5): Fixed some bugs w.r.t value returned by dump_radius_attribute() and length of values being displayed. 2007-06-25 12:38 farooq-i-azam * src/ah.h (1.5): Changed struct ah_header so that it now correctly conforms to little endian and big endian byte orders. 2007-06-25 12:25 farooq-i-azam * src/icmpv6.c (1.18): Fixed a minor bug. 2007-06-25 12:23 farooq-i-azam * src/icmp.c (1.18): Fixed bugs related to byte order and displayed fields under dump_icmp_mask(). 2007-06-25 12:20 farooq-i-azam * src/rsvp.c (1.4): Added some code so as something is displayed in the minimal mode as well. 2007-06-25 12:07 farooq-i-azam * src/rtcp.c (1.4): Fixed problems related to byte order. 2007-06-25 12:06 farooq-i-azam * src/ipx.c (1.14): Source and destination IPX addresses are now displayed correctly using 4 bytes. 2007-06-25 11:52 farooq-i-azam * src/ccp.c (1.2): Added some code to decode CCP_CODE_RESETREQ and CCP_CODE_RESETREP options. 2007-06-25 11:50 farooq-i-azam * src/ipcp.c (1.7): IPCP_OPTION_MOBILEIPV4 is also being parsed now. 2007-06-25 11:47 farooq-i-azam * src/lcp.c (1.11): LCP_CODE_PORTREJ and LCP_CODE_TIMEREMAINING are now being parsed. 2007-06-25 11:46 farooq-i-azam * src/ipv6.c (1.15): A small change with respect to use of hexadecimal instead of decimal numbers. 2007-06-25 11:42 farooq-i-azam * src/state.c (1.2): Fixed a minor problem related to port sizes. 2007-06-25 11:41 farooq-i-azam * src/arp.c (1.21): Fixed some minor problems. 2007-06-25 11:36 farooq-i-azam * src/llc.c (1.6): Fixed minor bugs related to byte order. 2007-06-25 10:47 farooq-i-azam * src/ipgrab.c (1.22): Fixed a fix so that filter strings also work when reading packets from file. Similary when ipgrab is now run without having proper permissions, it does not crash and displays an error message instead. 2007-06-25 10:44 farooq-i-azam * src/datalink.c (1.26): Made some minor changes so as timestamp is printed in human readable format. 2007-06-25 10:19 farooq-i-azam * src/dynports.c (1.8): fixed a minor problem 2007-06-25 10:17 farooq-i-azam * src/hexbuffer.c (1.6): cleaned variable int col which is not needed and made hexbuffer_flush() consistent with utilities.c:dump_hex_and_text() 2007-06-25 10:14 farooq-i-azam * src/utilities.c (1.13): cleaned some code in dump_hex_and_text() 2007-06-25 10:12 farooq-i-azam * src/display.c (1.34): Fixed display_minimal(), added DISP_BIN in display_minimal and fixed display_header_banner_ts() to correctly display timestamps in human readable format. 2007-06-25 10:07 farooq-i-azam * src/parse_cl.c (1.12): Fixed a minor problem with allocation and freeing of memory 2007-06-25 10:01 farooq-i-azam * src/error.c (1.4): Cleaned a line of code 2006-11-21 10:11 farooq-i-azam * Makefile.in (1.13), README (1.3), acconfig.h (1.5), acinclude.m4 (1.5), aclocal.m4 (1.9), config.guess (1.3), config.h.in (1.1), config.in (1.12), config.sub (1.3), configure (1.28), configure.ac (1.1), configure.in (1.29), depcomp (1.1), install-sh (1.2), missing (1.2), mkinstalldirs (1.2), autom4te.cache/output.0 (1.1), autom4te.cache/requests (1.1), autom4te.cache/traces.0 (1.1), doc/Makefile.in (1.8), tools/pmm/AUTHORS (1.2), tools/pmm/COPYING (1.2), tools/pmm/ChangeLog (1.3), tools/pmm/INSTALL (1.2), tools/pmm/Makefile.am (1.4), tools/pmm/Makefile.in (1.4), tools/pmm/NEWS (1.2), tools/pmm/README (1.2), tools/pmm/acconfig.h (1.2), tools/pmm/acinclude.m4 (1.2), tools/pmm/aclocal.m4 (1.3), tools/pmm/config.h (1.3), tools/pmm/config.in (1.3), tools/pmm/configure (1.4), tools/pmm/configure.in (1.4), tools/pmm/error.c (1.2), tools/pmm/error.h (1.2), tools/pmm/field.cc (1.3), tools/pmm/field.h (1.3), tools/pmm/global.h (1.2), tools/pmm/main.c (1.5), tools/pmm/main.cc (1.2), tools/pmm/protocol.cc (1.3), tools/pmm/protocol.h (1.3), tools/pmm/read_xml.c (1.3), tools/pmm/read_xml.h (1.3), tools/pmm/utilities.c (1.3), tools/pmm/utilities.h (1.3), tools/pmm/value.cc (1.3), tools/pmm/value.h (1.3), tools/pmm/xml.cc (1.2), tools/pmm/xml.h (1.2): Towards ipgrab-0.9.10 2006-11-21 10:02 farooq-i-azam * tools/pmm/protocols/mobileip.xml (1.3): Towards ipgrab-0.9.10 2006-11-21 08:59 farooq-i-azam * src/protocols.h (1.15): protocols.h not required at present. 2006-11-21 08:54 farooq-i-azam * src/test.c (1.2): Removing test.c which is a test file 2006-11-21 07:47 farooq-i-azam * src/: Makefile.am (1.49), Makefile.in (1.50), dhcp.c (1.21), dhcp.h (1.7), display.c (1.33), display.h (1.23), esp.c (1.7), ftpctrl.c (1.5), global.h (1.7), icmpv6.c (1.17), icmpv6.h (1.8), igmp.c (1.13), igmp.h (1.5), ip.c (1.27), ip_services.c (1.14), ip_services.h (1.12), ipgrab.c (1.21), ipx.h (1.6), mobileip.c (1.12), ns_labels.h (1.6), ppp.c (1.15), radius.h (1.3), radius_3gpp2.c (1.4), ripng.c (1.10), ripng.h (1.5), ssh.c (1.8), strmap.c (1.6), tcp.c (1.26), test.c (1.1), utilities.c (1.12), utilities.h (1.9): Test File 2002-08-01 13:31 mborella * src/ipgrab.c (1.20): Fixed segfault in cleanup_pcap(). 2002-08-01 13:27 mborella * Makefile.in (1.12), aclocal.m4 (1.8), config.in (1.11), configure (1.27), configure.in (1.28), doc/Makefile.in (1.7), src/Makefile.in (1.49), src/display.c (1.32), src/strmap.c (1.5): Added a few bug fixes resulting from valgrind runs. 2002-04-03 18:48 mborella * config.in (1.10), configure (1.26), configure.in (1.27), src/utilities.c (1.11), src/utilities.h (1.8): Added autoconf check for strlcpy and strlcat, fixed strlcpy and strlcat checks in code to be separate. 2002-04-03 18:43 mborella * src/: display.c (1.31), ftpctrl.c (1.4), ns_labels.h (1.5), utilities.c (1.10), utilities.h (1.7): Added strlcpy() and strlcat() local functions, replaced strncpy() calls. 2002-03-22 20:12 mborella * src/esp.c (1.6): Fixed bug in ESP sequence number displays. 2002-03-08 13:57 mborella * src/: bgp.c (1.5), ipx.h (1.5): More fixes to BGP. 2002-03-05 23:23 mborella * src/bgp.c (1.4): More fixes to BGP 2002-03-05 20:32 mborella * src/bgp.c (1.3): More updates to BGP 2002-03-01 23:17 mborella * src/bgp.c (1.2): Interim checkin of BGP 2002-03-01 14:36 mborella * src/: Makefile.am (1.48), Makefile.in (1.48), bgp.c (1.1), bgp.h (1.1), ip.c (1.26), ip_services.c (1.13), ip_services.h (1.11), tcp.c (1.25): Added atttrbiute support to IP and TCP, initial BGP support 2002-02-27 16:16 mborella * src/: dhcp.c (1.20), display.c (1.30), display.h (1.22): Used display_minimal_attribute() throughout most of DHCP. 2002-02-27 15:08 mborella * src/: dhcp.c (1.19), display.c (1.29): Added dump_hexbytes() usage in dhcp.c 2002-02-27 14:42 mborella * src/: icmpv6.c (1.16), ssh.c (1.7), utilities.c (1.9), utilities.h (1.6): Fixed a few more things with ICMPv6, added dump_hexbytes() to utilities. 2002-02-27 14:11 mborella * src/: display.c (1.28), display.h (1.21), icmpv6.c (1.15), ipgrab.c (1.19): Fixes to ICMPv6 so that options are handled properly. Added the name of the file being written to as part of output, fixed how IPv6 addresses are displayed. 2002-02-25 18:10 mborella * src/: dhcp.c (1.18), icmpv6.c (1.14), icmpv6.h (1.7), ripng.c (1.9), ripng.h (1.4): A number of fixes to ICMPv6, RIPv6 and one to DHCP 2002-02-25 16:18 mborella * src/dhcp.c (1.17): More fixes for DHCP 2002-02-25 16:07 mborella * src/: dhcp.c (1.16), dhcp.h (1.6): Fixed a number of display issues with DHCP. 2002-02-21 20:27 mborella * src/: igmp.c (1.12), igmp.h (1.4): Fixes to IGMP, addition of DVMRP support. 2002-02-19 18:13 mborella * src/: mobileip.c (1.11), radius.h (1.2), radius_3gpp2.c (1.3): Cleaned up Mobile IP extensions and 3GPP2 RADIUS attributes 2002-01-04 21:43 mborella * ChangeLog (1.12, release0-9-8): Updated Changelog 2002-01-04 17:24 mborella * doc/ipgrab.texi (1.20), src/datalink.c (1.25) (utags: release0-9-8): Fixed compilation error with libpcap 0.4 due to change in data structure. 2002-01-03 18:12 mborella * configure (1.25, release0-9-8), configure.in (1.26, release0-9-8), doc/ipgrab.texi (1.19), src/radius.c (1.4, release0-9-8): Documentation update. 2002-01-03 17:41 mborella * configure (1.24): Removed unnecessary libraries from linking. 2002-01-03 00:04 mborella * src/: ah.c (1.10, release0-9-8), datalink.c (1.24), dhcp.c (1.15, release0-9-8), display.c (1.27, release0-9-8), dns.c (1.21, release0-9-8), error.c (1.3, release0-9-8), file.c (1.4, release0-9-8), icmp.c (1.17, release0-9-8), icmpv6.c (1.13, release0-9-8), igmp.c (1.11, release0-9-8), ip.c (1.25, release0-9-8), ipv6.c (1.14, release0-9-8), ipx.c (1.13, release0-9-8), ipxrip.c (1.8, release0-9-8), netbios_ns.c (1.8, release0-9-8), ospf.c (1.14, release0-9-8), rip.c (1.14, release0-9-8), ripng.c (1.8, release0-9-8), slp.c (1.5, release0-9-8), tcp.c (1.24, release0-9-8): Changed all instances of sprintf() to snprintf() 2002-01-02 19:31 mborella * src/file.c (1.3): Changes to properly detect PCAP files on big endian machines. 2002-01-02 18:16 mborella * ChangeLog (1.11), config.in (1.9, release0-9-8), configure.in (1.25), doc/ipgrab.texi (1.18), src/dynports.c (1.7, release0-9-8), src/utilities.c (1.8, release0-9-8): Changes to cleanly compile on FreeBSD 4.3 2001-12-07 23:11 mborella * src/file.c (1.2): Added second libpcap signature so that we can support newer libpcap trace files. 2001-11-29 00:20 mborella * src/radius_3gpp2.c (1.2, release0-9-8): More changes to 3GPP2 RADIUS. 2001-11-21 22:03 mborella * src/: Makefile.am (1.47, release0-9-8), Makefile.in (1.47, release0-9-8), radius.c (1.3), radius_3gpp2.c (1.1), radius_3gpp2.h (1.1, release0-9-8): Broke out 3GPP2 RADIUS section into separate file, added more parameters 2001-11-21 18:04 mborella * src/: Makefile.am (1.46), Makefile.in (1.46), iana.c (1.1, release0-9-8), iana.h (1.1, release0-9-8), radius.c (1.2), utilities.c (1.7): Added support for IANA vendor types, enhanced RADIUS decoding. 2001-11-16 00:10 mborella * src/: Makefile.am (1.45), Makefile.in (1.45), ip_services.c (1.12, release0-9-8), ip_services.h (1.10, release0-9-8), radius.c (1.1), radius.h (1.1, release0-9-8): Added basic RADIUS support. 2001-11-15 20:15 mborella * src/: ftpctrl.c (1.3), local.h (1.6) (utags: release0-9-8): Fixed reply code determination in FTP control packets. 2001-11-15 19:28 mborella * src/ipgrab.c (1.18, release0-9-8): Fixed support for the -v option. It prints the version number then terminates the program now. 2001-11-15 00:22 mborella * src/: Makefile.am (1.44), Makefile.in (1.44), datalink.c (1.23), display.c (1.26), gre.c (1.12, release0-9-8), ip.c (1.24), ip_services.c (1.11), ip_services.h (1.9), nntp.c (1.1, release0-9-8), nntp.h (1.1, release0-9-8), payload.c (1.9, release0-9-8), ppp.c (1.14, release0-9-8), udp.c (1.19, release0-9-8), utilities.c (1.6), utilities.h (1.5, release0-9-8): Added NNTP support, fixed a couple of minimal mode errors with respect to payload displaying and lumping packets together. 2001-11-02 23:59 mborella * src/rtcp.c (1.3, release0-9-8): Major fixes to RTCP 2001-11-02 19:45 mborella * ChangeLog (1.10), config.guess (1.2, release0-9-8), config.sub (1.2, release0-9-8), configure (1.23), configure.in (1.24), ipgrab.gp (1.9, release0-9-8), doc/ipgrab.texi (1.17): Updated config.guess and config.sub 2001-11-02 00:23 mborella * src/: Makefile.am (1.43), Makefile.in (1.43), datalink.c (1.22), datalink.h (1.3, release0-9-8), ethertypes.c (1.6, release0-9-8), file.c (1.1), file.h (1.1, release0-9-8), gre.c (1.11), ip_protocols.c (1.18, release0-9-8), ipgrab.c (1.17), ppp.c (1.13), ppp.h (1.8, release0-9-8): Added support for reading Sun Snoop file format. In the process, completely re-architected the read-from-file process to make it more generic. 2001-10-19 15:24 mborella * src/: arp.c (1.20, release0-9-8), dhcp.c (1.14), display.c (1.25): Fixed several files to compile with gcc-3.0 2001-10-12 21:45 mborella * src/: l2tp.c (1.10, release0-9-8), tcp.c (1.23), udp.c (1.18): Fixed L2TP lock up and ordering of port numbers. 2001-10-11 23:02 mborella * src/rtcp.c (1.2): Added some more RTCP functionality. 2001-10-11 22:03 mborella * src/: Makefile.am (1.42), Makefile.in (1.42), dynports.c (1.6), ip_services.h (1.8), rtcp.c (1.1), rtcp.h (1.1, release0-9-8): Added basic RTCP support. 2001-10-11 20:43 mborella * src/: dynports.c (1.5), dynports.h (1.3, release0-9-8), ipv6.c (1.13), ipv6.h (1.9, release0-9-8), ospf.c (1.13), rtp.c (1.7, release0-9-8), rtp.h (1.5, release0-9-8): Fixed RTP support. 2001-10-09 23:20 mborella * src/: Makefile.am (1.41), Makefile.in (1.41), datalink.c (1.21), display.c (1.24), display.h (1.20, release0-9-8), dynports.c (1.4), dynports.h (1.2), ftpctrl.c (1.2), ip.c (1.23), ip_services.c (1.10), ip_services.h (1.7), local.h (1.5), packet_manip.c (1.16, release0-9-8), packet_manip.h (1.11, release0-9-8), state.c (1.1, release0-9-8), state.h (1.1, release0-9-8), tcp.c (1.22), tftp.c (1.1, release0-9-8), tftp.h (1.1, release0-9-8), udp.c (1.17): Added support for TFTP, in the process enhanced the dynamic port mapping functionality. 2001-10-07 19:17 mborella * src/: Makefile.am (1.40), Makefile.in (1.40), dynports.c (1.3), ftpctrl.c (1.1), ftpctrl.h (1.1, release0-9-8), ip_services.c (1.9), ip_services.h (1.6), packet_manip.h (1.10), parse_cl.c (1.11, release0-9-8), parse_cl.h (1.11, release0-9-8), ppp.h (1.7) (utags: v0-9-6): Added support for FTP control sessions. 2001-10-02 22:29 mborella * src/: mppc.c (1.1), mppc.h (1.1) (utags: release0-9-8, v0-9-6): Added MPPC module. 2001-10-02 22:28 mborella * src/: Makefile.am (1.39), Makefile.in (1.39), ppp.c (1.12, v0-9-6): [no log message] 2001-10-02 21:36 mborella * src/: Makefile.am (1.38), Makefile.in (1.38), ccp.c (1.1, release0-9-8, v0-9-6), ccp.h (1.1, release0-9-8, v0-9-6), parse_cl.c (1.10), parse_cl.h (1.10), ppp.c (1.11), ppp.h (1.6): Added CCP module. 2001-10-02 20:31 mborella * ChangeLog (1.9), Makefile.in (1.11, release0-9-8), aclocal.m4 (1.7, release0-9-8), config.in (1.8), configure (1.22), configure.in (1.23), doc/Makefile.in (1.6, release0-9-8), doc/ipgrab.texi (1.16) (utags: v0-9-6): [no log message] 2001-10-02 18:37 mborella * src/: Makefile.am (1.37), Makefile.in (1.37), cbcp.c (1.1, release0-9-8, v0-9-6), cbcp.h (1.1, release0-9-8, v0-9-6), chap.c (1.8, release0-9-8, v0-9-6), lcp.c (1.10, release0-9-8, v0-9-6), ppp.c (1.10), ppp.h (1.5), pptp.c (1.12, release0-9-8, v0-9-6): Added cbcp.h and cbcp.c for the Callback Control Protocol 2001-09-10 15:47 mborella * src/ipgrab.c (1.16, v0-9-6): Fixed an unnecessary memory allocation. 2001-09-07 22:50 mborella * ipgrab.gp (1.8), src/packet_manip.c (1.15), src/padding.c (1.2, release0-9-8), src/payload.c (1.8), src/utilities.c (1.5), src/utilities.h (1.4) (utags: v0-9-6): Generalized the get_packet_bytes() functions and the displaying of padding and payload. 2001-09-07 22:17 mborella * src/: padding.c (1.1), padding.h (1.1, release0-9-8, v0-9-6): Module for displaying padding. 2001-09-07 22:16 mborella * src/datalink.c (1.20, v0-9-6): Disabled payloads and padding display in minimal mode 2001-09-07 20:59 mborella * src/: Makefile.am (1.36), Makefile.in (1.36), arp.c (1.19, v0-9-6), datalink.c (1.19), dhcp.c (1.13, v0-9-6), icmp.c (1.16, v0-9-6), icmpv6.c (1.12, v0-9-6), ip.c (1.22, v0-9-6), mobileip.c (1.10, release0-9-8, v0-9-6), ospf.c (1.12, v0-9-6), packet_manip.c (1.14), packet_manip.h (1.9), parse_cl.c (1.9), parse_cl.h (1.9), payload.c (1.7), snmp.c (1.10, release0-9-8, v0-9-6), ssh.c (1.6, release0-9-8, v0-9-6), tcp.c (1.21, v0-9-6): Developed a more generic way of handling padding in packets, by adding an "apparent end" to packets. The apparent end is where a protocol says that a packet ends, but the real end is where the capture library says that the packet ends. The difference between the two is the padding 2001-09-07 19:27 mborella * src/: datalink.c (1.18), stats.c (1.2, release0-9-8, v0-9-6), stats.h (1.2, release0-9-8, v0-9-6): Fixed problem with stats counting headers encapsulated in ICMP. 2001-09-04 22:34 mborella * tools/pmm/: main.cc (1.1), xml.cc (1.1), xml.h (1.1) (utags: release0-9-8, v0-9-6): Initial check in 2001-09-04 22:33 mborella * tools/pmm/: Makefile.am (1.3), Makefile.in (1.3), aclocal.m4 (1.2), configure (1.3), configure.in (1.3), field.cc (1.2), field.h (1.2), protocol.cc (1.2), protocol.h (1.2), value.cc (1.2), value.h (1.2), protocols/mobileip.xml (1.2) (utags: release0-9-8, v0-9-6): Checkpoint checkin of modified pmm code 2001-07-24 22:13 mborella * tools/pmm/: data.c (1.5), data.h (1.5): Removed C data routines. 2001-07-24 22:11 mborella * tools/pmm/: data.c (1.4), data.h (1.4), field.cc (1.1), field.h (1.1), main.c (1.4, release0-9-8, v0-9-6), protocol.cc (1.1), protocol.h (1.1), utilities.c (1.2, release0-9-8, v0-9-6), utilities.h (1.2, release0-9-8, v0-9-6), value.cc (1.1), value.h (1.1): Initial checkin of C++ code. 2001-06-20 22:48 mborella * tools/pmm/: data.c (1.3), data.h (1.3), main.c (1.3): Added traverse and reading functions to the data module. 2001-06-20 20:07 mborella * tools/pmm/: ChangeLog (1.2, release0-9-8, v0-9-6), Makefile.am (1.2), Makefile.in (1.2), config.h (1.2, release0-9-8, v0-9-6), config.in (1.2, release0-9-8, v0-9-6), configure (1.2), configure.in (1.2), data.c (1.2), data.h (1.2), error.c (1.1, release0-9-8, v0-9-6), error.h (1.1, release0-9-8, v0-9-6), main.c (1.2), read_xml.c (1.2, release0-9-8, v0-9-6), read_xml.h (1.2, release0-9-8, v0-9-6), utilities.c (1.1), utilities.h (1.1): Added error and utility modules. Made the data module more "object oriented" 2001-06-20 17:31 mborella * tools/pmm/protocols/mobileip.xml (1.1): Added mobile XML schema. 2001-06-15 18:52 mborella * tools/pmm/: AUTHORS (1.1, release0-9-8, v0-9-6), COPYING (1.1, release0-9-8, v0-9-6), ChangeLog (1.1), INSTALL (1.1, release0-9-8, v0-9-6), Makefile.am (1.1), Makefile.in (1.1), NEWS (1.1, release0-9-8, v0-9-6), README (1.1, release0-9-8, v0-9-6), acconfig.h (1.1, release0-9-8, v0-9-6), acinclude.m4 (1.1, release0-9-8, v0-9-6), aclocal.m4 (1.1), config.h (1.1), config.in (1.1), configure (1.1), configure.in (1.1), data.c (1.1), data.h (1.1), global.h (1.1, release0-9-8, v0-9-6), main.c (1.1), read_xml.c (1.1), read_xml.h (1.1): Initial check-in of the bulk of the PMM code. 2001-05-28 20:39 mborella * ChangeLog (1.8), configure (1.21), configure.in (1.22), ipgrab.gp (1.7), doc/ipgrab.texi (1.15): Final commit for 0.9.4 2001-05-28 20:09 mborella * src/: Makefile.am (1.35), Makefile.in (1.35), payload.c (1.6): Marked the payload module as an application protocol so that it doesn't print junk when -a is used. 2001-05-28 19:51 mborella * src/: ip.c (1.21), layers.c (1.3, release0-9-8, v0-9-6), packet_manip.c (1.13), packet_manip.h (1.8), parse_cl.c (1.8), parse_cl.h (1.8): Added -a option for suppressing the display of app layer data. IP module now sets the end of the packet to be the end as given by the length of the IP packet. This helps with tinygrams. 2001-05-28 19:24 mborella * src/: Makefile.am (1.34), Makefile.in (1.34), ah.c (1.9, v0-9-6), arp.c (1.18), chap.c (1.7), dhcp.c (1.12), display.c (1.23, v0-9-6), display.h (1.19, v0-9-6), dns.c (1.20, v0-9-6), esp.c (1.5, release0-9-8, v0-9-6), ethernet.c (1.18, release0-9-8, v0-9-6), gre.c (1.10, v0-9-6), hexbuffer.c (1.5, release0-9-8, v0-9-6), http.c (1.6, release0-9-8, v0-9-6), icmp.c (1.15), icmpv6.c (1.11), igmp.c (1.10, v0-9-6), ip.c (1.20), ipcp.c (1.6, release0-9-8, v0-9-6), ipgrab.c (1.15), ipv6.c (1.12, v0-9-6), ipx.c (1.12, v0-9-6), ipxrip.c (1.7, v0-9-6), isakmp.c (1.10, release0-9-8, v0-9-6), l2tp.c (1.9, v0-9-6), layers.c (1.2), layers.h (1.2, release0-9-8, v0-9-6), lcp.c (1.9), llc.c (1.5, release0-9-8, v0-9-6), local.h (1.4, v0-9-6), loopback.c (1.5, release0-9-8, v0-9-6), mobileip.c (1.9), netbios_ns.c (1.7, v0-9-6), ospf.c (1.11), packet_manip.c (1.12), ppp.c (1.9), pppoe.c (1.5, release0-9-8, v0-9-6), pptp.c (1.11), raw.c (1.5, release0-9-8, v0-9-6), rip.c (1.13, v0-9-6), ripng.c (1.7, v0-9-6), rsvp.c (1.3, release0-9-8, v0-9-6), rtp.c (1.6, v0-9-6), sdp.c (1.8, release0-9-8, v0-9-6), sip.c (1.9, release0-9-8, v0-9-6), slip.c (1.5, release0-9-8, v0-9-6), slp.c (1.4, v0-9-6), snmp.c (1.9), spx.c (1.6, release0-9-8, v0-9-6), ssh.c (1.5), tcp.c (1.20), udp.c (1.16, v0-9-6): Implemented a number of changes: 1) The big one: Made determination of protocol layer transparent to the user of the displaying API. As long at each protocol module tells the (new) layering module which layer it is, the display functions will figure out whether or not to print something. 2) Modified TCP's header length display to include # of bytes 3) Fixed HTTP displaying to wrap headers and to use the hexbuffer properly. 4) Fixed hexbuffer to work properly when lines are being read. 2001-05-28 16:56 mborella * src/: layers.c (1.1), layers.h (1.1): Added layer tracking module. 2001-05-28 16:47 mborella * src/template.c (1.2, release0-9-8, v0-9-6): Updated template.c to reflect newer practices. 2001-05-18 22:07 mborella * doc/ipgrab.texi (1.14): Documentation update. 2001-05-18 22:04 mborella * TODO (1.16, release0-9-8, v0-9-6), configure (1.20), configure.in (1.21), doc/ipgrab.texi (1.13): Final commit for 0.9.3 2001-05-18 21:54 mborella * src/: arp.c (1.17), display.c (1.22), sdp.c (1.7), sdp.h (1.4, release0-9-8, v0-9-6), sip.c (1.8): Fixed displaying issues with SIP in minimal mode, as well as SIP interaction with SDP. SDP now requires a length. 2001-05-18 18:04 mborella * src/arp.c (1.16): Fixed display of excess padding packets with media lengths that are too long. 2001-05-18 15:30 mborella * src/: display.c (1.21), display.h (1.18), hexbuffer.c (1.4), packet_manip.c (1.11), sdp.c (1.6), sip.c (1.7), tcp.c (1.19): Fixed a number of issues: get_packet_line() was not returning positive values, TCP options were being shown in -t mode, added multiline string support, added hexbuffer support to SIP and SDP. 2001-05-17 17:58 mborella * src/arp.c (1.15): Fixed seg fault in arp.c cause by larger than expected padding. 2001-05-16 19:33 mborella * ChangeLog (1.7), doc/ipgrab.texi (1.12): Final checkin for 0.9.2. Documentation update. 2001-05-16 17:53 mborella * src/rtp.c (1.5): Modified RTP to work with APIs. 2001-04-27 02:51 mborella * acinclude.m4 (1.4, release0-9-8, v0-9-6), aclocal.m4 (1.6), configure (1.19), configure.in (1.20): Fixed configurator so that warnings appear when headers are not found 2001-04-26 23:49 mborella * ChangeLog (1.6), configure (1.18), configure.in (1.19), ipgrab.gp (1.6), doc/ipgrab.texi (1.11), src/dynports.c (1.2), src/gre.c (1.9), src/mobileip.c (1.8), src/payload.c (1.5), src/rtp.c (1.4): Added some minimal support to Mobile IP, fixed payload implementation to use API, added support for most protocols to dynports.c 2001-04-02 23:18 mborella * src/: Makefile.am (1.33), Makefile.in (1.33), dynports.c (1.1), dynports.h (1.1, v0-9-6), ip_services.c (1.8), ipgrab.c (1.14), mobileip.c (1.7), parse_cl.c (1.7), parse_cl.h (1.7), rtp.c (1.3), rtp.h (1.4, v0-9-6): Added dynamic port mapping, added mobile IP registration update and registration acknowledgement. 2001-04-02 18:06 mborella * src/Makefile.in (1.32): Fixed Makefile bad edit from last checkin 2001-04-02 18:04 mborella * src/: Makefile.in (1.31), datalink.c (1.17): Added packet numbering (counting) to minimal mode 2001-04-02 17:41 mborella * src/: stats.c (1.1), stats.h (1.1): Added packet stats module for packet counting 2001-04-02 17:41 mborella * src/: Makefile.am (1.32), Makefile.in (1.30), ah.c (1.8), arp.c (1.14), datalink.c (1.16), esp.c (1.4), gre.c (1.8), icmp.c (1.14), icmpv6.c (1.10), igmp.c (1.9), ip.c (1.19), ipgrab.c (1.13), ipv6.c (1.11), ipx.c (1.11), local.h (1.3), ospf.c (1.10), rsvp.c (1.2), tcp.c (1.18), udp.c (1.15): Added packet counting feature that displays counts of different packet types 2001-03-30 22:49 mborella * ChangeLog (1.5), ipgrab.gp (1.5), doc/ipgrab.texi (1.10): General update. 2001-03-30 15:36 mborella * src/: datalink.c (1.15), ipgrab.c (1.12), parse_cl.c (1.6), parse_cl.h (1.6): Added -w option for writing to packets to a file. 2001-03-30 14:06 mborella * src/mobileip.c (1.6): Added Mobile IP mobile/home authentication option. 2001-03-28 19:50 mborella * src/mobileip.c (1.5): Added critical vendor sepcific extension to mobile ip. 2001-03-28 18:34 mborella * src/: ethertypes.c (1.5, v0-9-6), ethertypes.h (1.5, release0-9-8, v0-9-6), mobileip.c (1.4): Added mobile ip session specific extension. 2001-03-28 00:43 mborella * src/: ethertypes.c (1.4), ethertypes.h (1.4), gre.c (1.7), gre.h (1.3, release0-9-8, v0-9-6): Finally fixed GRE issues so that old and new versions seem to work ok. 2001-03-27 20:45 mborella * AUTHORS (1.6, release0-9-8, v0-9-6), ChangeLog (1.4), ipgrab.gp (1.4), doc/ipgrab.texi (1.9), src/ah.c (1.7), src/datalink.c (1.14), src/gre.c (1.6), src/icmpv6.c (1.9), src/ip_services.c (1.7), src/ip_services.h (1.5), src/ipv6.c (1.10), src/isakmp.c (1.9), src/mobileip.c (1.3), src/ospf.c (1.9), src/payload.c (1.4), src/pppoe.c (1.4), src/rip.c (1.12), src/ripng.c (1.6), src/snmp.c (1.8), src/spx.c (1.5), src/tcp.c (1.17), src/udp.c (1.14): Added CDMA2000 A11 support (incomplete). Fix problems with separators. 2001-03-26 20:55 mborella * src/: Makefile.am (1.31), Makefile.in (1.29), ip_protocols.c (1.17, v0-9-6), ip_protocols.h (1.11, release0-9-8, v0-9-6), rsvp.c (1.1), rsvp.h (1.1, release0-9-8, v0-9-6): Added RSVP module which decodes the RSVP common header. 2001-03-26 17:00 mborella * src/: open_pcap.c (1.4, release0-9-8, v0-9-6), parse_cl.c (1.5), parse_cl.h (1.5): Added -r option. Allows packets to be read from file given on command line rather than an interface. The file is in the raw form, such as from tcpdump -w. 2001-01-20 00:49 mborella * src/mobileip.c (1.2): Updates to Mobile IP 2001-01-20 00:30 mborella * src/: Makefile.am (1.30), Makefile.in (1.28), dns.c (1.19), gre.c (1.5), gre.h (1.2), icmp.c (1.13), icmp.h (1.6, release0-9-8, v0-9-6), ip_services.c (1.6), ip_services.h (1.4), mobileip.c (1.1), mobileip.h (1.1, release0-9-8, v0-9-6): Fixes to GRE v0, added basic mobile IP support. 2001-01-17 01:22 mborella * src/ip.c (1.18): Fixed the displaying of IP frags in both verbose and minimal modes. 2001-01-17 00:29 mborella * src/arp.c (1.13): Fixed ARP to display padding on Ethernet runts. 2001-01-05 19:12 mborella * src/: chap.c (1.6), ipcp.c (1.5), lcp.c (1.8): More detailed option output in minimal mode for LCP, CHAP, and IPCP. 2000-11-07 19:47 mborella * configure (1.17), configure.in (1.18), doc/ipgrab.texi (1.8): CHanged version to 0.9. 2000-11-07 19:46 mborella * src/: Makefile.in (1.27), chap.c (1.5), ipcp.c (1.4), ipgrab.c (1.11), isakmp.c (1.8), l2tp.c (1.8), lcp.c (1.7), ssh.c (1.4): Fixed a few potential memory leaks. 2000-10-30 23:46 mborella * ChangeLog (1.3), doc/ipgrab.texi (1.7): Documentation update. 2000-10-30 22:06 mborella * src/: Makefile.am (1.29), Makefile.in (1.26), getopt.c (1.4, release0-9-8, v0-9-6), getopt.h (1.4, release0-9-8, v0-9-6), getopt_internal.c (1.3), parse_cl.c (1.4), parse_cl.h (1.4): Fixed command line parsing routines and made make dist work. 2000-10-17 20:45 mborella * src/isakmp.c (1.7): Added ISAKMP transform types and parsing. 2000-10-17 16:35 mborella * src/: chap.c (1.4), datalink.c (1.13), display.c (1.20), error.h (1.3, release0-9-8, v0-9-6), ipcp.c (1.3), ipgrab.c (1.10), isakmp.c (1.6), l2tp.c (1.7), lcp.c (1.6), ssh.c (1.3), utilities.c (1.4), utilities.h (1.3): Added my_malloc() and my_free() routines to utilities.c for safer memory management. Changed all modules that dynamically allocate memory to use these routines. 2000-10-12 19:27 mborella * src/: isakmp.c (1.5), isakmp.h (1.5, release0-9-8, v0-9-6): Added a few basic payloads to ISAKMP. 2000-10-12 18:16 mborella * src/: getopt.c (1.3), getopt.h (1.3): Fixed warning on freebsd build of getopt.h and getopt.c 2000-10-12 17:03 mborella * AUTHORS (1.5), Makefile.in (1.10), config.in (1.7), configure (1.16), configure.in (1.17), ipgrab.gp (1.3), doc/Makefile.in (1.5), src/Makefile.in (1.25), src/datalink.c (1.12), src/ethernet.c (1.17), src/getopt.c (1.2), src/getopt.h (1.2), src/getopt_internal.c (1.2), src/loopback.c (1.4), src/parse_cl.c (1.3), src/parse_cl.h (1.3), src/raw.c (1.4), src/slip.c (1.4), src/tcp.c (1.16): Updated getopt.h from the C library and added conditional compilation clauses so that the non-library getopt() functions that we include only compile if getopt_long() is not detected. 2000-10-12 16:20 mborella * src/pppoe.c (1.3): Yes more minor changes to PPPOE - added hexbuffer support. 2000-10-12 16:14 mborella * src/pppoe.c (1.2): Minor modifications to PPPOE 2000-10-12 16:05 mborella * src/: Makefile.am (1.28), Makefile.in (1.24), datalink.c (1.11), display.c (1.19), display.h (1.17), ethertypes.c (1.3), ethertypes.h (1.3), pppoe.c (1.1), pppoe.h (1.1, release0-9-8, v0-9-6), ssh.c (1.2): Added PPPOE module. 2000-10-11 19:31 mborella * src/: Makefile.am (1.27), Makefile.in (1.23), ip_services.c (1.5), ip_services.h (1.3), ssh.c (1.1), ssh.h (1.1, release0-9-8, v0-9-6), utilities.c (1.3): Added SSH module, which doesn't do much right now due to SSH's statefullness. I may be able to figure more out later. 2000-10-10 20:33 mborella * src/l2tp.c (1.6): Finished L2TP module (for now) 2000-10-09 20:58 mborella * src/l2tp.c (1.5): More features added to L2TP parser. 2000-10-09 19:30 mborella * configure (1.15), configure.in (1.16), src/ip_services.c (1.4), src/l2tp.c (1.4), src/l2tp.h (1.4, release0-9-8, v0-9-6): Significant upgrade to l2tp. 2000-10-02 22:37 mborella * src/: arp.c (1.12), icmp.c (1.12), igmp.c (1.8): Added more separators. 2000-10-02 22:33 mborella * src/: chap.c (1.3), ethernet.c (1.16), ip.c (1.17), ipcp.c (1.2), ipx.c (1.10), lcp.c (1.5), llc.c (1.4), netbios_ns.c (1.6), ppp.c (1.8), pptp.c (1.10), slp.c (1.3), tcp.c (1.15), udp.c (1.13): Added a separator "|" to most of the protocols' minimal modes. 2000-09-29 00:27 mborella * src/: ip_services.c (1.3), ip_services.h (1.2), isakmp.c (1.4), isakmp.h (1.4): Started working on basic ISAKMP support. Base header is now decoded. 2000-09-28 00:45 mborella * src/: Makefile.am (1.26), Makefile.in (1.22), ipcp.c (1.1), ipcp.h (1.1, release0-9-8, v0-9-6), ppp.c (1.7), ppp.h (1.4): Added initial IPCP support. Fixed bug in interpretation of compressed PPP. 2000-09-27 23:16 mborella * src/: display.c (1.18), display.h (1.16), gre.c (1.4), lcp.c (1.4), pptp.c (1.9), pptp.h (1.5, release0-9-8, v0-9-6): Added a new display method for multiline hex output. Minor fixes to LCP and added three new methods to PPTP. 2000-09-27 19:27 mborella * TODO (1.15), configure (1.14), configure.in (1.15), doc/ipgrab.texi (1.6), src/ah.c (1.6, release-0_9-pre7), src/arp.c (1.11, release-0_9-pre7), src/datalink.c (1.10, release-0_9-pre7), src/dhcp.c (1.11, release-0_9-pre7), src/display.c (1.17, release-0_9-pre7), src/display.h (1.15, release-0_9-pre7), src/dns.c (1.18, release-0_9-pre7), src/ethernet.c (1.15, release-0_9-pre7), src/http.c (1.5, release-0_9-pre7), src/icmp.c (1.11, release-0_9-pre7), src/icmpv6.c (1.8, release-0_9-pre7), src/igmp.c (1.7, release-0_9-pre7), src/ipgrab.c (1.9, release-0_9-pre7), src/ipv6.c (1.9, release-0_9-pre7), src/ipx.c (1.9, release-0_9-pre7), src/ipxrip.c (1.6, release-0_9-pre7), src/loopback.c (1.3, release-0_9-pre7), src/ospf.c (1.8, release-0_9-pre7), src/packet_manip.h (1.7, release-0_9-pre7), src/raw.c (1.3, release-0_9-pre7), src/rip.c (1.11, release-0_9-pre7), src/ripng.c (1.5, release-0_9-pre7), src/slip.c (1.3, release-0_9-pre7), src/spx.c (1.4, release-0_9-pre7), src/utilities.c (1.2, release-0_9-pre7), src/utilities.h (1.2, release-0_9-pre7): Well, well, lots of changes and new protocols supported. Changed string displaying routines so that they make sure a string is actually printable before they display it. Got rid of old way of displaying integers: DISP_2DEC, etc. 2000-09-05 21:31 mborella * TODO (1.14): Latest misc updates 2000-09-01 22:31 mborella * src/datalink.c (1.9): Added PPP knowledge to datalink shim. 2000-09-01 22:28 mborella * src/ppp.c (1.6, release-0_9-pre7): Added CCP knowledge to PPP. 2000-09-01 22:23 mborella * src/: chap.c (1.2, release-0_9-pre7), ppp.c (1.5), ppp.h (1.3, release-0_9-pre7): CHAP is now complete (or so I hope) 2000-09-01 21:31 mborella * src/: Makefile.am (1.25, release-0_9-pre7), Makefile.in (1.21, release-0_9-pre7), chap.c (1.1), chap.h (1.1, release0-9-8, v0-9-6, release-0_9-pre7), ipgrab.c (1.8), lcp.c (1.3, release-0_9-pre7), local.h (1.2, release-0_9-pre7), ppp.c (1.4), utilities.c (1.1), utilities.h (1.1): New modules for CHAP decoding and utilities are now borken out in their own module. Lots of additions to LCP support. 2000-08-31 22:56 mborella * src/: lcp.c (1.2), ppp.c (1.3), pptp.c (1.8, release-0_9-pre7): Further progress on LCP. Options initially supported. 2000-08-31 21:54 mborella * src/: Makefile.am (1.24), Makefile.in (1.20), lcp.c (1.1), lcp.h (1.1, release0-9-8, v0-9-6, release-0_9-pre7), ppp.c (1.2), ppp.h (1.2): Added initial LCP support 2000-08-31 21:13 mborella * src/: Makefile.am (1.23), Makefile.in (1.19), ethertypes.c (1.2, release-0_9-pre7), ethertypes.h (1.2, release-0_9-pre7), gre.c (1.3, release-0_9-pre7), ppp.c (1.1), ppp.h (1.1): Implemented initial PPP support. 2000-08-31 20:29 mborella * src/: ethertypes.c (1.1), ethertypes.h (1.1): New ethertypes module 2000-08-31 20:28 mborella * src/: Makefile.am (1.22), Makefile.in (1.18), arp.c (1.10), display.c (1.16), display.h (1.14), ethernet.c (1.14), ethernet.h (1.5, release0-9-8, v0-9-6, release-0_9-pre7), gre.c (1.2): Added new module for calculating ether types, finished GREv1 support. Added new display method, display_strmap_hex(). 2000-08-31 17:52 mborella * src/: Makefile.am (1.21), Makefile.in (1.17), gre.c (1.1), gre.h (1.1, release-0_9-pre7), ip_protocols.c (1.16, release-0_9-pre7), ip_protocols.h (1.10, release-0_9-pre7), pptp.c (1.7): Added the beginnings of GRE support. 2000-08-30 22:35 mborella * src/: pptp.c (1.6), pptp.h (1.4, release-0_9-pre7): Added more PPTP support. 2000-08-30 20:23 mborella * TODO (1.13), src/ah.c (1.5), src/ah.h (1.4, release0-9-8, v0-9-6, release-0_9-pre7), src/arp.c (1.9), src/arp.h (1.3, release0-9-8, v0-9-6, release-0_9-pre7), src/dhcp.c (1.10), src/dhcp.h (1.5, release0-9-8, v0-9-6, release-0_9-pre7), src/display.c (1.15), src/display.h (1.13), src/dns.c (1.17), src/dns.h (1.9, release0-9-8, v0-9-6, release-0_9-pre7), src/ethernet.h (1.4), src/global.h (1.6, release0-9-8, v0-9-6, release-0_9-pre7), src/hexbuffer.h (1.3, release0-9-8, v0-9-6, release-0_9-pre7), src/http.c (1.4), src/http.h (1.3, release0-9-8, v0-9-6, release-0_9-pre7), src/icmp.c (1.10), src/icmp.h (1.5, release-0_9-pre7), src/icmpv6.c (1.7), src/icmpv6.h (1.6, release0-9-8, v0-9-6, release-0_9-pre7), src/igmp.c (1.6), src/igmp.h (1.3, release0-9-8, v0-9-6, release-0_9-pre7), src/ip.c (1.16, release-0_9-pre7), src/ip.h (1.7, release0-9-8, v0-9-6, release-0_9-pre7), src/ipgsnmp.h (1.2, release0-9-8, v0-9-6, release-0_9-pre7), src/ipv6.c (1.8), src/ipv6.h (1.8, v0-9-6, release-0_9-pre7), src/ipx.c (1.8), src/ipx.h (1.4, release0-9-8, v0-9-6, release-0_9-pre7), src/ipxrip.c (1.5), src/ipxrip.h (1.3, release0-9-8, v0-9-6, release-0_9-pre7), src/isakmp.h (1.3, release-0_9-pre7), src/l2tp.h (1.3, release-0_9-pre7), src/llc.h (1.4, release0-9-8, v0-9-6, release-0_9-pre7), src/local.h (1.1), src/loopback.h (1.3, release0-9-8, v0-9-6, release-0_9-pre7), src/mgcp.c (1.6, release0-9-8, v0-9-6, release-0_9-pre7), src/mgcp.h (1.4, release0-9-8, v0-9-6, release-0_9-pre7), src/netbios_ns.h (1.5, release0-9-8, v0-9-6, release-0_9-pre7), src/ns_labels.h (1.4, release0-9-8, v0-9-6, release-0_9-pre7), src/open_pcap.c (1.3, release-0_9-pre7), src/ospf.h (1.5, release0-9-8, v0-9-6, release-0_9-pre7), src/packet_manip.c (1.10, release-0_9-pre7), src/payload.h (1.3, release0-9-8, v0-9-6, release-0_9-pre7), src/pptp.c (1.5), src/pptp.h (1.3), src/raw.h (1.3, release0-9-8, v0-9-6, release-0_9-pre7), src/rip.h (1.5, release0-9-8, v0-9-6, release-0_9-pre7), src/ripng.h (1.3, release0-9-8, v0-9-6, release-0_9-pre7), src/rtp.h (1.3, release-0_9-pre7), src/sdp.c (1.5, release-0_9-pre7), src/sdp.h (1.3, release-0_9-pre7), src/sip.h (1.4, release0-9-8, v0-9-6, release-0_9-pre7), src/slip.h (1.3, release0-9-8, v0-9-6, release-0_9-pre7), src/slp.h (1.3, release0-9-8, v0-9-6, release-0_9-pre7), src/snmp.c (1.7, release-0_9-pre7), src/spx.h (1.3, release0-9-8, v0-9-6, release-0_9-pre7), src/strmap.c (1.4, release0-9-8, v0-9-6, release-0_9-pre7), src/tcp.c (1.14, release-0_9-pre7), src/tcp.h (1.6, release0-9-8, v0-9-6, release-0_9-pre7), src/template.h (1.2, release0-9-8, v0-9-6, release-0_9-pre7), src/udp.c (1.12, release-0_9-pre7), src/udp.h (1.5, release0-9-8, v0-9-6, release-0_9-pre7): Worked header file dependencies by breaking out library headers vs. ipgrab headers into global.h and local.h respectively. Added new display method, display_strmap(). Will slowly convert to this method where appropriate. 2000-08-30 14:45 mborella * Makefile.in (1.9), TODO (1.12), configure (1.13), doc/Makefile.in (1.4), src/Makefile.in (1.16), src/ip_services.c (1.2, release-0_9-pre7), src/pptp.c (1.4): Minor changes for PPTP support. 2000-08-29 22:19 mborella * src/: Makefile.am (1.20), Makefile.in (1.15), debug.c (1.3): Removed debug.c 2000-08-29 21:59 mborella * doc/Makefile.in (1.3), doc/ipgrab.texi (1.5), src/Makefile.am (1.19), src/Makefile.in (1.14), src/ah.c (1.4), src/ah.h (1.3), src/arp.c (1.8), src/arp.h (1.2), src/datalink.c (1.8), src/datalink.h (1.2, v0-9-6, release-0_9-pre7), src/debug.c (1.2), src/dhcp.c (1.9), src/dhcp.h (1.4), src/display.c (1.14), src/display.h (1.12), src/dns.c (1.16), src/dns.h (1.8), src/error.c (1.2, v0-9-6, release-0_9-pre7), src/error.h (1.2, release-0_9-pre7), src/esp.c (1.3, release-0_9-pre7), src/esp.h (1.2, release0-9-8, v0-9-6, release-0_9-pre7), src/ethernet.c (1.13), src/global.h (1.5), src/hexbuffer.c (1.3, release-0_9-pre7), src/hexbuffer.h (1.2), src/http.c (1.3), src/http.h (1.2), src/icmp.c (1.9), src/icmp.h (1.4), src/icmpv6.c (1.6), src/icmpv6.h (1.5), src/igmp.c (1.5), src/igmp.h (1.2), src/ip.c (1.15), src/ip.h (1.6), src/ip_protocols.c (1.15), src/ip_protocols.h (1.9), src/ip_services.c (1.1), src/ip_services.h (1.1, release-0_9-pre7), src/ipgrab.c (1.7), src/ipgrab.h (1.2, release0-9-8, v0-9-6, release-0_9-pre7), src/ipv6.c (1.7), src/ipv6.h (1.7), src/ipx.c (1.7), src/ipx.h (1.3), src/ipxrip.c (1.4), src/ipxrip.h (1.2), src/isakmp.c (1.3, release-0_9-pre7), src/isakmp.h (1.2), src/l2tp.c (1.3, release-0_9-pre7), src/l2tp.h (1.2), src/llc.c (1.3, release-0_9-pre7), src/llc.h (1.3), src/loopback.c (1.2), src/loopback.h (1.2), src/mgcp.c (1.5), src/mgcp.h (1.3), src/netbios_ns.c (1.5, release-0_9-pre7), src/netbios_ns.h (1.4), src/ns_labels.c (1.3, release0-9-8, v0-9-6, release-0_9-pre7), src/ns_labels.h (1.3), src/open_pcap.c (1.2), src/open_pcap.h (1.2, release0-9-8, v0-9-6, release-0_9-pre7), src/ospf.c (1.7), src/ospf.h (1.4), src/packet_manip.c (1.9), src/packet_manip.h (1.6), src/payload.c (1.3, release-0_9-pre7), src/payload.h (1.2), src/pptp.c (1.3), src/raw.c (1.2), src/raw.h (1.2), src/rip.c (1.10), src/rip.h (1.4), src/ripng.c (1.4), src/ripng.h (1.2), src/rsip.c (1.2, release0-9-8, v0-9-6, release-0_9-pre7), src/rtp.c (1.2, release-0_9-pre7), src/rtp.h (1.2), src/sdp.c (1.4), src/sdp.h (1.2), src/sip.c (1.6, release-0_9-pre7), src/sip.h (1.3), src/slip.c (1.2), src/slip.h (1.2), src/slp.c (1.2, release-0_9-pre7), src/slp.h (1.2), src/snmp.c (1.6), src/spx.c (1.3), src/spx.h (1.2), src/strmap.c (1.3), src/strmap.h (1.3, release0-9-8, v0-9-6, release-0_9-pre7), src/tcp.c (1.13), src/tcp.h (1.5), src/template.c (1.1, release-0_9-pre7), src/template.h (1.1), src/udp.c (1.11), src/udp.h (1.4): 1) Added GPL statement to each source file. 2) Worked a little more on the documentation. 3) Made the header file dependencies more intelligent. 4) Broke ip_services.c modules out of ip_protocols.c 5) Added a few more headers to configure.in. 6) All system-dependent header file stuff is in global.h 7) Probably a few more things I'm forgetting. 2000-08-29 21:58 mborella * Makefile.in (1.8), TODO (1.11), config.in (1.6), configure (1.12), configure.in (1.14): Wow, lots of changes though most are cosmetic: 1) Added GPL statement to each source file. 2) Worked a little more on the documentation. 3) Made the header file dependencies more intelligent. 4) Broke ip_services.c modules out of ip_protocols.c 5) Added a few more headers to configure.in. 6) All system-dependent header file stuff is in global.h 7) Probably a few more things I'm forgetting. 2000-08-21 20:55 mborella * AUTHORS (1.4), TODO (1.10), configure (1.11), configure.in (1.13), ipgrab.gp (1.2), src/mgcp.c (1.4): Minor fix to mgcp so that it will compile. 2000-08-18 17:00 mborella * src/: dns.c (1.15), ethernet.c (1.12), ip.c (1.14), ipx.c (1.6), netbios_ns.c (1.4), netbios_ns.h (1.3), tcp.c (1.12), udp.c (1.10): Fixed netbios ns so that it works fairly well. I think its reasonably solid. Along the way fixed monir but nasty bugs in the name service routines. 2000-08-17 20:12 mborella * src/: Makefile.in (1.13), dns.c (1.14), netbios_ns.c (1.3), ns_labels.c (1.2), ns_labels.h (1.2), protocols.h (1.14, release0-9-8, v0-9-6, release-0_9-pre7): Eliminated a rasther nasty stack-frame overwrite bug in the ns_labels.c module. And there was much rejoicing. 2000-08-17 18:57 mborella * src/: Makefile.am (1.18), dns_labels.c (1.2), dns_labels.h (1.2), netbios_ns.c (1.2), netbios_ns.h (1.2), ns_labels.c (1.1), ns_labels.h (1.1): Further work on netbios ns, generalized DNS / NETBIOS NS label parsing to the ns_labels.c module. 2000-08-17 00:54 mborella * src/: Makefile.am (1.17), Makefile.in (1.12), dns.c (1.13), ethernet.c (1.11), ethernet.h (1.3), icmp.c (1.8), icmp.h (1.3), ip.c (1.13), ip.h (1.5), ip_protocols.c (1.14), ipx.c (1.5), ipx.h (1.2), llc.c (1.2), llc.h (1.2), mgcp.c (1.3), mgcp.h (1.2), netbios_ns.c (1.1), netbios_ns.h (1.1), pptp.c (1.2), pptp.h (1.2), protocols.h (1.13), strmap.c (1.2), tcp.c (1.11), tcp.h (1.4), udp.c (1.9), udp.h (1.3): Basic NETBIOS NS support, fixed a bug in map2str, linked in MGCP, but didn't quite get it working (DOH!) 2000-08-16 21:14 mborella * src/: arp.c (1.7), dhcp.c (1.8), dhcp.h (1.3), dns.c (1.12), dns.h (1.7), ethernet.c (1.10), hexbuffer.c (1.2), ip.c (1.12), ip.h (1.4), ipv6.c (1.6), ipv6.h (1.6), packet_manip.c (1.8), tcp.c (1.10), tcp.h (1.3), udp.c (1.8), udp.h (1.2): Added hex buffer support to more modules, fixed minor DHCP bugs. 2000-08-16 20:26 mborella * src/: Makefile.am (1.16), Makefile.in (1.11), datalink.c (1.7), display.c (1.13), display.h (1.11), ethernet.c (1.9), global.h (1.4), hexbuffer.c (1.1), hexbuffer.h (1.1), ipgrab.c (1.6), packet_manip.c (1.7), parse_cl.c (1.2, release-0_9-pre7), parse_cl.h (1.2, release-0_9-pre7): Added basic hexbuffer support. Tested with Ethernet, will add to other protocols. 2000-08-11 23:45 mborella * src/: Makefile.am (1.15), Makefile.in (1.10), ethernet.c (1.8), llc.c (1.1), llc.h (1.1), protocols.h (1.12): Added basic LLC support. Still mostly broken... 2000-08-11 18:18 mborella * src/: Makefile.am (1.14), Makefile.in (1.9), ip_protocols.h (1.8), pptp.c (1.1), pptp.h (1.1), protocols.h (1.11): Initial framework for PPTP. 2000-07-26 20:23 mborella * src/: dhcp.c (1.7), dhcp.h (1.2), icmp.c (1.7), snmp.c (1.5): Fixed all obvious DHCP bugs, including a segfault and a few unknown options. Also fixed SNMP minimal mode and ICMP minimal mode (the latter was ok, but I added the sequence number to all ping output) 2000-07-26 18:51 mborella * configure (1.10), configure.in (1.12), src/esp.c (1.2), src/rip.c (1.9), src/ripng.c (1.3): Changed RIP and RIPng to print only the number of routes seen in minimal mode, not the routes themselves. Major fix to ESP - it was still in 0.8.x mode...seesh! 2000-06-29 19:04 mborella * src/: Makefile.am (1.13), Makefile.in (1.8), display.c (1.12), display.h (1.10), global.h (1.3), http.c (1.2), ospf.c (1.6), packet_manip.c (1.6), protocols.h (1.10), rip.c (1.8), ripng.c (1.2), sdp.h (1.1), sip.c (1.5), snmp.c (1.4): Added -Wall and -Wstrict-prototypes to CFLAGS, which nailed a bunch of missing include files. Many fixes later, we're compiling cleanly again. 2000-06-19 23:10 mborella * src/: ripng.c (1.1), ripng.h (1.1): Adding RIPng support. 2000-06-19 23:09 mborella * src/: display.h (1.9), packet_manip.h (1.5), strmap.h (1.2): Added an include for global.h in a few files that need it. 2000-06-19 19:52 mborella * configure (1.9), configure.in (1.11) (utags: release-0_9-pre4): Fixed version number. 2000-06-19 19:47 mborella * TODO (1.9), src/display.c (1.11), src/slp.c (1.1), src/slp.h (1.1), src/udp.c (1.7) (utags: release-0_9-pre4): Fixed SLP support, v1 seems to be working ok, v2 is not tested. Also fixed bug in displaying routine for DISP_DEC. 2000-06-19 16:48 mborella * src/: tcp.c (1.9, release-0_9-pre4), udp.c (1.6): Modified TCP and UDP to use new decimal displaying API. 2000-06-19 16:41 mborella * TODO (1.8), src/Makefile.am (1.12, release-0_9-pre4), src/Makefile.in (1.7, release-0_9-pre4), src/display.c (1.10), src/display.h (1.8, release-0_9-pre4), src/ip.c (1.11, release-0_9-pre4), src/ip.h (1.3, release-0_9-pre4), src/ip_protocols.c (1.13, release-0_9-pre4), src/ip_protocols.h (1.7, release-0_9-pre4), src/protocols.h (1.9, release-0_9-pre4): Made a new API display type: DISP_DEC, which replaces all decimal type displaying functions. Required overcoming the usual hairy byte ordering issues, and I'm hoping it isn't going to screw anything up. 2000-06-19 15:32 mborella * src/: arp.c (1.6), dhcp.c (1.6), dns.c (1.11), icmp.c (1.6), icmpv6.c (1.5), igmp.c (1.4), ospf.c (1.5), rip.c (1.7) (utags: release-0_9-pre4): Modified all files to use new address display API (not that it makes a bit of difference to the user...) Also tested RIPng and it seems to work ok. 2000-06-16 23:03 mborella * TODO (1.7), src/Makefile.am (1.11), src/Makefile.in (1.6), src/display.c (1.9), src/display.h (1.7), src/ip.c (1.10), src/ipv6.c (1.5, release-0_9-pre4): Added special printing functions for ipv4 and ipv6 addresses. 2000-06-16 22:28 mborella * TODO (1.6), src/Makefile.am (1.10), src/Makefile.in (1.5), src/arp.c (1.5), src/dhcp.c (1.5), src/icmpv6.c (1.4), src/igmp.c (1.3), src/ip_protocols.c (1.12), src/ip_protocols.h (1.6), src/protocols.h (1.8), src/snmp.c (1.3, release-0_9-pre4): Added preliminary RIPng support that probably doesn't work, prettied up ARP and IGMP, fixed SNMP so that it compiles on Freebsd. 2000-06-07 23:10 mborella * TODO (1.5), src/icmpv6.c (1.3), src/icmpv6.h (1.4, release-0_9-pre4): Added slightly better ICMPv6 support. Still needs work though. 2000-06-07 15:31 mborella * TODO (1.4), src/dns.c (1.10), src/dns.h (1.6, release-0_9-pre4): Added IPv6 support to DNS. 2000-06-06 22:33 mborella * Makefile.in (1.7, release-0_9-pre4), acconfig.h (1.4, release0-9-8, v0-9-6, release-0_9-pre4), acinclude.m4 (1.3, release-0_9-pre4), aclocal.m4 (1.5, release-0_9-pre4), config.in (1.5, release-0_9-pre4), configure (1.8), configure.in (1.10), src/ip_protocols.c (1.11): Made IPv6 encapsulation work (doh!) and wrote a generic m4 macro for finding headers that may be in a number of directories. 2000-06-05 18:52 mborella * TODO (1.3), src/ospf.c (1.4), src/ospf.h (1.3, release-0_9-pre4): Added support for OSPF hello header. 2000-06-01 19:28 mborella * src/: arp.c (1.4), icmp.c (1.5) (utags: release-0_9-pre3): Added minimal mode announcements to arp and icmp 2000-06-01 19:12 mborella * TODO (1.2), src/icmpv6.h (1.3), src/ipx.c (1.4, release-0_9-pre4), src/spx.c (1.2, release-0_9-pre4) (utags: release-0_9-pre3): Added minimal mode to SPX (not complete), added a little more support for ICMPv6 (also not complete) 2000-06-01 18:36 mborella * Makefile.am (1.3, release0-9-8, v0-9-6, release-0_9-pre4, release-0_9-pre3), Makefile.in (1.6, release-0_9-pre3), TODO (1.1), doc/ipgrab.texi (1.4, release-0_9-pre4, release-0_9-pre3), src/arp.c (1.3), src/dhcp.c (1.4, release-0_9-pre3), src/dns.c (1.9, release-0_9-pre3), src/ethernet.c (1.7, release-0_9-pre4, release-0_9-pre3), src/icmp.c (1.4), src/icmpv6.c (1.2, release-0_9-pre3), src/icmpv6.h (1.2), src/igmp.c (1.2, release-0_9-pre3), src/ip.c (1.9, release-0_9-pre3), src/ip_protocols.c (1.10, release-0_9-pre3), src/ipv6.c (1.4, release-0_9-pre3), src/ipx.c (1.3), src/ipxrip.c (1.3, release-0_9-pre4, release-0_9-pre3), src/ospf.c (1.3, release-0_9-pre3), src/rip.c (1.6, release-0_9-pre3), src/tcp.c (1.8, release-0_9-pre3): Made sure that all string maps are properly terminated, added TODO file, minor improvments to ICMPv6. 2000-05-31 00:07 mborella * src/: Makefile.am (1.9, release-0_9-pre3), Makefile.in (1.4, release-0_9-pre3), icmpv6.c (1.1), icmpv6.h (1.1), ip_protocols.c (1.9), ipv6.c (1.3), ipv6.h (1.5, release-0_9-pre4, release-0_9-pre3), protocols.h (1.7, release-0_9-pre3): Added very basic framework for ICMPv6 support. Nothing useful yet. 2000-05-30 23:10 mborella * Makefile.in (1.5), acconfig.h (1.3, release-0_9-pre3), acinclude.m4 (1.2, release-0_9-pre3), aclocal.m4 (1.4, release-0_9-pre3), config.in (1.4, release-0_9-pre3), configure (1.7, release-0_9-pre3), configure.in (1.9, release-0_9-pre3), doc/Makefile.in (1.2, release-0_9-pre4, release-0_9-pre3), src/Makefile.in (1.3), src/snmp.c (1.2, release-0_9-pre3): SNMP now integrated more cleanly...I hope. 2000-05-30 22:15 mborella * doc/ipgrab.texi (1.3), src/ip.c (1.8): Minor documentation additions. 2000-05-30 21:37 mborella * src/: ip.c (1.7), rip.c (1.5), tcp.c (1.7), udp.c (1.5, release-0_9-pre3): Added dump of protocol to minimal mode. 2000-05-30 10:55 gwiley * src/: Makefile.am (1.8), Makefile.in (1.2), ip_protocols.c (1.8), ip_protocols.h (1.5, release-0_9-pre3), ipgsnmp.h (1.1, release-0_9-pre4, release-0_9-pre3), protocols.h (1.6), snmp.c (1.1): added hooks for snmp v1, v2c header dump, pdu support is incomplete 2000-05-30 10:53 gwiley * INSTALL (1.2, release0-9-8, v0-9-6, release-0_9-pre4, release-0_9-pre3), README (1.2, release0-9-8, v0-9-6, release-0_9-pre4, release-0_9-pre3), configure.in (1.8): added notes about support for SNMP via UCD libsnmp, added --with-snmphdr 2000-05-29 14:29 gwiley * configure.in (1.7): added a test to allow user to specify the pcap headers directory 2000-05-25 19:02 mborella * src/: rip.c (1.4), rip.h (1.3, release-0_9-pre4, release-0_9-pre3): Fixed RIP module to differentiate between RIP v1 and v2. 2000-05-21 22:21 mborella * Makefile.in (1.4), doc/Makefile.in (1.1), src/Makefile.in (1.1): Added makefil.in's finally. 2000-05-21 22:20 mborella * src/: dns.c (1.8), ip_protocols.c (1.7), rip.c (1.3), rip.h (1.2): Fixed RIP. 2000-05-21 20:44 mborella * src/: dns.c (1.7), dns.h (1.5, release-0_9-pre3): Finally got DNS working. Not perfect or complete but reasonably good. 2000-05-21 19:39 mborella * src/: Makefile.am (1.7), dns.c (1.6), dns.h (1.4), dns_labels.c (1.1, release-0_9-pre4, release-0_9-pre3), dns_labels.h (1.1, release-0_9-pre4, release-0_9-pre3), packet_manip.c (1.5, release-0_9-pre4, release-0_9-pre3), packet_manip.h (1.4, release-0_9-pre4, release-0_9-pre3): Added API for DNS label manipulation. What a mess. Added to the packet manip API as well, so that a place in a packet can be "marked" and the distance from that mark can be computed. 2000-05-21 16:20 mborella * src/: ospf.c (1.2), ospf.h (1.2, release-0_9-pre3): Tentative OSPF support. Completely untested. 2000-05-21 15:27 mborella * acinclude.m4 (1.1): Added acinclude for our custom m4 scripts. 2000-05-21 15:26 mborella * aclocal.m4 (1.3), configure (1.6), configure.in (1.6), doc/ipgrab.texi (1.2), src/Makefile.am (1.6), src/datalink.c (1.6, release-0_9-pre4, release-0_9-pre3), src/icmp.h (1.2, release-0_9-pre4, release-0_9-pre3), src/ip_protocols.c (1.6), src/ip_protocols.h (1.4), src/ipgrab.c (1.5, release-0_9-pre4, release-0_9-pre3), src/ospf.c (1.1), src/ospf.h (1.1), src/protocols.h (1.5): Added OSPF shim. Doesn't actually work yet. Also added autoconf hack that will look in several places for pcap.h. Finally, added a few new IP protocols. 2000-05-13 00:57 mborella * src/: display.c (1.8, release-0_9-pre3), dns.c (1.5), dns.h (1.3): Fixed DNS crashes by disabling anything besides the basic header until I get a chance to fix it. Minimal mode does nothing so far. Also fixed a real ugly crash in the main display routine due to the length of a label being too long. 2000-05-12 22:02 mborella * src/: ipv6.c (1.2), ipv6.h (1.4): Fixed naasty IPv6 byteorder problems. 2000-05-12 21:56 mborella * src/: ah.c (1.3, release-0_9-pre4, release-0_9-pre3), ipgrab.c (1.4), ipv6.h (1.3): Got rid of more build and dependency problems... 2000-05-11 22:18 mborella * src/: addrtoname.c (1.2), addrtoname.h (1.2): Fixed weird removal errors. 2000-05-11 22:08 mborella * doc/Makefile.am (1.2, release0-9-8, v0-9-6, release-0_9-pre4, release-0_9-pre3): Makefile now cleans up some documentation. 2000-05-11 21:54 mborella * doc/: mdate-sh (1.1), texinfo.tex (1.1) (utags: release-0_9-pre2, release-0_9-pre3, release-0_9-pre4, release0-9-8, v0-9-6): Added some more documentation files. 2000-05-11 21:52 mborella * src/ipv6.h (1.2, release-0_9-pre2): Trying to figure out what's wrong with these files - each of them always claims to be modified... 2000-05-11 21:47 mborella * src/: http.c (1.1), http.h (1.1) (utags: release-0_9-pre2, release-0_9-pre3, release-0_9-pre4): Added HTTP support. 2000-05-11 21:33 mborella * configure (1.5), configure.in (1.5), src/Makefile.am (1.5), src/icmp.c (1.3), src/igmp.c (1.1), src/igmp.h (1.1, release-0_9-pre4, release-0_9-pre3), src/ip.c (1.6), src/ip.h (1.2, release-0_9-pre3), src/ip_protocols.c (1.5), src/ip_protocols.h (1.3), src/protocols.h (1.4) (utags: release-0_9-pre1, release-0_9-pre2): Lots of changes. Added IGMP support. Fixed IP options. Added some more port mappings. 2000-05-10 20:37 mborella * acconfig.h (1.2, release-0_9-pre2, release-0_9-pre1), config.in (1.3, release-0_9-pre2, release-0_9-pre1), configure (1.4), configure.in (1.4), src/Makefile.am (1.4), src/dns.c (1.4, release-0_9-pre2, release-0_9-pre1), src/ip.c (1.5), src/ip_protocols.c (1.4), src/packet_manip.c (1.4, release-0_9-pre2, release-0_9-pre1), src/packet_manip.h (1.3, release-0_9-pre2, release-0_9-pre1), src/protocols.h (1.3), src/sdp.c (1.3, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), src/sip.c (1.4, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), src/tcp.c (1.6, release-0_9-pre2, release-0_9-pre1): Added HTTP support...hooohaaa! Also managed to create a very nasty little memory overwrite bug, which necessitated the creation of debug mode from configure.in. 2000-05-10 18:26 mborella * src/: datalink.c (1.5, release-0_9-pre2, release-0_9-pre1), display.c (1.7, release-0_9-pre2, release-0_9-pre1), display.h (1.6, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), tcp.c (1.5), tcp.h (1.2, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1): Added TCP option support, cleaned up minimal mode, added TCP window advert to minimal mode, added timestamp to all lines in minimal mode. 2000-05-09 22:49 mborella * Makefile.am (1.2, release-0_9-pre2, release-0_9-pre1), configure (1.3), configure.in (1.3), doc/Makefile.am (1.1, release-0_9-pre2, release-0_9-pre1), doc/ipgrab.texi (1.1, release-0_9-pre2, release-0_9-pre1), src/dhcp.c (1.3, release-0_9-pre2, release-0_9-pre1), src/dns.c (1.3), src/dns.h (1.2, release-0_9-pre2, release-0_9-pre1), src/ip_protocols.c (1.3): Added documentation files. Enabled DHCP and DNS output. Trying to fix DHCP output. 2000-05-09 19:41 mborella * src/: display.c (1.6), display.h (1.5), icmp.c (1.2), tcp.c (1.4): Fixed minimal mode for ICMP, fixed IPv6 header printing, added the minimal string display mode. 2000-05-09 17:43 mborella * src/: ethernet.c (1.6), ethernet.h (1.2, release-0_9-pre4, release-0_9-pre3) (utags: release-0_9-pre1, release-0_9-pre2): Made some fixes to minimal mode ethernet, so that the ethernet type field is always displayed. However, the results are weird... 2000-05-09 17:16 mborella * src/: arp.c (1.2, release-0_9-pre2, release-0_9-pre1), datalink.c (1.4), display.c (1.5), ip.c (1.4), ipx.c (1.2, release-0_9-pre2, release-0_9-pre1), ipxrip.c (1.2, release-0_9-pre2, release-0_9-pre1): Fixed new minimal more for IPX, IPX RIP and ARP. 2000-05-09 00:21 mborella * src/: dhcp.c (1.2), dns.c (1.2), ethernet.c (1.5), l2tp.c (1.2, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), payload.c (1.2, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), rip.c (1.2, release-0_9-pre2, release-0_9-pre1), tcp.c (1.3), udp.c (1.4, release-0_9-pre2, release-0_9-pre1): Got rid of some warnings on FreeBSD compile. 2000-05-08 23:37 mborella * AUTHORS (1.3, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1): Added Stuart. 2000-05-08 23:36 mborella * src/: Makefile.am (1.3), ah.c (1.2, release-0_9-pre2, release-0_9-pre1), ah.h (1.2, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), display.c (1.4), display.h (1.4), ipgrab.c (1.3, release-0_9-pre2, release-0_9-pre1), isakmp.c (1.2, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1): Got rid of addrtoname.c module. Functionality is now taken care of in our own way. 2000-05-08 22:55 mborella * src/: Makefile.am (1.2), display.c (1.3), display.h (1.3), ethernet.c (1.4), ip.c (1.3), ipv6.c (1.1, release-0_9-pre2, release-0_9-pre1), ipv6.h (1.1, release-0_9-pre1), protocols.h (1.2): Basic support for IPv6. 2000-05-08 22:06 mborella * src/datalink.c (1.3): Replaced malloc.h with stdlib.h. 2000-05-08 21:18 mborella * src/: datalink.c (1.2), display.c (1.2), display.h (1.2), ethernet.c (1.3), ip.c (1.2), tcp.c (1.2), udp.c (1.3): Made "minimal mode" into a one-line tcpdump-like mode. 2000-05-04 22:47 mborella * src/: ip_protocols.c (1.2), ip_protocols.h (1.2), packet_manip.c (1.3), sip.c (1.3), udp.c (1.2): Fixed SIP. Added application function mapping based on port number. 2000-05-04 21:49 mborella * src/: packet_manip.c (1.2), packet_manip.h (1.2), sdp.c (1.2), sip.c (1.2), sip.h (1.2, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1): Minor fix in packet API. I think I've got SIP up to date, but it may be broken... 2000-05-04 20:41 mborella * ipgrab.gp (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), src/Makefile.am (1.1): Added a couple of essential files that had previosly been omitted. 2000-05-04 20:22 mborella * Makefile.in (1.3), src/ethernet.c (1.2), src/global.h (1.2, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), src/ipgrab.c (1.2), src/mgcp.c (1.2, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), src/utils.c (1.2): Fixed a handful of configuration issues. Unfortuantely, the move to automake broke a couple of things. It won't build right now until I re-write sip, sdp and mgcp. 2000-05-04 20:11 mborella * Makefile.in (1.2), acconfig.h (1.1), aclocal.m4 (1.2, release-0_9-pre2, release-0_9-pre1), config.in (1.2), configure (1.2), configure.in (1.2): More configuration fixes. 2000-05-04 19:39 mborella * AUTHORS (1.2), CHANGELOG (1.2), ChangeLog (1.2, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), Makefile.am (1.1): Puttered with configuration files. 2000-05-04 19:33 mborella * AUTHORS (1.1), COPYING (1.1, release0-9-8, v0-9-6, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), ChangeLog (1.1), INSTALL (1.1, release-0_9-pre2, release-0_9-pre1), NEWS (1.1, release0-9-8, v0-9-6, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), aclocal.m4 (1.1), missing (1.1, release0-9-8, v0-9-6, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), mkinstalldirs (1.1, release0-9-8, v0-9-6, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1): Added a bund of files to the root directory to help with automake switchover 2000-05-04 19:30 mborella * Makefile.in (1.1), config.guess (1.1, v0-9-6, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), config.in (1.1), config.sub (1.1, v0-9-6, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), configure (1.1), configure.in (1.1), install-sh (1.1, release0-9-8, v0-9-6, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), ipgrab.8 (1.1, release0-9-8, v0-9-6, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1): Added files from build directoy to root directory. 2000-05-04 19:29 mborella * build/: Makefile.in (1.6), VERSION (1.2), config.guess (1.2), config.h.in (1.3), config.sub (1.2), configure (1.4), configure.in (1.4), install-sh (1.2), ipgrab.8 (1.2): Moved files from build directory to root directory. 2000-05-04 19:22 mborella * main/: addrtoname.c (1.2), addrtoname.h (1.2), datalink.c (1.3), datalink.h (1.2), debug.c (1.2), display.c (1.9), display.h (1.9), error.c (1.2), error.h (1.2), getopt.c (1.2), getopt.h (1.2), getopt_internal.c (1.2), global.h (1.6), ipgrab.c (1.4), ipgrab.gp (1.2), ipgrab.h (1.2), open_pcap.c (1.3), open_pcap.h (1.3), packet_manip.c (1.4), packet_manip.h (1.5), parse_cl.c (1.2), parse_cl.h (1.2), strmap.c (1.2), strmap.h (1.2), utils.c (1.2): Removed a bunch of files from main. 2000-05-04 19:21 mborella * src/: addrtoname.c (1.1, release-0_9-pre2, release-0_9-pre1), addrtoname.h (1.1, release-0_9-pre2, release-0_9-pre1), datalink.c (1.1), datalink.h (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), debug.c (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), display.c (1.1), display.h (1.1), error.c (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), error.h (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), getopt.c (1.1, release-0_9-pre7, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), getopt.h (1.1, release-0_9-pre7, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), getopt_internal.c (1.1, release-0_9-pre7, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), global.h (1.1), ipgrab.c (1.1), ipgrab.h (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), open_pcap.c (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), open_pcap.h (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), packet_manip.c (1.1), packet_manip.h (1.1), parse_cl.c (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), parse_cl.h (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), strmap.c (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), strmap.h (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), utils.c (1.1): Adding more files to src. 2000-05-04 19:16 mborella * protocols/: arp.c (1.7), arp.h (1.6), dhcp.c (1.3), dhcp.h (1.3), dns.c (1.3), dns.h (1.2), esp.c (1.3), esp.h (1.3), ethernet.c (1.11), ethernet.h (1.6), icmp.c (1.6), icmp.h (1.6), ip.c (1.7), ip.h (1.5), ip_protocols.c (1.5), ip_protocols.h (1.4), ipx.c (1.4), ipx.h (1.5), ipxrip.c (1.4), ipxrip.h (1.4), isakmp.c (1.4), isakmp.h (1.2), l2tp.c (1.4), l2tp.h (1.2), loopback.c (1.4), loopback.h (1.3), mgcp.c (1.3), mgcp.h (1.2), payload.c (1.3), payload.h (1.3), protocols.h (1.5), raw.c (1.4), raw.h (1.3), rip.c (1.3), rip.h (1.2), rsip.c (1.3), rsip.h (1.2), rtp.c (1.4), rtp.h (1.2), sdp.c (1.3), sip.c (1.3), sip.h (1.2), slip.c (1.4), slip.h (1.3), spx.c (1.4), spx.h (1.4), tcp.c (1.8), tcp.h (1.5), udp.c (1.6), udp.h (1.3): Removing more files from protocols directory. 2000-05-04 19:12 mborella * protocols/: ah.c (1.3), ah.h (1.3): Removing files from protocols directory. 2000-05-04 19:11 mborella * src/: ah.c (1.1), ah.h (1.1), arp.c (1.1), arp.h (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), dhcp.c (1.1), dhcp.h (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), dns.c (1.1), dns.h (1.1), esp.c (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), esp.h (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), ethernet.c (1.1), ethernet.h (1.1), icmp.c (1.1), icmp.h (1.1, release-0_9-pre2, release-0_9-pre1), ip.c (1.1), ip.h (1.1), ip_protocols.c (1.1), ip_protocols.h (1.1), ipx.c (1.1), ipx.h (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), ipxrip.c (1.1), ipxrip.h (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), isakmp.c (1.1), isakmp.h (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), l2tp.c (1.1), l2tp.h (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), loopback.c (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), loopback.h (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), mgcp.c (1.1), mgcp.h (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), payload.c (1.1), payload.h (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), protocols.h (1.1), raw.c (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), raw.h (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), rip.c (1.1), rip.h (1.1, release-0_9-pre2, release-0_9-pre1), rsip.c (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), rsip.h (1.1, release0-9-8, v0-9-6, release-0_9-pre7, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), rtp.c (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), rtp.h (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), sdp.c (1.1), sip.c (1.1), sip.h (1.1), slip.c (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), slip.h (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), spx.c (1.1, release-0_9-pre2, release-0_9-pre1), spx.h (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1), tcp.c (1.1), tcp.h (1.1), udp.c (1.1), udp.h (1.1, release-0_9-pre4, release-0_9-pre3, release-0_9-pre2, release-0_9-pre1): Moved a bunch of source files to the src directory. 2000-05-04 18:57 mborella * .ssh/known_hosts (1.2): Got rid of accidentally imported files. 2000-05-04 18:49 mborella * protocols/: ipxrip.c (1.3), ipxrip.h (1.3): Fixed IPX RIP. 2000-05-04 18:21 mborella * protocols/: spx.c (1.3), spx.h (1.3): Fixed SPX. 2000-05-04 00:25 mborella * protocols/: ipx.c (1.3), ipx.h (1.4), ipxrip.c (1.2), ipxrip.h (1.2), spx.c (1.2), spx.h (1.2): Updated IPX for new API. IPX RIP and SPX are now slightly broken. You've been warned... 2000-05-03 23:45 mborella * protocols/: ip.c (1.6), ip_protocols.c (1.4), ip_protocols.h (1.3), tcp.c (1.7), tcp.h (1.4): Added display map for IP next protocol field. Cleaned up TCP a little. Added more port definitions to ip_protocols. 2000-05-03 22:51 mborella * .cshrc (1.2), .login (1.2), .login_conf (1.2), .mail_aliases (1.2), .mailrc (1.2), .profile (1.2), .rhosts (1.2), .shrc (1.2): Delete a bunch of files that were accidentally imported. 2000-04-29 00:21 mborella * protocols/: ethernet.c (1.10), ip_protocols.c (1.3), tcp.c (1.6), udp.c (1.5): Port to string conversions work, but we're nowhere near complete yet. 2000-04-28 23:43 mborella * main/display.c (1.8), main/display.h (1.8), protocols/arp.c (1.6), protocols/ethernet.c (1.9), protocols/ip_protocols.c (1.2), protocols/ip_protocols.h (1.2): Fixed hex printing style. Began implementing port to string map. 2000-04-27 15:48 dgrabelsky * .cshrc (1.1), .login (1.1), .login_conf (1.1), .mail_aliases (1.1), .mailrc (1.1), .profile (1.1), .rhosts (1.1), .shrc (1.1), .ssh/known_hosts (1.1): Initial revision 2000-04-27 15:48 dgrabelsky * .cshrc (1.1.1.1), .login (1.1.1.1), .login_conf (1.1.1.1), .mail_aliases (1.1.1.1), .mailrc (1.1.1.1), .profile (1.1.1.1), .rhosts (1.1.1.1), .shrc (1.1.1.1), .ssh/known_hosts (1.1.1.1) (utags: start): [no log message] 2000-04-26 20:53 mborella * protocols/: dhcp.c (1.2), dhcp.h (1.2), dns.c (1.2), isakmp.c (1.3), l2tp.c (1.3), loopback.c (1.3), mgcp.c (1.2), raw.c (1.3), rip.c (1.2), rsip.c (1.2), rtp.c (1.3), sdp.c (1.2), sip.c (1.2), slip.c (1.3): Got rid of global packet end indicator. Fixed SIP output with Cullen's patch, then went and broke it again (see comments for details). Major mods to DHCP, made it work with the new architecture. 2000-04-26 00:27 mborella * main/: packet_manip.c (1.3), packet_manip.h (1.4): Added functions to look at the head of the packet and to move the pointer 2000-04-18 23:50 mborella * protocols/: icmp.c (1.5), icmp.h (1.5): Fixed ICMP time exceeded again. 2000-04-18 23:39 mborella * protocols/: icmp.c (1.4), icmp.h (1.4): Fixed ICMP time exceeded and mask request/reply. 2000-04-18 22:11 mborella * main/display.c (1.7), protocols/icmp.c (1.3), protocols/icmp.h (1.3): Fixed IP encapsulation in ICMP. 2000-04-18 19:52 mborella * protocols/: ethernet.c (1.8), ip.c (1.5): Minor fixes for minimal (-m) mode. 2000-04-18 19:25 mborella * protocols/: isakmp.c (1.2), l2tp.c (1.2), rtp.c (1.2): Moved extraction routines to global.h. Will do away with them soon. 2000-04-18 19:24 mborella * build/config.h.in (1.2), build/configure (1.3), build/configure.in (1.3), main/global.h (1.5), main/ipgrab.c (1.3): Added packet filter stats reporting. Moved extraction macros to global.h. Will do away with them soon. 2000-04-18 18:32 mborella * main/datalink.c (1.2), main/packet_manip.h (1.3), protocols/arp.c (1.5), protocols/arp.h (1.5), protocols/ethernet.c (1.7): Fixed Ethernet timestamp. ARP now uses IANA string mechanism. 2000-04-18 17:16 mborella * build/Makefile.in (1.5), main/global.h (1.4), protocols/ethernet.c (1.6): Updates for IANA string printing. 2000-04-18 16:45 mborella * main/: strmap.c (1.1), strmap.h (1.1): Added module for mapping IANA numbers to strings in a generic fashion. 2000-04-17 23:24 mborella * protocols/ip.h (1.4): Quick fix to ip.h. 2000-04-17 23:20 mborella * main/display.c (1.6), main/display.h (1.7), protocols/arp.c (1.4), protocols/ethernet.c (1.5), protocols/ethernet.h (1.5), protocols/ip.c (1.4), protocols/ip.h (1.3): Minor fixes to Ethernet, rudimentary support for IP options. 2000-04-17 20:54 mborella * main/display.c (1.5), main/display.h (1.6), protocols/arp.c (1.3), protocols/arp.h (1.4): Fixed ARP and cleaned it up. 2000-04-16 23:40 mborella * protocols/protocols.h (1.4): Ooops, forgot this one! Minor change, I think... 2000-04-16 23:37 mborella * protocols/: ip_protocols.c (1.1), ip_protocols.h (1.1): New files. Generic "next protcol" behavior for IP family, among other things. 2000-04-16 23:30 mborella * main/: datalink.c (1.1), datalink.h (1.1): New files. Generic datalink target for libpcap callback. 2000-04-16 23:28 mborella * build/Makefile.in (1.4), main/display.c (1.4), main/display.h (1.5), main/global.h (1.3), main/ipgrab.c (1.2), main/open_pcap.c (1.2), main/open_pcap.h (1.2), main/packet_manip.c (1.2), main/packet_manip.h (1.2), protocols/ah.c (1.2), protocols/ah.h (1.2), protocols/arp.c (1.2), protocols/arp.h (1.3), protocols/esp.c (1.2), protocols/esp.h (1.2), protocols/ethernet.c (1.4), protocols/ethernet.h (1.4), protocols/icmp.c (1.2), protocols/icmp.h (1.2), protocols/ip.c (1.3), protocols/ip.h (1.2), protocols/ipx.c (1.2), protocols/ipx.h (1.3), protocols/loopback.c (1.2), protocols/loopback.h (1.2), protocols/payload.c (1.2), protocols/payload.h (1.2), protocols/protocols.h (1.3), protocols/raw.c (1.2), protocols/raw.h (1.2), protocols/slip.c (1.2), protocols/slip.h (1.2), protocols/tcp.c (1.5), protocols/tcp.h (1.3), protocols/udp.c (1.4), protocols/udp.h (1.2): This is a major update, maoving the base IP stack protocols to the new generic reading and writing system. Some stuff is still broken. 2000-04-13 20:19 mborella * build/configure (1.2), build/configure.in (1.2), main/display.c (1.3), main/display.h (1.4), protocols/ethernet.c (1.3), protocols/ethernet.h (1.3), protocols/ipx.h (1.2), protocols/tcp.c (1.4), protocols/tcp.h (1.2): Added more generic display features, cleaned up more cruft. 2000-04-13 18:39 mborella * main/display.c (1.2), main/display.h (1.3), main/global.h (1.2), protocols/arp.h (1.2), protocols/ethernet.c (1.2), protocols/protocols.h (1.2), protocols/tcp.c (1.3), protocols/udp.c (1.3): Began to switch to generic display mechanism. Removing cruft as well. 2000-04-13 18:30 mborella * protocols/protocols.h (1.1): Generic include file for all protocols 2000-04-13 16:43 mborella * protocols/tcp.c (1.2): Added support to TCP for generic header banners 2000-04-13 16:42 mborella * build/Makefile.in (1.3), main/display.h (1.2), protocols/ethernet.h (1.2), protocols/ip.c (1.2), protocols/udp.c (1.2): Added support to some protocols for using generic header banners 2000-04-13 16:32 mborella * main/global.h (1.1): Added global include file -- eventually all modules should include this 2000-04-13 16:22 mborella * main/: display.c (1.1), display.h (1.1): Added files for generic display formatting 2000-04-13 13:58 mborella * main/packet_manip.h (1.1): Added packet_manip.h 2000-04-13 13:58 mborella * main/packet_manip.c (1.1): Added packet_manip.c 2000-04-13 13:53 mborella * build/Makefile.in (1.2): Added directive to create directory for object code if not already made. Added packet_manip.c to list of files to compile. 2000-04-11 17:26 mborella * CHANGELOG (1.1.1.1), README (1.1.1.1, release-0_9-pre2, release-0_9-pre1), build/Makefile.in (1.1.1.1), build/VERSION (1.1.1.1), build/config.guess (1.1.1.1), build/config.h.in (1.1.1.1), build/config.sub (1.1.1.1), build/configure (1.1.1.1), build/configure.in (1.1.1.1), build/install-sh (1.1.1.1), build/ipgrab.8 (1.1.1.1), main/addrtoname.c (1.1.1.1), main/addrtoname.h (1.1.1.1), main/debug.c (1.1.1.1), main/error.c (1.1.1.1), main/error.h (1.1.1.1), main/getopt.c (1.1.1.1), main/getopt.h (1.1.1.1), main/getopt_internal.c (1.1.1.1), main/ipgrab.c (1.1.1.1), main/ipgrab.gp (1.1.1.1), main/ipgrab.h (1.1.1.1), main/open_pcap.c (1.1.1.1), main/open_pcap.h (1.1.1.1), main/parse_cl.c (1.1.1.1), main/parse_cl.h (1.1.1.1), main/utils.c (1.1.1.1), protocols/arp.c (1.1.1.1), protocols/arp.h (1.1.1.1), protocols/dns.c (1.1.1.1), protocols/dns.h (1.1.1.1), protocols/ethernet.c (1.1.1.1), protocols/ethernet.h (1.1.1.1), protocols/icmp.c (1.1.1.1), protocols/icmp.h (1.1.1.1), protocols/ip.c (1.1.1.1), protocols/ip.h (1.1.1.1), protocols/ipx.c (1.1.1.1), protocols/ipx.h (1.1.1.1), protocols/l2tp.c (1.1.1.1), protocols/l2tp.h (1.1.1.1), protocols/spx.c (1.1.1.1), protocols/spx.h (1.1.1.1), protocols/tcp.c (1.1.1.1), protocols/tcp.h (1.1.1.1), protocols/udp.c (1.1.1.1), protocols/udp.h (1.1.1.1), protocols/ah.c (1.1.1.1), protocols/ah.h (1.1.1.1), protocols/dhcp.c (1.1.1.1), protocols/dhcp.h (1.1.1.1), protocols/esp.c (1.1.1.1), protocols/esp.h (1.1.1.1), protocols/ipxrip.c (1.1.1.1), protocols/ipxrip.h (1.1.1.1), protocols/isakmp.c (1.1.1.1), protocols/isakmp.h (1.1.1.1), protocols/loopback.c (1.1.1.1), protocols/loopback.h (1.1.1.1), protocols/mgcp.c (1.1.1.1), protocols/mgcp.h (1.1.1.1), protocols/payload.c (1.1.1.1), protocols/payload.h (1.1.1.1), protocols/raw.c (1.1.1.1), protocols/raw.h (1.1.1.1), protocols/rip.c (1.1.1.1), protocols/rip.h (1.1.1.1), protocols/rsip.c (1.1.1.1), protocols/rsip.h (1.1.1.1), protocols/rtp.c (1.1.1.1), protocols/rtp.h (1.1.1.1), protocols/sdp.c (1.1.1.1), protocols/sip.c (1.1.1.1), protocols/sip.h (1.1.1.1), protocols/slip.c (1.1.1.1), protocols/slip.h (1.1.1.1) (utags: start): Initial checkin of release 0.8.2 code. 2000-04-11 17:26 mborella * CHANGELOG (1.1), README (1.1), build/Makefile.in (1.1), build/VERSION (1.1), build/config.guess (1.1), build/config.h.in (1.1), build/config.sub (1.1), build/configure (1.1), build/configure.in (1.1), build/install-sh (1.1), build/ipgrab.8 (1.1), main/addrtoname.c (1.1), main/addrtoname.h (1.1), main/debug.c (1.1), main/error.c (1.1), main/error.h (1.1), main/getopt.c (1.1), main/getopt.h (1.1), main/getopt_internal.c (1.1), main/ipgrab.c (1.1), main/ipgrab.gp (1.1), main/ipgrab.h (1.1), main/open_pcap.c (1.1), main/open_pcap.h (1.1), main/parse_cl.c (1.1), main/parse_cl.h (1.1), main/utils.c (1.1), protocols/arp.c (1.1), protocols/arp.h (1.1), protocols/dns.c (1.1), protocols/dns.h (1.1), protocols/ethernet.c (1.1), protocols/ethernet.h (1.1), protocols/icmp.c (1.1), protocols/icmp.h (1.1), protocols/ip.c (1.1), protocols/ip.h (1.1), protocols/ipx.c (1.1), protocols/ipx.h (1.1), protocols/l2tp.c (1.1), protocols/l2tp.h (1.1), protocols/spx.c (1.1), protocols/spx.h (1.1), protocols/tcp.c (1.1), protocols/tcp.h (1.1), protocols/udp.c (1.1), protocols/udp.h (1.1), protocols/ah.c (1.1), protocols/ah.h (1.1), protocols/dhcp.c (1.1), protocols/dhcp.h (1.1), protocols/esp.c (1.1), protocols/esp.h (1.1), protocols/ipxrip.c (1.1), protocols/ipxrip.h (1.1), protocols/isakmp.c (1.1), protocols/isakmp.h (1.1), protocols/loopback.c (1.1), protocols/loopback.h (1.1), protocols/mgcp.c (1.1), protocols/mgcp.h (1.1), protocols/payload.c (1.1), protocols/payload.h (1.1), protocols/raw.c (1.1), protocols/raw.h (1.1), protocols/rip.c (1.1), protocols/rip.h (1.1), protocols/rsip.c (1.1), protocols/rsip.h (1.1), protocols/rtp.c (1.1), protocols/rtp.h (1.1), protocols/sdp.c (1.1), protocols/sip.c (1.1), protocols/sip.h (1.1), protocols/slip.c (1.1), protocols/slip.h (1.1): Initial revision ipgrab-0.9.10/AUTHORS0000644000175000001440000000024310640150053013314 0ustar farooqusersMike Borella Contributors ------------ Andy Juniper Marty Roesch Cullen Jennings Stuart Stock Glen Wiley Grant Hartline Muhammad Farooq-i-Azam ipgrab-0.9.10/COPYING0000644000175000001440000004311007104350231013300 0ustar farooqusers GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. ipgrab-0.9.10/doc/0000755000175000001440000000000010644764325013033 5ustar farooqusersipgrab-0.9.10/doc/Makefile.am0000644000175000001440000000012410642147347015061 0ustar farooqusersinfo_TEXINFOS = ipgrab.texi man_MANS = ipgrab.8 CLEANFILES = ipgrab.info ipgrab.pdf ipgrab-0.9.10/doc/Makefile.in0000644000175000001440000003427310642152142015073 0ustar farooqusers# Makefile.in generated by automake 1.9.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = .. am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : subdir = doc DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(srcdir)/stamp-vti $(srcdir)/version.texi mdate-sh \ texinfo.tex ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = SOURCES = DIST_SOURCES = INFO_DEPS = ipgrab.info am__TEXINFO_TEX_DIR = $(srcdir) DVIS = ipgrab.dvi PDFS = ipgrab.pdf PSS = ipgrab.ps HTMLS = ipgrab.html TEXINFOS = ipgrab.texi TEXI2DVI = texi2dvi TEXI2PDF = $(TEXI2DVI) --pdf --batch MAKEINFOHTML = $(MAKEINFO) --html AM_MAKEINFOHTMLFLAGS = $(AM_MAKEINFOFLAGS) DVIPS = dvips am__installdirs = "$(DESTDIR)$(infodir)" DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ ac_ct_CC = @ac_ct_CC@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build_alias = @build_alias@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host_alias = @host_alias@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ info_TEXINFOS = ipgrab.texi CLEANFILES = ipgrab.info ipgrab.pdf all: all-am .SUFFIXES: .SUFFIXES: .dvi .ps $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu doc/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ipgrab.info: ipgrab.texi $(srcdir)/version.texi restore=: && backupdir="$(am__leading_dot)am$$$$" && \ rm -rf $$backupdir && mkdir $$backupdir && \ if ($(MAKEINFO) --version) >/dev/null 2>&1; then \ for f in $@ $@-[0-9] $@-[0-9][0-9] $(@:.info=).i[0-9] $(@:.info=).i[0-9][0-9]; do \ if test -f $$f; then mv $$f $$backupdir; restore=mv; else :; fi; \ done; \ else :; fi && \ if $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \ -o $@ `test -f 'ipgrab.texi' || echo '$(srcdir)/'`ipgrab.texi; \ then \ rc=0; \ else \ rc=$$?; \ $$restore $$backupdir/* `echo "./$@" | sed 's|[^/]*$$||'`; \ fi; \ rm -rf $$backupdir; exit $$rc ipgrab.dvi: ipgrab.texi $(srcdir)/version.texi TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \ $(TEXI2DVI) -o $@ `test -f 'ipgrab.texi' || echo '$(srcdir)/'`ipgrab.texi ipgrab.pdf: ipgrab.texi $(srcdir)/version.texi TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \ $(TEXI2PDF) -o $@ `test -f 'ipgrab.texi' || echo '$(srcdir)/'`ipgrab.texi ipgrab.html: ipgrab.texi $(srcdir)/version.texi rm -rf $(@:.html=.htp) if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \ -o $(@:.html=.htp) `test -f 'ipgrab.texi' || echo '$(srcdir)/'`ipgrab.texi; \ then \ rm -rf $@; \ if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \ mv $(@:.html=) $@; else mv $(@:.html=.htp) $@; fi; \ else \ if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \ rm -rf $(@:.html=); else rm -Rf $(@:.html=.htp) $@; fi; \ exit 1; \ fi $(srcdir)/version.texi: $(srcdir)/stamp-vti $(srcdir)/stamp-vti: ipgrab.texi $(top_srcdir)/configure @(dir=.; test -f ./ipgrab.texi || dir=$(srcdir); \ set `$(SHELL) $(srcdir)/mdate-sh $$dir/ipgrab.texi`; \ echo "@set UPDATED $$1 $$2 $$3"; \ echo "@set UPDATED-MONTH $$2 $$3"; \ echo "@set EDITION $(VERSION)"; \ echo "@set VERSION $(VERSION)") > vti.tmp @cmp -s vti.tmp $(srcdir)/version.texi \ || (echo "Updating $(srcdir)/version.texi"; \ cp vti.tmp $(srcdir)/version.texi) -@rm -f vti.tmp @cp $(srcdir)/version.texi $@ mostlyclean-vti: -rm -f vti.tmp maintainer-clean-vti: -rm -f $(srcdir)/stamp-vti $(srcdir)/version.texi .dvi.ps: TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ $(DVIPS) -o $@ $< uninstall-info-am: @$(PRE_UNINSTALL) @if (install-info --version && \ install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \ list='$(INFO_DEPS)'; \ for file in $$list; do \ relfile=`echo "$$file" | sed 's|^.*/||'`; \ echo " install-info --info-dir='$(DESTDIR)$(infodir)' --remove '$(DESTDIR)$(infodir)/$$relfile'"; \ install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$$relfile"; \ done; \ else :; fi @$(NORMAL_UNINSTALL) @list='$(INFO_DEPS)'; \ for file in $$list; do \ relfile=`echo "$$file" | sed 's|^.*/||'`; \ relfile_i=`echo "$$relfile" | sed 's|\.info$$||;s|$$|.i|'`; \ (if cd "$(DESTDIR)$(infodir)"; then \ echo " cd '$(DESTDIR)$(infodir)' && rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]"; \ rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]; \ else :; fi); \ done dist-info: $(INFO_DEPS) @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ list='$(INFO_DEPS)'; \ for base in $$list; do \ case $$base in \ $(srcdir)/*) base=`echo "$$base" | sed "s|^$$srcdirstrip/||"`;; \ esac; \ if test -f $$base; then d=.; else d=$(srcdir); fi; \ for file in $$d/$$base*; do \ relfile=`expr "$$file" : "$$d/\(.*\)"`; \ test -f $(distdir)/$$relfile || \ cp -p $$file $(distdir)/$$relfile; \ done; \ done mostlyclean-aminfo: -rm -rf ipgrab.aux ipgrab.cp ipgrab.cps ipgrab.cv ipgrab.cvs ipgrab.ev \ ipgrab.evs ipgrab.fn ipgrab.fns ipgrab.ky ipgrab.kys \ ipgrab.log ipgrab.ma ipgrab.mas ipgrab.ov ipgrab.ovs \ ipgrab.pg ipgrab.pgs ipgrab.tmp ipgrab.toc ipgrab.tp \ ipgrab.tps ipgrab.vr ipgrab.vrs ipgrab.dvi ipgrab.pdf \ ipgrab.ps ipgrab.html maintainer-clean-aminfo: @list='$(INFO_DEPS)'; for i in $$list; do \ i_i=`echo "$$i" | sed 's|\.info$$||;s|$$|.i|'`; \ echo " rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]"; \ rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]; \ done tags: TAGS TAGS: ctags: CTAGS CTAGS: distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ list='$(DISTFILES)'; for file in $$list; do \ case $$file in \ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ esac; \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ if test "$$dir" != "$$file" && test "$$dir" != "."; then \ dir="/$$dir"; \ $(mkdir_p) "$(distdir)$$dir"; \ else \ dir=''; \ fi; \ if test -d $$d/$$file; then \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" distdir="$(distdir)" \ dist-info check-am: all-am check: check-am all-am: Makefile $(INFO_DEPS) installdirs: for dir in "$(DESTDIR)$(infodir)"; do \ test -z "$$dir" || $(mkdir_p) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: $(DVIS) html: html-am html-am: $(HTMLS) info: info-am info-am: $(INFO_DEPS) install-data-am: install-info-am install-exec-am: install-info: install-info-am install-info-am: $(INFO_DEPS) @$(NORMAL_INSTALL) test -z "$(infodir)" || $(mkdir_p) "$(DESTDIR)$(infodir)" @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ list='$(INFO_DEPS)'; \ for file in $$list; do \ case $$file in \ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ esac; \ if test -f $$file; then d=.; else d=$(srcdir); fi; \ file_i=`echo "$$file" | sed 's|\.info$$||;s|$$|.i|'`; \ for ifile in $$d/$$file $$d/$$file-[0-9] $$d/$$file-[0-9][0-9] \ $$d/$$file_i[0-9] $$d/$$file_i[0-9][0-9] ; do \ if test -f $$ifile; then \ relfile=`echo "$$ifile" | sed 's|^.*/||'`; \ echo " $(INSTALL_DATA) '$$ifile' '$(DESTDIR)$(infodir)/$$relfile'"; \ $(INSTALL_DATA) "$$ifile" "$(DESTDIR)$(infodir)/$$relfile"; \ else : ; fi; \ done; \ done @$(POST_INSTALL) @if (install-info --version && \ install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \ list='$(INFO_DEPS)'; \ for file in $$list; do \ relfile=`echo "$$file" | sed 's|^.*/||'`; \ echo " install-info --info-dir='$(DESTDIR)$(infodir)' '$(DESTDIR)$(infodir)/$$relfile'";\ install-info --info-dir="$(DESTDIR)$(infodir)" "$(DESTDIR)$(infodir)/$$relfile" || :;\ done; \ else : ; fi install-man: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-aminfo \ maintainer-clean-generic maintainer-clean-vti mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-aminfo mostlyclean-generic mostlyclean-vti pdf: pdf-am pdf-am: $(PDFS) ps: ps-am ps-am: $(PSS) uninstall-am: uninstall-info-am .PHONY: all all-am check check-am clean clean-generic dist-info \ distclean distclean-generic distdir dvi dvi-am html html-am \ info info-am install install-am install-data install-data-am \ install-exec install-exec-am install-info install-info-am \ install-man install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-aminfo \ maintainer-clean-generic maintainer-clean-vti mostlyclean \ mostlyclean-aminfo mostlyclean-generic mostlyclean-vti pdf \ pdf-am ps ps-am uninstall uninstall-am uninstall-info-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ipgrab-0.9.10/doc/ipgrab.80000644000175000001440000000572510644705215014372 0ustar farooqusers.TH IPGRAB 8 "07 March 2007" .SH NAME ipgrab \- A Verbose Packet Sniffer .SH SYNOPSIS \fBipgrab\fP [ -ablmnPprTtwx ] [ -c \fIcnt\fP ] [ -i \fIif\fP ] [ \fiexpr\fP ] .SH DESCRIPTION \fIipgrab\fP reads and parses packets from the link layer through the application layer, dumping explicit header information along the way. It is a lot like \fItcpdump\fP except that it prints almost every header field. .SS Options .TP \fB-a\fP Do not display application layer data. .TP \fB-b\fP Buffer standard output. Useful when you're redirecting output to a file. .TP \fB-c \fIcnt\fR, \fB--count \fIcnt\fR Terminate after receiving \fIcnt\fP packets. .TP \fB-C \fIproto\fR, \fB--CCP \fIproto\fR Assume a particular CCP protocol, such as MPPC. MPPC is the only one supported as yet. .TP \fB-d\fP Dump extra padding in packets. For example, according to an IP header, the packet ends at a certain point, but the link layer may have padded it beyond that. This option displays the padding. Not valid in minimal mode. .TP \fB-h, --help\fP Display usage screen with a brief description of the command line options. .TP \fB-i \fIif\fR, \fB--interface \fIif\fR Makes ipgrab listen to packets on interface \fIif\fP, e.g., eth0. If this option is not used, the default interface will be assumed. .TP \fB-l\fP Don't display link-layer headers. The following protocols are considered to be link layer: ARP, CHAP, Ethernet, IPCP, LCP, LLC, Loopback, PPP, PPPoE, Raw, Slip. .TP \fB-m\fP Minimal mode output. When operating in this mode, ipgrab displays only brief header information. .TP \fB-n\fP Don't display network-layer headers. The following protocols are considered to be network layer: AH, ESP, GRE, ICMP, ICMPv6, IGMP, IP, IPv6, IPX, IPXRIP. .TP \fB-P \fIstring\fR Initiate a dynamic port mapping. This option must be followed by a string of the form `=', such as `http=8080'. .TP \fB-p\fP Dump packet payloads beyond what IPgrab parses. In other words, if IPgrab does not parse a particular application, this option will dump application data in hex and text format. .TP \fB-r\fP FILE Read packets from a file, rather than an interface. The file shoule be created in "raw" format, such as with '-w' option. .TP \fB-T\fP Do not display timestamps in minimal mode. .TP \fB-t\fP Don't display transport layer headers. The following protocols are considered to be transport layer: SPX, TCP, UDP. .TP \fB-v, --version\fP Display version number and then quit. .TP \fB-w\fP FILE Write the raw packets to a file, rather than the screen. The packets will not be parsed. The file can be read with the '-r' option. .TP \fB-x\fP Hex dump mode. After processing each layer, dump out the contents of that layer in hex and text. Only valid in main mode. .TP \fBexpr\fP Berkeley packet filter expression. See tcpdump(8) man page for details and examples. .SH SEE ALSO tcpdump(8) .SH NOTES Requires libpcap version 0.3 or greater to be installed. .SH AUTHOR Michael S. Borella .br http://www.borella.net/mike/ .br mike@borella.net ipgrab-0.9.10/doc/ipgrab.texi0000644000175000001440000010306710644705646015202 0ustar farooqusers\input texinfo @c -*-texinfo-*- @c %**start of header @c @c $Id: ipgrab.texi,v 1.23 2007/07/10 13:37:42 farooq-i-azam Exp $ @c @setfilename ipgrab.info @settitle IPgrab @dircategory Networking @c For double-sided printing, uncomment: @c @setchapternewpage odd @c %**end of header @include version.texi @iftex @finalout @end iftex @ifinfo @format START-INFO-DIR-ENTRY * IPgrab: (ipgrab). Verbose Packet Sniffer END-INFO-DIR-ENTRY @end format IPgrab, verbose packet sniffer, by Mike Borella This file documents the IPgrab packet sniffer. Copyright (C) 1997-2007, Mike Borella Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. @ignore Permission is granted to process this file through TeX and print the results, provided the printed document carries copying permission notice identical to this one except for the removal of this paragraph (this paragraph not being relevant to the printed manual). @end ignore Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Author. @end ifinfo @titlepage @title IPgrab @subtitle Verbose Packet Sniffer @subtitle Edition @value{EDITION}, for IPgrab version @value{VERSION} @subtitle @value{UPDATED} @author Mike Borella @page @vskip 0pt plus 1filll Copyright @copyright{} 1997-2002, Mike Borella Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Author. @end titlepage @c TABLE OF CONTENTS @contents @c Define an environment variable index. @defcodeindex ev @c Define an output variable index. @defcodeindex ov @c Define a CPP variable index. @defcodeindex cv @c Define a macro index that @@defmac doesn't write to. @defcodeindex ma @node Top, Introduction, (dir), (dir) @comment node-name, next, previous, up @ifinfo This file documents IPgrab, a packet sniffer that allows rather verbose description of network packets. This is edition @value{EDITION}, for IPgrab version @value{VERSION}. @end ifinfo @c The master menu, created with texinfo-master-menu, goes here. @menu * Introduction:: Overview of IPgrab * Guidelines for Use:: How to get the most out of IPgrab * Status:: * History:: History of the project * Index:: @end menu @c CHAPTER @node Introduction, Guidelines for Use, Top, Top @chapter Introduction You don't really understand networks until you've watched traffic on the wire. I believe strongly in this statement. In fact, I believe in it so strongly that I've been devleoping a packet sniffer so that all of us can learn about networking this way. A packet sniffer is an application layer program that interacts with one or more layer two or layer three kernel modules or device drivers to capture packets on a network. The lower-layer pieces read the packet off the wire, copy it into memory, and provide an API for an application to read it. An application, such as IPgrab, can do whatever it likes with the resulting image of a packet. Packet sniffers have been used for many years to detect network problems, troubleshoot protocols, and detect intruders. Traditionally, packet sniffers have displayed the captured packets in brief, rather cryptic formats. IPgrab is my humble attempt to make most, and eventually all, network protocols readable. It currently supports a wide variety of IP-related protocols, including some of the newer IP telephony protocols such as SIP and MGCP, as well as IPv6. IPgrab also decodes basic IPX and NETBIOS packets. @cindex Contact info The center of all IPgrab development, testing, and communication is hosted on SourceForge at @uref{http://ipgrab.sourceforge.net/}. You may mail suggestions and bug reports for to me at @email{mike@@borella.net} or Muhammad Farooq-i-Azam @email{farooq@@chase.org.pk} who currently helps coordination of development activites of the project. @c CHAPTER @node Guidelines for Use, Status, Introduction, Top @chapter Guidelines for Use IPgrab can be used in a number of ways, for a number of purposes. In this section we provide a brief overview of IPgrab's two modes and its command-line options. @cindex Main mode @section Main Mode Main mode is the default mode for IPgrab output. It is extremely verbose, displaying each field from all packet headers and protocols that it understands across a separate line of text. Banners separate different layers of protocol output. Single packets may require more than 100 lines in order to be displayed. Main mode is most useful if you need to know why or when a certain field or fields take on certain values. Below is an example of main mode formatting of a TCP packet. @example ************************************************************************** Ethernet (990036574.132701) -------------------------------------------------------------------------- Hardware source: 00:80:3e:57:b4:cf Hardware destination: 01:00:5e:00:01:16 Type / Length: 0x800 (IP) Media length: 192 -------------------------------------------------------------------------- IP Header -------------------------------------------------------------------------- Version: 4 Header length: 5 (20 bytes) TOS: 0x00 Total length: 178 Identification: 16 Fragmentation offset: 0 Unused bit: 0 Don't fragment bit: 0 More fragments bit: 0 Time to live: 29 Protocol: 17 (UDP) Header checksum: 33315 Source address: 149.112.164.129 Destination address: 224.0.1.22 -------------------------------------------------------------------------- UDP Header -------------------------------------------------------------------------- Source port: 1026 (unknown) Destination port: 427 (SLP) Length: 158 Checksum: 17593 -------------------------------------------------------------------------- SLPv1 Header -------------------------------------------------------------------------- Version: 1 Operation: 1 (service request) Length: 150 Flags/Reserved: 0x00 Dialect: 0 Language code: en Character encoding: 1000 XID: 6365 @end example In general, IPgrab does not attempt to "interpret" the values of a packet. For example, the IP TOS field is displayed in its raw value of 0x00. If there is an interpretation or further explanation of a field, IPgrab puts it in parenthesis following the raw value. For example, the IP header lenght field is displayed in its raw form of 5 followed by an interpretation of the number of bytes that this value represents. Likewise, the TCP source port is 23, which IPgrab recognizes as the telnet port. Note that IPgrab adds a timestamp to the banner for each link layer packet. @cindex Minimal mode @section Minimal Mode IPgrab also supports a minimal mode in which all information about all parts of a packet are displayed in a single line of text. This line may be longer than 80 characters and thus wrap around a standard terminal window one or more times. Below is an example of minimal mode formatting of a TCP packet. @example 1 990038240.206509 | ETH 00:b0:d0:11:a4:d0->ff:ff:ff:ff:ff:ff | IP 149.112.90.171->149.112.90.255 (len:78,id:29629,frag:0) | UDP 137->137 | NETBIOS NS query 3-COM @end example Minimal mode begins with a number (in this case, the number 1 indicates that this packet is the first one read) and a timestamp, and then parses the packet from link layer to application layer. Each layer begins with an abbreviation of the protocol being displayed (such as ETH, IP, and UDP, above). These abbreviations are followed by only the most relevant fields of the protocol. For example, IP source and destination addresses are shown, along with the total length field and the DF bit (if set) in parentheses. Likewise, UDP source and destination ports are shown. @cindex Command line options @section Command Line Options Both main mode and minimal mode output can be adjusted by specifying one or more commend line options. In this section, we provide a complete list of IPgrab's command line options and their use. The usage of IPgrab is briefly described as follows. @command{ipgrab [-blmnPprTtwx] [-c|--count n] [-h|--help] [-i|--interface if] [BPF expr]} The BPF expression is a string of terms that is acceptable to the Berkeley Packet Filter. For more details on the BPF expression grammar, see the tcpdump manual page. @itemize @bullet @item @command{-a}. Don't display application layer data. @item @command{-b}. Turn off buffering of standard output (stdout) so that all displaying occurs as soon as possible. Useful when IPgrab output is being re-directed to a file. @item @command{-c n / --count n}. Terminate after reading and displaying the first n packets. @item @command{-C proto / --CCP proto}. Assume a particular CCP protocol, such as MPPC. MPPC is the only one supported today. @item @command{-d}. Dump extra padding in packets. For example, according to an IP header, the packet ends at a certain point, but the link layer may have padded it beyond that. This option displays the padding. Not valid in minimal mode. @item @command{-h / --help}. Display usage screen with a brief description of the command line options. @item @command{-i if / --interface if}. Makes IPgrab listen to packets on interface if. If this option is not used, the default interface will be assumed. @item @command{-l}. Don't display link layer headers. The following protocols are considered to be link layer: ARP, CHAP, Ethernet, IPCP, LCP, LLC, Loopback, PPP, PPPoE, Raw, Slip, . @item @command{-m}. Minimal mode output. @item @command{-n}. Don't display network layer headers. The following protocols are considered to be network layer: AH, ESP, GRE, ICMP, ICMPv6, IGMP, IP, IPv6, IPX, IPXRIP. @item @command{-P}. Initiate a dynamic port mapping. This option must be followed by a string of the form `=', such as `rtp=6569'. @item @command{-p}. Dump packet payloads beyond what IPgrab parses. In other words, if IPgrab doesn't parse a particular application, this option will dump the application data in hex and text format. @item @command{-r}. Read packets from a file, rather than an interface. The file should be created in "raw" format, such as with @option{-w} option. @item @command{-T}. Don't display timestamps in minimal mode. @item @command{-t}. Don't display transport layer headers. The following protocols are considered to be transport layer: SPX, TCP, UDP. @item @command{-v}. Display version number then quit. @item @command{-w}. Write the raw packets to a file, rather than the screen. The packets will not be parsed. The file can be read with the @option{-r} option. @item @command{-x}. Hex dump mode. After processing each layer, dump out the contents of that layer in hex and text. Only valid in main mode. @end itemize @section Examples @itemize @bullet @item Only ICMP packets will be displayed using main mode without link layer headers. Command: @command{ipgrab -l icmp} Output: @example ************************************************************************** IP Header -------------------------------------------------------------------------- Version: 4 Header length: 5 (20 bytes) TOS: 0x00 Total length: 84 Identification: 0 Fragmentation offset: 0 Unused bit: 0 Don't fragment bit: 1 More fragments bit: 0 Time to live: 64 Protocol: 1 (ICMP) Header checksum: 42625 Source address: 149.112.90.225 Destination address: 198.147.221.66 -------------------------------------------------------------------------- ICMP Header -------------------------------------------------------------------------- Type: 8 (echo request) Code: 0 Checksum: 43361 Identifier: 15353 Sequence number: 0 @end example @item Only packets arriving on interface eth1 with a source port of 21 (FTP) will be displayed in minimal mode. Command: @command{ipgrab -i eth1 -m src port 21} Output: @example 1 990038936.642292 | ETH 00:80:3e:57:b4:cf->00:50:04:32:0e:8f | IP 198.147.221.66->149.112.90.225 (len:64,id:18353,DF,frag:0) | TCP 21->1047 (SA,3123051349,2290714856,9856) @end example @end itemize @c CHAPTER @node Status, History, Guidelines for Use, Top @chapter Status of Protocol Modules In this section we discuss the status of each of the protocol modules. While some protocols may be fully supported and well tested, other modules may only have partial support or may not have been tested fully. @cindex Authentication Header @cindex AH @section Authentication Header (AH) @itemize @bullet @item Module: @command{ah.c} @item Support: Full. @item Maturity: Not tested. @item Notes: AH typically appears between IP and TCP/UDP headers in order to apply IPsec-based authentication. @end itemize @cindex Address Resolution Protocol @cindex ARP @cindex Reverse Address Resolution Protocol @cindex RARP @section Address Resolution Protocol (ARP) @itemize @bullet @item Module: @command{arp.c} @item Support: Partial (only supports IP over Ethernet). @item Maturity: Well tested. @item Notes: Originally, ARP was defined to support address resolution of network layer protocol x over link layer protocol y. Currently, IP over Ethernet is by far the most used mode of ARP, and thus is the only one supported. @end itemize @cindex Callback Control Protocol @cindex CBCP @section Callback Control Protocol (CBCP) @itemize @bullet @item Module: @command{cbcp.c} @item Support: Partial. @item Maturity: Well tested. @item Notes: This protocol runs over PPP and allows a client to request that the server calls back. We only support very basic negotiation that is seen in the Windows 2000 VPN client. @end itemize @cindex Compression Control Protocol @cindex CCP @section Compression Control Protocol (CBCP) @itemize @bullet @item Module: @command{ccp.c} @item Support: Partial. @item Maturity: Well tested. @item Notes: CCP negotiates a compression algorithm for PPP and its associated parameters. Since the protocol used is stateful, we need a hint in order to decode the header portion. Such a hint can be provided the -C option (see above). However, this limits us to decoding only one CCP-negotiated protocol at a time. @end itemize @cindex Challenge Handshake Authentication Protocol @cindex CHAP @section Challenge Handshake Authentication Protocol (CHAP) @itemize @bullet @item Module: @command{chap.c} @item Support: Full. @item Maturity: Well tested. @item Notes: CHAP authenticates the ends of a PPP session to one another. @end itemize @cindex Dynamic Host Configuration Protocol @cindex DHCP @section Dynamic Host Configuration Protocol (DHCP) @itemize @bullet @item Module: @command{dhcp.c} @item Support: Partial (doesn't support all options). @item Maturity: Well tested. @item Notes: DHCP is an extensibly protocol with a large number of officially sanctioned options, and a number of de facto options. Currently we support many of the most common, but not all, of these options. @end itemize @cindex Domain Name System @cindex DNS @section Domain Name System (DNS) @itemize @bullet @item Module: @command{dns.c} @item Support: Partial (doesn't support all record types). @item Maturity: Well tested. @item Notes: Currently, we support records of type A, AAAA, CNAME, NS, SOA, and PTR. Other record types, such as A6, MX, and SRV, are not supported. @end itemize @cindex Encapsulating Security Payload @cindex ESP @section Encapsulating Security Payload (ESP) @itemize @bullet @item Module: @command{esp.c} @item Support: Partial (doesn't decrypt packets nor decode ESP trailer). @item Maturity: Not tested. @item Notes: ESP typically appears between IP and TCP/UDP headers in order to apply IPsec-based encryption and/or authentication. We do not attempt to decode encrypted packets because this would require adding state to IPgrab, which is something that we'd rather not do. This prevents us from displaying the ESP trailer as well. As soon as an ESP header is read and the plaintext portion is displayed, we halt processing of the rest of the packet. @end itemize @cindex Ethernet @section Ethernet @itemize @bullet @item Module: @command{ethernet.c} @item Support: Full, expcept that not all Ethernet types are recognized, and 802.1p and VLANs are not supported. @item Maturity: Well tested. @item Notes: Supported Ethernet types include IP, IPv6, PPP, ARP, RARP, and IPX. LLC encapsulation is supported in the LLC module. @end itemize @cindex File Transfer Protocol: Control @cindex FTP @section File Transfer Protocol (FTP): Control @itemize @bullet @item Module: @command{ftpctrl.c} @item Support: Full. @item Maturity: Well tested. @item Notes: @end itemize @cindex Generic Routing Encapsulation @cindex GRE @section Generic Routing Encapsulation @itemize @bullet @item Module: @command{gre.c} @item Support: Full for versions 0 and 1. @item Maturity: Well tested. @item Notes: Version 1 is defined in the PPTP RFC. @end itemize @cindex Hypertext Transfer Protocol @cindex HTTP @section Hypertext Transfer Protocol @itemize @bullet @item Module: @command{http.c} @item Support: Full (displays only headers). @item Maturity: Well tested. @item Notes: Parses and displays HTTP headers only. The rest of the payload is skipped. @end itemize @cindex Internet Control Message Protocol @cindex ICMP @section Internet Control Message Protocol @itemize @bullet @item Module: @command{icmp.c} @item Support: Partial. @item Maturity: Well tested. @item Notes: Displays all ICMP types and codes, but does not parse specific payloads for some lesser-used ICMP types, such as source quench, and redirect. Also does not handle Mobile IP extensions (yet). @end itemize @cindex Internet Control Message Protocol Version 6 @cindex ICMPv6 @section Internet Control Message Protocol Version 6 @itemize @bullet @item Module: @command{icmpv6.c} @item Support: Partial. @item Maturity: Well tested. @item Notes: Not all types and codes are explicitly parsed. @end itemize @cindex Internet Group Message Protocol @cindex IGMP @section Internet Group Message Protocol @itemize @bullet @item Module: @command{igmp.c} @item Support: Partial. @item Maturity: Well tested. @item Notes: IGMPv1 and v2 are supported. IGMPv3 is not tested and may not be cleanly supported. @end itemize @cindex Internet Protocol @cindex IP @section Internet Protocol @itemize @bullet @item Module: @command{ip.c} @item Support: Full. @item Maturity: Well tested. @item Notes: Full support for the IP header and options. TOS/DS byte is not interpreted in any particular fashion. @end itemize @cindex Internet Protocol Control Protocol @cindex IP @section Internet Protocol Control Protocol @itemize @bullet @item Module: @command{ipcp.c} @item Support: Partial. @item Maturity: Well tested. @item Notes: Full support for common messages and options. Some options may not be supported. @end itemize @cindex Internet Protocol Version 6 @cindex IPv6 @section Internet Protocol Version 6 @itemize @bullet @item Module: @command{ipv6.c} @item Support: Partial. @item Maturity: Well tested. @item Notes: Full support for the IPv6 header, except that IPv6 addresses are not displayed in the proper shorthand. @end itemize @cindex Internet Packet Exchange @cindex IPX @section Internet Packet Exchange @itemize @bullet @item Module: @command{ipx.c} @item Support: Partial. @item Maturity: Well tested. @item Notes: Full support for the IPX header, but not all transport protocols and applications are supported, nor are the header fields interpretated as well as they could be. @end itemize @cindex Internet Packet Exchange Routing Information Protocol @cindex IPXRIP @section Internet Packet Exchange Routing Information Protocol @itemize @bullet @item Module: @command{ipxrip.c} @item Support: Partial. @item Maturity: Well tested. @item Notes: Basic listing of the routes. @end itemize @cindex Internet Key Exchange @cindex IKE @section Internet Key Exchange See Internet Security Association and Key Management Protocol. @cindex Internet Security Association and Key Management Protocol @cindex ISAKMP @section Internet Security Association and Key Management Protocol @itemize @bullet @item Module: @command{isakmp.c} @item Support: Partial. @item Maturity: Well tested against Windows 2000 only. @item Notes: Only the following ISAKMP headers are supported: delete, SA, vendor ID, proposal, transform. @end itemize @cindex Layer 2 Tunneling Protocol @cindex L2TP @section Layer 2 Tunneling Protocol @itemize @bullet @item Module: @command{l2tp.c} @item Support: Partial. @item Maturity: Well tested. @item Notes: Only the most common message types are supported. @end itemize @cindex Link Control Protocol @cindex LCP @section Link Control Protocol @itemize @bullet @item Module: @command{lcp.c} @item Support: Partial. @item Maturity: Well tested. @item Notes: Not all NCPs are tested for. @end itemize @cindex Logical Link Control @cindex LLC @section Logical Link Control @itemize @bullet @item Module: @command{llc.c} @item Support: Partial. @item Maturity: Partially tested. @item Notes: Some basic cases such as IP and IPX encapsulation work reasonably well, but other common cases are not supported. Basically, this module needs a re-write. @end itemize @cindex Loopback @section Loopback @itemize @bullet @item Module: @command{loopback.c} @item Support: Full. @item Maturity: Fully tested. @item Notes: Some loopback interfaces, Redhat Linux 6.2 for example, present themselves as Ethernet interfaces, where all Ethernet addresses are zeroed out. Strange but true. @end itemize @cindex Media Gateway Control Protocol @cindex MGCP @section Media Gateway Control Protocol @itemize @bullet @item Module: @command{mgcp.c} @item Support: Partial. @item Maturity: Not tested. @item Notes: Use at your own risk. @end itemize @cindex Mobile IP @cindex MIP @section Mobile IP @itemize @bullet @item Module: @command{mobileip.c} @item Support: Partial. @item Maturity: Well tested. @item Notes: Not all extensions are supported. Support for the CDMA2000 A11 interface is also in this module. We support registration update and registration acknowledgement, as well as some of the extensions. @end itemize @cindex Microsoft Point-to-Point Compression Protocol @cindex MPPC @section Microsoft Point-to-Point Compression Protocol (MPPC) @itemize @bullet @item Module: @command{mppc.c} @item Support: Partial. @item Maturity: Well tested. @item Notes: Since we are not guaranteed to know the compression state, we are not able to decode the compressed section. We only decode the header. In order to decode MPPC packets, "-C MPPC" must be specified on the command line. @end itemize @cindex NETBIOS Name Service @cindex NETBIOS @section NETBIOS Name Service @itemize @bullet @item Module: @command{netbios_ns.c} @item Support: Full. @item Maturity: Well tested. @item Notes: DNS-like protocol for NETBIOS. @end itemize @cindex Network News Transfer Protocol @cindex NNTP @section Network News Transfer Protocol (NNTP) @itemize @bullet @item Module: @command{nntp.c} @item Support: Full. @item Maturity: Well tested. @item Notes: Just dumps the raw text of the messages, as that's all there is. @end itemize @cindex Open Shortest Path First @cindex OSPF @section Open Shortest Path First @itemize @bullet @item Module: @command{ospf.c} @item Support: Partial. @item Maturity: Well tested. @item Notes: Only hello messages are supported. @end itemize @cindex Point to Point Protocol @cindex PPP @section Point to Point Protocol @itemize @bullet @item Module: @command{ppp.c} @item Support: Partial. @item Maturity: Well tested. @item Notes: Most systems will not let you sniff native PPP packets, as their headers are usually stripped off before the kernel gives the packet to the sniffer. However, when you use PPTP or L2TP, PPP is avilable to a sniffer. Thus all testing was done using tunneling modes, rather than native mode. Note that some tunnel configurations may fragment a single incoming PPP frame into multiple tunneled packets. In this case, it is not clear what ipgrab will do (probably something strange). We currently do not decode HDLC-mode (control escape) PPP packets. @end itemize @cindex PPP Over Ethernet @cindex PPPOE @section PPP Over Ethernet @itemize @bullet @item Module: @command{pppoe.c} @item Support: Full. @item Maturity: Not tested. @item Notes: This is a contributed module. I have not tested it, but the contributor has. @end itemize @cindex Point to Point Tunneling Protocol @cindex PPTP @section Point to Point Tunneling Protocol @itemize @bullet @item Module: @command{pptp.c} @item Support: Partial. @item Maturity: Well tested. @item Notes: Not all message types are supported, but the most common ones are. @end itemize @cindex RADIUS @section RADIUS @itemize @bullet @item Module: @command{radius.c} @item Support: Partial. @item Maturity: Well tested. @item Notes: Most attributes from RFC 2865 and RFC 2866 are supported. Additionally, most 3GPP2 vendor-specific attributes are supported. @end itemize @cindex Raw IP @section Raw IP @itemize @bullet @item Module: @command{raw.c} @item Support: Full. @item Maturity: Well tested. @item Notes: This is a default datalink type for native IP. Since most kernel don't let us look at native PPP frames, most packets on a PPP interface will be interpreted as raw. @end itemize @cindex Routing Information Protocol @cindex RIP @section Routing Information Protocol @itemize @bullet @item Module: @command{rip.c} @item Support: Partial. @item Maturity: Well tested. @item Notes: RIPv1 was tested extensively. RIPv2 was not tested. @end itemize @cindex Routing Information Protocol (Next Generation) @cindex RIPng @cindex RIPv6 @section Routing Information Protocol (Next Generation) @itemize @bullet @item Module: @command{ripng.c} @item Support: Full. @item Maturity: Well tested. @item Notes: @end itemize @cindex Real Time Control Protocol @cindex RTCP @section Real Time Control Protocol (RTP) @itemize @bullet @item Module: @command{rtcp.c} @item Support: Partial. @item Maturity: Well tested. @item Notes: In order to use this module, you'll need to notify IPgrab of proper port number on which to expect the RTP traffic. Use the @command{-P} option to do this. IPgrab will assume that the next highest port belongs to RTCP. Only sender reports, receiver reports and source description packets. @end itemize @cindex Real Time Protocol @cindex RTP @section Real Time Protocol (RTP) @itemize @bullet @item Module: @command{rtp.c} @item Support: Partial. @item Maturity: Well tested. @item Notes: In order to use this module, you'll need to notify IPgrab of proper port number on which to expect the RTP traffic. Use the @command{-P} option to do this. @end itemize @cindex Session Description Protocol @cindex SDP @section Session Description Protocol @itemize @bullet @item Module: @command{sdp.c} @item Support: Full. @item Maturity: Well tested. @item Notes: Displays the headers in plain format with no interpretation. Does not display anything in minimal mode. @end itemize @cindex Session Initiation Protocol @cindex SIP @section Session Initiation Protocol @itemize @bullet @item Module: @command{sip.c} @item Support: Full. @item Maturity: Well tested. @item Notes: Displays the headers in plain format with no interpretation. @end itemize @cindex Serial Line IP @cindex SLIP @section Serial Line IP @itemize @bullet @item Module: @command{slip.c} @item Support: Full. @item Maturity: Not tested. @item Notes: @end itemize @cindex Service Location Protocol @cindex SLP @section Service Location Protocol @itemize @bullet @item Module: @command{slp.c} @item Support: Partial. @item Maturity: Well tested. @item Notes: Only basic forms of version 1 are supported. @end itemize @cindex Simple Network Management Protocol @cindex SNMP @section Simple Network Management Protocol @itemize @bullet @item Module: @command{snmp.c} @item Support: Partial. @item Maturity: Well tested. @item Notes: This module only displays the most basic information about captured SNMP packets. Very little functionality is supported. @end itemize @cindex Sequenced Packet Exchange @cindex SPX @section Sequenced Packet Exchange @itemize @bullet @item Module: @command{spx.c} @item Support: Partial. @item Maturity: Well tested. @item Notes: Not all applications are supported. @end itemize @cindex Secure Shell @cindex SSH @section Secure Shell @itemize @bullet @item Module: @command{ssh.c} @item Support: Partial. @item Maturity: Well tested. @item Notes: Only the initial version number exchange is supported. @end itemize @cindex Transmission Control Protocol @cindex TCP @section Transmission Control Protocol @itemize @bullet @item Module: @command{tcp.c} @item Support: Partial. @item Maturity: Well tested. @item Notes: Not all options are well supported. Program might crash on assorted nastygrams. In the minimal mode output, there are four parameters following the port numbers. They are, in order: a list of all flags that are set, the sequence number, the acknowledgement number, and the advertized window size. @end itemize @cindex Trivial File Transfer Protocol @cindex TFTP @section Trivial File Transfer Protocol (TFTP) @itemize @bullet @item Module: @command{tftp.c} @item Support: Full. @item Maturity: Well tested. @item Notes: Displays all associated parameters. Figures out port number of transfer on the fly. @end itemize @cindex User Datagram Protocol @cindex UDP @section User Datagram Protocol @itemize @bullet @item Module: @command{udp.c} @item Support: Full. @item Maturity: Fully tested. @item Notes: @end itemize @c CHAPTER @node History, Index, Status, Top @chapter History @cindex History Like many other folks, I started using @command{tcpdump} after reading Rich Stevens' wonderful book, @emph{TCP/IP Illustrated Vol. 1}. Each packet is summarized in a single compact, but slightly cryptic, line of output. While @command{tcpdump} remained a classic, around 1997 development had slowed quite a bit. Support for new protocols was not being added to the official distribution, and understanding and modifying the existing code could be trying. I felt the need to provide a more general packet sniffer that not only displayed @emph{all} of a packet's fields, but was written in a way that could easily be read, understood, and modified. In Fall 1997 I developed the first few versions of IPgrab. They were very tentative, just displaying Ethernet, IP, TCP, and UDP fields. For the most part, they only compiled on Linux. But I had gotten a taste of how useful such a tool could be. I used IPgrab to find out that Windows NT 4.0 incremented IP identification fields by 256 instead of 1, and to find out that a LAN router wasn't proxy ARPing correctly. Over the next two years I added features to IPgrab. Most of the work was done in my spare time, and progress was slow. Occasionally I received a very useful patch from a user. I also worked on porting it to other systems besides Linux -- in particular, FreeBSD and Solaris. By mid-1999, IPgrab was stable (version 0.8.2) and supported a number of rather complex protocol suites, such as IPsec, L2TP and some VoIP protocols. I didn't do much work until April 2000, when I decided to host it on Sourceforge.net. It was time for a massive overhaul. Development took three major angles: (1) New APIs for safe reading from a packet and displaying to an output device, (2) a line-based minimal output mode comparable to @command{tcpdump}, and (3) more protocol support. In particular, the APIs took a while to get right, but now they're in place and work really well. This required a re-write of every module, resulted in an overall cleanup of the code. Release 0.9 was the first official release with these new features. The releases since 0.9 have added support for more protocols, cleaned up the architecture, and fixed bugs. @command{tcpdump} development is once again underway and there are many freeware and open source packet sniffers available that do much of what IPgrab does. However, I've continued to develop IPgrab for a number of reasons. In particular, new protocols are being designed so quickly by the IETF and other organizations that it becomes very useful to be able to add these protocols quickly to a sniffer. Some of the extensions to IETF protocols that are defined by other Standards Development Organizations are typically not supported in sniffers. Also, developing IPgrab gives me a reason to stay on top of protocol developments and keep my hands dirty with coding. @node Index, , History, Top @chapter Index @printindex cp @bye ipgrab-0.9.10/doc/mdate-sh0000755000175000001440000000516707106626056014471 0ustar farooqusers#!/bin/sh # Get modification time of a file or directory and pretty-print it. # Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. # written by Ulrich Drepper , June 1995 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Prevent date giving response in another language. LANG=C export LANG LC_ALL=C export LC_ALL LC_TIME=C export LC_TIME # Get the extended ls output of the file or directory. # On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below. if ls -L /dev/null 1>/dev/null 2>&1; then set - x`ls -L -l -d $1` else set - x`ls -l -d $1` fi # The month is at least the fourth argument # (3 shifts here, the next inside the loop). shift shift shift # Find the month. Next argument is day, followed by the year or time. month= until test $month do shift case $1 in Jan) month=January; nummonth=1;; Feb) month=February; nummonth=2;; Mar) month=March; nummonth=3;; Apr) month=April; nummonth=4;; May) month=May; nummonth=5;; Jun) month=June; nummonth=6;; Jul) month=July; nummonth=7;; Aug) month=August; nummonth=8;; Sep) month=September; nummonth=9;; Oct) month=October; nummonth=10;; Nov) month=November; nummonth=11;; Dec) month=December; nummonth=12;; esac done day=$2 # Here we have to deal with the problem that the ls output gives either # the time of day or the year. case $3 in *:*) set `date`; eval year=\$$# case $2 in Jan) nummonthtod=1;; Feb) nummonthtod=2;; Mar) nummonthtod=3;; Apr) nummonthtod=4;; May) nummonthtod=5;; Jun) nummonthtod=6;; Jul) nummonthtod=7;; Aug) nummonthtod=8;; Sep) nummonthtod=9;; Oct) nummonthtod=10;; Nov) nummonthtod=11;; Dec) nummonthtod=12;; esac # For the first six month of the year the time notation can also # be used for files modified in the last year. if (expr $nummonth \> $nummonthtod) > /dev/null; then year=`expr $year - 1` fi;; *) year=$3;; esac # The result. echo $day $month $year ipgrab-0.9.10/doc/texinfo.tex0000644000175000001440000054377207106626056015250 0ustar farooqusers% texinfo.tex -- TeX macros to handle Texinfo files. % $Id: texinfo.tex,v 1.1 2000/05/11 21:54:54 mborella Exp $ % % Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98 % Free Software Foundation, Inc. % % This texinfo.tex file is free software; you can redistribute it and/or % modify it under the terms of the GNU General Public License as % published by the Free Software Foundation; either version 2, or (at % your option) any later version. % % This texinfo.tex file is distributed in the hope that it will be % useful, but WITHOUT ANY WARRANTY; without even the implied warranty % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU % General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this texinfo.tex file; see the file COPYING. If not, write % to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, % Boston, MA 02111-1307, USA. % % In other words, you are welcome to use, share and improve this program. % You are forbidden to forbid anyone else to use, share and improve % what you give them. Help stamp out software-hoarding! % % Please try the latest version of texinfo.tex before submitting bug % reports; you can get the latest version from: % ftp://ftp.gnu.org/pub/gnu/texinfo.tex % /home/gd/gnu/doc/texinfo.tex on the GNU machines. % (and all GNU mirrors, see http://www.gnu.org/order/ftp.html) % ftp://tug.org/tex/texinfo.tex % ftp://ctan.org/macros/texinfo/texinfo.tex % (and all CTAN mirrors, finger ctan@ctan.org for a list). % The texinfo.tex in the texinfo distribution itself could well be out % of date, so if that's what you're using, please check. % % Send bug reports to bug-texinfo@gnu.org. % Please include a precise test case in each bug report, % including a complete document with which we can reproduce the problem. % % To process a Texinfo manual with TeX, it's most reliable to use the % texi2dvi shell script that comes with the distribution. For simple % manuals, however, you can get away with: % tex foo.texi % texindex foo.?? % tex foo.texi % tex foo.texi % dvips foo.dvi -o # or whatever, to process the dvi file. % The extra runs of TeX get the cross-reference information correct. % Sometimes one run after texindex suffices, and sometimes you need more % than two; texi2dvi does it as many times as necessary. % Make it possible to create a .fmt file just by loading this file: % if the underlying format is not loaded, start by loading it now. % Added by gildea November 1993. \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi % This automatically updates the version number based on RCS. \def\deftexinfoversion$#1: #2 ${\def\texinfoversion{#2}} \deftexinfoversion$Revision: 1.1 $ \message{Loading texinfo package [Version \texinfoversion]:} % If in a .fmt file, print the version number % and turn on active characters that we couldn't do earlier because % they might have appeared in the input file name. \everyjob{\message{[Texinfo version \texinfoversion]}\message{} \catcode`+=\active \catcode`\_=\active} % Save some parts of plain tex whose names we will redefine. \let\ptexb=\b \let\ptexbullet=\bullet \let\ptexc=\c \let\ptexcomma=\, \let\ptexdot=\. \let\ptexdots=\dots \let\ptexend=\end \let\ptexequiv=\equiv \let\ptexexclam=\! \let\ptexi=\i \let\ptexlbrace=\{ \let\ptexrbrace=\} \let\ptexstar=\* \let\ptext=\t % We never want plain's outer \+ definition in Texinfo. % For @tex, we can use \tabalign. \let\+ = \relax \message{Basics,} \chardef\other=12 % If this character appears in an error message or help string, it % starts a new line in the output. \newlinechar = `^^J % Set up fixed words for English if not already set. \ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi \ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi \ifx\putwordfile\undefined \gdef\putwordfile{file}\fi \ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi \ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi \ifx\putwordon\undefined \gdef\putwordon{on}\fi \ifx\putwordpage\undefined \gdef\putwordpage{page}\fi \ifx\putwordsection\undefined \gdef\putwordsection{section}\fi \ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi \ifx\putwordsee\undefined \gdef\putwordsee{see}\fi \ifx\putwordSee\undefined \gdef\putwordSee{See}\fi \ifx\putwordShortContents\undefined \gdef\putwordShortContents{Short Contents}\fi \ifx\putwordTableofContents\undefined\gdef\putwordTableofContents{Table of Contents}\fi % Ignore a token. % \def\gobble#1{} \hyphenation{ap-pen-dix} \hyphenation{mini-buf-fer mini-buf-fers} \hyphenation{eshell} \hyphenation{white-space} % Margin to add to right of even pages, to left of odd pages. \newdimen \bindingoffset \newdimen \normaloffset \newdimen\pagewidth \newdimen\pageheight % Sometimes it is convenient to have everything in the transcript file % and nothing on the terminal. We don't just call \tracingall here, % since that produces some useless output on the terminal. % \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% \ifx\eTeXversion\undefined \def\loggingall{\tracingcommands2 \tracingstats2 \tracingpages1 \tracingoutput1 \tracinglostchars1 \tracingmacros2 \tracingparagraphs1 \tracingrestores1 \showboxbreadth\maxdimen\showboxdepth\maxdimen }% \else \def\loggingall{\tracingcommands3 \tracingstats2 \tracingpages1 \tracingoutput1 \tracinglostchars1 \tracingmacros2 \tracingparagraphs1 \tracingrestores1 \tracingscantokens1 \tracingassigns1 \tracingifs1 \tracinggroups1 \tracingnesting2 \showboxbreadth\maxdimen\showboxdepth\maxdimen }% \fi % For @cropmarks command. % Do @cropmarks to get crop marks. % \newif\ifcropmarks \let\cropmarks = \cropmarkstrue % % Dimensions to add cropmarks at corners. % Added by P. A. MacKay, 12 Nov. 1986 % \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines \newdimen\cornerlong \cornerlong=1pc \newdimen\cornerthick \cornerthick=.3pt \newdimen\topandbottommargin \topandbottommargin=.75in % Main output routine. \chardef\PAGE = 255 \output = {\onepageout{\pagecontents\PAGE}} \newbox\headlinebox \newbox\footlinebox % \onepageout takes a vbox as an argument. Note that \pagecontents % does insertions, but you have to call it yourself. \def\onepageout#1{% \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi % \ifodd\pageno \advance\hoffset by \bindingoffset \else \advance\hoffset by -\bindingoffset\fi % % Do this outside of the \shipout so @code etc. will be expanded in % the headline as they should be, not taken literally (outputting ''code). \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}% \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}% % {% % Have to do this stuff outside the \shipout because we want it to % take effect in \write's, yet the group defined by the \vbox ends % before the \shipout runs. % \escapechar = `\\ % use backslash in output files. \indexdummies % don't expand commands in the output. \normalturnoffactive % \ in index entries must not stay \, e.g., if % the page break happens to be in the middle of an example. \shipout\vbox{% \ifcropmarks \vbox to \outervsize\bgroup \hsize = \outerhsize \line{\ewtop\hfil\ewtop}% \nointerlineskip \line{% \vbox{\moveleft\cornerthick\nstop}% \hfill \vbox{\moveright\cornerthick\nstop}% }% \vskip\topandbottommargin \line\bgroup \hfil % center the page within the outer (page) hsize. \ifodd\pageno\hskip\bindingoffset\fi \vbox\bgroup \fi % \unvbox\headlinebox \pagebody{#1}% \ifdim\ht\footlinebox > 0pt % Only leave this space if the footline is nonempty. % (We lessened \vsize for it in \oddfootingxxx.) % The \baselineskip=24pt in plain's \makefootline has no effect. \vskip 2\baselineskip \unvbox\footlinebox \fi % \ifcropmarks \egroup % end of \vbox\bgroup \hfil\egroup % end of (centering) \line\bgroup \vskip\topandbottommargin plus1fill minus1fill \boxmaxdepth = \cornerthick \line{% \vbox{\moveleft\cornerthick\nsbot}% \hfill \vbox{\moveright\cornerthick\nsbot}% }% \nointerlineskip \line{\ewbot\hfil\ewbot}% \egroup % \vbox from first cropmarks clause \fi }% end of \shipout\vbox }% end of group with \turnoffactive \advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi } \newinsert\margin \dimen\margin=\maxdimen \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} {\catcode`\@ =11 \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi % marginal hacks, juha@viisa.uucp (Juha Takala) \ifvoid\margin\else % marginal info is present \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi \dimen@=\dp#1 \unvbox#1 \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi \ifr@ggedbottom \kern-\dimen@ \vfil \fi} } % Here are the rules for the cropmarks. Note that they are % offset so that the space between them is truly \outerhsize or \outervsize % (P. A. MacKay, 12 November, 1986) % \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong} \def\nstop{\vbox {\hrule height\cornerthick depth\cornerlong width\cornerthick}} \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong} \def\nsbot{\vbox {\hrule height\cornerlong depth\cornerthick width\cornerthick}} % Parse an argument, then pass it to #1. The argument is the rest of % the input line (except we remove a trailing comment). #1 should be a % macro which expects an ordinary undelimited TeX argument. % \def\parsearg#1{% \let\next = #1% \begingroup \obeylines \futurelet\temp\parseargx } % If the next token is an obeyed space (from an @example environment or % the like), remove it and recurse. Otherwise, we're done. \def\parseargx{% % \obeyedspace is defined far below, after the definition of \sepspaces. \ifx\obeyedspace\temp \expandafter\parseargdiscardspace \else \expandafter\parseargline \fi } % Remove a single space (as the delimiter token to the macro call). {\obeyspaces % \gdef\parseargdiscardspace {\futurelet\temp\parseargx}} {\obeylines % \gdef\parseargline#1^^M{% \endgroup % End of the group started in \parsearg. % % First remove any @c comment, then any @comment. % Result of each macro is put in \toks0. \argremovec #1\c\relax % \expandafter\argremovecomment \the\toks0 \comment\relax % % % Call the caller's macro, saved as \next in \parsearg. \expandafter\next\expandafter{\the\toks0}% }% } % Since all \c{,omment} does is throw away the argument, we can let TeX % do that for us. The \relax here is matched by the \relax in the call % in \parseargline; it could be more or less anything, its purpose is % just to delimit the argument to the \c. \def\argremovec#1\c#2\relax{\toks0 = {#1}} \def\argremovecomment#1\comment#2\relax{\toks0 = {#1}} % \argremovec{,omment} might leave us with trailing spaces, though; e.g., % @end itemize @c foo % will have two active spaces as part of the argument with the % `itemize'. Here we remove all active spaces from #1, and assign the % result to \toks0. % % This loses if there are any *other* active characters besides spaces % in the argument -- _ ^ +, for example -- since they get expanded. % Fortunately, Texinfo does not define any such commands. (If it ever % does, the catcode of the characters in questionwill have to be changed % here.) But this means we cannot call \removeactivespaces as part of % \argremovec{,omment}, since @c uses \parsearg, and thus the argument % that \parsearg gets might well have any character at all in it. % \def\removeactivespaces#1{% \begingroup \ignoreactivespaces \edef\temp{#1}% \global\toks0 = \expandafter{\temp}% \endgroup } % Change the active space to expand to nothing. % \begingroup \obeyspaces \gdef\ignoreactivespaces{\obeyspaces\let =\empty} \endgroup \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} %% These are used to keep @begin/@end levels from running away %% Call \inENV within environments (after a \begingroup) \newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi} \def\ENVcheck{% \ifENV\errmessage{Still within an environment; press RETURN to continue} \endgroup\fi} % This is not perfect, but it should reduce lossage % @begin foo is the same as @foo, for now. \newhelp\EMsimple{Press RETURN to continue.} \outer\def\begin{\parsearg\beginxxx} \def\beginxxx #1{% \expandafter\ifx\csname #1\endcsname\relax {\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else \csname #1\endcsname\fi} % @end foo executes the definition of \Efoo. % \def\end{\parsearg\endxxx} \def\endxxx #1{% \removeactivespaces{#1}% \edef\endthing{\the\toks0}% % \expandafter\ifx\csname E\endthing\endcsname\relax \expandafter\ifx\csname \endthing\endcsname\relax % There's no \foo, i.e., no ``environment'' foo. \errhelp = \EMsimple \errmessage{Undefined command `@end \endthing'}% \else \unmatchedenderror\endthing \fi \else % Everything's ok; the right environment has been started. \csname E\endthing\endcsname \fi } % There is an environment #1, but it hasn't been started. Give an error. % \def\unmatchedenderror#1{% \errhelp = \EMsimple \errmessage{This `@end #1' doesn't have a matching `@#1'}% } % Define the control sequence \E#1 to give an unmatched @end error. % \def\defineunmatchedend#1{% \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}% } % Single-spacing is done by various environments (specifically, in % \nonfillstart and \quotations). \newskip\singlespaceskip \singlespaceskip = 12.5pt \def\singlespace{% % Why was this kern here? It messes up equalizing space above and below % environments. --karl, 6may93 %{\advance \baselineskip by -\singlespaceskip %\kern \baselineskip}% \setleading \singlespaceskip } %% Simple single-character @ commands % @@ prints an @ % Kludge this until the fonts are right (grr). \def\@{{\tt\char64}} % This is turned off because it was never documented % and you can use @w{...} around a quote to suppress ligatures. %% Define @` and @' to be the same as ` and ' %% but suppressing ligatures. %\def\`{{`}} %\def\'{{'}} % Used to generate quoted braces. \def\mylbrace {{\tt\char123}} \def\myrbrace {{\tt\char125}} \let\{=\mylbrace \let\}=\myrbrace \begingroup % Definitions to produce actual \{ & \} command in an index. \catcode`\{ = 12 \catcode`\} = 12 \catcode`\[ = 1 \catcode`\] = 2 \catcode`\@ = 0 \catcode`\\ = 12 @gdef@lbracecmd[\{]% @gdef@rbracecmd[\}]% @endgroup % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent % Others are defined by plain TeX: @` @' @" @^ @~ @= @v @H. \let\, = \c \let\dotaccent = \. \def\ringaccent#1{{\accent23 #1}} \let\tieaccent = \t \let\ubaraccent = \b \let\udotaccent = \d % Other special characters: @questiondown @exclamdown % Plain TeX defines: @AA @AE @O @OE @L (and lowercase versions) @ss. \def\questiondown{?`} \def\exclamdown{!`} % Dotless i and dotless j, used for accents. \def\imacro{i} \def\jmacro{j} \def\dotless#1{% \def\temp{#1}% \ifx\temp\imacro \ptexi \else\ifx\temp\jmacro \j \else \errmessage{@dotless can be used only with i or j}% \fi\fi } % Be sure we're in horizontal mode when doing a tie, since we make space % equivalent to this in @example-like environments. Otherwise, a space % at the beginning of a line will start with \penalty -- and % since \penalty is valid in vertical mode, we'd end up putting the % penalty on the vertical list instead of in the new paragraph. {\catcode`@ = 11 % Avoid using \@M directly, because that causes trouble % if the definition is written into an index file. \global\let\tiepenalty = \@M \gdef\tie{\leavevmode\penalty\tiepenalty\ } } % @: forces normal size whitespace following. \def\:{\spacefactor=1000 } % @* forces a line break. \def\*{\hfil\break\hbox{}\ignorespaces} % @. is an end-of-sentence period. \def\.{.\spacefactor=3000 } % @! is an end-of-sentence bang. \def\!{!\spacefactor=3000 } % @? is an end-of-sentence query. \def\?{?\spacefactor=3000 } % @w prevents a word break. Without the \leavevmode, @w at the % beginning of a paragraph, when TeX is still in vertical mode, would % produce a whole line of output instead of starting the paragraph. \def\w#1{\leavevmode\hbox{#1}} % @group ... @end group forces ... to be all on one page, by enclosing % it in a TeX vbox. We use \vtop instead of \vbox to construct the box % to keep its height that of a normal line. According to the rules for % \topskip (p.114 of the TeXbook), the glue inserted is % max (\topskip - \ht (first item), 0). If that height is large, % therefore, no glue is inserted, and the space between the headline and % the text is small, which looks bad. % \def\group{\begingroup \ifnum\catcode13=\active \else \errhelp = \groupinvalidhelp \errmessage{@group invalid in context where filling is enabled}% \fi % % The \vtop we start below produces a box with normal height and large % depth; thus, TeX puts \baselineskip glue before it, and (when the % next line of text is done) \lineskip glue after it. (See p.82 of % the TeXbook.) Thus, space below is not quite equal to space % above. But it's pretty close. \def\Egroup{% \egroup % End the \vtop. \endgroup % End the \group. }% % \vtop\bgroup % We have to put a strut on the last line in case the @group is in % the midst of an example, rather than completely enclosing it. % Otherwise, the interline space between the last line of the group % and the first line afterwards is too small. But we can't put the % strut in \Egroup, since there it would be on a line by itself. % Hence this just inserts a strut at the beginning of each line. \everypar = {\strut}% % % Since we have a strut on every line, we don't need any of TeX's % normal interline spacing. \offinterlineskip % % OK, but now we have to do something about blank % lines in the input in @example-like environments, which normally % just turn into \lisppar, which will insert no space now that we've % turned off the interline space. Simplest is to make them be an % empty paragraph. \ifx\par\lisppar \edef\par{\leavevmode \par}% % % Reset ^^M's definition to new definition of \par. \obeylines \fi % % Do @comment since we are called inside an environment such as % @example, where each end-of-line in the input causes an % end-of-line in the output. We don't want the end-of-line after % the `@group' to put extra space in the output. Since @group % should appear on a line by itself (according to the Texinfo % manual), we don't worry about eating any user text. \comment } % % TeX puts in an \escapechar (i.e., `@') at the beginning of the help % message, so this ends up printing `@group can only ...'. % \newhelp\groupinvalidhelp{% group can only be used in environments such as @example,^^J% where each line of input produces a line of output.} % @need space-in-mils % forces a page break if there is not space-in-mils remaining. \newdimen\mil \mil=0.001in \def\need{\parsearg\needx} % Old definition--didn't work. %\def\needx #1{\par % %% This method tries to make TeX break the page naturally %% if the depth of the box does not fit. %{\baselineskip=0pt% %\vtop to #1\mil{\vfil}\kern -#1\mil\nobreak %\prevdepth=-1000pt %}} \def\needx#1{% % Go into vertical mode, so we don't make a big box in the middle of a % paragraph. \par % % Don't add any leading before our big empty box, but allow a page % break, since the best break might be right here. \allowbreak \nointerlineskip \vtop to #1\mil{\vfil}% % % TeX does not even consider page breaks if a penalty added to the % main vertical list is 10000 or more. But in order to see if the % empty box we just added fits on the page, we must make it consider % page breaks. On the other hand, we don't want to actually break the % page after the empty box. So we use a penalty of 9999. % % There is an extremely small chance that TeX will actually break the % page at this \penalty, if there are no other feasible breakpoints in % sight. (If the user is using lots of big @group commands, which % almost-but-not-quite fill up a page, TeX will have a hard time doing % good page breaking, for example.) However, I could not construct an % example where a page broke at this \penalty; if it happens in a real % document, then we can reconsider our strategy. \penalty9999 % % Back up by the size of the box, whether we did a page break or not. \kern -#1\mil % % Do not allow a page break right after this kern. \nobreak } % @br forces paragraph break \let\br = \par % @dots{} output an ellipsis using the current font. % We do .5em per period so that it has the same spacing in a typewriter % font as three actual period characters. % \def\dots{% \leavevmode \hbox to 1.5em{% \hskip 0pt plus 0.25fil minus 0.25fil .\hss.\hss.% \hskip 0pt plus 0.5fil minus 0.5fil }% } % @enddots{} is an end-of-sentence ellipsis. % \def\enddots{% \leavevmode \hbox to 2em{% \hskip 0pt plus 0.25fil minus 0.25fil .\hss.\hss.\hss.% \hskip 0pt plus 0.5fil minus 0.5fil }% \spacefactor=3000 } % @page forces the start of a new page % \def\page{\par\vfill\supereject} % @exdent text.... % outputs text on separate line in roman font, starting at standard page margin % This records the amount of indent in the innermost environment. % That's how much \exdent should take out. \newskip\exdentamount % This defn is used inside fill environments such as @defun. \def\exdent{\parsearg\exdentyyy} \def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}} % This defn is used inside nofill environments such as @example. \def\nofillexdent{\parsearg\nofillexdentyyy} \def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount \leftline{\hskip\leftskip{\rm#1}}}} % @inmargin{TEXT} puts TEXT in the margin next to the current paragraph. \def\inmargin#1{% \strut\vadjust{\nobreak\kern-\strutdepth \vtop to \strutdepth{\baselineskip\strutdepth\vss \llap{\rightskip=\inmarginspacing \vbox{\noindent #1}}\null}}} \newskip\inmarginspacing \inmarginspacing=1cm \def\strutdepth{\dp\strutbox} %\hbox{{\rm#1}}\hfil\break}} % @include file insert text of that file as input. % Allow normal characters that we make active in the argument (a file name). \def\include{\begingroup \catcode`\\=12 \catcode`~=12 \catcode`^=12 \catcode`_=12 \catcode`|=12 \catcode`<=12 \catcode`>=12 \catcode`+=12 \parsearg\includezzz} % Restore active chars for included file. \def\includezzz#1{\endgroup\begingroup % Read the included file in a group so nested @include's work. \def\thisfile{#1}% \input\thisfile \endgroup} \def\thisfile{} % @center line outputs that line, centered \def\center{\parsearg\centerzzz} \def\centerzzz #1{{\advance\hsize by -\leftskip \advance\hsize by -\rightskip \centerline{#1}}} % @sp n outputs n lines of vertical space \def\sp{\parsearg\spxxx} \def\spxxx #1{\vskip #1\baselineskip} % @comment ...line which is ignored... % @c is the same as @comment % @ignore ... @end ignore is another way to write a comment \def\comment{\begingroup \catcode`\^^M=\other% \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other% \commentxxx} {\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}} \let\c=\comment % @paragraphindent is defined for the Info formatting commands only. \let\paragraphindent=\comment % Prevent errors for section commands. % Used in @ignore and in failing conditionals. \def\ignoresections{% \let\chapter=\relax \let\unnumbered=\relax \let\top=\relax \let\unnumberedsec=\relax \let\unnumberedsection=\relax \let\unnumberedsubsec=\relax \let\unnumberedsubsection=\relax \let\unnumberedsubsubsec=\relax \let\unnumberedsubsubsection=\relax \let\section=\relax \let\subsec=\relax \let\subsubsec=\relax \let\subsection=\relax \let\subsubsection=\relax \let\appendix=\relax \let\appendixsec=\relax \let\appendixsection=\relax \let\appendixsubsec=\relax \let\appendixsubsection=\relax \let\appendixsubsubsec=\relax \let\appendixsubsubsection=\relax \let\contents=\relax \let\smallbook=\relax \let\titlepage=\relax } % Used in nested conditionals, where we have to parse the Texinfo source % and so want to turn off most commands, in case they are used % incorrectly. % \def\ignoremorecommands{% \let\defcodeindex = \relax \let\defcv = \relax \let\deffn = \relax \let\deffnx = \relax \let\defindex = \relax \let\defivar = \relax \let\defmac = \relax \let\defmethod = \relax \let\defop = \relax \let\defopt = \relax \let\defspec = \relax \let\deftp = \relax \let\deftypefn = \relax \let\deftypefun = \relax \let\deftypevar = \relax \let\deftypevr = \relax \let\defun = \relax \let\defvar = \relax \let\defvr = \relax \let\ref = \relax \let\xref = \relax \let\printindex = \relax \let\pxref = \relax \let\settitle = \relax \let\setchapternewpage = \relax \let\setchapterstyle = \relax \let\everyheading = \relax \let\evenheading = \relax \let\oddheading = \relax \let\everyfooting = \relax \let\evenfooting = \relax \let\oddfooting = \relax \let\headings = \relax \let\include = \relax \let\lowersections = \relax \let\down = \relax \let\raisesections = \relax \let\up = \relax \let\set = \relax \let\clear = \relax \let\item = \relax } % Ignore @ignore ... @end ignore. % \def\ignore{\doignore{ignore}} % Ignore @ifinfo, @ifhtml, @ifnottex, @html, @menu, and @direntry text. % \def\ifinfo{\doignore{ifinfo}} \def\ifhtml{\doignore{ifhtml}} \def\ifnottex{\doignore{ifnottex}} \def\html{\doignore{html}} \def\menu{\doignore{menu}} \def\direntry{\doignore{direntry}} % @dircategory CATEGORY -- specify a category of the dir file % which this file should belong to. Ignore this in TeX. \let\dircategory = \comment % Ignore text until a line `@end #1'. % \def\doignore#1{\begingroup % Don't complain about control sequences we have declared \outer. \ignoresections % % Define a command to swallow text until we reach `@end #1'. % This @ is a catcode 12 token (that is the normal catcode of @ in % this texinfo.tex file). We change the catcode of @ below to match. \long\def\doignoretext##1@end #1{\enddoignore}% % % Make sure that spaces turn into tokens that match what \doignoretext wants. \catcode32 = 10 % % Ignore braces, too, so mismatched braces don't cause trouble. \catcode`\{ = 9 \catcode`\} = 9 % % We must not have @c interpreted as a control sequence. \catcode`\@ = 12 % % Make the letter c a comment character so that the rest of the line % will be ignored. This way, the document can have (for example) % @c @end ifinfo % and the @end ifinfo will be properly ignored. % (We've just changed @ to catcode 12.) \catcode`\c = 14 % % And now expand that command. \doignoretext } % What we do to finish off ignored text. % \def\enddoignore{\endgroup\ignorespaces}% \newif\ifwarnedobs\warnedobsfalse \def\obstexwarn{% \ifwarnedobs\relax\else % We need to warn folks that they may have trouble with TeX 3.0. % This uses \immediate\write16 rather than \message to get newlines. \immediate\write16{} \immediate\write16{***WARNING*** for users of Unix TeX 3.0!} \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).} \immediate\write16{If you are running another version of TeX, relax.} \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.} \immediate\write16{ Then upgrade your TeX installation if you can.} \immediate\write16{ (See ftp://ftp.gnu.ai.mit.edu/pub/gnu/TeX.README.)} \immediate\write16{If you are stuck with version 3.0, run the} \immediate\write16{ script ``tex3patch'' from the Texinfo distribution} \immediate\write16{ to use a workaround.} \immediate\write16{} \global\warnedobstrue \fi } % **In TeX 3.0, setting text in \nullfont hangs tex. For a % workaround (which requires the file ``dummy.tfm'' to be installed), % uncomment the following line: %%%%%\font\nullfont=dummy\let\obstexwarn=\relax % Ignore text, except that we keep track of conditional commands for % purposes of nesting, up to an `@end #1' command. % \def\nestedignore#1{% \obstexwarn % We must actually expand the ignored text to look for the @end % command, so that nested ignore constructs work. Thus, we put the % text into a \vbox and then do nothing with the result. To minimize % the change of memory overflow, we follow the approach outlined on % page 401 of the TeXbook: make the current font be a dummy font. % \setbox0 = \vbox\bgroup % Don't complain about control sequences we have declared \outer. \ignoresections % % Define `@end #1' to end the box, which will in turn undefine the % @end command again. \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}% % % We are going to be parsing Texinfo commands. Most cause no % trouble when they are used incorrectly, but some commands do % complicated argument parsing or otherwise get confused, so we % undefine them. % % We can't do anything about stray @-signs, unfortunately; % they'll produce `undefined control sequence' errors. \ignoremorecommands % % Set the current font to be \nullfont, a TeX primitive, and define % all the font commands to also use \nullfont. We don't use % dummy.tfm, as suggested in the TeXbook, because not all sites % might have that installed. Therefore, math mode will still % produce output, but that should be an extremely small amount of % stuff compared to the main input. % \nullfont \let\tenrm = \nullfont \let\tenit = \nullfont \let\tensl = \nullfont \let\tenbf = \nullfont \let\tentt = \nullfont \let\smallcaps = \nullfont \let\tensf = \nullfont % Similarly for index fonts (mostly for their use in % smallexample) \let\indrm = \nullfont \let\indit = \nullfont \let\indsl = \nullfont \let\indbf = \nullfont \let\indtt = \nullfont \let\indsc = \nullfont \let\indsf = \nullfont % % Don't complain when characters are missing from the fonts. \tracinglostchars = 0 % % Don't bother to do space factor calculations. \frenchspacing % % Don't report underfull hboxes. \hbadness = 10000 % % Do minimal line-breaking. \pretolerance = 10000 % % Do not execute instructions in @tex \def\tex{\doignore{tex}}% % Do not execute macro definitions. % `c' is a comment character, so the word `macro' will get cut off. \def\macro{\doignore{ma}}% } % @set VAR sets the variable VAR to an empty value. % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. % % Since we want to separate VAR from REST-OF-LINE (which might be % empty), we can't just use \parsearg; we have to insert a space of our % own to delimit the rest of the line, and then take it out again if we % didn't need it. Make sure the catcode of space is correct to avoid % losing inside @example, for instance. % \def\set{\begingroup\catcode` =10 \catcode`\-=12 \catcode`\_=12 % Allow - and _ in VAR. \parsearg\setxxx} \def\setxxx#1{\setyyy#1 \endsetyyy} \def\setyyy#1 #2\endsetyyy{% \def\temp{#2}% \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted. \fi \endgroup } % Can't use \xdef to pre-expand #2 and save some time, since \temp or % \next or other control sequences that we've defined might get us into % an infinite loop. Consider `@set foo @cite{bar}'. \def\setzzz#1#2 \endsetzzz{\expandafter\gdef\csname SET#1\endcsname{#2}} % @clear VAR clears (i.e., unsets) the variable VAR. % \def\clear{\parsearg\clearxxx} \def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax} % @value{foo} gets the text saved in variable foo. % { \catcode`\_ = \active % % We might end up with active _ or - characters in the argument if % we're called from @code, as @code{@value{foo-bar_}}. So \let any % such active characters to their normal equivalents. \gdef\value{\begingroup \catcode`\-=12 \catcode`\_=12 \indexbreaks \let_\normalunderscore \valuexxx} } \def\valuexxx#1{\expandablevalue{#1}\endgroup} % We have this subroutine so that we can handle at least some @value's % properly in indexes (we \let\value to this in \indexdummies). Ones % whose names contain - or _ still won't work, but we can't do anything % about that. The command has to be fully expandable, since the result % winds up in the index file. This means that if the variable's value % contains other Texinfo commands, it's almost certain it will fail % (although perhaps we could fix that with sufficient work to do a % one-level expansion on the result, instead of complete). % \def\expandablevalue#1{% \expandafter\ifx\csname SET#1\endcsname\relax {[No value for ``#1'']v}% \else \csname SET#1\endcsname \fi } % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined % with @set. % \def\ifset{\parsearg\ifsetxxx} \def\ifsetxxx #1{% \expandafter\ifx\csname SET#1\endcsname\relax \expandafter\ifsetfail \else \expandafter\ifsetsucceed \fi } \def\ifsetsucceed{\conditionalsucceed{ifset}} \def\ifsetfail{\nestedignore{ifset}} \defineunmatchedend{ifset} % @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been % defined with @set, or has been undefined with @clear. % \def\ifclear{\parsearg\ifclearxxx} \def\ifclearxxx #1{% \expandafter\ifx\csname SET#1\endcsname\relax \expandafter\ifclearsucceed \else \expandafter\ifclearfail \fi } \def\ifclearsucceed{\conditionalsucceed{ifclear}} \def\ifclearfail{\nestedignore{ifclear}} \defineunmatchedend{ifclear} % @iftex, @ifnothtml, @ifnotinfo always succeed; we read the text % following, through the first @end iftex (etc.). Make `@end iftex' % (etc.) valid only after an @iftex. % \def\iftex{\conditionalsucceed{iftex}} \def\ifnothtml{\conditionalsucceed{ifnothtml}} \def\ifnotinfo{\conditionalsucceed{ifnotinfo}} \defineunmatchedend{iftex} \defineunmatchedend{ifnothtml} \defineunmatchedend{ifnotinfo} % We can't just want to start a group at @iftex (for example) and end it % at @end iftex, since then @set commands inside the conditional have no % effect (they'd get reverted at the end of the group). So we must % define \Eiftex to redefine itself to be its previous value. (We can't % just define it to fail again with an ``unmatched end'' error, since % the @ifset might be nested.) % \def\conditionalsucceed#1{% \edef\temp{% % Remember the current value of \E#1. \let\nece{prevE#1} = \nece{E#1}% % % At the `@end #1', redefine \E#1 to be its previous value. \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}% }% \temp } % We need to expand lots of \csname's, but we don't want to expand the % control sequences after we've constructed them. % \def\nece#1{\expandafter\noexpand\csname#1\endcsname} % @asis just yields its argument. Used with @table, for example. % \def\asis#1{#1} % @math means output in math mode. % We don't use $'s directly in the definition of \math because control % sequences like \math are expanded when the toc file is written. Then, % we read the toc file back, the $'s will be normal characters (as they % should be, according to the definition of Texinfo). So we must use a % control sequence to switch into and out of math mode. % % This isn't quite enough for @math to work properly in indices, but it % seems unlikely it will ever be needed there. % \let\implicitmath = $ \def\math#1{\implicitmath #1\implicitmath} % @bullet and @minus need the same treatment as @math, just above. \def\bullet{\implicitmath\ptexbullet\implicitmath} \def\minus{\implicitmath-\implicitmath} % @refill is a no-op. \let\refill=\relax % If working on a large document in chapters, it is convenient to % be able to disable indexing, cross-referencing, and contents, for test runs. % This is done with @novalidate (before @setfilename). % \newif\iflinks \linkstrue % by default we want the aux files. \let\novalidate = \linksfalse % @setfilename is done at the beginning of every texinfo file. % So open here the files we need to have open while reading the input. % This makes it possible to make a .fmt file for texinfo. \def\setfilename{% \iflinks \readauxfile \fi % \openindices needs to do some work in any case. \openindices \fixbackslash % Turn off hack to swallow `\input texinfo'. \global\let\setfilename=\comment % Ignore extra @setfilename cmds. % % If texinfo.cnf is present on the system, read it. % Useful for site-wide @afourpaper, etc. % Just to be on the safe side, close the input stream before the \input. \openin 1 texinfo.cnf \ifeof1 \let\temp=\relax \else \def\temp{\input texinfo.cnf }\fi \closein1 \temp % \comment % Ignore the actual filename. } % Called from \setfilename. % \def\openindices{% \newindex{cp}% \newcodeindex{fn}% \newcodeindex{vr}% \newcodeindex{tp}% \newcodeindex{ky}% \newcodeindex{pg}% } % @bye. \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} \message{fonts,} % Font-change commands. % Texinfo sort of supports the sans serif font style, which plain TeX does not. % So we set up a \sf analogous to plain's \rm, etc. \newfam\sffam \def\sf{\fam=\sffam \tensf} \let\li = \sf % Sometimes we call it \li, not \sf. % We don't need math for this one. \def\ttsl{\tenttsl} % Use Computer Modern fonts at \magstephalf (11pt). \newcount\mainmagstep \mainmagstep=\magstephalf % Set the font macro #1 to the font named #2, adding on the % specified font prefix (normally `cm'). % #3 is the font's design size, #4 is a scale factor \def\setfont#1#2#3#4{\font#1=\fontprefix#2#3 scaled #4} % Use cm as the default font prefix. % To specify the font prefix, you must define \fontprefix % before you read in texinfo.tex. \ifx\fontprefix\undefined \def\fontprefix{cm} \fi % Support font families that don't use the same naming scheme as CM. \def\rmshape{r} \def\rmbshape{bx} %where the normal face is bold \def\bfshape{b} \def\bxshape{bx} \def\ttshape{tt} \def\ttbshape{tt} \def\ttslshape{sltt} \def\itshape{ti} \def\itbshape{bxti} \def\slshape{sl} \def\slbshape{bxsl} \def\sfshape{ss} \def\sfbshape{ss} \def\scshape{csc} \def\scbshape{csc} \ifx\bigger\relax \let\mainmagstep=\magstep1 \setfont\textrm\rmshape{12}{1000} \setfont\texttt\ttshape{12}{1000} \else \setfont\textrm\rmshape{10}{\mainmagstep} \setfont\texttt\ttshape{10}{\mainmagstep} \fi % Instead of cmb10, you many want to use cmbx10. % cmbx10 is a prettier font on its own, but cmb10 % looks better when embedded in a line with cmr10. \setfont\textbf\bfshape{10}{\mainmagstep} \setfont\textit\itshape{10}{\mainmagstep} \setfont\textsl\slshape{10}{\mainmagstep} \setfont\textsf\sfshape{10}{\mainmagstep} \setfont\textsc\scshape{10}{\mainmagstep} \setfont\textttsl\ttslshape{10}{\mainmagstep} \font\texti=cmmi10 scaled \mainmagstep \font\textsy=cmsy10 scaled \mainmagstep % A few fonts for @defun, etc. \setfont\defbf\bxshape{10}{\magstep1} %was 1314 \setfont\deftt\ttshape{10}{\magstep1} \def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf} % Fonts for indices and small examples (9pt). % We actually use the slanted font rather than the italic, % because texinfo normally uses the slanted fonts for that. % Do not make many font distinctions in general in the index, since they % aren't very useful. \setfont\ninett\ttshape{9}{1000} \setfont\ninettsl\ttslshape{10}{900} \setfont\indrm\rmshape{9}{1000} \setfont\indit\itshape{9}{1000} \setfont\indsl\slshape{9}{1000} \let\indtt=\ninett \let\indttsl=\ninettsl \let\indsf=\indrm \let\indbf=\indrm \setfont\indsc\scshape{10}{900} \font\indi=cmmi9 \font\indsy=cmsy9 % Fonts for title page: \setfont\titlerm\rmbshape{12}{\magstep3} \setfont\titleit\itbshape{10}{\magstep4} \setfont\titlesl\slbshape{10}{\magstep4} \setfont\titlett\ttbshape{12}{\magstep3} \setfont\titlettsl\ttslshape{10}{\magstep4} \setfont\titlesf\sfbshape{17}{\magstep1} \let\titlebf=\titlerm \setfont\titlesc\scbshape{10}{\magstep4} \font\titlei=cmmi12 scaled \magstep3 \font\titlesy=cmsy10 scaled \magstep4 \def\authorrm{\secrm} % Chapter (and unnumbered) fonts (17.28pt). \setfont\chaprm\rmbshape{12}{\magstep2} \setfont\chapit\itbshape{10}{\magstep3} \setfont\chapsl\slbshape{10}{\magstep3} \setfont\chaptt\ttbshape{12}{\magstep2} \setfont\chapttsl\ttslshape{10}{\magstep3} \setfont\chapsf\sfbshape{17}{1000} \let\chapbf=\chaprm \setfont\chapsc\scbshape{10}{\magstep3} \font\chapi=cmmi12 scaled \magstep2 \font\chapsy=cmsy10 scaled \magstep3 % Section fonts (14.4pt). \setfont\secrm\rmbshape{12}{\magstep1} \setfont\secit\itbshape{10}{\magstep2} \setfont\secsl\slbshape{10}{\magstep2} \setfont\sectt\ttbshape{12}{\magstep1} \setfont\secttsl\ttslshape{10}{\magstep2} \setfont\secsf\sfbshape{12}{\magstep1} \let\secbf\secrm \setfont\secsc\scbshape{10}{\magstep2} \font\seci=cmmi12 scaled \magstep1 \font\secsy=cmsy10 scaled \magstep2 % \setfont\ssecrm\bxshape{10}{\magstep1} % This size an font looked bad. % \setfont\ssecit\itshape{10}{\magstep1} % The letters were too crowded. % \setfont\ssecsl\slshape{10}{\magstep1} % \setfont\ssectt\ttshape{10}{\magstep1} % \setfont\ssecsf\sfshape{10}{\magstep1} %\setfont\ssecrm\bfshape{10}{1315} % Note the use of cmb rather than cmbx. %\setfont\ssecit\itshape{10}{1315} % Also, the size is a little larger than %\setfont\ssecsl\slshape{10}{1315} % being scaled magstep1. %\setfont\ssectt\ttshape{10}{1315} %\setfont\ssecsf\sfshape{10}{1315} %\let\ssecbf=\ssecrm % Subsection fonts (13.15pt). \setfont\ssecrm\rmbshape{12}{\magstephalf} \setfont\ssecit\itbshape{10}{1315} \setfont\ssecsl\slbshape{10}{1315} \setfont\ssectt\ttbshape{12}{\magstephalf} \setfont\ssecttsl\ttslshape{10}{1315} \setfont\ssecsf\sfbshape{12}{\magstephalf} \let\ssecbf\ssecrm \setfont\ssecsc\scbshape{10}{\magstep1} \font\sseci=cmmi12 scaled \magstephalf \font\ssecsy=cmsy10 scaled 1315 % The smallcaps and symbol fonts should actually be scaled \magstep1.5, % but that is not a standard magnification. % In order for the font changes to affect most math symbols and letters, % we have to define the \textfont of the standard families. Since % texinfo doesn't allow for producing subscripts and superscripts, we % don't bother to reset \scriptfont and \scriptscriptfont (which would % also require loading a lot more fonts). % \def\resetmathfonts{% \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf \textfont\ttfam = \tentt \textfont\sffam = \tensf } % The font-changing commands redefine the meanings of \tenSTYLE, instead % of just \STYLE. We do this so that font changes will continue to work % in math mode, where it is the current \fam that is relevant in most % cases, not the current font. Plain TeX does \def\bf{\fam=\bffam % \tenbf}, for example. By redefining \tenbf, we obviate the need to % redefine \bf itself. \def\textfonts{% \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy \let\tenttsl=\textttsl \resetmathfonts} \def\titlefonts{% \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy \let\tenttsl=\titlettsl \resetmathfonts \setleading{25pt}} \def\titlefont#1{{\titlefonts\rm #1}} \def\chapfonts{% \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy \let\tenttsl=\chapttsl \resetmathfonts \setleading{19pt}} \def\secfonts{% \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy \let\tenttsl=\secttsl \resetmathfonts \setleading{16pt}} \def\subsecfonts{% \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy \let\tenttsl=\ssecttsl \resetmathfonts \setleading{15pt}} \let\subsubsecfonts = \subsecfonts % Maybe make sssec fonts scaled magstephalf? \def\indexfonts{% \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy \let\tenttsl=\indttsl \resetmathfonts \setleading{12pt}} % Set up the default fonts, so we can use them for creating boxes. % \textfonts % Define these so they can be easily changed for other fonts. \def\angleleft{$\langle$} \def\angleright{$\rangle$} % Count depth in font-changes, for error checks \newcount\fontdepth \fontdepth=0 % Fonts for short table of contents. \setfont\shortcontrm\rmshape{12}{1000} \setfont\shortcontbf\bxshape{12}{1000} \setfont\shortcontsl\slshape{12}{1000} %% Add scribe-like font environments, plus @l for inline lisp (usually sans %% serif) and @ii for TeX italic % \smartitalic{ARG} outputs arg in italics, followed by an italic correction % unless the following character is such as not to need one. \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi} \def\smartslanted#1{{\sl #1}\futurelet\next\smartitalicx} \def\smartitalic#1{{\it #1}\futurelet\next\smartitalicx} \let\i=\smartitalic \let\var=\smartslanted \let\dfn=\smartslanted \let\emph=\smartitalic \let\cite=\smartslanted \def\b#1{{\bf #1}} \let\strong=\b % We can't just use \exhyphenpenalty, because that only has effect at % the end of a paragraph. Restore normal hyphenation at the end of the % group within which \nohyphenation is presumably called. % \def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} \def\restorehyphenation{\hyphenchar\font = `- } \def\t#1{% {\tt \rawbackslash \frenchspacing #1}% \null } \let\ttfont=\t \def\samp#1{`\tclose{#1}'\null} \setfont\smallrm\rmshape{8}{1000} \font\smallsy=cmsy9 \def\key#1{{\smallrm\textfont2=\smallsy \leavevmode\hbox{% \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{% \vbox{\hrule\kern-0.4pt \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}% \kern-0.4pt\hrule}% \kern-.06em\raise0.4pt\hbox{\angleright}}}} % The old definition, with no lozenge: %\def\key #1{{\ttsl \nohyphenation \uppercase{#1}}\null} \def\ctrl #1{{\tt \rawbackslash \hat}#1} % @file, @option are the same as @samp. \let\file=\samp \let\option=\samp % @code is a modification of @t, % which makes spaces the same size as normal in the surrounding text. \def\tclose#1{% {% % Change normal interword space to be same as for the current font. \spaceskip = \fontdimen2\font % % Switch to typewriter. \tt % % But `\ ' produces the large typewriter interword space. \def\ {{\spaceskip = 0pt{} }}% % % Turn off hyphenation. \nohyphenation % \rawbackslash \frenchspacing #1% }% \null } % We *must* turn on hyphenation at `-' and `_' in \code. % Otherwise, it is too hard to avoid overfull hboxes % in the Emacs manual, the Library manual, etc. % Unfortunately, TeX uses one parameter (\hyphenchar) to control % both hyphenation at - and hyphenation within words. % We must therefore turn them both off (\tclose does that) % and arrange explicitly to hyphenate at a dash. % -- rms. { \catcode`\-=\active \catcode`\_=\active % \global\def\code{\begingroup \catcode`\-=\active \let-\codedash \catcode`\_=\active \let_\codeunder \codex } % % If we end up with any active - characters when handling the index, % just treat them as a normal -. \global\def\indexbreaks{\catcode`\-=\active \let-\realdash} } \def\realdash{-} \def\codedash{-\discretionary{}{}{}} \def\codeunder{\ifusingtt{\normalunderscore\discretionary{}{}{}}{\_}} \def\codex #1{\tclose{#1}\endgroup} %\let\exp=\tclose %Was temporary % @kbd is like @code, except that if the argument is just one @key command, % then @kbd has no effect. % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), % `example' (@kbd uses ttsl only inside of @example and friends), % or `code' (@kbd uses normal tty font always). \def\kbdinputstyle{\parsearg\kbdinputstylexxx} \def\kbdinputstylexxx#1{% \def\arg{#1}% \ifx\arg\worddistinct \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}% \else\ifx\arg\wordexample \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}% \else\ifx\arg\wordcode \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}% \fi\fi\fi } \def\worddistinct{distinct} \def\wordexample{example} \def\wordcode{code} % Default is kbdinputdistinct. (Too much of a hassle to call the macro, % the catcodes are wrong for parsearg to work.) \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl} \def\xkey{\key} \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}% \ifx\one\xkey\ifx\threex\three \key{#2}% \else{\tclose{\kbdfont\look}}\fi \else{\tclose{\kbdfont\look}}\fi} % For @url, @env, @command quotes seem unnecessary, so use \code. \let\url=\code \let\env=\code \let\command=\code % @uref (abbreviation for `urlref') takes an optional second argument % specifying the text to display. First (mandatory) arg is the url. % Perhaps eventually put in a hypertex \special here. % \def\uref#1{\urefxxx #1,,\finish} \def\urefxxx#1,#2,#3\finish{% \setbox0 = \hbox{\ignorespaces #2}% \ifdim\wd0 > 0pt \unhbox0\ (\code{#1})% \else \code{#1}% \fi } % rms does not like the angle brackets --karl, 17may97. % So now @email is just like @uref. %\def\email#1{\angleleft{\tt #1}\angleright} \let\email=\uref % Check if we are currently using a typewriter font. Since all the % Computer Modern typewriter fonts have zero interword stretch (and % shrink), and it is reasonable to expect all typewriter fonts to have % this property, we can check that font parameter. % \def\ifmonospace{\ifdim\fontdimen3\font=0pt } % Typeset a dimension, e.g., `in' or `pt'. The only reason for the % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt. % \def\dmn#1{\thinspace #1} \def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par} % @l was never documented to mean ``switch to the Lisp font'', % and it is not used as such in any manual I can find. We need it for % Polish suppressed-l. --karl, 22sep96. %\def\l#1{{\li #1}\null} % Explicit font changes: @r, @sc, undocumented @ii. \def\r#1{{\rm #1}} % roman font \def\sc#1{{\smallcaps#1}} % smallcaps font \def\ii#1{{\it #1}} % italic font % @acronym downcases the argument and prints in smallcaps. \def\acronym#1{{\smallcaps \lowercase{#1}}} % @pounds{} is a sterling sign. \def\pounds{{\it\$}} \message{page headings,} \newskip\titlepagetopglue \titlepagetopglue = 1.5in \newskip\titlepagebottomglue \titlepagebottomglue = 2pc % First the title page. Must do @settitle before @titlepage. \newif\ifseenauthor \newif\iffinishedtitlepage % Do an implicit @contents or @shortcontents after @end titlepage if the % user says @contentsaftertitlepage or @shortcontentsaftertitlepage. % \newif\ifsetcontentsaftertitlepage \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue \newif\ifsetshortcontentsaftertitlepage \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue \def\shorttitlepage{\parsearg\shorttitlepagezzz} \def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}% \endgroup\page\hbox{}\page} \def\titlepage{\begingroup \parindent=0pt \textfonts \let\subtitlerm=\tenrm \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}% % \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}% % % Leave some space at the very top of the page. \vglue\titlepagetopglue % % Now you can print the title using @title. \def\title{\parsearg\titlezzz}% \def\titlezzz##1{\leftline{\titlefonts\rm ##1} % print a rule at the page bottom also. \finishedtitlepagefalse \vskip4pt \hrule height 4pt width \hsize \vskip4pt}% % No rule at page bottom unless we print one at the top with @title. \finishedtitlepagetrue % % Now you can put text using @subtitle. \def\subtitle{\parsearg\subtitlezzz}% \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}% % % @author should come last, but may come many times. \def\author{\parsearg\authorzzz}% \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi {\authorfont \leftline{##1}}}% % % Most title ``pages'' are actually two pages long, with space % at the top of the second. We don't want the ragged left on the second. \let\oldpage = \page \def\page{% \iffinishedtitlepage\else \finishtitlepage \fi \oldpage \let\page = \oldpage \hbox{}}% % \def\page{\oldpage \hbox{}} } \def\Etitlepage{% \iffinishedtitlepage\else \finishtitlepage \fi % It is important to do the page break before ending the group, % because the headline and footline are only empty inside the group. % If we use the new definition of \page, we always get a blank page % after the title page, which we certainly don't want. \oldpage \endgroup % % If they want short, they certainly want long too. \ifsetshortcontentsaftertitlepage \shortcontents \contents \global\let\shortcontents = \relax \global\let\contents = \relax \fi % \ifsetcontentsaftertitlepage \contents \global\let\contents = \relax \global\let\shortcontents = \relax \fi % \HEADINGSon } \def\finishtitlepage{% \vskip4pt \hrule height 2pt width \hsize \vskip\titlepagebottomglue \finishedtitlepagetrue } %%% Set up page headings and footings. \let\thispage=\folio \newtoks\evenheadline % headline on even pages \newtoks\oddheadline % headline on odd pages \newtoks\evenfootline % footline on even pages \newtoks\oddfootline % footline on odd pages % Now make Tex use those variables \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline \else \the\evenheadline \fi}} \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline \else \the\evenfootline \fi}\HEADINGShook} \let\HEADINGShook=\relax % Commands to set those variables. % For example, this is what @headings on does % @evenheading @thistitle|@thispage|@thischapter % @oddheading @thischapter|@thispage|@thistitle % @evenfooting @thisfile|| % @oddfooting ||@thisfile \def\evenheading{\parsearg\evenheadingxxx} \def\oddheading{\parsearg\oddheadingxxx} \def\everyheading{\parsearg\everyheadingxxx} \def\evenfooting{\parsearg\evenfootingxxx} \def\oddfooting{\parsearg\oddfootingxxx} \def\everyfooting{\parsearg\everyfootingxxx} {\catcode`\@=0 % \gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish} \gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{% \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} \gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish} \gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{% \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} \gdef\everyheadingxxx#1{\oddheadingxxx{#1}\evenheadingxxx{#1}}% \gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish} \gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{% \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} \gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish} \gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{% \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}% % % Leave some space for the footline. Hopefully ok to assume % @evenfooting will not be used by itself. \global\advance\pageheight by -\baselineskip \global\advance\vsize by -\baselineskip } \gdef\everyfootingxxx#1{\oddfootingxxx{#1}\evenfootingxxx{#1}} % }% unbind the catcode of @. % @headings double turns headings on for double-sided printing. % @headings single turns headings on for single-sided printing. % @headings off turns them off. % @headings on same as @headings double, retained for compatibility. % @headings after turns on double-sided headings after this page. % @headings doubleafter turns on double-sided headings after this page. % @headings singleafter turns on single-sided headings after this page. % By default, they are off at the start of a document, % and turned `on' after @end titlepage. \def\headings #1 {\csname HEADINGS#1\endcsname} \def\HEADINGSoff{ \global\evenheadline={\hfil} \global\evenfootline={\hfil} \global\oddheadline={\hfil} \global\oddfootline={\hfil}} \HEADINGSoff % When we turn headings on, set the page number to 1. % For double-sided printing, put current file name in lower left corner, % chapter name on inside top of right hand pages, document % title on inside top of left hand pages, and page numbers on outside top % edge of all pages. \def\HEADINGSdouble{ \global\pageno=1 \global\evenfootline={\hfil} \global\oddfootline={\hfil} \global\evenheadline={\line{\folio\hfil\thistitle}} \global\oddheadline={\line{\thischapter\hfil\folio}} \global\let\contentsalignmacro = \chapoddpage } \let\contentsalignmacro = \chappager % For single-sided printing, chapter title goes across top left of page, % page number on top right. \def\HEADINGSsingle{ \global\pageno=1 \global\evenfootline={\hfil} \global\oddfootline={\hfil} \global\evenheadline={\line{\thischapter\hfil\folio}} \global\oddheadline={\line{\thischapter\hfil\folio}} \global\let\contentsalignmacro = \chappager } \def\HEADINGSon{\HEADINGSdouble} \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} \let\HEADINGSdoubleafter=\HEADINGSafter \def\HEADINGSdoublex{% \global\evenfootline={\hfil} \global\oddfootline={\hfil} \global\evenheadline={\line{\folio\hfil\thistitle}} \global\oddheadline={\line{\thischapter\hfil\folio}} \global\let\contentsalignmacro = \chapoddpage } \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} \def\HEADINGSsinglex{% \global\evenfootline={\hfil} \global\oddfootline={\hfil} \global\evenheadline={\line{\thischapter\hfil\folio}} \global\oddheadline={\line{\thischapter\hfil\folio}} \global\let\contentsalignmacro = \chappager } % Subroutines used in generating headings % Produces Day Month Year style of output. \def\today{\number\day\space \ifcase\month\or January\or February\or March\or April\or May\or June\or July\or August\or September\or October\or November\or December\fi \space\number\year} % Use this if you want the Month Day, Year style of output. %\def\today{\ifcase\month\or %January\or February\or March\or April\or May\or June\or %July\or August\or September\or October\or November\or December\fi %\space\number\day, \number\year} % @settitle line... specifies the title of the document, for headings % It generates no output of its own \def\thistitle{No Title} \def\settitle{\parsearg\settitlezzz} \def\settitlezzz #1{\gdef\thistitle{#1}} \message{tables,} % Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x). % default indentation of table text \newdimen\tableindent \tableindent=.8in % default indentation of @itemize and @enumerate text \newdimen\itemindent \itemindent=.3in % margin between end of table item and start of table text. \newdimen\itemmargin \itemmargin=.1in % used internally for \itemindent minus \itemmargin \newdimen\itemmax % Note @table, @vtable, and @vtable define @item, @itemx, etc., with % these defs. % They also define \itemindex % to index the item name in whatever manner is desired (perhaps none). \newif\ifitemxneedsnegativevskip \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi} \def\internalBitem{\smallbreak \parsearg\itemzzz} \def\internalBitemx{\itemxpar \parsearg\itemzzz} \def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz} \def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \itemxpar \parsearg\xitemzzz} \def\internalBkitem{\smallbreak \parsearg\kitemzzz} \def\internalBkitemx{\itemxpar \parsearg\kitemzzz} \def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}% \itemzzz {#1}} \def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}% \itemzzz {#1}} \def\itemzzz #1{\begingroup % \advance\hsize by -\rightskip \advance\hsize by -\tableindent \setbox0=\hbox{\itemfont{#1}}% \itemindex{#1}% \nobreak % This prevents a break before @itemx. % % If the item text does not fit in the space we have, put it on a line % by itself, and do not allow a page break either before or after that % line. We do not start a paragraph here because then if the next % command is, e.g., @kindex, the whatsit would get put into the % horizontal list on a line by itself, resulting in extra blank space. \ifdim \wd0>\itemmax % % Make this a paragraph so we get the \parskip glue and wrapping, % but leave it ragged-right. \begingroup \advance\leftskip by-\tableindent \advance\hsize by\tableindent \advance\rightskip by0pt plus1fil \leavevmode\unhbox0\par \endgroup % % We're going to be starting a paragraph, but we don't want the % \parskip glue -- logically it's part of the @item we just started. \nobreak \vskip-\parskip % % Stop a page break at the \parskip glue coming up. Unfortunately % we can't prevent a possible page break at the following % \baselineskip glue. \nobreak \endgroup \itemxneedsnegativevskipfalse \else % The item text fits into the space. Start a paragraph, so that the % following text (if any) will end up on the same line. \noindent % Do this with kerns and \unhbox so that if there is a footnote in % the item text, it can migrate to the main vertical list and % eventually be printed. \nobreak\kern-\tableindent \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0 \unhbox0 \nobreak\kern\dimen0 \endgroup \itemxneedsnegativevskiptrue \fi } \def\item{\errmessage{@item while not in a table}} \def\itemx{\errmessage{@itemx while not in a table}} \def\kitem{\errmessage{@kitem while not in a table}} \def\kitemx{\errmessage{@kitemx while not in a table}} \def\xitem{\errmessage{@xitem while not in a table}} \def\xitemx{\errmessage{@xitemx while not in a table}} % Contains a kludge to get @end[description] to work. \def\description{\tablez{\dontindex}{1}{}{}{}{}} % @table, @ftable, @vtable. \def\table{\begingroup\inENV\obeylines\obeyspaces\tablex} {\obeylines\obeyspaces% \gdef\tablex #1^^M{% \tabley\dontindex#1 \endtabley}} \def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex} {\obeylines\obeyspaces% \gdef\ftablex #1^^M{% \tabley\fnitemindex#1 \endtabley \def\Eftable{\endgraf\afterenvbreak\endgroup}% \let\Etable=\relax}} \def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex} {\obeylines\obeyspaces% \gdef\vtablex #1^^M{% \tabley\vritemindex#1 \endtabley \def\Evtable{\endgraf\afterenvbreak\endgroup}% \let\Etable=\relax}} \def\dontindex #1{} \def\fnitemindex #1{\doind {fn}{\code{#1}}}% \def\vritemindex #1{\doind {vr}{\code{#1}}}% {\obeyspaces % \gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup% \tablez{#1}{#2}{#3}{#4}{#5}{#6}}} \def\tablez #1#2#3#4#5#6{% \aboveenvbreak % \begingroup % \def\Edescription{\Etable}% Necessary kludge. \let\itemindex=#1% \ifnum 0#3>0 \advance \leftskip by #3\mil \fi % \ifnum 0#4>0 \tableindent=#4\mil \fi % \ifnum 0#5>0 \advance \rightskip by #5\mil \fi % \def\itemfont{#2}% \itemmax=\tableindent % \advance \itemmax by -\itemmargin % \advance \leftskip by \tableindent % \exdentamount=\tableindent \parindent = 0pt \parskip = \smallskipamount \ifdim \parskip=0pt \parskip=2pt \fi% \def\Etable{\endgraf\afterenvbreak\endgroup}% \let\item = \internalBitem % \let\itemx = \internalBitemx % \let\kitem = \internalBkitem % \let\kitemx = \internalBkitemx % \let\xitem = \internalBxitem % \let\xitemx = \internalBxitemx % } % This is the counter used by @enumerate, which is really @itemize \newcount \itemno \def\itemize{\parsearg\itemizezzz} \def\itemizezzz #1{% \begingroup % ended by the @end itemize \itemizey {#1}{\Eitemize} } \def\itemizey #1#2{% \aboveenvbreak % \itemmax=\itemindent % \advance \itemmax by -\itemmargin % \advance \leftskip by \itemindent % \exdentamount=\itemindent \parindent = 0pt % \parskip = \smallskipamount % \ifdim \parskip=0pt \parskip=2pt \fi% \def#2{\endgraf\afterenvbreak\endgroup}% \def\itemcontents{#1}% \let\item=\itemizeitem} % Set sfcode to normal for the chars that usually have another value. % These are `.?!:;,' \def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000 \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 } % \splitoff TOKENS\endmark defines \first to be the first token in % TOKENS, and \rest to be the remainder. % \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% % Allow an optional argument of an uppercase letter, lowercase letter, % or number, to specify the first label in the enumerated list. No % argument is the same as `1'. % \def\enumerate{\parsearg\enumeratezzz} \def\enumeratezzz #1{\enumeratey #1 \endenumeratey} \def\enumeratey #1 #2\endenumeratey{% \begingroup % ended by the @end enumerate % % If we were given no argument, pretend we were given `1'. \def\thearg{#1}% \ifx\thearg\empty \def\thearg{1}\fi % % Detect if the argument is a single token. If so, it might be a % letter. Otherwise, the only valid thing it can be is a number. % (We will always have one token, because of the test we just made. % This is a good thing, since \splitoff doesn't work given nothing at % all -- the first parameter is undelimited.) \expandafter\splitoff\thearg\endmark \ifx\rest\empty % Only one token in the argument. It could still be anything. % A ``lowercase letter'' is one whose \lccode is nonzero. % An ``uppercase letter'' is one whose \lccode is both nonzero, and % not equal to itself. % Otherwise, we assume it's a number. % % We need the \relax at the end of the \ifnum lines to stop TeX from % continuing to look for a . % \ifnum\lccode\expandafter`\thearg=0\relax \numericenumerate % a number (we hope) \else % It's a letter. \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax \lowercaseenumerate % lowercase letter \else \uppercaseenumerate % uppercase letter \fi \fi \else % Multiple tokens in the argument. We hope it's a number. \numericenumerate \fi } % An @enumerate whose labels are integers. The starting integer is % given in \thearg. % \def\numericenumerate{% \itemno = \thearg \startenumeration{\the\itemno}% } % The starting (lowercase) letter is in \thearg. \def\lowercaseenumerate{% \itemno = \expandafter`\thearg \startenumeration{% % Be sure we're not beyond the end of the alphabet. \ifnum\itemno=0 \errmessage{No more lowercase letters in @enumerate; get a bigger alphabet}% \fi \char\lccode\itemno }% } % The starting (uppercase) letter is in \thearg. \def\uppercaseenumerate{% \itemno = \expandafter`\thearg \startenumeration{% % Be sure we're not beyond the end of the alphabet. \ifnum\itemno=0 \errmessage{No more uppercase letters in @enumerate; get a bigger alphabet} \fi \char\uccode\itemno }% } % Call itemizey, adding a period to the first argument and supplying the % common last two arguments. Also subtract one from the initial value in % \itemno, since @item increments \itemno. % \def\startenumeration#1{% \advance\itemno by -1 \itemizey{#1.}\Eenumerate\flushcr } % @alphaenumerate and @capsenumerate are abbreviations for giving an arg % to @enumerate. % \def\alphaenumerate{\enumerate{a}} \def\capsenumerate{\enumerate{A}} \def\Ealphaenumerate{\Eenumerate} \def\Ecapsenumerate{\Eenumerate} % Definition of @item while inside @itemize. \def\itemizeitem{% \advance\itemno by 1 {\let\par=\endgraf \smallbreak}% \ifhmode \errmessage{In hmode at itemizeitem}\fi {\parskip=0in \hskip 0pt \hbox to 0pt{\hss \itemcontents\hskip \itemmargin}% \vadjust{\penalty 1200}}% \flushcr} % @multitable macros % Amy Hendrickson, 8/18/94, 3/6/96 % % @multitable ... @end multitable will make as many columns as desired. % Contents of each column will wrap at width given in preamble. Width % can be specified either with sample text given in a template line, % or in percent of \hsize, the current width of text on page. % Table can continue over pages but will only break between lines. % To make preamble: % % Either define widths of columns in terms of percent of \hsize: % @multitable @columnfractions .25 .3 .45 % @item ... % % Numbers following @columnfractions are the percent of the total % current hsize to be used for each column. You may use as many % columns as desired. % Or use a template: % @multitable {Column 1 template} {Column 2 template} {Column 3 template} % @item ... % using the widest term desired in each column. % % For those who want to use more than one line's worth of words in % the preamble, break the line within one argument and it % will parse correctly, i.e., % % @multitable {Column 1 template} {Column 2 template} {Column 3 % template} % Not: % @multitable {Column 1 template} {Column 2 template} % {Column 3 template} % Each new table line starts with @item, each subsequent new column % starts with @tab. Empty columns may be produced by supplying @tab's % with nothing between them for as many times as empty columns are needed, % ie, @tab@tab@tab will produce two empty columns. % @item, @tab, @multitable or @end multitable do not need to be on their % own lines, but it will not hurt if they are. % Sample multitable: % @multitable {Column 1 template} {Column 2 template} {Column 3 template} % @item first col stuff @tab second col stuff @tab third col % @item % first col stuff % @tab % second col stuff % @tab % third col % @item first col stuff @tab second col stuff % @tab Many paragraphs of text may be used in any column. % % They will wrap at the width determined by the template. % @item@tab@tab This will be in third column. % @end multitable % Default dimensions may be reset by user. % @multitableparskip is vertical space between paragraphs in table. % @multitableparindent is paragraph indent in table. % @multitablecolmargin is horizontal space to be left between columns. % @multitablelinespace is space to leave between table items, baseline % to baseline. % 0pt means it depends on current normal line spacing. % \newskip\multitableparskip \newskip\multitableparindent \newdimen\multitablecolspace \newskip\multitablelinespace \multitableparskip=0pt \multitableparindent=6pt \multitablecolspace=12pt \multitablelinespace=0pt % Macros used to set up halign preamble: % \let\endsetuptable\relax \def\xendsetuptable{\endsetuptable} \let\columnfractions\relax \def\xcolumnfractions{\columnfractions} \newif\ifsetpercent % 2/1/96, to allow fractions to be given with more than one digit. \def\pickupwholefraction#1 {\global\advance\colcount by1 % \expandafter\xdef\csname col\the\colcount\endcsname{.#1\hsize}% \setuptable} \newcount\colcount \def\setuptable#1{\def\firstarg{#1}% \ifx\firstarg\xendsetuptable\let\go\relax% \else \ifx\firstarg\xcolumnfractions\global\setpercenttrue% \else \ifsetpercent \let\go\pickupwholefraction % In this case arg of setuptable % is the decimal point before the % number given in percent of hsize. % We don't need this so we don't use it. \else \global\advance\colcount by1 \setbox0=\hbox{#1 }% Add a normal word space as a separator; % typically that is always in the input, anyway. \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}% \fi% \fi% \ifx\go\pickupwholefraction\else\let\go\setuptable\fi% \fi\go} % multitable syntax \def\tab{&\hskip1sp\relax} % 2/2/96 % tiny skip here makes sure this column space is % maintained, even if it is never used. % @multitable ... @end multitable definitions: \def\multitable{\parsearg\dotable} \def\dotable#1{\bgroup \vskip\parskip \let\item\crcr \tolerance=9500 \hbadness=9500 \setmultitablespacing \parskip=\multitableparskip \parindent=\multitableparindent \overfullrule=0pt \global\colcount=0 \def\Emultitable{\global\setpercentfalse\cr\egroup\egroup}% % % To parse everything between @multitable and @item: \setuptable#1 \endsetuptable % % \everycr will reset column counter, \colcount, at the end of % each line. Every column entry will cause \colcount to advance by one. % The table preamble % looks at the current \colcount to find the correct column width. \everycr{\noalign{% % % \filbreak%% keeps underfull box messages off when table breaks over pages. % Maybe so, but it also creates really weird page breaks when the table % breaks over pages. Wouldn't \vfil be better? Wait until the problem % manifests itself, so it can be fixed for real --karl. \global\colcount=0\relax}}% % % This preamble sets up a generic column definition, which will % be used as many times as user calls for columns. % \vtop will set a single line and will also let text wrap and % continue for many paragraphs if desired. \halign\bgroup&\global\advance\colcount by 1\relax \multistrut\vtop{\hsize=\expandafter\csname col\the\colcount\endcsname % % In order to keep entries from bumping into each other % we will add a \leftskip of \multitablecolspace to all columns after % the first one. % % If a template has been used, we will add \multitablecolspace % to the width of each template entry. % % If the user has set preamble in terms of percent of \hsize we will % use that dimension as the width of the column, and the \leftskip % will keep entries from bumping into each other. Table will start at % left margin and final column will justify at right margin. % % Make sure we don't inherit \rightskip from the outer environment. \rightskip=0pt \ifnum\colcount=1 % The first column will be indented with the surrounding text. \advance\hsize by\leftskip \else \ifsetpercent \else % If user has not set preamble in terms of percent of \hsize % we will advance \hsize by \multitablecolspace. \advance\hsize by \multitablecolspace \fi % In either case we will make \leftskip=\multitablecolspace: \leftskip=\multitablecolspace \fi % Ignoring space at the beginning and end avoids an occasional spurious % blank line, when TeX decides to break the line at the space before the % box from the multistrut, so the strut ends up on a line by itself. % For example: % @multitable @columnfractions .11 .89 % @item @code{#} % @tab Legal holiday which is valid in major parts of the whole country. % Is automatically provided with highlighting sequences respectively marking % characters. \noindent\ignorespaces##\unskip\multistrut}\cr } \def\setmultitablespacing{% test to see if user has set \multitablelinespace. % If so, do nothing. If not, give it an appropriate dimension based on % current baselineskip. \ifdim\multitablelinespace=0pt %% strut to put in table in case some entry doesn't have descenders, %% to keep lines equally spaced \let\multistrut = \strut %% Test to see if parskip is larger than space between lines of %% table. If not, do nothing. %% If so, set to same dimension as multitablelinespace. \else \gdef\multistrut{\vrule height\multitablelinespace depth\dp0 width0pt\relax} \fi \ifdim\multitableparskip>\multitablelinespace \global\multitableparskip=\multitablelinespace \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller %% than skip between lines in the table. \fi% \ifdim\multitableparskip=0pt \global\multitableparskip=\multitablelinespace \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller %% than skip between lines in the table. \fi} \message{indexing,} % Index generation facilities % Define \newwrite to be identical to plain tex's \newwrite % except not \outer, so it can be used within \newindex. {\catcode`\@=11 \gdef\newwrite{\alloc@7\write\chardef\sixt@@n}} % \newindex {foo} defines an index named foo. % It automatically defines \fooindex such that % \fooindex ...rest of line... puts an entry in the index foo. % It also defines \fooindfile to be the number of the output channel for % the file that accumulates this index. The file's extension is foo. % The name of an index should be no more than 2 characters long % for the sake of vms. % \def\newindex#1{% \iflinks \expandafter\newwrite \csname#1indfile\endcsname \openout \csname#1indfile\endcsname \jobname.#1 % Open the file \fi \expandafter\xdef\csname#1index\endcsname{% % Define @#1index \noexpand\doindex{#1}} } % @defindex foo == \newindex{foo} \def\defindex{\parsearg\newindex} % Define @defcodeindex, like @defindex except put all entries in @code. \def\newcodeindex#1{% \iflinks \expandafter\newwrite \csname#1indfile\endcsname \openout \csname#1indfile\endcsname \jobname.#1 \fi \expandafter\xdef\csname#1index\endcsname{% \noexpand\docodeindex{#1}} } \def\defcodeindex{\parsearg\newcodeindex} % @synindex foo bar makes index foo feed into index bar. % Do this instead of @defindex foo if you don't want it as a separate index. % The \closeout helps reduce unnecessary open files; the limit on the % Acorn RISC OS is a mere 16 files. \def\synindex#1 #2 {% \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname \expandafter\closeout\csname#1indfile\endcsname \expandafter\let\csname#1indfile\endcsname=\synindexfoo \expandafter\xdef\csname#1index\endcsname{% define \xxxindex \noexpand\doindex{#2}}% } % @syncodeindex foo bar similar, but put all entries made for index foo % inside @code. \def\syncodeindex#1 #2 {% \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname \expandafter\closeout\csname#1indfile\endcsname \expandafter\let\csname#1indfile\endcsname=\synindexfoo \expandafter\xdef\csname#1index\endcsname{% define \xxxindex \noexpand\docodeindex{#2}}% } % Define \doindex, the driver for all \fooindex macros. % Argument #1 is generated by the calling \fooindex macro, % and it is "foo", the name of the index. % \doindex just uses \parsearg; it calls \doind for the actual work. % This is because \doind is more useful to call from other macros. % There is also \dosubind {index}{topic}{subtopic} % which makes an entry in a two-level index such as the operation index. \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer} \def\singleindexer #1{\doind{\indexname}{#1}} % like the previous two, but they put @code around the argument. \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} \def\indexdummies{% \def\ { }% % Take care of the plain tex accent commands. \def\"{\realbackslash "}% \def\`{\realbackslash `}% \def\'{\realbackslash '}% \def\^{\realbackslash ^}% \def\~{\realbackslash ~}% \def\={\realbackslash =}% \def\b{\realbackslash b}% \def\c{\realbackslash c}% \def\d{\realbackslash d}% \def\u{\realbackslash u}% \def\v{\realbackslash v}% \def\H{\realbackslash H}% % Take care of the plain tex special European modified letters. \def\oe{\realbackslash oe}% \def\ae{\realbackslash ae}% \def\aa{\realbackslash aa}% \def\OE{\realbackslash OE}% \def\AE{\realbackslash AE}% \def\AA{\realbackslash AA}% \def\o{\realbackslash o}% \def\O{\realbackslash O}% \def\l{\realbackslash l}% \def\L{\realbackslash L}% \def\ss{\realbackslash ss}% % Take care of texinfo commands likely to appear in an index entry. % (Must be a way to avoid doing expansion at all, and thus not have to % laboriously list every single command here.) \def\@{@}% will be @@ when we switch to @ as escape char. %\let\{ = \lbracecmd %\let\} = \rbracecmd \def\_{{\realbackslash _}}% \def\w{\realbackslash w }% \def\bf{\realbackslash bf }% %\def\rm{\realbackslash rm }% \def\sl{\realbackslash sl }% \def\sf{\realbackslash sf}% \def\tt{\realbackslash tt}% \def\gtr{\realbackslash gtr}% \def\less{\realbackslash less}% \def\hat{\realbackslash hat}% \def\TeX{\realbackslash TeX}% \def\dots{\realbackslash dots }% \def\result{\realbackslash result}% \def\equiv{\realbackslash equiv}% \def\expansion{\realbackslash expansion}% \def\print{\realbackslash print}% \def\error{\realbackslash error}% \def\point{\realbackslash point}% \def\copyright{\realbackslash copyright}% \def\tclose##1{\realbackslash tclose {##1}}% \def\code##1{\realbackslash code {##1}}% \def\dotless##1{\realbackslash dotless {##1}}% \def\samp##1{\realbackslash samp {##1}}% \def\,##1{\realbackslash ,{##1}}% \def\t##1{\realbackslash t {##1}}% \def\r##1{\realbackslash r {##1}}% \def\i##1{\realbackslash i {##1}}% \def\b##1{\realbackslash b {##1}}% \def\sc##1{\realbackslash sc {##1}}% \def\cite##1{\realbackslash cite {##1}}% \def\key##1{\realbackslash key {##1}}% \def\file##1{\realbackslash file {##1}}% \def\var##1{\realbackslash var {##1}}% \def\kbd##1{\realbackslash kbd {##1}}% \def\dfn##1{\realbackslash dfn {##1}}% \def\emph##1{\realbackslash emph {##1}}% % % Handle some cases of @value -- where the variable name does not % contain - or _, and the value does not contain any % (non-fully-expandable) commands. \let\value = \expandablevalue % \unsepspaces } % If an index command is used in an @example environment, any spaces % therein should become regular spaces in the raw index file, not the % expansion of \tie (\\leavevmode \penalty \@M \ ). {\obeyspaces \gdef\unsepspaces{\obeyspaces\let =\space}} % \indexnofonts no-ops all font-change commands. % This is used when outputting the strings to sort the index by. \def\indexdummyfont#1{#1} \def\indexdummytex{TeX} \def\indexdummydots{...} \def\indexnofonts{% % Just ignore accents. \let\,=\indexdummyfont \let\"=\indexdummyfont \let\`=\indexdummyfont \let\'=\indexdummyfont \let\^=\indexdummyfont \let\~=\indexdummyfont \let\==\indexdummyfont \let\b=\indexdummyfont \let\c=\indexdummyfont \let\d=\indexdummyfont \let\u=\indexdummyfont \let\v=\indexdummyfont \let\H=\indexdummyfont \let\dotless=\indexdummyfont % Take care of the plain tex special European modified letters. \def\oe{oe}% \def\ae{ae}% \def\aa{aa}% \def\OE{OE}% \def\AE{AE}% \def\AA{AA}% \def\o{o}% \def\O{O}% \def\l{l}% \def\L{L}% \def\ss{ss}% \let\w=\indexdummyfont \let\t=\indexdummyfont \let\r=\indexdummyfont \let\i=\indexdummyfont \let\b=\indexdummyfont \let\emph=\indexdummyfont \let\strong=\indexdummyfont \let\cite=\indexdummyfont \let\sc=\indexdummyfont %Don't no-op \tt, since it isn't a user-level command % and is used in the definitions of the active chars like <, >, |... %\let\tt=\indexdummyfont \let\tclose=\indexdummyfont \let\code=\indexdummyfont \let\file=\indexdummyfont \let\samp=\indexdummyfont \let\kbd=\indexdummyfont \let\key=\indexdummyfont \let\var=\indexdummyfont \let\TeX=\indexdummytex \let\dots=\indexdummydots \def\@{@}% } % To define \realbackslash, we must make \ not be an escape. % We must first make another character (@) an escape % so we do not become unable to do a definition. {\catcode`\@=0 \catcode`\\=\other @gdef@realbackslash{\}} \let\indexbackslash=0 %overridden during \printindex. \let\SETmarginindex=\relax % put index entries in margin (undocumented)? % For \ifx comparisons. \def\emptymacro{\empty} % Most index entries go through here, but \dosubind is the general case. % \def\doind#1#2{\dosubind{#1}{#2}\empty} % Workhorse for all \fooindexes. % #1 is name of index, #2 is stuff to put there, #3 is subentry -- % \empty if called from \doind, as we usually are. The main exception % is with defuns, which call us directly. % \def\dosubind#1#2#3{% % Put the index entry in the margin if desired. \ifx\SETmarginindex\relax\else \insert\margin{\hbox{\vrule height8pt depth3pt width0pt #2}}% \fi {% \count255=\lastpenalty {% \indexdummies % Must do this here, since \bf, etc expand at this stage \escapechar=`\\ {% \let\folio = 0% We will expand all macros now EXCEPT \folio. \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now % so it will be output as is; and it will print as backslash. % \def\thirdarg{#3}% % % If third arg is present, precede it with space in sort key. \ifx\thirdarg\emptymacro \let\subentry = \empty \else \def\subentry{ #3}% \fi % % First process the index-string with all font commands turned off % to get the string to sort by. {\indexnofonts \xdef\indexsorttmp{#2\subentry}}% % % Now produce the complete index entry, with both the sort key and the % original text, including any font commands. \toks0 = {#2}% \edef\temp{% \write\csname#1indfile\endcsname{% \realbackslash entry{\indexsorttmp}{\folio}{\the\toks0}}% }% % % If third (subentry) arg is present, add it to the index string. \ifx\thirdarg\emptymacro \else \toks0 = {#3}% \edef\temp{\temp{\the\toks0}}% \fi % % If a skip is the last thing on the list now, preserve it % by backing up by \lastskip, doing the \write, then inserting % the skip again. Otherwise, the whatsit generated by the % \write will make \lastskip zero. The result is that sequences % like this: % @end defun % @tindex whatever % @defun ... % will have extra space inserted, because the \medbreak in the % start of the @defun won't see the skip inserted by the @end of % the previous defun. % % But don't do any of this if we're not in vertical mode. We % don't want to do a \vskip and prematurely end a paragraph. % % Avoid page breaks due to these extra skips, too. % \iflinks \ifvmode \skip0 = \lastskip \ifdim\lastskip = 0pt \else \nobreak\vskip-\lastskip \fi \fi % \temp % do the write % % \ifvmode \ifdim\skip0 = 0pt \else \nobreak\vskip\skip0 \fi \fi \fi }% }% \penalty\count255 }% } % The index entry written in the file actually looks like % \entry {sortstring}{page}{topic} % or % \entry {sortstring}{page}{topic}{subtopic} % The texindex program reads in these files and writes files % containing these kinds of lines: % \initial {c} % before the first topic whose initial is c % \entry {topic}{pagelist} % for a topic that is used without subtopics % \primary {topic} % for the beginning of a topic that is used with subtopics % \secondary {subtopic}{pagelist} % for each subtopic. % Define the user-accessible indexing commands % @findex, @vindex, @kindex, @cindex. \def\findex {\fnindex} \def\kindex {\kyindex} \def\cindex {\cpindex} \def\vindex {\vrindex} \def\tindex {\tpindex} \def\pindex {\pgindex} \def\cindexsub {\begingroup\obeylines\cindexsub} {\obeylines % \gdef\cindexsub "#1" #2^^M{\endgroup % \dosubind{cp}{#2}{#1}}} % Define the macros used in formatting output of the sorted index material. % @printindex causes a particular index (the ??s file) to get printed. % It does not print any chapter heading (usually an @unnumbered). % \def\printindex{\parsearg\doprintindex} \def\doprintindex#1{\begingroup \dobreak \chapheadingskip{10000}% % \indexfonts \rm \tolerance = 9500 \indexbreaks % % See if the index file exists and is nonempty. % Change catcode of @ here so that if the index file contains % \initial {@} % as its first line, TeX doesn't complain about mismatched braces % (because it thinks @} is a control sequence). \catcode`\@ = 11 \openin 1 \jobname.#1s \ifeof 1 % \enddoublecolumns gets confused if there is no text in the index, % and it loses the chapter title and the aux file entries for the % index. The easiest way to prevent this problem is to make sure % there is some text. (Index is nonexistent) \else % % If the index file exists but is empty, then \openin leaves \ifeof % false. We have to make TeX try to read something from the file, so % it can discover if there is anything in it. \read 1 to \temp \ifeof 1 (Index is empty) \else % Index files are almost Texinfo source, but we use \ as the escape % character. It would be better to use @, but that's too big a change % to make right now. \def\indexbackslash{\rawbackslashxx}% \catcode`\\ = 0 \escapechar = `\\ \begindoublecolumns \input \jobname.#1s \enddoublecolumns \fi \fi \closein 1 \endgroup} % These macros are used by the sorted index file itself. % Change them to control the appearance of the index. \def\initial#1{{% % Some minor font changes for the special characters. \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt % % Remove any glue we may have, we'll be inserting our own. \removelastskip % % We like breaks before the index initials, so insert a bonus. \penalty -300 % % Typeset the initial. Making this add up to a whole number of % baselineskips increases the chance of the dots lining up from column % to column. It still won't often be perfect, because of the stretch % we need before each entry, but it's better. % % No shrink because it confuses \balancecolumns. \vskip 1.67\baselineskip plus .5\baselineskip \leftline{\secbf #1}% \vskip .33\baselineskip plus .1\baselineskip % % Do our best not to break after the initial. \nobreak }} % This typesets a paragraph consisting of #1, dot leaders, and then #2 % flush to the right margin. It is used for index and table of contents % entries. The paragraph is indented by \leftskip. % \def\entry#1#2{\begingroup % % Start a new paragraph if necessary, so our assignments below can't % affect previous text. \par % % Do not fill out the last line with white space. \parfillskip = 0in % % No extra space above this paragraph. \parskip = 0in % % Do not prefer a separate line ending with a hyphen to fewer lines. \finalhyphendemerits = 0 % % \hangindent is only relevant when the entry text and page number % don't both fit on one line. In that case, bob suggests starting the % dots pretty far over on the line. Unfortunately, a large % indentation looks wrong when the entry text itself is broken across % lines. So we use a small indentation and put up with long leaders. % % \hangafter is reset to 1 (which is the value we want) at the start % of each paragraph, so we need not do anything with that. \hangindent = 2em % % When the entry text needs to be broken, just fill out the first line % with blank space. \rightskip = 0pt plus1fil % % A bit of stretch before each entry for the benefit of balancing columns. \vskip 0pt plus1pt % % Start a ``paragraph'' for the index entry so the line breaking % parameters we've set above will have an effect. \noindent % % Insert the text of the index entry. TeX will do line-breaking on it. #1% % The following is kludged to not output a line of dots in the index if % there are no page numbers. The next person who breaks this will be % cursed by a Unix daemon. \def\tempa{{\rm }}% \def\tempb{#2}% \edef\tempc{\tempa}% \edef\tempd{\tempb}% \ifx\tempc\tempd\ \else% % % If we must, put the page number on a line of its own, and fill out % this line with blank space. (The \hfil is overwhelmed with the % fill leaders glue in \indexdotfill if the page number does fit.) \hfil\penalty50 \null\nobreak\indexdotfill % Have leaders before the page number. % % The `\ ' here is removed by the implicit \unskip that TeX does as % part of (the primitive) \par. Without it, a spurious underfull % \hbox ensues. \ #2% The page number ends the paragraph. \fi% \par \endgroup} % Like \dotfill except takes at least 1 em. \def\indexdotfill{\cleaders \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill} \def\primary #1{\line{#1\hfil}} \newskip\secondaryindent \secondaryindent=0.5cm \def\secondary #1#2{ {\parfillskip=0in \parskip=0in \hangindent =1in \hangafter=1 \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par }} % Define two-column mode, which we use to typeset indexes. % Adapted from the TeXbook, page 416, which is to say, % the manmac.tex format used to print the TeXbook itself. \catcode`\@=11 \newbox\partialpage \newdimen\doublecolumnhsize \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns % Grab any single-column material above us. \output = {\global\setbox\partialpage = \vbox{% % % Here is a possibility not foreseen in manmac: if we accumulate a % whole lot of material, we might end up calling this \output % routine twice in a row (see the doublecol-lose test, which is % essentially a couple of indexes with @setchapternewpage off). In % that case, we must prevent the second \partialpage from % simply overwriting the first, causing us to lose the page. % This will preserve it until a real output routine can ship it % out. Generally, \partialpage will be empty when this runs and % this will be a no-op. \unvbox\partialpage % % Unvbox the main output page. \unvbox255 \kern-\topskip \kern\baselineskip }}% \eject % % Use the double-column output routine for subsequent pages. \output = {\doublecolumnout}% % % Change the page size parameters. We could do this once outside this % routine, in each of @smallbook, @afourpaper, and the default 8.5x11 % format, but then we repeat the same computation. Repeating a couple % of assignments once per index is clearly meaningless for the % execution time, so we may as well do it in one place. % % First we halve the line length, less a little for the gutter between % the columns. We compute the gutter based on the line length, so it % changes automatically with the paper format. The magic constant % below is chosen so that the gutter has the same value (well, +-<1pt) % as it did when we hard-coded it. % % We put the result in a separate register, \doublecolumhsize, so we % can restore it in \pagesofar, after \hsize itself has (potentially) % been clobbered. % \doublecolumnhsize = \hsize \advance\doublecolumnhsize by -.04154\hsize \divide\doublecolumnhsize by 2 \hsize = \doublecolumnhsize % % Double the \vsize as well. (We don't need a separate register here, % since nobody clobbers \vsize.) \advance\vsize by -\ht\partialpage \vsize = 2\vsize } % The double-column output routine for all double-column pages except % the last. % \def\doublecolumnout{% \splittopskip=\topskip \splitmaxdepth=\maxdepth % Get the available space for the double columns -- the normal % (undoubled) page height minus any material left over from the % previous page. \dimen@ = \vsize \divide\dimen@ by 2 % % box0 will be the left-hand column, box2 the right. \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@ \onepageout\pagesofar \unvbox255 \penalty\outputpenalty } \def\pagesofar{% % Re-output the contents of the output page -- any previous material, % followed by the two boxes we just split, in box0 and box2. \advance\vsize by \ht\partialpage \unvbox\partialpage % \hsize = \doublecolumnhsize \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}% } \def\enddoublecolumns{% \output = {% % Split the last of the double-column material. Leave on the % current page, no automatic page break. \balancecolumns % % If we end up splitting too much material for the current page, % though, there will be another page break right after this \output % invocation ends. Having called \balancecolumns once, we do not % want to call it again. Therefore, reset \output to its normal % definition right away. (We hope \balancecolumns will never be % called on to balance too much material, but if it is, this makes % the output somewhat more palatable.) \global\output = {\onepageout{\pagecontents\PAGE}}% % % \pagegoal was set to the doubled \vsize above, since we restarted % the current page. We're now back to normal single-column % typesetting, so reset \pagegoal to the normal \vsize. \pagegoal = \vsize }% \eject \endgroup % started in \begindoublecolumns } \def\balancecolumns{% % Called at the end of the double column material. \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120. \dimen@ = \ht0 \advance\dimen@ by \topskip \advance\dimen@ by-\baselineskip \divide\dimen@ by 2 % target to split to %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}% \splittopskip = \topskip % Loop until we get a decent breakpoint. {% \vbadness = 10000 \loop \global\setbox3 = \copy0 \global\setbox1 = \vsplit3 to \dimen@ \ifdim\ht3>\dimen@ \global\advance\dimen@ by 1pt \repeat }% %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}% \setbox0=\vbox to\dimen@{\unvbox1}% \setbox2=\vbox to\dimen@{\unvbox3}% % \pagesofar } \catcode`\@ = \other \message{sectioning,} % Define chapters, sections, etc. \newcount\chapno \newcount\secno \secno=0 \newcount\subsecno \subsecno=0 \newcount\subsubsecno \subsubsecno=0 % This counter is funny since it counts through charcodes of letters A, B, ... \newcount\appendixno \appendixno = `\@ \def\appendixletter{\char\the\appendixno} % Each @chapter defines this as the name of the chapter. % page headings and footings can use it. @section does likewise. \def\thischapter{} \def\thissection{} \newcount\absseclevel % used to calculate proper heading level \newcount\secbase\secbase=0 % @raise/lowersections modify this count % @raisesections: treat @section as chapter, @subsection as section, etc. \def\raisesections{\global\advance\secbase by -1} \let\up=\raisesections % original BFox name % @lowersections: treat @chapter as section, @section as subsection, etc. \def\lowersections{\global\advance\secbase by 1} \let\down=\lowersections % original BFox name % Choose a numbered-heading macro % #1 is heading level if unmodified by @raisesections or @lowersections % #2 is text for heading \def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 \ifcase\absseclevel \chapterzzz{#2} \or \seczzz{#2} \or \numberedsubseczzz{#2} \or \numberedsubsubseczzz{#2} \else \ifnum \absseclevel<0 \chapterzzz{#2} \else \numberedsubsubseczzz{#2} \fi \fi } % like \numhead, but chooses appendix heading levels \def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 \ifcase\absseclevel \appendixzzz{#2} \or \appendixsectionzzz{#2} \or \appendixsubseczzz{#2} \or \appendixsubsubseczzz{#2} \else \ifnum \absseclevel<0 \appendixzzz{#2} \else \appendixsubsubseczzz{#2} \fi \fi } % like \numhead, but chooses numberless heading levels \def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 \ifcase\absseclevel \unnumberedzzz{#2} \or \unnumberedseczzz{#2} \or \unnumberedsubseczzz{#2} \or \unnumberedsubsubseczzz{#2} \else \ifnum \absseclevel<0 \unnumberedzzz{#2} \else \unnumberedsubsubseczzz{#2} \fi \fi } % @chapter, @appendix, @unnumbered. \def\thischaptername{No Chapter Title} \outer\def\chapter{\parsearg\chapteryyy} \def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz \def\chapterzzz #1{% \secno=0 \subsecno=0 \subsubsecno=0 \global\advance \chapno by 1 \message{\putwordChapter\space \the\chapno}% \chapmacro {#1}{\the\chapno}% \gdef\thissection{#1}% \gdef\thischaptername{#1}% % We don't substitute the actual chapter name into \thischapter % because we don't want its macros evaluated now. \xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}% \toks0 = {#1}% \edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}% {\the\chapno}}}% \temp \donoderef \global\let\section = \numberedsec \global\let\subsection = \numberedsubsec \global\let\subsubsection = \numberedsubsubsec } \outer\def\appendix{\parsearg\appendixyyy} \def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz \def\appendixzzz #1{% \secno=0 \subsecno=0 \subsubsecno=0 \global\advance \appendixno by 1 \message{\putwordAppendix\space \appendixletter}% \chapmacro {#1}{\putwordAppendix{} \appendixletter}% \gdef\thissection{#1}% \gdef\thischaptername{#1}% \xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}% \toks0 = {#1}% \edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}% {\putwordAppendix{} \appendixletter}}}% \temp \appendixnoderef \global\let\section = \appendixsec \global\let\subsection = \appendixsubsec \global\let\subsubsection = \appendixsubsubsec } % @centerchap is like @unnumbered, but the heading is centered. \outer\def\centerchap{\parsearg\centerchapyyy} \def\centerchapyyy #1{{\let\unnumbchapmacro=\centerchapmacro \unnumberedyyy{#1}}} % @top is like @unnumbered. \outer\def\top{\parsearg\unnumberedyyy} \outer\def\unnumbered{\parsearg\unnumberedyyy} \def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz \def\unnumberedzzz #1{% \secno=0 \subsecno=0 \subsubsecno=0 % % This used to be simply \message{#1}, but TeX fully expands the % argument to \message. Therefore, if #1 contained @-commands, TeX % expanded them. For example, in `@unnumbered The @cite{Book}', TeX % expanded @cite (which turns out to cause errors because \cite is meant % to be executed, not expanded). % % Anyway, we don't want the fully-expanded definition of @cite to appear % as a result of the \message, we just want `@cite' itself. We use % \the to achieve this: TeX expands \the only once, % simply yielding the contents of . (We also do this for % the toc entries.) \toks0 = {#1}\message{(\the\toks0)}% % \unnumbchapmacro {#1}% \gdef\thischapter{#1}\gdef\thissection{#1}% \toks0 = {#1}% \edef\temp{\noexpand\writetocentry{\realbackslash unnumbchapentry{\the\toks0}}}% \temp \unnumbnoderef \global\let\section = \unnumberedsec \global\let\subsection = \unnumberedsubsec \global\let\subsubsection = \unnumberedsubsubsec } % Sections. \outer\def\numberedsec{\parsearg\secyyy} \def\secyyy #1{\numhead1{#1}} % normally calls seczzz \def\seczzz #1{% \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}% \toks0 = {#1}% \edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}% {\the\chapno}{\the\secno}}}% \temp \donoderef \nobreak } \outer\def\appendixsection{\parsearg\appendixsecyyy} \outer\def\appendixsec{\parsearg\appendixsecyyy} \def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz \def\appendixsectionzzz #1{% \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}% \toks0 = {#1}% \edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}% {\appendixletter}{\the\secno}}}% \temp \appendixnoderef \nobreak } \outer\def\unnumberedsec{\parsearg\unnumberedsecyyy} \def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz \def\unnumberedseczzz #1{% \plainsecheading {#1}\gdef\thissection{#1}% \toks0 = {#1}% \edef\temp{\noexpand\writetocentry{\realbackslash unnumbsecentry{\the\toks0}}}% \temp \unnumbnoderef \nobreak } % Subsections. \outer\def\numberedsubsec{\parsearg\numberedsubsecyyy} \def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz \def\numberedsubseczzz #1{% \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}% \toks0 = {#1}% \edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}% {\the\chapno}{\the\secno}{\the\subsecno}}}% \temp \donoderef \nobreak } \outer\def\appendixsubsec{\parsearg\appendixsubsecyyy} \def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz \def\appendixsubseczzz #1{% \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}% \toks0 = {#1}% \edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}% {\appendixletter}{\the\secno}{\the\subsecno}}}% \temp \appendixnoderef \nobreak } \outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy} \def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz \def\unnumberedsubseczzz #1{% \plainsubsecheading {#1}\gdef\thissection{#1}% \toks0 = {#1}% \edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsecentry% {\the\toks0}}}% \temp \unnumbnoderef \nobreak } % Subsubsections. \outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy} \def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz \def\numberedsubsubseczzz #1{% \gdef\thissection{#1}\global\advance \subsubsecno by 1 % \subsubsecheading {#1} {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}% \toks0 = {#1}% \edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}% {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}% \temp \donoderef \nobreak } \outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy} \def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz \def\appendixsubsubseczzz #1{% \gdef\thissection{#1}\global\advance \subsubsecno by 1 % \subsubsecheading {#1} {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}% \toks0 = {#1}% \edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}% {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}% \temp \appendixnoderef \nobreak } \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy} \def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz \def\unnumberedsubsubseczzz #1{% \plainsubsubsecheading {#1}\gdef\thissection{#1}% \toks0 = {#1}% \edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsubsecentry% {\the\toks0}}}% \temp \unnumbnoderef \nobreak } % These are variants which are not "outer", so they can appear in @ifinfo. % Actually, they should now be obsolete; ordinary section commands should work. \def\infotop{\parsearg\unnumberedzzz} \def\infounnumbered{\parsearg\unnumberedzzz} \def\infounnumberedsec{\parsearg\unnumberedseczzz} \def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz} \def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz} \def\infoappendix{\parsearg\appendixzzz} \def\infoappendixsec{\parsearg\appendixseczzz} \def\infoappendixsubsec{\parsearg\appendixsubseczzz} \def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz} \def\infochapter{\parsearg\chapterzzz} \def\infosection{\parsearg\sectionzzz} \def\infosubsection{\parsearg\subsectionzzz} \def\infosubsubsection{\parsearg\subsubsectionzzz} % These macros control what the section commands do, according % to what kind of chapter we are in (ordinary, appendix, or unnumbered). % Define them by default for a numbered chapter. \global\let\section = \numberedsec \global\let\subsection = \numberedsubsec \global\let\subsubsection = \numberedsubsubsec % Define @majorheading, @heading and @subheading % NOTE on use of \vbox for chapter headings, section headings, and such: % 1) We use \vbox rather than the earlier \line to permit % overlong headings to fold. % 2) \hyphenpenalty is set to 10000 because hyphenation in a % heading is obnoxious; this forbids it. % 3) Likewise, headings look best if no \parindent is used, and % if justification is not attempted. Hence \raggedright. \def\majorheading{\parsearg\majorheadingzzz} \def\majorheadingzzz #1{% {\advance\chapheadingskip by 10pt \chapbreak }% {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt\raggedright \rm #1\hfill}}\bigskip \par\penalty 200} \def\chapheading{\parsearg\chapheadingzzz} \def\chapheadingzzz #1{\chapbreak % {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt\raggedright \rm #1\hfill}}\bigskip \par\penalty 200} % @heading, @subheading, @subsubheading. \def\heading{\parsearg\plainsecheading} \def\subheading{\parsearg\plainsubsecheading} \def\subsubheading{\parsearg\plainsubsubsecheading} % These macros generate a chapter, section, etc. heading only % (including whitespace, linebreaking, etc. around it), % given all the information in convenient, parsed form. %%% Args are the skip and penalty (usually negative) \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} \def\setchapterstyle #1 {\csname CHAPF#1\endcsname} %%% Define plain chapter starts, and page on/off switching for it % Parameter controlling skip before chapter headings (if needed) \newskip\chapheadingskip \def\chapbreak{\dobreak \chapheadingskip {-4000}} \def\chappager{\par\vfill\supereject} \def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi} \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname} \def\CHAPPAGoff{% \global\let\contentsalignmacro = \chappager \global\let\pchapsepmacro=\chapbreak \global\let\pagealignmacro=\chappager} \def\CHAPPAGon{% \global\let\contentsalignmacro = \chappager \global\let\pchapsepmacro=\chappager \global\let\pagealignmacro=\chappager \global\def\HEADINGSon{\HEADINGSsingle}} \def\CHAPPAGodd{ \global\let\contentsalignmacro = \chapoddpage \global\let\pchapsepmacro=\chapoddpage \global\let\pagealignmacro=\chapoddpage \global\def\HEADINGSon{\HEADINGSdouble}} \CHAPPAGon \def\CHAPFplain{ \global\let\chapmacro=\chfplain \global\let\unnumbchapmacro=\unnchfplain \global\let\centerchapmacro=\centerchfplain} % Plain chapter opening. % #1 is the text, #2 the chapter number or empty if unnumbered. \def\chfplain#1#2{% \pchapsepmacro {% \chapfonts \rm \def\chapnum{#2}% \setbox0 = \hbox{#2\ifx\chapnum\empty\else\enspace\fi}% \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright \hangindent = \wd0 \centerparametersmaybe \unhbox0 #1\par}% }% \nobreak\bigskip % no page break after a chapter title \nobreak } % Plain opening for unnumbered. \def\unnchfplain#1{\chfplain{#1}{}} % @centerchap -- centered and unnumbered. \let\centerparametersmaybe = \relax \def\centerchfplain#1{{% \def\centerparametersmaybe{% \advance\rightskip by 3\rightskip \leftskip = \rightskip \parfillskip = 0pt }% \chfplain{#1}{}% }} \CHAPFplain % The default \def\unnchfopen #1{% \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt\raggedright \rm #1\hfill}}\bigskip \par\nobreak } \def\chfopen #1#2{\chapoddpage {\chapfonts \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% \par\penalty 5000 % } \def\centerchfopen #1{% \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt \hfill {\rm #1}\hfill}}\bigskip \par\nobreak } \def\CHAPFopen{ \global\let\chapmacro=\chfopen \global\let\unnumbchapmacro=\unnchfopen \global\let\centerchapmacro=\centerchfopen} % Section titles. \newskip\secheadingskip \def\secheadingbreak{\dobreak \secheadingskip {-1000}} \def\secheading#1#2#3{\sectionheading{sec}{#2.#3}{#1}} \def\plainsecheading#1{\sectionheading{sec}{}{#1}} % Subsection titles. \newskip \subsecheadingskip \def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}} \def\subsecheading#1#2#3#4{\sectionheading{subsec}{#2.#3.#4}{#1}} \def\plainsubsecheading#1{\sectionheading{subsec}{}{#1}} % Subsubsection titles. \let\subsubsecheadingskip = \subsecheadingskip \let\subsubsecheadingbreak = \subsecheadingbreak \def\subsubsecheading#1#2#3#4#5{\sectionheading{subsubsec}{#2.#3.#4.#5}{#1}} \def\plainsubsubsecheading#1{\sectionheading{subsubsec}{}{#1}} % Print any size section title. % % #1 is the section type (sec/subsec/subsubsec), #2 is the section % number (maybe empty), #3 the text. \def\sectionheading#1#2#3{% {% \expandafter\advance\csname #1headingskip\endcsname by \parskip \csname #1headingbreak\endcsname }% {% % Switch to the right set of fonts. \csname #1fonts\endcsname \rm % % Only insert the separating space if we have a section number. \def\secnum{#2}% \setbox0 = \hbox{#2\ifx\secnum\empty\else\enspace\fi}% % \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright \hangindent = \wd0 % zero if no section number \unhbox0 #3}% }% \ifdim\parskip<10pt \nobreak\kern10pt\nobreak\kern-\parskip\fi \nobreak } \message{toc,} \newwrite\tocfile % Write an entry to the toc file, opening it if necessary. % Called from @chapter, etc. We supply {\folio} at the end of the % argument, which will end up as the last argument to the \...entry macro. % % We open the .toc file here instead of at @setfilename or any other % given time so that @contents can be put in the document anywhere. % \newif\iftocfileopened \def\writetocentry#1{% \iftocfileopened\else \immediate\openout\tocfile = \jobname.toc \global\tocfileopenedtrue \fi \iflinks \write\tocfile{#1{\folio}}\fi } \newskip\contentsrightmargin \contentsrightmargin=1in \newcount\savepageno \newcount\lastnegativepageno \lastnegativepageno = -1 % Finish up the main text and prepare to read what we've written % to \tocfile. % \def\startcontents#1{% % If @setchapternewpage on, and @headings double, the contents should % start on an odd page, unlike chapters. Thus, we maintain % \contentsalignmacro in parallel with \pagealignmacro. % From: Torbjorn Granlund \contentsalignmacro \immediate\closeout\tocfile % % Don't need to put `Contents' or `Short Contents' in the headline. % It is abundantly clear what they are. \unnumbchapmacro{#1}\def\thischapter{}% \savepageno = \pageno \begingroup % Set up to handle contents files properly. \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11 % We can't do this, because then an actual ^ in a section % title fails, e.g., @chapter ^ -- exponentiation. --karl, 9jul97. %\catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi \raggedbottom % Worry more about breakpoints than the bottom. \advance\hsize by -\contentsrightmargin % Don't use the full line length. % % Roman numerals for page numbers. \ifnum \pageno>0 \pageno = \lastnegativepageno \fi } % Normal (long) toc. \def\contents{% \startcontents{\putwordTableofContents}% \openin 1 \jobname.toc \ifeof 1 \else \closein 1 \input \jobname.toc \fi \vfill \eject \endgroup \lastnegativepageno = \pageno \pageno = \savepageno } % And just the chapters. \def\summarycontents{% \startcontents{\putwordShortContents}% % \let\chapentry = \shortchapentry \let\unnumbchapentry = \shortunnumberedentry % We want a true roman here for the page numbers. \secfonts \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl \rm \hyphenpenalty = 10000 \advance\baselineskip by 1pt % Open it up a little. \def\secentry ##1##2##3##4{} \def\unnumbsecentry ##1##2{} \def\subsecentry ##1##2##3##4##5{} \def\unnumbsubsecentry ##1##2{} \def\subsubsecentry ##1##2##3##4##5##6{} \def\unnumbsubsubsecentry ##1##2{} \openin 1 \jobname.toc \ifeof 1 \else \closein 1 \input \jobname.toc \fi \vfill \eject \endgroup \lastnegativepageno = \pageno \pageno = \savepageno } \let\shortcontents = \summarycontents % These macros generate individual entries in the table of contents. % The first argument is the chapter or section name. % The last argument is the page number. % The arguments in between are the chapter number, section number, ... % Chapter-level things, for both the long and short contents. \def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}} % See comments in \dochapentry re vbox and related settings \def\shortchapentry#1#2#3{% \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno{#3}}% } % Typeset the label for a chapter or appendix for the short contents. % The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter. % We could simplify the code here by writing out an \appendixentry % command in the toc file for appendices, instead of using \chapentry % for both, but it doesn't seem worth it. \setbox0 = \hbox{\shortcontrm \putwordAppendix } \newdimen\shortappendixwidth \shortappendixwidth = \wd0 \def\shortchaplabel#1{% % We typeset #1 in a box of constant width, regardless of the text of % #1, so the chapter titles will come out aligned. \setbox0 = \hbox{#1}% \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi % % This space should be plenty, since a single number is .5em, and the % widest letter (M) is 1em, at least in the Computer Modern fonts. % (This space doesn't include the extra space that gets added after % the label; that gets put in by \shortchapentry above.) \advance\dimen0 by 1.1em \hbox to \dimen0{#1\hfil}% } \def\unnumbchapentry#1#2{\dochapentry{#1}{#2}} \def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno{#2}}} % Sections. \def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}} \def\unnumbsecentry#1#2{\dosecentry{#1}{#2}} % Subsections. \def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}} \def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}} % And subsubsections. \def\subsubsecentry#1#2#3#4#5#6{% \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}} \def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}} % This parameter controls the indentation of the various levels. \newdimen\tocindent \tocindent = 3pc % Now for the actual typesetting. In all these, #1 is the text and #2 is the % page number. % % If the toc has to be broken over pages, we want it to be at chapters % if at all possible; hence the \penalty. \def\dochapentry#1#2{% \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip \begingroup \chapentryfonts \tocentry{#1}{\dopageno{#2}}% \endgroup \nobreak\vskip .25\baselineskip plus.1\baselineskip } \def\dosecentry#1#2{\begingroup \secentryfonts \leftskip=\tocindent \tocentry{#1}{\dopageno{#2}}% \endgroup} \def\dosubsecentry#1#2{\begingroup \subsecentryfonts \leftskip=2\tocindent \tocentry{#1}{\dopageno{#2}}% \endgroup} \def\dosubsubsecentry#1#2{\begingroup \subsubsecentryfonts \leftskip=3\tocindent \tocentry{#1}{\dopageno{#2}}% \endgroup} % Final typesetting of a toc entry; we use the same \entry macro as for % the index entries, but we want to suppress hyphenation here. (We % can't do that in the \entry macro, since index entries might consist % of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.) \def\tocentry#1#2{\begingroup \vskip 0pt plus1pt % allow a little stretch for the sake of nice page breaks % Do not use \turnoffactive in these arguments. Since the toc is % typeset in cmr, so characters such as _ would come out wrong; we % have to do the usual translation tricks. \entry{#1}{#2}% \endgroup} % Space between chapter (or whatever) number and the title. \def\labelspace{\hskip1em \relax} \def\dopageno#1{{\rm #1}} \def\doshortpageno#1{{\rm #1}} \def\chapentryfonts{\secfonts \rm} \def\secentryfonts{\textfonts} \let\subsecentryfonts = \textfonts \let\subsubsecentryfonts = \textfonts \message{environments,} % Since these characters are used in examples, it should be an even number of % \tt widths. Each \tt character is 1en, so two makes it 1em. % Furthermore, these definitions must come after we define our fonts. \newbox\dblarrowbox \newbox\longdblarrowbox \newbox\pushcharbox \newbox\bullbox \newbox\equivbox \newbox\errorbox %{\tentt %\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil} %\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil} %\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil} %\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil} % Adapted from the manmac format (p.420 of TeXbook) %\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex % depth .1ex\hfil} %} % @point{}, @result{}, @expansion{}, @print{}, @equiv{}. \def\point{$\star$} \def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} \def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}} \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} \def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}} % Adapted from the TeXbook's \boxit. {\tentt \global\dimen0 = 3em}% Width of the box. \dimen2 = .55pt % Thickness of rules % The text. (`r' is open on the right, `e' somewhat less so on the left.) \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt} \global\setbox\errorbox=\hbox to \dimen0{\hfil \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. \advance\hsize by -2\dimen2 % Rules. \vbox{ \hrule height\dimen2 \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. \kern3pt\vrule width\dimen2}% Space to right. \hrule height\dimen2} \hfil} % The @error{} command. \def\error{\leavevmode\lower.7ex\copy\errorbox} % @tex ... @end tex escapes into raw Tex temporarily. % One exception: @ is still an escape character, so that @end tex works. % But \@ or @@ will get a plain tex @ character. \def\tex{\begingroup \catcode `\\=0 \catcode `\{=1 \catcode `\}=2 \catcode `\$=3 \catcode `\&=4 \catcode `\#=6 \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie \catcode `\%=14 \catcode 43=12 % plus \catcode`\"=12 \catcode`\==12 \catcode`\|=12 \catcode`\<=12 \catcode`\>=12 \escapechar=`\\ % \let\b=\ptexb \let\bullet=\ptexbullet \let\c=\ptexc \let\,=\ptexcomma \let\.=\ptexdot \let\dots=\ptexdots \let\equiv=\ptexequiv \let\!=\ptexexclam \let\i=\ptexi \let\{=\ptexlbrace \let\+=\tabalign \let\}=\ptexrbrace \let\*=\ptexstar \let\t=\ptext % \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}% \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}% \def\@{@}% \let\Etex=\endgroup} % Define @lisp ... @endlisp. % @lisp does a \begingroup so it can rebind things, % including the definition of @endlisp (which normally is erroneous). % Amount to narrow the margins by for @lisp. \newskip\lispnarrowing \lispnarrowing=0.4in % This is the definition that ^^M gets inside @lisp, @example, and other % such environments. \null is better than a space, since it doesn't % have any width. \def\lisppar{\null\endgraf} % Make each space character in the input produce a normal interword % space in the output. Don't allow a line break at this space, as this % is used only in environments like @example, where each line of input % should produce a line of output anyway. % {\obeyspaces % \gdef\sepspaces{\obeyspaces\let =\tie}} % Define \obeyedspace to be our active space, whatever it is. This is % for use in \parsearg. {\sepspaces% \global\let\obeyedspace= } % This space is always present above and below environments. \newskip\envskipamount \envskipamount = 0pt % Make spacing and below environment symmetrical. We use \parskip here % to help in doing that, since in @example-like environments \parskip % is reset to zero; thus the \afterenvbreak inserts no space -- but the % start of the next paragraph will insert \parskip % \def\aboveenvbreak{{\advance\envskipamount by \parskip \endgraf \ifdim\lastskip<\envskipamount \removelastskip \penalty-50 \vskip\envskipamount \fi}} \let\afterenvbreak = \aboveenvbreak % \nonarrowing is a flag. If "set", @lisp etc don't narrow margins. \let\nonarrowing=\relax % @cartouche ... @end cartouche: draw rectangle w/rounded corners around % environment contents. \font\circle=lcircle10 \newdimen\circthick \newdimen\cartouter\newdimen\cartinner \newskip\normbskip\newskip\normpskip\newskip\normlskip \circthick=\fontdimen8\circle % \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth \def\ctr{{\hskip 6pt\circle\char'010}} \def\cbl{{\circle\char'012\hskip -6pt}} \def\cbr{{\hskip 6pt\circle\char'011}} \def\carttop{\hbox to \cartouter{\hskip\lskip \ctl\leaders\hrule height\circthick\hfil\ctr \hskip\rskip}} \def\cartbot{\hbox to \cartouter{\hskip\lskip \cbl\leaders\hrule height\circthick\hfil\cbr \hskip\rskip}} % \newskip\lskip\newskip\rskip \long\def\cartouche{% \begingroup \lskip=\leftskip \rskip=\rightskip \leftskip=0pt\rightskip=0pt %we want these *outside*. \cartinner=\hsize \advance\cartinner by-\lskip \advance\cartinner by-\rskip \cartouter=\hsize \advance\cartouter by 18.4pt % allow for 3pt kerns on either % side, and for 6pt waste from % each corner char, and rule thickness \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip % Flag to tell @lisp, etc., not to narrow margin. \let\nonarrowing=\comment \vbox\bgroup \baselineskip=0pt\parskip=0pt\lineskip=0pt \carttop \hbox\bgroup \hskip\lskip \vrule\kern3pt \vbox\bgroup \hsize=\cartinner \kern3pt \begingroup \baselineskip=\normbskip \lineskip=\normlskip \parskip=\normpskip \vskip -\parskip \def\Ecartouche{% \endgroup \kern3pt \egroup \kern3pt\vrule \hskip\rskip \egroup \cartbot \egroup \endgroup }} % This macro is called at the beginning of all the @example variants, % inside a group. \def\nonfillstart{% \aboveenvbreak \inENV % This group ends at the end of the body \hfuzz = 12pt % Don't be fussy \sepspaces % Make spaces be word-separators rather than space tokens. \singlespace \let\par = \lisppar % don't ignore blank lines \obeylines % each line of input is a line of output \parskip = 0pt \parindent = 0pt \emergencystretch = 0pt % don't try to avoid overfull boxes % @cartouche defines \nonarrowing to inhibit narrowing % at next level down. \ifx\nonarrowing\relax \advance \leftskip by \lispnarrowing \exdentamount=\lispnarrowing \let\exdent=\nofillexdent \let\nonarrowing=\relax \fi } % Define the \E... control sequence only if we are inside the particular % environment, so the error checking in \end will work. % % To end an @example-like environment, we first end the paragraph (via % \afterenvbreak's vertical glue), and then the group. That way we keep % the zero \parskip that the environments set -- \parskip glue will be % inserted at the beginning of the next paragraph in the document, after % the environment. % \def\nonfillfinish{\afterenvbreak\endgroup} % @lisp: indented, narrowed, typewriter font. \def\lisp{\begingroup \nonfillstart \let\Elisp = \nonfillfinish \tt \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special. \gobble % eat return } % @example: Same as @lisp. \def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp} % @small... is usually equivalent to the non-small (@smallbook % redefines). We must call \example (or whatever) last in the % definition, since it reads the return following the @example (or % whatever) command. % % This actually allows (for example) @end display inside an % @smalldisplay. Too bad, but makeinfo will catch the error anyway. % \def\smalldisplay{\begingroup\def\Esmalldisplay{\nonfillfinish\endgroup}\display} \def\smallexample{\begingroup\def\Esmallexample{\nonfillfinish\endgroup}\lisp} \def\smallformat{\begingroup\def\Esmallformat{\nonfillfinish\endgroup}\format} \def\smalllisp{\begingroup\def\Esmalllisp{\nonfillfinish\endgroup}\lisp} % Real @smallexample and @smalllisp (when @smallbook): use smaller fonts. % Originally contributed by Pavel@xerox. \def\smalllispx{\begingroup \def\Esmalllisp{\nonfillfinish\endgroup}% \def\Esmallexample{\nonfillfinish\endgroup}% \indexfonts \lisp } % @display: same as @lisp except keep current font. % \def\display{\begingroup \nonfillstart \let\Edisplay = \nonfillfinish \gobble } % @smalldisplay (when @smallbook): @display plus smaller fonts. % \def\smalldisplayx{\begingroup \def\Esmalldisplay{\nonfillfinish\endgroup}% \indexfonts \rm \display } % @format: same as @display except don't narrow margins. % \def\format{\begingroup \let\nonarrowing = t \nonfillstart \let\Eformat = \nonfillfinish \gobble } % @smallformat (when @smallbook): @format plus smaller fonts. % \def\smallformatx{\begingroup \def\Esmallformat{\nonfillfinish\endgroup}% \indexfonts \rm \format } % @flushleft (same as @format). % \def\flushleft{\begingroup \def\Eflushleft{\nonfillfinish\endgroup}\format} % @flushright. % \def\flushright{\begingroup \let\nonarrowing = t \nonfillstart \let\Eflushright = \nonfillfinish \advance\leftskip by 0pt plus 1fill \gobble } % @quotation does normal linebreaking (hence we can't use \nonfillstart) % and narrows the margins. % \def\quotation{% \begingroup\inENV %This group ends at the end of the @quotation body {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip \singlespace \parindent=0pt % We have retained a nonzero parskip for the environment, since we're % doing normal filling. So to avoid extra space below the environment... \def\Equotation{\parskip = 0pt \nonfillfinish}% % % @cartouche defines \nonarrowing to inhibit narrowing at next level down. \ifx\nonarrowing\relax \advance\leftskip by \lispnarrowing \advance\rightskip by \lispnarrowing \exdentamount = \lispnarrowing \let\nonarrowing = \relax \fi } \message{defuns,} % Define formatter for defuns % First, allow user to change definition object font (\df) internally \def\setdeffont #1 {\csname DEF#1\endcsname} \newskip\defbodyindent \defbodyindent=.4in \newskip\defargsindent \defargsindent=50pt \newskip\deftypemargin \deftypemargin=12pt \newskip\deflastargmargin \deflastargmargin=18pt \newcount\parencount % define \functionparens, which makes ( and ) and & do special things. % \functionparens affects the group it is contained in. \def\activeparens{% \catcode`\(=\active \catcode`\)=\active \catcode`\&=\active \catcode`\[=\active \catcode`\]=\active} % Make control sequences which act like normal parenthesis chars. \let\lparen = ( \let\rparen = ) {\activeparens % Now, smart parens don't turn on until &foo (see \amprm) % Be sure that we always have a definition for `(', etc. For example, % if the fn name has parens in it, \boldbrax will not be in effect yet, % so TeX would otherwise complain about undefined control sequence. \global\let(=\lparen \global\let)=\rparen \global\let[=\lbrack \global\let]=\rbrack \gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 } \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} % This is used to turn on special parens % but make & act ordinary (given that it's active). \gdef\boldbraxnoamp{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb\let&=\ampnr} % Definitions of (, ) and & used in args for functions. % This is the definition of ( outside of all parentheses. \gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested \global\advance\parencount by 1 } % % This is the definition of ( when already inside a level of parens. \gdef\opnested{\char`\(\global\advance\parencount by 1 } % \gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0. % also in that case restore the outer-level definition of (. \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi \global\advance \parencount by -1 } % If we encounter &foo, then turn on ()-hacking afterwards \gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ } % \gdef\normalparens{\boldbrax\let&=\ampnr} } % End of definition inside \activeparens %% These parens (in \boldbrax) actually are a little bolder than the %% contained text. This is especially needed for [ and ] \def\opnr{{\sf\char`\(}\global\advance\parencount by 1 } \def\clnr{{\sf\char`\)}\global\advance\parencount by -1 } \def\ampnr{\&} \def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}} % First, defname, which formats the header line itself. % #1 should be the function name. % #2 should be the type of definition, such as "Function". \def\defname #1#2{% % Get the values of \leftskip and \rightskip as they were % outside the @def... \dimen2=\leftskip \advance\dimen2 by -\defbodyindent \noindent \setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}% \dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line \dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations \parshape 2 0in \dimen0 \defargsindent \dimen1 % Now output arg 2 ("Function" or some such) % ending at \deftypemargin from the right margin, % but stuck inside a box of width 0 so it does not interfere with linebreaking {% Adjust \hsize to exclude the ambient margins, % so that \rightline will obey them. \advance \hsize by -\dimen2 \rlap{\rightline{{\rm #2}\hskip -1.25pc }}}% % Make all lines underfull and no complaints: \tolerance=10000 \hbadness=10000 \advance\leftskip by -\defbodyindent \exdentamount=\defbodyindent {\df #1}\enskip % Generate function name } % Actually process the body of a definition % #1 should be the terminating control sequence, such as \Edefun. % #2 should be the "another name" control sequence, such as \defunx. % #3 should be the control sequence that actually processes the header, % such as \defunheader. \def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody \medbreak % % Define the end token that this defining construct specifies % so that it will exit this group. \def#1{\endgraf\endgroup\medbreak}% \def#2{\begingroup\obeylines\activeparens\spacesplit#3}% \parindent=0in \advance\leftskip by \defbodyindent \exdentamount=\defbodyindent \begingroup % \catcode 61=\active % 61 is `=' \obeylines\activeparens\spacesplit#3} % #1 is the \E... control sequence to end the definition (which we define). % #2 is the \...x control sequence for consecutive fns (which we define). % #3 is the control sequence to call to resume processing. % #4, delimited by the space, is the class name. % \def\defmethparsebody#1#2#3#4 {\begingroup\inENV % \medbreak % % Define the end token that this defining construct specifies % so that it will exit this group. \def#1{\endgraf\endgroup\medbreak}% \def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}% \parindent=0in \advance\leftskip by \defbodyindent \exdentamount=\defbodyindent \begingroup\obeylines\activeparens\spacesplit{#3{#4}}} % @deftypemethod has an extra argument that nothing else does. Sigh. % #1 is the \E... control sequence to end the definition (which we define). % #2 is the \...x control sequence for consecutive fns (which we define). % #3 is the control sequence to call to resume processing. % #4, delimited by the space, is the class name. % #5 is the method's return type. % \def\deftypemethparsebody#1#2#3#4 #5 {\begingroup\inENV % \medbreak % % Define the end token that this defining construct specifies % so that it will exit this group. \def#1{\endgraf\endgroup\medbreak}% \def#2##1 ##2 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}{##2}}}% \parindent=0in \advance\leftskip by \defbodyindent \exdentamount=\defbodyindent \begingroup\obeylines\activeparens\spacesplit{#3{#4}{#5}}} \def\defopparsebody #1#2#3#4#5 {\begingroup\inENV % \medbreak % % Define the end token that this defining construct specifies % so that it will exit this group. \def#1{\endgraf\endgroup\medbreak}% \def#2##1 ##2 {\def#4{##1}% \begingroup\obeylines\activeparens\spacesplit{#3{##2}}}% \parindent=0in \advance\leftskip by \defbodyindent \exdentamount=\defbodyindent \begingroup\obeylines\activeparens\spacesplit{#3{#5}}} % These parsing functions are similar to the preceding ones % except that they do not make parens into active characters. % These are used for "variables" since they have no arguments. \def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody \medbreak % % Define the end token that this defining construct specifies % so that it will exit this group. \def#1{\endgraf\endgroup\medbreak}% \def#2{\begingroup\obeylines\spacesplit#3}% \parindent=0in \advance\leftskip by \defbodyindent \exdentamount=\defbodyindent \begingroup % \catcode 61=\active % \obeylines\spacesplit#3} % This is used for \def{tp,vr}parsebody. It could probably be used for % some of the others, too, with some judicious conditionals. % \def\parsebodycommon#1#2#3{% \begingroup\inENV % \medbreak % % Define the end token that this defining construct specifies % so that it will exit this group. \def#1{\endgraf\endgroup\medbreak}% \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}% \parindent=0in \advance\leftskip by \defbodyindent \exdentamount=\defbodyindent \begingroup\obeylines } \def\defvrparsebody#1#2#3#4 {% \parsebodycommon{#1}{#2}{#3}% \spacesplit{#3{#4}}% } % This loses on `@deftp {Data Type} {struct termios}' -- it thinks the % type is just `struct', because we lose the braces in `{struct % termios}' when \spacesplit reads its undelimited argument. Sigh. % \let\deftpparsebody=\defvrparsebody % % So, to get around this, we put \empty in with the type name. That % way, TeX won't find exactly `{...}' as an undelimited argument, and % won't strip off the braces. % \def\deftpparsebody #1#2#3#4 {% \parsebodycommon{#1}{#2}{#3}% \spacesplit{\parsetpheaderline{#3{#4}}}\empty } % Fine, but then we have to eventually remove the \empty *and* the % braces (if any). That's what this does. % \def\removeemptybraces\empty#1\relax{#1} % After \spacesplit has done its work, this is called -- #1 is the final % thing to call, #2 the type name (which starts with \empty), and #3 % (which might be empty) the arguments. % \def\parsetpheaderline#1#2#3{% #1{\removeemptybraces#2\relax}{#3}% }% \def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV % \medbreak % % Define the end token that this defining construct specifies % so that it will exit this group. \def#1{\endgraf\endgroup\medbreak}% \def#2##1 ##2 {\def#4{##1}% \begingroup\obeylines\spacesplit{#3{##2}}}% \parindent=0in \advance\leftskip by \defbodyindent \exdentamount=\defbodyindent \begingroup\obeylines\spacesplit{#3{#5}}} % Split up #2 at the first space token. % call #1 with two arguments: % the first is all of #2 before the space token, % the second is all of #2 after that space token. % If #2 contains no space token, all of it is passed as the first arg % and the second is passed as empty. {\obeylines \gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}% \long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{% \ifx\relax #3% #1{#2}{}\else #1{#2}{#3#4}\fi}} % So much for the things common to all kinds of definitions. % Define @defun. % First, define the processing that is wanted for arguments of \defun % Use this to expand the args and terminate the paragraph they make up \def\defunargs #1{\functionparens \sl % Expand, preventing hyphenation at `-' chars. % Note that groups don't affect changes in \hyphenchar. \hyphenchar\tensl=0 #1% \hyphenchar\tensl=45 \ifnum\parencount=0 \else \errmessage{Unbalanced parentheses in @def}\fi% \interlinepenalty=10000 \advance\rightskip by 0pt plus 1fil \endgraf\nobreak\vskip -\parskip\nobreak } \def\deftypefunargs #1{% % Expand, preventing hyphenation at `-' chars. % Note that groups don't affect changes in \hyphenchar. % Use \boldbraxnoamp, not \functionparens, so that & is not special. \boldbraxnoamp \tclose{#1}% avoid \code because of side effects on active chars \interlinepenalty=10000 \advance\rightskip by 0pt plus 1fil \endgraf\nobreak\vskip -\parskip\nobreak } % Do complete processing of one @defun or @defunx line already parsed. % @deffn Command forward-char nchars \def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader} \def\deffnheader #1#2#3{\doind {fn}{\code{#2}}% \begingroup\defname {#2}{#1}\defunargs{#3}\endgroup % \catcode 61=\other % Turn off change made in \defparsebody } % @defun == @deffn Function \def\defun{\defparsebody\Edefun\defunx\defunheader} \def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index \begingroup\defname {#1}{Function}% \defunargs {#2}\endgroup % \catcode 61=\other % Turn off change made in \defparsebody } % @deftypefun int foobar (int @var{foo}, float @var{bar}) \def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader} % #1 is the data type. #2 is the name and args. \def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax} % #1 is the data type, #2 the name, #3 the args. \def\deftypefunheaderx #1#2 #3\relax{% \doind {fn}{\code{#2}}% Make entry in function index \begingroup\defname {\defheaderxcond#1\relax$$$#2}{Function}% \deftypefunargs {#3}\endgroup % \catcode 61=\other % Turn off change made in \defparsebody } % @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar}) \def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader} % \defheaderxcond#1\relax$$$ % puts #1 in @code, followed by a space, but does nothing if #1 is null. \def\defheaderxcond#1#2$$${\ifx#1\relax\else\code{#1#2} \fi} % #1 is the classification. #2 is the data type. #3 is the name and args. \def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax} % #1 is the classification, #2 the data type, #3 the name, #4 the args. \def\deftypefnheaderx #1#2#3 #4\relax{% \doind {fn}{\code{#3}}% Make entry in function index \begingroup \normalparens % notably, turn off `&' magic, which prevents % at least some C++ text from working \defname {\defheaderxcond#2\relax$$$#3}{#1}% \deftypefunargs {#4}\endgroup % \catcode 61=\other % Turn off change made in \defparsebody } % @defmac == @deffn Macro \def\defmac{\defparsebody\Edefmac\defmacx\defmacheader} \def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index \begingroup\defname {#1}{Macro}% \defunargs {#2}\endgroup % \catcode 61=\other % Turn off change made in \defparsebody } % @defspec == @deffn Special Form \def\defspec{\defparsebody\Edefspec\defspecx\defspecheader} \def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index \begingroup\defname {#1}{Special Form}% \defunargs {#2}\endgroup % \catcode 61=\other % Turn off change made in \defparsebody } % This definition is run if you use @defunx % anywhere other than immediately after a @defun or @defunx. \def\deffnx #1 {\errmessage{@deffnx in invalid context}} \def\defunx #1 {\errmessage{@defunx in invalid context}} \def\defmacx #1 {\errmessage{@defmacx in invalid context}} \def\defspecx #1 {\errmessage{@defspecx in invalid context}} \def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}} \def\deftypemethodx #1 {\errmessage{@deftypemethodx in invalid context}} \def\deftypefunx #1 {\errmessage{@deftypefunx in invalid context}} % @defmethod, and so on % @defop CATEGORY CLASS OPERATION ARG... \def\defop #1 {\def\defoptype{#1}% \defopparsebody\Edefop\defopx\defopheader\defoptype} \def\defopheader #1#2#3{% \dosubind {fn}{\code{#2}}{\putwordon\ #1}% Make entry in function index \begingroup\defname {#2}{\defoptype{} on #1}% \defunargs {#3}\endgroup % } % @deftypemethod CLASS RETURN-TYPE METHOD ARG... % \def\deftypemethod{% \deftypemethparsebody\Edeftypemethod\deftypemethodx\deftypemethodheader} % % #1 is the class name, #2 the data type, #3 the method name, #4 the args. \def\deftypemethodheader#1#2#3#4{% \dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index \begingroup \defname{\defheaderxcond#2\relax$$$#3}{\putwordMethodon\ \code{#1}}% \deftypefunargs{#4}% \endgroup } % @defmethod == @defop Method % \def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader} % % #1 is the class name, #2 the method name, #3 the args. \def\defmethodheader#1#2#3{% \dosubind{fn}{\code{#2}}{\putwordon\ \code{#1}}% entry in function index \begingroup \defname{#2}{\putwordMethodon\ \code{#1}}% \defunargs{#3}% \endgroup } % @defcv {Class Option} foo-class foo-flag \def\defcv #1 {\def\defcvtype{#1}% \defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype} \def\defcvarheader #1#2#3{% \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index \begingroup\defname {#2}{\defcvtype{} of #1}% \defvarargs {#3}\endgroup % } % @defivar == @defcv {Instance Variable} \def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader} \def\defivarheader #1#2#3{% \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index \begingroup\defname {#2}{Instance Variable of #1}% \defvarargs {#3}\endgroup % } % These definitions are run if you use @defmethodx, etc., % anywhere other than immediately after a @defmethod, etc. \def\defopx #1 {\errmessage{@defopx in invalid context}} \def\defmethodx #1 {\errmessage{@defmethodx in invalid context}} \def\defcvx #1 {\errmessage{@defcvx in invalid context}} \def\defivarx #1 {\errmessage{@defivarx in invalid context}} % Now @defvar % First, define the processing that is wanted for arguments of @defvar. % This is actually simple: just print them in roman. % This must expand the args and terminate the paragraph they make up \def\defvarargs #1{\normalparens #1% \interlinepenalty=10000 \endgraf\nobreak\vskip -\parskip\nobreak} % @defvr Counter foo-count \def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader} \def\defvrheader #1#2#3{\doind {vr}{\code{#2}}% \begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup} % @defvar == @defvr Variable \def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader} \def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index \begingroup\defname {#1}{Variable}% \defvarargs {#2}\endgroup % } % @defopt == @defvr {User Option} \def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader} \def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index \begingroup\defname {#1}{User Option}% \defvarargs {#2}\endgroup % } % @deftypevar int foobar \def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader} % #1 is the data type. #2 is the name, perhaps followed by text that % is actually part of the data type, which should not be put into the index. \def\deftypevarheader #1#2{% \dovarind#2 \relax% Make entry in variables index \begingroup\defname {\defheaderxcond#1\relax$$$#2}{Variable}% \interlinepenalty=10000 \endgraf\nobreak\vskip -\parskip\nobreak \endgroup} \def\dovarind#1 #2\relax{\doind{vr}{\code{#1}}} % @deftypevr {Global Flag} int enable \def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader} \def\deftypevrheader #1#2#3{\dovarind#3 \relax% \begingroup\defname {\defheaderxcond#2\relax$$$#3}{#1} \interlinepenalty=10000 \endgraf\nobreak\vskip -\parskip\nobreak \endgroup} % This definition is run if you use @defvarx % anywhere other than immediately after a @defvar or @defvarx. \def\defvrx #1 {\errmessage{@defvrx in invalid context}} \def\defvarx #1 {\errmessage{@defvarx in invalid context}} \def\defoptx #1 {\errmessage{@defoptx in invalid context}} \def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}} \def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}} % Now define @deftp % Args are printed in bold, a slight difference from @defvar. \def\deftpargs #1{\bf \defvarargs{#1}} % @deftp Class window height width ... \def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader} \def\deftpheader #1#2#3{\doind {tp}{\code{#2}}% \begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup} % This definition is run if you use @deftpx, etc % anywhere other than immediately after a @deftp, etc. \def\deftpx #1 {\errmessage{@deftpx in invalid context}} \message{macros,} % @macro. % To do this right we need a feature of e-TeX, \scantokens, % which we arrange to emulate with a temporary file in ordinary TeX. \ifx\eTeXversion\undefined \newwrite\macscribble \def\scanmacro#1{% \begingroup \newlinechar`\^^M \immediate\openout\macscribble=\jobname.tmp \immediate\write\macscribble{#1}% \immediate\closeout\macscribble \let\xeatspaces\eatspaces \input \jobname.tmp \endgroup } \else \def\scanmacro#1{% \begingroup \newlinechar`\^^M \let\xeatspaces\eatspaces\scantokens{#1}\endgroup} \fi \newcount\paramno % Count of parameters \newtoks\macname % Macro name \newif\ifrecursive % Is it recursive? % Utility routines. % Thisdoes \let #1 = #2, except with \csnames. \def\cslet#1#2{% \expandafter\expandafter \expandafter\let \expandafter\expandafter \csname#1\endcsname \csname#2\endcsname} % Trim leading and trailing spaces off a string. % Concepts from aro-bend problem 15 (see CTAN). {\catcode`\@=11 \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }} \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@} \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @} \def\unbrace#1{#1} \unbrace{\gdef\trim@@@ #1 } #2@{#1} } % Trim a single trailing ^^M off a string. {\catcode`\^^M=12\catcode`\Q=3% \gdef\eatcr #1{\eatcra #1Q^^MQ}% \gdef\eatcra#1^^MQ{\eatcrb#1Q}% \gdef\eatcrb#1Q#2Q{#1}% } % Macro bodies are absorbed as an argument in a context where % all characters are catcode 10, 11 or 12, except \ which is active % (as in normal texinfo). It is necessary to change the definition of \. % It's necessary to have hard CRs when the macro is executed. This is % done by making ^^M (\endlinechar) catcode 12 when reading the macro % body, and then making it the \newlinechar in \scanmacro. \def\macrobodyctxt{% \catcode`\~=12 \catcode`\^=12 \catcode`\_=12 \catcode`\|=12 \catcode`\<=12 \catcode`\>=12 \catcode`\+=12 \catcode`\{=12 \catcode`\}=12 \catcode`\@=12 \catcode`\^^M=12 \usembodybackslash} \def\macroargctxt{% \catcode`\~=12 \catcode`\^=12 \catcode`\_=12 \catcode`\|=12 \catcode`\<=12 \catcode`\>=12 \catcode`\+=12 \catcode`\@=12 \catcode`\\=12} % \mbodybackslash is the definition of \ in @macro bodies. % It maps \foo\ => \csname macarg.foo\endcsname => #N % where N is the macro parameter number. % We define \csname macarg.\endcsname to be \realbackslash, so % \\ in macro replacement text gets you a backslash. {\catcode`@=0 @catcode`@\=@active @gdef@usembodybackslash{@let\=@mbodybackslash} @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname} } \expandafter\def\csname macarg.\endcsname{\realbackslash} \def\macro{\recursivefalse\parsearg\macroxxx} \def\rmacro{\recursivetrue\parsearg\macroxxx} \def\macroxxx#1{% \getargs{#1}% now \macname is the macname and \argl the arglist \ifx\argl\empty % no arguments \paramno=0% \else \expandafter\parsemargdef \argl;% \fi \expandafter\ifx \csname macsave.\the\macname\endcsname \relax \cslet{macsave.\the\macname}{\the\macname}% \else \message{Warning: redefining \the\macname}% \fi \begingroup \macrobodyctxt \ifrecursive \expandafter\parsermacbody \else \expandafter\parsemacbody \fi} \def\unmacro{\parsearg\unmacroxxx} \def\unmacroxxx#1{% \expandafter\ifx \csname macsave.\the\macname\endcsname \relax \errmessage{Macro \the\macname\ not defined.}% \else \cslet{#1}{macsave.#1}% \expandafter\let \csname macsave.\the\macname\endcsname \undefined \fi } % This makes use of the obscure feature that if the last token of a % is #, then the preceding argument is delimited by % an opening brace, and that opening brace is not consumed. \def\getargs#1{\getargsxxx#1{}} \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs} \def\getmacname #1 #2\relax{\macname={#1}} \def\getmacargs#1{\def\argl{#1}} % Parse the optional {params} list. Set up \paramno and \paramlist % so \defmacro knows what to do. Define \macarg.blah for each blah % in the params list, to be ##N where N is the position in that list. % That gets used by \mbodybackslash (above). % We need to get `macro parameter char #' into several definitions. % The technique used is stolen from LaTeX: let \hash be something % unexpandable, insert that wherever you need a #, and then redefine % it to # just before using the token list produced. % % The same technique is used to protect \eatspaces till just before % the macro is used. \def\parsemargdef#1;{\paramno=0\def\paramlist{}% \let\hash\relax\let\xeatspaces\relax\parsemargdefxxx#1,;,} \def\parsemargdefxxx#1,{% \if#1;\let\next=\relax \else \let\next=\parsemargdefxxx \advance\paramno by 1% \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname {\xeatspaces{\hash\the\paramno}}% \edef\paramlist{\paramlist\hash\the\paramno,}% \fi\next} % These two commands read recursive and nonrecursive macro bodies. % (They're different since rec and nonrec macros end differently.) \long\def\parsemacbody#1@end macro% {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% \long\def\parsermacbody#1@end rmacro% {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% % This defines the macro itself. There are six cases: recursive and % nonrecursive macros of zero, one, and many arguments. % Much magic with \expandafter here. % \xdef is used so that macro definitions will survive the file % they're defined in; @include reads the file inside a group. \def\defmacro{% \let\hash=##% convert placeholders to macro parameter chars \ifrecursive \ifcase\paramno % 0 \expandafter\xdef\csname\the\macname\endcsname{% \noexpand\scanmacro{\temp}}% \or % 1 \expandafter\xdef\csname\the\macname\endcsname{% \bgroup\noexpand\macroargctxt \noexpand\braceorline\csname\the\macname xxx\endcsname}% \expandafter\xdef\csname\the\macname xxx\endcsname##1{% \egroup\noexpand\scanmacro{\temp}}% \else % many \expandafter\xdef\csname\the\macname\endcsname{% \bgroup\noexpand\macroargctxt \noexpand\csname\the\macname xx\endcsname} \expandafter\xdef\csname\the\macname xx\endcsname##1{% \csname\the\macname xxx\endcsname ##1,}% \expandafter\expandafter \expandafter\xdef \expandafter\expandafter \csname\the\macname xxx\endcsname \paramlist{\egroup\noexpand\scanmacro{\temp}}% \fi \else \ifcase\paramno % 0 \expandafter\xdef\csname\the\macname\endcsname{% \noexpand\norecurse{\the\macname}% \noexpand\scanmacro{\temp}\egroup}% \or % 1 \expandafter\xdef\csname\the\macname\endcsname{% \bgroup\noexpand\macroargctxt \noexpand\braceorline\csname\the\macname xxx\endcsname}% \expandafter\xdef\csname\the\macname xxx\endcsname##1{% \egroup \noexpand\norecurse{\the\macname}% \noexpand\scanmacro{\temp}\egroup}% \else % many \expandafter\xdef\csname\the\macname\endcsname{% \bgroup\noexpand\macroargctxt \noexpand\csname\the\macname xx\endcsname} \expandafter\xdef\csname\the\macname xx\endcsname##1{% \csname\the\macname xxx\endcsname ##1,}% \expandafter\expandafter \expandafter\xdef \expandafter\expandafter \csname\the\macname xxx\endcsname \paramlist{% \egroup \noexpand\norecurse{\the\macname}% \noexpand\scanmacro{\temp}\egroup}% \fi \fi} \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}} % \braceorline decides whether the next nonwhitespace character is a % {. If so it reads up to the closing }, if not, it reads the whole % line. Whatever was read is then fed to the next control sequence % as an argument (by \parsebrace or \parsearg) \def\braceorline#1{\let\next=#1\futurelet\nchar\braceorlinexxx} \def\braceorlinexxx{% \ifx\nchar\bgroup\else \expandafter\parsearg \fi \next} \message{cross references,} \newwrite\auxfile \newif\ifhavexrefs % True if xref values are known. \newif\ifwarnedxrefs % True if we warned once that they aren't known. % @inforef is relatively simple. \def\inforef #1{\inforefzzz #1,,,,**} \def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, node \samp{\ignorespaces#1{}}} % @node's job is to define \lastnode. \def\node{\ENVcheck\parsearg\nodezzz} \def\nodezzz#1{\nodexxx [#1,]} \def\nodexxx[#1,#2]{\gdef\lastnode{#1}} \let\nwnode=\node \let\lastnode=\relax % The sectioning commands (@chapter, etc.) call these. \def\donoderef{% \ifx\lastnode\relax\else \expandafter\expandafter\expandafter\setref{\lastnode}% {Ysectionnumberandtype}% \global\let\lastnode=\relax \fi } \def\unnumbnoderef{% \ifx\lastnode\relax\else \expandafter\expandafter\expandafter\setref{\lastnode}{Ynothing}% \global\let\lastnode=\relax \fi } \def\appendixnoderef{% \ifx\lastnode\relax\else \expandafter\expandafter\expandafter\setref{\lastnode}% {Yappendixletterandtype}% \global\let\lastnode=\relax \fi } % @anchor{NAME} -- define xref target at arbitrary point. % \def\anchor#1{\setref{#1}{Ynothing}} % \setref{NAME}{SNT} defines a cross-reference point NAME, namely % NAME-title, NAME-pg, and NAME-SNT. Called from \foonoderef. We have % to set \indexdummies so commands such as @code in a section title % aren't expanded. It would be nicer not to expand the titles in the % first place, but there's so many layers that that is hard to do. % \def\setref#1#2{{% \indexdummies \dosetq{#1-title}{Ytitle}% \dosetq{#1-pg}{Ypagenumber}% \dosetq{#1-snt}{#2} }} % @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is % the node name, #2 the name of the Info cross-reference, #3 the printed % node name, #4 the name of the Info file, #5 the name of the printed % manual. All but the node name can be omitted. % \def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]} \def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]} \def\ref#1{\xrefX[#1,,,,,,,]} \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup \def\printedmanual{\ignorespaces #5}% \def\printednodename{\ignorespaces #3}% \setbox1=\hbox{\printedmanual}% \setbox0=\hbox{\printednodename}% \ifdim \wd0 = 0pt % No printed node name was explicitly given. \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax % Use the node name inside the square brackets. \def\printednodename{\ignorespaces #1}% \else % Use the actual chapter/section title appear inside % the square brackets. Use the real section title if we have it. \ifdim \wd1 > 0pt % It is in another manual, so we don't have it. \def\printednodename{\ignorespaces #1}% \else \ifhavexrefs % We know the real title if we have the xref values. \def\printednodename{\refx{#1-title}{}}% \else % Otherwise just copy the Info node name. \def\printednodename{\ignorespaces #1}% \fi% \fi \fi \fi % % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not % insert empty discretionaries after hyphens, which means that it will % not find a line break at a hyphen in a node names. Since some manuals % are best written with fairly long node names, containing hyphens, this % is a loss. Therefore, we give the text of the node name again, so it % is as if TeX is seeing it for the first time. \ifdim \wd1 > 0pt \putwordsection{} ``\printednodename'' in \cite{\printedmanual}% \else % _ (for example) has to be the character _ for the purposes of the % control sequence corresponding to the node, but it has to expand % into the usual \leavevmode...\vrule stuff for purposes of % printing. So we \turnoffactive for the \refx-snt, back on for the % printing, back off for the \refx-pg. {\normalturnoffactive % Only output a following space if the -snt ref is nonempty; for % @unnumbered and @anchor, it won't be. \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}% \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi }% % [mynode], [\printednodename],\space % page 3 \turnoffactive \putwordpage\tie\refx{#1-pg}{}% \fi \endgroup} % \dosetq is the interface for calls from other macros % Use \normalturnoffactive so that punctuation chars such as underscore % and backslash work in node names. (\turnoffactive doesn't do \.) \def\dosetq#1#2{% {\let\folio=0 \normalturnoffactive \edef\next{\write\auxfile{\internalsetq{#1}{#2}}}% \iflinks \next \fi }% } % \internalsetq {foo}{page} expands into % CHARACTERS 'xrdef {foo}{...expansion of \Ypage...} % When the aux file is read, ' is the escape character \def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}} % Things to be expanded by \internalsetq \def\Ypagenumber{\folio} \def\Ytitle{\thissection} \def\Ynothing{} \def\Ysectionnumberandtype{% \ifnum\secno=0 \putwordChapter\xreftie\the\chapno % \else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno % \else \ifnum \subsubsecno=0 % \putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno % \else % \putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno % \fi \fi \fi } \def\Yappendixletterandtype{% \ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}% \else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno % \else \ifnum \subsubsecno=0 % \putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno % \else % \putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno % \fi \fi \fi } \gdef\xreftie{'tie} % Use TeX 3.0's \inputlineno to get the line number, for better error % messages, but if we're using an old version of TeX, don't do anything. % \ifx\inputlineno\thisisundefined \let\linenumber = \empty % Non-3.0. \else \def\linenumber{\the\inputlineno:\space} \fi % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. % If its value is nonempty, SUFFIX is output afterward. \def\refx#1#2{% \expandafter\ifx\csname X#1\endcsname\relax % If not defined, say something at least. \angleleft un\-de\-fined\angleright \iflinks \ifhavexrefs \message{\linenumber Undefined cross reference `#1'.}% \else \ifwarnedxrefs\else \global\warnedxrefstrue \message{Cross reference values unknown; you must run TeX again.}% \fi \fi \fi \else % It's defined, so just use it. \csname X#1\endcsname \fi #2% Output the suffix in any case. } % This is the macro invoked by entries in the aux file. % \def\xrdef#1{\begingroup % Reenable \ as an escape while reading the second argument. \catcode`\\ = 0 \afterassignment\endgroup \expandafter\gdef\csname X#1\endcsname } % Read the last existing aux file, if any. No error if none exists. \def\readauxfile{\begingroup \catcode`\^^@=\other \catcode`\^^A=\other \catcode`\^^B=\other \catcode`\^^C=\other \catcode`\^^D=\other \catcode`\^^E=\other \catcode`\^^F=\other \catcode`\^^G=\other \catcode`\^^H=\other \catcode`\^^K=\other \catcode`\^^L=\other \catcode`\^^N=\other \catcode`\^^P=\other \catcode`\^^Q=\other \catcode`\^^R=\other \catcode`\^^S=\other \catcode`\^^T=\other \catcode`\^^U=\other \catcode`\^^V=\other \catcode`\^^W=\other \catcode`\^^X=\other \catcode`\^^Z=\other \catcode`\^^[=\other \catcode`\^^\=\other \catcode`\^^]=\other \catcode`\^^^=\other \catcode`\^^_=\other \catcode`\@=\other \catcode`\^=\other % It was suggested to define this as 7, which would allow ^^e4 etc. % in xref tags, i.e., node names. But since ^^e4 notation isn't % supported in the main text, it doesn't seem desirable. Furthermore, % that is not enough: for node names that actually contain a ^ % character, we would end up writing a line like this: 'xrdef {'hat % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first % argument, and \hat is not an expandable control sequence. It could % all be worked out, but why? Either we support ^^ or we don't. % % The other change necessary for this was to define \auxhat: % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter % and then to call \auxhat in \setq. % \catcode`\~=\other \catcode`\[=\other \catcode`\]=\other \catcode`\"=\other \catcode`\_=\other \catcode`\|=\other \catcode`\<=\other \catcode`\>=\other \catcode`\$=\other \catcode`\#=\other \catcode`\&=\other \catcode`+=\other % avoid \+ for paranoia even though we've turned it off % Make the characters 128-255 be printing characters {% \count 1=128 \def\loop{% \catcode\count 1=\other \advance\count 1 by 1 \ifnum \count 1<256 \loop \fi }% }% % The aux file uses ' as the escape (for now). % Turn off \ as an escape so we do not lose on % entries which were dumped with control sequences in their names. % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^ % Reference to such entries still does not work the way one would wish, % but at least they do not bomb out when the aux file is read in. \catcode`\{=1 \catcode`\}=2 \catcode`\%=\other \catcode`\'=0 \catcode`\\=\other % \openin 1 \jobname.aux \ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue \global\warnedobstrue \fi % Open the new aux file. TeX will close it automatically at exit. \openout\auxfile=\jobname.aux \endgroup} % Footnotes. \newcount \footnoteno % The trailing space in the following definition for supereject is % vital for proper filling; pages come out unaligned when you do a % pagealignmacro call if that space before the closing brace is % removed. (Generally, numeric constants should always be followed by a % space to prevent strange expansion errors.) \def\supereject{\par\penalty -20000\footnoteno =0 } % @footnotestyle is meaningful for info output only. \let\footnotestyle=\comment \let\ptexfootnote=\footnote {\catcode `\@=11 % % Auto-number footnotes. Otherwise like plain. \gdef\footnote{% \global\advance\footnoteno by \@ne \edef\thisfootno{$^{\the\footnoteno}$}% % % In case the footnote comes at the end of a sentence, preserve the % extra spacing after we do the footnote number. \let\@sf\empty \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi % % Remove inadvertent blank space before typesetting the footnote number. \unskip \thisfootno\@sf \footnotezzz }% % Don't bother with the trickery in plain.tex to not require the % footnote text as a parameter. Our footnotes don't need to be so general. % % Oh yes, they do; otherwise, @ifset and anything else that uses % \parseargline fail inside footnotes because the tokens are fixed when % the footnote is read. --karl, 16nov96. % \long\gdef\footnotezzz{\insert\footins\bgroup % We want to typeset this text as a normal paragraph, even if the % footnote reference occurs in (for example) a display environment. % So reset some parameters. \interlinepenalty\interfootnotelinepenalty \splittopskip\ht\strutbox % top baseline for broken footnotes \splitmaxdepth\dp\strutbox \floatingpenalty\@MM \leftskip\z@skip \rightskip\z@skip \spaceskip\z@skip \xspaceskip\z@skip \parindent\defaultparindent % % Hang the footnote text off the number. \hang \textindent{\thisfootno}% % % Don't crash into the line above the footnote text. Since this % expands into a box, it must come within the paragraph, lest it % provide a place where TeX can split the footnote. \footstrut \futurelet\next\fo@t } \def\fo@t{\ifcat\bgroup\noexpand\next \let\next\f@@t \else\let\next\f@t\fi \next} \def\f@@t{\bgroup\aftergroup\@foot\let\next} \def\f@t#1{#1\@foot} \def\@foot{\strut\egroup} }%end \catcode `\@=11 % Set the baselineskip to #1, and the lineskip and strut size % correspondingly. There is no deep meaning behind these magic numbers % used as factors; they just match (closely enough) what Knuth defined. % \def\lineskipfactor{.08333} \def\strutheightpercent{.70833} \def\strutdepthpercent {.29167} % \def\setleading#1{% \normalbaselineskip = #1\relax \normallineskip = \lineskipfactor\normalbaselineskip \normalbaselines \setbox\strutbox =\hbox{% \vrule width0pt height\strutheightpercent\baselineskip depth \strutdepthpercent \baselineskip }% } % @| inserts a changebar to the left of the current line. It should % surround any changed text. This approach does *not* work if the % change spans more than two lines of output. To handle that, we would % have adopt a much more difficult approach (putting marks into the main % vertical list for the beginning and end of each change). % \def\|{% % \vadjust can only be used in horizontal mode. \leavevmode % % Append this vertical mode material after the current line in the output. \vadjust{% % We want to insert a rule with the height and depth of the current % leading; that is exactly what \strutbox is supposed to record. \vskip-\baselineskip % % \vadjust-items are inserted at the left edge of the type. So % the \llap here moves out into the left-hand margin. \llap{% % % For a thicker or thinner bar, change the `1pt'. \vrule height\baselineskip width1pt % % This is the space between the bar and the text. \hskip 12pt }% }% } % For a final copy, take out the rectangles % that mark overfull boxes (in case you have decided % that the text looks ok even though it passes the margin). % \def\finalout{\overfullrule=0pt} % @image. We use the macros from epsf.tex to support this. % If epsf.tex is not installed and @image is used, we complain. % % Check for and read epsf.tex up front. If we read it only at @image % time, we might be inside a group, and then its definitions would get % undone and the next image would fail. \openin 1 = epsf.tex \ifeof 1 \else \closein 1 % Do not bother showing banner with post-v2.7 epsf.tex (available in % doc/epsf.tex until it shows up on ctan). \def\epsfannounce{\toks0 = }% \input epsf.tex \fi % \newif\ifwarnednoepsf \newhelp\noepsfhelp{epsf.tex must be installed for images to work. It is also included in the Texinfo distribution, or you can get it from ftp://ftp.tug.org/tex/epsf.tex.} % % Only complain once about lack of epsf.tex. \def\image#1{% \ifx\epsfbox\undefined \ifwarnednoepsf \else \errhelp = \noepsfhelp \errmessage{epsf.tex not found, images will be ignored}% \global\warnednoepsftrue \fi \else \imagexxx #1,,,\finish \fi } % % Arguments to @image: % #1 is (mandatory) image filename; we tack on .eps extension. % #2 is (optional) width, #3 is (optional) height. % #4 is just the usual extra ignored arg for parsing this stuff. \def\imagexxx#1,#2,#3,#4\finish{% % \epsfbox itself resets \epsf?size at each figure. \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi % If the image is by itself, center it. \ifvmode \nobreak\medskip \nobreak \centerline{\epsfbox{#1.eps}}% \bigbreak \else \epsfbox{#1.eps}% \fi } \message{paper sizes,} % And other related parameters. \newdimen\defaultparindent \defaultparindent = 15pt \chapheadingskip = 15pt plus 4pt minus 2pt \secheadingskip = 12pt plus 3pt minus 2pt \subsecheadingskip = 9pt plus 2pt minus 2pt % Prevent underfull vbox error messages. \vbadness = 10000 % Don't be so finicky about underfull hboxes, either. \hbadness = 2000 % Following George Bush, just get rid of widows and orphans. \widowpenalty=10000 \clubpenalty=10000 % Use TeX 3.0's \emergencystretch to help line breaking, but if we're % using an old version of TeX, don't do anything. We want the amount of % stretch added to depend on the line length, hence the dependence on % \hsize. This makes it come to about 9pt for the 8.5x11 format. We % call this whenever the paper size is set. % \def\setemergencystretch{% \ifx\emergencystretch\thisisundefined % Allow us to assign to \emergencystretch anyway. \def\emergencystretch{\dimen0}% \else \emergencystretch = \hsize \divide\emergencystretch by 45 \fi } % Parameters in order: 1) textheight; 2) textwidth; 3) voffset; % 4) hoffset; 5) binding offset; 6) topskip. Then whoever calls us can % set \parskip and call \setleading for \baselineskip. % \def\internalpagesizes#1#2#3#4#5#6{% \voffset = #3\relax \topskip = #6\relax \splittopskip = \topskip % \vsize = #1\relax \advance\vsize by \topskip \outervsize = \vsize \advance\outervsize by 0.6in \pageheight = \vsize % \hsize = #2\relax \outerhsize = \hsize \advance\outerhsize by 0.5in \pagewidth = \hsize % \normaloffset = #4\relax \bindingoffset = #5\relax % \parindent = \defaultparindent \setemergencystretch } % @letterpaper (the default). \def\letterpaper{{\globaldefs = 1 \parskip = 3pt plus 2pt minus 1pt \setleading{13.2pt}% % % If page is nothing but text, make it come out even. \internalpagesizes{46\baselineskip}{6in}{\voffset}{.25in}{\bindingoffset}{36pt}% }} % Use @smallbook to reset parameters for 7x9.5 (or so) format. \def\smallbook{{\globaldefs = 1 \parskip = 2pt plus 1pt \setleading{12pt}% % \internalpagesizes{7.5in}{5.in}{\voffset}{.25in}{\bindingoffset}{16pt}% % \lispnarrowing = 0.3in \tolerance = 700 \hfuzz = 1pt \contentsrightmargin = 0pt \deftypemargin = 0pt \defbodyindent = .5cm % \let\smalldisplay = \smalldisplayx \let\smallexample = \smalllispx \let\smallformat = \smallformatx \let\smalllisp = \smalllispx }} % Use @afourpaper to print on European A4 paper. \def\afourpaper{{\globaldefs = 1 \setleading{12pt}% \parskip = 3pt plus 2pt minus 1pt % \internalpagesizes{53\baselineskip}{160mm}{\voffset}{4mm}{\bindingoffset}{44pt}% % \tolerance = 700 \hfuzz = 1pt }} % A specific text layout, 24x15cm overall, intended for A4 paper. Top margin % 29mm, hence bottom margin 28mm, nominal side margin 3cm. \def\afourlatex{{\globaldefs = 1 \setleading{13.6pt}% % \afourpaper \internalpagesizes{237mm}{150mm}{3.6mm}{3.6mm}{3mm}{7mm}% % \globaldefs = 0 }} % Use @afourwide to print on European A4 paper in wide format. \def\afourwide{% \afourpaper \internalpagesizes{9.5in}{6.5in}{\hoffset}{\normaloffset}{\bindingoffset}{7mm}% % \globaldefs = 0 } % @pagesizes TEXTHEIGHT[,TEXTWIDTH] % Perhaps we should allow setting the margins, \topskip, \parskip, % and/or leading, also. Or perhaps we should compute them somehow. % \def\pagesizes{\parsearg\pagesizesxxx} \def\pagesizesxxx#1{\pagesizesyyy #1,,\finish} \def\pagesizesyyy#1,#2,#3\finish{{% \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi \globaldefs = 1 % \parskip = 3pt plus 2pt minus 1pt \setleading{13.2pt}% % \internalpagesizes{#1}{\hsize}{\voffset}{\normaloffset}{\bindingoffset}{44pt}% }} % Set default to letter. % \letterpaper \message{and turning on texinfo input format.} % Define macros to output various characters with catcode for normal text. \catcode`\"=\other \catcode`\~=\other \catcode`\^=\other \catcode`\_=\other \catcode`\|=\other \catcode`\<=\other \catcode`\>=\other \catcode`\+=\other \def\normaldoublequote{"} \def\normaltilde{~} \def\normalcaret{^} \def\normalunderscore{_} \def\normalverticalbar{|} \def\normalless{<} \def\normalgreater{>} \def\normalplus{+} % This macro is used to make a character print one way in ttfont % where it can probably just be output, and another way in other fonts, % where something hairier probably needs to be done. % % #1 is what to print if we are indeed using \tt; #2 is what to print % otherwise. Since all the Computer Modern typewriter fonts have zero % interword stretch (and shrink), and it is reasonable to expect all % typewriter fonts to have this, we can check that font parameter. % \def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi} % Turn off all special characters except @ % (and those which the user can use as if they were ordinary). % Most of these we simply print from the \tt font, but for some, we can % use math or other variants that look better in normal text. \catcode`\"=\active \def\activedoublequote{{\tt\char34}} \let"=\activedoublequote \catcode`\~=\active \def~{{\tt\char126}} \chardef\hat=`\^ \catcode`\^=\active \def^{{\tt \hat}} \catcode`\_=\active \def_{\ifusingtt\normalunderscore\_} % Subroutine for the previous macro. \def\_{\leavevmode \kern.06em \vbox{\hrule width.3em height.1ex}} \catcode`\|=\active \def|{{\tt\char124}} \chardef \less=`\< \catcode`\<=\active \def<{{\tt \less}} \chardef \gtr=`\> \catcode`\>=\active \def>{{\tt \gtr}} \catcode`\+=\active \def+{{\tt \char 43}} %\catcode 27=\active %\def^^[{$\diamondsuit$} % Set up an active definition for =, but don't enable it most of the time. {\catcode`\==\active \global\def={{\tt \char 61}}} \catcode`+=\active \catcode`\_=\active % If a .fmt file is being used, characters that might appear in a file % name cannot be active until we have parsed the command line. % So turn them off again, and have \everyjob (or @setfilename) turn them on. % \otherifyactive is called near the end of this file. \def\otherifyactive{\catcode`+=\other \catcode`\_=\other} \catcode`\@=0 % \rawbackslashxx output one backslash character in current font \global\chardef\rawbackslashxx=`\\ %{\catcode`\\=\other %@gdef@rawbackslashxx{\}} % \rawbackslash redefines \ as input to do \rawbackslashxx. {\catcode`\\=\active @gdef@rawbackslash{@let\=@rawbackslashxx }} % \normalbackslash outputs one backslash in fixed width font. \def\normalbackslash{{\tt\rawbackslashxx}} % Say @foo, not \foo, in error messages. \escapechar=`\@ % \catcode 17=0 % Define control-q \catcode`\\=\active % Used sometimes to turn off (effectively) the active characters % even after parsing them. @def@turnoffactive{@let"=@normaldoublequote @let\=@realbackslash @let~=@normaltilde @let^=@normalcaret @let_=@normalunderscore @let|=@normalverticalbar @let<=@normalless @let>=@normalgreater @let+=@normalplus} @def@normalturnoffactive{@let"=@normaldoublequote @let\=@normalbackslash @let~=@normaltilde @let^=@normalcaret @let_=@normalunderscore @let|=@normalverticalbar @let<=@normalless @let>=@normalgreater @let+=@normalplus} % Make _ and + \other characters, temporarily. % This is canceled by @fixbackslash. @otherifyactive % If a .fmt file is being used, we don't want the `\input texinfo' to show up. % That is what \eatinput is for; after that, the `\' should revert to printing % a backslash. % @gdef@eatinput input texinfo{@fixbackslash} @global@let\ = @eatinput % On the other hand, perhaps the file did not have a `\input texinfo'. Then % the first `\{ in the file would cause an error. This macro tries to fix % that, assuming it is called before the first `\' could plausibly occur. % Also back turn on active characters that might appear in the input % file name, in case not using a pre-dumped format. % @gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi @catcode`+=@active @catcode`@_=@active} % These look ok in all fonts, so just make them not special. The @rm below % makes sure that the current font starts out as the newly loaded cmr10 @catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other @textfonts @rm @c Local variables: @c page-delimiter: "^\\\\message" @c End: ipgrab-0.9.10/DEVELOPER-HOWTO0000644000175000001440000004200210644704540014423 0ustar farooqusers------------------------------------------------------------ Ipgrab Developer How To $Id: DEVELOPER-HOWTO,v 1.2 2007/07/10 13:28:00 farooq-i-azam Exp $ ------------------------------------------------------------ Introduction ------------ This document is meant for those who would like to learn about the development of ipgrab, and then to contribute and write some modules themselves if they would wish so. This is also meant to be used for educational purposes when ipgrab is used to teach network protocols, issues related to protocol implementation, etc. Though there are many open source packet sniffers available, ipgrab is unique beacuse of its light weight and verbose output. It is not packed with too many not-needed options. Also, ipgrab provides for a unique learning opportunity due to excellent documentation available and simple design. The code also contains lot of comments. Ipgrab has been developed using C language for the Unix and Linux environments. It also runs under Microsoft Windows if installed under cygwin. Ipgrab Modules -------------- Ipgrab consists of many source code files each of which may be named as an independent module. For example, ip.c is a module which dissects and displays IP header information in a packet. Similary, udp.c is another module which dissects and displays UPD header information in a packet. As you see, module names are descriptive. Architecture ------------ Before you can write a module, it is also important that you should understand the current architecture of ipgrab. In module ipgrab.c, each time a packet is captured, the function datalink_pcap() is called. This function itself is defined in module datalink.c Function datalink_pcap(), in turn, calls function datalink() defined in module datalink.c. Depending upon the type of datalink layer, datalink() further calls the appropriate module. Ipgrab, at present, supports the following datalink layer types: Loopback - function dump_loopback() in module loopback.c Ethernet - function dump_ethernet() in module ethernet.c SLIP - function dump_slip() in module slip.c PPP - function dump_ppp() in module ppp.c RAWIP - function dump_rawip() in module rawip.c For each datalink layer type, appropriate function provided in respective module is called by datalink(). As you are aware, for the most part we would be interested in Ethernet which is the available datalink type under most of the circumstances. In function dump_ethernet() in module ethernet.c, a function ethertype2func() is called upon to determine the network layer protocol encapsulated in the ethernet frame and to call appropriate function to dissect and display network layer header information. The function ethertype2func() is itself defined in module ethertypes.c. This function may call any of the following functions depending upon the type of network layer protocol: IP - dunction dump_ip() in module ip.c ARP, RARP - function dump_arp() in module arp.c IPX - function dump_ipx() in module ipx.c IPv6 - function dump_ipv6() in module ipv6.c PPP - function dump_ppp() in module ppp.c PPPHDLC - function dump_ppp_hdlc() in module ppp.c PPPoE Discovery - function dump_pppoed() in module pppoe.c PPPoE Session - function dump_pppoes() in module pppoe.c Most widely used protocol on the network layer is the Internet Protocol i.e. IP. Hence, we would be further interested in IP. In module ip.c, the function ip_proto_func() determines the next header on top of IP header and calls the appropriate function. The function ip_proto_func() is itself defined in module ip_protocols.c. The following protocols on top of IP are supported: ICMP - function dump_icmp() from module icmp.c IGMP - function dump_igmp() from module igmp.c TCP - function dump_tcp() from module tcp.c UDP - function dump_udp() from module udp.c GRE - function dump_gre() from module gre.c RSVP - function dump_rsvp() from module rsvp.c ESP - function dump_esp() from module esp.c AH - function dump_ah() from module ah.c OSPF - function dump_ospf() from module ospf.c ICMPv6 - function dump_icmpv6() from module icmpv6.c Of all these, only transport layer protocols i.e. TCP and UDP carry most commonly used application layer protocols above them. In both tcp.c and udp.c, the function prot2func() is called to determine the application layer protocol above the transport layer and to call appropriate function to dissect and display the application layer protocol. This functin itself is defined in ip_services.c. It should be obvious by now that if you would like ipgrab to dissect and display a new protocol, you should write a new module. In addition, if the protocol is on the datalink layer, you would need to add a couple of lines i.e. register the module in module datalink.c. If the new protocol falls in network layer, you should register the new module in ethertypes.c. Similarly, if the new protocol is a transport layer protocol, you should register it in ip_protocols.c. If the new protocol is an application layer protocol, this should be registered in ip_services.c. For example, if I would like to dissect an application layer protocol NEWPROTO which runs on port, say 1234, I would perform the following steps: 1- Write a module newproto.c accompanied by a header file newproto.h which should include function prototypes, header definition, other include files, etc. The module newproto.c would contain a function e.g. dump_newproto() to dissect the protocol. 2- Add following lines in ip_services.h #define PORT_NEWPROTO 1234 #include "newproto.h" 3- Add following lines in ip_services.c in function port2func(): case PORT_NEWPROTO: f = dump_newproto(); break; This would enable ipgrab to call your module whenever the protcol NEWPROTO is encountered in a packet. Writing A Module ---------------- In general, ipgrab modules can be divided into two categories: 1- Protocol Modules 2- Support Modules Protocol modules are the ones which dissect and display protocols like the examples of ip.c and upd.c given above. Support modules are auxiliary modules and which make up the architecture of ipgrab. These modules provide for various functions which are called by protocol modules. For example, almost each protocol module calls a function named get_packet_bytes() which is defined in support module named packet_manip.c. This function copies a specified number of packets from the packet to the specified destination. In short, protocol modules use functions defined in support modules to dissect and display packet information. Generally, we would be interested in writing and adding more protocol modules to ipgrab. To write a moduel for a particular protocol, you should first be familiar with the protocol itself. Best source of information to learn about the protocol is the document where it has been defined. Under most of the circumstances, this would be an RFC or a collection of RFCs published by IETF. Appendix A at the end of this document also contains a list of resources and RFCs along with existing module names. This list should be helpful to those who would like to learn and read various protocols and their associated modules. As would be clear from above description, a knowledge of functions provided in source modules is required if you would like to write protocol modules. Here is a list of all the important support modules: display.c error.c hexbuffer.c layers.c packet_manip.c utilities.c Anyone interested to contribute a protocol module for ipgrab should familiarize himself or herself with the functions defined in above modules, particularly those in display.c, layers.c and packet_manip.c. Generally, you start your module with declaration of necessary variables and then the following line: set_layer(LAYER_APPLICATION); Replace LAYER_APPLICATION with whatever layer your protocol belongs to. Definitions of layers are provided in layers.h. The module you would write should have a function with the following prototype: void dump_newproto (packet_t * pkt); packet_t is a structure defined in packet_manip.c. A copy of the entire contents of the packet would be passed to your module. A pointer in the form of p->current in packet_manip.c keeps track of which parts of the packet have already been read and dissected. You can simply copy NEWPROTO header from the packet to your own structure for the NEWPROTO defined probably in your header file for the new module. This can be accomplished by the function call below: if (get_packet_bytes((u_int8_t *) &newproto, pkt, sizeof (newproto)) == 0) return; This would simply return if it fails to get packet bytes. Remember you do not want to clutter the display during the packet display. If you would like to report any errors, please use functions provided in error.c. But as a rule of thumb, no error reporting should be done in a protocol module. After the protocol header has been copied to your structure, next important task is to perform byte order conversions. If a protocol field is stored in a structure member which is two or more bytes long, its byte order should be converted to host byte order from the network byte order. You use functions ntohs() and ntohl() to convert 2 and 4 byte variables respectively to host byte order. After this, you would proceed to display the header fields. Various functions in display.c are used for this purpose. Ipgrab supports minimal mode and verbose mode. In minimal mode, only small amount of information is displayed and in verbose mode almost all header information is displayed. The minimal mode is chosen using -m at the command line. We would like to display information for both modes and proceed somewhat like below: if ( my_args->m) { /* display information for minimal mode */ } else { /* display information for verbose mode */ } To display items in the minimal mode, we normally use function display_minimal() and to display fields in verbose mode, we normally use function display(). Both these functions are defined in display.c. It would be a good idea to read these functions and understand how they work. After all the fields have been displayed, the function hexbuffer_flush() should be called to display the protocol fields in hex. This function is defined in hexbuffer.c. This function would get executed only if -x is specified on the command line and ipgrab in not running in the minimal mode. However, you do not need to check for these conditions. These checks are performed by the function itself. If this is an application layer protocol and there is no further header encapsulated, you are done. However, if there is any other header encapsulated, you should call the next appropriate function. There are two template files named template.h and template.c available in src directory that you can use as templates for your module. ----------------------------------------------------------- Mike Borella Muhammad Farooq-i-Azam ------------------------------------------------------------ APPENDIX A ---------- ah.c RFC 2402 IP Authentication Header arp.c RFC 0826 Ethernet Address Resolution Protocol TCP/IP Tutorial and Technical Overview ccp.c RFC 1962 The PPP Compression Control Protocol (CCP) RFC 1332 PPP Internet Protocol Control Protocl (IPCP) iana/ppp-numbers chap.c RFC 1994 PPP Challenge Handshake Authentication Protocol iana/ppp-numbers dhcp.c RFC 2131 Dynamic Host configuration Protocol RFC 2132 DHCP Options and BOOTP Vendor Extensions iana/bootp-dhcp-parameters dns.c RFC 1034 Domain Names - Concepts And Facilities RFC 1035 Domain Names - Implementation And Specification RFC 0882 Domain Names - Concepts And Facilities RFC 0883 Domain Names - Implementation And Specification iana/dns-header-flags iana/dns-key-rr iana/dns-parameters esp.c RFC 2406 IP Encapsulating Security Payload ethernet.c TCP/IP Tutorial And Technical Overview Ethernet Frame Types: Don Provan's Definitive Answer http://netlab1/usu.edu/novell.faq/nvfaq-1.htm iana/ethernet-numbers iana/ieee-802-numbers ethertypes.c iana/ethernet-numbers iana/ieee-802-numbers file.c RFC 1761 Snoop Version 2 Packet Capture File Format ftpctrl.c RFC 0959 File Transfer Protocol RFC Handbook - http://www.networksorcery.com gre.c RFC 1701 Generic Routing Encapsulation RFC 2637 Point-to-Point Tunneling Protocol RFC 2784 Generic Routing Encapsulation http.c RFC 1945 Hypertext Transfer Protocol -- HTTP/1.0 iana.c iana/enterprise-numbers icmp.c RFC 0792 Internet Control Message Protocol RFC 1256 ICMP Router Discovery Messages iana/icmp-parameters icmpv6.c RFC 2463 Internet Control Message Protocol (ICMPv6) for the Internet Protocol Version 6 (IPv6) Specification RFC 2461 Neighbor Discovery for IP Version 6 (IPV6) RFC 2460 Internet Protocol, Version 6 (IPv6) Specifications iana/icmpv6-parameters igmp.c RFC 2236 Internet Group Management Protocol, Version 2 iana/igmp-type-numbers ip.c RFC 0791 Internet Protocol iana/ip-parameters ipcp.c RFC 1332 PPP Internet Protocol Control Protocol (IPCP) iana/ppp-numbers ip_protocols.c RFC 0791 Internet Protocol iana/protocol-numbers ip_services.c iana/port-numbers ipv6.c RFC 2460 Internet Protocol, Version 6 (IPv6) Specification ipx.c RFC Source Book http://www.networksorcery.com Protocols Directory http://www.protocols.com ipxrip.c Protocols Directory http://www.protocols.com isakmp.c RFC 2408 Internet Security Association And Key Management Protocol (ISAKMP) RFC 2407 The Internet IP Security Domain of Interpretation for ISAKMP RFC 2409 The Internet Key Exchange (IKE) iana/isakmp-registry l2tp.c RFC 2661 Layer Two Tunneling Protocol "L2TP" iana/l2tp-parameters lcp.c RFC 1661 The Point-to-Point Protocol (PPP) iana/ppp-numbers llc.c TCP/IP Tutorial and Technical Overview http://www.auggy.mlnet.com/ibm/3376c28.html IEEE 802.2 LLC http://ckp.made-it.com/ieee8022.html mgcp.c RFC 3435 Media Gateway Control Protocol (MGCP) Version 1.0 RFC 2705 Media Gateway Control Protocol (MGCP) Version 1.0 RFC 2805 Media Gateway Control Protocol Architecture and Requirements mobileip.c RFC 3344 IP Mobility Support for IPv4 iana/mobileip-numbers mppc.c RFC 2118 Microsoft Point-to-Point Compression (MPPC) Protocol netbios_ns.c RFC 1001 Protocol Standard For a NetBIOS Service on a TCP/UDP Transport: Concepts and Methods RFC 1002 Protocol Standard For a NetBIOS Service on a TCP/UDP Transport: Detailed Specifications nntp.c RFC 0977 Network News Transfer Protocol ns_labels.c RFC 0883 Domain Names: Implementation Specification RFC 1001 Protocol Standard For a NetBIOS Service on a TCP/UDP Transport: Concepts and Methods RFC 1002 Protocol Standard For a NetBIOS Service on a TCP/UDP Transport: Detailed Specifications RFC 1035 Domain Names - Implementation And Specification open_pcap.c pcap man pages pcap.h tcpdump http://www.tcpdump.org ospf.c RFC 2328 OSPF Version 2 iana/ospf-authentication-codes iana/ospf-apaque-types iana/ospf-sig-alg padding.c RFC 0791 Internet Protocol RFC 0826 Ethernet Address Resolution Protocol ppp.c RFC 1661 The Point-to-Point Protocol (PPP) RFC 1662 PPP in HDLC-like Framing iana/ppp-numbers pppoe.c RFC 2516 A Method for Transmitting PPP Over Ethernet (PPPoE) pptp.c RFC 2637 Point-to-Point Tunneling Protocol (PPTP) radius_3gpp2.c 3rd Generation Partnership Project 2 http://www.3gpp2.com radius.c RFC 2865 Remote Authentication Dial In User Service (RADIUS) RFC 2866 RADIUS Accounting iana/radius-types rip.c RFC 1058 Routing Information Protocol RFC 2453 RIP Version 2 ripng.c RFC 2080 RIPng for IPv6 rsvp.c RFC 2205 Resource ReSerVation Protocol (RSVP) -- Version 1 Functional Specification iana/rsvp-parameters rtcp.c RFC 1889 RTP: A Transport Protocol for Real-Time Applications iana/rtp-parameters rtp.c RFC 1889 RTP: A Transport Protocol for Real-Time Applications iana/rtp-parameters sdp.c RFC 2327 SDP: Session Description Protocol sip.c RFC 3261 SIP: Session Initiation Protocol RFC 2543 SIP: Session Initiation Protocol (Obsolete) RFC 2616 Hypertext Transfer Protocol HTTP/1.1 slip.c RFC 0914 Thinwire protocol for connecting personal computers to the Internet Zvon - RFC914 - Appendix D -- Serial Line Interface Protocol (SLIP) http://www.zvon.org/tmRFC/RFC914/output/ chapter8.html slp.c RFC 2165 Service Location Protocol RFC 2608 Service Location Protocol, Version 2 snmp.c RFC 1157 Simple Network Management Protocol (SNMP) spx.c RFC Source Book http://www.networksorcery.com Protocols Directory http://www.protocols.com tcp.c RFC 0793 Transmission Control Protocol iana/tcp-parameters tftp.c RFC 1350 The TFTP Protocol (Revision 2) udp.c RFC 0768 User Datagram Protocol Note: In addition to the above documents for specific topics, the following resources have been helpful in general for all the topics: RFC Handbook - http://www.networksorcery.com/ Protocols Directory - http://www.protocols.com/ ipgrab-0.9.10/INSTALL0000644000175000001440000002252010642511067013307 0ustar farooqusers$Id: INSTALL,v 1.3 2007/07/03 18:15:19 farooq-i-azam Exp $ Basic Installation ================== These are generic installation instructions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, a file `config.cache' that saves the results of its tests to speed up reconfiguring, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.in' is used to create `configure' by a program called `autoconf'. You only need `configure.in' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying to execute `configure' itself. Running `configure' takes awhile. While running, it prints some messages telling which features it is checking for. If you built/installed libpcap from the source or have some Linux distributions then you may see messages about missing net/bpf.h or pcap.h. In that case you may need to specify something like this for configure: --with-pcaphdr=/usr/include/pcap Replace /usr/include/pcap with the name of the directory in which the headers are stored. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. You can give `configure' initial values for variables by setting them in the environment. Using a Bourne-compatible shell, you can do that on the command line like this: CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure Or on systems that have the `env' program, you can do it like this: env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you must use a version of `make' that supports the `VPATH' variable, such as GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. If you have to use a `make' that does not supports the `VPATH' variable, you have to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' will install the package's files in `/usr/local/bin', `/usr/local/man', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PATH'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you give `configure' the option `--exec-prefix=PATH', the package will use PATH as the prefix for installing programs and libraries. Documentation and other data files will still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=PATH' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. --with-pcaphdr=DIR If you built/installed libpcap from the source or have some Linux distributions then you may see messages about missing net/bpf.h or pcap.h. In that case you may need to specify something like this for configure: --with-pcaphdr=/usr/include/pcap Replace /usr/include/pcap with the name of the directory in which the headers are stored. --with-snmphdr=DIR If you have the UCD libsnmp package and would like ipgrab to handle SNMP traffic then you may need to indicate where configure can find the headers. The headers that we need are part of the ucd-snmp source distribution, so you will need to specifiy something like this: ---with-snmphdr=/usr/local/src/ucd-snmp-4.1.2/snmplib Specifying the System Type ========================== There may be some features `configure' can not figure out automatically, but needs to determine by the type of host the package will run on. Usually `configure' can figure that out, but if it prints a message saying it can not guess the host type, give it the `--host=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name with three fields: CPU-COMPANY-SYSTEM See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the host type. If you are building compiler tools for cross-compiling, you can also use the `--target=TYPE' option to select the type of system they will produce code for and the `--build=TYPE' option to select the type of system on which you are compiling the package. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Operation Controls ================== `configure' recognizes the following options to control how it operates. `--cache-file=FILE' Use and save the results of the tests in FILE instead of `./config.cache'. Set FILE to `/dev/null' to disable caching, for debugging `configure'. `--help' Print a summary of the options to `configure', and exit. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--version' Print the version of Autoconf used to generate the `configure' script, and exit. `configure' also accepts some other, not widely useful, options. Help ==== If you face difficulty installing ipgrab, you may like to join ipgrab users mailing list. You can subscribe to the list, by visiting the following link: http://lists.sourceforge.net/lists/listinfo/ipgrab-users/ Please note that this list has been set up so that ipgrab users may help and coordinate with each other. While it may be helpful to solve your problems, it is not at all obligatory for other list subscribers to respond to your queries. You may download a fresh copy of ipgrab from the website: http://www.sourceforge.net/projects/ipgrab/ ipgrab-0.9.10/Makefile.am0000644000175000001440000000004207115526507014313 0ustar farooqusersSUBDIRS = src doc CLEANFILES = *~ ipgrab-0.9.10/Makefile.in0000644000175000001440000004353510640147370014334 0ustar farooqusers# Makefile.in generated by automake 1.9.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = . am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \ TODO depcomp install-sh missing mkinstalldirs ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno configure.status.lineno mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-exec-recursive install-info-recursive \ install-recursive installcheck-recursive installdirs-recursive \ pdf-recursive ps-recursive uninstall-info-recursive \ uninstall-recursive ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ { test ! -d $(distdir) \ || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -fr $(distdir); }; } DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best distuninstallcheck_listfiles = find . -type f -print distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ ac_ct_CC = @ac_ct_CC@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build_alias = @build_alias@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host_alias = @host_alias@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ SUBDIRS = src doc CLEANFILES = *~ all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: am--refresh: @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \ cd $(srcdir) && $(AUTOMAKE) --gnu \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) cd $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) config.h: stamp-h1 @if test ! -f $@; then \ rm -f stamp-h1; \ $(MAKE) stamp-h1; \ else :; fi stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status config.h $(srcdir)/config.h.in: $(am__configure_deps) cd $(top_srcdir) && $(AUTOHEADER) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 uninstall-info-am: # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" mostlyclean-recursive clean-recursive distclean-recursive \ maintainer-clean-recursive: @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) $(am__remove_distdir) mkdir $(distdir) @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ list='$(DISTFILES)'; for file in $$list; do \ case $$file in \ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ esac; \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ if test "$$dir" != "$$file" && test "$$dir" != "."; then \ dir="/$$dir"; \ $(mkdir_p) "$(distdir)$$dir"; \ else \ dir=''; \ fi; \ if test -d $$d/$$file; then \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(mkdir_p) "$(distdir)/$$subdir" \ || exit 1; \ distdir=`$(am__cd) $(distdir) && pwd`; \ top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ (cd $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$top_distdir" \ distdir="$$distdir/$$subdir" \ distdir) \ || exit 1; \ fi; \ done -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r $(distdir) dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 $(am__remove_distdir) dist-tarZ: distdir tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__remove_distdir) dist-shar: distdir shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__remove_distdir) dist dist-all: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir); chmod a+w $(distdir) mkdir $(distdir)/_build mkdir $(distdir)/_inst chmod a-w $(distdir) dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && cd $(distdir)/_build \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck $(am__remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}' distuninstallcheck: @cd $(distuninstallcheck_dir) \ && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-recursive all-am: Makefile config.h installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile distclean-am: clean-am distclean-generic distclean-hdr distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive info: info-recursive info-am: install-data-am: install-exec-am: install-info: install-info-recursive install-man: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-info-am uninstall-info: uninstall-info-recursive .PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am am--refresh check \ check-am clean clean-generic clean-recursive ctags \ ctags-recursive dist dist-all dist-bzip2 dist-gzip dist-shar \ dist-tarZ dist-zip distcheck distclean distclean-generic \ distclean-hdr distclean-recursive distclean-tags \ distcleancheck distdir distuninstallcheck dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-exec install-exec-am install-info \ install-info-am install-man install-strip installcheck \ installcheck-am installdirs installdirs-am maintainer-clean \ maintainer-clean-generic maintainer-clean-recursive \ mostlyclean mostlyclean-generic mostlyclean-recursive pdf \ pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ uninstall-info-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ipgrab-0.9.10/NEWS0000644000175000001440000000002607104350231012743 0ustar farooqusersNo news is good news ipgrab-0.9.10/README0000644000175000001440000001127510644704753013153 0ustar farooqusers$Id: README,v 1.5 2007/07/10 13:30:19 farooq-i-azam Exp $ ipgrab Mike Borella mike@borella.netNOPSAM ------------------------------------------------------------------------------ COPYRIGHT Copyright (C) 1997-2007 Mike Borella Redistribution and use in source and binary forms are permitted provided that this paragraph is duplicated in all such forms and in any documentation, advertising materials, and other materials related to such distribution and use acknowledge that the software was developed by Mike Borella. The name of the Author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. Some of this code has been taken from tcpdump, which was developed by the Network Research Group at Lawrence Berkeley National Lab, and is copyrighted by the University of California Regents. ------------------------------------------------------------------------------ ABOUT This README file accompanies ipgrab version 0.9.10. This new release fixes many bugs and errors, and ipgrab is now lot more stable. You may see ChangeLog for more details of the changes which were applied. Also, this release is now in synchronization with CVS repository. You may download a fresh copy of ipgrab from the following website: http://www.sourceforge.net/projects/ipgrab/ ------------------------------------------------------------------------------- DESCRIPTION This program reads and parses packets from the link layer through the transport layer, dumping explicit header information along the way. It is a lot like tcpdump from LBL except that I've made an effort to dump every relevant header field possible. The overall structure of the code is loosely based on tcpdump and I've lifted a few modules from the tcpdump distribution when necessary, rather than re-inventing the wheel. In particular, the address conversion hashing routines are pretty much lifted verbatim, as well as the TCP options section. I expect that this code can be used for detailed packet level debugging of existing or new protocols. Also, I imagine that it could be a useful teaching and instruction tool for TCP/IP or security courses. I've made an effort to make the code readable, sometimes even at the expense of efficiency, so that one can use it to learn about the pcap library calls and the header field data structures. Would you like to see new features and protocols supported? Do you have a proprietary protocol that you'd like to test? Two ways to make it happen: (1) write a module yourself - if you send me a copy I'll merge it into my source and acknowledge you as author, (2) ask me to write it - send me email for details. ------------------------------------------------------------------------------- INSTALLATION You must have the pcap library (libpcap) installed. In particular, the pcap.h and net/bpf.h files must be in an appropriate include directory (just grabbing a pre-compiled libpcap.so won't cut it). Download pcap from http://www.tcpdump.org Run the configure script to create a Makefile, then type 'make'. If you need to install any other libraries or headers, configure should tell you. It should compile cleanly on Linux and most other types of UNIX. It will also run on Windows if the WinPcap library is properly installed. In order to build on Windows you need Cygwin with the WinPcap development files installed in the /usr/local directory. Please refer to INSTALL file included with the ipgrab package for more detailed help on installation. ------------------------------------------------------------------------------- OPERATION See man and info pages for details. ------------------------------------------------------------------------------- BUGS Please report any problems or bugs to Mike Borella Muhammad Farooq-i-Azam ------------------------------------------------------------------------------- THANKS Marty Roesch fixed some of the timestamping, and provided the code for payload output. Jorgen Pehrson provided the buffered output option. Stuart Stock added a lot of fixes to ISAKMP. Cullen Jennings contributed the MGCP parser. Lots of other people suggested things that eventually made their way into the code, in one form or another. ------------------------------------------------------------------------------- DISCLAIMER Please use ipgrab at your own risk. There is no warranty, expressed or implied, associated with this product. ------------------------------------------------------------------------------- ipgrab-0.9.10/TODO0000644000175000001440000000413410644705033012747 0ustar farooqusers$Id: TODO,v 1.18 2007/07/10 13:31:07 farooq-i-azam Exp $ This file contains a list of features, improvements and minor bug fixes that would help make IPgrab a better program. Some of the things listed here will be implemented soon, others maybe not for a while, and some are pipe dreams :-) -Mike - Generic stats module with packet types - IP - UDP - TCP - IPX - SPX - NETBIOS - ICMP doesn't include padding after some errors. Also needs complete and mask code needs fixing. - display_banner_ts() [ Fixed in ipgrab version 0.9.10. Further improvement may be made. ] - quiet and version options not needed. - fix snmp.h - MGCP is very broken - NLZ display mode for HEX? [ This has now been provided with ipgrab version 0.9.10 ] - Fix output of v6 addresses to standard short form - FIx label length in display .c for announcements - ICMPv6 may not be printing neighbor solicitations properly - ICMPv6 support is weak - quick fix needed - ICMPv6 needs better minimal mode support - Need command line option to turn off timestamps [ This is already provided for minimal mode. ] - OSPF Hello options should be enumerated - Command line option for "fast mode" ? - DHCP in general is not complete - SPX minimal mode needs further work - currently is doesn't do much - Support for IPv6 extension headers aside from IPsec - IPv6 addresses should have a special display type that uses the "compression" to get rid of all-zero words. - ISAKMP and L2TP are not currently linked into the main code because of two reasons (1) they are big and will require careful re-writing to fit the 0.9 mold, and (2) I currently do not have a testbed available for testing. I will soon... - The strmap_t functions could be extended to support certain ranges so that we could say that, for example, all ICMPv6 types under 128 are errors, even though most are yet to be defined. Also, a binary search would speed some of the longer lists. - Update this TODO file. Note: This TODO file seems dated and many features in the list in this file seem to be available. However, this file has not been updated. ipgrab-0.9.10/acinclude.m40000644000175000001440000000527210530550304014445 0ustar farooqusers AC_DEFUN([AC_HEADER_FIND], [ r="0" for dir in $2; do AC_MSG_CHECKING(for $1 in $dir) if test -r $dir/$1; then CPPFLAGS="$CPPFLAGS -I$dir" AC_SUBST(CPPFLAGS) AC_DEFINE($3) AC_MSG_RESULT(yes) r="1" break; fi AC_MSG_RESULT(no) done if test $r = 0; then AC_MSG_WARN("$1 not found") fi ] ) # MD_PATH(PACKAGE, HEADER, LIBRARY, SYMBOL) # ----------------------------------------- # Set PACKAGE_CPPFLAGS and PACKAGE_LIBS to the flags needed to # compile/link with PACKAGE. HEADER and LIBRARY should be a header # file and a library, respectively, belonging to PACKAGE. SYMBOL # should be a SYMBOL in LIBRARY. If the package is available, define # HAVE_PACKAGE. AC_DEFUN([MD_PATH], [AS_VAR_PUSHDEF([md_Package], [md_path_have_$1])dnl AS_VAR_PUSHDEF([md_Inc], [md_path_include_$1])dnl AS_VAR_PUSHDEF([md_Lib], [md_path_lib_$1])dnl AS_VAR_SET(md_Package, yes) AS_VAR_SET(md_Inc, []) AS_VAR_SET(md_Lib, []) AC_ARG_WITH([$1], AC_HELP_STRING([--with-$1=DIR], [search $1 header files in DIR/include, library in DIR/lib]), [case $withval in yes) AS_VAR_SET(md_Package, yes) ;; no) AS_VAR_SET(md_Package, no) ;; *) AS_VAR_SET(md_Package, yes) AS_VAR_SET(md_Inc, ["$withval/include"]) AS_VAR_SET(md_Lib, ["$withval/lib"]) ;; esac]) AC_ARG_WITH([$1-include], AC_HELP_STRING([--with-$1-include=DIR], [search $1 header files in DIR]), [case $withval in yes) AS_VAR_SET(md_Package, yes) ;; no) AS_VAR_SET(md_Package, no) ;; *) AS_VAR_SET(md_Package, yes) AS_VAR_SET(md_Inc, ["$withval"]) ;; esac]) AC_ARG_WITH([$1-lib], AC_HELP_STRING([--with-$1-lib=DIR], [search $1 library in DIR]), [case $withval in yes) AS_VAR_SET(md_Package, yes) ;; no) AS_VAR_SET(md_Package, no) ;; *) AS_VAR_SET(md_Package, yes) AS_VAR_SET(md_Lib, ["$withval"]) ;; esac]) AS_TR_CPP([$1]_CPPFLAGS)= AS_TR_CPP([$1]_LIBS)= AS_IF([test AS_VAR_GET(md_Package) = yes], [AS_IF([test "x[]AS_VAR_GET(md_Inc)" != x], [AS_TR_CPP([$1]_CPPFLAGS)="-I[]AS_VAR_GET(md_Inc)"]) AS_IF([test "x[]AS_VAR_GET(md_Lib)" != x], [AS_TR_CPP([$1]_LIBS)="-L[]AS_VAR_GET(md_Lib)"]) save_CPPFLAGS="$CPPFLAGS"; CPPFLAGS="$CPPFLAGS $[]AS_TR_CPP([$1]_CPPFLAGS)" AC_CHECK_HEADER([$2], [save_LDFLAGS="$LDFLAGS"; LDFLAGS="$LDFLAGS $[]AS_TR_CPP([$1]_LIBS)" AC_CHECK_LIB([$3], [$4], [AS_TR_CPP([$1]_LIBS)="$[]AS_TR_CPP([$1]_LIBS) -l[$3]"], [AS_VAR_SET(md_Package, no)]) LDFLAGS="$save_LDFLAGS"], [AS_VAR_SET(md_Package, no)]) CPPFLAGS="$save_CPPFLAGS"]) AH_TEMPLATE(AS_TR_CPP(HAVE_[$1]), [Define if package `$1' is available.])dnl AS_IF([test AS_VAR_GET(md_Package) = yes], [AC_DEFINE(AS_TR_CPP(HAVE_[$1]), [1])])dnl AS_VAR_POPDEF([md_Lib])dnl AS_VAR_POPDEF([md_Inc])dnl AS_VAR_POPDEF([md_Package])dnl ])# MD_PATH ipgrab-0.9.10/aclocal.m40000644000175000001440000007465310640142372014131 0ustar farooqusers# generated automatically by aclocal 1.9.6 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. # Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"]) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION so it can be traced. # This function is AC_REQUIREd by AC_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.9.6])]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to # `$srcdir', `$srcdir/..', or `$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is `.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 7 # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ(2.52)dnl ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE]) AC_SUBST([$1_FALSE]) if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 8 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "GCJ", or "OBJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl ifelse([$1], CC, [depcc="$CC" am_compiler_list=], [$1], CXX, [depcc="$CXX" am_compiler_list=], [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf case $depmode in nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; none) break ;; esac # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. if depmode=$depmode \ source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE(dependency-tracking, [ --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH]) ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. #serial 3 # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [for mf in $CONFIG_FILES; do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # So let's grep whole file. if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each `.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 12 # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.58])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl # test to see if srcdir already configured if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) AM_MISSING_PROG(AUTOCONF, autoconf) AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) AM_MISSING_PROG(AUTOHEADER, autoheader) AM_MISSING_PROG(MAKEINFO, makeinfo) AM_PROG_INSTALL_SH AM_PROG_INSTALL_STRIP AC_REQUIRE([AM_PROG_MKDIR_P])dnl # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES(CC)], [define([AC_PROG_CC], defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES(CXX)], [define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl ]) ]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $1 | $1:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl install_sh=${install_sh-"$am_aux_dir/install-sh"} AC_SUBST(install_sh)]) # Copyright (C) 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 3 # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo done .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # We grep out `Entering directory' and `Leaving directory' # messages which can occur if `w' ends up in MAKEFLAGS. # In particular we don't look at `^make:' because GNU make might # be invoked under some other name (usually "gmake"), in which # case it prints its new name instead of `make'. if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then am__include=include am__quote= _am_result=GNU fi # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then am__include=.include am__quote="\"" _am_result=BSD fi fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 4 # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it supports --run. # If it does, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= AC_MSG_WARN([`missing' script is too old or missing]) fi ]) # Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_MKDIR_P # --------------- # Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise. # # Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories # created by `make install' are always world readable, even if the # installer happens to have an overly restrictive umask (e.g. 077). # This was a mistake. There are at least two reasons why we must not # use `-m 0755': # - it causes special bits like SGID to be ignored, # - it may be too restrictive (some setups expect 775 directories). # # Do not use -m 0755 and let people choose whatever they expect by # setting umask. # # We cannot accept any implementation of `mkdir' that recognizes `-p'. # Some implementations (such as Solaris 8's) are not thread-safe: if a # parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c' # concurrently, both version can detect that a/ is missing, but only # one can create it and the other will error out. Consequently we # restrict ourselves to GNU make (using the --version option ensures # this.) AC_DEFUN([AM_PROG_MKDIR_P], [if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then # We used to keeping the `.' as first argument, in order to # allow $(mkdir_p) to be used without argument. As in # $(mkdir_p) $(somedir) # where $(somedir) is conditionally defined. However this is wrong # for two reasons: # 1. if the package is installed by a user who cannot write `.' # make install will fail, # 2. the above comment should most certainly read # $(mkdir_p) $(DESTDIR)$(somedir) # so it does not work when $(somedir) is undefined and # $(DESTDIR) is not. # To support the latter case, we have to write # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), # so the `.' trick is pointless. mkdir_p='mkdir -p --' else # On NextStep and OpenStep, the `mkdir' command does not # recognize any option. It will interpret all options as # directories to create, and then abort because `.' already # exists. for d in ./-p ./--version; do test -d $d && rmdir $d done # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. if test -f "$ac_aux_dir/mkinstalldirs"; then mkdir_p='$(mkinstalldirs)' else mkdir_p='$(install_sh) -d' fi fi AC_SUBST([mkdir_p])]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 3 # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # ------------------------------ # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), 1)]) # _AM_SET_OPTIONS(OPTIONS) # ---------------------------------- # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 4 # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftest.file # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t $srcdir/configure conftest.file` fi rm -f conftest.file if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT(yes)]) # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor `install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in `make install-strip', and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be `maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of `v7', `ustar', or `pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. AM_MISSING_PROG([AMTAR], [tar]) m4_if([$1], [v7], [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], [m4_case([$1], [ustar],, [pax],, [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' _am_tools=${am_cv_prog_tar_$1-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and # Solaris sh will not grok spaces in the rhs of `-'. for _am_tool in $_am_tools do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([acinclude.m4]) ipgrab-0.9.10/config.h.in0000644000175000001440000001072710530550304014300 0ustar farooqusers/* config.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_INET_H /* Define to 1 if you have the header file. */ #undef HAVE_CTYPE_H /* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ #undef HAVE_DOPRNT /* Define to 1 if you have the header file. */ #undef HAVE_GETOPT_H /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY /* Define to 1 if you have the `inet_ntoa' function. */ #undef HAVE_INET_NTOA /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `intl' library (-lintl). */ #undef HAVE_LIBINTL /* Define to 1 if you have the header file. */ #undef HAVE_LIBINTL_H /* Define if package `libpcap' is available. */ #undef HAVE_LIBPCAP /* Define to 1 if your system has a GNU libc compatible `malloc' function, and to 0 otherwise. */ #undef HAVE_MALLOC /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_H /* Define to 1 if your system has a GNU libc compatible `realloc' function, and to 0 otherwise. */ #undef HAVE_REALLOC /* Define to 1 if you have the header file. */ #undef HAVE_SIGNAL_H /* Define to 1 if you have the header file. */ #undef HAVE_STDARG_H /* Define to 1 if stdbool.h conforms to C99. */ #undef HAVE_STDBOOL_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the `strchr' function. */ #undef HAVE_STRCHR /* Define to 1 if you have the `strdup' function. */ #undef HAVE_STRDUP /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strstr' function. */ #undef HAVE_STRSTR /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the `vprintf' function. */ #undef HAVE_VPRINTF /* Define to 1 if the system has the type `_Bool'. */ #undef HAVE__BOOL /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if the C compiler supports function prototypes. */ #undef PROTOTYPES /* Define as the return type of signal handlers (`int' or `void'). */ #undef RETSIGTYPE /* Define to 1 if the `setvbuf' function takes the buffering type as its second argument and the buffer pointer as the third, as on System V before release 3. */ #undef SETVBUF_REVERSED /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Version number of package */ #undef VERSION /* Define to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel and VAX). */ #undef WORDS_BIGENDIAN /* Define like PROTOTYPES; this can be used by system headers. */ #undef __PROTOTYPES /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus #undef inline #endif /* Define to rpl_malloc if the replacement function should be used. */ #undef malloc /* Define to `int' if does not define. */ #undef pid_t /* Define to rpl_realloc if the replacement function should be used. */ #undef realloc /* Define to `unsigned' if does not define. */ #undef size_t ipgrab-0.9.10/configure0000755000175000001440000065141210640142770014174 0ustar farooqusers#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for ipgrab 0.9.10. # # Report bugs to . # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi # PATH needs CR # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) as_nl=' ' IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 { (exit 1); exit 1; } fi # Work around bugs in pre-3.0 UWIN ksh. for as_var in ENV MAIL MAILPATH do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var fi done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # CDPATH. $as_unset CDPATH if test "x$CONFIG_SHELL" = x; then if (eval ":") 2>/dev/null; then as_have_required=yes else as_have_required=no fi if test $as_have_required = yes && (eval ": (as_func_return () { (exit \$1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = \"\$1\" ); then : else exitcode=1 echo positional parameters were not saved. fi test \$exitcode = 0) || { (exit 1); exit 1; } ( as_lineno_1=\$LINENO as_lineno_2=\$LINENO test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } ") 2> /dev/null; then : else as_candidate_shells= as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. case $as_dir in /*) for as_base in sh bash ksh sh5; do as_candidate_shells="$as_candidate_shells $as_dir/$as_base" done;; esac done IFS=$as_save_IFS for as_shell in $as_candidate_shells $SHELL; do # Try only shells that exist, to save several forks. if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { ("$as_shell") 2> /dev/null <<\_ASEOF if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi : _ASEOF }; then CONFIG_SHELL=$as_shell as_have_required=yes if { "$as_shell" 2> /dev/null <<\_ASEOF if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi : (as_func_return () { (exit $1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = "$1" ); then : else exitcode=1 echo positional parameters were not saved. fi test $exitcode = 0) || { (exit 1); exit 1; } ( as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } _ASEOF }; then break fi fi done if test "x$CONFIG_SHELL" != x; then for as_var in BASH_ENV ENV do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done export CONFIG_SHELL exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} fi if test $as_have_required = no; then echo This script requires a shell more modern than all the echo shells that I found on your system. Please install a echo modern shell, or manually run the script under such a echo shell if you do have one. { (exit 1); exit 1; } fi fi fi (eval "as_func_return () { (exit \$1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = \"\$1\" ); then : else exitcode=1 echo positional parameters were not saved. fi test \$exitcode = 0") || { echo No shell found that supports shell functions. echo Please tell autoconf@gnu.org about your system, echo including any error possibly output before this echo message } as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line after each line using $LINENO; the second 'sed' # does the real work. The second script uses 'N' to pair each # line-number line with the line containing $LINENO, and appends # trailing '-' during substitution so that $LINENO is not a special # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # scripts with optimization help from Paolo Bonzini. Blame Lee # E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in -n*) case `echo 'x\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. *) ECHO_C='\c';; esac;; *) ECHO_N='-n';; esac if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir fi echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='ipgrab' PACKAGE_TARNAME='ipgrab' PACKAGE_VERSION='0.9.10' PACKAGE_STRING='ipgrab 0.9.10' PACKAGE_BUGREPORT='mike@borella.net' ac_unique_file="src/ipgrab.c" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datarootdir datadir sysconfdir sharedstatedir localstatedir includedir oldincludedir docdir infodir htmldir dvidir pdfdir psdir libdir localedir mandir DEFS ECHO_C ECHO_N ECHO_T LIBS build_alias host_alias target_alias INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP GREP EGREP LIBOBJS LTLIBOBJS' ac_subst_files='' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` eval enable_$ac_feature=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` eval enable_$ac_feature=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package | sed 's/[-.]/_/g'` eval with_$ac_package=\$ac_optarg ;; -without-* | --without-*) ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package | sed 's/[-.]/_/g'` eval with_$ac_package=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) { echo "$as_me: error: unrecognized option: $ac_option Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` { echo "$as_me: error: missing argument to $ac_option" >&2 { (exit 1); exit 1; }; } fi # Be sure to have absolute directory names. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; } done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || { echo "$as_me: error: Working directory cannot be determined" >&2 { (exit 1); exit 1; }; } test "X$ac_ls_di" = "X$ac_pwd_ls_di" || { echo "$as_me: error: pwd does not report name of working directory" >&2 { (exit 1); exit 1; }; } # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$0" || $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$0" : 'X\(//\)[^/]' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X"$0" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 { (exit 1); exit 1; }; } fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 { (exit 1); exit 1; }; } pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures ipgrab 0.9.10 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/ipgrab] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of ipgrab 0.9.10:";; esac cat <<\_ACEOF Optional Features: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-libpcap=DIR search libpcap header files in DIR/include, library in DIR/lib --with-libpcap-include=DIR search libpcap header files in DIR --with-libpcap-lib=DIR search libpcap library in DIR Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF ipgrab configure 0.9.10 generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by ipgrab $as_me 0.9.10, which was generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; 2) ac_configure_args1="$ac_configure_args1 '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac done done $as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } $as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo cat <<\_ASBOX ## ---------------- ## ## Cache variables. ## ## ---------------- ## _ASBOX echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( *) $as_unset $ac_var ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo cat <<\_ASBOX ## ----------------- ## ## Output variables. ## ## ----------------- ## _ASBOX echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then cat <<\_ASBOX ## ------------------- ## ## File substitutions. ## ## ------------------- ## _ASBOX echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then cat <<\_ASBOX ## ----------- ## ## confdefs.h. ## ## ----------- ## _ASBOX echo cat confdefs.h echo fi test "$ac_signal" != 0 && echo "$as_me: caught signal $ac_signal" echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. if test -n "$CONFIG_SITE"; then set x "$CONFIG_SITE" elif test "x$prefix" != xNONE; then set x "$prefix/share/config.site" "$prefix/etc/config.site" else set x "$ac_default_prefix/share/config.site" \ "$ac_default_prefix/etc/config.site" fi shift for ac_site_file do if test -r "$ac_site_file"; then { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special # files actually), so we avoid doing that. if test -f "$cache_file"; then { echo "$as_me:$LINENO: loading cache $cache_file" >&5 echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { echo "$as_me:$LINENO: creating cache $cache_file" >&5 echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 echo "$as_me: former value: $ac_old_val" >&2;} { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 echo "$as_me: current value: $ac_new_val" >&2;} ac_cache_corrupted=: fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 echo "$as_me: error: changes in the environment can compromise the build" >&2;} { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu am__api_version="1.9" ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5 echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;} { (exit 1); exit 1; }; } fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. { echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; } if test -z "$INSTALL"; then if test "${ac_cv_path_install+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in ./ | .// | /cC/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi done done ;; esac done IFS=$as_save_IFS fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { echo "$as_me:$LINENO: result: $INSTALL" >&5 echo "${ECHO_T}$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { echo "$as_me:$LINENO: checking whether build environment is sane" >&5 echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6; } # Just in case sleep 1 echo timestamp > conftest.file # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t $srcdir/configure conftest.file` fi rm -f conftest.file if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken alias in your environment" >&5 echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken alias in your environment" >&2;} { (exit 1); exit 1; }; } fi test "$2" = conftest.file ) then # Ok. : else { { echo "$as_me:$LINENO: error: newly created file is older than distributed files! Check your system clock" >&5 echo "$as_me: error: newly created file is older than distributed files! Check your system clock" >&2;} { (exit 1); exit 1; }; } fi { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. echo might interpret backslashes. # By default was `s,x,x', remove it if useless. cat <<\_ACEOF >conftest.sed s/[\\$]/&&/g;s/;s,x,x,$// _ACEOF program_transform_name=`echo $program_transform_name | sed -f conftest.sed` rm -f conftest.sed # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then # We used to keeping the `.' as first argument, in order to # allow $(mkdir_p) to be used without argument. As in # $(mkdir_p) $(somedir) # where $(somedir) is conditionally defined. However this is wrong # for two reasons: # 1. if the package is installed by a user who cannot write `.' # make install will fail, # 2. the above comment should most certainly read # $(mkdir_p) $(DESTDIR)$(somedir) # so it does not work when $(somedir) is undefined and # $(DESTDIR) is not. # To support the latter case, we have to write # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), # so the `.' trick is pointless. mkdir_p='mkdir -p --' else # On NextStep and OpenStep, the `mkdir' command does not # recognize any option. It will interpret all options as # directories to create, and then abort because `.' already # exists. for d in ./-p ./--version; do test -d $d && rmdir $d done # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. if test -f "$ac_aux_dir/mkinstalldirs"; then mkdir_p='$(mkinstalldirs)' else mkdir_p='$(install_sh) -d' fi fi for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_AWK+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AWK="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { echo "$as_me:$LINENO: result: $AWK" >&5 echo "${ECHO_T}$AWK" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$AWK" && break done { echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6; } set x ${MAKE-make}; ac_make=`echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } SET_MAKE= else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null # test to see if srcdir already configured if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} { (exit 1); exit 1; }; } fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='ipgrab' VERSION='0.9.10' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} install_sh=${install_sh-"$am_aux_dir/install-sh"} # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_STRIP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { echo "$as_me:$LINENO: result: $STRIP" >&5 echo "${ECHO_T}$STRIP" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 echo "${ECHO_T}$ac_ct_STRIP" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. AMTAR=${AMTAR-"${am_missing_run}tar"} am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' ac_config_headers="$ac_config_headers config.h" # Checks for programs. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&5 echo "$as_me: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. echo "$as_me:$LINENO: checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (ac_try="$ac_compiler --version >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -v >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -v >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -V >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # # List of possible output files, starting from the most likely. # The algorithm is not robust to junk in `.', hence go to wildcards (a.*) # only as a last resort. b.out is created by i960 compilers. ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' # # The IRIX 6 linker writes into existing files which may not be # executable, retaining their permissions. Remove them first so a # subsequent execution test works. ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { (ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link_default") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi { echo "$as_me:$LINENO: result: $ac_file" >&5 echo "${ECHO_T}$ac_file" >&6; } if test -z "$ac_file"; then echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: C compiler cannot create executables See \`config.log' for more details." >&5 echo "$as_me: error: C compiler cannot create executables See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } fi ac_exeext=$ac_cv_exeext # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { echo "$as_me:$LINENO: checking whether the C compiler works" >&5 echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; } # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { echo "$as_me:$LINENO: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&5 echo "$as_me: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi fi fi { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } rm -f a.out a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } { echo "$as_me:$LINENO: result: $cross_compiling" >&5 echo "${ECHO_T}$cross_compiling" >&6; } { echo "$as_me:$LINENO: checking for suffix of executables" >&5 echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; } if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest$ac_cv_exeext { echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 echo "${ECHO_T}$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT { echo "$as_me:$LINENO: checking for suffix of object files" >&5 echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 echo "${ECHO_T}$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 CFLAGS="" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_c89+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_c89=$ac_arg else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { echo "$as_me:$LINENO: result: none needed" >&5 echo "${ECHO_T}none needed" >&6; } ;; xno) { echo "$as_me:$LINENO: result: unsupported" >&5 echo "${ECHO_T}unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; esac ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo done .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # We grep out `Entering directory' and `Leaving directory' # messages which can occur if `w' ends up in MAKEFLAGS. # In particular we don't look at `^make:' because GNU make might # be invoked under some other name (usually "gmake"), in which # case it prints its new name instead of `make'. if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then am__include=include am__quote= _am_result=GNU fi # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then am__include=.include am__quote="\"" _am_result=BSD fi fi { echo "$as_me:$LINENO: result: $_am_result" >&5 echo "${ECHO_T}$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi depcc="$CC" am_compiler_list= { echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; } if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf case $depmode in nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; none) break ;; esac # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. if depmode=$depmode \ source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi # Checks for libraries. { echo "$as_me:$LINENO: checking for main in -lintl" >&5 echo $ECHO_N "checking for main in -lintl... $ECHO_C" >&6; } if test "${ac_cv_lib_intl_main+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lintl $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_intl_main=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_intl_main=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_intl_main" >&5 echo "${ECHO_T}$ac_cv_lib_intl_main" >&6; } if test $ac_cv_lib_intl_main = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBINTL 1 _ACEOF LIBS="-lintl $LIBS" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test "${ac_cv_prog_CPP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { echo "$as_me:$LINENO: result: $CPP" >&5 echo "${ECHO_T}$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&5 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } if test "${ac_cv_path_GREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Extract the first word of "grep ggrep" to use in msg output if test -z "$GREP"; then set dummy grep ggrep; ac_prog_name=$2 if test "${ac_cv_path_GREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ac_count=`expr $ac_count + 1` if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS fi GREP="$ac_cv_path_GREP" if test -z "$GREP"; then { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } fi else ac_cv_path_GREP=$GREP fi fi { echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 echo "${ECHO_T}$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { echo "$as_me:$LINENO: checking for egrep" >&5 echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } if test "${ac_cv_path_EGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else # Extract the first word of "egrep" to use in msg output if test -z "$EGREP"; then set dummy egrep; ac_prog_name=$2 if test "${ac_cv_path_EGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ac_count=`expr $ac_count + 1` if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS fi EGREP="$ac_cv_path_EGREP" if test -z "$EGREP"; then { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } fi else ac_cv_path_EGREP=$EGREP fi fi fi { echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_header_stdc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi { echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF #define STDC_HEADERS 1 _ACEOF fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Header=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done md_path_have_libpcap=yes md_path_include_libpcap= md_path_lib_libpcap= # Check whether --with-libpcap was given. if test "${with_libpcap+set}" = set; then withval=$with_libpcap; case $withval in yes) md_path_have_libpcap=yes ;; no) md_path_have_libpcap=no ;; *) md_path_have_libpcap=yes md_path_include_libpcap="$withval/include" md_path_lib_libpcap="$withval/lib" ;; esac fi # Check whether --with-libpcap-include was given. if test "${with_libpcap_include+set}" = set; then withval=$with_libpcap_include; case $withval in yes) md_path_have_libpcap=yes ;; no) md_path_have_libpcap=no ;; *) md_path_have_libpcap=yes md_path_include_libpcap="$withval" ;; esac fi # Check whether --with-libpcap-lib was given. if test "${with_libpcap_lib+set}" = set; then withval=$with_libpcap_lib; case $withval in yes) md_path_have_libpcap=yes ;; no) md_path_have_libpcap=no ;; *) md_path_have_libpcap=yes md_path_lib_libpcap="$withval" ;; esac fi LIBPCAP_CPPFLAGS= LIBPCAP_LIBS= if test $md_path_have_libpcap = yes; then if test "x$md_path_include_libpcap" != x; then LIBPCAP_CPPFLAGS="-I$md_path_include_libpcap" fi if test "x$md_path_lib_libpcap" != x; then LIBPCAP_LIBS="-L$md_path_lib_libpcap" fi save_CPPFLAGS="$CPPFLAGS"; CPPFLAGS="$CPPFLAGS $LIBPCAP_CPPFLAGS" if test "${ac_cv_header_pcap_h+set}" = set; then { echo "$as_me:$LINENO: checking for pcap.h" >&5 echo $ECHO_N "checking for pcap.h... $ECHO_C" >&6; } if test "${ac_cv_header_pcap_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi { echo "$as_me:$LINENO: result: $ac_cv_header_pcap_h" >&5 echo "${ECHO_T}$ac_cv_header_pcap_h" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking pcap.h usability" >&5 echo $ECHO_N "checking pcap.h usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking pcap.h presence" >&5 echo $ECHO_N "checking pcap.h presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: pcap.h: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: pcap.h: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: pcap.h: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: pcap.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: pcap.h: present but cannot be compiled" >&5 echo "$as_me: WARNING: pcap.h: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: pcap.h: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: pcap.h: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: pcap.h: see the Autoconf documentation" >&5 echo "$as_me: WARNING: pcap.h: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: pcap.h: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: pcap.h: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: pcap.h: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: pcap.h: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: pcap.h: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: pcap.h: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## ------------------------------- ## ## Report this to mike@borella.net ## ## ------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { echo "$as_me:$LINENO: checking for pcap.h" >&5 echo $ECHO_N "checking for pcap.h... $ECHO_C" >&6; } if test "${ac_cv_header_pcap_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_pcap_h=$ac_header_preproc fi { echo "$as_me:$LINENO: result: $ac_cv_header_pcap_h" >&5 echo "${ECHO_T}$ac_cv_header_pcap_h" >&6; } fi if test $ac_cv_header_pcap_h = yes; then save_LDFLAGS="$LDFLAGS"; LDFLAGS="$LDFLAGS $LIBPCAP_LIBS" { echo "$as_me:$LINENO: checking for pcap_close in -lpcap" >&5 echo $ECHO_N "checking for pcap_close in -lpcap... $ECHO_C" >&6; } if test "${ac_cv_lib_pcap_pcap_close+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpcap $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pcap_close (); int main () { return pcap_close (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_pcap_pcap_close=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_pcap_pcap_close=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_pcap_pcap_close" >&5 echo "${ECHO_T}$ac_cv_lib_pcap_pcap_close" >&6; } if test $ac_cv_lib_pcap_pcap_close = yes; then LIBPCAP_LIBS="$LIBPCAP_LIBS -lpcap" else md_path_have_libpcap=no fi LDFLAGS="$save_LDFLAGS" else md_path_have_libpcap=no fi CPPFLAGS="$save_CPPFLAGS" fi if test $md_path_have_libpcap = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_LIBPCAP 1 _ACEOF fi # Checks for header files. { echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_header_stdc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi { echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF #define STDC_HEADERS 1 _ACEOF fi for ac_header in arpa/inet.h libintl.h netinet/in.h stdlib.h string.h strings.h sys/socket.h unistd.h stdarg.h signal.h sys/types.h ctype.h getopt.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## ------------------------------- ## ## Report this to mike@borella.net ## ## ------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # Checks for typedefs, structures, and compiler characteristics. { echo "$as_me:$LINENO: checking for stdbool.h that conforms to C99" >&5 echo $ECHO_N "checking for stdbool.h that conforms to C99... $ECHO_C" >&6; } if test "${ac_cv_header_stdbool_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #ifndef bool "error: bool is not defined" #endif #ifndef false "error: false is not defined" #endif #if false "error: false is not 0" #endif #ifndef true "error: true is not defined" #endif #if true != 1 "error: true is not 1" #endif #ifndef __bool_true_false_are_defined "error: __bool_true_false_are_defined is not defined" #endif struct s { _Bool s: 1; _Bool t; } s; char a[true == 1 ? 1 : -1]; char b[false == 0 ? 1 : -1]; char c[__bool_true_false_are_defined == 1 ? 1 : -1]; char d[(bool) 0.5 == true ? 1 : -1]; bool e = &s; char f[(_Bool) 0.0 == false ? 1 : -1]; char g[true]; char h[sizeof (_Bool)]; char i[sizeof s.t]; enum { j = false, k = true, l = false * true, m = true * 256 }; _Bool n[m]; char o[sizeof n == m * sizeof n[0] ? 1 : -1]; char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; # if defined __xlc__ || defined __GNUC__ /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 reported by James Lemley on 2005-10-05; see http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html This test is not quite right, since xlc is allowed to reject this program, as the initializer for xlcbug is not one of the forms that C requires support for. However, doing the test right would require a runtime test, and that would make cross-compilation harder. Let us hope that IBM fixes the xlc bug, and also adds support for this kind of constant expression. In the meantime, this test will reject xlc, which is OK, since our stdbool.h substitute should suffice. We also test this with GCC, where it should work, to detect more quickly whether someone messes up the test in the future. */ char digs[] = "0123456789"; int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1); # endif /* Catch a bug in an HP-UX C compiler. See http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html */ _Bool q = true; _Bool *pq = &q; int main () { *pq |= q; *pq |= ! q; /* Refer to every declared value, to avoid compiler optimizations. */ return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + !m + !n + !o + !p + !q + !pq); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_header_stdbool_h=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_stdbool_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_header_stdbool_h" >&5 echo "${ECHO_T}$ac_cv_header_stdbool_h" >&6; } { echo "$as_me:$LINENO: checking for _Bool" >&5 echo $ECHO_N "checking for _Bool... $ECHO_C" >&6; } if test "${ac_cv_type__Bool+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef _Bool ac__type_new_; int main () { if ((ac__type_new_ *) 0) return 0; if (sizeof (ac__type_new_)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_type__Bool=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type__Bool=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_type__Bool" >&5 echo "${ECHO_T}$ac_cv_type__Bool" >&6; } if test $ac_cv_type__Bool = yes; then cat >>confdefs.h <<_ACEOF #define HAVE__BOOL 1 _ACEOF fi if test $ac_cv_header_stdbool_h = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_STDBOOL_H 1 _ACEOF fi { echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6; } if test "${ac_cv_c_const+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { /* FIXME: Include the comments suggested by Paul. */ #ifndef __cplusplus /* Ultrix mips cc rejects this. */ typedef int charset[2]; const charset cs; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this. */ char *t; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; }; struct s *b; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_c_const=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 echo "${ECHO_T}$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then cat >>confdefs.h <<\_ACEOF #define const _ACEOF fi { echo "$as_me:$LINENO: checking for inline" >&5 echo $ECHO_N "checking for inline... $ECHO_C" >&6; } if test "${ac_cv_c_inline+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifndef __cplusplus typedef int foo_t; static $ac_kw foo_t static_foo () {return 0; } $ac_kw foo_t foo () {return 0; } #endif _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_c_inline=$ac_kw else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test "$ac_cv_c_inline" != no && break done fi { echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5 echo "${ECHO_T}$ac_cv_c_inline" >&6; } case $ac_cv_c_inline in inline | yes) ;; *) case $ac_cv_c_inline in no) ac_val=;; *) ac_val=$ac_cv_c_inline;; esac cat >>confdefs.h <<_ACEOF #ifndef __cplusplus #define inline $ac_val #endif _ACEOF ;; esac { echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6; } if test "${ac_cv_c_bigendian+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # See if sys/param.h defines the BYTE_ORDER macro. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN && defined LITTLE_ENDIAN \ && BYTE_ORDER && BIG_ENDIAN && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then # It does; now see whether it defined to BIG_ENDIAN or not. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_c_bigendian=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # It does not; compile a test program. if test "$cross_compiling" = yes; then # try to guess the endianness by grepping values into an object file ac_cv_c_bigendian=unknown cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; } int main () { _ascii (); _ebcdic (); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_c_bigendian=no else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 echo "${ECHO_T}$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in yes) cat >>confdefs.h <<\_ACEOF #define WORDS_BIGENDIAN 1 _ACEOF ;; no) ;; *) { { echo "$as_me:$LINENO: error: unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" >&5 echo "$as_me: error: unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" >&2;} { (exit 1); exit 1; }; } ;; esac { echo "$as_me:$LINENO: checking for pid_t" >&5 echo $ECHO_N "checking for pid_t... $ECHO_C" >&6; } if test "${ac_cv_type_pid_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef pid_t ac__type_new_; int main () { if ((ac__type_new_ *) 0) return 0; if (sizeof (ac__type_new_)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_type_pid_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_pid_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_type_pid_t" >&5 echo "${ECHO_T}$ac_cv_type_pid_t" >&6; } if test $ac_cv_type_pid_t = yes; then : else cat >>confdefs.h <<_ACEOF #define pid_t int _ACEOF fi { echo "$as_me:$LINENO: checking for size_t" >&5 echo $ECHO_N "checking for size_t... $ECHO_C" >&6; } if test "${ac_cv_type_size_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef size_t ac__type_new_; int main () { if ((ac__type_new_ *) 0) return 0; if (sizeof (ac__type_new_)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_type_size_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_size_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 echo "${ECHO_T}$ac_cv_type_size_t" >&6; } if test $ac_cv_type_size_t = yes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi { echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5 echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6; } if test "${ac_cv_header_time+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_header_time=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5 echo "${ECHO_T}$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then cat >>confdefs.h <<\_ACEOF #define TIME_WITH_SYS_TIME 1 _ACEOF fi # Checks for library functions. { echo "$as_me:$LINENO: checking for error_at_line" >&5 echo $ECHO_N "checking for error_at_line... $ECHO_C" >&6; } if test "${ac_cv_lib_error_at_line+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include int main () { error_at_line (0, 0, "", 0, "an error occurred"); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_error_at_line=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_error_at_line=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_lib_error_at_line" >&5 echo "${ECHO_T}$ac_cv_lib_error_at_line" >&6; } if test $ac_cv_lib_error_at_line = no; then case " $LIBOBJS " in *" error.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS error.$ac_objext" ;; esac fi for ac_header in stdlib.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## ------------------------------- ## ## Report this to mike@borella.net ## ## ------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { echo "$as_me:$LINENO: checking for GNU libc compatible malloc" >&5 echo $ECHO_N "checking for GNU libc compatible malloc... $ECHO_C" >&6; } if test "${ac_cv_func_malloc_0_nonnull+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then ac_cv_func_malloc_0_nonnull=no else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #if defined STDC_HEADERS || defined HAVE_STDLIB_H # include #else char *malloc (); #endif int main () { return ! malloc (0); ; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_malloc_0_nonnull=yes else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_malloc_0_nonnull=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi { echo "$as_me:$LINENO: result: $ac_cv_func_malloc_0_nonnull" >&5 echo "${ECHO_T}$ac_cv_func_malloc_0_nonnull" >&6; } if test $ac_cv_func_malloc_0_nonnull = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_MALLOC 1 _ACEOF else cat >>confdefs.h <<\_ACEOF #define HAVE_MALLOC 0 _ACEOF case " $LIBOBJS " in *" malloc.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS malloc.$ac_objext" ;; esac cat >>confdefs.h <<\_ACEOF #define malloc rpl_malloc _ACEOF fi for ac_header in stdlib.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## ------------------------------- ## ## Report this to mike@borella.net ## ## ------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { echo "$as_me:$LINENO: checking for GNU libc compatible realloc" >&5 echo $ECHO_N "checking for GNU libc compatible realloc... $ECHO_C" >&6; } if test "${ac_cv_func_realloc_0_nonnull+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then ac_cv_func_realloc_0_nonnull=no else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #if defined STDC_HEADERS || defined HAVE_STDLIB_H # include #else char *realloc (); #endif int main () { return ! realloc (0, 0); ; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_realloc_0_nonnull=yes else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_realloc_0_nonnull=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi { echo "$as_me:$LINENO: result: $ac_cv_func_realloc_0_nonnull" >&5 echo "${ECHO_T}$ac_cv_func_realloc_0_nonnull" >&6; } if test $ac_cv_func_realloc_0_nonnull = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_REALLOC 1 _ACEOF else cat >>confdefs.h <<\_ACEOF #define HAVE_REALLOC 0 _ACEOF case " $LIBOBJS " in *" realloc.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS realloc.$ac_objext" ;; esac cat >>confdefs.h <<\_ACEOF #define realloc rpl_realloc _ACEOF fi { echo "$as_me:$LINENO: checking for function prototypes" >&5 echo $ECHO_N "checking for function prototypes... $ECHO_C" >&6; } if test "$ac_cv_prog_cc_c89" != no; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } cat >>confdefs.h <<\_ACEOF #define PROTOTYPES 1 _ACEOF cat >>confdefs.h <<\_ACEOF #define __PROTOTYPES 1 _ACEOF else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi { echo "$as_me:$LINENO: checking whether setvbuf arguments are reversed" >&5 echo $ECHO_N "checking whether setvbuf arguments are reversed... $ECHO_C" >&6; } if test "${ac_cv_func_setvbuf_reversed+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_func_setvbuf_reversed=no cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include # ifdef PROTOTYPES int (setvbuf) (FILE *, int, char *, size_t); # endif int main () { char buf; return setvbuf (stdout, _IOLBF, &buf, 1); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include # ifdef PROTOTYPES int (setvbuf) (FILE *, int, char *, size_t); # endif int main () { char buf; return setvbuf (stdout, &buf, _IOLBF, 1); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then # It compiles and links either way, so it must not be declared # with a prototype and most likely this is a K&R C compiler. # Try running it. if test "$cross_compiling" = yes; then : # Assume setvbuf is not reversed when cross-compiling. else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { /* This call has the arguments reversed. A reversed system may check and see that the address of buf is not _IOLBF, _IONBF, or _IOFBF, and return nonzero. */ char buf; if (setvbuf (stdout, _IOLBF, &buf, 1) != 0) return 1; putchar ('\r'); return 0; /* Non-reversed systems SEGV here. */ ; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_setvbuf_reversed=yes else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi ac_cv_func_setvbuf_reversed=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_func_setvbuf_reversed" >&5 echo "${ECHO_T}$ac_cv_func_setvbuf_reversed" >&6; } if test $ac_cv_func_setvbuf_reversed = yes; then cat >>confdefs.h <<\_ACEOF #define SETVBUF_REVERSED 1 _ACEOF fi { echo "$as_me:$LINENO: checking return type of signal handlers" >&5 echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6; } if test "${ac_cv_type_signal+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { return *(signal (0, 0)) (0) == 1; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_type_signal=int else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_signal=void fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5 echo "${ECHO_T}$ac_cv_type_signal" >&6; } cat >>confdefs.h <<_ACEOF #define RETSIGTYPE $ac_cv_type_signal _ACEOF for ac_func in vprintf do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$ac_func || defined __stub___$ac_func choke me #endif int main () { return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF { echo "$as_me:$LINENO: checking for _doprnt" >&5 echo $ECHO_N "checking for _doprnt... $ECHO_C" >&6; } if test "${ac_cv_func__doprnt+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define _doprnt to an innocuous variant, in case declares _doprnt. For example, HP-UX 11i declares gettimeofday. */ #define _doprnt innocuous__doprnt /* System header to define __stub macros and hopefully few prototypes, which can conflict with char _doprnt (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef _doprnt /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char _doprnt (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub__doprnt || defined __stub____doprnt choke me #endif int main () { return _doprnt (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_func__doprnt=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func__doprnt=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_func__doprnt" >&5 echo "${ECHO_T}$ac_cv_func__doprnt" >&6; } if test $ac_cv_func__doprnt = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_DOPRNT 1 _ACEOF fi fi done for ac_func in gettimeofday inet_ntoa memset strchr strdup strerror strstr do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$ac_func || defined __stub___$ac_func choke me #endif int main () { return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done ac_config_files="$ac_config_files Makefile doc/Makefile src/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( *) $as_unset $ac_var ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then test "x$cache_file" != "x/dev/null" && { echo "$as_me:$LINENO: updating cache $cache_file" >&5 echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." >&5 echo "$as_me: error: conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." >&5 echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi : ${CONFIG_STATUS=./config.status} ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >$CONFIG_STATUS <<_ACEOF #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi # PATH needs CR # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) as_nl=' ' IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 { (exit 1); exit 1; } fi # Work around bugs in pre-3.0 UWIN ksh. for as_var in ENV MAIL MAILPATH do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var fi done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # CDPATH. $as_unset CDPATH as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line after each line using $LINENO; the second 'sed' # does the real work. The second script uses 'N' to pair each # line-number line with the line containing $LINENO, and appends # trailing '-' during substitution so that $LINENO is not a special # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # scripts with optimization help from Paolo Bonzini. Blame Lee # E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in -n*) case `echo 'x\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. *) ECHO_C='\c';; esac;; *) ECHO_N='-n';; esac if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir fi echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 # Save the log message, to keep $[0] and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by ipgrab $as_me 0.9.10, which was generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF cat >>$CONFIG_STATUS <<_ACEOF # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ ipgrab config.status 0.9.10 configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" Copyright (C) 2006 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # If no file are specified by the user, then we need to provide default # value. By we need to know if files were specified by the user. ac_need_defaults=: while test $# != 0 do case $1 in --*=*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) echo "$ac_cs_version"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift CONFIG_FILES="$CONFIG_FILES $ac_optarg" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header { echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; };; --help | --hel | -h ) echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) { echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *) ac_config_targets="$ac_config_targets $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF if \$ac_cs_recheck; then echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 CONFIG_SHELL=$SHELL export CONFIG_SHELL exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= trap 'exit_status=$? { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || { echo "$me: cannot create a temporary directory in ." >&2 { (exit 1); exit 1; } } # # Set up the sed scripts for CONFIG_FILES section. # # No need to generate the scripts if there are no CONFIG_FILES. # This happens for instance when ./config.status config.h if test -n "$CONFIG_FILES"; then _ACEOF ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF SHELL!$SHELL$ac_delim PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim PACKAGE_NAME!$PACKAGE_NAME$ac_delim PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim PACKAGE_STRING!$PACKAGE_STRING$ac_delim PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim exec_prefix!$exec_prefix$ac_delim prefix!$prefix$ac_delim program_transform_name!$program_transform_name$ac_delim bindir!$bindir$ac_delim sbindir!$sbindir$ac_delim libexecdir!$libexecdir$ac_delim datarootdir!$datarootdir$ac_delim datadir!$datadir$ac_delim sysconfdir!$sysconfdir$ac_delim sharedstatedir!$sharedstatedir$ac_delim localstatedir!$localstatedir$ac_delim includedir!$includedir$ac_delim oldincludedir!$oldincludedir$ac_delim docdir!$docdir$ac_delim infodir!$infodir$ac_delim htmldir!$htmldir$ac_delim dvidir!$dvidir$ac_delim pdfdir!$pdfdir$ac_delim psdir!$psdir$ac_delim libdir!$libdir$ac_delim localedir!$localedir$ac_delim mandir!$mandir$ac_delim DEFS!$DEFS$ac_delim ECHO_C!$ECHO_C$ac_delim ECHO_N!$ECHO_N$ac_delim ECHO_T!$ECHO_T$ac_delim LIBS!$LIBS$ac_delim build_alias!$build_alias$ac_delim host_alias!$host_alias$ac_delim target_alias!$target_alias$ac_delim INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim INSTALL_DATA!$INSTALL_DATA$ac_delim CYGPATH_W!$CYGPATH_W$ac_delim PACKAGE!$PACKAGE$ac_delim VERSION!$VERSION$ac_delim ACLOCAL!$ACLOCAL$ac_delim AUTOCONF!$AUTOCONF$ac_delim AUTOMAKE!$AUTOMAKE$ac_delim AUTOHEADER!$AUTOHEADER$ac_delim MAKEINFO!$MAKEINFO$ac_delim install_sh!$install_sh$ac_delim STRIP!$STRIP$ac_delim INSTALL_STRIP_PROGRAM!$INSTALL_STRIP_PROGRAM$ac_delim mkdir_p!$mkdir_p$ac_delim AWK!$AWK$ac_delim SET_MAKE!$SET_MAKE$ac_delim am__leading_dot!$am__leading_dot$ac_delim AMTAR!$AMTAR$ac_delim am__tar!$am__tar$ac_delim am__untar!$am__untar$ac_delim CC!$CC$ac_delim CFLAGS!$CFLAGS$ac_delim LDFLAGS!$LDFLAGS$ac_delim CPPFLAGS!$CPPFLAGS$ac_delim ac_ct_CC!$ac_ct_CC$ac_delim EXEEXT!$EXEEXT$ac_delim OBJEXT!$OBJEXT$ac_delim DEPDIR!$DEPDIR$ac_delim am__include!$am__include$ac_delim am__quote!$am__quote$ac_delim AMDEP_TRUE!$AMDEP_TRUE$ac_delim AMDEP_FALSE!$AMDEP_FALSE$ac_delim AMDEPBACKSLASH!$AMDEPBACKSLASH$ac_delim CCDEPMODE!$CCDEPMODE$ac_delim am__fastdepCC_TRUE!$am__fastdepCC_TRUE$ac_delim am__fastdepCC_FALSE!$am__fastdepCC_FALSE$ac_delim CPP!$CPP$ac_delim GREP!$GREP$ac_delim EGREP!$EGREP$ac_delim LIBOBJS!$LIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 79; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} { (exit 1); exit 1; }; } else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` if test -n "$ac_eof"; then ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` ac_eof=`expr $ac_eof + 1` fi cat >>$CONFIG_STATUS <<_ACEOF cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof /@[a-zA-Z_][a-zA-Z_0-9]*@/!b end _ACEOF sed ' s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g s/^/s,@/; s/!/@,|#_!!_#|/ :n t n s/'"$ac_delim"'$/,g/; t s/$/\\/; p N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n ' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF :end s/|#_!!_#|//g CEOF$ac_eof _ACEOF # VPATH may cause trouble with some makes, so we remove $(srcdir), # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=/{ s/:*\$(srcdir):*/:/ s/:*\${srcdir}:*/:/ s/:*@srcdir@:*/:/ s/^\([^=]*=[ ]*\):*/\1/ s/:*$// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF fi # test -n "$CONFIG_FILES" for ac_tag in :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 echo "$as_me: error: Invalid tag $ac_tag." >&2;} { (exit 1); exit 1; }; };; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 echo "$as_me: error: cannot find input file: $ac_f" >&2;} { (exit 1); exit 1; }; };; esac ac_file_inputs="$ac_file_inputs $ac_f" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input="Generated from "`IFS=: echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { echo "$as_me:$LINENO: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} fi case $ac_tag in *:-:* | *:-) cat >"$tmp/stdin";; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` { as_dir="$ac_dir" case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 echo "$as_me: error: cannot create directory $as_dir" >&2;} { (exit 1); exit 1; }; }; } ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= case `sed -n '/datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p ' $ac_file_inputs` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s&@configure_input@&$configure_input&;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t $ac_datarootdir_hack " $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&5 echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&2;} rm -f "$tmp/stdin" case $ac_file in -) cat "$tmp/out"; rm -f "$tmp/out";; *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; esac ;; :H) # # CONFIG_HEADER # _ACEOF # Transform confdefs.h into a sed script `conftest.defines', that # substitutes the proper values into config.h.in to produce config.h. rm -f conftest.defines conftest.tail # First, append a space to every undef/define line, to ease matching. echo 's/$/ /' >conftest.defines # Then, protect against being on the right side of a sed subst, or in # an unquoted here document, in config.status. If some macros were # called several times there might be several #defines for the same # symbol, which is useless. But do not sort them, since the last # AC_DEFINE must be honored. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* # These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where # NAME is the cpp macro being defined, VALUE is the value it is being given. # PARAMS is the parameter list in the macro definition--in most cases, it's # just an empty string. ac_dA='s,^\\([ #]*\\)[^ ]*\\([ ]*' ac_dB='\\)[ (].*,\\1define\\2' ac_dC=' ' ac_dD=' ,' uniq confdefs.h | sed -n ' t rset :rset s/^[ ]*#[ ]*define[ ][ ]*// t ok d :ok s/[\\&,]/\\&/g s/^\('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p s/^\('"$ac_word_re"'\)[ ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p ' >>conftest.defines # Remove the space that was appended to ease matching. # Then replace #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. # (The regexp can be short, since the line contains either #define or #undef.) echo 's/ $// s,^[ #]*u.*,/* & */,' >>conftest.defines # Break up conftest.defines: ac_max_sed_lines=50 # First sed command is: sed -f defines.sed $ac_file_inputs >"$tmp/out1" # Second one is: sed -f defines.sed "$tmp/out1" >"$tmp/out2" # Third one will be: sed -f defines.sed "$tmp/out2" >"$tmp/out1" # et cetera. ac_in='$ac_file_inputs' ac_out='"$tmp/out1"' ac_nxt='"$tmp/out2"' while : do # Write a here document: cat >>$CONFIG_STATUS <<_ACEOF # First, check the format of the line: cat >"\$tmp/defines.sed" <<\\CEOF /^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*\$/b def /^[ ]*#[ ]*define[ ][ ]*$ac_word_re[( ]/b def b :def _ACEOF sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS echo 'CEOF sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail grep . conftest.tail >/dev/null || break rm -f conftest.defines mv conftest.tail conftest.defines done rm -f conftest.defines conftest.tail echo "ac_result=$ac_in" >>$CONFIG_STATUS cat >>$CONFIG_STATUS <<\_ACEOF if test x"$ac_file" != x-; then echo "/* $configure_input */" >"$tmp/config.h" cat "$ac_result" >>"$tmp/config.h" if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else rm -f $ac_file mv "$tmp/config.h" $ac_file fi else echo "/* $configure_input */" cat "$ac_result" fi rm -f "$tmp/out12" # Compute $ac_file's index in $config_headers. _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $ac_file | $ac_file:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $ac_file" >`$as_dirname -- $ac_file || $as_expr X$ac_file : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X$ac_file : 'X\(//\)[^/]' \| \ X$ac_file : 'X\(//\)$' \| \ X$ac_file : 'X\(/\)' \| . 2>/dev/null || echo X$ac_file | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { echo "$as_me:$LINENO: executing $ac_file commands" >&5 echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # So let's grep whole file. if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` { as_dir=$dirpart/$fdir case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 echo "$as_me: error: cannot create directory $as_dir" >&2;} { (exit 1); exit 1; }; }; } # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done ;; esac done # for ac_tag { (exit 0); exit 0; } _ACEOF chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || { (exit 1); exit 1; } fi ipgrab-0.9.10/configure.ac0000644000175000001440000000206310640141751014541 0ustar farooqusers# -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ(2.57) AC_INIT(ipgrab, 0.9.10, mike@borella.net) AC_CONFIG_SRCDIR(src/ipgrab.c) AM_INIT_AUTOMAKE AC_CONFIG_HEADER([config.h]) # Checks for programs. AC_PROG_CC # Checks for libraries. AC_CHECK_LIB(intl, main) MD_PATH(libpcap, pcap.h, pcap, pcap_close) # Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS([arpa/inet.h libintl.h netinet/in.h stdlib.h string.h strings.h sys/socket.h unistd.h stdarg.h signal.h sys/types.h ctype.h getopt.h]) # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL AC_C_CONST AC_C_INLINE AC_C_BIGENDIAN AC_TYPE_PID_T AC_TYPE_SIZE_T AC_HEADER_TIME # Checks for library functions. AC_FUNC_ERROR_AT_LINE AC_FUNC_MALLOC AC_FUNC_REALLOC AC_FUNC_SETVBUF_REVERSED AC_TYPE_SIGNAL AC_FUNC_VPRINTF AC_CHECK_FUNCS([gettimeofday inet_ntoa memset strchr strdup strerror strstr]) AC_CONFIG_FILES([Makefile doc/Makefile src/Makefile]) AC_OUTPUT ipgrab-0.9.10/depcomp0000644000175000001440000003305210530550304013623 0ustar farooqusers#! /bin/sh # depcomp - compile a program generating dependencies as side-effects # Copyright 1999, 2000, 2003 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # `libtool' can also be set to `yes' or `no'. if test -z "$depfile"; then base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'` dir=`echo "$object" | sed 's,/.*$,/,'` if test "$dir" = "$object"; then dir= fi # FIXME: should be _deps on DOS. depfile="$dir.deps/$base" fi tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ## The second -e expression handles DOS-style file names with drive letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the `deleted header file' problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. tr ' ' ' ' < "$tmpdepfile" | ## Some versions of gcc put a space before the `:'. On the theory ## that the space means something, we add a space to the output as ## well. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like `#:fec' to the end of the # dependency line. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ tr ' ' ' ' >> $depfile echo >> $depfile # The second pass generates a dummy entry for each header file. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> $depfile else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts `$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` tmpdepfile="$stripped.u" if test "$libtool" = yes; then "$@" -Wc,-M else "$@" -M fi stat=$? if test -f "$tmpdepfile"; then : else stripped=`echo "$stripped" | sed 's,^.*/,,'` tmpdepfile="$stripped.u" fi if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi if test -f "$tmpdepfile"; then outname="$stripped.o" # Each line is of the form `foo.o: dependent.h'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; icc) # Intel's C compiler understands `-MD -MF file'. However on # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c # ICC 7.0 will fill foo.d with something like # foo.o: sub/foo.c # foo.o: sub/foo.h # which is wrong. We want: # sub/foo.o: sub/foo.c # sub/foo.o: sub/foo.h # sub/foo.c: # sub/foo.h: # ICC 7.1 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using \ : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in `foo.d' instead, so we check for that too. # Subdirectories are respected. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1="$dir.libs/$base.lo.d" tmpdepfile2="$dir.libs/$base.d" "$@" -Wc,-MD else tmpdepfile1="$dir$base.o.d" tmpdepfile2="$dir$base.d" "$@" -MD fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi if test -f "$tmpdepfile1"; then tmpdepfile="$tmpdepfile1" else tmpdepfile="$tmpdepfile2" fi if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test $1 != '--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for `:' # in the target name. This is to cope with DOS-style filenames: # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. "$@" $dashmflag | sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' ' ' < "$tmpdepfile" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test $1 != '--mode=compile'; do shift done shift fi # X makedepend shift cleared=no for arg in "$@"; do case $cleared in no) set ""; shift cleared=yes ;; esac case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix="`echo $object | sed 's/^.*\././'`" touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" sed '1,2d' "$tmpdepfile" | tr ' ' ' ' | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test $1 != '--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E | sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o, # because we must use -o when running libtool. "$@" || exit $? IFS=" " for arg do case "$arg" in "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" echo " " >> "$depfile" . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 ipgrab-0.9.10/install-sh0000755000175000001440000001572210530550304014261 0ustar farooqusers#!/bin/sh # # install - install a program, script, or datafile # # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd=$cpprog shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd=$stripprog shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "$0: no input file specified" >&2 exit 1 else : fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d "$dst" ]; then instcmd=: chmodcmd="" else instcmd=$mkdirprog fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f "$src" ] || [ -d "$src" ] then : else echo "$0: $src does not exist" >&2 exit 1 fi if [ x"$dst" = x ] then echo "$0: no destination specified" >&2 exit 1 else : fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d "$dst" ] then dst=$dst/`basename "$src"` else : fi fi ## this sed command emulates the dirname command dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-$defaultIFS}" oIFS=$IFS # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` IFS=$oIFS pathcomp='' while [ $# -ne 0 ] ; do pathcomp=$pathcomp$1 shift if [ ! -d "$pathcomp" ] ; then $mkdirprog "$pathcomp" else : fi pathcomp=$pathcomp/ done fi if [ x"$dir_arg" != x ] then $doit $instcmd "$dst" && if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename "$dst"` else dstfile=`basename "$dst" $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename "$dst"` else : fi # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up temp files at exit. trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0 trap '(exit $?); exit' 1 2 13 15 # Move or copy the file name to the temp name $doit $instcmd "$src" "$dsttmp" && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi && # Now remove or move aside any old file at destination location. We try this # two ways since rm can't unlink itself on some systems and the destination # file might be busy for other reasons. In this case, the final cleanup # might fail but the new file should still install successfully. { if [ -f "$dstdir/$dstfile" ] then $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null || { echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 (exit 1); exit } else : fi } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" fi && # The final little trick to "correctly" pass the exit status to the exit trap. { (exit 0); exit } ipgrab-0.9.10/missing0000755000175000001440000002403210530550304013646 0ustar farooqusers#! /bin/sh # Common stub for a few missing GNU programs while installing. # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003 Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi case "$1" in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case "$1" in -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file tar try tar, gnutar, gtar, then tar without non-portable flags yacc create \`y.tab.[ch]', if possible, from existing .[ch]" ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing 0.4 - GNU automake" ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; aclocal*) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case "$f" in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake*) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; autom4te) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is needed, and you do not seem to have it handy on your system. You might have modified some files without having the proper tools for further handling them. You can get \`$1' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo "#! /bin/sh" echo "# Created by GNU Automake missing as a replacement of" echo "# $ $@" echo "exit 0" chmod +x $file exit 1 fi ;; bison|yacc) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.h fi ;; esac fi if [ ! -f y.tab.h ]; then echo >y.tab.h fi if [ ! -f y.tab.c ]; then echo 'main() { return 0; }' >y.tab.c fi ;; lex|flex) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if [ ! -f lex.yy.c ]; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` fi if [ -f "$file" ]; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit 1 fi ;; makeinfo) if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then # We have makeinfo, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` fi touch $file ;; tar) shift if test -n "$run"; then echo 1>&2 "ERROR: \`tar' requires --run" exit 1 fi # We have already tried tar in the generic part. # Look for gnutar/gtar before invocation to avoid ugly error # messages. if (gnutar --version > /dev/null 2>&1); then gnutar "$@" && exit 0 fi if (gtar --version > /dev/null 2>&1); then gtar "$@" && exit 0 fi firstarg="$1" if shift; then case "$firstarg" in *o*) firstarg=`echo "$firstarg" | sed s/o//` tar "$firstarg" "$@" && exit 0 ;; esac case "$firstarg" in *h*) firstarg=`echo "$firstarg" | sed s/h//` tar "$firstarg" "$@" && exit 0 ;; esac fi echo 1>&2 "\ WARNING: I can't seem to be able to run \`tar' with the given arguments. You may want to install GNU tar or Free paxutils, or check the command line arguments." exit 1 ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and you do not seem to have it handy on your system. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequisites for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 ipgrab-0.9.10/mkinstalldirs0000755000175000001440000000370410530550304015060 0ustar farooqusers#! /bin/sh # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman # Created: 1993-05-16 # Public domain errstatus=0 dirmode="" usage="\ Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..." # process command line arguments while test $# -gt 0 ; do case $1 in -h | --help | --h*) # -h for help echo "$usage" 1>&2 exit 0 ;; -m) # -m PERM arg shift test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } dirmode=$1 shift ;; --) # stop option processing shift break ;; -*) # unknown option echo "$usage" 1>&2 exit 1 ;; *) # first non-opt arg break ;; esac done for file do if test -d "$file"; then shift else break fi done case $# in 0) exit 0 ;; esac case $dirmode in '') if mkdir -p -- . 2>/dev/null; then echo "mkdir -p -- $*" exec mkdir -p -- "$@" fi ;; *) if mkdir -m "$dirmode" -p -- . 2>/dev/null; then echo "mkdir -m $dirmode -p -- $*" exec mkdir -m "$dirmode" -p -- "$@" fi ;; esac for file do set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` shift pathcomp= for d do pathcomp="$pathcomp$d" case $pathcomp in -*) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr else if test ! -z "$dirmode"; then echo "chmod $dirmode $pathcomp" lasterr="" chmod "$dirmode" "$pathcomp" || lasterr=$? if test ! -z "$lasterr"; then errstatus=$lasterr fi fi fi fi pathcomp="$pathcomp/" done done exit $errstatus # Local Variables: # mode: shell-script # sh-indentation: 2 # End: # mkinstalldirs ends here ipgrab-0.9.10/src/0000755000175000001440000000000010644764351013054 5ustar farooqusersipgrab-0.9.10/src/Makefile.am0000644000175000001440000000264010530527425015103 0ustar farooqusersAM_CFLAGS = -Wall -Wstrict-prototypes -Wformat INCLUDES = -I/usr/local/include bin_PROGRAMS = ipgrab ipgrab_SOURCES = ah.h ah.c arp.h arp.c cbcp.h cbcp.c ccp.h ccp.c chap.h chap.c datalink.h datalink.c dhcp.h dhcp.c display.h display.c dns.h dns.c dynports.h dynports.c error.h error.c esp.h esp.c ethernet.h ethernet.c ethertypes.h ethertypes.c file.h file.c ftpctrl.h ftpctrl.c getopt.h getopt.c global.h gre.h gre.c hexbuffer.h hexbuffer.c http.h http.c iana.h iana.c icmp.h icmp.c icmpv6.h icmpv6.c igmp.h igmp.c ip.h ip.c ip_protocols.h ip_protocols.c ip_services.h ip_services.c ipcp.h ipcp.c ipgrab.h ipgrab.c ipv6.h ipv6.c ipx.h ipx.c ipxrip.h ipxrip.c isakmp.h isakmp.c l2tp.h l2tp.c layers.h layers.c lcp.h lcp.c llc.h llc.c local.h loopback.h loopback.c mgcp.h mgcp.c mobileip.h mobileip.c mppc.h mppc.c netbios_ns.h netbios_ns.c nntp.h nntp.c ns_labels.h ns_labels.c open_pcap.h open_pcap.c ospf.h ospf.c packet_manip.h packet_manip.c padding.h padding.c parse_cl.h parse_cl.c payload.h payload.c ppp.h ppp.c pppoe.h pppoe.c pptp.h pptp.c radius.h radius.c radius_3gpp2.h radius_3gpp2.c raw.h raw.c rip.h rip.c ripng.h ripng.c rsvp.h rsvp.c rtcp.h rtcp.c rtp.h rtp.c sdp.h sdp.c sip.h sip.c slip.h slip.c slp.h slp.c ipgsnmp.h snmp.c spx.h spx.c ssh.h ssh.c state.h state.c stats.h stats.c strmap.h strmap.c tcp.h tcp.c tftp.h tftp.c udp.h udp.c utilities.h utilities.c ipgrab_LDADD = -L/usr/local/lib -lpcap CLEANFILES = *~ ipgrab-0.9.10/src/Makefile.in0000644000175000001440000004741310642170426015122 0ustar farooqusers# Makefile.in generated by automake 1.9.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = .. am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : bin_PROGRAMS = ipgrab$(EXEEXT) subdir = src DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = am__installdirs = "$(DESTDIR)$(bindir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) am_ipgrab_OBJECTS = ah.$(OBJEXT) arp.$(OBJEXT) cbcp.$(OBJEXT) \ ccp.$(OBJEXT) chap.$(OBJEXT) datalink.$(OBJEXT) dhcp.$(OBJEXT) \ display.$(OBJEXT) dns.$(OBJEXT) dynports.$(OBJEXT) \ error.$(OBJEXT) esp.$(OBJEXT) ethernet.$(OBJEXT) \ ethertypes.$(OBJEXT) file.$(OBJEXT) ftpctrl.$(OBJEXT) \ getopt.$(OBJEXT) gre.$(OBJEXT) hexbuffer.$(OBJEXT) \ http.$(OBJEXT) iana.$(OBJEXT) icmp.$(OBJEXT) icmpv6.$(OBJEXT) \ igmp.$(OBJEXT) ip.$(OBJEXT) ip_protocols.$(OBJEXT) \ ip_services.$(OBJEXT) ipcp.$(OBJEXT) ipgrab.$(OBJEXT) \ ipv6.$(OBJEXT) ipx.$(OBJEXT) ipxrip.$(OBJEXT) isakmp.$(OBJEXT) \ l2tp.$(OBJEXT) layers.$(OBJEXT) lcp.$(OBJEXT) llc.$(OBJEXT) \ loopback.$(OBJEXT) mgcp.$(OBJEXT) mobileip.$(OBJEXT) \ mppc.$(OBJEXT) netbios_ns.$(OBJEXT) nntp.$(OBJEXT) \ ns_labels.$(OBJEXT) open_pcap.$(OBJEXT) ospf.$(OBJEXT) \ packet_manip.$(OBJEXT) padding.$(OBJEXT) parse_cl.$(OBJEXT) \ payload.$(OBJEXT) ppp.$(OBJEXT) pppoe.$(OBJEXT) pptp.$(OBJEXT) \ radius.$(OBJEXT) radius_3gpp2.$(OBJEXT) raw.$(OBJEXT) \ rip.$(OBJEXT) ripng.$(OBJEXT) rsvp.$(OBJEXT) rtcp.$(OBJEXT) \ rtp.$(OBJEXT) sdp.$(OBJEXT) sip.$(OBJEXT) slip.$(OBJEXT) \ slp.$(OBJEXT) snmp.$(OBJEXT) spx.$(OBJEXT) ssh.$(OBJEXT) \ state.$(OBJEXT) stats.$(OBJEXT) strmap.$(OBJEXT) tcp.$(OBJEXT) \ tftp.$(OBJEXT) udp.$(OBJEXT) utilities.$(OBJEXT) ipgrab_OBJECTS = $(am_ipgrab_OBJECTS) ipgrab_DEPENDENCIES = DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(ipgrab_SOURCES) DIST_SOURCES = $(ipgrab_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ ac_ct_CC = @ac_ct_CC@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build_alias = @build_alias@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host_alias = @host_alias@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ AM_CFLAGS = -Wall -Wstrict-prototypes -Wformat INCLUDES = -I/usr/local/include ipgrab_SOURCES = ah.h ah.c arp.h arp.c cbcp.h cbcp.c ccp.h ccp.c \ chap.h chap.c datalink.h datalink.c dhcp.h dhcp.c display.h \ display.c dns.h dns.c dynports.h dynports.c error.h error.c \ esp.h esp.c ethernet.h ethernet.c ethertypes.h ethertypes.c \ file.h file.c ftpctrl.h ftpctrl.c getopt.h getopt.c global.h \ gre.h gre.c hexbuffer.h hexbuffer.c http.h http.c iana.h \ iana.c icmp.h icmp.c icmpv6.h icmpv6.c igmp.h igmp.c ip.h ip.c \ ip_protocols.h ip_protocols.c ip_services.h ip_services.c \ ipcp.h ipcp.c ipgrab.h ipgrab.c ipv6.h ipv6.c ipx.h ipx.c \ ipxrip.h ipxrip.c isakmp.h isakmp.c l2tp.h l2tp.c layers.h \ layers.c lcp.h lcp.c llc.h llc.c local.h loopback.h loopback.c \ mgcp.h mgcp.c mobileip.h mobileip.c mppc.h mppc.c netbios_ns.h \ netbios_ns.c nntp.h nntp.c ns_labels.h ns_labels.c open_pcap.h \ open_pcap.c ospf.h ospf.c packet_manip.h packet_manip.c \ padding.h padding.c parse_cl.h parse_cl.c payload.h payload.c \ ppp.h ppp.c pppoe.h pppoe.c pptp.h pptp.c radius.h radius.c \ radius_3gpp2.h radius_3gpp2.c raw.h raw.c rip.h rip.c ripng.h \ ripng.c rsvp.h rsvp.c rtcp.h rtcp.c rtp.h rtp.c sdp.h sdp.c \ sip.h sip.c slip.h slip.c slp.h slp.c ipgsnmp.h snmp.c spx.h \ spx.c ssh.h ssh.c state.h state.c stats.h stats.c strmap.h \ strmap.c tcp.h tcp.c tftp.h tftp.c udp.h udp.c utilities.h \ utilities.c ipgrab_LDADD = -L/usr/local/lib -lpcap CLEANFILES = *~ all: all-am .SUFFIXES: .SUFFIXES: .c .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu src/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; for p in $$list; do \ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ if test -f $$p \ ; then \ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ else :; fi; \ done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; for p in $$list; do \ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ rm -f "$(DESTDIR)$(bindir)/$$f"; \ done clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) ipgrab$(EXEEXT): $(ipgrab_OBJECTS) $(ipgrab_DEPENDENCIES) @rm -f ipgrab$(EXEEXT) $(LINK) $(ipgrab_LDFLAGS) $(ipgrab_OBJECTS) $(ipgrab_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ah.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cbcp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ccp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/datalink.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dhcp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/display.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dns.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynports.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/esp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ethernet.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ethertypes.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftpctrl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gre.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hexbuffer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/http.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iana.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/icmp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/icmpv6.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/igmp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ip.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ip_protocols.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ip_services.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ipcp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ipgrab.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ipv6.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ipx.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ipxrip.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/isakmp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/l2tp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/layers.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lcp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/llc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loopback.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mgcp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mobileip.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mppc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netbios_ns.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nntp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ns_labels.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/open_pcap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ospf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/packet_manip.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/padding.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse_cl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/payload.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pppoe.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pptp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/radius.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/radius_3gpp2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/raw.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rip.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ripng.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rsvp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rtcp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rtp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sdp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sip.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slip.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/snmp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spx.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssh.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/state.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stats.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strmap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tftp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/udp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utilities.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` uninstall-info-am: ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ list='$(DISTFILES)'; for file in $$list; do \ case $$file in \ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ esac; \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ if test "$$dir" != "$$file" && test "$$dir" != "."; then \ dir="/$$dir"; \ $(mkdir_p) "$(distdir)$$dir"; \ else \ dir=''; \ fi; \ if test -d $$d/$$file; then \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(mkdir_p) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-exec-am: install-binPROGRAMS install-info: install-info-am install-man: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-info-am .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-exec install-exec-am \ install-info install-info-am install-man install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-binPROGRAMS uninstall-info-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ipgrab-0.9.10/src/ah.c0000644000175000001440000000573607414717761013627 0ustar farooqusers/**************************************************************************** ** File: ah.c ** ** Author: Mike Borella ** ** Dump AH payload ** ** $Id: ah.c,v 1.10 2002/01/03 00:04:01 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "ah.h" #include "ip_protocols.h" #define HOLDER_SIZE 256 extern struct arg_t *my_args; extern strmap_t ipproto_map[]; extern void (*ip_proto_func[])(packet_t *); /*---------------------------------------------------------------------------- ** ** dump_ah() ** ** Parse AH packet and dump fields. ** **---------------------------------------------------------------------------- */ void dump_ah(packet_t *pkt) { ah_header_t ah; char holder[HOLDER_SIZE]; u_int16_t ad_length; u_int8_t len; u_int8_t next; u_int16_t reserved; /* Set the layer */ set_layer(LAYER_NETWORK); /* * Stats accounting */ stats_update(STATS_AH); /* * Get the AH header */ if (get_packet_bytes((u_int8_t *) &ah, pkt, 12) == 0) return; /* * Conversions */ len = ah.length; next = ah.next; reserved = ah.reserved; ah.spi = ntohl(ah.spi); ah.seqno = ntohl(ah.seqno); /* * Figure out length of authentication data, hoping its not too big... */ ad_length = len * 4 - 12; if (get_packet_bytes((u_int8_t *) &holder, pkt, ad_length) == 0) return; /* * Dump header */ if (my_args->m && !my_args->n) { display_minimal_string("| AH "); display_minimal((u_int8_t *) &ah.spi, 4, DISP_HEX); display_minimal_string(" "); } else if (!my_args->n) { /* announcement */ display_header_banner("Authentication Header"); /* print fields */ snprintf(holder, HOLDER_SIZE, "%d (%s)", next, map2str(ipproto_map, next)); display("Next header", holder, strlen(holder), DISP_STRING); display("Reseerved", (u_int8_t *) &reserved, 2, DISP_DEC); display("Header length", (u_int8_t *) &len, 1, DISP_DEC); display("SPI", (u_int8_t *) &ah.spi, 4, DISP_HEX); display("Sequence number", (u_int8_t *) &ah.seqno, 4, DISP_DEC); } /* * Figure out the next header */ if (ip_proto_func[ah.next]) ip_proto_func[ah.next](pkt); } ipgrab-0.9.10/src/ah.h0000644000175000001440000000257410637733536013630 0ustar farooqusers/**************************************************************************** ** File: ah.h ** ** Author: Mike Borella ** ** Comments: Structure of AH packets ** ** $Id: ah.h,v 1.5 2007/06/25 12:38:54 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef AH_H #define AH_H #include "global.h" #include "local.h" /* * Static part of AH header */ typedef struct ah_header { #if defined(WORDS_BIGENDIAN) u_int32_t next:8, length:8, reserved:16; #else u_int32_t reserved:16, length:8, next:8; #endif u_int32_t spi; u_int32_t seqno; } ah_header_t; void dump_ah(packet_t *); #endif ipgrab-0.9.10/src/arp.c0000644000175000001440000001221610637724731014004 0ustar farooqusers/**************************************************************************** ** File: arp.c ** ** Author: Mike Borella ** ** Comments: Dump ARP / RARP header information ** ** $Id: arp.c,v 1.21 2007/06/25 11:41:13 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** *****************************************************************************/ #include "arp.h" #include "ethertypes.h" #define ARP_PADDING_SIZE 18 /* bytes to pad ARP to the min eth frame len */ /* * ARP opcode map */ strmap_t arp_opcode_map[] = { { ARP_OPCODE_REQUEST, "request" }, { ARP_OPCODE_REPLY, "reply" }, { RARP_OPCODE_REQUEST, "RARP request" }, { RARP_OPCODE_REPLY, "RARP reply" }, { 0, "" } }; /* * ARP hardware map */ strmap_t arp_hardware_map[] = { { ARP_HWTYPE_ETHERNET, "Ethernet" }, { ARP_HWTYPE_IEEE802, "IEEE 802" }, { ARP_HWTYPE_IEEE1394, "IEEE 1394" }, { 0, "" } }; extern strmap_t ethertype_map[]; extern struct arg_t *my_args; /*---------------------------------------------------------------------------- ** ** dump_etherarp() ** ** Parse Ethernet-specifc parts of ARP messages ** **---------------------------------------------------------------------------- */ void dump_etherarp(packet_t *pkt) { ether_arp_t etharp; /* * Get the Ethernet section */ if (get_packet_bytes((u_int8_t *) ðarp, pkt, 20) == 0) return; /* * Do minimal or not-so-minimal mode */ if (my_args->m) { display_minimal_ipv4((u_int8_t *) ðarp.target_protoaddr); } else { display("Sender Ether address", (u_int8_t *) ðarp.sender_hwaddr, 6, DISP_HEXCOLONS); display_ipv4("Sender IP address", (u_int8_t *) ðarp.sender_protoaddr); display("Target Ether address", (u_int8_t *) ðarp.target_hwaddr, 6, DISP_HEXCOLONS); display_ipv4("Target IP address", (u_int8_t *) ðarp.target_protoaddr); } /* * Some ARPs include Ethernet frame padding. Check for that. Note that we * must allow ARP frames to be 1500 bytes. Some NICs seems to generate * them as such. Strange but true. In any case, we set the apparent end * of the packet to be at the place where we stop processing legit ARP * bytes, and if padding is turned on, you'll see the rest of the bytes. */ if (!my_args->m) { int bytes; bytes = get_packet_apparentbytesleft(pkt); if (bytes > 0) set_packet_apparentend(pkt, 0); } } /*---------------------------------------------------------------------------- ** ** dump_arp() ** ** Parse ARP header and dump fields ** **---------------------------------------------------------------------------- */ void dump_arp(packet_t *pkt) { arp_header_t arp; /* Set the layer */ set_layer(LAYER_DATALINK); /* * Stats accounting */ stats_update(STATS_ARP); /* * Get the ARP fixed header */ if (get_packet_bytes((u_int8_t *) &arp, pkt, 8) == 0) return; /* * Conversions */ arp.hwaddr_format = ntohs(arp.hwaddr_format); arp.protoaddr_format = ntohs(arp.protoaddr_format); arp.opcode = ntohs(arp.opcode); /* * Check for minimal mode first */ if (my_args->m) { display_minimal_string("| ARP "); display_minimal_string(map2str(arp_opcode_map, arp.opcode)); display_minimal_string(" "); } else { /* * Banner announcement */ display_header_banner("ARP Header"); /* * Dump hardware type */ display_strmap_hex("Hardware type", arp.hwaddr_format, arp_hardware_map); /* * Dump protocol type */ display_strmap_hex("Protocol type", arp.protoaddr_format, ethertype_map); /* * Dump hardware and protocol lengths */ display("Hardware length", (u_int8_t *) &arp.hwaddr_length, 1, DISP_DEC); display("Protocol length", (u_int8_t *) &arp.protoaddr_length, 1, DISP_DEC); /* * Now do the opcode */ display_strmap("Opcode", arp.opcode, arp_opcode_map); } /* * Check hardware type and layer 3 address format */ switch(arp.hwaddr_format) { case ARP_HWTYPE_ETHERNET: case ARP_HWTYPE_IEEE802: switch(arp.protoaddr_format) { case ETHERTYPE_IP: dump_etherarp(pkt); break; default: break; } /* inner switch */ default: break; } /* outer switch */ /* dump the hex buffer */ hexbuffer_flush(); } ipgrab-0.9.10/src/arp.h0000644000175000001440000000463507153266450014015 0ustar farooqusers/**************************************************************************** ** File: arp.h ** ** Author: Mike Borella ** ** Comments: Generic ARP structure - an attempt at OS independence ** ** $Id: arp.h,v 1.3 2000/08/30 20:23:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef ARP_H #define ARP_H #include "global.h" #include "local.h" /* * ARP hardware identifiers (not even close to complete, but sufficient) */ #define ARP_HWTYPE_ETHERNET 1 #define ARP_HWTYPE_IEEE802 6 #define ARP_HWTYPE_IEEE1394 29 /* * ARP protocol opcodes. */ #define ARP_OPCODE_REQUEST 1 /* ARP request */ #define ARP_OPCODE_REPLY 2 /* ARP reply */ #define RARP_OPCODE_REQUEST 3 /* RARP request */ #define RARP_OPCODE_REPLY 4 /* RARP reply */ /* * ARP header */ typedef struct arp_header { u_int16_t hwaddr_format; /* format of hardware address */ u_int16_t protoaddr_format; /* format of protocol address */ u_int8_t hwaddr_length; /* length of hardware address */ u_int8_t protoaddr_length; /* length of protocol address */ u_int16_t opcode; /* ARP opcode (command) */ } arp_header_t; /* * Ethernet ARP format */ typedef struct ether_arp { u_int8_t sender_hwaddr[6]; /* sender hardware address */ u_int8_t sender_protoaddr[4]; /* sender protocol address */ u_int8_t target_hwaddr[6]; /* target hardware address */ u_int8_t target_protoaddr[4]; /* target protocol address */ } ether_arp_t; void dump_arp(packet_t *); #endif ipgrab-0.9.10/src/bgp.c0000644000175000001440000004146107442141533013767 0ustar farooqusers/**************************************************************************** ** File: bgp.c ** ** Author: Mike Borella ** ** Comments: Dumps BGP packets ** ** $Id: bgp.c,v 1.5 2002/03/08 13:57:47 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "bgp.h" #define BGP_COMMON_HDR_SIZE 19 #define HOLDER_SIZE 64 #define PREFIX_SIZE 16 /* * BGP message types */ #define BGP_MSGTYPE_OPEN 1 #define BGP_MSGTYPE_UPDATE 2 #define BGP_MSGTYPE_NOTIFICATION 3 #define BGP_MSGTYPE_KEEPALIVE 4 /* * BGP message type map */ strmap_t bgp_msgtype_map[] = { { BGP_MSGTYPE_OPEN, "open" }, { BGP_MSGTYPE_UPDATE, "update" }, { BGP_MSGTYPE_NOTIFICATION, "notification" }, { BGP_MSGTYPE_KEEPALIVE, "keepalive" }, { 0, "" } }; /* * BGP path attributes */ #define BGP_PATHATTR_ORIGIN 1 #define BGP_PATHATTR_ASPATH 2 #define BGP_PATHATTR_NEXTHOP 3 #define BGP_PATHATTR_MULTIEXITDISC 4 #define BGP_PATHATTR_LOCALPREF 5 #define BGP_PATHATTR_ATOMICAGGREGATE 6 #define BGP_PATHATTR_AGGREGATOR 7 #define BGP_PATHATTR_COMMUNITY 8 #define BGP_PATHATTR_ORIGINATORID 9 #define BGP_PATHATTR_CLUSTERLIST 10 #define BGP_PATHATTR_DPA 11 #define BGP_PATHATTR_ADVERTISER 12 #define BGP_PATHATTR_CLUSTERID 13 #define BGP_PATHATTR_MPREACHNLRI 14 #define BGP_PATHATTR_MPUNREACHNLRI 15 #define BGP_PATHATTR_EXTENDCOMMUNITIES 16 #define BGP_PATHATTR_NEWASPATH 17 #define BGP_PATHATTR_NEWAGGREGATOR 18 /* * BGP path attribute map */ strmap_t bgp_pathattr_map[] = { { BGP_PATHATTR_ORIGIN, "origin" }, { BGP_PATHATTR_ASPATH, "AS path" }, { BGP_PATHATTR_NEXTHOP, "next hop" }, { BGP_PATHATTR_MULTIEXITDISC, "multiexit discrimination" }, { BGP_PATHATTR_LOCALPREF, "local preferences" }, { BGP_PATHATTR_ATOMICAGGREGATE, "atomic aggregate" }, { BGP_PATHATTR_AGGREGATOR, "aggregator" }, { BGP_PATHATTR_COMMUNITY, "community" }, { BGP_PATHATTR_ORIGINATORID, "originator ID" }, { BGP_PATHATTR_CLUSTERLIST, "cluster list" }, { BGP_PATHATTR_DPA, "DPA" }, { BGP_PATHATTR_ADVERTISER, "advertiser" }, { BGP_PATHATTR_CLUSTERID, "cluster ID" }, { BGP_PATHATTR_MPREACHNLRI, "multiprotocol reachable NLRI" }, { BGP_PATHATTR_MPUNREACHNLRI, "multiprotocol unreachable NLRI" }, { BGP_PATHATTR_EXTENDCOMMUNITIES, "extended communities" }, { BGP_PATHATTR_NEWASPATH, "new AS path" }, { BGP_PATHATTR_NEWAGGREGATOR, "new aggregator" }, { 0, "" } }; /* * BGP origin types */ #define BGP_ORIGIN_IGP 1 #define BGP_ORIGIN_EGP 2 #define BGP_ORIGIN_INCOMPLETE 3 /* * BGP origin map */ strmap_t bgp_origin_map[] = { { BGP_ORIGIN_IGP, "IGP" }, { BGP_ORIGIN_EGP, "EGP" }, { BGP_ORIGIN_INCOMPLETE, "incomplete" }, { 0, "" } }; /* * BGP AS Path types */ #define BGP_ASPATH_SET 1 #define BGP_ASPATH_SEQUENCE 2 /* * BGP AS Path type map */ strmap_t bgp_aspath_map[] = { { BGP_ASPATH_SET, "set" }, { BGP_ASPATH_SEQUENCE, "sequence" }, { 0, "" } }; /* * BGP common header format */ typedef struct bgp_common { u_int8_t marker[16]; u_int16_t length; u_int8_t type; } bgp_common_t; /* * BGP open message format without the version number */ typedef struct bgp_open { u_int16_t my_as; u_int16_t hold_time; u_int32_t bgp_id; } bgp_open_t; extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** dump_bgp_prefix() ** ** Dumps and displays a BGP prefix ** **---------------------------------------------------------------------------- */ void dump_bgp_prefix(char * s, packet_t * pkt, int total_len) { u_int8_t bytes_read = 0; u_int8_t length; u_int8_t prefix[PREFIX_SIZE]; /* Made this big enough for v6 just in case */ u_int8_t prefix_length; int i; while(1) { /* Get the length of the prefix */ if (get_packet_bytes((u_int8_t *) &length, pkt, 1) == 0) break; /* Display the length */ if (!my_args->m) display(s, (u_int8_t *) &length, 1, DISP_DEC); /* Determine the real length */ if (length % 8 == 0) prefix_length = length / 8; else prefix_length = (length + 8) / 8; /* Get the prefix and pad it with 0's*/ if (get_packet_bytes((u_int8_t *) prefix, pkt, prefix_length) == 0) break; for (i=prefix_length; i 4) { } else { /* IPv4 */ if (my_args->m) { display_minimal((u_int8_t *) prefix, prefix_length, DISP_DOTTEDDEC); display_minimal_string("/"); display_minimal((u_int8_t *) &prefix_length, 1, DISP_DEC); display_minimal_string(" "); } else display(" Prefix", (u_int8_t *) prefix, prefix_length, DISP_DOTTEDDEC); } /* Check for the end of the list */ bytes_read = bytes_read + prefix_length + 1; if (bytes_read >= total_len) break; } } /*---------------------------------------------------------------------------- ** ** dump_bgp_attr() ** ** Dumps a single BGP attribute ** **---------------------------------------------------------------------------- */ void dump_bgp_attr(int attr, packet_t * pkt, int len) { switch(attr) { case BGP_PATHATTR_ORIGIN: { u_int8_t value; /* Get the value */ if (get_packet_bytes((u_int8_t *) &value, pkt, 1) == 0) return; /* Display */ if (my_args->m) { display_minimal_attribute(map2str(bgp_origin_map, value), (u_int8_t *) &value, 1, DISP_DEC, 1); } else { display_strmap(" Attribute", value, bgp_origin_map); } } break; case BGP_PATHATTR_ASPATH: { int bytes_read = 0; u_int8_t type; u_int8_t length; u_int16_t value; int i = 0; while(bytes_read < len) { /* Get the type and length */ if (get_packet_bytes((u_int8_t *) &type, pkt, 1) == 0) return; if (get_packet_bytes((u_int8_t *) &length, pkt, 1) == 0) return; /* Display */ if (my_args->m) { } else { display_strmap(" Type", type, bgp_aspath_map); display(" Length", (u_int8_t *) &length, 1, DISP_DEC); } /* Grab all of the values */ for (i=0; im) { } else display(" Value", (u_int8_t *) &value, 2, DISP_DEC); } /* for */ bytes_read = bytes_read + 2*length + 2; } } break; case BGP_PATHATTR_NEXTHOP: case BGP_PATHATTR_ORIGINATORID: { u_int32_t addr; /* Get the address */ if (get_packet_bytes((u_int8_t *) &addr, pkt, 4) == 0) return; /* Display */ if (my_args->m) { display_minimal_attribute("address", (u_int8_t *) &addr, 4, DISP_DOTTEDDEC, 1); } else { display_ipv4(" Address", (u_int8_t *) &addr); } } break; case BGP_PATHATTR_AGGREGATOR: { u_int16_t as; u_int32_t addr; /* Get the AS and address */ if (get_packet_bytes((u_int8_t *) &as, pkt, 2) == 0) return; if (get_packet_bytes((u_int8_t *) &addr, pkt, 4) == 0) return; /* Conversion */ as = ntohs(as); /* Display */ if (my_args->m) { } else { display(" AS", (u_int8_t *) &as, 2, DISP_DEC); display_ipv4(" Address", (u_int8_t *) &addr); } } break; case BGP_PATHATTR_COMMUNITY: { u_int8_t bytes_read = 0; while (bytes_read < len) { u_int16_t as; u_int16_t value; /* Get the AS and address */ if (get_packet_bytes((u_int8_t *) &as, pkt, 2) == 0) return; if (get_packet_bytes((u_int8_t *) &value, pkt, 2) == 0) return; /* Conversion */ as = ntohs(as); value = ntohs(value); /* Display */ if (my_args->m) { } else { display(" AS", (u_int8_t *) &as, 2, DISP_DEC); display(" Value", (u_int8_t *) &value, 2, DISP_DEC); } bytes_read = bytes_read + 4; } } break; case BGP_PATHATTR_CLUSTERLIST: { u_int8_t bytes_read = 0; while (bytes_read < len) { u_int32_t addr; /* Get the AS and address */ if (get_packet_bytes((u_int8_t *) &addr, pkt, 4) == 0) return; /* Display */ if (my_args->m) { } else { display(" Address", (u_int8_t *) &addr, 4, DISP_DOTTEDDEC); } bytes_read = bytes_read + 4; } } break; default: { dump_hexbytes(" Attribute", pkt, len, 0); } break; } } /*---------------------------------------------------------------------------- ** ** dump_bgp_pathattr() ** ** Dumps and displays BGP path attributes ** **---------------------------------------------------------------------------- */ void dump_bgp_pathattr(packet_t *pkt, int total_len) { u_int8_t bytes_read = 0; while(bytes_read < total_len) { u_int8_t attr_flags; u_int8_t attr_code; u_int8_t attr_len1; u_int16_t attr_len2; u_int8_t optional_bit, transitive_bit, partial_bit, extlen_bit; u_int16_t real_len; /* Get the flags and code */ if (get_packet_bytes((u_int8_t *) &attr_flags, pkt, 1) == 0) return; if (get_packet_bytes((u_int8_t *) &attr_code, pkt, 1) == 0) return; bytes_read = bytes_read + 2; /* Conversions */ optional_bit = attr_flags >> 7; transitive_bit = (attr_flags >> 6) & 0x01; partial_bit = (attr_flags >> 5) & 0x01; extlen_bit = (attr_flags >> 4) & 0x01; /* Display the attribute flags and code */ if (my_args->m) { display_minimal_strmap(attr_code, bgp_pathattr_map); display_minimal_string(" "); } else { display_strmap(" Attribute code", attr_code, bgp_pathattr_map); display(" Optional bit", (u_int8_t *) &optional_bit, 1, DISP_DEC); display(" Transitive bit", (u_int8_t *) &transitive_bit, 1, DISP_DEC); display(" Partial bit", (u_int8_t *) &partial_bit, 1, DISP_DEC); display(" Extended len bit", (u_int8_t *) &extlen_bit, 1, DISP_DEC); } /* Get the length, making sure we read the size correctly */ if (extlen_bit) { if (get_packet_bytes((u_int8_t *) &attr_len2, pkt, 2) == 0) return; attr_len2 = ntohs(attr_len2); real_len = attr_len2; bytes_read = bytes_read + 2; } else { if (get_packet_bytes((u_int8_t *) &attr_len1, pkt, 1) == 0) return; real_len = attr_len1; bytes_read = bytes_read + 1; } /* Display the length */ if (!my_args->m) display(" Length", (u_int8_t *) &real_len, 2, DISP_DEC); /* Get and display the attribute. We'll fix this later... */ if (real_len > 0) { dump_bgp_attr(attr_code, pkt, real_len); bytes_read = bytes_read + real_len; } } /* while */ } /*---------------------------------------------------------------------------- ** ** dump_bgp() ** ** Dumps and displays BGP packets ** **---------------------------------------------------------------------------- */ void dump_bgp(packet_t *pkt) { bgp_common_t bgp_common_hdr; char holder[HOLDER_SIZE]; /* Display the banner info */ if (my_args->m) display_minimal_string("| BGP "); else display_header_banner("BGP Header"); /* Loop over all individual messages */ while(1) { /* Get the common header */ if (get_packet_bytes((u_int8_t *) &bgp_common_hdr, pkt, BGP_COMMON_HDR_SIZE) == 0) break; /* Conversions */ bgp_common_hdr.length = ntohs(bgp_common_hdr.length); /* Display the common header */ if (my_args->m) { display_minimal_string("["); display_minimal_strmap(bgp_common_hdr.type, bgp_msgtype_map); display_minimal_string(" "); } else { snprintf(holder, HOLDER_SIZE, "%d (%s)", bgp_common_hdr.type, map2str(bgp_msgtype_map, bgp_common_hdr.type)); display_string("Message type", holder); display(" Marker", (u_int8_t *) &bgp_common_hdr.marker, 16, DISP_HEX); display(" Length", (u_int8_t *) &bgp_common_hdr.length, 2, DISP_DEC); } /* Decide how to continue based on message type */ switch(bgp_common_hdr.type) { case BGP_MSGTYPE_OPEN: { u_int8_t version; bgp_open_t open; u_int8_t option_len; /* Get the version then get the rest of the packet open header */ if (get_packet_bytes((u_int8_t *) &version, pkt, 1) == 0) break; if (get_packet_bytes((u_int8_t *) &open, pkt, sizeof(bgp_open_t)) == 0) break; /* Conversions */ open.my_as = ntohs(open.my_as); open.hold_time = ntohs(open.hold_time); /* Display */ if (my_args->m) { } else { display(" Version", (u_int8_t *) &version, 1, DISP_DEC); display(" My AS", (u_int8_t *) &open.my_as, 2, DISP_DEC); display(" Hold time", (u_int8_t *) &open.hold_time, 2, DISP_DEC); display_ipv4(" BGP ID", (u_int8_t *) &open.bgp_id); } /* Get options, if we need to */ if (get_packet_bytes((u_int8_t *) &option_len, pkt, 1) == 0) break; /* Display */ if (!my_args->m) display(" Options length", (u_int8_t *) &option_len, 1, DISP_DEC); if (option_len > 0) dump_hexbytes(" Options", pkt, option_len, 0); } break; case BGP_MSGTYPE_UPDATE: { u_int16_t withdrawn_routes_len; u_int16_t total_path_attr_len; /* Get the withdrawn routes len */ if (get_packet_bytes((u_int8_t *) &withdrawn_routes_len, pkt, 2) == 0) break; /* Conversion */ withdrawn_routes_len = ntohs(withdrawn_routes_len); /* Display */ if (!my_args->m) display(" Withdrawn routes len", (u_int8_t *) &withdrawn_routes_len, 2, DISP_DEC); /* Parse and display the withdrawn routes */ if (withdrawn_routes_len > 0) dump_bgp_prefix(" Withdrawn route len", pkt, withdrawn_routes_len); /* Get the total path attr len */ if (get_packet_bytes((u_int8_t *) &total_path_attr_len, pkt, 2) == 0) break; /* Conversion */ total_path_attr_len = ntohs(total_path_attr_len); /* Display */ if (!my_args->m) display(" Total path attr len", (u_int8_t *) &total_path_attr_len, 2, DISP_DEC); /* Dump all of the path attributes */ dump_bgp_pathattr(pkt, total_path_attr_len); /* Dump the NLRI's */ dump_bgp_prefix(" NLRI length", pkt, bgp_common_hdr.length - BGP_COMMON_HDR_SIZE - withdrawn_routes_len - total_path_attr_len - 4); } break; case BGP_MSGTYPE_NOTIFICATION: { u_int8_t error_code; u_int8_t error_subcode; /* Get the code and subcode */ if (get_packet_bytes((u_int8_t *) &error_code, pkt, 1) == 0) break; if (get_packet_bytes((u_int8_t *) &error_subcode, pkt, 1) == 0) break; /* Display */ if (my_args->m) { } else { display(" Error code", (u_int8_t *) &error_code, 1, DISP_DEC); display(" Error subcode", (u_int8_t *) &error_subcode, 1, DISP_DEC); } /* Figure out the length of the data and get it */ dump_hexbytes(" Data", pkt, bgp_common_hdr.length - BGP_COMMON_HDR_SIZE - 2, 0); } break; case BGP_MSGTYPE_KEEPALIVE: { /* Do nothing because keepalives have no data */ } break; default: { /* If we don't understand the message, dump the rest of it */ dump_hexbytes(" Value", pkt, bgp_common_hdr.length - BGP_COMMON_HDR_SIZE, 0); } break; } /* Close off this message in minimal mode */ if (my_args->m) display_minimal_string("] "); } /* while (1) */ /* dump the hex buffer */ hexbuffer_flush(); } ipgrab-0.9.10/src/bgp.h0000644000175000001440000000215607437710742014002 0ustar farooqusers/**************************************************************************** ** File: bgp.h ** ** Author: Mike Borella ** ** Comments: Definitons for BGP decoder ** ** $Id: bgp.h,v 1.1 2002/03/01 14:36:18 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef BGP_H #define BGP_H #include "global.h" #include "local.h" void dump_bgp(packet_t *); #endif ipgrab-0.9.10/src/cbcp.c0000644000175000001440000001176707356404567014151 0ustar farooqusers/**************************************************************************** ** File: cbcp.c ** ** Author: Mike Borella ** ** Comments: CBCP module. This is Microsoft's Callback Control Protocol. ** ** $Id: cbcp.c,v 1.1 2001/10/02 18:37:43 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "cbcp.h" #define CBCP_OPTION_LEN 64 /* * CBCP codes */ #define CBCP_CODE_CBREQ 1 #define CBCP_CODE_CBRES 2 #define CBCP_CODE_CBACK 3 /* * CBCP code map */ strmap_t cbcp_code_map[] = { { CBCP_CODE_CBREQ, "Callback-Request" }, { CBCP_CODE_CBRES, "Callback-Response" }, { CBCP_CODE_CBACK, "Callback-Ack" }, { 0, ""} }; /* * CBCP options */ #define CBCP_OPTION_NOCALLBACK 1 #define CBCP_OPTION_CALLBACKTOUSERNUMBER 2 #define CBCP_OPTION_CALLBACKTOADMINNUMBER 3 #define CBCP_OPTION_CALLBACKTOANYLIST 4 /* * CBCP option map */ strmap_t cbcp_option_map[] = { { CBCP_OPTION_NOCALLBACK, "no callback" }, { CBCP_OPTION_CALLBACKTOUSERNUMBER, "callback to user defined number" }, { CBCP_OPTION_CALLBACKTOADMINNUMBER, "callback to admin defined number" }, { CBCP_OPTION_CALLBACKTOANYLIST, "callback to any list of numbers" }, { 0, "" } }; /* * CBCP frame format */ typedef struct cbcp { u_int8_t code; u_int8_t identifier; u_int16_t length; } cbcp_t; extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** dump_cbcp() ** ** Displays CBCP packets. ** **---------------------------------------------------------------------------- */ void dump_cbcp(packet_t *pkt) { cbcp_t cbcp; /* Set the layer */ set_layer(LAYER_DATALINK); /* * Get the header */ if (get_packet_bytes((u_int8_t *) &cbcp, pkt, sizeof(cbcp_t)) == 0) return; /* * Conversion */ cbcp.length = ntohs(cbcp.length); /* * Dump the header */ if (my_args->m) { display_minimal_string("| CBCP "); display_minimal_string(map2str(cbcp_code_map, cbcp.code)); display_minimal_string(" "); } else { display_header_banner("CBCP Header"); display_strmap("Code", cbcp.code, cbcp_code_map); display("Identifier", &cbcp.identifier, 1, DISP_DEC); display("Length", (u_int8_t *) &cbcp.length, 2, DISP_DEC); } /* * Grab the payload data */ if (cbcp.length > sizeof(cbcp_t)) { switch(cbcp.code) { case CBCP_CODE_CBREQ: case CBCP_CODE_CBRES: case CBCP_CODE_CBACK: { u_int8_t bytes_read = 0; u_int8_t type; u_int8_t length; u_int8_t value [CBCP_OPTION_LEN]; int comma = 0; /* * CBCP options appear in Type-Length-Value format */ while (bytes_read < cbcp.length - sizeof(cbcp_t)) { /* * Get type */ if (get_packet_bytes((u_int8_t *) &type, pkt, 1) == 0) break; bytes_read ++; /* * Get length */ if (get_packet_bytes((u_int8_t *) &length, pkt, 1) == 0) break; bytes_read ++; /* * In minimal mode we start all CBCP options with an open paren * and put a comma before all but the first */ if (my_args->m) { if (comma) display_minimal_string(", "); else display_minimal_string("("); } comma = 1; /* * Display the type and length */ if (my_args->m) { display_minimal_string(map2str(cbcp_option_map, type)); } else { display_strmap("Option", type, cbcp_option_map); display(" Length", &length, 1, DISP_DEC); } /* * Figure out if we need to get a value */ if (length > 2) { if (get_packet_bytes((u_int8_t *) value, pkt, length-2) == 0) break; bytes_read = bytes_read + length - 2; /* * Display the value */ if (my_args->m) { display_minimal_string(" "); display_minimal(value, length-2, DISP_HEX); } else { display(" Value", (u_int8_t *) value, length-2, DISP_HEX); } } /* if */ } /* while */ /* * Insert end paren in minimal mode */ if (my_args->m) display_minimal_string(")"); } break; default: break; } } /* dump the hex buffer */ if (!my_args->l) hexbuffer_flush(); } ipgrab-0.9.10/src/cbcp.h0000644000175000001440000000216007356404567014141 0ustar farooqusers/**************************************************************************** ** File: lcp.h ** ** Author: Mike Borella ** ** Comments: CBCP module definitions. ** ** $Id: cbcp.h,v 1.1 2001/10/02 18:37:43 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef CBCP_H #define CBCP_H #include "global.h" #include "local.h" void dump_cbcp(packet_t *); #endif ipgrab-0.9.10/src/ccp.c0000644000175000001440000001655510637726215014000 0ustar farooqusers/**************************************************************************** ** File: ccp.c ** ** Author: Mike Borella ** ** Comments: CCP module. ** ** $Id: ccp.c,v 1.2 2007/06/25 11:52:45 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "ccp.h" #define CCP_OPTION_LEN 64 /* * CCP codes */ #define CCP_CODE_CONFREQ 1 #define CCP_CODE_CONFACK 2 #define CCP_CODE_CONFNAK 3 #define CCP_CODE_CONFREJ 4 #define CCP_CODE_TERMREQ 5 #define CCP_CODE_TERMACK 6 #define CCP_CODE_CODEREJ 7 #define CCP_CODE_RESETREQ 14 #define CCP_CODE_RESETREP 15 /* * CCP code map */ strmap_t ccp_code_map[] = { { CCP_CODE_CONFREQ, "Configure-Request" }, { CCP_CODE_CONFACK, "Configure-Ack" }, { CCP_CODE_CONFNAK, "Configure-Nak" }, { CCP_CODE_CONFREJ, "Configure-Reject" }, { CCP_CODE_TERMREQ, "Terminate-Request" }, { CCP_CODE_TERMACK, "Terminate-Ack" }, { CCP_CODE_CODEREJ, "Code-Rej" }, { CCP_CODE_RESETREQ, "Reset-Request" }, { CCP_CODE_RESETREP, "Reset-Replay" }, { 0, ""} }; /* * CCP options */ #define CCP_OPTION_OUI 0 #define CCP_OPTION_PREDICTORTYPE1 1 #define CCP_OPTION_PREDICTORTYPE2 2 #define CCP_OPTION_PUDDLEJUMPER 3 #define CCP_OPTION_HPPPC 16 #define CCP_OPTION_STACLZS 17 #define CCP_OPTION_MSPPC 18 #define CCP_OPTION_GANDALFFZA 19 #define CCP_OPTION_V42BIS 20 #define CCP_OPTION_BSDCOMPRESS 21 #define CCP_OPTION_LZSDCP 23 #define CCP_OPTION_MVRCAMAGNALINK 24 #define CCP_OPTION_DEFLATE 26 /* * CCP option map */ strmap_t ccp_option_map[] = { { CCP_OPTION_OUI, "OUI" }, { CCP_OPTION_PREDICTORTYPE1, "predictor type 1" }, { CCP_OPTION_PREDICTORTYPE2, "predictor type 2" }, { CCP_OPTION_PUDDLEJUMPER, "puddlejumper" }, { CCP_OPTION_HPPPC, "Hewlett-Packard PPC" }, { CCP_OPTION_STACLZS, "STAC LZS" }, { CCP_OPTION_MSPPC, "Microsoft PPC" }, { CCP_OPTION_GANDALFFZA, "Gandalf FZA" }, { CCP_OPTION_V42BIS, "V42BIS" }, { CCP_OPTION_BSDCOMPRESS, "BSD compress" }, { CCP_OPTION_LZSDCP, "LZS DCP" }, { CCP_OPTION_MVRCAMAGNALINK, "MVRCA/Magnalink" }, { CCP_OPTION_DEFLATE, "deflate" }, { 0, "" } }; /* * CCP frame format */ typedef struct ccp { u_int8_t code; u_int8_t identifier; u_int16_t length; } ccp_t; extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** dump_ccp() ** ** Displays CCP packets. ** **---------------------------------------------------------------------------- */ void dump_ccp(packet_t *pkt) { ccp_t ccp; /* Set the layer */ set_layer(LAYER_DATALINK); /* * Get the header */ if (get_packet_bytes((u_int8_t *) &ccp, pkt, sizeof(ccp_t)) == 0) return; /* * Conversion */ ccp.length = ntohs(ccp.length); /* * Dump the header */ if (my_args->m) { display_minimal_string("| CCP "); display_minimal_string(map2str(ccp_code_map, ccp.code)); display_minimal_string(" "); } else { display_header_banner("CCP Header"); display_strmap("Code", ccp.code, ccp_code_map); display("Identifier", &ccp.identifier, 1, DISP_DEC); display("Length", (u_int8_t *) &ccp.length, 2, DISP_DEC); } /* * Grab the payload data */ if (ccp.length > sizeof(ccp_t)) { switch(ccp.code) { case CCP_CODE_CONFREQ: case CCP_CODE_CONFACK: case CCP_CODE_CONFNAK: case CCP_CODE_CONFREJ: { u_int8_t bytes_read = 0; u_int8_t type; u_int8_t length; u_int8_t value [CCP_OPTION_LEN]; int comma = 0; /* * CCP options appear in Type-Length-Value format */ while (bytes_read < ccp.length - sizeof(ccp_t)) { /* * Get type */ if (get_packet_bytes((u_int8_t *) &type, pkt, 1) == 0) break; bytes_read ++; /* * Get length */ if (get_packet_bytes((u_int8_t *) &length, pkt, 1) == 0) break; bytes_read ++; /* * In minimal mode we start all CCP options with an open paren * and put a comma before all but the first */ if (my_args->m) { if (comma) display_minimal_string(", "); else display_minimal_string("("); } comma = 1; /* * Display the type and length */ if (my_args->m) { display_minimal_string(map2str(ccp_option_map, type)); } else { display_strmap("Option", type, ccp_option_map); display(" Length", &length, 1, DISP_DEC); } /* * Figure out if we need to get a value */ if (length > 2) { if (get_packet_bytes((u_int8_t *) value, pkt, length-2) == 0) break; bytes_read = bytes_read + length - 2; /* * Display the value */ if (my_args->m) { display_minimal_string(" "); display_minimal(value, length-2, DISP_HEX); } else { display(" Value", (u_int8_t *) value, length-2, DISP_HEX); } } /* if */ } /* while */ /* * Insert end paren in minimal mode */ if (my_args->m) display_minimal_string(")"); } break; case CCP_CODE_TERMREQ: case CCP_CODE_TERMACK: { u_int8_t * data; u_int8_t data_len; /* * Read the data, if any */ data_len = ccp.length - sizeof(ccp_t); if (data_len > 0) { /* allocate memory for the data */ data = (u_int8_t *) my_malloc(data_len); /* grab the data field */ if (get_packet_bytes(data, pkt, data_len) == 0) { my_free(data); return; } /* dump it out as hex, but don't dump in minimal mode */ if (!my_args->m) { display("Data", data, data_len, DISP_HEX); } /* free that darn mem! */ my_free(data); } } break; case CCP_CODE_CODEREJ: dump_ccp(pkt); break; case CCP_CODE_RESETREQ: case CCP_CODE_RESETREP: { u_int8_t * data; u_int8_t data_len; data_len = ccp.length - sizeof(ccp_t); if(data_len > 0) { data = (u_int8_t *) my_malloc(data_len); if (get_packet_bytes(data, pkt, data_len) == 0) { my_free(data); return; } if(!my_args->m) { display("Data", data, data_len, DISP_HEX); } my_free(data); } } break; default: break; } } /* dump the hex buffer */ if (!my_args->l) hexbuffer_flush(); } ipgrab-0.9.10/src/ccp.h0000644000175000001440000000215307356431504013770 0ustar farooqusers/**************************************************************************** ** File: ccp.h ** ** Author: Mike Borella ** ** Comments: CCP module definitions. ** ** $Id: ccp.h,v 1.1 2001/10/02 21:36:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef CCP_H #define CCP_H #include "global.h" #include "local.h" void dump_ccp(packet_t *); #endif ipgrab-0.9.10/src/chap.c0000644000175000001440000001116007356404567014140 0ustar farooqusers/**************************************************************************** ** File: chap.c ** ** Author: Mike Borella ** ** Comments: CHAP decoding. ** ** $Id: chap.c,v 1.8 2001/10/02 18:37:43 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "chap.h" /* * CHAP header */ typedef struct chap { u_int8_t code; u_int8_t identifier; u_int16_t length; } chap_t; /* * CHAP codes */ #define CHAP_CODE_CHALLENGE 1 #define CHAP_CODE_RESPONSE 2 #define CHAP_CODE_SUCCESS 3 #define CHAP_CODE_FAILURE 4 /* * CHAP code map */ strmap_t chap_code_map[] = { { CHAP_CODE_CHALLENGE, "challenge" }, { CHAP_CODE_RESPONSE, "response" }, { CHAP_CODE_SUCCESS, "success" }, { CHAP_CODE_FAILURE, "failure" }, { 0, "" } }; extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** dump_chap() ** ** Dump CHAP headers and payload. ** **---------------------------------------------------------------------------- */ void dump_chap(packet_t *pkt) { chap_t chap; /* Set the layer */ set_layer(LAYER_DATALINK); /* * Get the header */ if (get_packet_bytes((u_int8_t *) &chap, pkt, sizeof(chap_t)) == 0) return; /* * Conversion */ chap.length = ntohs(chap.length); /* * Dump the header */ if (my_args->m) { display_minimal_string("| CHAP "); } else { display_header_banner("CHAP Header"); display_strmap("Code", chap.code, chap_code_map); display("Identifier", &chap.identifier, 1, DISP_DEC); display("Length", (u_int8_t *) &chap.length, 2, DISP_DEC); } /* * Get the CHAP payload */ switch(chap.code) { case CHAP_CODE_CHALLENGE: case CHAP_CODE_RESPONSE: { u_int8_t * value; u_int8_t value_size; u_int8_t * name; u_int16_t name_size; /* Get the value size */ if (get_packet_bytes(&value_size, pkt, 1) == 0) return; /* Get the value */ value = (u_int8_t *) my_malloc(value_size); if (get_packet_bytes(value, pkt, value_size) == 0) { my_free(value); return; } /* Figure out the size of the name and get it */ name_size = chap.length - sizeof(chap_t) - value_size - 1; name = (u_int8_t *) my_malloc(name_size+1); if (get_packet_bytes(name, pkt, name_size) == 0) { my_free(value); my_free(name); return; } name[name_size] = '\0'; /* display everything */ if (my_args->m) { if (chap.code == CHAP_CODE_CHALLENGE) display_minimal_string("challenge "); if (chap.code == CHAP_CODE_RESPONSE) display_minimal_string("response "); display_minimal_string("("); display_minimal(value, value_size, DISP_HEX); display_minimal_string(", "); display_minimal_string(name); display_minimal_string(")"); } else { display("Value size", &value_size, 1, DISP_DEC); display("Value", value, value_size, DISP_HEX_MULTILINE); display_string("Name", name); } /* free memory */ my_free(value); my_free(name); } break; case CHAP_CODE_SUCCESS: case CHAP_CODE_FAILURE: { u_int8_t * message; u_int8_t message_len; /* figure out length of the message and then grab it */ message_len = chap.length - sizeof(chap_t); message = (u_int8_t *) my_malloc (message_len + 1); if (get_packet_bytes(message, pkt, message_len) == 0) { my_free(message); return; } message[message_len] = '\0'; /* display it */ if (my_args->m) { if (chap.code == CHAP_CODE_SUCCESS) display_minimal_string("success "); if (chap.code == CHAP_CODE_FAILURE) display_minimal_string("failure "); display_minimal_string("("); display_minimal_string(message); display_minimal_string(")"); } else { display_string("Message", message); } /* free memory */ my_free(message); } break; } } ipgrab-0.9.10/src/chap.h0000644000175000001440000000213107154020045014120 0ustar farooqusers/**************************************************************************** ** File: chap.h ** ** Author: Mike Borella ** ** Comments: ** ** $Id: chap.h,v 1.1 2000/09/01 21:31:17 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef CHAP_H #define CHAP_H #include "global.h" #include "local.h" void dump_chap(packet_t *); #endif ipgrab-0.9.10/src/datalink.c0000644000175000001440000001471110637716241015010 0ustar farooqusers/**************************************************************************** ** File: datalink.c ** ** Author: Mike Borella ** ** Comments: Generic datalink module ** ** $Id: datalink.c,v 1.26 2007/06/25 10:44:49 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "global.h" #include "error.h" #include "datalink.h" #include "ethernet.h" #include "loopback.h" #include "slip.h" #include "raw.h" #include "ppp.h" #include "padding.h" #include "payload.h" #include "stats.h" #include "dynports.h" extern struct arg_t * my_args; extern int packet_displayed; extern int start_of_packet; /* Map for datalink types */ strmap_t datalink_type_map[] = { { DATALINK_TYPE_ETHERNET, "ethernet" }, { DATALINK_TYPE_8023, "802.3" }, { DATALINK_TYPE_TOKENBUS, "token bus" }, { DATALINK_TYPE_TOKENRING, "token ring" }, { DATALINK_TYPE_METRONET, "metro net" }, { DATALINK_TYPE_HDLC, "HDLC" }, { DATALINK_TYPE_CHARSYNCH, "character synchronous" }, { DATALINK_TYPE_IBMC2C, "IBM channel-to-channel" }, { DATALINK_TYPE_FDDI, "FDDI" }, { DATALINK_TYPE_NULL, "null" }, { DATALINK_TYPE_SLIP, "SLIP" }, { DATALINK_TYPE_PPP, "PPP" }, { DATALINK_TYPE_RAWIP, "raw ip" }, { 0, ""} }; /*---------------------------------------------------------------------------- ** ** datalink_pcap() ** ** Libpcap specific wrapper for the generic datalink function ** **---------------------------------------------------------------------------- */ void datalink_pcap(u_char * user, const struct pcap_pkthdr * h, u_char * pkt) { int linktype = -1; u_int32_t * link; struct timeval tv; /* Translate the link type */ link = (u_int32_t *) user; switch(*link) { case DLT_NULL: linktype = DATALINK_TYPE_NULL; break; case DLT_EN10MB: linktype = DATALINK_TYPE_ETHERNET; break; case DLT_SLIP: linktype = DATALINK_TYPE_SLIP; break; case DLT_PPP: linktype = DATALINK_TYPE_PPP; break; #ifdef DLT_RAW /* Not supported in some arch or older pcap versions */ case DLT_RAW: linktype = DATALINK_TYPE_RAWIP; break; #endif default: error_fatal("\ncannot handle data link type %d", link); } /* * Copy the timestamp our own timeval struct to avoid compilation * errors with older versions of libpcap. */ tv.tv_sec = h->ts.tv_sec; tv.tv_usec = h->ts.tv_usec; /* Call the generic datalink function */ datalink(linktype, tv, h->caplen, h->len, pkt); } /*---------------------------------------------------------------------------- ** ** datalink() ** **---------------------------------------------------------------------------- */ void datalink(int linktype, struct timeval ts, u_int32_t captured_length, u_int32_t media_length, u_int8_t * pkt) { packet_t packet; static int count = 1; /* count of the number of packets */ /* * For minimal mode. We haven't displayed part of a packet yet... * Set the start of packet flag so that we can display a nicer separator */ packet_displayed = 0; start_of_packet = 1; /* * Reset the stats counted flag and unpause the counting if paused. * This avoids the double-counting of encapsulated headers. */ stats_reset(); stats_unpause(); /* * Set up packet into data structure */ packet.contents = my_malloc(captured_length); memcpy(packet.contents, pkt, captured_length); packet.current = &packet.contents[0]; packet.end = &packet.contents[0] + captured_length; packet.apparent_end = packet.end; packet.media_length = media_length; /* * Print time stamp is human readable format. */ snprintf(packet.timestamp, PACKET_TIMESTAMP_LEN, "%s", ctime ( ( const time_t * ) &ts.tv_sec ) ); /* * If we're in minimal mode, start off with the count number * and the optional packet timestamp */ if (my_args->m) { display_minimal((u_int8_t *) &count, 4, DISP_DEC); display_minimal_string(" "); count ++; if (!my_args->T) { display_minimal_string(packet.timestamp); display_minimal_string(" "); } } /* * Delete any remaining hex buffer contents */ hexbuffer_kill(); /* * Determine what to do next */ switch(linktype) { case DATALINK_TYPE_NULL: dump_loopback(&packet); break; case DATALINK_TYPE_ETHERNET: dump_ethernet(&packet); break; case DATALINK_TYPE_SLIP: dump_slip(&packet); break; case DATALINK_TYPE_PPP: dump_ppp(&packet); break; case DATALINK_TYPE_RAWIP: dump_raw(&packet); break; default: error_fatal("\ncannot handle data link type %d", linktype); } /* * Make sure we set the layer back to a null value in case one of * the layers was suppressed. */ set_layer(LAYER_NONE); /* * Both payload and padding shouldn't be displayed in minimal mode */ if (!my_args->m) { /* * If there is any remaining data and the user wants to see it, dump it * out now */ if (my_args->p && get_packet_apparentbytesleft(&packet)) dump_payload(&packet); /* * If there is a padding and the user wants to see it, dump it out now */ if (my_args->d && packet_haspadding(&packet)) dump_padding(&packet); } /* * For minimal mode, finish with a carriage return */ if (my_args->m && packet_displayed) { display_minimal_cr(); display_minimal_cr(); } /* * Time out stale dynamic port mappings */ dynports_timeout(); /* * Deallocate memory */ my_free(packet.contents); } ipgrab-0.9.10/src/datalink.h0000644000175000001440000000332207370363552015014 0ustar farooqusers/**************************************************************************** ** File: datalink.h ** ** Author: Mike Borella ** ** Header file for generic datalink functionality ** ** $Id: datalink.h,v 1.3 2001/11/02 00:23:06 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef DATALINK_H #define DATALINK_H #include "global.h" #define DATALINK_TYPE_ETHERNET 0 #define DATALINK_TYPE_8023 1 #define DATALINK_TYPE_TOKENBUS 2 #define DATALINK_TYPE_TOKENRING 3 #define DATALINK_TYPE_METRONET 4 #define DATALINK_TYPE_HDLC 5 #define DATALINK_TYPE_CHARSYNCH 6 #define DATALINK_TYPE_IBMC2C 7 #define DATALINK_TYPE_FDDI 8 #define DATALINK_TYPE_NULL 9 #define DATALINK_TYPE_SLIP 10 #define DATALINK_TYPE_PPP 11 #define DATALINK_TYPE_RAWIP 12 /* * Function prototypes */ void datalink_pcap(u_char *, const struct pcap_pkthdr *, u_char *); void datalink(int, struct timeval, u_int32_t, u_int32_t, u_int8_t *); #endif ipgrab-0.9.10/src/dhcp.c0000644000175000001440000003256010637735720014144 0ustar farooqusers/**************************************************************************** ** File: dhcp.c ** ** Author: Mike Borella ** ** Comments: Dump DHCP header information. See RFCs 2131 and 2132. ** ** $Id: dhcp.c,v 1.22 2007/06/25 12:57:52 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "arp.h" #include "dhcp.h" #define HOLDER_SIZE 256 /* * DHCP operation type map */ strmap_t dhcp_op_map[] = { { DHCP_OP_BOOTREQUEST, "boot request" }, { DHCP_OP_BOOTREPLY, "boot reply" }, { 0, "" } }; /* * DHCP option map */ strmap_t dhcp_option_map[] = { { DHCP_OPTION_PAD, "pad" }, { DHCP_OPTION_NETMASK, "netmask" }, { DHCP_OPTION_TIMEOFFSET, "time offset" }, { DHCP_OPTION_ROUTER, "router" }, { DHCP_OPTION_TIMESERVER, "time server" }, { DHCP_OPTION_NAMESERVER, "name server" }, { DHCP_OPTION_DNS, "DNS server" }, { DHCP_OPTION_LOGSERVER, "log server" }, { DHCP_OPTION_COOKIESERVER, "cookie server" }, { DHCP_OPTION_LPRSERVER, "LPR server" }, { DHCP_OPTION_IMPRESSSERVER, "impress server" }, { DHCP_OPTION_RESLOCSERVER, "RLP server" }, { DHCP_OPTION_HOSTNAME, "hostname" }, { DHCP_OPTION_BOOTFILESIZE, "boot file size" }, { DHCP_OPTION_MERITDUMP, "Merit dump" }, { DHCP_OPTION_DOMAINNAME, "domain name" }, { DHCP_OPTION_SWAPSERVER, "swap server" }, { DHCP_OPTION_ROOTPATH, "root path" }, { DHCP_OPTION_EXTSPATH, "extension path" }, { DHCP_OPTION_IPFORWARD, "IP forward" }, { DHCP_OPTION_NONLOCALSR, "source routing" }, { DHCP_OPTION_POLICYFILTER, "policy filter" }, { DHCP_OPTION_VENDORSPECIFIC, "vendor specific" }, { DHCP_OPTION_NETBIOSNAMESERV, "NETBIOS name server" }, { DHCP_OPTION_NETBIOSDGDIST, "NETBIOS datagram distribution server" }, { DHCP_OPTION_NETBIOSNODETYPE, "NETBIOS node type" }, { DHCP_OPTION_NETBIOSSCOPE, "NETBIOS scope" }, { DHCP_OPTION_REQUESTEDIPADDR, "requested IP address" }, { DHCP_OPTION_IPADDRLEASE, "IP address lease" }, { DHCP_OPTION_OVERLOAD, "overload" }, { DHCP_OPTION_MESSAGETYPE, "message type" }, { DHCP_OPTION_SERVERID, "server ID" }, { DHCP_OPTION_PARAMREQLIST, "parameter request list" }, { DHCP_OPTION_RENEWALTIME, "renewal time" }, { DHCP_OPTION_REBINDINGTIME, "rebinding time" }, { DHCP_OPTION_VENDORCLASSID, "vendor class ID" }, { DHCP_OPTION_CLIENTID, "client ID" }, { DHCP_OPTION_USERCLASS, "user class" }, { DHCP_OPTION_END, "end of options" }, { 0, "" } }; /* * DHCP message type map */ strmap_t dhcp_msgtype_map[] = { { DHCP_MSGTYPE_DISCOVER, "DHCPDISCOVER" }, { DHCP_MSGTYPE_OFFER, "DHCPOFFER" }, { DHCP_MSGTYPE_REQUEST, "DHCPREQUEST" }, { DHCP_MSGTYPE_DECLINE, "DHCPDECLINE" }, { DHCP_MSGTYPE_ACK, "DHCPACK" }, { DHCP_MSGTYPE_NAK, "DHCPNAK" }, { DHCP_MSGTYPE_RELEASE, "DHCPRELASE" }, { DHCP_MSGTYPE_INFORM, "DHCPINFORM" }, { 0, "" } }; extern struct arg_t *my_args; extern strmap_t arp_hardware_map[]; /*---------------------------------------------------------------------------- ** ** dump_dhcp() ** ** Parse DHCP packet and dump fields ** **---------------------------------------------------------------------------- */ void dump_dhcp(packet_t *pkt) { dhcp_header_t dhcp; int j; u_int32_t i; u_int32_t cookie_holder; u_int8_t opt; char holder[HOLDER_SIZE]; /* this needs to be as big as the biggest option */ /* Set the layer */ set_layer(LAYER_APPLICATION); /* * Get the DHCP fixed header */ if (get_packet_bytes((u_int8_t *) &dhcp, pkt, sizeof(dhcp_header_t)) == 0) return; /* * Conversions */ dhcp.xid = ntohl(dhcp.xid); dhcp.secs = ntohs(dhcp.secs); dhcp.flags = ntohs(dhcp.flags); /* announcement */ if (!my_args->m) display_header_banner("DHCP Header"); /* * Display operation, other info */ snprintf(holder, HOLDER_SIZE, "%d (%s)", dhcp.op, map2str(dhcp_op_map, dhcp.op)); if (my_args->m) { display_minimal_string(map2str(dhcp_op_map, dhcp.op)); display_minimal_string(" "); } else { display("Operation", (u_int8_t *) holder, strlen(holder), DISP_STRING); display("Hardware addr type", (u_int8_t *) &dhcp.htype, 1, DISP_DEC); display("Hardware addr length", (u_int8_t *) &dhcp.hlen, 1, DISP_DEC); display("Hops", (u_int8_t *) &dhcp.hops, 1, DISP_DEC); display("Transaction ID", (u_int8_t *) &dhcp.xid, 4, DISP_HEX); display("Seconds", (u_int8_t *) &dhcp.secs, 2, DISP_DEC); display("Flags", (u_int8_t *) &dhcp.flags, 2, DISP_HEX); } /* * Display IPs */ if (!my_args->m) { display_ipv4("Client addr", (u_int8_t *) &dhcp.ciaddr); display_ipv4("Your addr", (u_int8_t *) &dhcp.yiaddr); display_ipv4("Next server addr", (u_int8_t *) &dhcp.siaddr); display_ipv4("Relay agent addr", (u_int8_t *) &dhcp.giaddr); display ("Client hardware addr:", (u_int8_t *) dhcp.chaddr, dhcp.hlen, DISP_HEXCOLONS ); } /* * Display names */ if (!my_args->m) { display("Server host name", (u_int8_t *) dhcp.sname, strlen(dhcp.sname), DISP_STRING); display("Boot file name", (u_int8_t *) dhcp.file, strlen(dhcp.file), DISP_STRING); } /* * Look for BOOTP cookie */ i = htonl(BOOTP_COOKIE); if (look_packet_bytes((u_int8_t *) &cookie_holder, pkt, 4) == 0) return; if (i == cookie_holder && !my_args->m) { if (skip_packet_bytes(pkt, 4) == 0) return; display("BOOTP cookie", (u_int8_t *) &cookie_holder, 4, DISP_HEX); } /* * Parse the options list */ while (get_packet_apparentbytesleft(pkt)) { u_int8_t len=0; /* * Get the option number and dump it */ if (get_packet_bytes((u_int8_t *) &opt, pkt, 1) == 0) return; snprintf(holder, HOLDER_SIZE, "%d (%s)", opt, map2str(dhcp_option_map, opt)); if (!my_args->m) display("Option", (u_int8_t *) holder, strlen(holder), DISP_STRING); /* * If its a pad, go back and get another */ if (opt == DHCP_OPTION_PAD) continue; /* * If its an end-of-options indicator, bail out */ if (opt == DHCP_OPTION_END) break; /* * Otherwise, grab and dump the length */ if (get_packet_bytes((u_int8_t *) &len, pkt, 1) == 0) return; if (!my_args->m) display(" Length", (u_int8_t *) &len, 1, DISP_DEC); switch(opt) { case DHCP_OPTION_NETMASK: /* 1 */ if (get_packet_bytes((u_int8_t *) holder, pkt, len) == 0) return; if (!my_args->m) display_ipv4(" Mask", (u_int8_t *) holder); break; case DHCP_OPTION_TIMEOFFSET: /* 2 */ if (get_packet_bytes((u_int8_t *) holder, pkt, len) == 0) return; if (!my_args->m) display(" Offset", (u_int8_t *) holder, len, DISP_DEC); break; case DHCP_OPTION_ROUTER: /* 3 */ case DHCP_OPTION_TIMESERVER: /* 4 */ case DHCP_OPTION_NAMESERVER: /* 5 */ case DHCP_OPTION_DNS: /* 6 */ case DHCP_OPTION_LOGSERVER: /* 7 */ case DHCP_OPTION_COOKIESERVER: /* 8 */ case DHCP_OPTION_LPRSERVER: /* 9 */ case_DHCP_OPTION_IMPRESSSERVER: /* 10 */ case_DHCP_OPTION_RESLOCSERVER: /* 11 */ case_DHCP_OPTION_SWAPSERVER: /* 16 */ case DHCP_OPTION_NETBIOSNAMESERV: /* 44 */ j = 0; while (j < len / 4) { if (get_packet_bytes((u_int8_t *) holder, pkt, 4) == 0) return; if (!my_args->m) display_ipv4(" Address", (u_int8_t *) holder); j++; } break; case DHCP_OPTION_HOSTNAME: /* 12 */ if (get_packet_bytes((u_int8_t *) holder, pkt, len) == 0) return; holder[len] = '\0'; if (!my_args->m) display(" Host name", (u_int8_t *) holder, strlen(holder), DISP_STRING); break; case DHCP_OPTION_DOMAINNAME: /* 15 */ if (get_packet_bytes((u_int8_t *) holder, pkt, len) == 0) return; holder[len] = '\0'; if (!my_args->m) display(" Domain name", (u_int8_t *) holder, strlen(holder), DISP_STRING); break; case DHCP_OPTION_VENDORSPECIFIC: /* 43 */ if (get_packet_bytes((u_int8_t *) holder, pkt, len) == 0) return; if (!my_args->m) display(" Parameters", (u_int8_t *) holder, len, DISP_HEX); break; case DHCP_OPTION_NETBIOSNODETYPE: /* 46 */ if (get_packet_bytes((u_int8_t *) holder, pkt, len) == 0) return; switch(holder[0]) { case 0x1: snprintf(holder, HOLDER_SIZE, "0x%x (B-node / broadcast)", holder[0]); break; case 0x2: snprintf(holder, HOLDER_SIZE, "0x%x (P-node / point to point)", holder[0]); break; case 0x4: snprintf(holder, HOLDER_SIZE, "0x%x (M-node / mixed)", holder[0]); break; case 0x8: snprintf(holder, HOLDER_SIZE, "0x%x (H-node)", holder[0]); break; } if (!my_args->m) display_string("Node type", holder); break; case DHCP_OPTION_REQUESTEDIPADDR: /* 50 */ if (get_packet_bytes((u_int8_t *) holder, pkt, len) == 0) return; if (!my_args->m) display_ipv4(" Address", (u_int8_t *) holder); else { display_minimal_ipv4((u_int8_t *) holder); display_minimal_string(" "); } break; case DHCP_OPTION_IPADDRLEASE: /* 51 */ if (get_packet_bytes((u_int8_t *) holder, pkt, 4) == 0) return; if (!my_args->m) display(" Lease time", (u_int8_t *) holder, 4, DISP_DEC); break; case DHCP_OPTION_MESSAGETYPE: /* 53 */ { u_int8_t msg_type; if (get_packet_bytes(&msg_type, pkt, 1) == 0) return; snprintf(holder, HOLDER_SIZE, "%d (%s)", msg_type, map2str(dhcp_msgtype_map, msg_type)); if (!my_args->m) display_string(" Message type", holder); else { display_minimal_string(map2str(dhcp_msgtype_map, msg_type)); display_minimal_string(" "); } } break; case DHCP_OPTION_SERVERID: /* 54 */ if (get_packet_bytes((u_int8_t *) holder, pkt, len) == 0) return; if (!my_args->m) display_ipv4(" Address", (u_int8_t *) holder); break; case DHCP_OPTION_PARAMREQLIST: /* 55 */ for (i=0; i < len; i++) { u_int8_t opt; if (get_packet_bytes((u_int8_t *) &opt, pkt, 1) == 0) return; if (!my_args->m) { snprintf(holder, HOLDER_SIZE, "%d (%s)", opt, map2str(dhcp_option_map, opt)); display_string(" Option", holder); } } break; case DHCP_OPTION_MAXDHCPMSGSIZE: /* 57 */ if (get_packet_bytes((u_int8_t *) holder, pkt, len) == 0) return; /* * Conversion */ *holder = ntohs ( *holder ); if (!my_args->m) display(" Size", (u_int8_t *) holder, 2, DISP_DEC); break; case DHCP_OPTION_RENEWALTIME: /* 58 */ { u_int32_t renewal_time; if (get_packet_bytes((u_int8_t *) &renewal_time, pkt, len) == 0) return; renewal_time = ntohl(renewal_time); if (!my_args->m) display(" Renewal time", (u_int8_t *) &renewal_time, 4, DISP_DEC); } break; case DHCP_OPTION_REBINDINGTIME: /* 59 */ { u_int32_t rebinding_time; if (get_packet_bytes((u_int8_t *) &rebinding_time, pkt, len) == 0) return; rebinding_time = ntohl(rebinding_time); if (!my_args->m) display(" Rebinding time", (u_int8_t *) &rebinding_time, 4, DISP_DEC); } break; case DHCP_OPTION_VENDORCLASSID: /* 60 */ if (get_packet_bytes((u_int8_t *) holder, pkt, len) == 0) return; if (!my_args->m) display(" Parameters", (u_int8_t *) holder, len, DISP_HEX); break; case DHCP_OPTION_CLIENTID: /* 61 */ if (!my_args->m) { u_int8_t hw_type; /* The first byte should be a hardware type */ if (get_packet_bytes((u_int8_t *) &hw_type, pkt, 1) == 0) return; snprintf(holder, HOLDER_SIZE, "%d (%s)", hw_type, map2str(arp_hardware_map, hw_type)); display_string(" Hardware type", (u_int8_t *) holder); /* If its ethernet, display it as such, otherwise punt */ if (hw_type == ARP_HWTYPE_ETHERNET) { if (get_packet_bytes((u_int8_t *) holder, pkt, len-1) == 0) return; display(" Hardware address", (u_int8_t *) holder, len-1, DISP_HEXCOLONS); } else { if (get_packet_bytes((u_int8_t *) holder, pkt, len-1) == 0) return; display(" Hardware address", (u_int8_t *) holder, len-1, DISP_HEX); } } else { /* In minimal mode, we'll just grab the parameter and continue */ if (get_packet_bytes((u_int8_t *) holder, pkt, len) == 0) return; } break; default: break; /* do nothing for now */ } /* switch */ } /* while */ /* dump the hex buffer */ hexbuffer_flush(); } ipgrab-0.9.10/src/dhcp.h0000644000175000001440000001200410637736166014145 0ustar farooqusers/**************************************************************************** ** File: dhcp.h ** ** Author: Mike Borella ** ** Comments: Structure of DHCP packets ** ** $Id: dhcp.h,v 1.8 2007/06/25 13:00:38 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef DHCP_H #define DHCP_H #include "global.h" #include "local.h" #define DHCP_OP_BOOTREQUEST 1 #define DHCP_OP_BOOTREPLY 2 #define BOOTP_COOKIE 0x63825363 #define DHCP_OPTION_PAD 0 #define DHCP_OPTION_NETMASK 1 #define DHCP_OPTION_TIMEOFFSET 2 #define DHCP_OPTION_ROUTER 3 #define DHCP_OPTION_TIMESERVER 4 #define DHCP_OPTION_NAMESERVER 5 #define DHCP_OPTION_DNS 6 #define DHCP_OPTION_LOGSERVER 7 #define DHCP_OPTION_COOKIESERVER 8 #define DHCP_OPTION_LPRSERVER 9 #define DHCP_OPTION_IMPRESSSERVER 10 #define DHCP_OPTION_RESLOCSERVER 11 #define DHCP_OPTION_HOSTNAME 12 #define DHCP_OPTION_BOOTFILESIZE 13 #define DHCP_OPTION_MERITDUMP 14 #define DHCP_OPTION_DOMAINNAME 15 #define DHCP_OPTION_SWAPSERVER 16 #define DHCP_OPTION_ROOTPATH 17 #define DHCP_OPTION_EXTSPATH 18 #define DHCP_OPTION_IPFORWARD 19 #define DHCP_OPTION_NONLOCALSR 20 #define DHCP_OPTION_POLICYFILTER 21 #define DHCP_OPTION_MAXREASSEMBLE 22 #define DHCP_OPTION_IPTTL 23 #define DHCP_OPTION_PATHMTUAGING 24 #define DHCP_OPTION_PATHMTUPLATEAU 25 #define DHCP_OPTION_INTERFACEMTU 26 #define DHCP_OPTION_SUBNETSLOCAL 27 #define DHCP_OPTION_BCASTADDRESS 28 #define DHCP_OPTION_MASKDISCOVERY 29 #define DHCP_OPTION_MASKSUPPLIER 30 #define DHCP_OPTION_ROUTERDISCOVERY 31 #define DHCP_OPTION_ROUTERSOLIC 32 #define DHCP_OPTION_STATICROUTE 33 #define DHCP_OPTION_TRAILERENCAPS 34 #define DHCP_OPTION_ARPTIMEOUT 35 #define DHCP_OPTION_ETHERNETENCAPS 36 #define DHCP_OPTION_TCPTTL 37 #define DHCP_OPTION_TCPKEEPALIVEINT 38 #define DHCP_OPTION_TCPKEEPALIVEGRBG 39 #define DHCP_OPTION_NISDOMAIN 40 #define DHCP_OPTION_NISSERVERS 41 #define DHCP_OPTION_NTPSERVERS 42 #define DHCP_OPTION_VENDORSPECIFIC 43 #define DHCP_OPTION_NETBIOSNAMESERV 44 #define DHCP_OPTION_NETBIOSDGDIST 45 #define DHCP_OPTION_NETBIOSNODETYPE 46 #define DHCP_OPTION_NETBIOSSCOPE 47 #define DHCP_OPTION_X11FONTS 48 #define DHCP_OPTION_X11DISPLAYMNGR 49 #define DHCP_OPTION_REQUESTEDIPADDR 50 #define DHCP_OPTION_IPADDRLEASE 51 #define DHCP_OPTION_OVERLOAD 52 #define DHCP_OPTION_MESSAGETYPE 53 #define DHCP_OPTION_SERVERID 54 #define DHCP_OPTION_PARAMREQLIST 55 #define DHCP_OPTION_MESSAGE 56 #define DHCP_OPTION_MAXDHCPMSGSIZE 57 #define DHCP_OPTION_RENEWALTIME 58 #define DHCP_OPTION_REBINDINGTIME 59 #define DHCP_OPTION_VENDORCLASSID 60 #define DHCP_OPTION_CLIENTID 61 #define DHCP_OPTION_NISPLUSDOMAIN 64 #define DHCP_OPTION_NISPLUSSERVERS 65 #define DHCP_OPTION_TFTPSERVER 66 #define DHCP_OPTION_BOOTFILE 67 #define DHCP_OPTION_MOBILEIPHOME 68 #define DHCP_OPTION_SMTPSERVER 69 #define DHCP_OPTION_POP3SERVER 70 #define DHCP_OPTION_NNTPSERVER 71 #define DHCP_OPTION_WWWSERVER 72 #define DHCP_OPTION_FINGERSERVER 73 #define DHCP_OPTION_IRCSERVER 74 #define DHCP_OPTION_STSERVER 75 #define DHCP_OPTION_STDASERVER 76 #define DHCP_OPTION_USERCLASS 77 #define DHCP_OPTION_SLPDIRAGENT 78 #define DHCP_OPTION_END 255 /* * DHCP message types */ #define DHCP_MSGTYPE_DISCOVER 1 #define DHCP_MSGTYPE_OFFER 2 #define DHCP_MSGTYPE_REQUEST 3 #define DHCP_MSGTYPE_DECLINE 4 #define DHCP_MSGTYPE_ACK 5 #define DHCP_MSGTYPE_NAK 6 #define DHCP_MSGTYPE_RELEASE 7 #define DHCP_MSGTYPE_INFORM 8 /* * DHCP header */ typedef struct dhcp_header { /* No need for this #if defined(WORDS_BIGENDIAN) u_int8_t hops; u_int8_t hlen; u_int8_t htype; u_int8_t op; #else */ u_int8_t op; u_int8_t htype; u_int8_t hlen; u_int8_t hops; /* #endif */ u_int32_t xid; u_int16_t secs; u_int16_t flags; u_int32_t ciaddr; u_int32_t yiaddr; u_int32_t siaddr; u_int32_t giaddr; char chaddr [16]; char sname [64]; char file [128]; } dhcp_header_t; void dump_dhcp(packet_t *); #endif ipgrab-0.9.10/src/display.c0000644000175000001440000003334310637712425014670 0ustar farooqusers/**************************************************************************** ** File: display.c ** ** Author: Mike Borella ** ** Comments: Displaying functions ** ** $Id: display.c,v 1.34 2007/06/25 10:12:37 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "display.h" #define LABEL_LENGTH 22 #define MULTILINE_LENGTH 23 #define MULTILINE_STRING_LENGTH 48 #define BUF_SIZE 128 #define HOLDER_LEN 64 int packet_displayed; int start_of_packet; extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** display_header_line() ** ** Writes out a line of separators (separators defined in headerline_t) ** **---------------------------------------------------------------------------- */ inline void display_header_line(headerline_t hl) { /* Check the layer */ if (check_layer()) return; switch(hl) { case HEADERLINE_DASHES: printf("--------------------------------------------------------------------------\n"); break; case HEADERLINE_STARS: printf("**************************************************************************\n"); break; case HEADERLINE_EQUALS: printf("==========================================================================\n"); break; case HEADERLINE_DOTS: printf("..........................................................................\n"); break; default: error_fatal("unknown header line type"); } } /*---------------------------------------------------------------------------- ** ** display_whitespace_pad() ** ** Pad the output with a pre-determined number of spaces from the label to ** the output. The input parameter is the length of the label. ** **---------------------------------------------------------------------------- */ inline void display_whitespace_pad(int length) { int i; /* Check the layer */ if (check_layer()) return; for (i=0; i < LABEL_LENGTH+1-length; i++) putchar(' '); } /*---------------------------------------------------------------------------- ** ** display_header_banner_ts() ** ** Writes out a generic header banner with timestamp for protocol headers. ** ** ISSUE: Do we want to limit the length of the banner string so that it ** doesn't run off the screen? ** **---------------------------------------------------------------------------- */ inline void display_header_banner_ts(char *banner, char *ts) { /* Check the layer */ if (check_layer()) return; if (start_of_packet) { display_header_line(HEADERLINE_STARS); start_of_packet = 0; } else display_header_line(HEADERLINE_DASHES); printf(" %s", banner); printf("\n"); if (ts != NULL) { display_whitespace_pad ( 0 ); printf ( " %s ", ts ); } display_header_line(HEADERLINE_DASHES); } /*---------------------------------------------------------------------------- ** ** display_header_banner() ** ** Writes out a generic header banner for protocol headers. ** **---------------------------------------------------------------------------- */ inline void display_header_banner(char * banner) { display_header_banner_ts(banner, NULL); } /*---------------------------------------------------------------------------- ** ** display() ** ** Display a protocol field or some other string according to our rules ** ** Parameters: ** label - always printed, must be null terminated string ** content - the stuff to display, usually the value of the field ** length - the number of bytes to display from the content parameter ** format - the specific format to use when displaying ** **---------------------------------------------------------------------------- */ inline void display(char * label, u_int8_t * content, u_int32_t length, display_t format) { int label_len; char label_truncated[LABEL_LENGTH+1]; /* Check the layer */ if (check_layer()) return; /* * Do sanity checks here */ label_len = strlen(label); if (label_len >= LABEL_LENGTH) { strncpy(label_truncated, label, LABEL_LENGTH); label_truncated[LABEL_LENGTH] = '\0'; label_len = LABEL_LENGTH; printf("%s:", label_truncated); } else printf("%s:", label); /* * Do the actual displaying */ display_whitespace_pad(label_len); display_minimal(content, length, format); /* * Trailing printf() */ printf("\n"); } /*---------------------------------------------------------------------------- ** ** display_minimal() ** ** Display a protocol field or some other string in minimal mode. ** This means that there is no label, no padding, and no carriage return. ** ** Parameters: ** content - the stuff to display, usually the value of the field ** length - the number of bytes to display from the content parameter ** format - the specific format to use when displaying ** **---------------------------------------------------------------------------- */ inline void display_minimal(u_int8_t * content, u_int32_t length, display_t format) { int i,j; int seen_a_one; u_int8_t bit_holder; struct in_addr * ip_holder; u_int8_t * ptr; u_int8_t * temp; double sum; u_int32_t multiplier; int len; /* Check the layer */ if (check_layer()) return; /* * We have displayed part of this packet, so we need a carriage return. */ packet_displayed = 1; /* * Depending on the display format, we may do different things */ switch(format) { case DISP_DEC: temp = (u_int8_t *) my_malloc(length); memcpy(temp, content, length); #if !defined(WORDS_BIGENDIAN) reverse_byte_order(temp, length); #endif sum = 0.0; multiplier = 1; for (i = length-1; i >= 0; i--) { ptr = temp+i; sum += (double) (multiplier * *ptr); multiplier = multiplier * 256; } printf("%.0f", sum); my_free(temp); break; case DISP_DOTTEDDEC: ip_holder = (struct in_addr *) content; for (i=0; i<4; i++) if (i==3) printf("%d", content[i]); else printf("%d.", content[i]); break; case DISP_HEX: printf("0x"); for (i=0; i < length; i++) { if (content[i] < 16) printf("0%x", content[i]); else printf("%x", content[i]); } break; case DISP_HEX_MULTILINE: printf("0x"); for (i=0; i < length; i++) { if ((i > 0) && (i % MULTILINE_LENGTH == 0)) { printf("\n"); display_whitespace_pad(-3); } if (content[i] < 16) printf("0%x", content[i]); else printf("%x", content[i]); } break; case DISP_HEXCOLONS: for (i=0; i < length; i++) { if (content[i] < 16) printf("0%x", content[i]); else printf("%x", content[i]); if (i != length-1) printf(":"); } break; case DISP_HEXCOLONS4: for (i=0; i < length; i++) { if ( content [ i ] < 0x10 ) printf("0%x", content[i]); else printf("%x", content[i]); if (i % 2 == 1 && i != length - 1) printf(":"); } break; case DISP_BINNLZ: seen_a_one = 0; for (i=0; i < length; i++) { bit_holder = 128; for (j=1; j<=8; j++) { if (content[i] & bit_holder) { seen_a_one = 1; printf("1"); } else { if (seen_a_one || (i == length -1 && j == 8)) printf("0"); } bit_holder = bit_holder >> 1; } } break; case DISP_BIN: for (i = 0; i < length; i++) { bit_holder = 0x80; for (j = 1; j <= 8; j++) { if (content[i] & bit_holder) printf ( "1" ); else printf ( "0" ); bit_holder = bit_holder >> 1; } } break; case DISP_STRING: /* * Rather than just ass-u-ming that we've been handed a properly * null terminated string, we created one of our own. * * Make sure that ONLY printable characters are sent in this call, * Otherwise, very strnage bugs will occur! For example, send this * code a \n and just try to figure out why your output is screwy... * */ ptr = (u_int8_t *) my_malloc(length+1); memcpy(ptr, content, length); ptr[length] = '\0'; /* Clean out extra control characters */ len = strlen(ptr); while((ptr[len-1] == '\n' || ptr[len-1] == '\r') && len >= 1) { ptr[len-1] = '\0'; len--; } /* * Let's make sure that the string contains only printable * characters */ if (!isprint_str(ptr, len)) { my_free(ptr); break; } /* print it then free it */ printf("%s", ptr); my_free(ptr); break; case DISP_STRING_MULTILINE: /* I'm sure that this could be made much more efficient... */ for (i=0; i < length; i++) { if ((i > 0) && (i % MULTILINE_STRING_LENGTH == 0)) { printf("\n"); display_whitespace_pad(-3); } printf("%c", content[i]); } break; default: /* oops, this shouldn't happen... */ break; } } /*---------------------------------------------------------------------------- ** ** display_minimal_string() ** ** Same as display_minimal() but we assume that the content argument is ** a string. ** **---------------------------------------------------------------------------- */ inline void display_minimal_string(u_int8_t * content) { display_minimal(content, strlen(content), DISP_STRING); } /*---------------------------------------------------------------------------- ** ** display_string() ** ** Same as display() but we assume that the content argument is ** a string. We also assume multiline support is required. ** **---------------------------------------------------------------------------- */ inline void display_string(u_int8_t * label, u_int8_t * content) { display(label, content, strlen(content), DISP_STRING_MULTILINE); } /*---------------------------------------------------------------------------- ** ** display_strmap() ** ** Display an item from a strmap_t array, with proper expansion of its ** textual representation. ** **---------------------------------------------------------------------------- */ inline void display_strmap(char * label, int content, strmap_t map[]) { char holder[HOLDER_LEN]; snprintf(holder, HOLDER_LEN, "%d (%s)", content, map2str(map, content)); holder[HOLDER_LEN-1] = '\0'; display_string(label, holder); } /*---------------------------------------------------------------------------- ** ** display_strmap_hex() ** ** Display an item from a strmap_t array, with proper expansion of its ** textual representation. The number appears in hex format rather than ** decimal. ** **---------------------------------------------------------------------------- */ inline void display_strmap_hex(char * label, int content, strmap_t map[]) { char holder[HOLDER_LEN]; snprintf(holder, HOLDER_LEN, "0x%x (%s)", content, map2str(map, content)); holder[HOLDER_LEN-1] = '\0'; display_string(label, holder); } /*---------------------------------------------------------------------------- ** ** display_ipv4() ** ** Same as display() but we assume that the content argument is ** a 4-byte IPv4 address. ** **---------------------------------------------------------------------------- */ inline void display_ipv4(u_int8_t * label, u_int8_t * addr) { display(label, addr, 4, DISP_DOTTEDDEC); } /*---------------------------------------------------------------------------- ** ** display_ipv6() ** ** Same as display() but we assume that the content argument is ** a 16-byte IPv6 address. ** **---------------------------------------------------------------------------- */ inline void display_ipv6(u_int8_t * label, u_int8_t * addr) { display(label, addr, 16, DISP_HEXCOLONS4); } /*---------------------------------------------------------------------------- ** ** display_minimal_ipv4() ** ** Same as display_minimal() but we assume that the content argument is ** a 4-byte IPv4 address. ** **---------------------------------------------------------------------------- */ inline void display_minimal_ipv4(u_int8_t * content) { display_minimal(content, 4, DISP_DOTTEDDEC); } /*---------------------------------------------------------------------------- ** ** display_minimal_ipv6() ** ** Same as display_minimal() but we assume that the content argument is ** a 16-byte IPv6 address. ** **---------------------------------------------------------------------------- */ inline void display_minimal_ipv6(u_int8_t * content) { display_minimal(content, 16, DISP_HEXCOLONS4); } /*---------------------------------------------------------------------------- ** ** display_minimal_cr() ** ** Display a carriage return (actually, this will work for regular mode as ** well). ** **---------------------------------------------------------------------------- */ inline void display_minimal_cr(void) { /* Check the layer */ if (check_layer()) return; printf("\n"); } ipgrab-0.9.10/src/display.h0000644000175000001440000000543310530527425014670 0ustar farooqusers/**************************************************************************** ** File: display.h ** ** Author: Mike Borella ** ** Comments: Header file for displaying functions ** ** $Id: display.h,v 1.23 2006/11/21 07:47:33 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef DISPLAY_H #define DISPLAY_H #include "global.h" #include "strmap.h" #include "utilities.h" #include "layers.h" #include "error.h" /* * Display format types */ typedef enum display { DISP_DEC, /* Display and arbitrary decimal value */ DISP_BIN, /* Binary format with leading 0's (01101110) */ DISP_BINNLZ, /* Binary format w/o leading 0's (1101110) */ DISP_HEX, /* 2 bytes, hex (0F) */ DISP_HEX_MULTILINE, /* Hex output spanning more than one line */ DISP_HEXCOLONS, /* Hex bytes separated by colons (0F:7A:B1) */ DISP_HEXCOLONS4, /* 4 Hex bytes between colons */ DISP_DOTTEDDEC, /* Dotted decimal (IP address) format (4 bytes only) */ DISP_STRING, /* Plain old ascii string */ DISP_STRING_MULTILINE /* String output spanning more than one line */ } display_t; /* * Header line types */ typedef enum headerline { HEADERLINE_DASHES, HEADERLINE_STARS, HEADERLINE_EQUALS, HEADERLINE_DOTS, } headerline_t; /* * Function prototypes */ inline void display_header_line (headerline_t); inline void display_header_banner (char *); inline void display_header_banner_ts(char *, char *); inline void display (char *, u_int8_t *, u_int32_t, display_t); inline void display_string (u_int8_t *, u_int8_t *); inline void display_strmap(char *, int, strmap_t *map); inline void display_strmap_hex(char *, int, strmap_t *map); inline void display_ipv4 (u_int8_t *, u_int8_t *); inline void display_ipv6 (u_int8_t *, u_int8_t *); inline void display_minimal (u_int8_t *, u_int32_t, display_t); inline void display_minimal_string (u_int8_t *); inline void display_minimal_ipv4 (u_int8_t *); inline void display_minimal_ipv6 (u_int8_t *); inline void display_minimal_cr(void); #endif ipgrab-0.9.10/src/dns.c0000644000175000001440000002375007414717761014017 0ustar farooqusers/**************************************************************************** ** File: dns.c ** ** Author: Mike Borella ** ** Comments: Dump DNS header information ** ** $Id: dns.c,v 1.21 2002/01/03 00:04:01 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "dns.h" #include "ns_labels.h" #define HOLDER_SIZE 256 /* * QR flag map */ strmap_t dns_qrflag_map [] = { { DNS_QRFLAG_QUERY, "query" }, { DNS_QRFLAG_RESPONSE, "response" }, { 0, "" } }; /* * Opcode flag map */ strmap_t dns_opcodeflag_map [] = { { DNS_OPCODEFLAG_STANDARD, "standard" }, { DNS_OPCODEFLAG_INVERSE, "inverse" }, { DNS_OPCODEFLAG_STATUS, "status" }, { 0, "" } }; /* * Rcode (return code) flag map */ strmap_t dns_rcodeflag_map [] = { { DNS_RCODEFLAG_NOERROR, "no error" }, { DNS_RCODEFLAG_FORMATERROR, "format error" }, { DNS_RCODEFLAG_SERVERERROR, "server error" }, { DNS_RCODEFLAG_NAMEERROR, "name error" }, { DNS_RCODEFLAG_NOTIMPLEMENTED, "not implemented" }, { DNS_RCODEFLAG_SERVICEREFUSED, "service refused" }, { 0, "" } }; /* * Query type map */ strmap_t dns_querytype_map [] = { { DNS_QUERYTYPE_A, "A - IP address" }, { DNS_QUERYTYPE_NS, "NS - name server" }, { DNS_QUERYTYPE_CNAME, "CNAME - canonical name" }, { DNS_QUERYTYPE_SOA, "SOA - start of auth record" }, { DNS_QUERYTYPE_PTR, "PTR - pointer record" }, { DNS_QUERYTYPE_HINFO, "HINFO - host info" }, { DNS_QUERYTYPE_MX, "MX - mail exchange record" }, { DNS_QUERYTYPE_AAAA, "AAAA - IPv6 address" }, { DNS_QUERYTYPE_AXFR, "AXFR - zone transfer request" }, { DNS_QUERYTYPE_ANY, "ANY - all records request" }, { 0, "" } }; /* * Query class map */ strmap_t dns_queryclass_map [] = { { DNS_QUERYCLASS_IP, "Internet" }, { 0, "" } }; extern struct arg_t *my_args; /*---------------------------------------------------------------------------- ** ** dump_dns_questions() ** ** Parse DNS questions and display them ** **---------------------------------------------------------------------------- */ void dump_dns_questions(packet_t *pkt, u_int8_t num) { char holder[HOLDER_SIZE]; u_int16_t query_type, query_class; while(num > 0) { /* * Parse the name */ parse_ns_labels(pkt, holder); /* * Parse the query type and class */ if (get_packet_bytes((u_int8_t *) &query_type, pkt, 2) == 0) return; if (get_packet_bytes((u_int8_t *) &query_class, pkt, 2) == 0) return; /* * Conversions */ query_type = ntohs(query_type); query_class = ntohs(query_class); /* * Dump the info */ if (my_args->m) { display_minimal_string(holder); display_minimal_string(" "); } else { display_string("Query", holder); snprintf(holder, HOLDER_SIZE, "%d (%s)", query_type, map2str(dns_querytype_map, query_type)); display_string(" Query type", holder); snprintf(holder, HOLDER_SIZE, "%d (%s)", query_class, map2str(dns_queryclass_map, query_class)); display_string(" Query class", holder); } num --; } } /*---------------------------------------------------------------------------- ** ** dump_dns_answers() ** ** Parse DNS answers and display them ** **---------------------------------------------------------------------------- */ void dump_dns_answers(packet_t *pkt, u_int8_t num, char *answer_type) { char holder[HOLDER_SIZE]; u_int16_t query_type, query_class; u_int32_t ttl; u_int16_t rdl; u_int8_t resource_data[64]; while(num > 0) { /* * Parse the name */ parse_ns_labels(pkt, holder); /* * Parse the query type and class */ if (get_packet_bytes((u_int8_t *) &query_type, pkt, 2) == 0) return; if (get_packet_bytes((u_int8_t *) &query_class, pkt, 2) == 0) return; if (get_packet_bytes((u_int8_t *) &ttl, pkt, 4) == 0) return; if (get_packet_bytes((u_int8_t *) &rdl, pkt, 2) == 0) return; /* * Conversions */ query_type = ntohs(query_type); query_class = ntohs(query_class); ttl = ntohl(ttl); rdl = ntohs(rdl); /* * Get the resource data */ switch (query_type) { case DNS_QUERYTYPE_NS: case DNS_QUERYTYPE_CNAME: case DNS_QUERYTYPE_SOA: case DNS_QUERYTYPE_PTR: parse_ns_labels(pkt, resource_data); break; case DNS_QUERYTYPE_A: default: if (get_packet_bytes((u_int8_t *) &resource_data, pkt, rdl) == 0) return; break; } /* * Dump the info */ if (my_args->m) { if (query_type == DNS_QUERYTYPE_A && !strcmp(answer_type, "Answers")) { display_minimal_ipv4((u_int8_t *) resource_data); display_minimal_string(" "); } if (query_type == DNS_QUERYTYPE_AAAA && !strcmp(answer_type, "Answers") && rdl == 16 ) { display_minimal_ipv6((u_int8_t *) resource_data); display_minimal_string(" "); } } else { display_string(answer_type, holder); snprintf(holder, HOLDER_SIZE, "%d (%s)", query_type, map2str(dns_querytype_map, query_type)); display_string(" Query type", holder); snprintf(holder, HOLDER_SIZE, "%d (%s)", query_class, map2str(dns_queryclass_map, query_class)); display_string(" Query class", holder); display(" TTL", (u_int8_t *) &ttl, 4, DISP_DEC); display(" Resource data length", (u_int8_t *) &rdl, 2, DISP_DEC); switch(query_type) { case DNS_QUERYTYPE_A: display_ipv4(" Resource data", (u_int8_t *) resource_data); break; case DNS_QUERYTYPE_AAAA: display_ipv6(" Resource data", (u_int8_t *) resource_data); break; case DNS_QUERYTYPE_NS: case DNS_QUERYTYPE_CNAME: case DNS_QUERYTYPE_SOA: case DNS_QUERYTYPE_PTR: display_string(" Resource data", resource_data); break; default: display(" Resource data", (u_int8_t *) resource_data, rdl, DISP_HEX); } } num --; } } /*---------------------------------------------------------------------------- ** ** dump_dns() ** ** Parse DNS packet and dump fields ** **---------------------------------------------------------------------------- */ void dump_dns(packet_t *pkt) { dns_header_t dns; u_int8_t f_qr, f_opcode, f_aa, f_tc, f_rd, f_ra, f_zero, f_rcode; char holder[HOLDER_SIZE]; /* Set the layer */ set_layer(LAYER_APPLICATION); /* * Mark the beginning of the DNS portion so that labels can be stored * properly */ set_packet_mark(pkt); /* * Reset the DNS labels structures for a new DNS packet */ reset_nslabels(); /* * Get the header */ if (get_packet_bytes((u_int8_t *) &dns, pkt, 12) == 0) return; /* * Conversions */ dns.id = ntohs(dns.id); dns.number_questions = ntohs(dns.number_questions); dns.number_answers = ntohs(dns.number_answers); dns.number_authority = ntohs(dns.number_authority); dns.number_additional = ntohs(dns.number_additional); f_qr = dns.flag_qr; f_opcode = dns.flag_opcode; f_aa = dns.flag_aa; f_tc = dns.flag_tc; f_rd = dns.flag_rd; f_ra = dns.flag_ra; f_zero = dns.flag_zero; f_rcode = dns.flag_rcode; /* * Print it */ if (my_args->m) { display_minimal_string("| DNS "); display_minimal_string(map2str(dns_qrflag_map, f_qr)); display_minimal_string(" "); } else { /* announcement */ display_header_banner("DNS Header"); /* identification */ display("Identification", (u_int8_t *) &dns.id, 2, DISP_DEC); /* flags */ snprintf(holder, HOLDER_SIZE, "%d (%s)", f_qr, map2str(dns_qrflag_map, f_qr)); display_string("Flag query/response", holder); snprintf(holder, HOLDER_SIZE, "%d (%s)", f_opcode, map2str(dns_opcodeflag_map, f_opcode)); display_string("Flag opcode", holder); display("Flag auth answer", (u_int8_t *) &f_aa, 1, DISP_BINNLZ); display("Flag trunctated", (u_int8_t *) &f_tc, 1, DISP_BINNLZ); display("Flag recursion desired", (u_int8_t *) &f_ra, 1, DISP_BINNLZ); display("Flag recursion available", (u_int8_t *) &f_ra, 1, DISP_BINNLZ); display("Flag zero", (u_int8_t *) &f_zero, 1, DISP_BINNLZ); snprintf(holder, HOLDER_SIZE, "%d (%s)", f_rcode, map2str(dns_rcodeflag_map, f_rcode)); display_string("Flag return code", holder); /* numbers of questions and answers */ display("# of questions", (u_int8_t *) &dns.number_questions, 2, DISP_DEC); display("# of answers", (u_int8_t *) &dns.number_answers, 2, DISP_DEC); display("# of authorization RRs", (u_int8_t *) &dns.number_authority, 2, DISP_DEC); display("# of additional RRs", (u_int8_t *) &dns.number_additional, 2, DISP_DEC); } /* * Parse the question and answers */ dump_dns_questions(pkt, dns.number_questions); dump_dns_answers(pkt, dns.number_answers, "Answers"); dump_dns_answers(pkt, dns.number_authority, "Auth answers"); dump_dns_answers(pkt, dns.number_additional, "Addtl answers"); /* dump the hex buffer */ hexbuffer_flush(); } ipgrab-0.9.10/src/dns.h0000644000175000001440000000527207153266450014015 0ustar farooqusers/**************************************************************************** ** File: dns.h ** ** Author: Mike Borella ** ** Structure of the first 12 bytes of DNS packets ** ** $Id: dns.h,v 1.9 2000/08/30 20:23:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ****************************************************************************/ #ifndef DNS_H #define DNS_H #include "global.h" #include "local.h" typedef struct dns_header { u_int16_t id; #if defined (WORDS_BIGENDIAN) u_int16_t flag_qr:1, flag_opcode:4, flag_aa:1, flag_tc:1, flag_rd:1, flag_ra:1, flag_zero:3, flag_rcode:4; #else u_int16_t flag_rcode:4, flag_zero:3, flag_ra:1, flag_rd:1, flag_tc:1, flag_aa:1, flag_opcode:4, flag_qr:1; #endif u_int16_t number_questions; u_int16_t number_answers; u_int16_t number_authority; u_int16_t number_additional; } dns_header_t; /* * Query/response flag */ #define DNS_QRFLAG_QUERY 0 #define DNS_QRFLAG_RESPONSE 1 /* * Opcode flag */ #define DNS_OPCODEFLAG_STANDARD 0 #define DNS_OPCODEFLAG_INVERSE 1 #define DNS_OPCODEFLAG_STATUS 2 /* * Rcode (return code) flag */ #define DNS_RCODEFLAG_NOERROR 0 #define DNS_RCODEFLAG_FORMATERROR 1 #define DNS_RCODEFLAG_SERVERERROR 2 #define DNS_RCODEFLAG_NAMEERROR 3 #define DNS_RCODEFLAG_NOTIMPLEMENTED 4 #define DNS_RCODEFLAG_SERVICEREFUSED 5 /* * Query type */ #define DNS_QUERYTYPE_A 1 #define DNS_QUERYTYPE_NS 2 #define DNS_QUERYTYPE_CNAME 5 #define DNS_QUERYTYPE_SOA 6 #define DNS_QUERYTYPE_PTR 12 #define DNS_QUERYTYPE_HINFO 13 #define DNS_QUERYTYPE_MX 15 #define DNS_QUERYTYPE_AAAA 28 #define DNS_QUERYTYPE_AXFR 252 #define DNS_QUERYTYPE_ANY 255 /* * Query class */ #define DNS_QUERYCLASS_IP 1 void dump_dns(packet_t *); #endif ipgrab-0.9.10/src/dynports.c0000644000175000001440000001334310637713266015107 0ustar farooqusers/**************************************************************************** ** ** File: dynports.c ** ** Author: Mike Borella ** ** Comments: Support for dynamic port mapping. This allows a protocol to ** to listened for on a non-standard port. Each mapping is assigned a ** duration. Mappings that are user defined via the command line are ** considered permanent. Mappings that are made by protocols will time out ** in DYNPORTS_DURATION seconds unless they are refreshed. ** ** $Id: dynports.c,v 1.8 2007/06/25 10:19:34 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "dynports.h" #include "error.h" #include #define DYNPORTS_NUM 256/* max number of dynamic ports on the system */ #define DYNPORTS_DURATION 5 /* # of seconds that nonpermanent mappings stay */ typedef struct portmap { u_int16_t port; service_func_t f; unsigned long t; } portmap_t; static portmap_t dynport_map[DYNPORTS_NUM]; static int current_ptr = 0; /*---------------------------------------------------------------------------- ** ** dynports_add() ** ** Adds a dynamic port mapping ** **---------------------------------------------------------------------------- */ void dynports_add(u_int16_t port, service_func_t f, unsigned long t) { if (current_ptr >= DYNPORTS_NUM) error_fatal("too many dynamic port mappings"); dynport_map[current_ptr].port = port; dynport_map[current_ptr].f = f; dynport_map[current_ptr].t = t; current_ptr++; } /*---------------------------------------------------------------------------- ** ** dynports_refresh() ** ** Refreshes dynamic port mapping, by adding the mapping again with the ** current time. ** **---------------------------------------------------------------------------- */ void dynports_refresh(u_int16_t port, service_func_t f) { struct timeval t; int i; /* get the current time */ gettimeofday(&t, NULL); /* refresh the dynamic port mapping with the current time */ for (i=0; i #include "error.h" #define ERROR_BUF_SIZE 32 /* * This avoids a warning with glibc compilation */ #ifndef errno extern int errno; #endif /* * If we have strerror() we won't use sys_errlist, so don't bother defining * it. */ #ifndef HAVE_STRERROR extern char * sys_errlist[]; #endif /*---------------------------------------------------------------------------- ** ** Function: my_strerror() ** ** Comments: Use strerror() if this system supports it. Roll our own otherwise. ** **---------------------------------------------------------------------------- */ char *my_strerror(int errnum) { #ifdef HAVE_STRERROR return (strerror(errnum)); #else extern int sys_nerr; static char ebuf[ERROR_BUF_SIZE]; if (errnum < sys_nerr) return ((char *) sys_errlist[errnum]); snprintf(ebuf, ERROR_BUF_SIZE, "Unknown error: %d", errnum); return(ebuf); #endif } /*---------------------------------------------------------------------------- ** ** error() ** ** Generic error dumping. Here's how the arguments are used ** ** syserr: 0 is not an error from a system call, non-zero otherwise ** filename: filename of the caller. Optional. ** line: line number of the caller. Optional, set to 0 is filename and ** line number info is not to be printed ** **---------------------------------------------------------------------------- */ void error(int syserr, char *filename, int line, const char *fmt, va_list args) { /* * Dump the error message */ fprintf(stderr,"ERROR: "); if (line) fprintf(stderr, "%s line %d: ", filename, line); vfprintf(stderr, fmt, args); /* * If this is a system error, print the errno info. Otherwise, don't */ if (syserr) { fprintf(stderr," (%d ", errno); fprintf(stderr, "%s)\n", my_strerror(errno)); } else fprintf(stderr, "\n"); } /***************************************************************************** * Externally-visible functions are below here ****************************************************************************/ /*---------------------------------------------------------------------------- ** ** error_fatal() ** ** General fatal error. ** **---------------------------------------------------------------------------- */ void error_fatal(char *fmt, ...) { va_list args; va_start(args,fmt); error(0, "", 0, fmt, args); va_end(args); abort(); } /*---------------------------------------------------------------------------- ** ** error_system() ** ** General system error. ** **---------------------------------------------------------------------------- */ void error_system(char *fmt, ...) { va_list args; va_start(args, fmt); error(1, "", 0, fmt, args); va_end(args); abort(); } /*---------------------------------------------------------------------------- ** ** error_message() ** ** General non-terminal error. ** **---------------------------------------------------------------------------- */ void error_message(char *fmt, ...) { va_list args; va_start(args, fmt); error(1, "", 0, fmt, args); va_end(args); } ipgrab-0.9.10/src/error.h0000644000175000001440000000333207173077731014361 0ustar farooqusers/**************************************************************************** ** ** File: error.h ** ** Author: Mike Borella ** ** Comments: Definitions for error.c. The goal here is to have a clean ** API for useful error reporting. We three different types of ** errors: messages fatal, and system. ** ** System errors result from failed system calls, and errno info ** is reported. The program is aborted ** ** Fatal errors are any other error which requires program ** termination. ** ** Message errors are like fatal errors, but just print a message ** without aborting. ** ** $Id: error.h,v 1.3 2000/10/17 16:35:37 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef ERROR_H #define ERROR_H #include "global.h" void error(int, char *, int, const char *fmt, va_list); void error_system(char *fmt, ...); void error_fatal(char *fmt, ...); void error_message(char *fmt, ...); #endif ipgrab-0.9.10/src/esp.c0000644000175000001440000000462510530527426014010 0ustar farooqusers/**************************************************************************** ** File: esp.c ** ** Author: Mike Borella ** ** Comments: Dump ESP header information. Since this packet sniffer ** is stateless, we cannot determine any headers besides the SPI and the ** sequence number. In order to figure out the padding length and next ** payload headers we would need to know the authentication mechanism ** (if any) used for this SA. But that info is part of the ISAKMP ** negotiation rather than the ESP header. Oh well. ** ** $Id: esp.c,v 1.7 2006/11/21 07:47:34 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "global.h" #include "ip_protocols.h" extern struct arg_t *my_args; /*---------------------------------------------------------------------------- ** ** dump_esp() ** ** Parse ESP packet and dump fields. ** **---------------------------------------------------------------------------- */ void dump_esp(packet_t *pkt) { esp_header_t esp; /* Set the layer */ set_layer(LAYER_NETWORK); /* * Stats accounting */ stats_update(STATS_ESP); /* * Get the ESP header */ if (get_packet_bytes((u_int8_t *) &esp, pkt, sizeof(esp_header_t)) == 0) return; /* * Conversions */ esp.spi = ntohl(esp.spi); esp.spi = ntohl(esp.seqno); /* * Dump header */ if (my_args->m) { display_minimal((u_int8_t *) &esp.spi, 4, DISP_HEX); display_minimal_string(" "); } else { /* announcement */ display_header_banner("ESP Header"); display("SPI", (u_int8_t *) &esp.spi, 4, DISP_HEX); display("Sequence number", (u_int8_t *) &esp.seqno, 4, DISP_DEC); } } ipgrab-0.9.10/src/esp.h0000644000175000001440000000226007153031045014000 0ustar farooqusers/**************************************************************************** ** File: esp.h ** ** Author: Mike Borella ** ** Structure of ESP packets ** ** $Id: esp.h,v 1.2 2000/08/29 21:59:01 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef ESP_H #define ESP_H /* * Static part of ESP header */ typedef struct esp_header { u_int32_t spi; u_int32_t seqno; } esp_header_t; void dump_esp(packet_t *); #endif ipgrab-0.9.10/src/ethernet.c0000644000175000001440000000655107304522724015040 0ustar farooqusers/**************************************************************************** ** File: ethernet.c ** ** Author: Mike Borella ** ** Comments: Dump ethernet packets ** ** $Id: ethernet.c,v 1.18 2001/05/28 19:24:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "ethernet.h" #include "ethertypes.h" #include "ipx.h" #include "llc.h" #include "arp.h" #include "ip_protocols.h" extern struct arg_t * my_args; extern strmap_t ethertype_map[]; /*---------------------------------------------------------------------------- ** ** dump_ethernet() ** ** Process packets from the DLT_EN10MB interface type ** **---------------------------------------------------------------------------- */ void dump_ethernet(packet_t *pkt) { ether_header_t eth; ethertype_func_t et; /* Set the layer */ set_layer(LAYER_DATALINK); /* * Read the header */ if (get_packet_bytes((u_int8_t *) ð, pkt, 14) == 0) return; /* * Conversions */ eth.type = ntohs(eth.type); /* * Dump header */ if (my_args->m) { if (my_args->T) display_minimal_string("ETH "); else display_minimal_string("| ETH "); display_minimal((u_int8_t *) ð.src, 6, DISP_HEXCOLONS); display_minimal_string("->"); display_minimal((u_int8_t *) ð.dst, 6, DISP_HEXCOLONS); display_minimal_string(" "); } else { /* announcement */ display_header_banner_ts("Ethernet", pkt->timestamp); /* fields */ display("Hardware source", (u_int8_t *) ð.src, 6, DISP_HEXCOLONS); display("Hardware destination", (u_int8_t *) ð.dst, 6, DISP_HEXCOLONS); display_strmap_hex("Type / Length", eth.type, ethertype_map); display("Media length", (u_int8_t *) &pkt->media_length, 2, DISP_DEC); } /* dump the hex buffer */ hexbuffer_flush(); /* * Check for IEEE 802 (LLC) encapsulation. If not, assume regular ethernet */ if (eth.type <= ETHERMTU) { /* Do something intelligent with LLC */ if (my_args->m) { display_minimal_string("("); display_minimal((u_int8_t *) ð.type, 2, DISP_HEX); display_minimal_string(") "); } dump_llc(pkt); } else { /* * Display the rest of the packet */ et = ethertype2func(eth.type); if (et) { et(pkt); } else { /* * If we can't map the type, and we're in minimal mode, * dump the protocol type */ if (my_args->m) { display_minimal_string("("); display_minimal((u_int8_t *) ð.type, 2, DISP_HEX); display_minimal_string(") "); } } } /* else */ } ipgrab-0.9.10/src/ethernet.h0000644000175000001440000000252607153537751015053 0ustar farooqusers/**************************************************************************** ** File: ethernet.h ** ** Author: Mike Borella ** ** Comments: Generic ethernet structure - an attempt at OS independence ** ** $Id: ethernet.h,v 1.5 2000/08/31 20:28:25 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef ETHERNET_H #define ETHERNET_H #include "global.h" #include "local.h" #define ETHERMTU 1500 /* * Ethernet header */ typedef struct ether_header { u_int8_t dst[6]; u_int8_t src[6]; u_int16_t type; } ether_header_t; void dump_ethernet(packet_t *); #endif ipgrab-0.9.10/src/ethertypes.c0000644000175000001440000000451507370363552015421 0ustar farooqusers/**************************************************************************** ** File: ethertypes.c ** ** Author: Mike Borella ** ** Comments: Functions to handle ethernet types ** ** $Id: ethertypes.c,v 1.6 2001/11/02 00:23:06 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "ethertypes.h" /* * Ethernet type map */ strmap_t ethertype_map[] = { { ETHERTYPE_IP, "IP" }, { ETHERTYPE_ARP, "ARP" }, { ETHERTYPE_RARP, "RARP" }, { ETHERTYPE_IPX, "IPX" }, { ETHERTYPE_IPV6, "IPV6" }, { ETHERTYPE_PPP, "PPP" }, { ETHERTYPE_PPPOED, "PPPoEd" }, { ETHERTYPE_PPPOES, "PPPoEs" }, { ETHERTYPE_PPPHDLC, "PPP with HDLC framing" }, { 0, "" } }; /*---------------------------------------------------------------------------- ** ** ethertype2func() ** ** Map an ethertype to a function that handles that type ** **---------------------------------------------------------------------------- */ ethertype_func_t ethertype2func(u_int16_t et) { ethertype_func_t f; switch(et) { case ETHERTYPE_IP: f = dump_ip; break; case ETHERTYPE_ARP: case ETHERTYPE_RARP: f = dump_arp; break; case ETHERTYPE_IPX: f = dump_ipx; break; case ETHERTYPE_IPV6: f = dump_ipv6; break; case ETHERTYPE_PPP: f = dump_ppp; break; case ETHERTYPE_PPPHDLC: f = dump_ppp_hdlc; break; case ETHERTYPE_PPPOED: f = dump_pppoed; break; case ETHERTYPE_PPPOES: f = dump_pppoes; break; default: f = NULL; break; } return f; } ipgrab-0.9.10/src/ethertypes.h0000644000175000001440000000402107260427302015406 0ustar farooqusers/**************************************************************************** ** File: ethertypes.h ** ** Author: Mike Borella ** ** Comments: Header file for ethernet types ** ** $Id: ethertypes.h,v 1.5 2001/03/28 18:34:42 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef ETHERTYPES_H #define ETHERTYPES_H #include "global.h" #include "ip.h" #include "ipv6.h" #include "arp.h" #include "ipx.h" #include "ppp.h" #include "pppoe.h" #define ETHERTYPE_IP 0x0800 /* IPv4 */ #define ETHERTYPE_ARP 0x0806 /* Addr. resolution protocol */ #define ETHERTYPE_RARP 0x8035 /* Reverse addr. resolution protocol */ #define ETHERTYPE_IPX 0x8137 /* IPX family */ #define ETHERTYPE_IPV6 0x86dd /* IPv6 */ #define ETHERTYPE_PPP 0x880b /* PPP */ #define ETHERTYPE_PPPOED 0x8863 /* PPPoE discovery */ #define ETHERTYPE_PPPOES 0x8864 /* PPPoE session */ #define ETHERTYPE_PPPHDLC 0x8881 /* CDMA2000 PPP with HDLC framing in GRE */ /* * Define a type that is a function that takes a packet_t pointer and * returns a void */ typedef void (*ethertype_func_t)(packet_t *); /* * This function maps a ethertype to a function that processes the * protocol that runs on that ethertype */ ethertype_func_t ethertype2func(u_int16_t); #endif ipgrab-0.9.10/src/file.c0000644000175000001440000002417610637737244014154 0ustar farooqusers/**************************************************************************** ** ** File: file.c ** ** Author: Mike Borella ** ** Comments: Support for various trace file formats. Currently ** we support: ** - Libpcap ** - Sun Snoop ** ** $Id: file.c,v 1.5 2007/06/25 13:09:56 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include #include "file.h" #include "error.h" #include "parse_cl.h" #include "ipgrab.h" #include "datalink.h" #include "utilities.h" #define FILE_PCAP_SIG 0xa1b2c3d4 #define FILE_PCAP_SIG2 0xa1b2cd34 #define FILE_SNOOP_SIG1 0x736e #define FILE_SNOOP_SIG2 0x6f6f #define FILE_SNOOP_SIG3 0x7000 #define FILE_SNOOP_SIG4 0x0000 /* * Trace file formats */ typedef enum file_ { FILE_TYPE_NULL = 0, /* No file type yet assigned */ FILE_TYPE_PCAP, /* Libpcap */ FILE_TYPE_SNOOP, /* Sun Snoop */ FILE_TYPE_UNKNOWN /* File type unknown */ } file_t; /* * Snoop packet header format * * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Original Length | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Included Length | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Packet Record Length | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Cumulative Drops | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Timestamp Seconds | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Timestamp Microseconds | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ typedef struct snoop_packet_header { u_int32_t orig_len; u_int32_t inc_len; u_int32_t rec_len; u_int32_t drops; u_int32_t ts_sec; u_int32_t ts_usec; } snoop_packet_header_t; static file_t file_type = FILE_TYPE_NULL; extern char * pcap_cmd; static pcap_t * pd; static struct bpf_program fcode; static char errorbuf[PCAP_ERRBUF_SIZE]; static int mylink; static pcap_dumper_t * p; static FILE * fp; extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** file_id() ** ** Attempt to identify a file format by looking at the first few bytes. ** Most trace file formats begin with a distinctive signature. ** Libpcap: a1b3 c3d4 (1 32 bit little endian word) ** Sun Snoop: 736e 6f6f 7000 0000 0000 (5 16 bit big endian words) ** ** This function returns 1 on successful identification and 0 otherwise. ** **---------------------------------------------------------------------------- */ int file_id(char *s) { FILE * fp; u_int32_t word32; u_int16_t word16[4]; int ret; /* Open the file */ fp = fopen(s, "r"); if (fp == NULL) error_system("can't open %s", s); /* Check against libpcap signature */ ret = fread((void *) &word32, 4, 1, fp); if (ret < 1) error_fatal("can't read file format signature from %s", s); #ifdef WORDS_BIGENDIAN reverse_byte_order((u_int8_t *) &word32, 4); #endif if (word32 == FILE_PCAP_SIG || word32 == FILE_PCAP_SIG2) { file_type = FILE_TYPE_PCAP; fclose (fp); return 1; } /* Check against Sun Snoop signature (first 3 bytes should be enough) */ rewind(fp); /* Go to beginning of the file */ ret = fread((void *) &word16, 2, 4, fp); if (ret < 4) error_fatal("can't read file format signature from %s", s); if (ntohs(word16[0]) == FILE_SNOOP_SIG1 && ntohs(word16[1]) == FILE_SNOOP_SIG2 && ntohs(word16[2]) == FILE_SNOOP_SIG3 && ntohs(word16[3]) == FILE_SNOOP_SIG4) { file_type = FILE_TYPE_SNOOP; fclose (fp); return 1; } /* Can't ID the file, return an error */ file_type = FILE_TYPE_UNKNOWN; fclose(fp); return 0; } /*---------------------------------------------------------------------------- ** ** file_open() ** ** Open an ID'd file ** **---------------------------------------------------------------------------- */ int file_open(char *s) { fprintf(stderr, "Reading from file %s", s); switch (file_type) { case FILE_TYPE_PCAP: { fprintf(stderr, " (libpcap)\n"); pd = pcap_open_offline(s, errorbuf); if (pd == NULL) error_fatal("%s", errorbuf); /* Compile command line filter spec info fcode FSM */ if (pcap_compile(pd, &fcode, pcap_cmd, 0, 0) < 0) error_fatal("pcap_compile: %s", pcap_geterr(pd)); /* Set the pcap filter with our fcode FSM. That should do it... */ if (pcap_setfilter(pd, &fcode) < 0) error_fatal("pcap_setfilter: %s", pcap_geterr(pd)); /* Get the data link type */ mylink = pcap_datalink(pd); if (mylink < 0) error_fatal("pcap_datalink: %s", pcap_geterr(pd)); switch(mylink) { case DLT_NULL: fprintf(stderr,"(loopback)\n"); break; case DLT_EN10MB: fprintf(stderr, "(ethernet)\n"); break; case DLT_SLIP: fprintf(stderr, "(slip)\n"); break; #ifdef DLT_RAW /* Not supported in some arch or older pcap versions */ case DLT_RAW: fprintf(stderr, "(raw)\n"); break; #endif case DLT_PPP: fprintf(stderr, "(ppp)\n"); break; default: error_fatal("\n cannot handle data link type %d", mylink); } /* Open the file for writing if -w is used */ if (my_args->w) { p = pcap_dump_open(pd, my_args->w); if (p == NULL) error_system("pcap_dump_open: %s", pcap_geterr(pd)); } /* Return to the caller w/o reading a packet */ return 1; } break; case FILE_TYPE_SNOOP: { u_int32_t version; int ret; /* Open the file */ fp = fopen(s, "r"); if (fp == NULL) error_system("can't open %s", s); /* Get the first four bytes which are the signature, throw them out */ fseek(fp, 8, SEEK_SET); /* Get the version number */ ret = fread((void *) &version, 4, 1, fp); if (ret < 1) error_fatal("can't read version number from %s", s); version = ntohl(version); fprintf(stderr, " (snoop v%d)\n", version); return 1; } break; default: error_fatal("trying to open invalid file %s", my_args->r); } return 0; } /*---------------------------------------------------------------------------- ** ** file_read() ** ** Read packets from a file. The cnt parameter is the number of packets to ** read. ** **---------------------------------------------------------------------------- */ int file_read(int cnt) { switch (file_type) { case FILE_TYPE_PCAP: { /* Make sure that the file is open */ if (pd == NULL) error_fatal("trying to read from unopened file %s", my_args->r); if (my_args->w) { /* Read the specified number of packets */ if (pcap_loop(pd, cnt, pcap_dump, (u_char *) p) < 0) error_fatal("pcap_loop: %s", pcap_geterr(pd)); } else { /* Read until cnt packets read */ if (pcap_loop(pd, cnt, (pcap_func_t) datalink_pcap, (u_char *) &mylink) < 0) error_fatal("pcap_loop: %s", pcap_geterr(pd)); } } break; case FILE_TYPE_SNOOP: { u_int32_t linktype; int ret; snoop_packet_header_t header; u_int8_t * packet; int pad_len; struct timeval tv; /* Make sure that the file is open */ if (fp == NULL) error_fatal("trying to read from unopened file %s", my_args->r); /* Read the datalink type */ ret = fread((void *) &linktype, 4, 1, fp); if (ret < 1) error_fatal("can't read link type from %s", my_args->r); linktype = ntohl(linktype); /* Translate the link type to local definitions */ switch(linktype) { case 4: linktype = DATALINK_TYPE_ETHERNET; break; default: /* We really can handle linktypes better but I'm lazy */ error_fatal("unsupported snoop link type %d", linktype); } /* Loop to read individual packets */ while(1) { /* Read the header */ ret = fread((void *) &header, sizeof(snoop_packet_header_t), 1, fp); if (ret < 1) { if (feof(fp)) break; else error_fatal("can't read packet header from %s", my_args->r); } /* Do conversions */ header.orig_len = ntohl(header.orig_len); header.inc_len = ntohl(header.inc_len); header.rec_len = ntohl(header.rec_len); header.drops = ntohl(header.drops); header.ts_sec = ntohl(header.ts_sec); header.ts_usec = ntohl(header.ts_usec); /* Get the actual packet */ packet = my_malloc(header.inc_len+1); ret = fread((void *) packet, header.inc_len, 1, fp); if (ret < 1) { if (feof(fp)) break; else error_fatal("can't read packet from %s", my_args->r); } /* Calculate the pad length, then move the pointer */ pad_len = header.rec_len - header.inc_len - 24; fseek(fp, pad_len, SEEK_CUR); /* Set up the timeval */ tv.tv_sec = header.ts_sec; tv.tv_usec = header.ts_usec; /* Call the datalink() function */ datalink(linktype, tv, header.inc_len, header.inc_len, packet); /* Deallocate memory */ my_free(packet); } return 1; } break; default: error_fatal("trying to read invalid file %s", my_args->r); } return 0; } ipgrab-0.9.10/src/file.h0000644000175000001440000000227107370363552014146 0ustar farooqusers/**************************************************************************** ** ** File: file.h ** ** Author: Mike Borella ** ** Header Definitions for trace file formats ** ** $Id: file.h,v 1.1 2001/11/02 00:23:06 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef FILE_H #define FILE_H #include "global.h" /* * Function prototypes */ int file_id(char *); int file_open(char *); int file_read(int); #endif ipgrab-0.9.10/src/ftpctrl.c0000644000175000001440000001075210530527426014675 0ustar farooqusers/**************************************************************************** ** File: ftpctrl.c ** ** Author: Mike Borella ** ** Comments: FTP control module. ** ** $Id: ftpctrl.c,v 1.5 2006/11/21 07:47:34 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "ftpctrl.h" extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** dump_ftpctrl() ** ** Parse and display FTP control packets ** **---------------------------------------------------------------------------- */ void dump_ftpctrl(packet_t *pkt) { u_int8_t * payload; u_int32_t size; u_int8_t * ptr; /* Set the layer */ set_layer(LAYER_APPLICATION); /* find the payload size, then allocate memory and read the packet */ size = get_packet_apparentbytesleft(pkt); if (size <= 0) return; payload = (u_int8_t *) my_malloc (size+1); payload[size] = '\0'; if (get_packet_bytes(payload, pkt, size) == 0) { my_free(payload); return; } /* Get rid of carriage return and line feed at end of payload if it exists */ ptr = payload + strlen(payload); while(1) { ptr --; if (*ptr == 0x0D || *ptr == 0x0A) *ptr = '\0'; else break; } /* * FTP control connections either have commands or response codes. If there * is a response code, then this is a reply, otherwise it is a request. All * response codes are 3 digits long followed by a space. Exception: Some * replies are split over multiple packets and do not have a numeric code * to begin with. * * We determine the direction by looking at the source port. Replies * should always come from the FTP control port. */ if (state_get_srcport() == PORT_FTPCTRL) { if (isdigit(payload[0]) && isdigit(payload[1]) && isdigit(payload[2]) && isspace(payload[3])) { /* process a reply with a reply code */ char replycode_str[4]; int replycode; strncpy(replycode_str, payload, 3); replycode_str[3] = '\0'; replycode = atoi(replycode_str); if (my_args->m) { display_minimal_string("FTP control "); display_minimal_string(replycode_str); display_minimal_string(payload+3); } else { display_header_banner("FTP control"); display_string("Reply code", replycode_str); display_string("Reply", payload+4); } } else { /* process a reply without a reply code */ if (my_args->m) { display_minimal_string("FTP control "); display_minimal_string(payload+3); } else { display_header_banner("FTP control"); display_string("Reply", payload); } } } else { /* process a request */ u_int8_t * requestcode_str; u_int8_t * ptr; /* find the first space, which separates the request code from request */ ptr = strchr(payload, ' '); if (!ptr) { /* This is the case where there is nothing following the code */ ptr = payload + strlen(payload); requestcode_str = payload; payload = NULL; } else { requestcode_str = my_malloc((ptr - payload) + 1); strncpy(requestcode_str, payload, ptr - payload); requestcode_str[ptr - payload] = '\0'; } if (my_args->m) { display_minimal_string("FTP control "); display_minimal_string(requestcode_str); display_minimal_string(" "); display_minimal_string(ptr+1); } else { display_header_banner("FTP control"); display_string("Request code", requestcode_str); if (payload && ptr) display_string("Request", ptr+1); } /* free memory */ my_free(requestcode_str); } /* free memory */ my_free(payload); /* dump the hex buffer */ hexbuffer_flush(); } ipgrab-0.9.10/src/ftpctrl.h0000644000175000001440000000220307360125124014666 0ustar farooqusers/**************************************************************************** ** File: ftpctrl.h ** ** Author: Mike Borella ** ** Comments: Definitions for FTP control ** ** $Id: ftpctrl.h,v 1.1 2001/10/07 19:17:40 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef FTPCTRL_H #define FTPCTRL_H #include "global.h" #include "local.h" void dump_ftpctrl(packet_t *); #endif ipgrab-0.9.10/src/getopt.c0000644000175000001440000007427407177370313014536 0ustar farooqusers/* * getopt entry points * * modified by Mike Borella * * $Id: getopt.c,v 1.4 2000/10/30 22:06:03 mborella Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifndef HAVE_GETOPT_LONG /* getopt_long and getopt_long_only entry points for GNU getopt. Copyright (C) 1987,88,89,90,91,92,93,94,96,97 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "getopt.h" #if !defined (__STDC__) || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ #ifndef const #define const #endif #endif #include /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling and linking in this code is a waste when using the GNU C library (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ #define GETOPT_INTERFACE_VERSION 2 #if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2 #include #if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION #define ELIDE_CODE #endif #endif #ifndef ELIDE_CODE /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ #include #endif #ifndef NULL #define NULL 0 #endif int getopt_long (argc, argv, options, long_options, opt_index) int argc; char *const *argv; const char *options; const struct option *long_options; int *opt_index; { return _getopt_internal (argc, argv, options, long_options, opt_index, 0); } /* Like getopt_long, but '-' as well as '--' can indicate a long option. If an option that starts with '-' (not '--') doesn't match a long option, but does match a short option, it is parsed as a short option instead. */ int getopt_long_only (argc, argv, options, long_options, opt_index) int argc; char *const *argv; const char *options; const struct option *long_options; int *opt_index; { return _getopt_internal (argc, argv, options, long_options, opt_index, 1); } int getopt (int argc, char * const * argv, const char * optstring) { return _getopt_internal (argc, argv, optstring, (const struct option *) 0, (int *) 0, 0); } #endif /* Not ELIDE_CODE. */ #ifndef _NO_PROTO #define _NO_PROTO #endif #if !defined (__STDC__) || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ #ifndef const #define const #endif #endif #include /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling and linking in this code is a waste when using the GNU C library (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ #define GETOPT_INTERFACE_VERSION 2 #if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2 #include #if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION #define ELIDE_CODE #endif #endif #ifndef ELIDE_CODE /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ /* Don't include stdlib.h for non-GNU C libraries because some of them contain conflicting prototypes for getopt. */ #include #include #endif /* GNU C library. */ #ifdef VMS #include #if HAVE_STRING_H - 0 #include #endif #endif #if defined (WIN32) && !defined (__CYGWIN32__) /* It's not Unix, really. See? Capital letters. */ #include #define getpid() GetCurrentProcessId() #endif #ifndef _ /* This is for other GNU distributions with internationalized messages. When compiling libc, the _ macro is predefined. */ #ifdef HAVE_LIBINTL_H # include # define _(msgid) gettext (msgid) #else # define _(msgid) (msgid) #endif #endif /* This version of `getopt' appears to the caller like standard Unix `getopt' but it behaves differently for the user, since it allows the user to intersperse the options with the other arguments. As `getopt' works, it permutes the elements of ARGV so that, when it is done, all the options precede everything else. Thus all application programs are extended to handle flexible argument order. Setting the environment variable POSIXLY_CORRECT disables permutation. Then the behavior is completely standard. GNU application programs can use a third alternative mode in which they can distinguish the relative order of options and other arguments. */ #include "getopt.h" /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ char *optarg = NULL; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns -1, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ /* 1003.2 says this must be 1 before any call. */ int optind = 1; /* Formerly, initialization of getopt depended on optind==0, which causes problems with re-calling getopt as programs generally don't know that. */ int __getopt_initialized = 0; /* The next char to be scanned in the option-element in which the last option character we returned was found. This allows us to pick up the scan where we left off. If this is zero, or a null string, it means resume the scan by advancing to the next ARGV-element. */ static char *nextchar; /* Callers store zero here to inhibit the error message for unrecognized options. */ int opterr = 1; /* Set to an option character which was unrecognized. This must be initialized on some systems to avoid linking in the system's own getopt implementation. */ int optopt = '?'; /* Describe how to deal with options that follow non-option ARGV-elements. If the caller did not specify anything, the default is REQUIRE_ORDER if the environment variable POSIXLY_CORRECT is defined, PERMUTE otherwise. REQUIRE_ORDER means don't recognize them as options; stop option processing when the first non-option is seen. This is what Unix does. This mode of operation is selected by either setting the environment variable POSIXLY_CORRECT, or using `+' as the first character of the list of option characters. PERMUTE is the default. We permute the contents of ARGV as we scan, so that eventually all the non-options are at the end. This allows options to be given in any order, even with programs that were not written to expect this. RETURN_IN_ORDER is an option available to programs that were written to expect options and other ARGV-elements in any order and that care about the ordering of the two. We describe each non-option ARGV-element as if it were the argument of an option with character code 1. Using `-' as the first character of the list of option characters selects this mode of operation. The special argument `--' forces an end of option-scanning regardless of the value of `ordering'. In the case of RETURN_IN_ORDER, only `--' can cause `getopt' to return -1 with `optind' != ARGC. */ static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; /* Value of POSIXLY_CORRECT environment variable. */ static char *posixly_correct; #ifdef __GNU_LIBRARY__ /* We want to avoid inclusion of string.h with non-GNU libraries because there are many ways it can cause trouble. On some systems, it contains special magic macros that don't work in GCC. */ #include #define my_index strchr #else /* Avoid depending on library functions or files whose names are inconsistent. */ extern char * getenv(const char *); static char * my_index (const char *str, int chr) { while (*str) { if (*str == chr) return (char *) str; str++; } return 0; } /* If using GCC, we can safely declare strlen this way. If not using GCC, it is ok not to declare it. */ #ifdef __GNUC__ /* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. That was relevant to code that was here before. */ #if !defined (__STDC__) || !__STDC__ /* gcc with -traditional declares the built-in strlen to return int, and has done so at least since version 2.4.5. -- rms. */ extern int strlen (const char *); #endif /* not __STDC__ */ #endif /* __GNUC__ */ #endif /* not __GNU_LIBRARY__ */ /* Handle permutation of arguments. */ /* Describe the part of ARGV that contains non-options that have been skipped. `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is the index after the last of them. */ static int first_nonopt; static int last_nonopt; #ifdef _LIBC /* Bash 2.0 gives us an environment variable containing flags indicating ARGV elements that should not be considered arguments. */ /* Defined in getopt_init.c */ extern char *__getopt_nonoption_flags; static int nonoption_flags_max_len; static int nonoption_flags_len; static int original_argc; static char *const *original_argv; extern pid_t __libc_pid; /* Make sure the environment variable bash 2.0 puts in the environment is valid for the getopt call we must make sure that the ARGV passed to getopt is that one passed to the process. */ static void __attribute__ ((unused)) store_args_and_env (int argc, char *const *argv) { /* XXX This is no good solution. We should rather copy the args so that we can compare them later. But we must not use malloc(3). */ original_argc = argc; original_argv = argv; } text_set_element (__libc_subinit, store_args_and_env); # define SWAP_FLAGS(ch1, ch2) \ if (nonoption_flags_len > 0) \ { \ char __tmp = __getopt_nonoption_flags[ch1]; \ __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ __getopt_nonoption_flags[ch2] = __tmp; \ } #else /* !_LIBC */ # define SWAP_FLAGS(ch1, ch2) #endif /* _LIBC */ /* Exchange two adjacent subsequences of ARGV. One subsequence is elements [first_nonopt,last_nonopt) which contains all the non-options that have been skipped so far. The other is elements [last_nonopt,optind), which contains all the options processed since those non-options were skipped. `first_nonopt' and `last_nonopt' are relocated so that they describe the new indices of the non-options in ARGV after they are moved. */ #if defined (__STDC__) && __STDC__ static void exchange (char **); #endif static void exchange (argv) char **argv; { int bottom = first_nonopt; int middle = last_nonopt; int top = optind; char *tem; /* Exchange the shorter segment with the far end of the longer segment. That puts the shorter segment into the right place. It leaves the longer segment in the right place overall, but it consists of two parts that need to be swapped next. */ #ifdef _LIBC /* First make sure the handling of the `__getopt_nonoption_flags' string can work normally. Our top argument must be in the range of the string. */ if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) { /* We must extend the array. The user plays games with us and presents new arguments. */ char *new_str = malloc (top + 1); if (new_str == NULL) nonoption_flags_len = nonoption_flags_max_len = 0; else { memcpy (new_str, __getopt_nonoption_flags, nonoption_flags_max_len); memset (&new_str[nonoption_flags_max_len], '\0', top + 1 - nonoption_flags_max_len); nonoption_flags_max_len = top + 1; __getopt_nonoption_flags = new_str; } } #endif while (top > middle && middle > bottom) { if (top - middle > middle - bottom) { /* Bottom segment is the short one. */ int len = middle - bottom; register int i; /* Swap it with the top part of the top segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[top - (middle - bottom) + i]; argv[top - (middle - bottom) + i] = tem; SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); } /* Exclude the moved bottom segment from further swapping. */ top -= len; } else { /* Top segment is the short one. */ int len = top - middle; register int i; /* Swap it with the bottom part of the bottom segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[middle + i]; argv[middle + i] = tem; SWAP_FLAGS (bottom + i, middle + i); } /* Exclude the moved top segment from further swapping. */ bottom += len; } } /* Update records for the slots the non-options now occupy. */ first_nonopt += (optind - last_nonopt); last_nonopt = optind; } /* Initialize the internal data when the first call is made. */ #if defined (__STDC__) && __STDC__ static const char *_getopt_initialize (int, char *const *, const char *); #endif static const char * _getopt_initialize (argc, argv, optstring) int argc; char *const *argv; const char *optstring; { /* Start processing options with ARGV-element 1 (since ARGV-element 0 is the program name); the sequence of previously skipped non-option ARGV-elements is empty. */ first_nonopt = last_nonopt = optind; nextchar = NULL; posixly_correct = getenv ("POSIXLY_CORRECT"); /* Determine how to handle the ordering of options and nonoptions. */ if (optstring[0] == '-') { ordering = RETURN_IN_ORDER; ++optstring; } else if (optstring[0] == '+') { ordering = REQUIRE_ORDER; ++optstring; } else if (posixly_correct != NULL) ordering = REQUIRE_ORDER; else ordering = PERMUTE; #ifdef _LIBC if (posixly_correct == NULL && argc == original_argc && argv == original_argv) { if (nonoption_flags_max_len == 0) { if (__getopt_nonoption_flags == NULL || __getopt_nonoption_flags[0] == '\0') nonoption_flags_max_len = -1; else { const char *orig_str = __getopt_nonoption_flags; int len = nonoption_flags_max_len = strlen (orig_str); if (nonoption_flags_max_len < argc) nonoption_flags_max_len = argc; __getopt_nonoption_flags = (char *) malloc (nonoption_flags_max_len); if (__getopt_nonoption_flags == NULL) nonoption_flags_max_len = -1; else { memcpy (__getopt_nonoption_flags, orig_str, len); memset (&__getopt_nonoption_flags[len], '\0', nonoption_flags_max_len - len); } } } nonoption_flags_len = nonoption_flags_max_len; } else nonoption_flags_len = 0; #endif return optstring; } /* Scan elements of ARGV (whose length is ARGC) for option characters given in OPTSTRING. If an element of ARGV starts with '-', and is not exactly "-" or "--", then it is an option element. The characters of this element (aside from the initial '-') are option characters. If `getopt' is called repeatedly, it returns successively each of the option characters from each of the option elements. If `getopt' finds another option character, it returns that character, updating `optind' and `nextchar' so that the next call to `getopt' can resume the scan with the following option character or ARGV-element. If there are no more option characters, `getopt' returns -1. Then `optind' is the index in ARGV of the first ARGV-element that is not an option. (The ARGV-elements have been permuted so that those that are not options now come last.) OPTSTRING is a string containing the legitimate option characters. If an option character is seen that is not listed in OPTSTRING, return '?' after printing an error message. If you set `opterr' to zero, the error message is suppressed but we still return '?'. If a char in OPTSTRING is followed by a colon, that means it wants an arg, so the following text in the same ARGV-element, or the text of the following ARGV-element, is returned in `optarg'. Two colons mean an option that wants an optional arg; if there is text in the current ARGV-element, it is returned in `optarg', otherwise `optarg' is set to zero. If OPTSTRING starts with `-' or `+', it requests different methods of handling the non-option ARGV-elements. See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. Long-named options begin with `--' instead of `-'. Their names may be abbreviated as long as the abbreviation is unique or is an exact match for some defined option. If they have an argument, it follows the option name in the same ARGV-element, separated from the option name by a `=', or else the in next ARGV-element. When `getopt' finds a long-named option, it returns 0 if that option's `flag' field is nonzero, the value of the option's `val' field if the `flag' field is zero. The elements of ARGV aren't really const, because we permute them. But we pretend they're const in the prototype to be compatible with other systems. LONGOPTS is a vector of `struct option' terminated by an element containing a name which is zero. LONGIND returns the index in LONGOPT of the long-named option found. It is only valid when a long-named option has been found by the most recent call. If LONG_ONLY is nonzero, '-' as well as '--' can introduce long-named options. */ int _getopt_internal (argc, argv, optstring, longopts, longind, long_only) int argc; char *const *argv; const char *optstring; const struct option *longopts; int *longind; int long_only; { optarg = NULL; if (optind == 0 || !__getopt_initialized) { if (optind == 0) optind = 1; /* Don't scan ARGV[0], the program name. */ optstring = _getopt_initialize (argc, argv, optstring); __getopt_initialized = 1; } /* Test whether ARGV[optind] points to a non-option argument. Either it does not have option syntax, or there is an environment flag from the shell indicating it is not an option. The later information is only used when the used in the GNU libc. */ #ifdef _LIBC #define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ || (optind < nonoption_flags_len \ && __getopt_nonoption_flags[optind] == '1')) #else #define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') #endif if (nextchar == NULL || *nextchar == '\0') { /* Advance to the next ARGV-element. */ /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been moved back by the user (who may also have changed the arguments). */ if (last_nonopt > optind) last_nonopt = optind; if (first_nonopt > optind) first_nonopt = optind; if (ordering == PERMUTE) { /* If we have just processed some options following some non-options, exchange them so that the options come first. */ if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (last_nonopt != optind) first_nonopt = optind; /* Skip any additional non-options and extend the range of non-options previously skipped. */ while (optind < argc && NONOPTION_P) optind++; last_nonopt = optind; } /* The special ARGV-element `--' means premature end of options. Skip it like a null option, then exchange with previous non-options as if it were an option, then skip everything else like a non-option. */ if (optind != argc && !strcmp (argv[optind], "--")) { optind++; if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (first_nonopt == last_nonopt) first_nonopt = optind; last_nonopt = argc; optind = argc; } /* If we have done all the ARGV-elements, stop the scan and back over any non-options that we skipped and permuted. */ if (optind == argc) { /* Set the next-arg-index to point at the non-options that we previously skipped, so the caller will digest them. */ if (first_nonopt != last_nonopt) optind = first_nonopt; return -1; } /* If we have come to a non-option and did not permute it, either stop the scan or describe it to the caller and pass it by. */ if (NONOPTION_P) { if (ordering == REQUIRE_ORDER) return -1; optarg = argv[optind++]; return 1; } /* We have found another option-ARGV-element. Skip the initial punctuation. */ nextchar = (argv[optind] + 1 + (longopts != NULL && argv[optind][1] == '-')); } /* Decode the current option-ARGV-element. */ /* Check whether the ARGV-element is a long option. If long_only and the ARGV-element has the form "-f", where f is a valid short option, don't consider it an abbreviated form of a long option that starts with f. Otherwise there would be no way to give the -f short option. On the other hand, if there's a long option "fubar" and the ARGV-element is "-fu", do consider that an abbreviation of the long option, just like "--fu", and not "-f" with arg "u". This distinction seems to be the most useful approach. */ if (longopts != NULL && (argv[optind][1] == '-' || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) { char *nameend; const struct option *p; const struct option *pfound = NULL; int exact = 0; int ambig = 0; int indfound = -1; int option_index; for (nameend = nextchar; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, nameend - nextchar)) { if ((unsigned int) (nameend - nextchar) == (unsigned int) strlen (p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else /* Second or later nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (opterr) fprintf (stderr, _("%s: option `%s' is ambiguous\n"), argv[0], argv[optind]); nextchar += strlen (nextchar); optind++; optopt = 0; return '?'; } if (pfound != NULL) { option_index = indfound; optind++; if (*nameend) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) optarg = nameend + 1; else { if (opterr) { if (argv[optind - 1][1] == '-') /* --option */ fprintf (stderr, _("%s: option `--%s' doesn't allow an argument\n"), argv[0], pfound->name); else { /* +option or -option */ fprintf (stderr, _("%s: option `%c%s' doesn't allow an argument\n"), argv[0], argv[optind - 1][0], pfound->name); } } nextchar += strlen (nextchar); optopt = pfound->val; return '?'; } } else if (pfound->has_arg == 1) { if (optind < argc) optarg = argv[optind++]; else { if (opterr) fprintf (stderr, _("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); nextchar += strlen (nextchar); optopt = pfound->val; return optstring[0] == ':' ? ':' : '?'; } } nextchar += strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } /* Can't find it as a long option. If this is not getopt_long_only, or the option starts with '--' or is not a valid short option, then it's an error. Otherwise interpret it as a short option. */ if (!long_only || argv[optind][1] == '-' || my_index (optstring, *nextchar) == NULL) { if (opterr) { if (argv[optind][1] == '-') /* --option */ fprintf (stderr, _("%s: unrecognized option `--%s'\n"), argv[0], nextchar); else /* +option or -option */ fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), argv[0], argv[optind][0], nextchar); } nextchar = (char *) ""; optind++; optopt = 0; return '?'; } } /* Look at and handle the next short option-character. */ { char c = *nextchar++; char *temp = my_index (optstring, c); /* Increment `optind' when we start to process its last character. */ if (*nextchar == '\0') ++optind; if (temp == NULL || c == ':') { if (opterr) { if (posixly_correct) /* 1003.2 specifies the format of this message. */ fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c); else fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c); } optopt = c; return '?'; } /* Convenience. Treat POSIX -W foo same as long option --foo */ if (temp[0] == 'W' && temp[1] == ';') { char *nameend; const struct option *p; const struct option *pfound = NULL; int exact = 0; int ambig = 0; int indfound = 0; int option_index; /* This is an option that requires an argument. */ if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ optind++; } else if (optind == argc) { if (opterr) { /* 1003.2 specifies the format of this message. */ fprintf (stderr, _("%s: option requires an argument -- %c\n"), argv[0], c); } optopt = c; if (optstring[0] == ':') c = ':'; else c = '?'; return c; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; /* optarg is now the argument, see if it's in the table of longopts. */ for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, nameend - nextchar)) { if ((unsigned int) (nameend - nextchar) == strlen (p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else /* Second or later nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (opterr) fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), argv[0], argv[optind]); nextchar += strlen (nextchar); optind++; return '?'; } if (pfound != NULL) { option_index = indfound; if (*nameend) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) optarg = nameend + 1; else { if (opterr) fprintf (stderr, _("\ %s: option `-W %s' doesn't allow an argument\n"), argv[0], pfound->name); nextchar += strlen (nextchar); return '?'; } } else if (pfound->has_arg == 1) { if (optind < argc) optarg = argv[optind++]; else { if (opterr) fprintf (stderr, _("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); nextchar += strlen (nextchar); return optstring[0] == ':' ? ':' : '?'; } } nextchar += strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } nextchar = NULL; return 'W'; /* Let the application handle it. */ } if (temp[1] == ':') { if (temp[2] == ':') { /* This is an option that accepts an argument optionally. */ if (*nextchar != '\0') { optarg = nextchar; optind++; } else optarg = NULL; nextchar = NULL; } else { /* This is an option that requires an argument. */ if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ optind++; } else if (optind == argc) { if (opterr) { /* 1003.2 specifies the format of this message. */ fprintf (stderr, _("%s: option requires an argument -- %c\n"), argv[0], c); } optopt = c; if (optstring[0] == ':') c = ':'; else c = '?'; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; nextchar = NULL; } } return c; } } #endif /* Not ELIDE_CODE. */ #endif ipgrab-0.9.10/src/getopt.h0000644000175000001440000001334507177370313014533 0ustar farooqusers/* Declarations for getopt. Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _GETOPT_H #ifndef __need_getopt # define _GETOPT_H 1 #endif #ifdef __cplusplus extern "C" { #endif /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ extern char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns -1, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ extern int optind; /* Callers store zero here to inhibit the error message `getopt' prints for unrecognized options. */ extern int opterr; /* Set to an option character which was unrecognized. */ extern int optopt; #ifndef __need_getopt /* Describe the long-named options requested by the application. The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector of `struct option' terminated by an element containing a name which is zero. The field `has_arg' is: no_argument (or 0) if the option does not take an argument, required_argument (or 1) if the option requires an argument, optional_argument (or 2) if the option takes an optional argument. If the field `flag' is not NULL, it points to a variable that is set to the value given in the field `val' when the option is found, but left unchanged if the option is not found. To have a long-named option do something other than set an `int' to a compiled-in constant, such as set a value from `optarg', set the option's `flag' field to zero and its `val' field to a nonzero value (the equivalent single-letter option character, if there is one). For long options that have a zero `flag' field, `getopt' returns the contents of the `val' field. */ struct option { # if defined __STDC__ && __STDC__ const char *name; # else char *name; # endif /* has_arg can't be an enum because some compilers complain about type mismatches in all the code that assumes it is an int. */ int has_arg; int *flag; int val; }; /* Names for the values of the `has_arg' field of `struct option'. */ # define no_argument 0 # define required_argument 1 # define optional_argument 2 #endif /* need getopt */ /* Get definitions and prototypes for functions to process the arguments in ARGV (ARGC of them, minus the program name) for options given in OPTS. Return the option character from OPTS just read. Return -1 when there are no more options. For unrecognized options, or options missing arguments, `optopt' is set to the option letter, and '?' is returned. The OPTS string is a list of characters which are recognized option letters, optionally followed by colons, specifying that that letter takes an argument, to be placed in `optarg'. If a letter in OPTS is followed by two colons, its argument is optional. This behavior is specific to the GNU `getopt'. The argument `--' causes premature termination of argument scanning, explicitly telling `getopt' that there are no more options. If OPTS begins with `--', then non-option arguments are treated as arguments to the option '\0'. This behavior is specific to the GNU `getopt'. */ #if defined __STDC__ && __STDC__ # ifdef __GNU_LIBRARY__ /* Many other libraries have conflicting prototypes for getopt, with differences in the consts, in stdlib.h. To avoid compilation errors, only prototype getopt for the GNU C library. */ extern int getopt (int __argc, char *const *__argv, const char *__shortopts); # else /* not __GNU_LIBRARY__ */ extern int getopt (); # endif /* __GNU_LIBRARY__ */ # ifndef __need_getopt extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind); extern int getopt_long_only (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind); /* Internal only. Users should not call this directly. */ extern int _getopt_internal (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind, int __long_only); # endif #else /* not __STDC__ */ extern int getopt (); # ifndef __need_getopt extern int getopt_long (); extern int getopt_long_only (); extern int _getopt_internal (); # endif #endif /* __STDC__ */ #ifdef __cplusplus } #endif /* Make sure we later can get all the definitions and declarations. */ #undef __need_getopt #endif /* getopt.h */ ipgrab-0.9.10/src/global.h0000644000175000001440000000320310530527426014455 0ustar farooqusers/**************************************************************************** ** File: global.h ** ** Author: Mike Borella ** ** Comments: Includes the header files that most or all modules will need. ** ** $Id: global.h,v 1.7 2006/11/21 07:47:34 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef GLOBAL_H #define GLOBAL_H #include #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_NETINET_IN_H #include /* for ntohs() and related */ #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STDLIB_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_CTYPE_H #include #endif #ifdef HAVE_SIGNAL_H #include #endif #ifdef HAVE_STDARG_H #include #endif #ifdef HAVE_LIBPCAP #include "pcap.h" #endif #endif ipgrab-0.9.10/src/gre.c0000644000175000001440000002221407374605314013775 0ustar farooqusers/**************************************************************************** ** File: gre.c ** ** Author: Mike Borella ** ** Comments: ** ** $Id: gre.c,v 1.12 2001/11/15 00:22:36 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "gre.h" #include "ip_protocols.h" #include "ethertypes.h" extern struct arg_t * my_args; extern strmap_t ipproto_map[]; extern strmap_t ethertype_map[]; /*---------------------------------------------------------------------------- ** ** dump_gre() ** ** Displays both versions of GRE headers ** **---------------------------------------------------------------------------- */ void dump_gre(packet_t *pkt) { gre_v0_rfc2784_t gre0; gre_v1_t gre1; ethertype_func_t et; /* Set the layer */ set_layer(LAYER_NETWORK); /* * Stats accounting */ stats_update(STATS_GRE); /* * Look at the first 2 bytes of the GRE header so that we can check the * version */ if (look_packet_bytes((u_int8_t *) &gre0, pkt, 2) == 0) return; /* * Check version number */ switch(gre0.version) { case 0: { u_int16_t reserved; u_int16_t protocol; ethertype_func_t et; /* * Please note: If the reserved field is 0, we assume that * the GRE packet follows RFC2784 and act accordingly. Otherwise * we assume the RFC1701 interpretation. If key and sequence * number fields are used, ala RFC2890, then we parse according * RFC1701. Got all that? */ reserved = (gre0.reserved_high << 5) || gre0.reserved_low; protocol = ntohs(gre0.protocol); if (reserved == 0) { gre_v0_rfc2784_t gre; u_int8_t C; /* * Get the header */ if (get_packet_bytes((u_int8_t *) &gre, pkt, sizeof(gre_v0_rfc2784_t)) == 0) return; /* * Conversions */ gre.protocol = ntohs(gre.protocol); protocol = gre.protocol; C = gre.c; /* Dump the header */ if (my_args->m) { display_minimal_string("| GRE v0 "); display_minimal((u_int8_t *) &gre.protocol, 2, DISP_HEX); } else { display_header_banner("GREv0 Header"); display("C", &C, 1, DISP_DEC); display("Reserved", (u_int8_t *) &reserved, 2, DISP_DEC); display_strmap_hex("Protocol", gre.protocol, ethertype_map); } /* * Get the checksum and reserved fields, if they exist */ if (C) { u_int16_t checksum; u_int16_t reserved; /* Get the fields */ if (get_packet_bytes((u_int8_t *) &checksum, pkt, 2) == 0) return; if (get_packet_bytes((u_int8_t *) &reserved, pkt, 2) == 0) return; /* conversions */ checksum = ntohs(checksum); reserved = ntohs(reserved); if (!my_args->m) { display("Checksum", (u_int8_t *) &checksum, 2, DISP_DEC); display("Reserved", (u_int8_t *) &reserved, 2, DISP_DEC); } } } else { gre_v0_rfc1701_t gre; u_int8_t C, R, K, S, s, recur, flags, version; /* * Get the header */ if (get_packet_bytes((u_int8_t *) &gre, pkt, sizeof(gre_v0_rfc1701_t)) == 0) return; /* * Conversions */ gre.protocol = ntohs(gre.protocol); protocol = gre.protocol; C = gre.c; R = gre.r; K = gre.k; S = gre.S; s = gre.s; recur = gre.recur; flags = gre.flags; version = gre.version; /* Dump the header */ if (my_args->m) { display_minimal_string("| GRE v0 "); display_minimal((u_int8_t *) &gre.protocol, 2, DISP_HEX); display_minimal_string(" "); } else { display_header_banner("GREv0 Header"); display("C", &C, 1, DISP_DEC); display("R", &R, 1, DISP_DEC); display("K", &K, 1, DISP_DEC); display("S", &S, 1, DISP_DEC); display("s", &s, 1, DISP_DEC); display("Recur", &recur, 1, DISP_DEC); display("Flags", &flags, 1, DISP_DEC); display("Version", &version, 1, DISP_DEC); display_strmap_hex("Protocol", gre.protocol, ethertype_map); } /* * Parse options fields. Note that if the C or the R bits are * present then both the checksum and offset fields are present */ if (C || R) { u_int16_t checksum; u_int16_t offset; /* * Nothing to report for minimal mode here, so just get * the checksum and offset and display them. */ if (get_packet_bytes((u_int8_t *) &checksum, pkt, 2) == 0) return; checksum = ntohs(checksum); if (!my_args->m) display("Checksum", (u_int8_t *) &checksum, 2, DISP_DEC); if (get_packet_bytes((u_int8_t *) &offset, pkt, 2) == 0) return; offset = ntohs(offset); if (!my_args->m) display("Offset", (u_int8_t *) &offset, 2, DISP_DEC); } /* Check for the K bit (key field) */ if (K) { u_int32_t key; if (get_packet_bytes((u_int8_t *) &key, pkt, 4) == 0) return; key = ntohl(key); if (!my_args->m) display("Key", (u_int8_t *) &key, 4, DISP_DEC); } /* Check for the sequence number field */ if (S) { u_int32_t seqno; if (get_packet_bytes((u_int8_t *) &seqno, pkt, 4) == 0) return; seqno = ntohl(seqno); if (!my_args->m) display("Sequence number", (u_int8_t *) &seqno, 4, DISP_DEC); } /* Check for routing field */ if (R) { u_int32_t routing; if (get_packet_bytes((u_int8_t *) &routing, pkt, 4) == 0) return; routing = ntohs(routing); if (!my_args->m) display("Routing", (u_int8_t *) &routing, 4, DISP_DEC); } } /* flush the hexbuffer */ hexbuffer_flush(); /* * Display the rest of the packet */ et = ethertype2func(protocol); if (et) { et(pkt); } } break; case 1: /* PPTP version */ { u_int8_t C, R, K, S, s, recur, A, flags, version; /* * Get the header */ if (get_packet_bytes((u_int8_t *) &gre1, pkt, sizeof(gre_v1_t)) == 0) return; /* * Conversions */ C = gre1.C_bit; R = gre1.R_bit; K = gre1.K_bit; S = gre1.S_bit; s = gre1.s_bit; recur = gre1.recur; A = gre1.A_bit; flags = gre1.flags; version = gre1.version; gre1.protocol = ntohs(gre1.protocol); gre1.payload_len = ntohs(gre1.payload_len); gre1.call_id = ntohs(gre1.call_id); /* * Dump header */ if (my_args->m) { display_minimal_string("| GREv1 "); } else { /* announcement */ display_header_banner("GREv1 Header"); /* fields */ display("Checksum (C) bit", &C, 1, DISP_BINNLZ); display("Routing (R) bit", &R, 1, DISP_BINNLZ); display("Key present (K) bit", &K, 1, DISP_BINNLZ); display("Seq. # present (S) bit", &S, 1, DISP_BINNLZ); display("Strict src rte (s) bit", &s, 1, DISP_BINNLZ); display("Recursion control", &recur, 1, DISP_DEC); display("Ack. # present (A) bit", &A, 1, DISP_BINNLZ); display("Flags", &flags, 1, DISP_DEC); display("Version", &version, 1, DISP_DEC); display_strmap_hex("Protocol", gre1.protocol, ethertype_map); display("Payload length", (u_int8_t *) &gre1.payload_len, 2, DISP_DEC); display("Call ID", (u_int8_t *) &gre1.call_id, 2, DISP_DEC); } /* * Check for sequence and acknowledgement number fields */ if (S) { u_int32_t seqno; if (get_packet_bytes((u_int8_t *) &seqno, pkt, 4) == 0) return; seqno = ntohl(seqno); if (my_args->m) { display_minimal_string("seq "); display_minimal((u_int8_t *) &seqno, 4, DISP_DEC); display_minimal_string(" "); } else display("Sequence number", (u_int8_t *) &seqno, 4, DISP_DEC); } if (A) { u_int32_t ackno; if (get_packet_bytes((u_int8_t *) &ackno, pkt, 4) == 0) return; ackno = ntohl(ackno); if (my_args->m) { display_minimal_string("ack "); display_minimal((u_int8_t *) &ackno, 4, DISP_DEC); display_minimal_string(" "); } else display("Acknowledgement number", (u_int8_t *) &ackno, 4, DISP_DEC); } /* dump the hex buffer */ hexbuffer_flush(); /* * Display the rest of the packet */ et = ethertype2func(gre1.protocol); if (et) { et(pkt); } else { /* * If we can't map the type, and we're in minimal mode, * dump the protocol type */ if (my_args->m) { display_minimal_string("("); display_minimal((u_int8_t *) &gre1.protocol, 2, DISP_HEX); display_minimal_string(") "); } } break; default: break; } } } ipgrab-0.9.10/src/gre.h0000644000175000001440000000476107260231646014006 0ustar farooqusers/**************************************************************************** ** File: gre.h ** ** Author: Mike Borella ** ** Comments: Generic routing encapsulation header file ** ** $Id: gre.h,v 1.3 2001/03/28 00:43:18 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef GRE_H #define GRE_H #include "global.h" #include "local.h" /* * GRE version 0 header (RFC 1701) */ typedef struct gre_v0_rfc1701 { #ifdef WORDS_BIGENDIAN u_int8_t c:1, r:1, k:1, S:1, s:1, recur:3; u_int8_t flags:5, version:3; #else u_int8_t recur:3, s:1, S:1, k:1, r:1, c:1; u_int8_t version:3, flags:5; #endif u_int16_t protocol; } gre_v0_rfc1701_t; /* * GRE version 0 header (RFC 2784) */ typedef struct gre_v0_rfc2784 { #ifdef WORDS_BIGENDIAN u_int8_t c:1, reserved_high:7; u_int8_t reserved_low:5, version:3; #else u_int8_t reserved_high:7, c:1; u_int8_t version:3, reserved_low:5; #endif u_int16_t protocol; } gre_v0_rfc2784_t; /* * GRE version 1 header (used for PPTP, etc.) */ typedef struct gre_v1 { #ifdef WORDS_BIGENDIAN u_int8_t C_bit:1, R_bit:1, K_bit:1, S_bit:1, s_bit:1, recur:3; u_int8_t A_bit:1, flags:4, version:3; #else u_int8_t recur:3, s_bit:1, S_bit:1, K_bit:1, R_bit:1, C_bit:1; u_int8_t version:3, flags:4, A_bit:1; #endif u_int16_t protocol; u_int16_t payload_len; u_int16_t call_id; } gre_v1_t; /* * GRE function */ void dump_gre(packet_t *); #endif ipgrab-0.9.10/src/hexbuffer.c0000644000175000001440000000767410637713125015207 0ustar farooqusers/**************************************************************************** ** File: hexbuffer.c ** ** Author: Mike Borella ** ** Comments: Hex buffer manipulation routines ** ** $Id: hexbuffer.c,v 1.6 2007/06/25 10:17:57 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "hexbuffer.h" #include "display.h" #include "error.h" #define HEXBUFFER_SIZE 4000 /* max size of hex buffer */ #define TEMPBUFFER_SIZE 128 static u_int8_t hexbuffer[HEXBUFFER_SIZE]; static u_int16_t current_ptr = 0; extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** hexbuffer_kill() ** ** Reset the hex buffer without displaying its contents ** **---------------------------------------------------------------------------- */ inline void hexbuffer_kill() { /* * Sanity check */ if (!my_args->x || my_args->m) return; current_ptr = 0; } /*---------------------------------------------------------------------------- ** ** hexbuffer_add() ** ** Add bytes to the hex buffer ** **---------------------------------------------------------------------------- */ inline void hexbuffer_add(u_int8_t * bytes, int length) { /* * Sanity checks */ if (!my_args->x || my_args->m) return; if (length < 0) error_fatal("can't add length %d string to the hex buffer", length); /* check for buffer overflow */ if (current_ptr + length > HEXBUFFER_SIZE) { fprintf(stderr,"Hex buffer overflow!\n"); length = HEXBUFFER_SIZE - current_ptr; } /* copy the bytes into the hex buffer */ memcpy(&hexbuffer[current_ptr], bytes, length); current_ptr = current_ptr + length; } /*---------------------------------------------------------------------------- ** ** hexbuffer_flush() ** ** Flush the hex buffer ** **---------------------------------------------------------------------------- */ inline void hexbuffer_flush(void) { u_int8_t temp_hexbuf[TEMPBUFFER_SIZE], temp_charbuf[TEMPBUFFER_SIZE]; u_int8_t *buf_ptr, *buf_end; int i; /* * Sanity check */ if (!my_args->x || my_args->m) return; /* if there's nothing to print, skip out */ if (current_ptr == 0) return; /* mark the beginning and the end of the area to print */ buf_ptr = &hexbuffer[0]; buf_end = &hexbuffer[current_ptr]; /* display some dots as a separator */ display_header_line(HEADERLINE_DOTS); /* loop through the hex buffer, printing a line at a time */ do { memset(temp_hexbuf, 0, TEMPBUFFER_SIZE); memset(temp_charbuf, 0, TEMPBUFFER_SIZE); for(i=0;i<18;i++) { if(buf_ptr < buf_end) { snprintf(temp_hexbuf+(i*3), TEMPBUFFER_SIZE-1,"%.2X ", buf_ptr[0] & 0xFF); if(*buf_ptr > 0x1F && *buf_ptr < 0x7E) snprintf(temp_charbuf+i, TEMPBUFFER_SIZE-1, "%c", buf_ptr[0]); else snprintf(temp_charbuf+i, TEMPBUFFER_SIZE-1, "."); buf_ptr++; } } if (!check_layer()) printf("%-54s %s\n", temp_hexbuf, temp_charbuf); } while(buf_ptr < buf_end); /* now that the hex buffer is flushed, reset its size */ current_ptr = 0; } ipgrab-0.9.10/src/hexbuffer.h0000644000175000001440000000272607153266450015210 0ustar farooqusers/**************************************************************************** ** File: hexbuffer.h ** ** Author: Mike Borella ** ** Header file for hex buffer manipulation. The hex buffer holds ** all of the bytes read since the last time the hex buffer was flushed. ** When the hex buffer is flushed, all bytes are displayed in hex and ** (printable) ascii format to the screen, preceeded by a dotted line. ** ** $Id: hexbuffer.h,v 1.3 2000/08/30 20:23:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef HEXBUFFER_H #define HEXBUFFER_H #include "global.h" #include "local.h" inline void hexbuffer_add(u_int8_t *ptr, int length); inline void hexbuffer_flush(void); inline void hexbuffer_kill(void); #endif ipgrab-0.9.10/src/http.c0000644000175000001440000000530007304522724014170 0ustar farooqusers/**************************************************************************** ** File: http.c ** ** Author: Mike Borella ** ** Comments: Dump HTTP header information. I didn't try to do anything ** fancy with this - I just dump the plaintext headers. This makes ** debugging easier since parsing is such a pain to get right. ** ** $Id: http.c,v 1.6 2001/05/28 19:24:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "http.h" #define LINE_SIZE 256 #define FALSE 0 #define TRUE 1 extern struct arg_t *my_args; /*---------------------------------------------------------------------------- ** ** dump_http() ** ** Parse HTTP packet and dump fields. ** **---------------------------------------------------------------------------- */ void dump_http(packet_t *pkt) { char line[LINE_SIZE]; int i; int len; int first_line = 1; #ifdef DEBUG printf("\nEntering HTTP\n"); #endif /* Set the layer */ set_layer(LAYER_APPLICATION); /* announcement */ if (!my_args->m) display_header_banner("HTTP"); while(1) { len = get_packet_line(line, LINE_SIZE, pkt); if (len == 0) break; /* * If the first line doesn't * contain 'HTTP/', assume that there are no headers. * In minimal mode, just dump the first line. */ if (first_line) { if (!strstr(line, "HTTP/")) break; if (my_args->m) { display_minimal_string(line); break; } } first_line = 0; /* * If we have a line of all whitespace, that's the end of the headers. */ if (isspace_str(line, strlen(line))) break; /* * Display a header */ display_string("Header", line); /* * Convert each line to lower case for easier parsing. */ for (i=0; im) { display_minimal((u_int8_t *) &echo.seqno, 2, DISP_DEC); display_minimal_string(" "); } else { display("Identifier", (u_int8_t *) &echo.id, 2, DISP_DEC); display("Sequence number", (u_int8_t *) &echo.seqno, 2, DISP_DEC); } } /*---------------------------------------------------------------------------- ** ** dump_icmp_mask() ** ** Parse ICMP mask request and reply fields ** **---------------------------------------------------------------------------- */ void dump_icmp_mask(packet_t *pkt) { icmp_mask_t mask; /* * Get the Mask Request/Reply fields */ if (get_packet_bytes((u_int8_t *) &mask, pkt, 8) == 0) return; /* * Conversions */ mask.id = ntohs ( mask.id ); mask.seqno = ntohs ( mask.seqno ); /* * Dump the mask */ if (my_args->m) { display_minimal_ipv4((u_int8_t *) &mask.mask); display_minimal_string ( " " ); } else { display ( "Identifier", (u_int8_t *) &mask.id, 2, DISP_DEC ); display ( "Sequence Number", (u_int8_t *) &mask.seqno, 2, DISP_DEC ); display_ipv4("Mask", (u_int8_t *) &mask.mask); } } /*---------------------------------------------------------------------------- ** ** dump_icmp_routeradvert() ** ** Parse ICMP router advertisement ** **---------------------------------------------------------------------------- */ void dump_icmp_routeradvert(packet_t *pkt) { icmp_routeradvert_t ra; u_int32_t addr; u_int32_t preference; int i; /* * Get the basic fields */ if (get_packet_bytes((u_int8_t *) &ra, pkt, sizeof(ra)) == 0) return; /* Conversions */ ra.lifetime = ntohs(ra.lifetime); /* * Dump the basic fields */ if (my_args->m) { } else { display("Addresses", (u_int8_t *) &ra.addresses, 1, DISP_DEC); display("Address size", (u_int8_t *) &ra.address_size, 1, DISP_DEC); display("Lifetime", (u_int8_t *) &ra.lifetime, 2, DISP_DEC); } /* * Loop through addresses */ for (i=0; i < ra.addresses; i++) { if (get_packet_bytes((u_int8_t *) &addr, pkt, 4) == 0) return; if (get_packet_bytes((u_int8_t *) &preference, pkt, 4) == 0) return; /* Conversions */ preference = ntohl(preference); if (my_args->m) { display_minimal_ipv4((u_int8_t *) &addr); display_minimal_string("("); display_minimal((u_int8_t *) &preference, 4, DISP_DEC); display_minimal_string(") "); } else { display_ipv4("Address", (u_int8_t *) &addr); display("Preference", (u_int8_t *) &preference, 4, DISP_DEC); } } } /*---------------------------------------------------------------------------- ** ** dump_icmp() ** ** Parse ICMP header and dump fields ** **---------------------------------------------------------------------------- */ void dump_icmp(packet_t *pkt) { icmp_header_t icmp; char holder[HOLDER_SIZE]; /* Set the layer */ set_layer(LAYER_NETWORK); /* * Stats accounting */ stats_update(STATS_ICMP); /* * Get the header */ if (get_packet_bytes((u_int8_t *) &icmp, pkt, 4) == 0) return; if (my_args->m) { /* In minimal mode lets just dump the type and code */ display_minimal_string("| ICMP "); display_minimal_string(map2str(icmp_type_map, icmp.type)); display_minimal_string(" "); switch(icmp.type) { case ICMP_TYPE_DESTUNREACHABLE: display_minimal_string(map2str(icmp_du_map, icmp.code)); break; case ICMP_TYPE_TIMEEXCEEDED: display_minimal_string(map2str(icmp_timeexceeded_map, icmp.code)); break; case ICMP_TYPE_ECHOREPLY: case ICMP_TYPE_ECHOREQUEST: dump_icmp_echo(pkt); break; case ICMP_TYPE_MASKREQUEST: case ICMP_TYPE_MASKREPLY: dump_icmp_mask(pkt); break; case ICMP_TYPE_ROUTERADVERT: dump_icmp_routeradvert(pkt); break; case ICMP_TYPE_ROUTERSOLICIT: return; case ICMP_TYPE_SOURCEQUENCH: case ICMP_TYPE_REDIRECT: case ICMP_TYPE_PARAMPROBLEM: case ICMP_TYPE_TIMESTAMP: case ICMP_TYPE_TIMESTAMPREPLY: case ICMP_TYPE_INFOREQUEST: case ICMP_TYPE_INFOREPLY: case ICMP_TYPE_TRACEROUTE: case ICMP_TYPE_CONVERSIONERROR: break; default: break; } } else { /* announcement */ display_header_banner("ICMP Header"); /* Dump the type */ snprintf(holder, HOLDER_SIZE, "%d (%s)", icmp.type, map2str(icmp_type_map, icmp.type)); display("Type", (u_int8_t *) holder, strlen(holder), DISP_STRING); /* * Based on the type, dump the code, if the type has codes */ switch(icmp.type) { case ICMP_TYPE_DESTUNREACHABLE: snprintf(holder, HOLDER_SIZE, "%d (%s)", icmp.code, map2str(icmp_du_map, icmp.code)); display("Code", (u_int8_t *) &holder, strlen(holder), DISP_STRING); break; case ICMP_TYPE_TIMEEXCEEDED: snprintf(holder, HOLDER_SIZE, "%d (%s)", icmp.code, map2str(icmp_timeexceeded_map, icmp.code)); display("Code", (u_int8_t *) &holder, strlen(holder), DISP_STRING); break; default: display("Code", (u_int8_t *) &icmp.code, 1, DISP_DEC); break; } icmp.checksum = ntohs(icmp.checksum); display("Checksum", (u_int8_t *) &icmp.checksum, 2, DISP_DEC); /* * Call an ICMP-type-specific function */ switch (icmp.type) { case ICMP_TYPE_ECHOREPLY: case ICMP_TYPE_ECHOREQUEST: dump_icmp_echo(pkt); /* dump the hex buffer */ hexbuffer_flush(); return; /* bail so that we don't continue reading */ case ICMP_TYPE_DESTUNREACHABLE: /* Get the unused bytes */ if (get_packet_bytes((u_int8_t *) &holder, pkt, 4) == 0) return; break; case ICMP_TYPE_ROUTERSOLICIT: /* Get the unused bytes */ if (get_packet_bytes((u_int8_t *) &holder, pkt, 4) == 0) return; /* dump the hex buffer */ hexbuffer_flush(); return; case ICMP_TYPE_ROUTERADVERT: dump_icmp_routeradvert(pkt); /* dump the hex buffer */ hexbuffer_flush(); return; case ICMP_TYPE_SOURCEQUENCH: case ICMP_TYPE_REDIRECT: case ICMP_TYPE_PARAMPROBLEM: case ICMP_TYPE_TIMESTAMP: case ICMP_TYPE_TIMESTAMPREPLY: case ICMP_TYPE_INFOREQUEST: case ICMP_TYPE_INFOREPLY: case ICMP_TYPE_TRACEROUTE: case ICMP_TYPE_CONVERSIONERROR: break; case ICMP_TYPE_TIMEEXCEEDED: /* Get the unused bytes */ if (get_packet_bytes((u_int8_t *) &holder, pkt, 4) == 0) return; break; case ICMP_TYPE_MASKREQUEST: case ICMP_TYPE_MASKREPLY: dump_icmp_mask(pkt); break; default: break; } /* dump the hex buffer */ hexbuffer_flush(); /* * In most ICMP packets there will be an IP header after the ICMP hdr. * If it seems to be there, we can parse it out */ if (get_packet_apparentbytesleft(pkt) >= 20) dump_ip(pkt); } } ipgrab-0.9.10/src/icmp.h0000644000175000001440000000525507232156047014160 0ustar farooqusers/**************************************************************************** ** File: icmp.h ** ** Author: Mike Borella ** ** Comments: Generic ICMP header format for fixed portion ** ** $Id: icmp.h,v 1.6 2001/01/20 00:30:31 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef ICMP_H #define ICMP_H #include "global.h" #include "local.h" typedef struct icmp_header { u_int8_t type; u_int8_t code; u_int16_t checksum; } icmp_header_t; /* * Let's list all of the ICMP types here. Whoo-hoo! * Actually, these are only the ones made "official" by an RFC. */ #define ICMP_TYPE_ECHOREPLY 0 #define ICMP_TYPE_DESTUNREACHABLE 3 #define ICMP_TYPE_SOURCEQUENCH 4 #define ICMP_TYPE_REDIRECT 5 #define ICMP_TYPE_ECHOREQUEST 8 #define ICMP_TYPE_ROUTERADVERT 9 #define ICMP_TYPE_ROUTERSOLICIT 10 #define ICMP_TYPE_TIMEEXCEEDED 11 #define ICMP_TYPE_PARAMPROBLEM 12 #define ICMP_TYPE_TIMESTAMP 13 #define ICMP_TYPE_TIMESTAMPREPLY 14 #define ICMP_TYPE_INFOREQUEST 15 #define ICMP_TYPE_INFOREPLY 16 #define ICMP_TYPE_MASKREQUEST 17 #define ICMP_TYPE_MASKREPLY 18 #define ICMP_TYPE_TRACEROUTE 30 #define ICMP_TYPE_CONVERSIONERROR 31 /* * These are the ICMP destination unreachable codes */ #define ICMP_DU_NET 0 #define ICMP_DU_HOST 1 #define ICMP_DU_PROTOCOL 2 #define ICMP_DU_PORT 3 #define ICMP_DU_FRAG 4 #define ICMP_DU_SRCRTEFAIL 5 #define ICMP_DU_NETUNKNOWN 6 #define ICMP_DU_HOSTUNKNOWN 7 #define ICMP_DU_SRCISOLATED 8 #define ICMP_DU_NETADMIN 9 #define ICMP_DU_HOSTADMIN 10 #define ICMP_DU_NETTOS 11 #define ICMP_DU_HOSTTOS 12 #define ICMP_DU_ADMIN 13 #define ICMP_DU_HOSTPRECVIOL 14 #define ICMP_DU_PRECCUTOFF 15 /* * These are the ICMP time exceeded codes */ #define ICMP_TIMEEXCEEDED_TTL 0 #define ICMP_TIMEEXCEEDED_REASSEMBLY 1 /* * Function prototypes */ void dump_icmp(packet_t *); #endif ipgrab-0.9.10/src/icmpv6.c0000644000175000001440000001427410637732100014421 0ustar farooqusers/**************************************************************************** ** File: icmpv6.c ** ** Author: Mike Borella ** ** Comments: Dump ICMPv6 information ** ** $Id: icmpv6.c,v 1.18 2007/06/25 12:25:36 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "ipv6.h" #include "icmpv6.h" #define HOLDER_SIZE 64 /* * ICMPv6 type map */ strmap_t icmpv6_type_map [] = { { ICMPV6_TYPE_DESTUNREACHABLE, "destination unreachable" }, { ICMPV6_TYPE_PACKETTOOBIG, "packet too big" }, { ICMPV6_TYPE_TIMEEXCEEDED, "time exceeded" }, { ICMPV6_TYPE_PARAMETERPROBLEM, "parameter problem" }, { ICMPV6_TYPE_ECHOREQUEST, "echo request" }, { ICMPV6_TYPE_ECHOREPLY, "echo reply" }, { ICMPV6_TYPE_GROUPMEMQUERY, "group membership query" }, { ICMPV6_TYPE_GROUPMEMREPORT, "group membership report" }, { ICMPV6_TYPE_GROUPMEMREDUCTION, "group membership reduction" }, { ICMPV6_TYPE_ROUTERSOLICIT, "router solicitation" }, { ICMPV6_TYPE_ROUTERADVERT, "router advertisement" }, { ICMPV6_TYPE_NEIGHBORSOLICIT, "neighbor solicitation" }, { ICMPV6_TYPE_NEIGHBORADVERT, "neighbor advertisement" }, { ICMPV6_TYPE_REDIRECT, "redirect" }, { 0, "" } }; /* * ICMPv6 destination unreachable code map */ strmap_t icmpv6_ducode_map [] = { { ICMPV6_DUCODE_NOROUTE, "no route" }, { ICMPV6_DUCODE_ADMIN, "administratively prohibited" }, { ICMPV6_DUCODE_ADDRUNREACHABLE, "address unreachable" }, { ICMPV6_DUCODE_PORTUNREACHABLE, "port unreachable" }, { 0, "" } }; extern struct arg_t *my_args; /*---------------------------------------------------------------------------- ** ** dump_icmpv6() ** ** Parse ICMPv6 header and dump fields ** **---------------------------------------------------------------------------- */ void dump_icmpv6(packet_t *pkt) { icmpv6_header_t icmpv6; char holder[HOLDER_SIZE]; u_int32_t parameter; u_int16_t ping6_id, ping6_seqno; u_int8_t v6addr[16]; /* Set the layer */ set_layer(LAYER_NETWORK); /* * Stats accounting */ stats_update(STATS_ICMPV6); /* * Get the ICMPv6 header */ if (get_packet_bytes((u_int8_t *) &icmpv6, pkt, 4) == 0) return; /* * Conversions */ icmpv6.checksum = ntohs(icmpv6.checksum); /* * Dump header */ if (my_args->m) { display_minimal_string("| ICMPv6 "); display_minimal_string(map2str(icmpv6_type_map, icmpv6.type)); display_minimal_string(" "); } else { /* announcement */ display_header_banner("ICMPv6 Header"); /* print type */ snprintf(holder, HOLDER_SIZE, "%d (%s)", icmpv6.type, map2str(icmpv6_type_map, icmpv6.type)); display_string("Type", holder); /* based on the type, decide what to do with the code */ switch(icmpv6.type) { case ICMPV6_TYPE_DESTUNREACHABLE: snprintf(holder, HOLDER_SIZE, "%d (%s)", icmpv6.code, map2str(icmpv6_ducode_map, icmpv6.code)); display_string("Code", holder); break; default: display("Code", (u_int8_t *) &icmpv6.code, 1, DISP_DEC); } display("Checksum", (u_int8_t *) &icmpv6.checksum, 2, DISP_DEC); } /* * Special processing of the rest of the ICMP part */ switch(icmpv6.type) { case ICMPV6_TYPE_DESTUNREACHABLE: case ICMPV6_TYPE_TIMEEXCEEDED: /* skip unused 4 bytes */ if (skip_packet_bytes(pkt, 4) == 0) return; /* dump the contained IPv6 header */ if (get_packet_apparentbytesleft(pkt)) dump_ipv6(pkt); break; case ICMPV6_TYPE_PACKETTOOBIG: /* next 4 bytes should be the mtu, get them, convert, display */ if (get_packet_bytes((u_int8_t *) ¶meter, pkt, 4) == 0) return; parameter = ntohl(parameter); display("MTU", (u_int8_t *) ¶meter, 4, DISP_DEC); /* dump the contained IPv6 header */ if (get_packet_apparentbytesleft(pkt)) dump_ipv6(pkt); break; case ICMPV6_TYPE_PARAMETERPROBLEM: /* next 4 bytes should be a pointer, get them, convert, display */ if (get_packet_bytes((u_int8_t *) ¶meter, pkt, 4) == 0) return; parameter = ntohl(parameter); display("Pointer", (u_int8_t *) ¶meter, 4, DISP_DEC); /* dump the contained IPv6 header */ if (get_packet_apparentbytesleft(pkt)) dump_ipv6(pkt); break; case ICMPV6_TYPE_ECHOREQUEST: case ICMPV6_TYPE_ECHOREPLY: /* Next 4 bytes are an id followed by a seqno: get, convert, display */ if (get_packet_bytes((u_int8_t *) &ping6_id, pkt, 2) == 0) return; if (get_packet_bytes((u_int8_t *) &ping6_seqno, pkt, 2) == 0) return; ping6_id = ntohs(ping6_id); ping6_seqno = ntohs(ping6_seqno); if (my_args->m) { display_minimal((u_int8_t *) &ping6_seqno, 2, DISP_DEC); } else { display("Identifier", (u_int8_t *) &ping6_id, 2, DISP_DEC); display("Sequence number", (u_int8_t *) &ping6_seqno, 2, DISP_DEC); } break; case ICMPV6_TYPE_NEIGHBORSOLICIT: /* Skip 4 unused bytes */ if ( skip_packet_bytes (pkt,4) == 0 ) return 0; /* Next 16 bytes are an IPv6 address */ if (get_packet_bytes((u_int8_t *) &v6addr, pkt, 16) == 0) return; if (my_args->m) { display_minimal_ipv6((u_int8_t *) &v6addr); display_minimal_string(" "); } else display_ipv6("Address", (u_int8_t *) &v6addr); break; default: break; } } ipgrab-0.9.10/src/icmpv6.h0000644000175000001440000000466010530527426014431 0ustar farooqusers/**************************************************************************** ** File: icmpv6.h ** ** Author: Mike Borella ** ** Generic ICMPv6 header structures. ** ** $Id: icmpv6.h,v 1.8 2006/11/21 07:47:34 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef ICMPV6_H #define ICMPV6_H #include "global.h" #include "local.h" /* * ICMPv6 type fields */ #define ICMPV6_TYPE_DESTUNREACHABLE 1 #define ICMPV6_TYPE_PACKETTOOBIG 2 #define ICMPV6_TYPE_TIMEEXCEEDED 3 #define ICMPV6_TYPE_PARAMETERPROBLEM 4 #define ICMPV6_TYPE_ECHOREQUEST 128 #define ICMPV6_TYPE_ECHOREPLY 129 #define ICMPV6_TYPE_GROUPMEMQUERY 130 #define ICMPV6_TYPE_GROUPMEMREPORT 131 #define ICMPV6_TYPE_GROUPMEMREDUCTION 132 #define ICMPV6_TYPE_ROUTERSOLICIT 133 #define ICMPV6_TYPE_ROUTERADVERT 134 #define ICMPV6_TYPE_NEIGHBORSOLICIT 135 #define ICMPV6_TYPE_NEIGHBORADVERT 136 #define ICMPV6_TYPE_REDIRECT 137 /* * ICMPv6 destination unreachable code fields */ #define ICMPV6_DUCODE_NOROUTE 0 #define ICMPV6_DUCODE_ADMIN 1 #define ICMPV6_DUCODE_ADDRUNREACHABLE 2 #define ICMPV6_DUCODE_PORTUNREACHABLE 3 /* * ICMPv6 time exceeded code fields */ #define ICMPV6_TECODE_HOPLIMIT 0 #define ICMPV6_TECODE_REASSEMBLY 1 /* * ICMPv6 parameter problem code fields */ #define ICMPV6_PPCODE_BADHEADERFIELD 0 #define ICMPV6_PPCODE_BADNEXTHEADER 1 #define ICMPV6_PPCODE_BADIPV6OPTION 2 /* * ICMPv6 common header format */ typedef struct icmpv6_header { u_int8_t type; u_int8_t code; u_int16_t checksum; } icmpv6_header_t; void dump_icmpv6(packet_t *); #endif ipgrab-0.9.10/src/igmp.c0000644000175000001440000000607110530527426014152 0ustar farooqusers/**************************************************************************** ** File: igmp.c ** ** Author: Mike Borella ** ** Comments: Dump IGMP information ** ** $Id: igmp.c,v 1.13 2006/11/21 07:47:34 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "igmp.h" #define HOLDER_SIZE 64 extern struct arg_t * my_args; /* * Contains the descriptions of IGMP types */ strmap_t igmp_type_map[] = { { IGMP_TYPE_MEMBERQUERY, "membership query" }, { IGMP_TYPE_MEMBERREPORTV1, "v1 membership report" }, { IGMP_TYPE_DVMRP, "DVMRP" }, { IGMP_TYPE_MEMBERREPORTV2, "v2 membership report" }, { IGMP_TYPE_LEAVEGROUP, "leave group" }, { 0, "" } }; /*---------------------------------------------------------------------------- ** ** dump_igmp() ** ** Parse IGMP header and dump fields ** **---------------------------------------------------------------------------- */ void dump_igmp(packet_t *pkt) { igmp_header_t igmp; char holder[HOLDER_SIZE]; /* Set the layer */ set_layer(LAYER_NETWORK); /* * Stats accounting */ stats_update(STATS_IGMP); /* * Get the header. Note that the length of 8 may cause a problem with * some DVMRP packets, but so far it hasn't. Change it to 4 later for * safety... -MB */ if (get_packet_bytes((u_int8_t *) &igmp, pkt, 8) == 0) return; /* * Conversions */ igmp.checksum = ntohs(igmp.checksum); /* * Dump the contents */ if (my_args->m) { /* In minimal mode lets just dump the type and address */ display_minimal_string("| IGMP "); display_minimal_string(map2str(igmp_type_map, igmp.type)); display_minimal_string(" "); } else { /* announcement */ display_header_banner("IGMP Header"); /* Dump the type, max resp time, checksum and address */ snprintf(holder, HOLDER_SIZE, "%d (%s)", igmp.type, map2str(igmp_type_map, igmp.type)); display_string("Type", holder); display("Max response time", (u_int8_t *) &igmp.max_resp_time, 1, DISP_DEC); display("Checksum", (u_int8_t *) &igmp.checksum, 2, DISP_DEC); /* * We currently don't try to interpret DVMRP packets... */ if (igmp.type != IGMP_TYPE_DVMRP) display_ipv4("Group address", (u_int8_t *) &igmp.address); } } ipgrab-0.9.10/src/igmp.h0000644000175000001440000000273610530527426014163 0ustar farooqusers/**************************************************************************** ** File: igmp.h ** ** Author: Mike Borella ** ** Comments: Generic IGMP header format ** ** $Id: igmp.h,v 1.5 2006/11/21 07:47:34 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef IGMP_H #define IGMP_H #include "global.h" #include "local.h" typedef struct igmp_header { u_int8_t type; u_int8_t max_resp_time; u_int16_t checksum; u_int32_t address; } igmp_header_t; /* * IGMP types */ #define IGMP_TYPE_MEMBERQUERY 0x11 #define IGMP_TYPE_MEMBERREPORTV1 0x12 #define IGMP_TYPE_DVMRP 0x13 #define IGMP_TYPE_MEMBERREPORTV2 0x16 #define IGMP_TYPE_LEAVEGROUP 0x17 void dump_igmp(packet_t *); #endif ipgrab-0.9.10/src/ip.c0000644000175000001440000002046310530527426013627 0ustar farooqusers/**************************************************************************** ** File: ip.c ** ** Author: Mike Borella ** ** Comments: Dump IP header information ** ** $Id: ip.c,v 1.27 2006/11/21 07:47:34 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "global.h" #include "ip_protocols.h" #include "ip_services.h" #define HOLDER_SIZE 64 /* * Contains the descriptions of IP options */ strmap_t ip_option_map[] = { { IP_OPTION_EOL, "end of options" }, { IP_OPTION_NOP, "no op" }, { IP_OPTION_RECORDROUTE, "record route" }, { IP_OPTION_TIMESTAMP, "time stamp" }, { IP_OPTION_TRACEROUTE, "traceroute" }, { IP_OPTION_SECURITY, "security" }, { IP_OPTION_LSR, "loose source route" }, { IP_OPTION_EXTSECURITY, "extra security" }, { IP_OPTION_COMSECURITY, "commercial security" }, { IP_OPTION_STREAMID, "stream ID" }, { IP_OPTION_SSR, "strict source route" }, { IP_OPTION_ROUTERALERT, "router alert" }, { 0, "" } }; extern struct arg_t *my_args; extern void (*ip_proto_func[])(packet_t *); extern strmap_t ipproto_map[]; void dump_ip_options(packet_t *, u_int8_t); /*---------------------------------------------------------------------------- ** ** dump_ip() ** ** Parse IP header and dump fields ** **---------------------------------------------------------------------------- */ void dump_ip(packet_t *pkt) { ip_header_t ip; u_int16_t frag_off; u_int8_t ver, hlen; u_int8_t u_bit, df_bit, mf_bit; #ifdef DEBUG printf("\nEntering IP\n"); #endif /* Set the layer */ set_layer(LAYER_NETWORK); /* * Stats accounting */ stats_update(STATS_IP); /* * Get the IP header */ if (get_packet_bytes((u_int8_t *) &ip, pkt, sizeof(ip_header_t)) == 0) return; /* * Conversions */ ver = ip.version; hlen = ip.header_length; ip.offset = ntohs(ip.offset); ip.length = ntohs(ip.length); ip.id = ntohs(ip.id); frag_off = ip.offset & 0x1fff; u_bit = (ip.offset & 0x8000) >> 15; df_bit = (ip.offset & 0x4000) >> 14; mf_bit = (ip.offset & 0x2000) >> 13; ip.checksum = ntohs(ip.checksum); /* * Set the effective end of the packet. Take the total length as per the * IP header, subtract the header we've read. This is the number of bytes * into the packet where the end should be. This helps us get rid of * link layer padding on tinygrams. */ set_packet_apparentend(pkt, ip.length - sizeof(ip_header_t)); /* * Dump header */ if (my_args->m) { u_int16_t new_fo = frag_off * 8; display_minimal_string("| IP "); display_minimal_ipv4((u_int8_t *) &ip.src); display_minimal_string("->"); display_minimal_ipv4((u_int8_t *) &ip.dst); display_minimal_string(" (len:"); display_minimal((u_int8_t *) &ip.length, 2, DISP_DEC); display_minimal_string(",id:"); display_minimal((u_int8_t *) &ip.id, 2, DISP_DEC); if (df_bit) display_minimal_string(",DF"); if (mf_bit) display_minimal_string(",MF"); display_minimal_string(",frag:"); display_minimal((u_int8_t *) &new_fo, 2, DISP_DEC); display_minimal_string(") "); } else { u_int8_t holder[64]; /* announcement */ display_header_banner("IP Header"); /* print fields */ display("Version", (u_int8_t *) &ver, 1, DISP_DEC); sprintf(holder, "%d (%d bytes)", hlen, hlen*4); display_string("Header length", holder); display("TOS", (u_int8_t *) &ip.tos, 1, DISP_HEX); display("Total length", (u_int8_t *) &ip.length, 2, DISP_DEC); display("Identification", (u_int8_t *) &ip.id, 2, DISP_DEC); if (frag_off) { sprintf(holder, "%d (%d bytes)", frag_off, frag_off*8); display_string("Fragmentation offset", holder); } else display("Fragmentation offset", (u_int8_t *) &frag_off, 2, DISP_DEC); display("Unused bit", (u_int8_t *) &u_bit, 1, DISP_BINNLZ); display("Don't fragment bit", (u_int8_t *) &df_bit, 1, DISP_BINNLZ); display("More fragments bit", (u_int8_t *) &mf_bit, 1, DISP_BINNLZ); display("Time to live", (u_int8_t *) &ip.ttl, 1, DISP_DEC); display_strmap("Protocol", ip.protocol, ipproto_map); display("Header checksum", (u_int8_t *) &ip.checksum, 2, DISP_DEC); /* IP's are not in network byte order?? */ display_ipv4("Source address", (u_int8_t *) &ip.src); display_ipv4("Destination address", (u_int8_t *) &ip.dst); } /* set IP address state */ state_set_srcaddr(ntohl(ip.src)); state_set_dstaddr(ntohl(ip.dst)); /* check for IP options */ if (hlen > 5) dump_ip_options(pkt, hlen * 4 - 20); /* dump the hex buffer */ hexbuffer_flush(); /* * If this is fragment zero, hand it to the next higher * level protocol. */ if ((ip.offset & 0x1fff) == 0 && ip_proto_func[ip.protocol]) ip_proto_func[ip.protocol](pkt); #ifdef DEBUG printf("\nLeaving IP\n"); #endif } /*---------------------------------------------------------------------------- ** ** dump_ip_recordroute() ** ** Dump a record route IP option ** **---------------------------------------------------------------------------- */ void dump_ip_recordroute(u_int8_t * rr, u_int8_t len) { u_int8_t pointer; u_int32_t addr; int i; /* * The first byte should be a pointer and the next len-1 bytes should be * a series of IP addresses. If len-1 is not a multiple of 4 then something * is very wrong and we bail out. */ pointer = *rr; if (!my_args->m) { display(" Pointer", (u_int8_t *) &pointer, 1, DISP_HEX); } i = 1; while (i+3 <= len) { /* Get and address then increment i to the next address */ memcpy((u_int8_t *) &addr, rr+i, 4); display_ipv4(" Address", (u_int8_t *) &addr); i = i + 4; } } /*---------------------------------------------------------------------------- ** ** dump_ip_options() ** ** Dump any IP options ** **---------------------------------------------------------------------------- */ void dump_ip_options(packet_t *pkt, u_int8_t length) { u_int8_t bytes_read = 0; ip_option_t opt; char holder[HOLDER_SIZE]; while(bytes_read < length) { /* * Get the first byte to make sure that we don't have a 1-byte option */ if (get_packet_bytes((u_int8_t *) &opt.code, pkt, 1) == 0) return; bytes_read += 1; /* * Display it */ snprintf(holder, HOLDER_SIZE, "%d (%s)", opt.code, map2str(ip_option_map, opt.code)); if (!my_args->m) display_string("IP option code", holder); else { display_minimal_string(holder); display_minimal_string(" "); } /* * If it is 0, then its just a 1-byte EOL */ if (opt.code == 0) continue; /* * It isn't, so lets read the rest... */ if (get_packet_bytes((u_int8_t *) &opt.length, pkt, 1) == 0) return; bytes_read += 1; if (!my_args->m) display(" Length", (u_int8_t *) &opt.length, 1, DISP_DEC); /* * Get the rest of the option, adjusting the length by 2 to count * option type and length fields... */ if (get_packet_bytes((u_int8_t *) &holder, pkt, opt.length-2) == 0) return; bytes_read = bytes_read + opt.length - 2; /* * Do something intelligent with the options that we understand */ switch(opt.code) { case IP_OPTION_RECORDROUTE: dump_ip_recordroute(holder, opt.length-2); break; default: break; } } } ipgrab-0.9.10/src/ip.h0000644000175000001440000000403607153266450013636 0ustar farooqusers/**************************************************************************** ** File: ip.h ** ** Author: Mike Borella ** ** Comments: Generic IP header structure - an attempt at OS independence ** ** $Id: ip.h,v 1.7 2000/08/30 20:23:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef IP_H #define IP_H #include "global.h" #include "local.h" typedef struct ip_header { #if defined(WORDS_BIGENDIAN) u_int8_t version:4, header_length:4; #else u_int8_t header_length:4, version:4; #endif u_int8_t tos; u_int16_t length; u_int16_t id; u_int16_t offset; u_int8_t ttl; u_int8_t protocol; u_int16_t checksum; u_int32_t src; u_int32_t dst; } ip_header_t; typedef struct ip_option { u_int8_t code; u_int8_t length; } ip_option_t; #define IP_OPTION_EOL 0 #define IP_OPTION_NOP 1 #define IP_OPTION_RECORDROUTE 7 #define IP_OPTION_TIMESTAMP 68 #define IP_OPTION_TRACEROUTE 82 #define IP_OPTION_SECURITY 130 #define IP_OPTION_LSR 131 #define IP_OPTION_EXTSECURITY 133 #define IP_OPTION_COMSECURITY 134 #define IP_OPTION_STREAMID 136 #define IP_OPTION_SSR 137 #define IP_OPTION_ROUTERALERT 148 void dump_ip(packet_t *); #endif ipgrab-0.9.10/src/ip_protocols.c0000644000175000001440000000712607370363552015742 0ustar farooqusers/**************************************************************************** ** File: ip_protocols.c ** ** Author: Mike Borella ** ** Comments: Functions to handle certain IP protocol numbers ** ** $Id: ip_protocols.c,v 1.18 2001/11/02 00:23:06 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "global.h" #include "ip_protocols.h" #define IP_PROTO_ARRAY_SIZE 256 /* * Make an array that will hold all of the pointers to protocol functions */ void (*ip_proto_func[IP_PROTO_ARRAY_SIZE])(packet_t *); /* * Fill the array up with pointers. I'd like to do this in global space * so that this function does not have to be explicitly called...but I can't * get that to work right (won't compile). Help? */ void init_ip_protocols(void) { int i; for (i = 0; i < 256; i++) ip_proto_func[i] = NULL; ip_proto_func[PROTO_ICMP] = dump_icmp; ip_proto_func[PROTO_IGMP] = dump_igmp; ip_proto_func[PROTO_IPENCAP] = dump_ip; ip_proto_func[PROTO_TCP] = dump_tcp; ip_proto_func[PROTO_UDP] = dump_udp; ip_proto_func[PROTO_GRE] = dump_gre; ip_proto_func[PROTO_RSVP] = dump_rsvp; ip_proto_func[PROTO_ESP] = dump_esp; ip_proto_func[PROTO_AH] = dump_ah; ip_proto_func[PROTO_OSPF] = dump_ospf; ip_proto_func[PROTO_IPV6ICMP] = dump_icmpv6; ip_proto_func[PROTO_IPV6] = dump_ipv6; ip_proto_func[PROTO_PUP] = dump_tcp; } /* * IP protocol map. There appears to be 3 different types of IP in IP * encapsulation. Weird. I'm not sure which is(are) really used... */ strmap_t ipproto_map[] = { { PROTO_IPV6HOP, "IPv6 hop by hop" }, { PROTO_ICMP, "ICMP" }, { PROTO_IGMP, "IGMP" }, { PROTO_GGP, "GGP" }, { PROTO_IPENCAP, "IP encapsulation" }, { PROTO_ST, "ST" }, { PROTO_TCP, "TCP" }, { PROTO_CBT, "CBT" }, { PROTO_EGP, "EGP" }, { PROTO_IGP, "IGP" }, { PROTO_PUP, "PUP" }, { PROTO_UDP, "UDP" }, { PROTO_HMP, "HMP" }, { PROTO_XNSIDP, "XNS IDP" }, { PROTO_RDP, "RDP" }, { PROTO_IPV6, "IPv6" }, { PROTO_IPV6ROUTE, "IPv6 route" }, { PROTO_IPV6FRAG, "IPv6 fragmentation" }, { PROTO_IDRP, "IDRP" }, { PROTO_RSVP, "RSVP" }, { PROTO_GRE, "GRE" }, { PROTO_ESP, "ESP" }, { PROTO_AH, "AH" }, { PROTO_NARP, "NARP" }, { PROTO_IPV6ICMP, "ICMPv6" }, { PROTO_IPV6NONEXT, "IPv6 no next header" }, { PROTO_IPV6OPTS, "IPv6 options" }, { PROTO_RSPF, "Radio shortest path first" }, { PROTO_VMTP, "Versatile message transport" }, { PROTO_OSPF, "OSPF" }, { PROTO_IPIP, "IPinIP" }, { PROTO_ENCAP, "IPinIP encapsulation" }, { 0, "" } }; ipgrab-0.9.10/src/ip_protocols.h0000644000175000001440000000451007257726274015751 0ustar farooqusers/**************************************************************************** ** File: ip_protocols.h ** ** Author: Mike Borella ** ** Comments: IP next protocol numbers ** ** $Id: ip_protocols.h,v 1.11 2001/03/26 20:55:24 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef IP_PROTOCOLS_H #define IP_PROTOCOLS_H #include "ip.h" #include "tcp.h" #include "udp.h" #include "ah.h" #include "esp.h" #include "icmp.h" #include "igmp.h" #include "ospf.h" #include "icmpv6.h" #include "ipv6.h" #include "gre.h" #include "rsvp.h" /* * This list contains lots of crufty old protocols just for kicks. * The complete list is at http://www.iana.org. */ #define PROTO_IPV6HOP 0 #define PROTO_ICMP 1 #define PROTO_IGMP 2 #define PROTO_GGP 3 #define PROTO_IPENCAP 4 #define PROTO_ST 5 #define PROTO_TCP 6 #define PROTO_CBT 7 #define PROTO_EGP 8 #define PROTO_IGP 9 #define PROTO_PUP 12 #define PROTO_UDP 17 #define PROTO_HMP 20 #define PROTO_XNSIDP 22 #define PROTO_RDP 27 #define PROTO_IPV6 41 #define PROTO_IPV6ROUTE 43 #define PROTO_IPV6FRAG 44 #define PROTO_IDRP 45 #define PROTO_RSVP 46 #define PROTO_GRE 47 #define PROTO_ESP 50 #define PROTO_AH 51 #define PROTO_NARP 54 #define PROTO_IPV6ICMP 58 #define PROTO_IPV6NONEXT 59 #define PROTO_IPV6OPTS 60 #define PROTO_RSPF 73 #define PROTO_VMTP 81 #define PROTO_OSPF 89 #define PROTO_IPIP 94 #define PROTO_ENCAP 98 void init_ip_protocols(void); #endif /* ip_protocols.h */ ipgrab-0.9.10/src/ip_services.c0000644000175000001440000001205010530527426015523 0ustar farooqusers/**************************************************************************** ** File: ip_services.c ** ** Author: Mike Borella ** ** Comments: Functions to handle certain IP protocol numbers ** ** $Id: ip_services.c,v 1.14 2006/11/21 07:47:34 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "global.h" #include "ip_services.h" #include "dynports.h" /* * We'll put the port map here even though it is used by TCP and UDP. * BTW, we can call these anything we'd like. Suggestions welcome :-) */ strmap_t port_map[] = { { PORT_TCPMUX, "TCP multiplexing" }, { PORT_ECHO, "echo" }, { PORT_DISCARD, "discard" }, { PORT_SYSTAT, "systat" }, { PORT_DAYTIME, "daytime" }, { PORT_NETSTAT, "netstat" }, { PORT_QOTD, "quote of the day" }, { PORT_MSP, "MSP" }, { PORT_CHARGEN, "character generator" }, { PORT_FTPDATA, "FTP data" }, { PORT_FTPCTRL, "FTP control" }, { PORT_SSH, "SSH" }, { PORT_TELNET, "telnet" }, { PORT_SMTP, "SMTP" }, { PORT_TIME, "time" }, { PORT_RLP, "RLP" }, { PORT_NAMESERVER, "name server" }, { PORT_WHOIS, "whois" }, { PORT_REMOTEMAILCHECK, "remote mail checking" }, { PORT_DNS, "DNS" }, { PORT_MTP, "MTP" }, { PORT_DHCPSERVER, "DHCP/BOOTP server" }, { PORT_DHCPCLIENT, "DHCP/BOOTP client" }, { PORT_TFTP, "TFTP" }, { PORT_GOPHER, "gopher" }, { PORT_RJE, "RJE" }, { PORT_FINGER, "finger" }, { PORT_HTTP, "http" }, { PORT_TTYLINK, "ttylink" }, { PORT_KERBEROS, "Kerberos" }, { PORT_SUPDUP, "SUPDUP" }, { PORT_HOSTNAMES, "hostnames" }, { PORT_ISOTSAP, "ISO TSAP" }, { PORT_CSNETNAMESERVICE, "CSNET name service" }, { PORT_EUDORA, "Eudora" }, { PORT_RTELNET, "rtelnet" }, { PORT_POP2, "POP2" }, { PORT_POP3, "POP3" }, { PORT_SUNRPC, "sunrpc" }, { PORT_NNTP, "nntp" }, { PORT_AUTH, "auth" }, { PORT_SNMP, "SNMP" }, { PORT_NETBIOSNS, "NETBIOS name service" }, { PORT_NETBIOSDGM, "NETBIOS datagram service" }, { PORT_NETBIOSSSN, "NETBIOS session service" }, { PORT_SLP, "SLP" }, { PORT_MOBILEIP, "Mobile IP"}, { PORT_ISAKMP, "ISAKMP/IKE" }, { PORT_RIP, "RIP" }, { PORT_RIPNG, "RIPng" }, { PORT_CDMA2000A11, "CDMA2000 A11" }, { PORT_L2TP, "L2TP" }, { PORT_PPTP, "PPTP" }, { PORT_RADIUS, "RADIUS" }, { PORT_RADACCOUNT, "RADIUS accounting" }, { PORT_SIP, "SIP" }, { 0, "" } }; extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** port2func(u_int16_t) ** ** Map a port number to a function to call ** **---------------------------------------------------------------------------- */ service_func_t port2func(u_int16_t port) { service_func_t f = NULL; /* Check for dynamic mappings */ f = dynports_find(port); if (f == NULL) { switch(port) { case PORT_SSH: f = dump_ssh; break; case PORT_SIP: f = dump_sip; break; case PORT_DNS: f = dump_dns; break; case PORT_DHCPCLIENT: case PORT_DHCPSERVER: f = dump_dhcp; break; case PORT_HTTP: f = dump_http; break; case PORT_NNTP: f = dump_nntp; break; case PORT_NETBIOSNS: f = dump_netbios_ns; break; case PORT_SNMP: f = dump_snmp; break; case PORT_SLP: f = dump_slp; break; case PORT_MOBILEIP: f = dump_mobileip; break; case PORT_ISAKMP: f = dump_isakmp; break; case PORT_RIP: f = dump_rip; break; case PORT_RIPNG: f = dump_ripng; break; case PORT_CDMA2000A11: f = dump_mobileip; break; case PORT_L2TP: f = dump_l2tp; break; case PORT_PPTP: f = dump_pptp; break; case PORT_FTPCTRL: f = dump_ftpctrl; break; case PORT_TFTP: f = dump_tftp; break; case PORT_RADIUS: case PORT_RADACCOUNT: f = dump_radius; break; default: f = NULL; break; } } return f; } ipgrab-0.9.10/src/ip_services.h0000644000175000001440000001354410530527426015541 0ustar farooqusers/**************************************************************************** ** File: ip_services.h ** ** Author: Mike Borella ** ** Comments: IP service numbers ** ** $Id: ip_services.h,v 1.12 2006/11/21 07:47:34 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef IP_SERVICES_H #define IP_SERVICES_H #include "global.h" #include "dhcp.h" #include "dns.h" #include "http.h" #include "isakmp.h" #include "l2tp.h" #include "mgcp.h" #include "mobileip.h" #include "netbios_ns.h" #include "nntp.h" #include "pptp.h" #include "radius.h" #include "rip.h" #include "ripng.h" #include "rtcp.h" #include "rtp.h" #include "sip.h" #include "slp.h" #include "ssh.h" #include "ipgsnmp.h" #include "ftpctrl.h" #include "tftp.h" /* * List of well-known and non-so-well-known port numbers - NOT DONE YET! */ #define PORT_TCPMUX 1 #define PORT_ECHO 7 #define PORT_DISCARD 9 #define PORT_SYSTAT 11 #define PORT_DAYTIME 13 #define PORT_NETSTAT 15 #define PORT_QOTD 17 #define PORT_MSP 18 #define PORT_CHARGEN 19 #define PORT_FTPDATA 20 #define PORT_FTPCTRL 21 #define PORT_SSH 22 #define PORT_TELNET 23 #define PORT_SMTP 25 #define PORT_TIME 37 #define PORT_RLP 39 #define PORT_NAMESERVER 42 #define PORT_WHOIS 43 #define PORT_REMOTEMAILCHECK 50 #define PORT_DNS 53 #define PORT_MTP 57 #define PORT_DHCPSERVER 67 #define PORT_DHCPCLIENT 68 #define PORT_TFTP 69 #define PORT_GOPHER 70 #define PORT_RJE 77 #define PORT_FINGER 79 #define PORT_HTTP 80 #define PORT_TTYLINK 87 #define PORT_KERBEROS 88 #define PORT_SUPDUP 95 #define PORT_HOSTNAMES 101 #define PORT_ISOTSAP 102 #define PORT_CSNETNAMESERVICE 105 #define PORT_EUDORA 106 #define PORT_RTELNET 107 #define PORT_POP2 109 #define PORT_POP3 110 #define PORT_SUNRPC 111 #define PORT_AUTH 113 #define PORT_SFTP 115 #define PORT_UUCPPATH 117 #define PORT_NNTP 119 #define PORT_NETBIOSNS 137 #define PORT_NETBIOSDGM 138 #define PORT_NETBIOSSSN 139 #define PORT_IMAP2 143 #define PORT_SNMP 161 #define PORT_SNMPTRAP 162 #define PORT_CMIPMAN 163 #define PORT_CMIPAGENT 164 #define PORT_XDMCP 177 #define PORT_NEXTSTEP 178 #define PORT_BGP 179 #define PORT_PROSPERO 191 #define PORT_IRC 194 #define PORT_SMUX 199 #define PORT_APPLETALKRTMP 201 #define PORT_APPLETALKNBP 202 #define PORT_APPLETALKECHO 204 #define PORT_APPLETALKZIS 206 #define PORT_QMTP 209 #define PORT_Z3950 210 #define PORT_IPX 213 #define PORT_IMAP3 220 #define PORT_RPC2PORTMAP 369 #define PORT_CODAAUTH2 370 #define PORT_UNIXLISTSERV 372 #define PORT_SLP 427 #define PORT_MOBILEIP 434 #define PORT_HTTPS 443 #define PORT_SNPP 444 #define PORT_SAFT 487 #define PORT_ISAKMP 500 #define PORT_EXECBIFF 512 #define PORT_LOGIN 513 #define PORT_WHO 514 #define PORT_PRINTER 515 #define PORT_TALK 517 #define PORT_NTALK 518 #define PORT_RIP 520 #define PORT_RIPNG 521 #define PORT_TIMED 525 #define PORT_TEMPO 526 #define PORT_COURIER 530 #define PORT_CONFERENCE 531 #define PORT_NETNEWS 532 #define PORT_NETWALL 533 #define PORT_UUCP 540 #define PORT_KLOGIN 543 #define PORT_KSHELL 544 #define PORT_AFPOVERTCP 548 #define PORT_REMOTEFS 556 #define PORT_NPMPLOCAL 610 #define PORT_NPMPGUI 611 #define PORT_HMMPIND 612 #define PORT_CDMA2000A11 699 #define PORT_KERBEROSADM 749 #define PORT_WEBSTER 765 #define PORT_INGRESLOCK 1524 #define PORT_PROSPERONP 1525 #define PORT_DATAMETRICSRADIUS 1645 #define PORT_SAMSG 1646 #define PORT_L2TP 1701 #define PORT_PPTP 1723 #define PORT_RADIUS 1812 #define PORT_RADACCOUNT 1813 #define PORT_CVSSERVER 2401 #define PORT_VENUS 2430 #define PORT_VENUSSE 2431 #define PORT_CODASERVER 2432 #define PORT_CODASERVERSE 2433 #define PORT_MYSQL 3306 #define PORT_RFE 5002 #define PORT_SIP 5060 #define PORT_CFENGINE 5308 #define PORT_BBS 7000 /* * Define a type that is a function that takes a packet_t pointer and * returns a void */ typedef void (*service_func_t)(packet_t *); /* * This function maps a port number to a function that processes the * protocol that runs on that port */ service_func_t port2func(u_int16_t); #endif /* ip_services.h */ ipgrab-0.9.10/src/ipcp.c0000644000175000001440000001740110637726002014147 0ustar farooqusers/**************************************************************************** ** File: ipcp.c ** ** Author: Mike Borella ** ** Comments: IPCP module. ** ** $Id: ipcp.c,v 1.7 2007/06/25 11:50:26 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "ipcp.h" #define IPCP_OPTION_LEN 64 /* * IPCP codes */ #define IPCP_CODE_CONFREQ 1 #define IPCP_CODE_CONFACK 2 #define IPCP_CODE_CONFNAK 3 #define IPCP_CODE_CONFREJ 4 #define IPCP_CODE_TERMREQ 5 #define IPCP_CODE_TERMACK 6 #define IPCP_CODE_CODEREJ 7 /* * IPCP code map */ strmap_t ipcp_code_map[] = { { IPCP_CODE_CONFREQ, "Configure-Request" }, { IPCP_CODE_CONFACK, "Configure-Ack" }, { IPCP_CODE_CONFNAK, "Configure-Nak" }, { IPCP_CODE_CONFREJ, "Configure-Reject" }, { IPCP_CODE_TERMREQ, "Terminate-Request" }, { IPCP_CODE_TERMACK, "Terminate-Ack" }, { IPCP_CODE_CODEREJ, "Code-Rej" }, { 0, ""} }; /* * IPCP options */ #define IPCP_OPTION_IPADDRS 1 #define IPCP_OPTION_IPCOMPPROTO 2 #define IPCP_OPTION_IPADDR 3 #define IPCP_OPTION_MOBILEIPV4 4 #define IPCP_OPTION_PRIMARYDNS 129 #define IPCP_OPTION_PRIMARYNBNS 130 #define IPCP_OPTION_SECONDARYDNS 131 #define IPCP_OPTION_SECONDARYNBNS 132 /* * IPCP option map */ strmap_t ipcp_option_map[] = { { IPCP_OPTION_IPADDRS, "IP addresses" }, { IPCP_OPTION_IPCOMPPROTO, "IP compression protocol" }, { IPCP_OPTION_IPADDR, "IP address" }, { IPCP_OPTION_MOBILEIPV4, "Mobile IPv4" }, { IPCP_OPTION_PRIMARYDNS, "Primary DNS" }, { IPCP_OPTION_PRIMARYNBNS, "Primary NBNS" }, { IPCP_OPTION_SECONDARYDNS, "Secondary DNS" }, { IPCP_OPTION_SECONDARYNBNS, "Secondary NBNS" }, { 0, "" } }; /* * IPCP compression types */ #define IPCP_COMP_VJ 0x002d /* * IPCP compression type map */ strmap_t ipcp_comp_map[] = { { IPCP_COMP_VJ, "Van Jacobson" }, { 0, "" } }; /* * IPCP frame format */ typedef struct ipcp { u_int8_t code; u_int8_t identifier; u_int16_t length; } ipcp_t; extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** dump_ipcp() ** ** Displays IPCP packets. ** **---------------------------------------------------------------------------- */ void dump_ipcp(packet_t *pkt) { ipcp_t ipcp; /* Set the layer */ set_layer(LAYER_DATALINK); /* * Get the header */ if (get_packet_bytes((u_int8_t *) &ipcp, pkt, sizeof(ipcp_t)) == 0) return; /* * Conversion */ ipcp.length = ntohs(ipcp.length); /* * Dump the header */ if (my_args->m) { display_minimal_string("| IPCP "); display_minimal_string(map2str(ipcp_code_map, ipcp.code)); display_minimal_string(" "); } else { display_header_banner("IPCP Header"); display_strmap("Code", ipcp.code, ipcp_code_map); display("Identifier", &ipcp.identifier, 1, DISP_DEC); display("Length", (u_int8_t *) &ipcp.length, 2, DISP_DEC); } /* * Grab the payload data */ if (ipcp.length > sizeof(ipcp_t)) { switch(ipcp.code) { case IPCP_CODE_CONFREQ: case IPCP_CODE_CONFACK: case IPCP_CODE_CONFNAK: case IPCP_CODE_CONFREJ: { u_int8_t bytes_read = 0; u_int8_t type; u_int8_t length; u_int8_t value [IPCP_OPTION_LEN]; int comma = 0; /* * IPCP options appear in Type-Length-Value format */ while (bytes_read < ipcp.length - sizeof(ipcp_t)) { /* * Get type */ if (get_packet_bytes((u_int8_t *) &type, pkt, 1) == 0) break; bytes_read ++; /* * Get length */ if (get_packet_bytes((u_int8_t *) &length, pkt, 1) == 0) break; bytes_read ++; /* * In minimal mode we start all IPCP options with an open paren * and put a comma before all but the first */ if (my_args->m) { if (comma) display_minimal_string(", "); else display_minimal_string("("); comma = 1; } /* * Display the type and length */ if (my_args->m) { display_minimal_string(map2str(ipcp_option_map, type)); } else { display_strmap("Option", type, ipcp_option_map); display(" Length", &length, 1, DISP_DEC); } /* * Figure out if we need to get a value */ if (length > 2) { if (get_packet_bytes((u_int8_t *) value, pkt, length-2) == 0) break; bytes_read = bytes_read + length - 2; /* * Display the value */ switch(type) { case IPCP_OPTION_IPADDRS: break; case IPCP_OPTION_IPCOMPPROTO: { u_int16_t comp_type; memcpy((void *) &comp_type, (void *) &value, 2); comp_type = ntohs(comp_type); if (my_args->m) { display_minimal_string(" "); display_minimal_string(map2str (ipcp_comp_map, comp_type)); } else { u_int8_t max_slot_id = value[2]; u_int8_t comp_slot_id = value[3]; display_strmap("IP compression", comp_type, ipcp_comp_map); display("Max slot ID", (u_int8_t *) &max_slot_id, 1, DISP_DEC); display("Comp slot ID", (u_int8_t *) &comp_slot_id, 1, DISP_DEC); } break; } case IPCP_OPTION_IPADDR: case IPCP_OPTION_MOBILEIPV4: case IPCP_OPTION_PRIMARYDNS: case IPCP_OPTION_PRIMARYNBNS: case IPCP_OPTION_SECONDARYDNS: case IPCP_OPTION_SECONDARYNBNS: if (my_args->m) { display_minimal_string(" "); display_minimal_ipv4((u_int8_t *) &value); } else display_ipv4("IP address", (u_int8_t *) &value); break; } } } /* while */ /* * Insert end paren in minimal mode */ if (my_args->m) display_minimal_string(")"); } break; case IPCP_CODE_TERMREQ: case IPCP_CODE_TERMACK: { u_int8_t * data; u_int8_t data_len; /* * Read the data, if any */ data_len = ipcp.length - sizeof(ipcp_t); if (data_len > 0) { /* allocate memory for the data */ data = (u_int8_t *) my_malloc(data_len); /* grab the data field */ if (get_packet_bytes(data, pkt, data_len) == 0) { my_free(data); return; } /* dump it out as hex, but don't dump in minimal mode */ if (!my_args->m) { display("Data", data, data_len, DISP_HEX); } /* free that darn mem! */ my_free(data); } } break; case IPCP_CODE_CODEREJ: dump_ipcp(pkt); break; default: break; } } /* dump the hex buffer */ if (!my_args->l) hexbuffer_flush(); } ipgrab-0.9.10/src/ipcp.h0000644000175000001440000000216107164512250014150 0ustar farooqusers/**************************************************************************** ** File: ipcp.h ** ** Author: Mike Borella ** ** Comments: IPCP module definitions. ** ** $Id: ipcp.h,v 1.1 2000/09/28 00:45:28 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef IPCP_H #define IPCP_H #include "global.h" #include "local.h" void dump_ipcp(packet_t *); #endif ipgrab-0.9.10/src/ipgrab.c0000644000175000001440000001613510637716531014471 0ustar farooqusers/**************************************************************************** ** ** File: ipgrab.c ** ** Author: Mike Borella ** ** Sniffs all packets on the link and dumps the fields of the data link, ** IP, TCP, and UDP headers. ** ** $Id: ipgrab.c,v 1.22 2007/06/25 10:47:53 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "global.h" #include "datalink.h" #include "ipgrab.h" #include "open_pcap.h" #include "ip_protocols.h" #include "error.h" #include "stats.h" #include "dynports.h" #include "file.h" char * pcap_cmd; /* command string for pcap */ pcap_t * pd; /* pcap device descriptor */ int cnt; /* number of packets to read */ pcap_dumper_t * p; /* pointer to pcap dump file for writing */ struct arg_t * my_args; /* Command line arguments */ RETSIGTYPE cleanup(void); RETSIGTYPE cleanup_pcap(void); /*---------------------------------------------------------------------------- * * main() * *---------------------------------------------------------------------------- */ int main(int argc, char *argv[]) { u_int8_t * userdata; int link; /* * Initiatilize the IP family module and the stats collection module */ init_ip_protocols(); stats_init(); /* * Set the layer */ set_layer(LAYER_NONE); /* * Clear packet count */ cnt = -1; /* * Parse command line for options, take care for version and packet count */ my_args = Cmdline(argc, argv); if (my_args->v) { printf("%s\n", VERSION); return 0; } if (my_args->c) cnt = my_args->c; /* * Make stdout buffered, if necessary */ if (my_args->b) #ifdef HAVE_SETLINEBUF setlinebuf(stdout); #else setvbuf(stdout, NULL, _IOLBF, 0); #endif /* * Parse any dynamic port bindings */ if (my_args->P) dynports_parse(my_args->P); /* * Copy filter command into a string only if there is a command. */ if (my_args->optind) pcap_cmd = argv2str (&argv[my_args->optind]); /* * If we're reading a file, do things in a generic fashion. Otherwise * use standard libpcap functions to do a live read. */ if (my_args->r) { int ret; /*Get rid of root privs, not needed for reading files */ setuid(getuid()); /* * Set the signals so that we can clean up when ctrl-C is pressed * or some other reason causes the program to stop */ signal(SIGTERM, (sighandler_t) cleanup); signal(SIGINT, (sighandler_t) cleanup); signal(SIGQUIT, (sighandler_t) cleanup); signal(SIGABRT, (sighandler_t) cleanup); /* Try to ID the trace file type */ ret = file_id(my_args->r); if (ret == 0) error_fatal("unrecognized file type: %s", my_args->r); /* Open the file */ file_open(my_args->r); /* Read the packets */ file_read(cnt); /* When done, dump the stats */ stats_dump(); } else { /* This is just for live packet capture, not reading from a file */ /* * Set the signals so that we can clean up when ctrl-C is pressed * or some other reason causes the program to stop */ signal(SIGTERM, (sighandler_t) cleanup_pcap); signal(SIGINT, (sighandler_t) cleanup_pcap); signal(SIGQUIT, (sighandler_t) cleanup_pcap); signal(SIGABRT, (sighandler_t) cleanup_pcap); /* * Open the pcap device for sniffing */ link = open_pcap(); /* * Get rid of root privs */ setuid(getuid()); /* * Print intro stuff to stderr so output files have consistent * format */ fprintf(stderr, "%s %s\n", PACKAGE, VERSION); fprintf(stderr, "Listening on device %s ", my_args->i); switch(link) { case DLT_NULL: fprintf(stderr,"(loopback)\n"); break; case DLT_EN10MB: fprintf(stderr, "(ethernet)\n"); break; case DLT_SLIP: fprintf(stderr, "(slip)\n"); break; #ifdef DLT_RAW /* Not supported in some arch or older pcap versions */ case DLT_RAW: fprintf(stderr, "(raw)\n"); break; #endif case DLT_PPP: fprintf(stderr, "(ppp)\n"); break; default: error_fatal("\n%s cannot handle data link type %d", argv[0], link); } /* * Put the link type into a string */ userdata = (u_char *) &link; /* * Open the file for writing if -w is used */ if (my_args->w) { p = pcap_dump_open(pd, my_args->w); if (p == NULL) error_system("pcap_dump_open: %s", pcap_geterr(pd)); /* Read the specified number of packets */ if (pcap_loop(pd, cnt, pcap_dump, (u_char *) p) < 0) error_fatal("pcap_loop: %s", pcap_geterr(pd)); } else { /* Read all packets on the device. Continue until cnt packets read */ if (pcap_loop(pd, cnt, (pcap_func_t) datalink_pcap, userdata) < 0) error_fatal("pcap_loop: %s", pcap_geterr(pd)); } cleanup_pcap(); } return 0; } /*---------------------------------------------------------------------------- * * cleanup_pcap() * * Cleanup and collect PCAP statistics * *---------------------------------------------------------------------------- */ RETSIGTYPE cleanup_pcap(void) { struct pcap_stat stats; /* * If we aborted because no device was found, then no need * of further processing. */ if (!pd) exit ( EXIT_FAILURE ); if (pcap_stats(pd, &stats) < 0) fprintf(stderr, "pcap_stats: %s\n", pcap_geterr(pd)); else { fprintf(stderr, "%d packets received\n", stats.ps_recv); fprintf(stderr, "%d packets dropped by kernel\n", stats.ps_drop); } /* Close the pcap device */ pcap_close(pd); /* If there was a dump file open for writing, close that too */ if (my_args->w) pcap_dump_close(p); /* Display any other states that were collected */ cleanup(); } /*---------------------------------------------------------------------------- ** ** cleanup() ** ** Cleans up any files and displays stats. ** **---------------------------------------------------------------------------- */ RETSIGTYPE cleanup (void) { /* Free memory allocated in parse_cl:Cmdline() */ free_args ( my_args ); /* Display the stats */ stats_dump(); /* Let's close the program with a delimitor */ display_header_line ( HEADERLINE_DASHES ); exit(0); } ipgrab-0.9.10/src/ipgrab.h0000644000175000001440000000312507153031046014457 0ustar farooqusers/**************************************************************************** ** ** File: ipgrab.h ** ** Author: Mike Borella ** ** Comments: Macros and stuff ** ** $Id: ipgrab.h,v 1.2 2000/08/29 21:59:02 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "global.h" char *copy_argv(char **argv); /* * This is a typecast to avoid stupid warning messages. The PCAP library * assumes that a call to a function that parses data link layer packets * includes a const in the third argument. Actually doing so is a pain * because it makes the higher layer protocols much harder to parse because * you can't assign a pointer to the packet data. So this tricks PCAP * into thinking you're using the const when you really are not. * Bleah. */ typedef void (*pcap_func_t)(u_char *, const struct pcap_pkthdr *, const u_char *); ipgrab-0.9.10/src/ipgsnmp.h0000644000175000001440000000055307153266450014703 0ustar farooqusers/* ipgsnmp.h * $Id: ipgsnmp.h,v 1.2 2000/08/30 20:23:04 mborella Exp $ * Glen Wiley * * this is the stuff we need to expose in order to be able to decompose * snmp v1 * * NOTE: I am relying on the ucd snmp library for much of the heavy * lifting */ #include "global.h" #include "local.h" void dump_snmp(packet_t *); /* ipgsnmp.h */ ipgrab-0.9.10/src/ipv6.c0000644000175000001440000000761310637725410014106 0ustar farooqusers/**************************************************************************** ** File: ipv6.c ** ** Author: Mike Borella ** ** Comments: Dump IP header information ** ** $Id: ipv6.c,v 1.15 2007/06/25 11:46:16 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "ipv6.h" #include "ip_protocols.h" #define HOLDER_SIZE 64 /* Structure of IPv6 header */ typedef struct ipv6_header { #if defined(WORDS_BIGENDIAN) u_int8_t version:4, traffic_class_high:4; u_int8_t traffic_class_low:4, flow_label_high:4; #else u_int8_t traffic_class_high:4, version:4; u_int8_t flow_label_high:4, traffic_class_low:4; #endif u_int16_t flow_label_low; u_int16_t payload_length; u_int8_t next_header; u_int8_t hop_limit; u_int8_t src_addr[16]; u_int8_t dst_addr[16]; } ipv6_header_t; extern struct arg_t *my_args; extern void (*ip_proto_func[])(packet_t *); extern strmap_t ipproto_map[]; /*---------------------------------------------------------------------------- ** ** dump_ipv6() ** ** Parse IPv6 header and dump fields ** **---------------------------------------------------------------------------- */ void dump_ipv6(packet_t *pkt) { ipv6_header_t ipv6; char holder[HOLDER_SIZE]; u_int8_t ver; u_int8_t class; u_int32_t flow; /* Set the layer */ set_layer(LAYER_NETWORK); /* * Stats accounting */ stats_update(STATS_IPV6); /* * Stats accounting */ stats_update(STATS_IP); /* * Get the IPv6 header */ if (get_packet_bytes((u_int8_t *) &ipv6, pkt, 40) == 0) return; /* * Conversions */ ver = ipv6.version; class = ipv6.traffic_class_high * 0x10 + ipv6.traffic_class_low; flow = ipv6.flow_label_high * 0x10000 + ntohs(ipv6.flow_label_low); ipv6.payload_length = ntohs(ipv6.payload_length); /* * Dump header */ if (my_args->m) { display_minimal_string("| IPv6 "); display_minimal_ipv6((u_int8_t *) &ipv6.src_addr); display_minimal_string("->"); display_minimal_ipv6((u_int8_t *) &ipv6.dst_addr); display_minimal_string(" "); } else { /* announcement */ display_header_banner("IPv6 Header"); /* print fields */ display("Version", (u_int8_t *) &ver, 1, DISP_DEC); display("Traffic class", (u_int8_t *) &class, 1, DISP_HEX); display("Flow label", (u_int8_t *) &flow, 4, DISP_HEX); display("Payload length", (u_int8_t *) &ipv6.payload_length, 2, DISP_DEC); snprintf(holder, HOLDER_SIZE, "%d (%s)", ipv6.next_header, map2str(ipproto_map, ipv6.next_header)); display("Next header", holder, strlen(holder), DISP_STRING); display("Hop limit", (u_int8_t *) &ipv6.hop_limit, 1, DISP_DEC); display_ipv6("Source address",(u_int8_t *) &ipv6.src_addr); display_ipv6("Destination address",(u_int8_t *) &ipv6.dst_addr); } /* dump the hex buffer */ hexbuffer_flush(); /* * Hand it to the next higher level protocol. */ if (ip_proto_func[ipv6.next_header]) ip_proto_func[ipv6.next_header](pkt); } ipgrab-0.9.10/src/ipv6.h0000644000175000001440000000216707361402206014105 0ustar farooqusers/**************************************************************************** ** File: ipv6.h ** ** Author: Mike Borella ** ** Comments: Generic IPv6 header structure. ** ** $Id: ipv6.h,v 1.9 2001/10/11 20:43:50 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef IPV6_H #define IPV6_H #include "global.h" #include "local.h" void dump_ipv6(packet_t *); #endif ipgrab-0.9.10/src/ipx.c0000644000175000001440000001000410637727712014015 0ustar farooqusers/**************************************************************************** ** File: ipx.c ** ** Author: Mike Borella ** ** Dump IPX header information ** ** $Id: ipx.c,v 1.14 2007/06/25 12:06:34 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "ipx.h" #include "spx.h" #include "ipxrip.h" #define HOLDER_SIZE 64 /* * IPX packet type map */ strmap_t ipx_packettype_map[] = { { IPX_PACKETTYPE_UNKNOWN, "unknown" }, { IPX_PACKETTYPE_RIP, "RIP" }, { IPX_PACKETTYPE_ECHO, "echo" }, { IPX_PACKETTYPE_ERROR, "error" }, { IPX_PACKETTYPE_PEP, "PEP" }, { IPX_PACKETTYPE_SPX, "SPX" }, { IPX_PACKETTYPE_NCP, "NCP" }, { IPX_PACKETTYPE_NETBIOS, "NetBIOS" }, { 0, "" } }; extern struct arg_t *my_args; /*---------------------------------------------------------------------------- ** ** dump_ipx() ** ** Parse IPX header and dump fields ** **---------------------------------------------------------------------------- */ void dump_ipx(packet_t *pkt) { ipx_header_t ipx; char holder[HOLDER_SIZE]; /* Set the layer */ set_layer(LAYER_NETWORK); /* * Stats accounting */ stats_update(STATS_IPX); /* * Get the IPX header */ if (get_packet_bytes((u_int8_t *) &ipx, pkt, 30) == 0) return; /* * Conversions */ ipx.csum = ntohs(ipx.csum); ipx.len = ntohs(ipx.len); ipx.dstnet = ntohl(ipx.dstnet); ipx.dstport = ntohs(ipx.dstport); ipx.srcnet = ntohl(ipx.srcnet); ipx.srcport = ntohs(ipx.srcport); /* * Dump header */ if (my_args->m && !my_args->n) { display_minimal_string("| IPX "); display_minimal((u_int8_t *) &ipx.srcnode, 6, DISP_HEXCOLONS); display_minimal_string("->"); display_minimal((u_int8_t *) &ipx.dstnode, 6, DISP_HEXCOLONS); display_minimal_string(" "); } else { /* announcement */ display_header_banner("IPX Header"); /* Checksum, length, transport */ display("Checksum", (u_int8_t *) &ipx.csum, 2, DISP_DEC); display("Packet length", (u_int8_t *) &ipx.len, 2, DISP_DEC); display("Transport control", (u_int8_t *) &ipx.tc, 1, DISP_DEC); /* packet type */ snprintf(holder, HOLDER_SIZE, "%d (%s)", ipx.pt, map2str(ipx_packettype_map, ipx.pt)); display("Packet type", (u_int8_t *) holder, strlen(holder), DISP_STRING); /* destination network information */ display("Destination network", (u_int8_t *) &ipx.dstnet, 4, DISP_DEC); display("Destination node", (u_int8_t *) &ipx.dstnode, 6, DISP_HEXCOLONS); display("Destination port", (u_int8_t *) &ipx.dstport, 2, DISP_DEC); /* source network information */ display("Source network", (u_int8_t *) &ipx.srcnet, 4, DISP_DEC); display("Source node", (u_int8_t *) &ipx.srcnode, 6, DISP_HEXCOLONS); display("Source port", (u_int8_t *) &ipx.srcport, 2, DISP_DEC); } /* dump the hex buffer */ hexbuffer_flush(); /* * Hand it to the next higher layer protocol. */ switch (ipx.pt) { case 1: dump_ipxrip(pkt); break; case 5: dump_spx(pkt); break; default: break; } } ipgrab-0.9.10/src/ipx.h0000644000175000001440000000330610530527426014021 0ustar farooqusers/**************************************************************************** ** File: ipx.h ** ** Author: Mike Borella ** ** Comments: IPX header format and such ** ** $Id: ipx.h,v 1.6 2006/11/21 07:47:34 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef IPX_H #define IPX_H #include "global.h" #include "local.h" /* * IPX packet types */ #define IPX_PACKETTYPE_UNKNOWN 0 #define IPX_PACKETTYPE_RIP 1 #define IPX_PACKETTYPE_ECHO 2 #define IPX_PACKETTYPE_ERROR 3 #define IPX_PACKETTYPE_PEP 4 #define IPX_PACKETTYPE_SPX 5 #define IPX_PACKETTYPE_NCP 17 #define IPX_PACKETTYPE_NETBIOS 20 /* * IPX header */ typedef struct ipx_header { u_int16_t csum; u_int16_t len; u_int8_t tc; u_int8_t pt; u_int32_t dstnet; u_char dstnode[6]; u_int16_t dstport; u_int32_t srcnet; u_char srcnode[6]; u_int16_t srcport; } ipx_header_t; void dump_ipx(packet_t *); #endif ipgrab-0.9.10/src/ipxrip.c0000644000175000001440000000566007414717761014546 0ustar farooqusers/**************************************************************************** ** File: ipxrip.c ** ** Author: Mike Borella ** ** Dump IPX/RIP header information ** ** $Id: ipxrip.c,v 1.8 2002/01/03 00:04:01 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "ipxrip.h" #define HOLDER_SIZE 64 strmap_t ipxrip_command_map [] = { { IPXRIP_COMMAND_REQUEST, "request" }, { IPXRIP_COMMAND_RESPONSE, "response" }, { 0, "" } }; extern struct arg_t *my_args; /*---------------------------------------------------------------------------- ** ** dump_ipxrip() ** ** Parse IPX/RIP header and dump fields ** **---------------------------------------------------------------------------- */ void dump_ipxrip(packet_t *pkt) { ipxrip_header_t rip; ipxrip_entry_t e; char holder[HOLDER_SIZE]; u_int8_t count = 0; /* Set the layer */ set_layer(LAYER_NETWORK); /* * Get the IPX RIP header */ if (get_packet_bytes((u_int8_t *) &rip, pkt, sizeof(ipxrip_header_t)) == 0) return; /* * Conversions */ rip.op = ntohs(rip.op); /* * Dump header */ if (my_args->m) { /* what to do with minimal mode here?? */ return; } else { /* announcement */ display_header_banner("IPX RIP Header"); /* operation */ snprintf(holder, HOLDER_SIZE, "%d (%s)", rip.op, map2str(ipxrip_command_map, rip.op)); display("Operation", (u_int8_t *) holder, strlen(holder), DISP_STRING); /* * Loop forever dumping routing entries. Get_packet_bytes() failing * kicks us out when the time comes. */ while(1) { /* Get the entry */ if (get_packet_bytes((u_int8_t *) &e, pkt, sizeof(ipxrip_entry_t)) == 0) return; /* increment count */ count++; /* do conversions */ e.net = htonl(e.net); e.hops = htons(e.hops); e.ticks = htons(e.ticks); /* Show the route */ display("Route", (u_int8_t *) &count, 1, DISP_DEC); display(" Network", (u_int8_t *) &e.net, 4, DISP_HEX); display(" Hops", (u_int8_t *) &e.hops, 2, DISP_DEC); display(" Ticks", (u_int8_t *) &e.ticks, 2, DISP_DEC); } } /* else */ } ipgrab-0.9.10/src/ipxrip.h0000644000175000001440000000270607153266450014543 0ustar farooqusers/**************************************************************************** ** File: ipxrip.h ** ** Author: Mike Borella ** ** Comments: IPX/RIP header format and such ** ** $Id: ipxrip.h,v 1.3 2000/08/30 20:23:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef IPXRIP_H #define IPXRIP_H #include "global.h" #include "local.h" /* * IPX RIP commands */ #define IPXRIP_COMMAND_REQUEST 1 #define IPXRIP_COMMAND_RESPONSE 2 /* * Routing entries */ typedef struct ipxrip_entry { u_int32_t net; u_int16_t hops; u_int16_t ticks; } ipxrip_entry_t; /* * Generic header */ typedef struct ipxrip_header { u_int16_t op; } ipxrip_header_t; void dump_ipxrip(packet_t *); #endif ipgrab-0.9.10/src/isakmp.c0000644000175000001440000005731010637736404014512 0ustar farooqusers/**************************************************************************** ** ** File: isakmp.c ** ** Extensions and additions by: Stuart Stock (stuart@ins.com) ** Original Author: Mike Borella ** ** Comments: Dump ISAKMP headers under IPSec DOI ** ** See RFC 2408 "Internet Security Association and Key Management Protocol" ** and RFC 2407 "The Internet IP Security Domain Interpretation for ISAKMP" ** ** and when you can't find the value anywhere else, look in: ** draft-ietf-ipsec-ike-01 "The Internet Key Exchange (IKE)" ** ** $Id: isakmp.c,v 1.11 2007/06/25 13:03:00 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "isakmp.h" #include "payload.h" extern strmap_t ipproto_map[]; extern struct arg_t * my_args; #define ISAKMP_DOI_IPSEC 1 /* * Static part of ISAKMP header */ typedef struct isakmp { char i_cookie[8]; char r_cookie[8]; #if defined(WORDS_BIGENDIAN) u_int16_t maj_version:4, min_version:4, next_payload:8; #else u_int16_t next_payload:8, min_version:4, maj_version:4; #endif u_int8_t exchange_type; u_int8_t flags; u_int32_t msg_id; u_int32_t length; } isakmp_t; /* * ISAKMP Generic Payload Header */ typedef struct isakmpgeneric { u_int8_t next_payload; u_int8_t reserved; u_int16_t length; } isakmpgeneric_t; /* * ISAKMP proposal payload (partial) */ typedef struct isakmpproposal { u_int8_t number; u_int8_t protocol_id; u_int8_t spi_size; u_int8_t num_transforms; } isakmpproposal_t; /* * ISAKMP transform payload (partial) */ typedef struct isakmptransform { u_int8_t number; u_int8_t id; u_int16_t reserved; } isakmptransform_t; /* * ISAKMP flags */ #define ISAKMP_FLAG_ENCRYPTION 0x01 #define ISAKMP_FLAG_COMMIT 0x02 #define ISAKMP_FLAG_AUTHONLY 0x04 /* * ISAKMP payload types */ #define ISAKMP_PAYLOAD_NONE 0 #define ISAKMP_PAYLOAD_SA 1 #define ISAKMP_PAYLOAD_PROPOSAL 2 #define ISAKMP_PAYLOAD_TRANSFORM 3 #define ISAKMP_PAYLOAD_KEYEXCHANGE 4 #define ISAKMP_PAYLOAD_IDENTIFICATION 5 #define ISAKMP_PAYLOAD_CERTIFICATE 6 #define ISAKMP_PAYLOAD_CERTIFICATEREQ 7 #define ISAKMP_PAYLOAD_HASH 8 #define ISAKMP_PAYLOAD_SIGNATURE 9 #define ISAKMP_PAYLOAD_NONCE 10 #define ISAKMP_PAYLOAD_NOTIFICATION 11 #define ISAKMP_PAYLOAD_DELETE 12 #define ISAKMP_PAYLOAD_VENDORID 13 /* * ISAKMP payload map */ strmap_t isakmp_payload_map[] = { { ISAKMP_PAYLOAD_NONE, "none" }, { ISAKMP_PAYLOAD_SA, "security association" }, { ISAKMP_PAYLOAD_PROPOSAL, "proposal" }, { ISAKMP_PAYLOAD_TRANSFORM, "transform" }, { ISAKMP_PAYLOAD_KEYEXCHANGE, "key exchange" }, { ISAKMP_PAYLOAD_IDENTIFICATION, "identification" }, { ISAKMP_PAYLOAD_CERTIFICATE, "certificate" }, { ISAKMP_PAYLOAD_CERTIFICATEREQ, "certificate request" }, { ISAKMP_PAYLOAD_HASH, "hash" }, { ISAKMP_PAYLOAD_SIGNATURE, "signature" }, { ISAKMP_PAYLOAD_NONCE, "nonce" }, { ISAKMP_PAYLOAD_NOTIFICATION, "notification" }, { ISAKMP_PAYLOAD_DELETE, "delete" }, { ISAKMP_PAYLOAD_VENDORID, "vendor id" }, { 0, "" } }; /* * ISAKMP exchange types */ #define ISAKMP_EXCHANGE_NONE 0 #define ISAKMP_EXCHANGE_BASE 1 #define ISAKMP_EXCHANGE_IDPROTECT 2 #define ISAKMP_EXCHANGE_AUTHONLY 3 #define ISAKMP_EXCHANGE_AGGRESSIVE 4 #define ISAKMP_EXCHANGE_INFORMATIONAL 5 /* * ISAKMP exchange map */ strmap_t isakmp_exchange_map[] = { { ISAKMP_EXCHANGE_NONE, "none" }, { ISAKMP_EXCHANGE_BASE, "base" }, { ISAKMP_EXCHANGE_IDPROTECT, "identity protection" }, { ISAKMP_EXCHANGE_AUTHONLY, "authentication only" }, { ISAKMP_EXCHANGE_AGGRESSIVE, "aggressive" }, { ISAKMP_EXCHANGE_INFORMATIONAL, "informational" }, { 0, "" } }; /* * Situation definitions for IPSEC DOI */ #define ISAKMP_SIT_IDENTITYONLY 0x01 #define ISAKMP_SIT_SECRECY 0x02 #define ISAKMP_SIT_INTEGRITY 0x04 /* * IPSEC DOI situation map */ strmap_t isakmp_doisituation_map[] = { { ISAKMP_SIT_IDENTITYONLY, "identity only" }, { ISAKMP_SIT_SECRECY, "secrecy" }, { ISAKMP_SIT_INTEGRITY, "integrity" }, { 0, "" } }; /* * Protocol ID definitions */ #define ISAKMP_PROTOCOLID_RESERVED 0 #define ISAKMP_PROTOCOLID_ISAKMP 1 #define ISAKMP_PROTOCOLID_IPSECAH 2 #define ISAKMP_PROTOCOLID_IPSECESP 3 #define ISAKMP_PROTOCOLID_IPCOMP 4 /* * Protocol ID map */ strmap_t isakmp_protocolid_map[] = { { ISAKMP_PROTOCOLID_RESERVED, "reserved" }, { ISAKMP_PROTOCOLID_ISAKMP, "ISAKMP" }, { ISAKMP_PROTOCOLID_IPSECAH, "IPSEC AH" }, { ISAKMP_PROTOCOLID_IPSECESP, "IPSEC ESP" }, { ISAKMP_PROTOCOLID_IPCOMP, "IPCOMP" }, { 0, "" } }; /* * Transform definitions */ #define ISAKMP_TRANSFORM_RESERVED 0 #define ISAKMP_TRANSFORM_KEYIKE 1 /* * Transform map */ strmap_t isakmp_transform_map[] = { { ISAKMP_TRANSFORM_RESERVED, "reserved" }, { ISAKMP_TRANSFORM_KEYIKE, "KEY_IKE" }, { 0, "" } }; /* * Attribute types */ #define ISAKMP_ATTR_ENCRALG 1 #define ISAKMP_ATTR_HASHALG 2 #define ISAKMP_ATTR_AUTHMETHOD 3 #define ISAKMP_ATTR_GROUPDESC 4 #define ISAKMP_ATTR_GROUPTYPE 5 #define ISAKMP_ATTR_GROUPPRIME 6 #define ISAKMP_ATTR_GROUPGEN1 7 #define ISAKMP_ATTR_GROUPGEN2 8 #define ISAKMP_ATTR_GROUPCURVEA 9 #define ISAKMP_ATTR_GROUPCURVEB 10 #define ISAKMP_ATTR_LIFETYPE 11 #define ISAKMP_ATTR_LIFEDURATION 12 #define ISAKMP_ATTR_PRF 13 #define ISAKMP_ATTR_KEYLENGTH 14 #define ISAKMP_ATTR_FIELDSIZE 15 #define ISAKMP_ATTR_GROUPORDER 16 /* * Attribute type map */ strmap_t isakmp_attr_map[] = { { ISAKMP_ATTR_ENCRALG, "encryption algorithm" }, { ISAKMP_ATTR_HASHALG, "hash algorithm" }, { ISAKMP_ATTR_AUTHMETHOD, "authentication method" }, { ISAKMP_ATTR_GROUPDESC, "group description" }, { ISAKMP_ATTR_GROUPTYPE, "group type" }, { ISAKMP_ATTR_GROUPPRIME, "group prime" }, { ISAKMP_ATTR_GROUPGEN1, "group generator 1" }, { ISAKMP_ATTR_GROUPGEN2, "group generator 2" }, { ISAKMP_ATTR_GROUPCURVEA, "group curve A" }, { ISAKMP_ATTR_GROUPCURVEB, "group curve B" }, { ISAKMP_ATTR_LIFETYPE, "life type" }, { ISAKMP_ATTR_LIFEDURATION, "life duration" }, { ISAKMP_ATTR_PRF, "PRF" }, { ISAKMP_ATTR_KEYLENGTH, "key length" }, { ISAKMP_ATTR_FIELDSIZE, "field size" }, { ISAKMP_ATTR_GROUPORDER, "group order" }, { 0, "" } }; /* * Encryption algorithm attribute types */ #define ISAKMP_ATTR_ENCRALG_DESCBC 1 #define ISAKMP_ATTR_ENCRALG_IDEACBC 2 #define ISAKMP_ATTR_ENCRALG_BLOWFISHCBC 3 #define ISAKMP_ATTR_ENCRALG_RC5R16B64CBC 4 #define ISAKMP_ATTR_ENCRALG_3DESCBC 5 #define ISAKMP_ATTR_ENCRALG_CASTCBC 6 /* * Encryption algorithm attribute map */ strmap_t isakmp_attr_encralg_map[] = { { ISAKMP_ATTR_ENCRALG_DESCBC, "DES-CBC" }, { ISAKMP_ATTR_ENCRALG_IDEACBC, "IDEA-CBC" }, { ISAKMP_ATTR_ENCRALG_BLOWFISHCBC, "blowfish-CBC" }, { ISAKMP_ATTR_ENCRALG_RC5R16B64CBC, "RC5-R16-B64-CBC" }, { ISAKMP_ATTR_ENCRALG_3DESCBC, "3DES-CBC" }, { ISAKMP_ATTR_ENCRALG_CASTCBC, "CAST-CBC" }, { 0, "" } }; /* * Hash algorithm attribute types */ #define ISAKMP_ATTR_HASHALG_MD5 1 #define ISAKMP_ATTR_HASHALG_SHA 2 #define ISAKMP_ATTR_HASHALG_TIGER 3 /* * Hash algorithm attribute map */ strmap_t isakmp_attr_hashalg_map[] = { { ISAKMP_ATTR_HASHALG_MD5, "MD5" }, { ISAKMP_ATTR_HASHALG_SHA, "SHA" }, { ISAKMP_ATTR_HASHALG_TIGER, "Tiger" }, { 0, "" } }; /* * Authentication method attribute types */ #define ISAKMP_ATTR_AUTHMETHOD_PRESHAREDKEY 1 #define ISAKMP_ATTR_AUTHMETHOD_DSSSIG 2 #define ISAKMP_ATTR_AUTHMETHOD_RSASIG 3 #define ISAKMP_ATTR_AUTHMETHOD_ENCRRSA 4 #define ISAKMP_ATTR_AUTHMETHOD_REVENCRRSA 5 /* * Authentication method attribute map */ strmap_t isakmp_attr_authmethod_map[] = { { ISAKMP_ATTR_AUTHMETHOD_PRESHAREDKEY, "pre-shared key" }, { ISAKMP_ATTR_AUTHMETHOD_DSSSIG, "DSS signatures" }, { ISAKMP_ATTR_AUTHMETHOD_RSASIG, "RSA signatures" }, { ISAKMP_ATTR_AUTHMETHOD_ENCRRSA, "encryption with RSA" }, { ISAKMP_ATTR_AUTHMETHOD_REVENCRRSA, "revised encryption with RSA" }, { 0, "" } }; /* * Group description attribute types */ #define ISAKMP_ATTR_GROUPDESC_MODP768 1 #define ISAKMP_ATTR_GROUPDESC_MODP1024 2 #define ISAKMP_ATTR_GROUPDESC_EC2N155 3 #define ISAKMP_ATTR_GROUPDESC_EC2N185 4 /* * Group description attribute map */ strmap_t isakmp_attr_groupdesc_map[] = { { ISAKMP_ATTR_GROUPDESC_MODP768, "768-bit MODP group" }, { ISAKMP_ATTR_GROUPDESC_MODP1024, "1024-bit MODP group" }, { ISAKMP_ATTR_GROUPDESC_EC2N155, "EC2N group on GP[2^155]" }, { ISAKMP_ATTR_GROUPDESC_EC2N185, "EC2N group on GP[2^185]" }, { 0, "" } }; /* * Group type attribute types */ #define ISAKMP_ATTR_GROUPTYPE_MODP 1 #define ISAKMP_ATTR_GROUPTYPE_ECP 2 #define ISAKMP_ATTR_GROUPTYPE_EC2N 3 /* * Group type attribute map */ strmap_t isakmp_attr_grouptype_map[] = { { ISAKMP_ATTR_GROUPTYPE_MODP, "modular exponentiation" }, { ISAKMP_ATTR_GROUPTYPE_ECP, "elliptical curve over GF[P]" }, { ISAKMP_ATTR_GROUPTYPE_EC2N, "elliptical curve over GF[2^N]" }, { 0, "" } }; /* * Life type attribute types */ #define ISAKMP_ATTR_LIFETYPE_SECONDS 1 #define ISAKMP_ATTR_LIFETYPE_KILOBYTES 2 /* * Life type attribute map */ strmap_t isakmp_attr_lifetype_map[] = { { ISAKMP_ATTR_LIFETYPE_SECONDS, "seconds" }, { ISAKMP_ATTR_LIFETYPE_KILOBYTES, "kilobytes" }, { 0, "" } }; void isakmp_next_payload(packet_t *, u_int8_t); /*---------------------------------------------------------------------------- ** ** dump_isakmp_attributes() ** ** Parse an ISAKMP attribute set and interpret it. This is for IKE with ** the IPSEC DOI only! ** **---------------------------------------------------------------------------- */ void dump_isakmp_attributes(u_int8_t *attr, int len) { u_int8_t * p; u_int16_t type; u_int16_t length; u_int8_t * value; p = attr; while (1) { /* get the type */ if (p+2 > attr+len) return; memcpy((void *) &type, (void * ) p, 2); type = ntohs(type); p = p + 2; if (type >= 0x8000) { u_int16_t temp; temp = type - 0x8000; display_strmap("Attribute", temp, isakmp_attr_map); } else display_strmap("Attribute", type, isakmp_attr_map); /* determine whether we have a length field or not */ if (type < 0x8000) { /* get length field */ if (p+2 > attr+len) return; memcpy((void *) &length, (void *) p, 2); length = ntohs(length); p = p + 2; display(" Length", (u_int8_t *) &length, 2, DISP_DEC); } else length = 2; /* * Get the value. Values without a length field should be 2 bytes. * It must say that in some RFC but I just can't find it... */ if (p+length > attr+len) return; value = my_malloc(length); memcpy((void *) value, (void *) p, length); reverse_byte_order(value, length); p = p + length; /* display the value, based on its type */ switch(type & 0x7fff) { case ISAKMP_ATTR_ENCRALG: display_strmap(" Value", (u_int16_t) *value, isakmp_attr_encralg_map); break; case ISAKMP_ATTR_HASHALG: display_strmap(" Value", (u_int16_t) *value, isakmp_attr_hashalg_map); break; case ISAKMP_ATTR_AUTHMETHOD: display_strmap(" Value", (u_int16_t) *value, isakmp_attr_authmethod_map); break; case ISAKMP_ATTR_GROUPDESC: display_strmap(" Value", (u_int16_t) *value, isakmp_attr_groupdesc_map); break; case ISAKMP_ATTR_GROUPTYPE: display_strmap(" Value", (u_int16_t) *value, isakmp_attr_grouptype_map); break; case ISAKMP_ATTR_LIFETYPE: display_strmap(" Value", (u_int16_t) *value, isakmp_attr_lifetype_map); break; default: display(" Value", (u_int8_t *) value, length, DISP_DEC); break; } my_free(value); } } /*---------------------------------------------------------------------------- ** ** dump_isakmp_transform() ** ** Parse ISAKMP transform payload ** **---------------------------------------------------------------------------- */ void dump_isakmp_transform(packet_t * pkt) { isakmpgeneric_t hdr; isakmptransform_t transform; u_int8_t * sa_attributes = NULL; int sa_attributes_len; /* get the generic header */ if (get_packet_bytes((u_int8_t *) &hdr, pkt, sizeof(hdr)) == 0) return; /* conversions */ hdr.length = ntohs(hdr.length); if (my_args->m) { /* nothing to do here... */ } else { display_header_banner("ISAKMP/IKE transform"); display_strmap("Next payload", hdr.next_payload, isakmp_payload_map); display("Reserved", (u_int8_t *) &hdr.reserved, 1, DISP_DEC); display("Payload length", (u_int8_t *) &hdr.length, 2, DISP_DEC); } /* Get the fixed transform payload, then the SA attributes field */ if (get_packet_bytes((u_int8_t *) &transform, pkt, sizeof(isakmptransform_t)) == 0) return; sa_attributes_len = hdr.length - 8; if (sa_attributes_len > 0) { sa_attributes = (u_int8_t *) my_malloc(sa_attributes_len); if (get_packet_bytes(sa_attributes, pkt, sa_attributes_len) == 0) { my_free(sa_attributes); return; } } /* conversion */ transform.reserved = ntohs(transform.reserved); if (my_args->m) { /* nothing to do here... */ } else { display("Transform #", (u_int8_t *) &transform.number, 1, DISP_DEC); display_strmap("Transform ID", transform.id, isakmp_transform_map); display("Reserved", (u_int8_t *) &transform.reserved, 2, DISP_DEC); if (sa_attributes_len > 0) dump_isakmp_attributes(sa_attributes, sa_attributes_len); } /* Dump the hex buffer */ hexbuffer_flush(); /* free the sa_attrinutes memory */ if (sa_attributes_len > 0) my_free(sa_attributes); } /*---------------------------------------------------------------------------- ** ** dump_isakmp_proposal() ** ** Parse ISAKMP proposal payload ** **---------------------------------------------------------------------------- */ void dump_isakmp_proposal(packet_t * pkt) { isakmpgeneric_t hdr; isakmpproposal_t proposal; u_int8_t * spi = NULL; int i; /* get the generic header */ if (get_packet_bytes((u_int8_t *) &hdr, pkt, sizeof(hdr)) == 0) return; /* conversions */ hdr.length = ntohs(hdr.length); if (my_args->m) { /* nothing to do here... */ } else { display_header_banner("ISAKMP/IKE proposal"); display_strmap("Next payload", hdr.next_payload, isakmp_payload_map); display("Reserved", (u_int8_t *) &hdr.reserved, 1, DISP_DEC); display("Payload length", (u_int8_t *) &hdr.length, 2, DISP_DEC); } /* get the proposal, then the SPI */ if (get_packet_bytes((u_int8_t *) &proposal, pkt, sizeof(proposal)) == 0) return; if (proposal.spi_size > 0) { spi = my_malloc(proposal.spi_size); if (get_packet_bytes((u_int8_t *) &spi, pkt, proposal.spi_size) == 0) { my_free(spi); return; } } if (my_args->m) { /* nothing to do here... */ } else { display("Proposal #", (u_int8_t *) &proposal.number, 1, DISP_DEC); display_strmap("Protocol ID", proposal.protocol_id, isakmp_protocolid_map); display("SPI size", (u_int8_t *) &proposal.spi_size, 1, DISP_DEC); display("Number of transforms", (u_int8_t *) &proposal.num_transforms, 1, DISP_DEC); if (proposal.spi_size > 0) display("SPI", (u_int8_t *) &spi, proposal.spi_size, DISP_HEX); } /* Dump the hex buffer */ hexbuffer_flush(); /* free the spi memory */ if (proposal.spi_size > 0) my_free(spi); /* Do each of the transform headers */ i = 0; while (i < proposal.num_transforms) { dump_isakmp_transform(pkt); i++; } } /*---------------------------------------------------------------------------- ** ** dump_isakmp_sa() ** ** Parse ISAKMP SA payload ** **---------------------------------------------------------------------------- */ void dump_isakmp_sa(packet_t * pkt) { isakmpgeneric_t hdr; u_int32_t doi; u_int32_t situation; /* get the generic header */ if (get_packet_bytes((u_int8_t *) &hdr, pkt, sizeof(hdr)) == 0) return; /* conversions */ hdr.length = ntohs(hdr.length); if (my_args->m) { /* nothing to do here... */ } else { display_header_banner("ISAKMP/IKE SA"); display_strmap("Next payload", hdr.next_payload, isakmp_payload_map); display("Reserved", (u_int8_t *) &hdr.reserved, 1, DISP_DEC); display("Payload length", (u_int8_t *) &hdr.length, 2, DISP_DEC); } /* * The next 4 bytes is the DOI. We need to get it now in order to figure * out what the situation is... */ if (get_packet_bytes((u_int8_t *) &doi, pkt, 4) == 0) return; /* conversion */ doi = ntohl(doi); if (!my_args->m) display("DOI", (u_int8_t *) &doi, 4, DISP_DEC); /* get the situation based on the DOI. The IPSEC DOI situation is 4 bytes */ if (doi != ISAKMP_DOI_IPSEC) return; if (get_packet_bytes((u_int8_t *) &situation, pkt, 4) == 0) return; /* conversion */ situation = ntohl(situation); if (!my_args->m) display_strmap("Situation", situation, isakmp_doisituation_map); /* Dump the hex buffer */ hexbuffer_flush(); /* * Since an SA payload is always followed by a number of * proposal / transform payload sets, we parse then next, automatically, * then we do the given "next payload". How annoying... */ dump_isakmp_proposal(pkt); /* determine the next payload and parse it */ isakmp_next_payload(pkt, hdr.next_payload); } /*---------------------------------------------------------------------------- ** ** dump_isakmp_vendorid() ** ** Parse ISAKMP vendorid payload ** **---------------------------------------------------------------------------- */ void dump_isakmp_vendorid(packet_t * pkt) { isakmpgeneric_t hdr; u_int8_t * vendorid; int len; /* get the generic header */ if (get_packet_bytes((u_int8_t *) &hdr, pkt, sizeof(hdr)) == 0) return; /* conversions */ hdr.length = ntohs(hdr.length); if (my_args->m) { /* nothing to do here... */ } else { display_header_banner("ISAKMP/IKE vendor ID"); display_strmap("Next payload", hdr.next_payload, isakmp_payload_map); display("Reserved", (u_int8_t *) &hdr.reserved, 1, DISP_DEC); display("Payload length", (u_int8_t *) &hdr.length, 2, DISP_DEC); } /* * This payload contains a vendor ID hash that is hdr.length - 4 bytes * First allocate memory and grab it */ len = hdr.length - sizeof(isakmpgeneric_t); vendorid = (u_int8_t *) my_malloc(len); if (get_packet_bytes(vendorid, pkt, len) == 0) { my_free(vendorid); return; } display("Vendor ID (hash)", vendorid, len, DISP_HEX_MULTILINE); /* free memory */ my_free(vendorid); /* determine the next payload and parse it */ isakmp_next_payload(pkt, hdr.next_payload); } /*---------------------------------------------------------------------------- ** ** dump_isakmp_delete() ** ** Parse ISAKMP delete payload ** **---------------------------------------------------------------------------- */ void dump_isakmp_delete(packet_t * pkt) { isakmpgeneric_t hdr; /* get the generic header */ if (get_packet_bytes((u_int8_t *) &hdr, pkt, sizeof(hdr)) == 0) return; /* conversions */ hdr.length = ntohs(hdr.length); if (my_args->m) { /* nothing to do here... */ } else { display_header_banner("ISAKMP/IKE delete"); display_strmap("Next payload", hdr.next_payload, isakmp_payload_map); display("Reserved", (u_int8_t *) &hdr.reserved, 1, DISP_DEC); display("Payload length", (u_int8_t *) &hdr.length, 2, DISP_DEC); } } /*---------------------------------------------------------------------------- ** ** isakmp_next_payload() ** ** Call the proper payload parser based on the given next payload field ** **---------------------------------------------------------------------------- */ void isakmp_next_payload(packet_t * pkt, u_int8_t next) { switch (next) { case ISAKMP_PAYLOAD_DELETE: dump_isakmp_delete(pkt); break; case ISAKMP_PAYLOAD_SA: dump_isakmp_sa(pkt); break; case ISAKMP_PAYLOAD_VENDORID: dump_isakmp_vendorid(pkt); break; default: /* unrecognized payload, so we'll fall through and stop */ break; } } /*---------------------------------------------------------------------------- ** ** dump_isakmp() ** ** Parse ISAKMP packet and dump fields. ** **---------------------------------------------------------------------------- */ void dump_isakmp(packet_t * pkt) { isakmp_t isakmp; u_int8_t major; u_int8_t minor; u_int8_t next; u_int8_t e_flag, c_flag, a_flag; /* Set the layer */ set_layer(LAYER_APPLICATION); /* * Get the main ISAKMP header */ if (get_packet_bytes((u_int8_t *) &isakmp, pkt, sizeof(isakmp_t)) == 0) return; /* * Conversions */ isakmp.msg_id = ntohl(isakmp.msg_id); isakmp.length = ntohl(isakmp.length); next = isakmp.next_payload; major = isakmp.maj_version; minor = isakmp.min_version; e_flag = isakmp.flags & ISAKMP_FLAG_ENCRYPTION; c_flag = isakmp.flags & ISAKMP_FLAG_COMMIT >> 1; a_flag = isakmp.flags & ISAKMP_FLAG_AUTHONLY >> 2; /* * Dump header */ if (my_args->m) { /* do something here */ } else { display_header_banner("ISAKMP/IKE Header"); display("Initiatior cookie", (u_int8_t *) &isakmp.i_cookie, 8, DISP_HEX); display("Responder cookie", (u_int8_t *) &isakmp.r_cookie, 8, DISP_HEX); display_strmap("Next payload", next, isakmp_payload_map); display("Major version", (u_int8_t *) &major, 1, DISP_DEC); display("Minor version", (u_int8_t *) &minor, 1, DISP_DEC); display_strmap("Exchange type", isakmp.exchange_type, isakmp_exchange_map); display("Encryption flag", (u_int8_t *) &e_flag, 1, DISP_DEC); display("Commit flag", (u_int8_t *) &c_flag, 1, DISP_DEC); display("Auth only flag", (u_int8_t *) &a_flag, 1, DISP_DEC); display("Message ID", (u_int8_t *) &isakmp.msg_id, 4, DISP_DEC); display("Length", (u_int8_t *) &isakmp.length, 4, DISP_DEC); } /* * Dump the hex buffer */ hexbuffer_flush(); /* * Short circuit processing if this is the only header or encryption * bit is set */ if (next == ISAKMP_PAYLOAD_NONE || e_flag) { return; } /* determine the next payload and parse it */ isakmp_next_payload(pkt, next); } ipgrab-0.9.10/src/isakmp.h0000644000175000001440000000217607171410256014510 0ustar farooqusers/**************************************************************************** ** File: isakmp.h ** ** Author: Mike Borella ** ** Comments: Structure of ISAKMP packets ** ** $Id: isakmp.h,v 1.5 2000/10/12 19:27:42 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef ISAKMP_H #define ISAKMP_H #include "global.h" #include "local.h" void dump_isakmp(packet_t *); #endif ipgrab-0.9.10/src/l2tp.c0000644000175000001440000004155610637737102014110 0ustar farooqusers/**************************************************************************** ** ** File: l2tp.c ** ** Author: Mike Borella ** ** Comments: Dump L2TP header information ** ** $Id: l2tp.c,v 1.11 2007/06/25 13:08:18 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ****************************************************************************/ #include "l2tp.h" #include "ppp.h" #define L2TP_AVP_SIZE 6 /* * Control message types */ #define L2TP_CTRL_RESERVED1 0 #define L2TP_CTRL_SCCRQ 1 #define L2TP_CTRL_SCCRP 2 #define L2TP_CTRL_SCCCN 3 #define L2TP_CTRL_STOPCCN 4 #define L2TP_CTRL_RESERVED2 5 #define L2TP_CTRL_HELLO 6 #define L2TP_CTRL_OCRQ 7 #define L2TP_CTRL_OCRP 8 #define L2TP_CTRL_OCCN 9 #define L2TP_CTRL_ICRQ 10 #define L2TP_CTRL_ICRP 11 #define L2TP_CTRL_ICCN 12 #define L2TP_CTRL_RESERVED3 13 #define L2TP_CTRL_CDN 14 #define L2TP_CTRL_WEN 15 #define L2TP_CTRL_SLI 16 /* * L2tp control message type map */ strmap_t l2tp_ctrl_map[] = { { L2TP_CTRL_RESERVED1, "Reserved" }, { L2TP_CTRL_SCCRQ, "Start-Control-Connection-Request" }, { L2TP_CTRL_SCCRP, "Start-Control-Connection-Reply" }, { L2TP_CTRL_SCCCN, "Stop-Control-Connection-Connected" }, { L2TP_CTRL_STOPCCN, "Stop-Control-Connection-Notification" }, { L2TP_CTRL_RESERVED2, "Reserved" }, { L2TP_CTRL_HELLO, "Hello" }, { L2TP_CTRL_OCRQ, "Outgoing-Call-Request" }, { L2TP_CTRL_OCRP, "Outgoing-Call-Reply" }, { L2TP_CTRL_OCCN, "Outgoing-Call-Connected" }, { L2TP_CTRL_ICRQ, "Incoming-Call-Request" }, { L2TP_CTRL_ICRP, "Incoming-Call-Reply" }, { L2TP_CTRL_ICCN, "Incoming-Call-Connected" }, { L2TP_CTRL_RESERVED3, "Reserved" }, { L2TP_CTRL_CDN, "Call-Disconnect-Notify" }, { L2TP_CTRL_WEN, "WAN-Error-Notify" }, { L2TP_CTRL_SLI, "Set-Link-Info" }, { 0, "" } }; /* * L2TP AVPs */ #define L2TP_AVP_MESSAGETYPE 0 #define L2TP_AVP_RESULTCODE 1 #define L2TP_AVP_PROTOCOLVERSION 2 #define L2TP_AVP_FRAMINGCAP 3 #define L2TP_AVP_BEARERCAP 4 #define L2TP_AVP_TIEBREAKER 5 #define L2TP_AVP_FIRMWAREREV 6 #define L2TP_AVP_HOSTNAME 7 #define L2TP_AVP_VENDORNAME 8 #define L2TP_AVP_ASSIGNEDTUNNELID 9 #define L2TP_AVP_RECEIVEWINDOWSIZE 10 #define L2TP_AVP_CHALLENGE 11 #define L2TP_AVP_Q931CAUSECODE 12 #define L2TP_AVP_RESPONSE 13 #define L2TP_AVP_ASSIGNEDSESSIONID 14 #define L2TP_AVP_CALLSERIALNUMBER 15 #define L2TP_AVP_MINIMUMBPS 16 #define L2TP_AVP_MAXIMUMBPS 17 #define L2TP_AVP_BEARERTYPE 18 #define L2TP_AVP_FRAMINGTYPE 19 #define L2TP_AVP_RESERVED1 20 #define L2TP_AVP_CALLEDNUMBER 21 #define L2TP_AVP_CALLINGNUMBER 22 #define L2TP_AVP_SUBADDRESS 23 #define L2TP_AVP_TXCONNECTSPEED 24 #define L2TP_AVP_PHYSICALCHANNELID 25 #define L2TP_AVP_INITIALRECVLCP 26 #define L2TP_AVP_LASTSENTLCP 27 #define L2TP_AVP_LASTRECVLCP 28 #define L2TP_AVP_PROXYAUTHTYPE 29 #define L2TP_AVP_PROXYAUTHNAME 30 #define L2TP_AVP_PROXYAUTHCHALLENGE 31 #define L2TP_AVP_PROXYAUTHID 32 #define L2TP_AVP_PROXYAUTHRESPONSE 33 #define L2TP_AVP_CALLERRORS 34 #define L2TP_AVP_ACCM 35 #define L2TP_AVP_RANDOMVECTOR 36 #define L2TP_AVP_PRIVATEGROUP 37 #define L2TP_AVP_RXCONNECTSPEED 38 #define L2TP_AVP_SEQUENCINGREQUIRED 39 /* * L2TP AVP map */ strmap_t l2tp_avp_map[] = { { L2TP_AVP_MESSAGETYPE, "message type" }, { L2TP_AVP_RESULTCODE, "result code" }, { L2TP_AVP_PROTOCOLVERSION, "protocol version" }, { L2TP_AVP_FRAMINGCAP, "framing capabilities" }, { L2TP_AVP_BEARERCAP, "bearer capabilities" }, { L2TP_AVP_TIEBREAKER, "tie breaker" }, { L2TP_AVP_FIRMWAREREV, "firmware revision" }, { L2TP_AVP_HOSTNAME, "host name" }, { L2TP_AVP_VENDORNAME, "vendor name" }, { L2TP_AVP_ASSIGNEDTUNNELID, "assigned tunnel ID" }, { L2TP_AVP_RECEIVEWINDOWSIZE, "receive window size" }, { L2TP_AVP_CHALLENGE, "challenge" }, { L2TP_AVP_Q931CAUSECODE, "Q.931 cause code" }, { L2TP_AVP_RESPONSE, "response" }, { L2TP_AVP_ASSIGNEDSESSIONID, "assigned session ID" }, { L2TP_AVP_CALLSERIALNUMBER, "call serial number" }, { L2TP_AVP_MINIMUMBPS, "minimum BPS" }, { L2TP_AVP_MAXIMUMBPS, "maximum BPS" }, { L2TP_AVP_BEARERTYPE, "bearer type" }, { L2TP_AVP_FRAMINGTYPE, "framing type" }, { L2TP_AVP_RESERVED1, "reserved" }, { L2TP_AVP_CALLEDNUMBER, "called number" }, { L2TP_AVP_CALLINGNUMBER, "calling number" }, { L2TP_AVP_SUBADDRESS, "subaddress" }, { L2TP_AVP_TXCONNECTSPEED, "transmit connect speed" }, { L2TP_AVP_PHYSICALCHANNELID, "physical channel ID" }, { L2TP_AVP_INITIALRECVLCP, "initial receive LCP" }, { L2TP_AVP_LASTSENTLCP, "last sent LCP" }, { L2TP_AVP_LASTRECVLCP, "last receive LCP" }, { L2TP_AVP_PROXYAUTHTYPE, "proxy authentication type" }, { L2TP_AVP_PROXYAUTHNAME, "proxy authentication name" }, { L2TP_AVP_PROXYAUTHCHALLENGE,"proxy authentication challenge" }, { L2TP_AVP_PROXYAUTHID, "proxy authentication ID" }, { L2TP_AVP_PROXYAUTHRESPONSE, "proxy authentication response" }, { L2TP_AVP_CALLERRORS, "call errors" }, { L2TP_AVP_ACCM, "ACCM" }, { L2TP_AVP_RANDOMVECTOR, "random vector" }, { L2TP_AVP_PRIVATEGROUP, "private group" }, { L2TP_AVP_RXCONNECTSPEED, "receive connect speed" }, { L2TP_AVP_SEQUENCINGREQUIRED,"sequencing required" }, { 0, "" } }; /* * Message type AVP (generic part) * * 0 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |M|H| rsvd | Length | Vendor ID | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Attribute Type | Attribute Value... * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * [until Length is reached]... | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * */ typedef struct l2tpavp { #if defined(WORDS_BIGENDIAN) u_int8_t m:1, h:1, zeros:4, length_high:2; #else u_int16_t length_high:2, zeros:4, h:1, m:1; #endif u_int8_t length_low; u_int16_t vendor_id; u_int16_t attribute_type; } l2tpavp_t; /* * First two bytes of l2tp header * 0 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |T|L|x|x|S|x|O|P|x|x|x|x| Ver | Length (opt) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Tunnel ID | Session ID | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Ns (opt) | Nr (opt) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Offset Size (opt) | Offset pad... (opt) * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * */ typedef struct l2tphdr { #if defined(WORDS_BIGENDIAN) u_int8_t t_bit:1, l_bit:1, reserved1:2, s_bit:1, reserved2:1, o_bit:1, p_bit:1; #else u_int8_t p_bit:1, o_bit:1, reserved2:1, s_bit:1, reserved1:2, l_bit:1, t_bit:1; #endif #if defined(WORD_BIGENDIAN) u_int8_t reserved3:4, version:4; #else u_int8_t version:4, reserved3:4; #endif } l2tphdr_t; extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** dump_l2tp_avp() ** ** Parse L2TP AVP subheader ** ** Returns a -1 on error so that we can fall out of the calling loop. ** **---------------------------------------------------------------------------- */ int dump_l2tp_avp(packet_t * pkt, u_int16_t *n) { l2tpavp_t avp; int8_t m, h, zeros; int16_t length; /* * Get the avp */ if (get_packet_bytes((u_int8_t *) &avp, pkt, L2TP_AVP_SIZE) == 0) return -1; *n = *n + L2TP_AVP_SIZE; /* * conversions */ m = avp.m; h = avp.h; zeros = avp.zeros; length = avp.length_high * 256 + avp.length_low; avp.vendor_id = ntohs(avp.vendor_id); avp.attribute_type = ntohs(avp.attribute_type); /* * display */ if (my_args->m) { } else { display_strmap("AVP type", avp.attribute_type, l2tp_avp_map); display(" M (mandatory)", (u_int8_t *) &m, 1, DISP_DEC); display(" H (hidden)", (u_int8_t *) &h, 1, DISP_DEC); display(" Reserved", (u_int8_t *) &zeros, 1, DISP_DEC); display(" Length", (u_int8_t *) &length, 2, DISP_DEC); display(" Vendor ID", (u_int8_t *) &avp.vendor_id, 2, DISP_DEC); } /* * Now we can deal with the attribute, the length of which is the * given length - 6 */ if (length > 6) { u_int8_t * attribute; int real_length = length - 6; attribute = (u_int8_t *) my_malloc(real_length); if (get_packet_bytes((u_int8_t *) attribute, pkt, real_length) == 0) { my_free(attribute); return -1; } *n = *n + real_length; if (my_args->m) { switch(avp.attribute_type) { case L2TP_AVP_MESSAGETYPE: { u_int16_t attr; memcpy((void *) &attr, (void *) attribute, 2); attr = ntohs(attr); display_minimal_string(map2str(l2tp_ctrl_map, attr)); display_minimal_string(" "); } break; default: break; } } else { switch(avp.attribute_type) { case L2TP_AVP_MESSAGETYPE: { u_int16_t attr; memcpy((void *) &attr, (void *) attribute, 2); attr = ntohs(attr); display_strmap(" Message type", attr, l2tp_ctrl_map); } break; case L2TP_AVP_HOSTNAME: case L2TP_AVP_VENDORNAME: /* all of these attributes are text strings */ attribute[real_length] = '\0'; display_string(" Name", attribute); break; case L2TP_AVP_ASSIGNEDTUNNELID: case L2TP_AVP_ASSIGNEDSESSIONID: case L2TP_AVP_RECEIVEWINDOWSIZE: case L2TP_AVP_FIRMWAREREV: case L2TP_AVP_PROXYAUTHTYPE: { /* all of these attributes are 2 bytes */ u_int16_t value; memcpy((void *) &value, (void *) attribute, 2); value = ntohs(value); display(" Value", (u_int8_t *) &value, 2, DISP_DEC); } break; case L2TP_AVP_CALLSERIALNUMBER: case L2TP_AVP_MINIMUMBPS: case L2TP_AVP_MAXIMUMBPS: case L2TP_AVP_TXCONNECTSPEED: case L2TP_AVP_PHYSICALCHANNELID: { /* all of these attributes are 4 bytes */ u_int32_t value; memcpy((void *) &value, (void *) attribute, 4); value = ntohl(value); display(" Value", (u_int8_t *) &value, 4, DISP_DEC); } break; case L2TP_AVP_PROTOCOLVERSION: { u_int8_t ver; u_int8_t rev; ver = attribute[0]; rev = attribute[1]; display(" Version", (u_int8_t *) &ver, 1, DISP_DEC); display(" Revision", (u_int8_t *) &rev, 1, DISP_DEC); } break; default: /* display as hex for now */ display(" Attribute", (u_int8_t *) attribute, real_length, DISP_HEX_MULTILINE); break; } } /* free memory */ my_free(attribute); } return 0; } /*---------------------------------------------------------------------------- ** ** dump_l2tp() ** ** Parse L2TP packet and dump fields ** **---------------------------------------------------------------------------- */ void dump_l2tp(packet_t *pkt) { l2tphdr_t hdr; u_int8_t t, l, r1, s, r2, o, p, r3, v; u_int16_t tunnel_id; u_int16_t session_id; u_int16_t bytes_read = 0; u_int16_t length; /* Set the layer */ set_layer(LAYER_APPLICATION); /* * Read the first byte, determine what to do next */ if (get_packet_bytes((u_int8_t *) &hdr, pkt, 2) == 0) return; bytes_read += 2; /* * conversions */ t = hdr.t_bit; l = hdr.l_bit; r1 = hdr.reserved1; s = hdr.s_bit; r2 = hdr.reserved2; o = hdr.o_bit; p = hdr.p_bit; r3 = hdr.reserved3; v = hdr.version; /* * Display the first byte */ if (my_args->m) { if (t) display_minimal_string("| L2TP control "); else display_minimal_string("| L2TP data "); } else { /* announcement */ if (t) display_header_banner("L2TP control"); else display_header_banner("L2TP data"); display("T (type)", (u_int8_t *) &t, 1, DISP_DEC); display("L (length present)", (u_int8_t *) &l, 1, DISP_DEC); display("Reserved", (u_int8_t *) &r1, 1, DISP_DEC); display("S (sequence present)", (u_int8_t *) &s, 1, DISP_DEC); display("Reserved", (u_int8_t *) &r2, 1, DISP_DEC); display("O (offset present)", (u_int8_t *) &o, 1, DISP_DEC); display("P (priority)", (u_int8_t *) &p, 1, DISP_DEC); display("Reserved", (u_int8_t *) &r3, 1, DISP_DEC); display("Version", (u_int8_t *) &v, 1, DISP_DEC); } /* * If the length bit is set, get the length field and display it */ if (l) { /* get it */ if (get_packet_bytes((u_int8_t *) &length, pkt, 2) == 0) return; bytes_read += 2; /* convert */ length = ntohs(length); if (!my_args->m) display("Length", (u_int8_t *) &length, 2, DISP_DEC); } /* * Get the tunnel ID and session ID fields */ if (get_packet_bytes((u_int8_t *) &tunnel_id, pkt, 2) == 0) return; if (get_packet_bytes((u_int8_t *) &session_id, pkt, 2) == 0) return; bytes_read += 4; /* convert */ tunnel_id = ntohs(tunnel_id); session_id = ntohs(session_id); /* display */ if (my_args->m) { display_minimal_string("tunnel "); display_minimal((u_int8_t *) &tunnel_id, 2, DISP_DEC); display_minimal_string(" "); display_minimal_string("session "); display_minimal((u_int8_t *) &session_id, 2, DISP_DEC); display_minimal_string(" "); } else { display("Tunnel ID", (u_int8_t *) &tunnel_id, 2, DISP_DEC); display("Session ID", (u_int8_t *) &session_id, 2, DISP_DEC); } /* * If the sequence bit is set, get the seqno fields and display them */ if (s) { u_int16_t ns; u_int16_t nr; /* get them */ if (get_packet_bytes((u_int8_t *) &ns, pkt, 2) == 0) return; if (get_packet_bytes((u_int8_t *) &nr, pkt, 2) == 0) return; bytes_read += 4; /* convert */ ns = ntohs(ns); nr = ntohs(nr); /* display */ if (!my_args->m) { display("Seqno (Ns)", (u_int8_t *) &ns, 2, DISP_DEC); display("Received seqno (Nr)", (u_int8_t *) &nr, 2, DISP_DEC); } } /* * If the offset bit is set, get the offset and pad */ if (o) { u_int16_t offset; u_int8_t * pad; /* get the offset */ if (get_packet_bytes((u_int8_t *) &offset, pkt, 2) == 0) return; bytes_read += 2; /* convert */ offset = ntohs(offset); /* display */ if (!my_args->m) display("Offset", (u_int8_t *) &offset, 2, DISP_DEC); /* allocate memory for pad */ pad = (u_int8_t *) my_malloc(offset+1); /* get the pad */ if (get_packet_bytes((u_int8_t *) &pad, pkt, offset) == 0) { my_free(pad); return; } bytes_read += offset; /* display the offset in hex */ if (!my_args->m) display("Offset pad", pad, offset, DISP_HEX_MULTILINE); /* Free memory for the offset */ my_free(pad); } /* * For control messages, get the avp's. For data messages, parse the * PPP header that should be on top of the L2TP header... */ if (t) { /* grab all of the avp's, one by one */ while(bytes_read < length) if (dump_l2tp_avp(pkt, &bytes_read) == -1) break; /* dump the hex buffer */ hexbuffer_flush(); } else { dump_ppp(pkt); /* dump the hex buffer */ hexbuffer_flush(); } } ipgrab-0.9.10/src/l2tp.h0000644000175000001440000000216607170416335014107 0ustar farooqusers/**************************************************************************** ** ** File: l2tp.h ** ** Author: Mike Borella ** ** Comments: Structure of L2TP packets ** ** $Id: l2tp.h,v 1.4 2000/10/09 19:30:37 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef L2TP_H #define L2TP_H #include "global.h" #include "local.h" void dump_l2tp(packet_t *); #endif ipgrab-0.9.10/src/layers.c0000644000175000001440000000455407304526103014515 0ustar farooqusers/**************************************************************************** ** File: layers.c ** ** Author: Mike Borella ** ** Comments: ** ** $Id: layers.c,v 1.3 2001/05/28 19:51:31 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "layers.h" static layer_t l; extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** set_layer() ** ** Set the layer. ** **---------------------------------------------------------------------------- */ inline void set_layer(layer_t new_layer) { l = new_layer; } /*---------------------------------------------------------------------------- ** ** get_layer() ** ** Get the layer. ** **---------------------------------------------------------------------------- */ inline layer_t get_layer(void) { return l; } /*---------------------------------------------------------------------------- ** ** check_layer() ** ** Checks the current layer against the command line args. Returns 1 if ** we should not print, 0 if we should. ** **---------------------------------------------------------------------------- */ inline int check_layer(void) { switch(l) { case LAYER_NONE: return 0; case LAYER_DATALINK: if (my_args->l) return 1; else return 0; case LAYER_NETWORK: if (my_args->n) return 1; else return 0; case LAYER_TRANSPORT: if (my_args->t) return 1; else return 0; case LAYER_APPLICATION: if (my_args->a) return 1; else return 0; default: error_fatal("unknown layer type"); return 0; } } ipgrab-0.9.10/src/layers.h0000644000175000001440000000265107304522724014523 0ustar farooqusers/**************************************************************************** ** File: layers.h ** ** Author: Mike Borella ** ** Comments: Module that keeps track of what layer of the packet is ** being processed. ** ** $Id: layers.h,v 1.2 2001/05/28 19:24:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef LAYERS_H #define LAYERS_H #include "global.h" #include "local.h" typedef enum layer { LAYER_NONE, /* default for when a layer is not set */ LAYER_DATALINK, LAYER_NETWORK, LAYER_TRANSPORT, LAYER_APPLICATION } layer_t; inline void set_layer(layer_t); inline layer_t get_layer(void); inline int check_layer(void); #endif ipgrab-0.9.10/src/lcp.c0000644000175000001440000002574510637725554014017 0ustar farooqusers/**************************************************************************** ** File: lcp.c ** ** Author: Mike Borella ** ** Comments: LCP module. ** ** $Id: lcp.c,v 1.11 2007/06/25 11:47:56 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "lcp.h" #define LCP_OPTION_LEN 64 /* * LCP codes */ #define LCP_CODE_CONFREQ 1 #define LCP_CODE_CONFACK 2 #define LCP_CODE_CONFNAK 3 #define LCP_CODE_CONFREJ 4 #define LCP_CODE_TERMREQ 5 #define LCP_CODE_TERMACK 6 #define LCP_CODE_CODEREJ 7 #define LCP_CODE_PROTREJ 8 #define LCP_CODE_ECHOREQ 9 #define LCP_CODE_ECHOREP 10 #define LCP_CODE_DISCREQ 11 #define LCP_CODE_IDENTIFICATION 12 #define LCP_CODE_TIMEREMAINING 13 /* * LCP code map */ strmap_t lcp_code_map[] = { { LCP_CODE_CONFREQ, "Configure-Request" }, { LCP_CODE_CONFACK, "Configure-Ack" }, { LCP_CODE_CONFNAK, "Configure-Nak" }, { LCP_CODE_CONFREJ, "Configure-Reject" }, { LCP_CODE_TERMREQ, "Terminate-Request" }, { LCP_CODE_TERMACK, "Terminate-Ack" }, { LCP_CODE_CODEREJ, "Code-Rej" }, { LCP_CODE_PROTREJ, "Protocol-Reject" }, { LCP_CODE_ECHOREQ, "Echo-Request" }, { LCP_CODE_ECHOREP, "Echo-Reply" }, { LCP_CODE_DISCREQ, "Discard-Request" }, { LCP_CODE_IDENTIFICATION, "Identification" }, { LCP_CODE_TIMEREMAINING, "Time-Remaining" }, { 0, ""} }; /* * LCP options */ #define LCP_OPTION_VENDORSPECIFIC 0 #define LCP_OPTION_MAXRECVUNIT 1 #define LCP_OPTION_ASYNCCTRLCHARMAP 2 #define LCP_OPTION_AUTHPROTOCOL 3 #define LCP_OPTION_QUALITYPROTOCOL 4 #define LCP_OPTION_MAGICNUMBER 5 #define LCP_OPTION_PROTOFIELDCOMP 7 #define LCP_OPTION_ADDRCTRLFIELDCOMP 8 #define LCP_OPTION_FCSALTERNATIVES 9 #define LCP_OPTION_SELFDESCRIBINGPAD 10 #define LCP_OPTION_NUMBEREDMODE 11 #define LCP_OPTION_CALLBACK 13 #define LCP_OPTION_MULTILINKMRRU 17 #define LCP_OPTION_MULTILINKSSNHEADER 18 #define LCP_OPTION_MULTILINKENDPNTDISC 19 #define LCP_OPTION_PROPRIETARY 20 #define LCP_OPTION_DCEIDENTIFIER 21 #define LCP_OPTION_MULTILINKPLUSPROC 22 #define LCP_OPTION_LINKDISCFORBACP 23 #define LCP_OPTION_LCPAUTH 24 #define LCP_OPTION_COBS 25 #define LCP_OPTION_PREFIXELISION 26 #define LCP_OPTION_MULTILINKHDRFORMAT 27 #define LCP_OPTION_INTERNATIONALIZATION 28 #define LCP_OPTION_SIMPLEDATALINKSONET 29 #define LCP_OPTION_PPPMUXING 30 /* * LCP option map */ strmap_t lcp_option_map[] = { { LCP_OPTION_VENDORSPECIFIC, "vendor specific" }, { LCP_OPTION_MAXRECVUNIT, "max receive unit" }, { LCP_OPTION_ASYNCCTRLCHARMAP, "async char control map" }, { LCP_OPTION_AUTHPROTOCOL, "authentication protocol" }, { LCP_OPTION_QUALITYPROTOCOL, "quality protocol" }, { LCP_OPTION_MAGICNUMBER, "magic number" }, { LCP_OPTION_PROTOFIELDCOMP, "protocol field compression" }, { LCP_OPTION_ADDRCTRLFIELDCOMP, "address control field compression" }, { LCP_OPTION_FCSALTERNATIVES, "FCS alternatives" }, { LCP_OPTION_SELFDESCRIBINGPAD, "self describing pad" }, { LCP_OPTION_NUMBEREDMODE, "numbered mode" }, { LCP_OPTION_CALLBACK, "callback" }, { LCP_OPTION_MULTILINKMRRU, "multilink MRRU" }, { LCP_OPTION_MULTILINKSSNHEADER, "multilink short seq number header" }, { LCP_OPTION_MULTILINKENDPNTDISC, "multilink endpoint discriminator" }, { LCP_OPTION_PROPRIETARY, "proprietary" }, { LCP_OPTION_DCEIDENTIFIER, "DCE identifier" }, { LCP_OPTION_MULTILINKPLUSPROC, "multilink-plus procedure" }, { LCP_OPTION_LINKDISCFORBACP, "link discriminator for BACP" }, { LCP_OPTION_LCPAUTH, "LCP authentication" }, { LCP_OPTION_COBS, "consistent overhead byte stuffing" }, { LCP_OPTION_PREFIXELISION, "prefix elision" }, { LCP_OPTION_MULTILINKHDRFORMAT, "multilink header format" }, { LCP_OPTION_INTERNATIONALIZATION, "internationalization" }, { LCP_OPTION_SIMPLEDATALINKSONET, "simple datalink on SONET/SDH" }, { LCP_OPTION_PPPMUXING, "PPP muxing" }, { 0, "" } }; /* * LCP frame format */ typedef struct lcp { u_int8_t code; u_int8_t identifier; u_int16_t length; } lcp_t; extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** dump_lcp() ** ** Displays LCP packets. ** **---------------------------------------------------------------------------- */ void dump_lcp(packet_t *pkt) { lcp_t lcp; /* Set the layer */ set_layer(LAYER_DATALINK); /* * Get the header */ if (get_packet_bytes((u_int8_t *) &lcp, pkt, sizeof(lcp_t)) == 0) return; /* * Conversion */ lcp.length = ntohs(lcp.length); /* * Dump the header */ if (my_args->m) { display_minimal_string("| LCP "); display_minimal_string(map2str(lcp_code_map, lcp.code)); display_minimal_string(" "); } else { display_header_banner("LCP Header"); display_strmap("Code", lcp.code, lcp_code_map); display("Identifier", &lcp.identifier, 1, DISP_DEC); display("Length", (u_int8_t *) &lcp.length, 2, DISP_DEC); } /* * Grab the payload data */ if (lcp.length > sizeof(lcp_t)) { switch(lcp.code) { case LCP_CODE_CONFREQ: case LCP_CODE_CONFACK: case LCP_CODE_CONFNAK: case LCP_CODE_CONFREJ: { u_int8_t bytes_read = 0; u_int8_t type; u_int8_t length; u_int8_t value [LCP_OPTION_LEN]; int comma = 0; /* * LCP options appear in Type-Length-Value format */ while (bytes_read < lcp.length - sizeof(lcp_t)) { /* * Get type */ if (get_packet_bytes((u_int8_t *) &type, pkt, 1) == 0) break; bytes_read ++; /* * Get length */ if (get_packet_bytes((u_int8_t *) &length, pkt, 1) == 0) break; bytes_read ++; /* * In minimal mode we start all LCP options with an open paren * and put a comma before all but the first */ if (my_args->m) { if (comma) display_minimal_string(", "); else display_minimal_string("("); } comma = 1; /* * Display the type and length */ if (my_args->m) { display_minimal_string(map2str(lcp_option_map, type)); } else { display_strmap("Option", type, lcp_option_map); display(" Length", &length, 1, DISP_DEC); } /* * Figure out if we need to get a value */ if (length > 2) { if (get_packet_bytes((u_int8_t *) value, pkt, length-2) == 0) break; bytes_read = bytes_read + length - 2; /* * Display the value */ if (my_args->m) { display_minimal_string(" "); display_minimal(value, length-2, DISP_HEX); } else { display(" Value", (u_int8_t *) value, length-2, DISP_HEX); } } /* if */ } /* while */ /* * Insert end paren in minimal mode */ if (my_args->m) display_minimal_string(")"); } break; case LCP_CODE_TERMREQ: case LCP_CODE_TERMACK: { u_int8_t * data; u_int8_t data_len; /* * Read the data, if any */ data_len = lcp.length - sizeof(lcp_t); if (data_len > 0) { /* allocate memory for the data */ data = (u_int8_t *) my_malloc(data_len); /* grab the data field */ if (get_packet_bytes(data, pkt, data_len) == 0) { my_free(data); return; } /* dump it out as hex, but don't dump in minimal mode */ if (!my_args->m) { display("Data", data, data_len, DISP_HEX); } /* free that darn mem! */ my_free(data); } } break; case LCP_CODE_ECHOREQ: case LCP_CODE_ECHOREP: case LCP_CODE_DISCREQ: case LCP_CODE_IDENTIFICATION: case LCP_CODE_TIMEREMAINING: { u_int32_t magic_number; u_int8_t * data; u_int8_t data_len; /* get the magic number */ if (get_packet_bytes((u_int8_t *) &magic_number, pkt, 4) == 0) return; /* display it */ if (my_args->m) { display_minimal((u_int8_t *) &magic_number, 4, DISP_HEX); display_minimal_string(" "); } else { display("Magic number", (u_int8_t *) &magic_number, 4, DISP_HEX); } /* Read the data, if any */ data_len = lcp.length - sizeof(lcp_t) - 4; if (data_len > 0) { /* Allocate memory for the data - extra for nulling a string */ data = (u_int8_t *) my_malloc(data_len + 1); /* grab the data field */ if (get_packet_bytes(data, pkt, data_len) == 0) { my_free(data); return; } data[data_len] = '\0'; /* dump it out as hex, but don't dump in minimal mode */ if (!my_args->m) { if (isprint_str(data, data_len)) display_string("Data", data); else display("Data", data, data_len, DISP_HEX); } /* free that darn mem! */ my_free(data); } } break; case LCP_CODE_CODEREJ: dump_lcp(pkt); break; /** * In this case, the payload contains two-byte rejected protocol * field, followed by which is the rejected information. **/ case LCP_CODE_PROTREJ: { u_int16_t proto; u_int8_t * data; u_int8_t data_len; /* * Get the rejected protocol field */ if (get_packet_bytes((u_int8_t *) &proto, pkt, 2) == 0) return; if (my_args->m) { display_minimal((u_int8_t *) &proto, 2, DISP_HEX); display_minimal_string(" "); } else { display("Rejected Protocol", (u_int8_t *) &proto, 2, DISP_HEX); } /* * Read and display the protocol data if any */ data_len = lcp.length - sizeof(lcp_t) - 2; if (data_len > 0) { data = (u_int8_t *) my_malloc(data_len); if (get_packet_bytes(data, pkt, data_len) == 0) { my_free(data); return; } if (!my_args->m) { display("Rejected Data", data, data_len, DISP_HEX); } my_free(data); } /* if */ } break; default: break; } } /* dump the hex buffer */ if (!my_args->l) hexbuffer_flush(); } ipgrab-0.9.10/src/lcp.h0000644000175000001440000000215307153552026013777 0ustar farooqusers/**************************************************************************** ** File: lcp.h ** ** Author: Mike Borella ** ** Comments: LCP module definitions. ** ** $Id: lcp.h,v 1.1 2000/08/31 21:54:30 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef LCP_H #define LCP_H #include "global.h" #include "local.h" void dump_lcp(packet_t *); #endif ipgrab-0.9.10/src/llc.c0000644000175000001440000000774510637724267014013 0ustar farooqusers/**************************************************************************** ** File: llc.c ** ** Author: Mike Borella ** ** Comments: Dump LLC packets ** ** $Id: llc.c,v 1.6 2007/06/25 11:36:23 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "global.h" #include "llc.h" #include "ipx.h" extern struct arg_t *my_args; /*---------------------------------------------------------------------------- ** ** dump_llc() ** ** Process packets encapsulated in LLC ** **---------------------------------------------------------------------------- */ void dump_llc(packet_t *pkt) { llc_header_t llc; u_int8_t org_id[3]; u_int16_t ethertype; u_int8_t control; /* Set the layer */ set_layer(LAYER_DATALINK); /* * Read the header */ if (get_packet_bytes((u_int8_t *) &llc, pkt, 2) == 0) return; /* * Dump header */ if (my_args->m) { display_minimal_string("| LLC "); display_minimal((u_int8_t *) &llc.dsap, 1, DISP_HEX); display_minimal_string(" "); display_minimal((u_int8_t *) &llc.ssap, 1, DISP_HEX); display_minimal_string(" "); } else { /* announcement */ display_header_banner("LLC header"); display("DSAP", (u_int8_t *) &llc.dsap, 1, DISP_HEX); display("SSAP", (u_int8_t *) &llc.ssap, 1, DISP_HEX); } /* check for IPX raw framing */ if (llc.dsap == 0xFF && llc.ssap == 0xFF) { dump_ipx(pkt); return; } /* * If it was not IPX raw framing, now we know that we have a control field as well in the packet. So get it. */ if (get_packet_bytes((u_int8_t *) &control, pkt, 1) == 0) return; if (my_args->m) { display_minimal((u_int8_t *) &control, 1, DISP_HEX); display_minimal_string(" "); } else display("Control", (u_int8_t *) &control, 1, DISP_HEX); /* check for NETBIOS logon */ if (llc.dsap == 0xF0 && llc.ssap == 0xF0) { /* dump_ipx(pkt); */ return; } /* check for IPX/NETBIOS encapsulation */ if (llc.dsap == 0xE0 && llc.ssap == 0xE0) { dump_ipx(pkt); return; } /* check for SNAP (802.1a) encapsulation */ if (llc.dsap == 0xAA && llc.ssap == 0xAA) { /* The next three bytes should be the organization id, which is typically 0 */ if (get_packet_bytes((u_int8_t *) org_id, pkt, 3) == 0) return; if (get_packet_bytes((u_int8_t *) ðertype, pkt, 2) == 0) return; /* * Conversions -- No conversion is required as the DISP_HEX * option in display:display_minimal() requires data in * network byte order i.e. big endian unless DISP_HEX is * modified. Later option would require looking up the entire * source code so as not to break it. */ /* * ethertype = ntohs(ethertype); */ /* * Display fields */ if (my_args->m) { display_minimal_string("SNAP "); display_minimal((u_int8_t *) ðertype, 2, DISP_HEX); display_minimal_string(" "); } else { /* announcement */ display_header_banner("SNAP header"); display("Organization ID", (u_int8_t *) org_id, 3, DISP_HEX); display("Protocol", (u_int8_t *) ðertype, 2, DISP_HEX); } } return; } ipgrab-0.9.10/src/llc.h0000644000175000001440000000234407153266450014000 0ustar farooqusers/**************************************************************************** ** File: llc.h ** ** Author: Mike Borella ** ** Comments: LLC encapsulation for ethernet packets ** ** $Id: llc.h,v 1.4 2000/08/30 20:23:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef LLC_H #define LLC_H #include "global.h" #include "local.h" /* * LLC header */ typedef struct llc_header { u_int8_t dsap; u_int8_t ssap; } llc_header_t; void dump_llc(packet_t *); #endif ipgrab-0.9.10/src/local.h0000644000175000001440000000266007375021177014322 0ustar farooqusers/**************************************************************************** ** File: local.h ** ** Author: Mike Borella ** ** Comments: Includes the ipgrab header files commonly needed. ** ** $Id: local.h,v 1.6 2001/11/15 20:15:59 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef LOCAL_H #define LOCAL_H #include "strmap.h" #include "display.h" #include "packet_manip.h" #include "parse_cl.h" #include "hexbuffer.h" #include "utilities.h" #include "stats.h" #include "layers.h" #include "state.h" #include "ip_services.h" /* * This is a stupid hack to get around forcing signal handlers to take * an int as an argument */ typedef void (*sighandler_t)(int); #endif ipgrab-0.9.10/src/loopback.c0000644000175000001440000000420707304522724015010 0ustar farooqusers/**************************************************************************** ** ** File: loopback.c ** ** Author: Mike Borella ** ** Comments: Dump loopback packets ** ** $Id: loopback.c,v 1.5 2001/05/28 19:24:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "loopback.h" #include "ip_protocols.h" #define LOOPBACK_FAMILY_INET 524288 /* magic cookie for IP over loopback */ extern struct arg_t *my_args; /*---------------------------------------------------------------------------- ** ** dump_loopback() ** ** Process packets from DLT_NULL device ** **---------------------------------------------------------------------------- */ void dump_loopback(packet_t *pkt) { u_int32_t family; if (get_packet_bytes((u_int8_t *) &family, pkt, 4) == 0) return; /* Set the layer */ set_layer(LAYER_DATALINK); /* * Dump header */ if (my_args->m) { if (my_args->T) display_minimal_string("LOOPBACK "); else display_minimal_string("| LOOPBACK "); } else { /* * Dump header announcement */ display_header_banner_ts("Loopback", pkt->timestamp); /* * Dump header field */ display("Address family", (u_int8_t *) &family, 4, DISP_HEX); } switch (family) { case LOOPBACK_FAMILY_INET: dump_ip(pkt); break; default: break; } return; } ipgrab-0.9.10/src/loopback.h0000644000175000001440000000225207153266450015016 0ustar farooqusers/**************************************************************************** ** ** File: loopback.h ** ** Author: Mike Borella ** ** Comments: Loopback device definitions ** ** $Id: loopback.h,v 1.3 2000/08/30 20:23:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef LOOPBACK_H #define LOOPBACK_H #include "global.h" #include "local.h" #define LOOPBACK_HEADER_LEN 4 void dump_loopback(packet_t *); #endif ipgrab-0.9.10/src/mgcp.c0000644000175000001440000000520707153266450014150 0ustar farooqusers/**************************************************************************** ** File: mgcp.c ** ** Author: Cullen Jennings & Mike Borella ** ** Comments: Dump MGCP header information. I didn't try to do anything ** fancy with this - I just dump the plaintext ** ** $Id: mgcp.c,v 1.6 2000/08/30 20:23:04 mborella Exp $ ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "mgcp.h" #include "sdp.h" #define LINE_SIZE 256 #define FALSE 0 #define TRUE 1 /*---------------------------------------------------------------------------- ** ** is_mgcp() ** ** Return true if this udp packet is a MGCP packet ** **---------------------------------------------------------------------------- */ int is_mgcp(packet_t *pkt) { if ( 0 < 4 ) return 0; /* FIXME!!*/ if ( !strncmp(pkt->current,"EPCF",4) ) return 1; if ( !strncmp(pkt->current,"RQNT",4) ) return 1; if ( !strncmp(pkt->current,"NTFY",4) ) return 1; if ( !strncmp(pkt->current,"CRCX",4) ) return 1; if ( !strncmp(pkt->current,"MDCX",4) ) return 1; if ( !strncmp(pkt->current,"DLCX",4) ) return 1; if ( !strncmp(pkt->current,"AUEP",4) ) return 1; if ( !strncmp(pkt->current,"AUCX",4) ) return 1; if ( !strncmp(pkt->current,"RSIP",4) ) return 1; return 0; } /*---------------------------------------------------------------------------- ** ** dump_mgcp() ** ** Parse MGCP packet and dump fields. ** **---------------------------------------------------------------------------- */ void dump_mgcp(packet_t *pkt) { /* char line[LINE_SIZE]; int n = 0;*/ printf("-----------------------------------------------------------------\n"); printf(" MGCP \n"); printf("-----------------------------------------------------------------\n"); /* FIX ME LATER while(p <= ep && (n = get_next_line(p, ep, line))) { p = p + n; length = length - n; printf("%s\n", line); } */ } ipgrab-0.9.10/src/mgcp.h0000644000175000001440000000217407153266450014155 0ustar farooqusers/**************************************************************************** ** ** File: mgcp.h ** ** Author: Cullen Jennings & Mike Borella ** ** $Id: mgcp.h,v 1.4 2000/08/30 20:23:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef MGCP_H #define MGCP_H #include "global.h" #include "local.h" int is_mgcp(packet_t *pkt); void dump_mgcp(packet_t *pkt); #endif ipgrab-0.9.10/src/mobileip.c0000644000175000001440000006222210530527426015016 0ustar farooqusers/**************************************************************************** ** File: mobileip.c ** ** Author: Mike Borella ** ** Comments: ** ** $Id: mobileip.c,v 1.12 2006/11/21 07:47:34 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "global.h" #include "mobileip.h" #include "ethertypes.h" /* * Types of Mobile IP messages */ #define MOBILEIP_TYPE_REGREQ 1 #define MOBILEIP_TYPE_REGREP 3 #define MOBILEIP_TYPE_REGUPDATE 20 #define MOBILEIP_TYPE_REGACK 21 /* * Mobile IP type map */ strmap_t mobileip_type_map[] = { { MOBILEIP_TYPE_REGREQ, "registration request" }, { MOBILEIP_TYPE_REGREP, "registration reply" }, { MOBILEIP_TYPE_REGUPDATE, "registration update" }, { MOBILEIP_TYPE_REGACK, "registration acknowledgement" }, { 0, ""} }; /* * Mobile IP response codes */ #define MOBILEIP_RESPCODE_REGACCEPTED 0 #define MOBILEIP_RESPCODE_REGACCEPTEDNOSMB 1 #define MOBILEIP_RESPCODE_FA_UNSPECIFIED 64 #define MOBILEIP_RESPCODE_FA_ADMINPROHIBITED 65 #define MOBILEIP_RESPCODE_FA_INSUFFICIENTRESOURCES 66 #define MOBILEIP_RESPCODE_FA_MNAUTHFAILED 67 #define MOBILEIP_RESPCODE_FA_HAAUTHFAILED 68 #define MOBILEIP_RESPCODE_FA_LIFETIMETOOLONG 69 #define MOBILEIP_RESPCODE_FA_POORLYFORMEDREQ 70 #define MOBILEIP_RESPCODE_FA_POORLYFORMEDREP 71 #define MOBILEIP_RESPCODE_FA_ENCAPSUNAVAILABLE 72 #define MOBILEIP_RESPCODE_FA_VJCOMPUNAVAILABLE 73 #define MOBILEIP_RESPCODE_FA_HNUNREACHABLE 80 #define MOBILEIP_RESPCODE_FA_HAHOSTUNREACHABLE 81 #define MOBILEIP_RESPCODE_FA_HAPORTUNREACHABLE 82 #define MOBILEIP_RESPCODE_FA_HAUNREACHABLE 88 #define MOBILEIP_RESPCODE_HA_UNSPECIFIED 128 #define MOBILEIP_RESPCODE_HA_ADMINPROHIBITED 129 #define MOBILEIP_RESPCODE_HA_INSUFFICIENTRESOURCES 130 #define MOBILEIP_RESPCODE_HA_MNAUTHFAILED 131 #define MOBILEIP_RESPCODE_HA_FAAUTHFAILED 132 #define MOBILEIP_RESPCODE_HA_IDMISMATCH 133 #define MOBILEIP_RESPCODE_HA_POORLYFORMEDREQ 134 #define MOBILEIP_RESPCODE_HA_TOOMANYSMB 135 #define MOBILEIP_RESPCODE_HA_UNKNOWNHAADDR 136 /* * Mobile IP extensions */ #define MOBILEIP_EXT_MHAUTH 32 /* RFC 2002 */ #define MOBILEIP_EXT_MFAUTH 33 /* RFC 2002 */ #define MOBILEIP_EXT_FHAUTH 34 /* RFC 2002 */ #define MOBILEIP_EXT_GENMOBILEIPAUTH 36 /* RFC 3012 */ #define MOBILEIP_EXT_CVSE 38 /* RFC 3025 */ #define MOBILEIP_EXT_SESSIONSPECIFIC 39 /* TIA/IS-2001 */ #define MOBILEIP_EXT_REGUPDATEAUTH 40 /* TIA/IS-2001 */ #define MOBILEIP_EXT_NAI 131 /* RFC 2794 */ #define MOBILEIP_EXT_MNFACHALLENGE 132 /* RFC 2794 */ /* * Mobile IP extension map */ strmap_t mobileip_ext_map [] = { { MOBILEIP_EXT_MHAUTH, "mobile-home authentication" }, { MOBILEIP_EXT_MFAUTH, "mobile-foreign authentication" }, { MOBILEIP_EXT_FHAUTH, "foreign-home authentication" }, { MOBILEIP_EXT_GENMOBILEIPAUTH, "generalized Mobile IP authentication" }, { MOBILEIP_EXT_CVSE, "critical vendor-specific extension" }, { MOBILEIP_EXT_SESSIONSPECIFIC, "session specific extension" }, { MOBILEIP_EXT_REGUPDATEAUTH, "registration update authentication" }, { MOBILEIP_EXT_NAI, "network access identifier" }, { MOBILEIP_EXT_MNFACHALLENGE, "MN-FA challenge" }, { 0, "" } }; /* * Format of Mobile IP registration request * * * 0 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Type |S|B|D|M|G|V|rsv| Lifetime | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Home Address | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Home Agent | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Care-of Address | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | | * + Identification + * | | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Extensions ... * +-+-+-+-+-+-+-+- */ typedef struct mobileip_regreq { u_int8_t type; u_int8_t flags; u_int16_t lifetime; u_int32_t home_addr; u_int32_t home_agent; u_int32_t care_of_addr; u_int8_t identification[8]; } mobileip_regreq_t; /* * Format of Mobile IP registration reply * * 0 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Type | Code | Lifetime | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Home Address | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Home Agent | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | | * + Identification + * | | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Extensions ... * +-+-+-+-+-+-+-+- */ typedef struct mobileip_regrep { u_int8_t type; u_int8_t code; u_int16_t lifetime; u_int32_t home_addr; u_int32_t home_agent; u_int8_t identification[8]; } mobileip_regrep_t; /* * Format of Mobile IP registration update * 0 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Type | Reserved | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Home Address | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Home Agent Address | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | | * + Identification + * | | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Extensions ... * +-+-+-+-+-+-+-+- */ typedef struct mobileip_regupdate { u_int8_t type; u_int8_t reserved[3]; u_int32_t home_addr; u_int32_t home_agent; u_int8_t identification[8]; } mobileip_regupdate_t; /* * Format of Mobile IP registration ack * * 0 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Type | Status | Reserved | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Home Address | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Home Agent | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | | * + Identification + * | | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Extensions ... * +-+-+-+-+-+-+-+- */ typedef struct mobileip_regack { u_int8_t type; u_int8_t status; u_int16_t reserved; u_int32_t home_addr; u_int32_t home_agent; u_int8_t identification[8]; } mobileip_regack_t; /* * Structure of the Mobile IP session specific extension */ typedef struct mobileip_ext_sessionspecific { u_int8_t type; u_int8_t length; u_int16_t protocol; u_int32_t key; u_int16_t reserved; u_int16_t mn_session; u_int16_t mn_id_type; u_int8_t mn_id_length; } mobileip_ext_sessionspecific_t; /* * Structure of the mobile IP CVSE */ typedef struct mobileip_ext_cvse { u_int8_t type; u_int8_t reserved; u_int16_t length; u_int32_t vendor; u_int16_t subtype; } mobileip_ext_cvse_t; /* * Structure of the mobile IP mobile/home authentication extension */ typedef struct mobileip_ext_mhauth { u_int8_t type; u_int8_t length; u_int32_t spi; } mobileip_ext_mhauth_t; /* * Structure of the fixed portion of the general mobile IP auth extension */ typedef struct mobileip_ext_genmobileipauth { u_int8_t type; u_int8_t subtype; u_int16_t length; u_int32_t spi; } mobileip_ext_genmobileipauth_t; extern struct arg_t * my_args; extern strmap_t ethertype_map[]; /*---------------------------------------------------------------------------- ** ** dump_mobileip_sessionspecificext() ** ** Dumps mobile IP session specific extensions ** **---------------------------------------------------------------------------- */ void dump_mobileip_ext_sessionspecific(packet_t *pkt) { mobileip_ext_sessionspecific_t ss; u_int8_t * mn_id; /* Get the common part of the extension */ if (get_packet_bytes((u_int8_t *) &ss, pkt, 15) == 0) return; /* Conversions */ ss.protocol = ntohs(ss.protocol); ss.key = ntohl(ss.key); ss.reserved = ntohs(ss.reserved); ss.mn_session = ntohs(ss.mn_session); ss.mn_id_type = ntohs(ss.mn_id_type); /* Display */ if (my_args->m) { display_minimal_string(map2str(mobileip_ext_map, ss.type)); display_minimal_string(" "); } else { display_strmap("Extension type", ss.type, mobileip_ext_map); display(" Length", &ss.length, 1, DISP_DEC); display_strmap_hex(" Protocol", ss.protocol, ethertype_map); display(" Key", (u_int8_t *) &ss.key, 4, DISP_HEX); display(" Reserved", (u_int8_t *) &ss.reserved, 2, DISP_DEC); display(" MN session ref ID", (u_int8_t *) &ss.mn_session, 2, DISP_DEC); display(" MN ID type", (u_int8_t *) &ss.mn_id_type, 2, DISP_DEC); display(" MN ID length", (u_int8_t *) &ss.mn_id_length, 1, DISP_DEC); } /* Allocate memeory for the MN ID */ mn_id = my_malloc(ss.mn_id_length); /* Get the MN ID */ if (get_packet_bytes(mn_id, pkt, ss.mn_id_length) == 0) return; /* Display the MN ID */ if (my_args->m) { } else display(" MN ID", mn_id, ss.mn_id_length, DISP_HEX); /* Deallocate memory for the MN ID */ my_free(mn_id); /* * Check for any padding. Some PCF's send a full 21 byte option * regardless of the length of the MN ID. The fixed portion of the * option is 13 bytes. */ if (ss.mn_id_length + 13 < ss.length) { u_int16_t dummy; if (get_packet_bytes((u_int8_t *) &dummy, pkt, ss.length - ss.mn_id_length - 13) == 0) return; } return; } /*---------------------------------------------------------------------------- ** ** dump_mobileip_ext_csve() ** ** Dumps mobile IP critical / vendor specific extensions ** **---------------------------------------------------------------------------- */ void dump_mobileip_ext_cvse(packet_t * pkt) { mobileip_ext_cvse_t cvse; u_int8_t * data; /* Get the common part of the header */ if (get_packet_bytes((u_int8_t *) &cvse, pkt, 10) == 0) return; /* Conversions */ cvse.length = ntohs(cvse.length); cvse.vendor = ntohl(cvse.vendor); cvse.subtype = ntohs(cvse.subtype); /* Display */ if (my_args->m) { display_minimal_string(map2str(mobileip_ext_map, cvse.type)); display_minimal_string(" "); } else { display_strmap("Extention type", cvse.type, mobileip_ext_map); display(" Reserved", &cvse.reserved, 1, DISP_DEC); display(" Length", (u_int8_t *) &cvse.length, 2, DISP_DEC); display(" Vendor ID", (u_int8_t *) &cvse.vendor, 4, DISP_DEC); display(" Subtype", (u_int8_t *) &cvse.subtype, 2, DISP_DEC); } if (cvse.length > 6) { /* Allocate memory for data */ data = my_malloc(cvse.length-6); /* Get data portion */ if (get_packet_bytes(data, pkt, cvse.length-6) == 0) return; /* Display data portion */ if (!my_args->m) display(" Data", data, cvse.length-6, DISP_HEX_MULTILINE); /* Free memory for data */ my_free(data); } } /*---------------------------------------------------------------------------- ** ** dump_mobileip_ext_nai() ** ** Dumps mobile IP NAI extension ** **---------------------------------------------------------------------------- */ void dump_mobileip_ext_nai(packet_t * pkt) { u_int8_t type; u_int8_t length; char * nai; /* Get the type */ if (get_packet_bytes((u_int8_t *) &type, pkt, 1) == 0) return; /* Get the length */ if (get_packet_bytes((u_int8_t *) &length, pkt, 1) == 0) return; /* Get the NAI */ nai = (char *) malloc (length+2); if (get_packet_bytes(nai, pkt, length) == 0) return; nai[length] = '\0'; /* Display */ if (my_args->m) { } else { display_strmap("Extension type", type, mobileip_ext_map); display(" Length", (u_int8_t *) &length, 1, DISP_DEC); display_string(" NAI", nai); } /* Free memory */ my_free(nai); return; } /*---------------------------------------------------------------------------- ** ** dump_mobileip_ext_mnfachallenge() ** ** Dumps mobile IP MN-FA extension ** **---------------------------------------------------------------------------- */ void dump_mobileip_ext_mnfachallenge(packet_t * pkt) { u_int8_t type; u_int8_t length; u_int8_t * challenge; /* Get the type */ if (get_packet_bytes((u_int8_t *) &type, pkt, 1) == 0) return; /* Get the length */ if (get_packet_bytes((u_int8_t *) &length, pkt, 1) == 0) return; /* Get the authenticator */ challenge = (char *) malloc (length+2); if (get_packet_bytes((u_int8_t *) challenge, pkt, length) == 0) return; /* Display */ if (my_args->m) { } else { display_strmap("Extension type", type, mobileip_ext_map); display(" Length", (u_int8_t *) &length, 1, DISP_DEC); display(" Challenge", (u_int8_t *) challenge, length, DISP_HEX); } /* Free memory */ my_free(challenge); return; } /*---------------------------------------------------------------------------- ** ** dump_mobileip_ext_genmobileipauth() ** ** Dumps the general MIP authentication extension ** **---------------------------------------------------------------------------- */ void dump_mobileip_ext_genmobileipauth(packet_t * pkt) { mobileip_ext_genmobileipauth_t genmip; u_int8_t * auth; /* Get the fixed header */ if (get_packet_bytes((u_int8_t *) &genmip, pkt, 8) == 0) return; /* Conversions */ genmip.length = ntohs(genmip.length); /* Allocate memory for the authentication */ auth = my_malloc(genmip.length-4); /* Get the authenticator */ if (get_packet_bytes(auth, pkt, genmip.length-4) == 0) return; /* Display */ if (my_args->m) { } else { display_strmap("Extension type", genmip.type, mobileip_ext_map); display(" Subtype", &genmip.subtype, 1, DISP_DEC); display(" Length", (u_int8_t *) &genmip.length, 2, DISP_DEC); display(" SPI", (u_int8_t *) &genmip.spi, 4, DISP_HEX); display(" Authenticator", auth, genmip.length-4, DISP_HEX_MULTILINE); } /* Free memory for authenticator */ my_free(auth); return; } /*---------------------------------------------------------------------------- ** ** dump_mobileip_ext_mhauth() ** ** Dumps mobile IP mobile/home authentication extension messages ** **---------------------------------------------------------------------------- */ void dump_mobileip_ext_mhauth(packet_t * pkt) { mobileip_ext_mhauth_t mh; u_int8_t * authenticator; /* Read all but the authenticator */ if (get_packet_bytes((u_int8_t *) &mh, pkt, 6) == 0) return; /* Conversions */ mh.spi = ntohl(mh.spi); /* Allocate memory for authenticator */ authenticator = my_malloc(mh.length-4); /* Read authenticator */ if (get_packet_bytes(authenticator, pkt, mh.length-4) == 0) return; /* Display */ if (my_args->m) { display_minimal_string(map2str(mobileip_ext_map, mh.type)); display_minimal_string(" "); } else { display_strmap("Extension type", mh.type, mobileip_ext_map); display(" Length", &mh.length, 1, DISP_DEC); display(" SPI", (u_int8_t *) &mh.spi, 4, DISP_HEX); display(" Authenticator", authenticator, mh.length-4, DISP_HEX_MULTILINE); } /* Free memory for authenticator */ my_free(authenticator); return; } /*---------------------------------------------------------------------------- ** ** dump_mobileip() ** ** Dumps mobile IP messages ** **---------------------------------------------------------------------------- */ void dump_mobileip(packet_t *pkt) { u_int8_t first_byte; /* Set the layer */ set_layer(LAYER_APPLICATION); /* * Look at the first byte to determine the type */ if (look_packet_bytes(&first_byte, pkt, 1) == 0) return; /* * Display mobile IP annoucnement */ if (my_args->m) display_minimal_string("| Mobile IP "); else display_header_banner("Mobile IP"); /* * Take action based on message type */ switch(first_byte) { case MOBILEIP_TYPE_REGREQ: /* registration request */ { mobileip_regreq_t regreq; /* Get the message */ if (get_packet_bytes((u_int8_t *) ®req, pkt, sizeof(regreq)) == 0) return; /* Conversions */ regreq.lifetime = ntohs(regreq.lifetime); /* Display */ if (my_args->m) { display_minimal_string(map2str(mobileip_type_map, regreq.type)); display_minimal_string(" ("); display_minimal_string("addr:"); display_minimal_ipv4((u_int8_t *) ®req.home_addr); display_minimal_string(",HA:"); display_minimal_ipv4((u_int8_t *) ®req.home_agent); display_minimal_string(",COA:"); display_minimal_ipv4((u_int8_t *) ®req.care_of_addr); display_minimal_string(") "); } else { display_strmap("Type", regreq.type, mobileip_type_map); display("Flags", ®req.flags, 1, DISP_HEX); display("Lifetime", (u_int8_t *) ®req.lifetime, 2, DISP_DEC); display_ipv4("Home address", (u_int8_t *) ®req.home_addr); display_ipv4("Home agent", (u_int8_t *) ®req.home_agent); display_ipv4("Care of address", (u_int8_t *) ®req.care_of_addr); display("Identification", (u_int8_t *) ®req.identification, 8, DISP_HEX); } } break; case MOBILEIP_TYPE_REGREP: /* registration response */ { mobileip_regrep_t regrep; /* Get the message */ if (get_packet_bytes((u_int8_t *) ®rep, pkt, sizeof(regrep)) == 0) return; /* Conversions */ regrep.lifetime = ntohs(regrep.lifetime); /* Display */ if (my_args->m) { display_minimal_string(map2str(mobileip_type_map, regrep.type)); display_minimal_string(" ("); display_minimal_string("addr:"); display_minimal_ipv4((u_int8_t *) ®rep.home_addr); display_minimal_string(",HA:"); display_minimal_ipv4((u_int8_t *) ®rep.home_agent); display_minimal_string(") "); } else { display_strmap("Type", regrep.type, mobileip_type_map); display("Code", ®rep.code, 1, DISP_HEX); display("Lifetime", (u_int8_t *) ®rep.lifetime, 2, DISP_DEC); display_ipv4("Home address", (u_int8_t *) ®rep.home_addr); display_ipv4("Home agent", (u_int8_t *) ®rep.home_agent); display("Identification", (u_int8_t *) ®rep.identification, 8, DISP_HEX); } } break; case MOBILEIP_TYPE_REGUPDATE: /* registration update */ { mobileip_regupdate_t regupdate; /* Get the message */ if (get_packet_bytes((u_int8_t *) ®update, pkt, sizeof(regupdate)) == 0) return; /* Display */ if (my_args->m) { display_minimal_string(map2str(mobileip_type_map, regupdate.type)); display_minimal_string(" ("); display_minimal_string("addr:"); display_minimal_ipv4((u_int8_t *) ®update.home_addr); display_minimal_string(",HA:"); display_minimal_ipv4((u_int8_t *) ®update.home_agent); display_minimal_string(") "); } else { display_strmap("Type", regupdate.type, mobileip_type_map); display("Reserved", (u_int8_t *) ®update.reserved, 3, DISP_DEC); display_ipv4("Home address", (u_int8_t *) ®update.home_addr); display_ipv4("Home agent", (u_int8_t *) ®update.home_agent); display("Identification", (u_int8_t *) ®update.identification, 8, DISP_HEX); } } break; case MOBILEIP_TYPE_REGACK: /* registration ack */ { mobileip_regack_t regack; /* Get the message */ if (get_packet_bytes((u_int8_t *) ®ack, pkt, sizeof(regack)) == 0) return; /* Conversions */ regack.reserved = ntohs(regack.reserved); /* Display */ if (my_args->m) { display_minimal_string(map2str(mobileip_type_map, regack.type)); display_minimal_string(" ("); display_minimal_string("addr:"); display_minimal_ipv4((u_int8_t *) ®ack.home_addr); display_minimal_string(",HA:"); display_minimal_ipv4((u_int8_t *) ®ack.home_agent); display_minimal_string(") "); } else { display_strmap("Type", regack.type, mobileip_type_map); display("Status", ®ack.status, 1, DISP_HEX); display("Reserved", (u_int8_t *) ®ack.reserved, 2, DISP_DEC); display_ipv4("Home address", (u_int8_t *) ®ack.home_addr); display_ipv4("Home agent", (u_int8_t *) ®ack.home_agent); display("Identification", (u_int8_t *) ®ack.identification, 8, DISP_HEX); } } break; default: /* Unknown message type, dump the hexbuffer and quit */ hexbuffer_flush(); return; } /* * Look for extensions. Note that since not all mobile IP extensions * follow the RFC 2002 method (type-length-value) we may cause weird * problems by assuming that there is a valid length after the type. */ while (get_packet_apparentbytesleft(pkt)) { u_int8_t type; /* Get the next byte, which should be the type of the extension */ if (look_packet_bytes(&type, pkt, 1) == 0) { hexbuffer_flush(); return; } /* Decide what to do based on the extension type */ switch(type) { case MOBILEIP_EXT_SESSIONSPECIFIC: dump_mobileip_ext_sessionspecific(pkt); break; case MOBILEIP_EXT_CVSE: dump_mobileip_ext_cvse(pkt); break; case MOBILEIP_EXT_MHAUTH: case MOBILEIP_EXT_REGUPDATEAUTH: dump_mobileip_ext_mhauth(pkt); break; case MOBILEIP_EXT_NAI: dump_mobileip_ext_nai(pkt); break; case MOBILEIP_EXT_MNFACHALLENGE: dump_mobileip_ext_mnfachallenge(pkt); break; case MOBILEIP_EXT_GENMOBILEIPAUTH: dump_mobileip_ext_genmobileipauth(pkt); break; default: /* We don't recognize this extension...just dump the data */ { u_int8_t type; u_int8_t length; u_int8_t * data; /* Get the type and the length */ if (get_packet_bytes(&type, pkt, 1) == 0) return; if (get_packet_bytes(&length, pkt, 1) == 0) return; /* Display the type and the length */ if (my_args->m) { } else { display_strmap("Extension type", type, mobileip_ext_map); display(" Length", &length, 1, DISP_DEC); } /* Allocate memory for the data */ data = my_malloc(length); /* Get the data */ if (get_packet_bytes(data, pkt, length) == 0) { hexbuffer_flush(); return; } /* * Dump the data. Let's not do anything for minimal mode because * it would probably just clutter the display */ if (!my_args->m) { display(" Data", data, length, DISP_HEX_MULTILINE); } /* Deallocate memory for the data */ my_free(data); } break; } } /* Dump the hex buffer */ hexbuffer_flush(); return; } ipgrab-0.9.10/src/mobileip.h0000644000175000001440000000215507232156047015024 0ustar farooqusers/**************************************************************************** ** File: mobileip.h ** ** Author: Mike Borella ** ** Comments: ** ** $Id: mobileip.h,v 1.1 2001/01/20 00:30:31 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef MOBILEIP_H #define MOBILEIP_H #include "global.h" #include "local.h" void dump_mobileip(packet_t *); #endif ipgrab-0.9.10/src/mppc.c0000644000175000001440000000542607356437655014200 0ustar farooqusers/**************************************************************************** ** File: mppc.c ** ** Author: Mike Borella ** ** Comments: MPPC/MPPE protocol module. ** ** Microsoft's point to point compression and point to point encryption ** use the same formats so they are combined here. Basically this code ** is never executed unless the user runs ipgrab with the "-C mppc" option. ** There is no way to know that a compressed frame is MPPC encoded, so ** we need a hint from the user. ** ** $Id: mppc.c,v 1.1 2001/10/02 22:29:01 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "mppc.h" extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** dump_mppc() ** ** Parse and display MPPC and MPPE packets. Basically we can only decode ** two bytes. The first nibble contains the A, B, C, and D bits, and the ** second third and fourth nibbles contain the coherency count. ** **---------------------------------------------------------------------------- */ void dump_mppc(packet_t *pkt) { u_int16_t bytes; u_int8_t a_bit; u_int8_t b_bit; u_int8_t c_bit; u_int8_t d_bit; u_int16_t coherency; /* Set the layer */ set_layer(LAYER_DATALINK); /* get the bytes */ if (get_packet_bytes((u_int8_t *) &bytes, pkt, 2) == 0) return; /* conversions */ bytes = ntohs(bytes); a_bit = (bytes & 0x8000) >> 15; b_bit = (bytes & 0x4000) >> 14; c_bit = (bytes & 0x2000) >> 13; d_bit = (bytes & 0x1000) >> 12; coherency = bytes & 0x0fff; /* Figure out what to print */ if (my_args->m) { } else { /* announcement */ display_header_banner("MPPC Header"); display ("A bit (flushed)", &a_bit, 1, DISP_DEC); display ("B bit (reset history)", &b_bit, 1, DISP_DEC); display ("C bit (compressed)", &c_bit, 1, DISP_DEC); display ("D bit (encrypted)", &d_bit, 1, DISP_DEC); display ("Coherency count", (u_int8_t *) &coherency, 2, DISP_DEC); } /* dump the hex buffer */ hexbuffer_flush(); } ipgrab-0.9.10/src/mppc.h0000644000175000001440000000217607356437655014204 0ustar farooqusers/**************************************************************************** ** File: mppc.h ** ** Author: Mike Borella ** ** Comments: Definitions for MPPC and MPPE parsing ** ** $Id: mppc.h,v 1.1 2001/10/02 22:29:01 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef MPPC_H #define MPPC_H #include "global.h" #include "local.h" void dump_mppc(packet_t *); #endif ipgrab-0.9.10/src/netbios_ns.c0000644000175000001440000002765210637735313015375 0ustar farooqusers/**************************************************************************** ** File: netbios_ns.c ** ** Author: Mike Borella ** ** Dump netbios name service data ** ** $Id: netbios_ns.c,v 1.9 2007/06/25 12:53:31 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "global.h" #include "netbios_ns.h" #include "ns_labels.h" #define HOLDER_SIZE 256 extern struct arg_t *my_args; /* * R flag map */ strmap_t netbios_ns_r_map [] = { { NETBIOS_NS_R_QUERY, "query" }, { NETBIOS_NS_R_RESPONSE, "response" }, { 0, "" } }; /* * Opcode map */ strmap_t netbios_ns_opcode_map [] = { { NETBIOS_NS_OPCODE_QUERY, "query" }, { NETBIOS_NS_OPCODE_REGISTRATION, "registration" }, { NETBIOS_NS_OPCODE_RELEASE, "release" }, { NETBIOS_NS_OPCODE_WACK, "WACK" }, { NETBIOS_NS_OPCODE_REFRESH, "refresh" }, { 0, "" } }; /* * Rcode map */ strmap_t netbios_ns_rcode_map [] = { { NETBIOS_NS_RCODE_NOERROR, "no error" }, { 0, "" } }; /* * Query type map */ strmap_t netbios_ns_querytype_map [] = { { NETBIOS_NS_QUERYTYPE_IPADDR, "A - IP address" }, { NETBIOS_NS_QUERYTYPE_NAMESERVER, "NS - name server" }, { NETBIOS_NS_QUERYTYPE_NULL, "NULL" }, { NETBIOS_NS_QUERYTYPE_GENERAL, "NB - general" }, { NETBIOS_NS_QUERYTYPE_NODESTATUS, "NBSTAT - node status" }, { 0, "" } }; /* * Query class map */ strmap_t netbios_ns_queryclass_map [] = { { NETBIOS_NS_QUERYCLASS_IP, "Internet" }, { 0, "" } }; /*---------------------------------------------------------------------------- ** ** translate_netbios_ns_format() ** ** Translate the NETBIOS name format to something that makes sense to humans ** ** We do the reverse of this: ** 0 1 2 3 4 5 6 7 +-+-+-+-+-+-+-+-+ |a b c d|w x y z| ORIGINAL BYTE +-+-+-+-+-+-+-+-+ | | +--------+ +--------+ | | SPLIT THE NIBBLES v v 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ |0 0 0 0 a b c d| |0 0 0 0 w x y z| +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ | | + + ADD 'A' | | 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ |0 1 0 0 0 0 0 1| |0 1 0 0 0 0 0 1| +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ **---------------------------------------------------------------------------- */ void translate_netbios_name(char *s) { char output[32]; int output_ptr = 0; int input_ptr = 0; int input_length = strlen(s); char *ptr; while(input_ptr < input_length) { char high_char, low_char; /* get next two chars */ high_char = s[input_ptr]; input_ptr ++; low_char = s[input_ptr]; input_ptr ++; /* subtract A from each */ high_char = high_char - 'A'; low_char = low_char - 'A'; /* shift the high char left by 4 */ high_char = high_char << 4; /* combine them into the output */ output[output_ptr] = high_char | low_char; output_ptr++; } /* null terminate, eliminate spaces, and copy back to the input string */ output[output_ptr] = '\0'; strcat(output, " "); ptr = strchr(output, ' '); *ptr = '\0'; strcpy(s, output); } /*---------------------------------------------------------------------------- ** ** dump_netbios_ns_questions() ** ** Parse NETBIOS name service questions and display them ** **---------------------------------------------------------------------------- */ void dump_netbios_ns_questions(packet_t *pkt, u_int16_t num) { char holder[HOLDER_SIZE]; u_int16_t query_type, query_class; while(num > 0) { /* * Parse the name */ parse_ns_labels(pkt, holder); /* * The name is stored in wacky NETBIOS format, with each * character spread across 2 bytes. Let's fix that. * */ /* * Parse the query type and class */ if (get_packet_bytes((u_int8_t *) &query_type, pkt, 2) == 0) return; if (get_packet_bytes((u_int8_t *) &query_class, pkt, 2) == 0) return; /* * Conversions */ query_type = ntohs(query_type); query_class = ntohs(query_class); /* * The name may be stored in wacky NETBIOS format, with each * character spread across 2 bytes. Let's fix that. */ if (query_type == NETBIOS_NS_QUERYTYPE_GENERAL) translate_netbios_name(holder); /* * Dump the info */ if (my_args->m) { display_minimal_string(holder); display_minimal_string(" "); } else { display_string("Query", holder); snprintf(holder, HOLDER_SIZE, "%d (%s)", query_type, map2str(netbios_ns_querytype_map, query_type)); display_string(" Type", holder); snprintf(holder, HOLDER_SIZE, "%d (%s)", query_class, map2str(netbios_ns_queryclass_map, query_class)); display_string(" Query class", holder); } num --; } } /*---------------------------------------------------------------------------- ** ** dump_netbios_ns_answers() ** ** Parse NETBIOS NS answers and display them ** **---------------------------------------------------------------------------- */ void dump_netbios_ns_answers(packet_t *pkt, u_int8_t num, char *answer_type) { char holder[HOLDER_SIZE]; u_int16_t query_type, query_class; u_int32_t ttl; u_int16_t rdl; u_int8_t resource_data[64]; u_int16_t nb_flags; while(num > 0) { /* * Parse the name */ parse_ns_labels(pkt, holder); /* * Parse the query type and class */ if (get_packet_bytes((u_int8_t *) &query_type, pkt, 2) == 0) return; if (get_packet_bytes((u_int8_t *) &query_class, pkt, 2) == 0) return; if (get_packet_bytes((u_int8_t *) &ttl, pkt, 4) == 0) return; if (get_packet_bytes((u_int8_t *) &rdl, pkt, 2) == 0) return; /* * Conversions */ query_type = ntohs(query_type); query_class = ntohs(query_class); ttl = ntohl(ttl); rdl = ntohs(rdl); /* * The name may be stored in wacky NETBIOS format, with each * character spread across 2 bytes. Let's fix that. */ if (query_type == NETBIOS_NS_QUERYTYPE_GENERAL) translate_netbios_name(holder); /* * Get the resource data */ switch (query_type) { case NETBIOS_NS_QUERYTYPE_NAMESERVER: parse_ns_labels(pkt, resource_data); break; case NETBIOS_NS_QUERYTYPE_IPADDR: case NETBIOS_NS_QUERYTYPE_GENERAL: default: if (get_packet_bytes((u_int8_t *) &nb_flags, pkt, 2) == 0) return; if (get_packet_bytes((u_int8_t *) &resource_data, pkt, 4) == 0) return; break; } /* * Dump the info */ if (my_args->m) { if (query_type == NETBIOS_NS_QUERYTYPE_GENERAL && query_class == NETBIOS_NS_QUERYCLASS_IP) { display_minimal_ipv4((u_int8_t *) resource_data); display_minimal_string(" "); } } else { display_string(answer_type, holder); snprintf(holder, HOLDER_SIZE, "%d (%s)", query_type, map2str(netbios_ns_querytype_map, query_type)); display_string(" Query type", holder); snprintf(holder, HOLDER_SIZE, "%d (%s)", query_class, map2str(netbios_ns_queryclass_map, query_class)); display_string(" Query class", holder); display(" TTL", (u_int8_t *) &ttl, 4, DISP_DEC); display(" Resource data length", (u_int8_t *) &rdl, 2, DISP_DEC); switch(query_type) { case NETBIOS_NS_QUERYTYPE_IPADDR: case NETBIOS_NS_QUERYTYPE_GENERAL: display(" NB flags", (u_int8_t *) &nb_flags, 2, DISP_HEX); display_ipv4(" Resource data", (u_int8_t *) resource_data); break; case NETBIOS_NS_QUERYTYPE_NAMESERVER: display_string(" Resource data", resource_data); break; default: display(" Resource data", (u_int8_t *) resource_data, rdl, DISP_HEX); } } num --; } } /*---------------------------------------------------------------------------- ** ** dump_netbios_ns() ** ** Parse netbios name service header and dump fields ** **---------------------------------------------------------------------------- */ void dump_netbios_ns(packet_t *pkt) { netbios_ns_t nb_ns; u_int8_t holder[64]; u_int8_t r, opcode, flags, rcode; u_int8_t flag_aa, flag_tc, flag_rd, flag_ra, flag_zeros, flag_b; /* Set the layer */ set_layer(LAYER_APPLICATION); /* * Mark the beginning of the NS portion so that labels can be stored * properly */ set_packet_mark(pkt); /* * Reset the NS label module */ reset_nslabels(); /* * Read the header */ if (get_packet_bytes((u_int8_t *) &nb_ns, pkt, sizeof(netbios_ns_t)) == 0) return; /* * Conversions */ nb_ns.transaction_id = ntohs(nb_ns.transaction_id); r = nb_ns.r; opcode = nb_ns.opcode; flags = (nb_ns.flags_high << 4) || nb_ns.flags_low; flag_aa = (flags & 0x40) >> 6; flag_tc = (flags & 0x20) >> 5; flag_rd = (flags & 0x10) >> 4; flag_ra = (flags & 0x08) >> 3; flag_zeros = (flags & 0x06) >> 1; flag_b = (flags & 0x01); rcode = nb_ns.rcode; nb_ns.questions = ntohs(nb_ns.questions); nb_ns.answers = ntohs(nb_ns.answers); nb_ns.auth_answers = ntohs(nb_ns.auth_answers); nb_ns.add_answers = ntohs(nb_ns.add_answers); /* * Dump header */ if (my_args->m) { display_minimal_string("| NETBIOS NS "); display_minimal_string(map2str(netbios_ns_r_map, r)); display_minimal_string(" "); } else { /* announcement */ display_header_banner("NETBIOS Name Service"); /* fields */ display("Transaction ID", (u_int8_t *) &nb_ns.transaction_id, 2, DISP_DEC); snprintf(holder, HOLDER_SIZE, "%d (%s)", r, map2str(netbios_ns_r_map, r)); display_string("R", holder); snprintf(holder, HOLDER_SIZE, "%d (%s)", opcode, map2str(netbios_ns_opcode_map, opcode)); display_string("Opcode", holder); snprintf(holder, HOLDER_SIZE, "%d (%s)", rcode, map2str(netbios_ns_rcode_map, rcode)); display_string("Rcode", holder); /* number of questions and answers */ display("Questions", (u_int8_t *) &nb_ns.questions, 2, DISP_DEC); display("Answers", (u_int8_t *) &nb_ns.answers, 2, DISP_DEC); display("Auth answers", (u_int8_t *) &nb_ns.auth_answers, 2, DISP_DEC); display("Add answers", (u_int8_t *) &nb_ns.add_answers, 2, DISP_DEC); } /* * Parse the question and answers */ dump_netbios_ns_questions(pkt, nb_ns.questions); dump_netbios_ns_answers(pkt, nb_ns.answers, "Answers"); dump_netbios_ns_answers(pkt, nb_ns.auth_answers, "Auth answers"); dump_netbios_ns_answers(pkt, nb_ns.add_answers, "Addtl answers"); /* dump the hex buffer */ hexbuffer_flush(); } ipgrab-0.9.10/src/netbios_ns.h0000644000175000001440000000570707153266450015377 0ustar farooqusers/**************************************************************************** ** File: netbios_ns.h ** ** Author: Mike Borella ** ** Definitions for NETBIOS name service routines ** ** $Id: netbios_ns.h,v 1.5 2000/08/30 20:23:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef NETBIOS_NS_H #define NETBIOS_NS_H #include "global.h" #include "local.h" /* * R flag values */ #define NETBIOS_NS_R_QUERY 0 #define NETBIOS_NS_R_RESPONSE 1 /* * Opcode values */ #define NETBIOS_NS_OPCODE_QUERY 0 #define NETBIOS_NS_OPCODE_REGISTRATION 5 #define NETBIOS_NS_OPCODE_RELEASE 6 #define NETBIOS_NS_OPCODE_WACK 7 #define NETBIOS_NS_OPCODE_REFRESH 8 /* * Rcode values */ #define NETBIOS_NS_RCODE_NOERROR 0 /* * Query types */ #define NETBIOS_NS_QUERYTYPE_IPADDR 0x0001 #define NETBIOS_NS_QUERYTYPE_NAMESERVER 0x0002 #define NETBIOS_NS_QUERYTYPE_NULL 0x000A #define NETBIOS_NS_QUERYTYPE_GENERAL 0x0020 #define NETBIOS_NS_QUERYTYPE_NODESTATUS 0x0021 /* * Query classes */ #define NETBIOS_NS_QUERYCLASS_IP 1 /* * Format of netbios name service common header * * 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | NAME_TRN_ID | OPCODE | NM_FLAGS | RCODE | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | QDCOUNT | ANCOUNT | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | NSCOUNT | ARCOUNT | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ typedef struct netbios_ns { u_int16_t transaction_id; #if defined(WORDS_BIGENDIAN) u_int8_t r:1, opcode:4, flags_high:3; u_int8_t flags_low:4, rcode:4; #else u_int8_t flags_high:3, opcode:4, r:1; u_int8_t rcode:4, flags_low:4; #endif u_int16_t questions; u_int16_t answers; u_int16_t auth_answers; u_int16_t add_answers; } netbios_ns_t; void dump_netbios_ns(packet_t *); #endif ipgrab-0.9.10/src/nntp.c0000644000175000001440000000524607374605314014205 0ustar farooqusers/**************************************************************************** ** File: nntp.c ** ** Author: Mike Borella ** ** Comments: NNTP protocol module. ** ** Since NNTP is both stateful and ASCII, there isn't much "parsing" to ** do. Instead we grab each string and try to display as much as makes ** sense. This is NNTP_MINMODE_LEN characters for minimal mode, but the ** whole thing for verbose mode. ** ** $Id: nntp.c,v 1.1 2001/11/15 00:22:36 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "nntp.h" #define NNTP_MINMODE_LEN 50 /* The length of printed strings in minimal mode */ extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** dump_nntp() ** ** Parse and display NNTP packets ** **---------------------------------------------------------------------------- */ void dump_nntp(packet_t *pkt) { u_int8_t * payload; u_int32_t size; int i; /* Set the layer */ set_layer(LAYER_APPLICATION); /* find the paylaod size, then allocate memory and read the packet */ size = get_packet_apparentbytesleft(pkt); if (size <= 0) return; payload = (u_int8_t *) my_malloc (size+1); payload[size] = '\0'; if (get_packet_bytes(payload, pkt, size) == 0) { my_free(payload); return; } /* Get rid of those pesky \r's, \t's and \n's, replace them with spaces */ for (i=0; im) { display_minimal_string("| NNTP "); if (size > NNTP_MINMODE_LEN) payload[NNTP_MINMODE_LEN] ='\0'; display_minimal_string(payload); } else { display_header_banner("NNTP"); display("Data", payload, size, DISP_STRING_MULTILINE); } /* free memory, of course */ my_free(payload); /* dump the hex buffer */ hexbuffer_flush(); } ipgrab-0.9.10/src/nntp.h0000644000175000001440000000216507374605314014207 0ustar farooqusers/**************************************************************************** ** File: nntp.h ** ** Author: Mike Borella ** ** Comments: Definitions for NNTP parsing ** ** $Id: nntp.h,v 1.1 2001/11/15 00:22:36 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef NNTP_H #define NNTP_H #include "global.h" #include "local.h" void dump_nntp(packet_t *); #endif ipgrab-0.9.10/src/ns_labels.c0000644000175000001440000001316507153031046015155 0ustar farooqusers/**************************************************************************** ** File: ns_labels.c ** ** Author: Mike Borella ** ** Comments: Encapsulation for ugly NS label manipulation ** ** $Id: ns_labels.c,v 1.3 2000/08/29 21:59:02 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "ns_labels.h" #define NUM_LABELS 128 int current_label = -1; ns_label_t nslabels[NUM_LABELS]; /*---------------------------------------------------------------------------- ** ** reset_nslabels() ** ** Initialize the NS labels structures ** **---------------------------------------------------------------------------- */ void reset_nslabels(void) { int i; current_label = -1; for (i=0; i= 0) { strcat(s, "."); get_nslabel(nslabels[nslabels[i].next].offset, s+strlen(s)); } strcat(s, "\0"); break; } } /*---------------------------------------------------------------------------- ** ** parse_ns_labels() ** ** Recursively parse a label entry in a DNS packet. We assume that the ** current byte of the packet points to the first label count. Store ** the DNS name in the string passed in, and let's assume that this string ** is big enough. ** **---------------------------------------------------------------------------- */ void parse_ns_labels(packet_t *pkt, char *name) { u_int8_t count; u_int16_t offset; int read_a_label = 0; char label[MAX_LABEL_SIZE]; int first_offset = 0; while(1) { if (get_packet_bytes((u_int8_t *) &count, pkt, 1) == 0) return; /* * A count of 0 indicates an "end of string", so quit */ if (count == 0) break; /* * Make sure that we don't run past the ned of label space in * our structure - this should NOT be an issue, but if for some * reason it is, it will cause *nasty* bugs... */ if (count > MAX_LABEL_SIZE && count < 192) count = MAX_LABEL_SIZE; /* * This is a new label, so let's mark it as such */ if (read_a_label) set_nslabel_next(); new_nslabel(); if (!first_offset) { first_offset = get_packet_markdistance(pkt)-1; } set_nslabel_offset(get_packet_markdistance(pkt)-1); /* * A count > 192 indicates a pointer. What an ugly way of * saving a few bytes */ if (count >= 192) { /* * There's a pointer in this label. Sigh. Let's grab the * 14 low-order bits and run with them... */ offset = count - 192; offset = offset << 8; if (get_packet_bytes((u_int8_t *) &count, pkt, 1) == 0) return; offset = offset + count; get_nslabel(offset, name); set_nslabel_label(name); return; } /* * This is normal behavior, if anything is "normal" for DNS. * Grab count bytes and stick them in the label string, follow it * up with a "." to separate the hierarchy */ if (get_packet_bytes((u_int8_t *) &label, pkt, count ) == 0) return; label[count] = '\0'; set_nslabel_label(label); read_a_label = 1; } get_nslabel(first_offset, name); return; } ipgrab-0.9.10/src/ns_labels.h0000644000175000001440000000363510530527426015170 0ustar farooqusers/**************************************************************************** ** File: ns_labels.h ** ** Author: Mike Borella ** ** Comments: Encapsulation for ugly DNS / NETBIOS NS label manipulation ** ** $Id: ns_labels.h,v 1.6 2006/11/21 07:47:34 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef NS_LABELS_H #define NS_LABELS_H #include "global.h" #include "local.h" /* * This is for parsing DNS and NETBIOS NS labels. We save all labels so * that we can refer to them without re-reading the packet. * This is SO annoying! Goes to show the damage that can be done when * bandwidth is a major concern. */ #define MAX_LABEL_SIZE 64 typedef struct ns_label { int32_t offset; /* offset from beginning of DNS payload */ char label[MAX_LABEL_SIZE]; /* char string contents of label */ int next; /* next label */ } ns_label_t; void reset_nslabels(void); void new_nslabel(void); void set_nslabel_offset(int32_t); void set_nslabel_label(char *); void set_nslabel_next(void); void get_nslabel(int32_t, char *); /* get a label given its offset */ void parse_ns_labels(packet_t *, char *); #endif ipgrab-0.9.10/src/open_pcap.c0000644000175000001440000000654307257672660015203 0ustar farooqusers/**************************************************************************** ** ** File: open_pcap.c ** ** Author: Mike Borella ** ** Set up pcap to sniff the packets we want. Most of these commands are ** listed in the pcap(3) man page. ** ** $Id: open_pcap.c,v 1.4 2001/03/26 17:00:32 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "open_pcap.h" #include "error.h" #include "parse_cl.h" #define SNAPLEN 1514 #define PROMISC 1 #define READ_TIMEOUT 500 extern struct arg_t *my_args; /*---------------------------------------------------------------------------- * * pcap_open() * *---------------------------------------------------------------------------- */ int open_pcap(void) { extern char * pcap_cmd; extern pcap_t * pd; bpf_u_int32 localnet; bpf_u_int32 netmask; struct bpf_program fcode; char errorbuf[PCAP_ERRBUF_SIZE]; int datalink; /* * If -r and a filename are given, then take input from the file rather * than from the network connection. Otherwise, Look up the device and * get a handle to it */ if (my_args->r != NULL) { fprintf(stderr, "Reading from file %s\n", my_args->r); pd = pcap_open_offline(my_args->r, errorbuf); if (pd == NULL) error_fatal("%s", errorbuf); localnet = 0; netmask = 0; } else { if (my_args->i == NULL) { my_args->i = pcap_lookupdev(errorbuf); if (my_args->i == NULL) error_fatal("open_pcap: pcap_lookupdev() failed for %s: %s", my_args->i, errorbuf); } /* * Get a file descriptor to the device */ pd = pcap_open_live(my_args->i, SNAPLEN, PROMISC, READ_TIMEOUT, errorbuf); if (pd == NULL) error_fatal("open_pcap: pcap_open_live() failed for %s: %s", my_args->i, errorbuf); /* * Determine local net and netmask */ if (pcap_lookupnet(my_args->i, &localnet, &netmask, errorbuf) < 0) error_fatal("open_pcap: pcap_lookupnet() failed for %s: %s", my_args->i, errorbuf); } /* * Compile command line filter spec info fcode FSM */ if (pcap_compile(pd, &fcode, pcap_cmd, 0, netmask) < 0) error_fatal("pcap_compile: %s", pcap_geterr(pd)); /* * Set the pcap filter with our fcode FSM. That should do it... */ if (pcap_setfilter(pd, &fcode) < 0) error_fatal("pcap_setfilter: %s", pcap_geterr(pd)); /* * Get the data link type */ datalink = pcap_datalink(pd); if (datalink < 0) error_fatal("pcap_datalink: %s", pcap_geterr(pd)); return datalink; } ipgrab-0.9.10/src/open_pcap.h0000644000175000001440000000227707153031046015166 0ustar farooqusers/**************************************************************************** ** ** File: open_pcap.h ** ** Author: Mike Borella ** ** Comments: Set up pcap to sniff the packets we want. Most of these ** commands are listed in the pcap(3) man page. ** ** $Id: open_pcap.h,v 1.2 2000/08/29 21:59:02 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef OPEN_PCAP_H #define OPEN_PCAP_H #include "global.h" int open_pcap(void); #endif ipgrab-0.9.10/src/ospf.c0000644000175000001440000001306307414717761014176 0ustar farooqusers/**************************************************************************** ** File: ospf.c ** ** Author: Mike Borella ** ** Comments: Dump OSPF information ** ** $Id: ospf.c,v 1.14 2002/01/03 00:04:01 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "global.h" #include "ospf.h" #define HOLDER_SIZE 64 /* * OSPF type map */ strmap_t ospf_type_map [] = { { OSPF_TYPE_HELLO, "hello" }, { OSPF_TYPE_DATABASEDESC, "database description" }, { OSPF_TYPE_LSREQUEST, "link state request" }, { OSPF_TYPE_LSUPDATE, "link state update" }, { OSPF_TYPE_LSACK, "link state acknowledgement" }, { 0, "" } }; /* * OSPF auth type map */ strmap_t ospf_auth_map [] = { { OSPF_AUTH_NONE, "none" }, { OSPF_AUTH_SIMPLE, "simple" }, { OSPF_AUTH_CRYPTO, "cryptographic" }, { 0, "" } }; extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** dump_ospf_hello() ** ** Parse OSPF hello header and dump fields ** **---------------------------------------------------------------------------- */ void dump_ospf_hello(packet_t *pkt, u_int16_t length) { ospf_hello_header_t ospf_hello; u_int8_t neighbor[4]; /* * Get the header */ if (get_packet_bytes((u_int8_t *) &ospf_hello, pkt, sizeof(ospf_hello_header_t)) == 0) return; /* * Conversions */ ospf_hello.interval = ntohs(ospf_hello.interval); ospf_hello.dead_interval = ntohl(ospf_hello.dead_interval); /* * Dump the fields */ if (my_args->m) { display_minimal_ipv4((u_int8_t *) &ospf_hello.designated_router); display_minimal_string(" "); } else { display_ipv4("Netmask", (u_int8_t *) &ospf_hello.netmask); display("Interval", (u_int8_t *) &ospf_hello.interval, 2, DISP_DEC); display("Options", (u_int8_t *) &ospf_hello.options, 1, DISP_HEX); display("Router priority", (u_int8_t *) &ospf_hello.router_priority, 1, DISP_DEC); display("Dead interval", (u_int8_t *) &ospf_hello.dead_interval, 4, DISP_DEC); display_ipv4("Designated router", (u_int8_t *) &ospf_hello.designated_router); display_ipv4("Backup router", (u_int8_t *) &ospf_hello.backup_router); } /* * Dump the neighbors, which should just be a bunch of IP addresses * lasting the rest of the packet. */ while (get_packet_apparentbytesleft(pkt)) { if (get_packet_bytes((u_int8_t *) &neighbor, pkt, 4) == 0) return; if (my_args->m) { display_minimal_ipv4((u_int8_t *) &neighbor); display_minimal_string(" "); } else display_ipv4("Neighbor", (u_int8_t *) &neighbor); } } /*---------------------------------------------------------------------------- ** ** dump_ospf() ** ** Parse OSPF common header and dump fields ** **---------------------------------------------------------------------------- */ void dump_ospf(packet_t *pkt) { ospf_common_header_t ospf; char holder[HOLDER_SIZE]; /* Set the layer */ set_layer(LAYER_APPLICATION); /* * Stats accounting */ stats_update(STATS_OSPF); /* * Get the header */ if (get_packet_bytes((u_int8_t *) &ospf, pkt, sizeof(ospf_common_header_t)) == 0) return; /* * Conversions */ ospf.length = ntohs(ospf.length); ospf.checksum = ntohs(ospf.checksum); ospf.auth_type = ntohs(ospf.auth_type); /* * Dump the fields */ if (my_args->m) { /* In minimal mode lets just dump the type and the router ID */ display_minimal_string("| OSPF "); display_minimal_string(map2str(ospf_type_map, ospf.type)); display_minimal_string(" "); display_minimal_ipv4((u_int8_t *) &ospf.router_id); display_minimal_string(" "); } else { /* announcement */ display_header_banner("OSPF Header"); display("Version", (u_int8_t *) &ospf.version, 1, DISP_DEC); snprintf(holder, HOLDER_SIZE, "%d (%s)", ospf.type, map2str(ospf_type_map, ospf.type)); display_string("Type", holder); display("Length", (u_int8_t *) &ospf.length, 2, DISP_DEC); display_ipv4("Router ID", (u_int8_t *) &ospf.router_id); display_ipv4("Area ID", (u_int8_t *) &ospf.area_id); display("Checksum", (u_int8_t *) &ospf.checksum, 2, DISP_DEC); snprintf(holder, HOLDER_SIZE, "%d (%s)", ospf.auth_type, map2str(ospf_auth_map, ospf.auth_type)); display_string("Authentication", holder); display("Authentication data", (u_int8_t *) &ospf.auth_data, 8, DISP_HEX); } /* * Dump the more specific header type XXX NOT COMPLETE! */ switch(ospf.type) { case OSPF_TYPE_HELLO: dump_ospf_hello(pkt, ospf.length); break; default: break; } /* Dump the hex buffer */ hexbuffer_flush(); } ipgrab-0.9.10/src/ospf.h0000644000175000001440000000374007153266450014176 0ustar farooqusers/**************************************************************************** ** File: ospf.h ** ** Author: Mike Borella ** ** Comments: OSPF common header format ** ** $Id: ospf.h,v 1.5 2000/08/30 20:23:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef OSPF_H #define OSPF_H #include "global.h" #include "local.h" /* * Format of OSPF common header */ typedef struct ospf_common_header { u_int8_t version; u_int8_t type; u_int16_t length; u_int32_t router_id; u_int32_t area_id; u_int16_t checksum; u_int16_t auth_type; u_int8_t auth_data[8]; } ospf_common_header_t; /* * Format of OSPF hello header */ typedef struct ospf_hello_header { u_int32_t netmask; u_int16_t interval; u_int8_t options; u_int8_t router_priority; u_int32_t dead_interval; u_int32_t designated_router; u_int32_t backup_router; } ospf_hello_header_t; /* * OSPF types */ #define OSPF_TYPE_HELLO 1 #define OSPF_TYPE_DATABASEDESC 2 #define OSPF_TYPE_LSREQUEST 3 #define OSPF_TYPE_LSUPDATE 4 #define OSPF_TYPE_LSACK 5 /* * OSPF Authentication types */ #define OSPF_AUTH_NONE 0 #define OSPF_AUTH_SIMPLE 1 #define OSPF_AUTH_CRYPTO 2 void dump_ospf(packet_t *); #endif ipgrab-0.9.10/src/packet_manip.c0000644000175000001440000002547007360703112015650 0ustar farooqusers/**************************************************************************** ** File: packet_manip.c ** ** Author: Mike Borella ** ** Comments: Packet manipulation routines ** ** $Id: packet_manip.c,v 1.16 2001/10/09 23:20:42 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "packet_manip.h" #include "hexbuffer.h" extern struct arg_t *my_args; /*---------------------------------------------------------------------------- ** ** get_packet_bytesgeneral() ** ** Non API function, this is a generalization of get_packet_bytes() and ** get_packet_bytestoend(). ** ** Mode 0 is get_packet_bytes() ** Mode 1 is get_packet_bytestoend() ** ** NOTE: This is NOT a safe function. The caller MUST allocate enough memory ** in the destination array. ** ** Returns 0 if operation fails and no write occurs. Returns 1 otherwise. **---------------------------------------------------------------------------- */ inline int get_packet_bytesgeneral(u_int8_t *dst, packet_t *p, unsigned int n, int mode) { /* * First make sure that we can read the bytes without running off the end * of the packet. */ switch(mode) { case 0: if (p->current + n > p->apparent_end + 1) return 0; break; case 1: if (p->current + n > p->end + 1) return 0; break; default: error_message("unknown mode for get_packet_bytesgeneral()"); return 0; } /* * Do the copy */ memcpy(dst, p->current, n); hexbuffer_add(p->current, n); /* * Increment the current pointer */ p->current += n; /* * Return successfully */ return 1; } /*---------------------------------------------------------------------------- ** ** get_packet_bytes() ** ** Grab a specified number of bytes from a packet and deposit them in an array. ** ** NOTE: This is NOT a safe function. The caller MUST allocate enough memory ** in the destination array. ** ** Returns 0 if operation fails and no write occurs. Returns 1 otherwise. **---------------------------------------------------------------------------- */ inline int get_packet_bytes(u_int8_t *dst, packet_t *p, unsigned int n) { return get_packet_bytesgeneral(dst, p, n, 0); } /*---------------------------------------------------------------------------- ** ** get_packet_bytestoend() ** ** Grab a specified number of bytes from a packet and deposit them in an array. ** Get bytes all the way to the real end of the packet, not the apparent end. ** ** NOTE: This is NOT a safe function. The caller MUST allocate enough memory ** in the destination array. ** ** Returns 0 if operation fails and no write occurs. Returns 1 otherwise. **---------------------------------------------------------------------------- */ inline int get_packet_bytestoend(u_int8_t *dst, packet_t *p, unsigned int n) { return get_packet_bytesgeneral(dst, p, n, 1); } /*---------------------------------------------------------------------------- ** ** get_packet_line() ** ** Get a \n terminated line of text from the packet. ** ** NOTE: This is NOT a safe function. The caller MUST allocate enough memory ** in the destination array. ** ** Returns 0 if operation fails and no write occurs. ** Returns number of bytes read otherwise. **---------------------------------------------------------------------------- */ inline int get_packet_line(u_int8_t *dst, u_int32_t max, packet_t *p) { u_int8_t * ptr; int ret; /* * Find the next \n */ ptr = p->current; while (ptr < p->apparent_end && (ptr - p->current) < max - 1) { if (*ptr == '\n') break; ptr++; } /* * If we reached the end, then there's no line to read, fail. */ if (ptr >= p->apparent_end) return 0; /* * Do the copy (NOTE, we do not copy the \n) * We add a \0 in the appropriate place. */ memcpy(dst, p->current, ptr - p->current); dst[ptr - p->current] = '\0'; hexbuffer_add(p->current, ptr - p->current); /* * Increment the current pointer past the \n */ ret = ptr - p->current; p->current += ret + 1; /* * Return successfully the length of the text, not including the \n */ return ret; } /*---------------------------------------------------------------------------- ** ** get_packet_string() ** ** Get a \0 terminated string of text from the packet. ** ** NOTE: This is NOT a safe function. The caller MUST allocate enough memory ** in the destination array. ** ** Returns 0 if operation fails and no write occurs. ** Returns number of bytes read otherwise. **---------------------------------------------------------------------------- */ inline int get_packet_string(u_int8_t *dst, u_int32_t max, packet_t *p) { u_int8_t * ptr; int ret; /* * Find the next \0 */ ptr = p->current; while (ptr < p->apparent_end && (ptr - p->current) < max - 1) { if (*ptr == '\0') break; ptr++; } /* * If we reached the end, then there's no line to read, fail. */ if (ptr >= p->apparent_end) return 0; /* * Do the copy (NOTE, we do not copy the \0) * We add a \0 in the appropriate place. */ memcpy(dst, p->current, ptr - p->current); dst[ptr - p->current] = '\0'; hexbuffer_add(p->current, ptr - p->current); /* * Increment the current pointer past the \0 */ ret = ptr - p->current; p->current += ret + 1; /* * Return successfully the length of the text */ return ret; } /*---------------------------------------------------------------------------- ** ** look_packet_bytes() ** ** Copy specified number of bytes from a packet and deposit them in an array. ** Unlike get_packet_bytes(), we will not increment the pointer. ** ** NOTE: This is NOT a safe function. The caller MUST allocate enough memory ** in the destination array. ** ** Returns 0 if operation fails and no write occurs. Returns 1 otherwise. **---------------------------------------------------------------------------- */ inline int look_packet_bytes(u_int8_t *dst, packet_t *p, unsigned int n) { /* * First make sure that we can read the bytes without running off the end * of the packet. */ if (p->current + n > p->apparent_end + 1) return 0; /* * Do the copy */ memcpy(dst, p->current, n); /* * Return successfully */ return 1; } /*---------------------------------------------------------------------------- ** ** skip_packet_bytes() ** ** Jump the pointer ahead the specified number of bytes ** ** Returns 0 if operation fails and no write occurs. Returns 1 otherwise. **---------------------------------------------------------------------------- */ inline int skip_packet_bytes(packet_t *p, unsigned int n) { /* * First make sure that we can read the bytes without running off the end * of the packet. */ if (p->current + n > p->apparent_end + 1) return 0; /* * Increment the current pointer */ p->current += n; hexbuffer_add(p->current, n); /* * Return successfully */ return 1; } /*---------------------------------------------------------------------------- ** ** skip_packet_toapparentend() ** ** Jump the pointer ahead the apparent end of the packet. Useful for ** jumping a padding section, if one exists. ** ** Returns 0 if operation fails and no write occurs. Returns 1 otherwise. **---------------------------------------------------------------------------- */ inline int skip_packet_toapparentend(packet_t *p) { if (p->current > p->apparent_end) return 0; /* * Set the current pointer */ p->current = p->apparent_end; /* * Return successfully */ return 1; } /*---------------------------------------------------------------------------- ** ** get_packet_apparentbytesleft() ** ** Returns the # of apparent bytes left to read off of the packet. ** **---------------------------------------------------------------------------- */ inline u_int32_t get_packet_apparentbytesleft(packet_t *pkt) { u_int32_t len; len = pkt->apparent_end - pkt->current; if (len < 0) return 0; else return len; } /*---------------------------------------------------------------------------- ** ** get_packet_bytesleft() ** ** Returns the # of bytes left to read off of the packet. ** **---------------------------------------------------------------------------- */ inline u_int32_t get_packet_bytesleft(packet_t *pkt) { u_int32_t len; len = pkt->end - pkt->current; if (len < 0) return 0; else return len; } /*---------------------------------------------------------------------------- ** ** packet_haspadding() ** ** Returns 1 if there are bytes between the apparent end and the real end, ** 0 otherwise ** **---------------------------------------------------------------------------- */ inline int packet_haspadding(packet_t *pkt) { u_int32_t len; len = pkt->end - pkt->apparent_end; if (len <= 0) return 0; else return 1; } /*---------------------------------------------------------------------------- ** ** set_packet_mark() ** ** Mark the current byte of the packet ** **---------------------------------------------------------------------------- */ inline void set_packet_mark(packet_t *pkt) { pkt->mark = pkt->current; } /*---------------------------------------------------------------------------- ** ** get_packet_markdistance() ** ** Get the distance between the current pointer and the mark ** **---------------------------------------------------------------------------- */ inline int32_t get_packet_markdistance(packet_t *pkt) { /* * Sanity check the mark first */ if (pkt->mark < pkt->contents || pkt->mark > pkt->apparent_end) return -1; return pkt->current - pkt->mark; } /*---------------------------------------------------------------------------- ** ** set_packet_apparentend() ** ** Set the apparent end of the packet to be the given number of bytes beyond ** the current pointer. ** **---------------------------------------------------------------------------- */ inline void set_packet_apparentend(packet_t * pkt, int n) { /* make sure we're not running off the packet */ if (pkt->current + n >= pkt->apparent_end) return; pkt->apparent_end = pkt->current + n; } ipgrab-0.9.10/src/packet_manip.h0000644000175000001440000000651407360703112015653 0ustar farooqusers/**************************************************************************** ** File: packet_manip.h ** ** Author: Mike Borella ** ** Comments: Header file for packet structures and manipulation functions ** ** The structure used here gives us pointers to several important areas ** in a packet. ** ** contents: points to the first byte of the packet. ** current: points to the next unconsumed byte. ** end: points to the real end of the packet. ** apparent_end: points to where IP (or another protocol) thinks the ** packet should end (this value is not accurate until IP ** IP or some other protocol processes the packet). ** mark: points to a user defined mark (only used for DNS right now... ** ** +++++++++++++++++++++++++++++++++++++++++++++++ ** ^ ^ ^ ^ ** | | | | ** contents current apparent_end end ** ** Note that the difference between the end and the apparent_end is due ** to padding, typically done by a link layer device. In most cases, there ** is no padding and apparent_end == end. ** ** $Id: packet_manip.h,v 1.11 2001/10/09 23:20:42 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef PACKET_MANIP_H #define PACKET_MANIP_H #include "global.h" #define PACKET_TIMESTAMP_LEN 32 /* * Data structure that contains the bytestring of a packet and pointers * to the next byte to read as well as the end. */ typedef struct packet { u_int8_t * contents; u_int8_t * current; u_int8_t * end; u_int8_t * apparent_end; /* where a protocol such as IP thinks the end is */ u_int8_t * mark; u_int32_t media_length; /* length of the packet as reported by the media */ char timestamp [PACKET_TIMESTAMP_LEN]; } packet_t; inline int look_packet_bytes(u_int8_t *, packet_t *, unsigned int); inline int get_packet_bytes(u_int8_t *, packet_t *, unsigned int); inline int get_packet_bytestoend(u_int8_t *, packet_t *, unsigned int); inline int get_packet_line(u_int8_t *, u_int32_t, packet_t *); inline int get_packet_string(u_int8_t *, u_int32_t, packet_t *); inline int skip_packet_bytes(packet_t *, unsigned int); inline int skip_packet_toapparentend(packet_t *); inline u_int32_t get_packet_bytesleft(packet_t *); inline u_int32_t get_packet_apparentbytesleft(packet_t *); inline void set_packet_mark(packet_t *); inline int32_t get_packet_markdistance(packet_t *); inline void set_packet_apparentend(packet_t *, int); inline int packet_haspadding(packet_t *); #endif ipgrab-0.9.10/src/padding.c0000644000175000001440000000352107346247467014640 0ustar farooqusers/**************************************************************************** ** File: padding.c ** ** Author: Mike Borella ** ** Comments: Dump packet padding ** ** $Id: padding.c,v 1.2 2001/09/07 22:50:31 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "global.h" #include "padding.h" #define PADDING_SIZE 1500 /*---------------------------------------------------------------------------- ** ** dump_padding() ** ** Dump printable portions of packet padding ** **---------------------------------------------------------------------------- */ void dump_padding(packet_t *pkt) { char holder[PADDING_SIZE]; int bytes; /* Set the layer */ set_layer(LAYER_APPLICATION); /* display announcement */ display_header_banner("Padding"); /* The rest of the packet is padding, so lets grab the whole thing */ skip_packet_toapparentend(pkt); bytes = get_packet_bytesleft(pkt); if (bytes <= 0) return; if (get_packet_bytestoend(holder, pkt, bytes) == 0) return; /* * Display the hex and text */ dump_hex_and_text(holder, bytes); return; } ipgrab-0.9.10/src/padding.h0000644000175000001440000000217607346243541014637 0ustar farooqusers/**************************************************************************** ** File: padding.h ** ** Author: Mike Borella ** ** Comments: Dump packet padding ** ** $Id: padding.h,v 1.1 2001/09/07 22:17:05 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef PADDING_H #define PADDING_H #include "global.h" #include "local.h" void dump_padding(packet_t *pkt); #endif ipgrab-0.9.10/src/parse_cl.c0000644000175000001440000001577010637711747015025 0ustar farooqusers/****************************************************************************** ** ** parse_cl.c ** ** Sun Oct 7 12:44:00 2001 ** Linux 2.4.2 (#5 Thu Apr 26 12:29:16 CDT 2001) i686 ** mborella@stratos.mw.3com.com (Mike Borella) ** ** C file for command line parser ** ** Automatically created by genparse v0.5.2 ** ** See http://genparse.sourceforge.net/ for details and updates ** ******************************************************************************/ #include #include #include #include #include #include "parse_cl.h" /*---------------------------------------------------------------------------- ** ** usage() ** ** Print out usage information, then exit ** **--------------------------------------------------------------------------*/ void usage(char *executable) { printf("usage: %s [ -abcCdilmnPprTtwxhv ] \n", executable); printf(" [ -a ] "); printf("("); printf("type="); printf("FLAG"); printf(")\n"); printf(" Don't print application layer data\n"); printf(" [ -b ] "); printf("("); printf("type="); printf("FLAG"); printf(")\n"); printf(" Make stdout buffered\n"); printf(" [ -c ] "); printf("[ --count ] "); printf("("); printf("type="); printf("INTEGER,"); printf(" range=1...,"); printf(")\n"); printf(" Exit after receiving 'count' packets\n"); printf(" [ -C ] "); printf("[ --CCP ] "); printf("("); printf("type="); printf("STRING"); printf(")\n"); printf(" CCP compression algorithm\n"); printf(" [ -d ] "); printf("("); printf("type="); printf("FLAG"); printf(")\n"); printf(" Dump padding if any exists\n"); printf(" [ -i ] "); printf("[ --interface ] "); printf("("); printf("type="); printf("STRING"); printf(")\n"); printf(" Listen on interface 'interface'\n"); printf(" [ -l ] "); printf("("); printf("type="); printf("FLAG"); printf(")\n"); printf(" Don't print link-layer headers\n"); printf(" [ -m ] "); printf("("); printf("type="); printf("FLAG"); printf(")\n"); printf(" Minimal output\n"); printf(" [ -n ] "); printf("("); printf("type="); printf("FLAG"); printf(")\n"); printf(" Don't print network-layer headers\n"); printf(" [ -P ] "); printf("("); printf("type="); printf("STRING"); printf(")\n"); printf(" Dynamic port mapping (usage: 'protocol=port')\n"); printf(" [ -p ] "); printf("("); printf("type="); printf("FLAG"); printf(")\n"); printf(" Display unknown application payloads in hex\n"); printf(" [ -r ] "); printf("("); printf("type="); printf("STRING"); printf(")\n"); printf(" Read from file rather than interface\n"); printf(" [ -T ] "); printf("("); printf("type="); printf("FLAG"); printf(")\n"); printf(" Don't print timestamps in minimal mode\n"); printf(" [ -t ] "); printf("("); printf("type="); printf("FLAG"); printf(")\n"); printf(" Don't print transport-layer headers\n"); printf(" [ -w ] "); printf("("); printf("type="); printf("STRING"); printf(")\n"); printf(" Write the raw packets to a file\n"); printf(" [ -x ] "); printf("("); printf("type="); printf("FLAG"); printf(")\n"); printf(" Display hex dump of each field\n"); printf(" [ -h ] "); printf("[ --help ] "); printf("("); printf("type="); printf("FLAG"); printf(")\n"); printf(" Display help information.\n"); printf(" [ -v ] "); printf("[ --version ] "); printf("("); printf("type="); printf("FLAG"); printf(")\n"); printf(" Output version.\n"); exit(1); } /*---------------------------------------------------------------------------- ** ** free_args() ** ** Call this to free the memory that was dynamically allocated by the parser. ** **--------------------------------------------------------------------------*/ void free_args(struct arg_t *my_args) { my_free(my_args); } /*---------------------------------------------------------------------------- ** ** Cmdline() ** ** Parse the argv array into the command line structure ** **--------------------------------------------------------------------------*/ struct arg_t *Cmdline(int argc, char *argv[]) { extern char *optarg; extern int optind; int option_index = 0; int c; struct arg_t *my_args; int errflg = 0; static struct option long_options[] = { {"", 0, 0, 'a'}, {"", 0, 0, 'b'}, {"count", 1, 0, 'c'}, {"CCP", 1, 0, 'C'}, {"", 0, 0, 'd'}, {"interface", 1, 0, 'i'}, {"", 0, 0, 'l'}, {"", 0, 0, 'm'}, {"", 0, 0, 'n'}, {"", 1, 0, 'P'}, {"", 0, 0, 'p'}, {"", 1, 0, 'r'}, {"", 0, 0, 'T'}, {"", 0, 0, 't'}, {"", 1, 0, 'w'}, {"", 0, 0, 'x'}, {"help", 0, 0, 'h'}, {"version", 0, 0, 'v'}, {0, 0, 0, 0} }; my_args = (struct arg_t *) my_malloc (sizeof(struct arg_t)); my_args->a = false; my_args->b = false; my_args->C = NULL; my_args->d = false; my_args->i = NULL; my_args->l = false; my_args->m = false; my_args->n = false; my_args->P = NULL; my_args->p = false; my_args->r = NULL; my_args->T = false; my_args->t = false; my_args->w = NULL; my_args->x = false; my_args->h = false; my_args->v = false; while ((c = getopt_long(argc, argv, "abc:C:di:lmnP:pr:Ttw:xhv", long_options, &option_index)) != EOF) { switch(c) { case 'a': my_args->a = true; break; case 'b': my_args->b = true; break; case 'c': my_args->c = atoi(optarg); if (my_args->c < 1) { fprintf(stderr, "parameter range error: c must be >= 1\n"); errflg++; } break; case 'C': my_args->C = strdup(optarg); break; case 'd': my_args->d = true; break; case 'i': my_args->i = strdup(optarg); break; case 'l': my_args->l = true; break; case 'm': my_args->m = true; break; case 'n': my_args->n = true; break; case 'P': my_args->P = strdup(optarg); break; case 'p': my_args->p = true; break; case 'r': my_args->r = strdup(optarg); break; case 'T': my_args->T = true; break; case 't': my_args->t = true; break; case 'w': my_args->w = strdup(optarg); break; case 'x': my_args->x = true; break; case 'h': my_args->h = true; usage(argv[0]); break; case 'v': my_args->v = true; break; default: usage(argv[0]); } } /* while */ if (errflg) usage(argv[0]); if (optind >= argc) my_args->optind = 0; else my_args->optind = optind; return my_args; } ipgrab-0.9.10/src/parse_cl.h0000644000175000001440000000167007360125124015007 0ustar farooqusers/****************************************************************************** ** ** parse_cl.h ** ** Sun Oct 7 12:44:00 2001 ** Linux 2.4.2 (#5 Thu Apr 26 12:29:16 CDT 2001) i686 ** mborella@stratos.mw.3com.com (Mike Borella) ** ** Header file for command line parser ** ** Automatically created by genparse v0.5.2 ** ** See http://genparse.sourceforge.net/ for details and updates ** ******************************************************************************/ #include #ifndef bool typedef enum bool_t { false = 0, true } bool; #endif /* customized structure for command line parameters */ struct arg_t { bool a; bool b; int c; char * C; bool d; char * i; bool l; bool m; bool n; char * P; bool p; char * r; bool T; bool t; char * w; bool x; bool h; bool v; int optind; }; /* function prototypes */ struct arg_t * Cmdline(int, char **); void usage(char *); void free_args(struct arg_t *); ipgrab-0.9.10/src/payload.c0000644000175000001440000000363007374605314014652 0ustar farooqusers/**************************************************************************** ** File: payload.c ** ** Author: Mike Borella ** ** Comments: Dump packet payload ** ** $Id: payload.c,v 1.9 2001/11/15 00:22:36 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "global.h" #include "payload.h" #define PAYLOAD_SIZE 1500 extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** dump_payload() ** ** Dump printable portions of packet payload ** **---------------------------------------------------------------------------- */ void dump_payload(packet_t *pkt) { char holder[PAYLOAD_SIZE]; int bytes; /* Quit if we're in minimal mode */ if (my_args->m) return; /* Set the layer */ set_layer(LAYER_APPLICATION); /* display announcement */ display_header_banner("Payload"); /* The rest of the packet is payload, so lets grab the whole thing */ bytes = get_packet_apparentbytesleft(pkt); if (bytes <= 0) return; if (get_packet_bytes(holder, pkt, bytes) == 0) return; /* * Display the hex and text */ dump_hex_and_text(holder, bytes); return; } ipgrab-0.9.10/src/payload.h0000644000175000001440000000217607153266450014662 0ustar farooqusers/**************************************************************************** ** File: payload.h ** ** Author: Mike Borella ** ** Comments: Dump packet payload ** ** $Id: payload.h,v 1.3 2000/08/30 20:23:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef PAYLOAD_H #define PAYLOAD_H #include "global.h" #include "local.h" void dump_payload(packet_t *pkt); #endif ipgrab-0.9.10/src/ppp.c0000644000175000001440000001764610530527426014027 0ustar farooqusers/**************************************************************************** ** File: ppp.c ** ** Author: Mike Borella ** ** Comments: PPP module. ** ** $Id: ppp.c,v 1.15 2006/11/21 07:47:34 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "ppp.h" #include "payload.h" /* * PPP protocol types */ #define PPP_PROTOCOL_IP 0x0021 #define PPP_PROTOCOL_IPCP 0x8021 #define PPP_PROTOCOL_IPXCP 0x802b #define PPP_PROTOCOL_LCP 0xc021 #define PPP_PROTOCOL_PAP 0xc023 #define PPP_PROTOCOL_CHAP 0xc223 #define PPP_PROTOCOL_CCP 0x80fd #define PPP_PROTOCOL_COMPRESSED_FRAME 0x00fd #define PPP_PROTOCOL_CBCP 0xc029 #define PPP_PROTOCOL_VJUNCOMPRESSED 0x002f /* * PPP protocol map */ strmap_t ppp_protocol_map[] = { { PPP_PROTOCOL_IP, "IP" }, { PPP_PROTOCOL_IPCP, "IPCP" }, { PPP_PROTOCOL_IPXCP, "IPXCP" }, { PPP_PROTOCOL_LCP, "LCP" }, { PPP_PROTOCOL_PAP, "PAP" }, { PPP_PROTOCOL_CHAP, "CHAP" }, { PPP_PROTOCOL_CCP, "CCP" }, { PPP_PROTOCOL_COMPRESSED_FRAME, "compressed frame" }, { PPP_PROTOCOL_CBCP, "CBCP" }, { PPP_PROTOCOL_VJUNCOMPRESSED, "VJ uncompressed" }, { 0, "" } }; /* * PPP frame format */ typedef struct ppp { u_int8_t address; u_int8_t control; u_int16_t protocol; } ppp_t; extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** dump_ppp() ** ** Displays PPP packets. ** **---------------------------------------------------------------------------- */ void dump_ppp(packet_t * pkt) { ppp_t ppp; u_int16_t protocol; u_int16_t two_bytes; /* Set the layer */ set_layer(LAYER_DATALINK); /* * Look at the first 2 bytes to see if address/control compression is * set or not. */ if (look_packet_bytes((u_int8_t *) &two_bytes, pkt, sizeof(u_int16_t)) == 0) return; /* * If the result is 0xff03, then process the packet normally. Anything else * and we'll assume that compression is being used and that these two * bytes are a protocol type. */ if (ntohs(two_bytes) == 0xff03) { /* * Get the header */ if (get_packet_bytes((u_int8_t *) &ppp, pkt, sizeof(ppp_t)) == 0) return; /* * Conversion */ protocol = ntohs(ppp.protocol); /* * Dump the header */ if (my_args->m) { display_minimal_string("| PPP "); } else { display_header_banner("PPP Header"); display("Address", &ppp.address, 1, DISP_HEX); display("Control", &ppp.control, 1, DISP_HEX); display_strmap_hex("Protocol type", protocol, ppp_protocol_map); } } else { u_int8_t temp_protocol; /* * Get the protocol. If the protocol is "0x21" then it is only * one byte and compression is suppressing the "0x00" - i.e., its a * damn IP packet. If is one byte and is "0xfd", its a compressed * PPP frame and therefore we cannot decode it. * * This is a quick fix = it could be made more robust */ if (look_packet_bytes((u_int8_t *) &temp_protocol, pkt, 1) == 0) return; if (temp_protocol == PPP_PROTOCOL_IP || temp_protocol == PPP_PROTOCOL_COMPRESSED_FRAME || temp_protocol == PPP_PROTOCOL_VJUNCOMPRESSED) { if (get_packet_bytes((u_int8_t *) &temp_protocol, pkt, 1) == 0) return; protocol = temp_protocol; } else { if (get_packet_bytes((u_int8_t *) &protocol, pkt, 2) == 0) return; protocol = ntohs(protocol); } /* * Dump the header */ if (my_args->m) { display_minimal_string("PPP "); } else { display_header_banner("PPP Header"); display_strmap_hex("Protocol type", protocol, ppp_protocol_map); } } /* else */ /* dump the hex buffer */ hexbuffer_flush(); /* * Determine the next layer protocol */ switch(protocol) { case PPP_PROTOCOL_IP: case PPP_PROTOCOL_VJUNCOMPRESSED: dump_ip(pkt); break; case PPP_PROTOCOL_LCP: dump_lcp(pkt); break; case PPP_PROTOCOL_CHAP: dump_chap(pkt); break; case PPP_PROTOCOL_IPCP: dump_ipcp(pkt); break; case PPP_PROTOCOL_CBCP: dump_cbcp(pkt); break; case PPP_PROTOCOL_CCP: dump_ccp(pkt); break; case PPP_PROTOCOL_COMPRESSED_FRAME: /* If MPPC was given as the default CCP algorithm, dump it */ if (!strcmp(my_args->C, "mppc")) dump_mppc(pkt); break; default: if (!my_args->m) dump_payload(pkt); break; } /* Should be able to display the PPP trailer here.... */ } /*---------------------------------------------------------------------------- ** ** dump_ppp_hdlc() ** ** Scans over the HDLC based PPP frame and translates it into a regular ** frame that PPP can handle. Some systems however will fragment the ** HDLC-ized packets. We would need memory and state to handle these ** cases, and we're not going to implement that right now. ** **---------------------------------------------------------------------------- */ void dump_ppp_hdlc(packet_t * pkt) { packet_t hdlc_frame; int length; char * holder_before; char * holder_after; int ptr; int i; u_int8_t first_byte; /* Set the layer */ set_layer(LAYER_DATALINK); /* * Look at the first byte. Bail out if it is not 0x7e. We may be able * to fix this later */ if (look_packet_bytes(&first_byte, pkt, 1) == 0) return; else { if (first_byte != 0x7e) { dump_ppp(pkt); return; } } /* Determine the length of the frame */ length = get_packet_apparentbytesleft(pkt); /* Allocate space for this */ holder_before = my_malloc(length); holder_after = my_malloc(length); /* Get the packet */ if (get_packet_bytes(holder_before, pkt, length) == 0) return; /* Run through the before array moving fixed characters to the after array */ ptr = 0; for (i=0; i= length) break; i++; holder_after[ptr] = holder_before[i] ^ 0x20; ptr++; } /* Bail out when we see a 0x7e that is not at the beginning */ if (i>0 && holder_before[i] == 0x7e) break; } /* Delete the before data, we no longer need it */ my_free (holder_before); /* Create a fake packet to fake out PPP and other modules */ hdlc_frame.contents = holder_after; hdlc_frame.current = &hdlc_frame.contents[0]; hdlc_frame.end = &hdlc_frame.contents[0] + ptr; hdlc_frame.apparent_end = hdlc_frame.end; hdlc_frame.media_length = ptr; /* Kill the hex buffer here in order to eliminate duplicate processing */ hexbuffer_kill(); /* Send this packet through the processing */ dump_ppp(&hdlc_frame); /* Free the memory for the fake packet */ my_free(hdlc_frame.contents); } ipgrab-0.9.10/src/ppp.h0000644000175000001440000000242707370363552014031 0ustar farooqusers/**************************************************************************** ** File: ppp.h ** ** Author: Mike Borella ** ** Comments: PPP module definitions. ** ** $Id: ppp.h,v 1.8 2001/11/02 00:23:06 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef PPP_H #define PPP_H #include "global.h" #include "local.h" #include "ip.h" #include "ipv6.h" #include "lcp.h" #include "chap.h" #include "ipcp.h" #include "ccp.h" #include "cbcp.h" #include "mppc.h" void dump_ppp(packet_t *); void dump_ppp_hdlc(packet_t *); #endif ipgrab-0.9.10/src/pppoe.c0000644000175000001440000001416107304522724014341 0ustar farooqusers/**************************************************************************** ** File: pppoe.c ** ** Author: Andy Juniper ** ** Comments: PPP module. ** ** $Id: pppoe.c,v 1.5 2001/05/28 19:24:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "pppoe.h" #include "ppp.h" /* * PPPOE code types */ #define PPPOE_CODE_PADI 0x09 #define PPPOE_CODE_PADO 0x07 #define PPPOE_CODE_PADR 0x19 #define PPPOE_CODE_PADS 0x65 #define PPPOE_CODE_PADT 0xa7 #define PPPOE_CODE_SESS 0x00 /* * PPPOE tag types */ #define PPPOE_TAG_ENDOFLIST 0x0000 #define PPPOE_TAG_SERVICENAME 0x0101 #define PPPOE_TAG_ACNAME 0x0102 #define PPPOE_TAG_HOSTUNIQ 0x0103 #define PPPOE_TAG_ACCOOKIE 0x0104 #define PPPOE_TAG_VENDORSPEC 0x0105 #define PPPOE_TAG_RELAYSESSID 0x0110 #define PPPOE_TAG_SERVNAMEERR 0x0201 #define PPPOE_TAG_ACSYSERR 0x0202 #define PPPOE_TAG_GENERICERR 0x0203 /* * PPPOE code map */ strmap_t pppoe_code_map[] = { { PPPOE_CODE_PADI ,"PADI" }, { PPPOE_CODE_PADO ,"PADO" }, { PPPOE_CODE_PADR ,"PADR" }, { PPPOE_CODE_PADS ,"PADS" }, { PPPOE_CODE_PADT ,"PADT" }, { PPPOE_CODE_SESS ,"SESSION" }, { 0, "" } }; /* * PPPOE TLV map */ strmap_t pppoe_tlv_map[] = { { PPPOE_TAG_ENDOFLIST ,"End of List" }, { PPPOE_TAG_SERVICENAME ,"Service Name" }, { PPPOE_TAG_ACNAME ,"AC Name" }, { PPPOE_TAG_HOSTUNIQ ,"Host Uniq" }, { PPPOE_TAG_ACCOOKIE ,"AC Cookie" }, { PPPOE_TAG_VENDORSPEC ,"Vendor Specific" }, { PPPOE_TAG_RELAYSESSID ,"Relay Session ID" }, { PPPOE_TAG_SERVNAMEERR ,"Service Name Error" }, { PPPOE_TAG_ACSYSERR ,"AC System Error" }, { PPPOE_TAG_GENERICERR ,"Generic Error" }, { 0, "" } }; /* * PPPOE frame format */ typedef struct pppoe { u_int8_t vertype; u_int8_t code; u_int16_t session; u_int16_t length; } pppoe_t; typedef struct pppoe_tlv { u_int16_t tagtype; u_int16_t taglen; } pppoe_tlv_t; extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** dump_pppoe_hdr() ** ** Displays PPPOE headers ** **---------------------------------------------------------------------------- */ int dump_pppoe_hdr(packet_t *pkt) { pppoe_t pppoe; int len; /* Set the layer */ set_layer(LAYER_DATALINK); /* * Get the header */ if (get_packet_bytes((u_int8_t *) &pppoe, pkt, sizeof(pppoe_t)) == 0) return 0; len = ntohs(pppoe.length); /* * Dump the header */ if (my_args->m) { display_minimal_string("| PPPOE "); } else { display_header_banner("PPPOE Header"); display("Version/Type", &pppoe.vertype, 1, DISP_HEX); display("Session ID", (u_int8_t *) &pppoe.session, 2, DISP_HEX); display("Length", (u_int8_t *) &len, 2, DISP_DEC); display_strmap_hex("Message code", pppoe.code, pppoe_code_map); } /* dump the hex buffer */ hexbuffer_flush(); return len; } /*---------------------------------------------------------------------------- ** ** dump_pppoed() ** ** Displays PPPOE discovery packets ** **---------------------------------------------------------------------------- */ void dump_pppoed(packet_t *pkt) { pppoe_tlv_t tlv; int len; int offset; int totlen; u_int8_t data[1000]; /* should be enough */ totlen = dump_pppoe_hdr(pkt); /* do no more if we don't need to */ if (my_args->m) return; /* dump the TLVs */ while ((totlen > 0) && (get_packet_bytes((u_int8_t*)&tlv, pkt, sizeof(pppoe_tlv_t)))) { /* do the header */ len = ntohs(tlv.taglen); totlen -= (sizeof(pppoe_tlv_t)+len); display_strmap_hex(" TLV type", ntohs(tlv.tagtype), pppoe_tlv_map); display(" TLV len", (u_int8_t*)&len, 2, DISP_DEC); /* copy the data out */ len = (len>sizeof(data))?sizeof(data)-1:len; if (len == 0) continue; if (get_packet_bytes(data, pkt, len) == 0) return; offset=0; if (tlv.tagtype == PPPOE_TAG_ENDOFLIST) break; /* and the data */ switch (ntohs(tlv.tagtype)) { case PPPOE_TAG_SERVICENAME: case PPPOE_TAG_ACNAME: case PPPOE_TAG_SERVNAMEERR: case PPPOE_TAG_ACSYSERR: case PPPOE_TAG_GENERICERR: /* all string values, if present, not necessarily null terminated */ data[len]=0; display(" TLV value", data, len, DISP_STRING); break; case PPPOE_TAG_VENDORSPEC: /* * 4 bytes vendor id followed by whatever - we dump as hex by * falling through */ display(" TLV vendor", data, 4, DISP_HEX); offset+=4; case PPPOE_TAG_HOSTUNIQ: case PPPOE_TAG_ACCOOKIE: case PPPOE_TAG_RELAYSESSID: default: /* all hex values, if present, and not necessarily null terminated */ display(" TLV value", data+offset, len-offset, DISP_HEX); break; } } /* dump the hex buffer */ hexbuffer_flush(); } /*---------------------------------------------------------------------------- ** ** dump_pppoes() ** ** Displays PPPOE data session packets ** **---------------------------------------------------------------------------- */ void dump_pppoes(packet_t *pkt) { dump_pppoe_hdr(pkt); dump_ppp(pkt); } ipgrab-0.9.10/src/pppoe.h0000644000175000001440000000227507171360513014347 0ustar farooqusers /**************************************************************************** ** File: pppoe.h ** ** Author: Andy Juniper ** ** Comments: PPPOE module definitions. ** ** $Id: pppoe.h,v 1.1 2000/10/12 16:05:31 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef PPPOE_H #define PPPOE_H #include "global.h" #include "local.h" void dump_pppoes(packet_t *); void dump_pppoed(packet_t *); #endif ipgrab-0.9.10/src/pptp.c0000644000175000001440000003502307356404567014214 0ustar farooqusers/**************************************************************************** ** File: pptp.c ** ** Author: Mike Borella ** ** Comments: Dump PPTP information ** ** $Id: pptp.c,v 1.12 2001/10/02 18:37:43 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "global.h" #include "ip_protocols.h" #include "pptp.h" extern struct arg_t *my_args; /* * PPTP message type map */ strmap_t pptp_msgtype_map[] = { { PPTP_MSGTYPE_CONTROL, "control" }, { PPTP_MSGTYPE_MANAGEMENT, "management" } }; #define PPTP_MSGTYPE_CONTROL 1 #define PPTP_MSGTYPE_MANAGEMENT 2 /* * PPTP control message types */ strmap_t pptp_cntlmsgtype_map[] = { { PPTP_CNTLMSGTYPE_STARTCCREQ, "Start-Control-Connection-Request" }, { PPTP_CNTLMSGTYPE_STARTCCREP, "Start-Control-Connection-Reply" }, { PPTP_CNTLMSGTYPE_STOPCCREQ, "Stop-Control-Connection-Request" }, { PPTP_CNTLMSGTYPE_STOPCCREP, "Stop-Control-Connection-Reply" }, { PPTP_CNTLMSGTYPE_ECHOREQ, "Echo-Request" }, { PPTP_CNTLMSGTYPE_ECHOREP, "Echo-Reply" }, { PPTP_CNTLMSGTYPE_OUTGOINGREQ, "Outgoing-Call-Request" }, { PPTP_CNTLMSGTYPE_OUTGOINGREP, "Outgoing-Call-Reply" }, { PPTP_CNTLMSGTYPE_INCOMINGREQ, "Incoming-Call-Request" }, { PPTP_CNTLMSGTYPE_INCOMINGREP, "Incoming-Call-Reply" }, { PPTP_CNTLMSGTYPE_INCOMINGCONN, "Incoming-Call-Connected" }, { PPTP_CNTLMSGTYPE_CALLCLEARREQ, "Call-Clear-Request" }, { PPTP_CNTLMSGTYPE_CALLDISCNTFY, "Call-Disconnect-Notify" }, { PPTP_CNTLMSGTYPE_WANERRORNTFY, "WAN-Error-Notify" }, { PPTP_CNTLMSGTYPE_SETLINKINFO, "Set-Link-Info" }, { 0, "" } }; /*---------------------------------------------------------------------------- ** ** dump_pptp_startccreq() ** ** Parse PPTP Start-Control-Connection-Request ** **---------------------------------------------------------------------------- */ void dump_pptp_startccreq(packet_t *pkt) { pptp_startccreq_t hdr; /* * Get the header */ if (get_packet_bytes((u_int8_t *) &hdr, pkt, sizeof(pptp_startccreq_t)) == 0) return; /* * Conversions */ hdr.version = ntohs(hdr.version); hdr.reserved1 = ntohs(hdr.reserved1); hdr.framing_cap = ntohl(hdr.framing_cap); hdr.bearer_cap = ntohl(hdr.bearer_cap); hdr.max_channels = ntohs(hdr.max_channels); hdr.firmware_rev = ntohs(hdr.firmware_rev); hdr.hostname[PPTP_HOSTNAME_LEN-1] = '\0'; hdr.vendor[PPTP_VENDOR_LEN-1] = '\0'; /* * Display */ if (my_args->m) { display_minimal_string(hdr.hostname); display_minimal_string(" "); } else { display("Version", (u_int8_t *) &hdr.version, 2, DISP_DEC); display("Reserved", (u_int8_t *) &hdr.reserved1, 2, DISP_DEC); display("Framing capabilities", (u_int8_t *) &hdr.framing_cap, 4, DISP_DEC); display("Bearer capabilities", (u_int8_t *) &hdr.bearer_cap, 4, DISP_DEC); display("Max channels", (u_int8_t *) &hdr.max_channels, 2, DISP_DEC); display("Firmware revision", (u_int8_t *) &hdr.firmware_rev, 2, DISP_DEC); display_string("Host name", hdr.hostname); display_string("Vendor", hdr.vendor); } } /*---------------------------------------------------------------------------- ** ** dump_pptp_startccrep() ** ** Parse PPTP Start-Control-Connection-Reply ** **---------------------------------------------------------------------------- */ void dump_pptp_startccrep(packet_t *pkt) { pptp_startccrep_t hdr; /* * Get the header */ if (get_packet_bytes((u_int8_t *) &hdr, pkt, sizeof(pptp_startccrep_t)) == 0) return; /* * Conversions */ hdr.version = ntohs(hdr.version); hdr.framing_cap = ntohl(hdr.framing_cap); hdr.bearer_cap = ntohl(hdr.bearer_cap); hdr.max_channels = ntohs(hdr.max_channels); hdr.firmware_rev = ntohs(hdr.firmware_rev); hdr.hostname[PPTP_HOSTNAME_LEN-1] = '\0'; hdr.vendor[PPTP_VENDOR_LEN-1] = '\0'; /* * Display */ if (my_args->m) { display_minimal_string(hdr.hostname); display_minimal_string(" "); } else { display("Version", (u_int8_t *) &hdr.version, 2, DISP_DEC); display("Result code", (u_int8_t *) &hdr.result_code, 1, DISP_DEC); display("Error code", (u_int8_t *) &hdr.error_code, 1, DISP_DEC); display("Framing capabilities", (u_int8_t *) &hdr.framing_cap, 4, DISP_DEC); display("Bearer capabilities", (u_int8_t *) &hdr.bearer_cap, 4, DISP_DEC); display("Max channels", (u_int8_t *) &hdr.max_channels, 2, DISP_DEC); display("Firmware revision", (u_int8_t *) &hdr.firmware_rev, 2, DISP_DEC); display_string("Host name", hdr.hostname); display_string("Vendor", hdr.vendor); } } /*---------------------------------------------------------------------------- ** ** dump_pptp_outgoingreq() ** ** Parse PPTP Outgoing-Call-Request ** **---------------------------------------------------------------------------- */ void dump_pptp_outgoingreq(packet_t *pkt) { pptp_outgoingreq_t hdr; /* * Get the header */ if (get_packet_bytes((u_int8_t *) &hdr, pkt, sizeof(pptp_outgoingreq_t)) == 0) return; /* * Conversions */ hdr.call_id = ntohs(hdr.call_id); hdr.call_sn = ntohs(hdr.call_sn); hdr.min_bps = ntohl(hdr.min_bps); hdr.max_bps = ntohl(hdr.max_bps); hdr.bearer_type = ntohl(hdr.bearer_type); hdr.framing_type = ntohl(hdr.framing_type); hdr.recv_window_size = ntohs(hdr.recv_window_size); hdr.packet_proc_delay = ntohs(hdr.packet_proc_delay); hdr.phone_num_len = ntohs(hdr.phone_num_len); hdr.reserved1 = ntohs(hdr.reserved1); hdr.phone_num[PPTP_PHONENUM_LEN-1] = '\0'; hdr.phone_num[hdr.phone_num_len] = '\0'; hdr.subaddress[PPTP_SUBADDRESS_LEN-1] = '\0'; /* * Display */ if (my_args->m) { display_minimal_string(hdr.phone_num); display_minimal_string(" "); } else { display("Call ID", (u_int8_t *) &hdr.call_id, 2, DISP_DEC); display("Call serial number", (u_int8_t *) &hdr.call_sn, 2, DISP_DEC); display("Minimum BPS", (u_int8_t *) &hdr.min_bps, 4, DISP_DEC); display("Maximum BPS", (u_int8_t *) &hdr.max_bps, 4, DISP_DEC); display("Bearer type", (u_int8_t *) &hdr.bearer_type, 4, DISP_DEC); display("Framing type", (u_int8_t *) &hdr.framing_type, 4, DISP_DEC); display("Receive window size", (u_int8_t *) &hdr.recv_window_size, 2, DISP_DEC); display("Packet processing delay", (u_int8_t *) &hdr.packet_proc_delay, 2, DISP_DEC); display("Phone number length", (u_int8_t *) &hdr.phone_num_len, 2, DISP_DEC); display("Reserved", (u_int8_t *) &hdr.reserved1, 2, DISP_DEC); display_string("Phone number", hdr.phone_num); display_string("Subaddress", hdr.subaddress); } } /*---------------------------------------------------------------------------- ** ** dump_pptp_outgoingrep() ** ** Parse PPTP Outgoing-Call-Reply ** **---------------------------------------------------------------------------- */ void dump_pptp_outgoingrep(packet_t *pkt) { pptp_outgoingrep_t hdr; /* * Get the header */ if (get_packet_bytes((u_int8_t *) &hdr, pkt, sizeof(pptp_outgoingrep_t)) == 0) return; /* * Conversions */ hdr.call_id = ntohs(hdr.call_id); hdr.peer_call_id = ntohs(hdr.peer_call_id); hdr.cause_code = ntohs(hdr.cause_code); hdr.connect_speed = ntohl(hdr.connect_speed); hdr.recv_window_size = ntohs(hdr.recv_window_size); hdr.packet_proc_delay = ntohs(hdr.packet_proc_delay); hdr.phy_channel_id = ntohl(hdr.phy_channel_id); /* * Display */ if (my_args->m) { /* XXX fix me ! */ display_minimal_string(" "); } else { display("Call ID", (u_int8_t *) &hdr.call_id, 2, DISP_DEC); display("Peer call ID", (u_int8_t *) &hdr.peer_call_id, 2, DISP_DEC); display("Result code", (u_int8_t *) &hdr.result_code, 1, DISP_DEC); display("Error code", (u_int8_t *) &hdr.error_code, 1, DISP_DEC); display("Cause code", (u_int8_t *) &hdr.cause_code, 2, DISP_DEC); display("Connect speed", (u_int8_t *) &hdr.connect_speed, 4, DISP_DEC); display("Receive window size", (u_int8_t *) &hdr.recv_window_size, 2, DISP_DEC); display("Packet processing delay", (u_int8_t *) &hdr.packet_proc_delay, 2, DISP_DEC); display("Physical channel ID", (u_int8_t *) &hdr.phy_channel_id, 4, DISP_DEC); } } /*---------------------------------------------------------------------------- ** ** dump_pptp_setlinkinfo() ** ** Parse PPTP Set-Link-Info ** **---------------------------------------------------------------------------- */ void dump_pptp_setlinkinfo(packet_t *pkt) { pptp_setlinkinfo_t hdr; /* * Get the header */ if (get_packet_bytes((u_int8_t *) &hdr, pkt, sizeof(pptp_setlinkinfo_t)) == 0) return; /* * Conversions */ hdr.peer_call_id = ntohs(hdr.peer_call_id); hdr.reserved1 = ntohs(hdr.reserved1); hdr.send_accm = ntohl(hdr.send_accm); hdr.receive_accm = ntohl(hdr.receive_accm); /* * Display */ if (my_args->m) { /* XXX fix me ! */ display_minimal_string(" "); } else { display("Peer call ID", (u_int8_t *) &hdr.peer_call_id, 2, DISP_DEC); display("Reserved", (u_int8_t *) &hdr.reserved1, 2, DISP_DEC); display("Send ACCM", (u_int8_t *) &hdr.send_accm, 4, DISP_HEX); display("Receive ACCM", (u_int8_t *) &hdr.receive_accm, 4, DISP_HEX); } } /*---------------------------------------------------------------------------- ** ** dump_pptp_callclearreq() ** ** Parse PPTP Call-Clear-Request ** **---------------------------------------------------------------------------- */ void dump_pptp_callclearreq(packet_t *pkt) { pptp_callclearreq_t hdr; /* * Get the header */ if (get_packet_bytes((u_int8_t *) &hdr, pkt, sizeof(pptp_callclearreq_t)) == 0) return; /* * Conversions */ hdr.call_id = ntohs(hdr.call_id); hdr.reserved = ntohs(hdr.reserved); /* * Display */ if (my_args->m) { /* XXX fix me ! */ display_minimal_string(" "); } else { display("Call ID", (u_int8_t *) &hdr.call_id, 2, DISP_DEC); display("Reserved", (u_int8_t *) &hdr.reserved, 2, DISP_DEC); } } /*---------------------------------------------------------------------------- ** ** dump_pptp_calldiscntfy() ** ** Parse PPTP Call-Disconnect-Notify ** **---------------------------------------------------------------------------- */ void dump_pptp_calldiscntfy(packet_t *pkt) { pptp_calldiscntfy_t hdr; /* * Get the header */ if (get_packet_bytes((u_int8_t *) &hdr, pkt, sizeof(pptp_calldiscntfy_t)) == 0) return; /* * Conversions */ hdr.call_id = ntohs(hdr.call_id); hdr.cause_code = ntohs(hdr.cause_code); hdr.reserved = ntohs(hdr.reserved); /* * Display */ if (my_args->m) { /* XXX fix me ! */ display_minimal_string(" "); } else { display("Call ID", (u_int8_t *) &hdr.call_id, 2, DISP_DEC); display("Result code", (u_int8_t *) &hdr.result_code, 1, DISP_DEC); display("Error code", (u_int8_t *) &hdr.error_code, 1, DISP_DEC); display("Cause code", (u_int8_t *) &hdr.cause_code, 2, DISP_DEC); display("Reserved", (u_int8_t *) &hdr.reserved, 2, DISP_DEC); display("Call statistics", (u_int8_t *) &hdr.call_stats, 128, DISP_HEX_MULTILINE); } } /*---------------------------------------------------------------------------- ** ** dump_pptp() ** ** Parse PPTP header and dump fields ** **---------------------------------------------------------------------------- */ void dump_pptp(packet_t *pkt) { pptp_generic_header_t pptp; /* char holder[64]; */ /* Set the layer */ set_layer(LAYER_APPLICATION); /* * Get the generic header */ if (get_packet_bytes((u_int8_t *) &pptp, pkt, sizeof(pptp_generic_header_t)) == 0) return; /* * Conversions */ pptp.length = ntohs(pptp.length); pptp.pptp_msg_type = ntohs(pptp.pptp_msg_type); pptp.cookie = ntohl(pptp.cookie); pptp.control_msg_type = ntohs(pptp.control_msg_type); pptp.reserved0 = ntohs(pptp.reserved0); /* * Minimal mode */ if (my_args->m) { display_minimal_string("| PPTP "); display_minimal_string(map2str(pptp_msgtype_map, pptp.pptp_msg_type)); display_minimal_string(" "); display_minimal_string(map2str(pptp_cntlmsgtype_map, pptp.control_msg_type)); display_minimal_string(" "); } else { /* announcement */ display_header_banner("PPTP Header"); /* dump common fields */ display("Length", (u_int8_t *) &pptp.length, 2, DISP_DEC); display_strmap("PPTP message type", pptp.pptp_msg_type, pptp_msgtype_map); display("Magic cookie", (u_int8_t *) &pptp.cookie, 4, DISP_HEX); display_strmap("Control message type", pptp.control_msg_type, pptp_cntlmsgtype_map); display("Reserved", (u_int8_t *) &pptp.reserved0, 2, DISP_HEX); } /* * Now decide what to do based on the control message type. * Note - management messages are currently undefined so we shouldn't * have to worry about them for a while. */ if (pptp.pptp_msg_type == PPTP_MSGTYPE_CONTROL) { switch(pptp.control_msg_type) { case PPTP_CNTLMSGTYPE_STARTCCREQ: dump_pptp_startccreq(pkt); break; case PPTP_CNTLMSGTYPE_STARTCCREP: dump_pptp_startccrep(pkt); break; case PPTP_CNTLMSGTYPE_OUTGOINGREQ: dump_pptp_outgoingreq(pkt); break; case PPTP_CNTLMSGTYPE_OUTGOINGREP: dump_pptp_outgoingrep(pkt); break; case PPTP_CNTLMSGTYPE_SETLINKINFO: dump_pptp_setlinkinfo(pkt); break; case PPTP_CNTLMSGTYPE_CALLCLEARREQ: dump_pptp_callclearreq(pkt); break; case PPTP_CNTLMSGTYPE_CALLDISCNTFY: dump_pptp_calldiscntfy(pkt); break; } } /* dump the hex buffer */ hexbuffer_flush(); return; } ipgrab-0.9.10/src/pptp.h0000644000175000001440000002553307164477743014231 0ustar farooqusers/**************************************************************************** ** File: pptp.h ** ** Author: Mike Borella ** ** Comments: Generic PPTP header structure ** ** $Id: pptp.h,v 1.5 2000/09/27 23:16:51 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef PPTP_H #define PPTP_H #include "global.h" #include "local.h" #define PPTP_HOSTNAME_LEN 64 #define PPTP_VENDOR_LEN 64 #define PPTP_PHONENUM_LEN 64 #define PPTP_SUBADDRESS_LEN 64 /* * PPTP message types */ #define PPTP_MSGTYPE_CONTROL 1 #define PPTP_MSGTYPE_MANAGEMENT 2 /* * PPTP control message types */ #define PPTP_CNTLMSGTYPE_STARTCCREQ 1 #define PPTP_CNTLMSGTYPE_STARTCCREP 2 #define PPTP_CNTLMSGTYPE_STOPCCREQ 3 #define PPTP_CNTLMSGTYPE_STOPCCREP 4 #define PPTP_CNTLMSGTYPE_ECHOREQ 5 #define PPTP_CNTLMSGTYPE_ECHOREP 6 #define PPTP_CNTLMSGTYPE_OUTGOINGREQ 7 #define PPTP_CNTLMSGTYPE_OUTGOINGREP 8 #define PPTP_CNTLMSGTYPE_INCOMINGREQ 9 #define PPTP_CNTLMSGTYPE_INCOMINGREP 10 #define PPTP_CNTLMSGTYPE_INCOMINGCONN 11 #define PPTP_CNTLMSGTYPE_CALLCLEARREQ 12 #define PPTP_CNTLMSGTYPE_CALLDISCNTFY 13 #define PPTP_CNTLMSGTYPE_WANERRORNTFY 14 #define PPTP_CNTLMSGTYPE_SETLINKINFO 15 /* * Structure of generic PPTP header - should be in all PPTP packets * * * 0 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Length | PPTP Message Type | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Magic Cookie | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Control Message Type | Reserved0 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ typedef struct pptp_generic_header { u_int16_t length; u_int16_t pptp_msg_type; u_int32_t cookie; u_int16_t control_msg_type; u_int16_t reserved0; } pptp_generic_header_t; /* * Structure of PPTP Start-Control-Connection-Request * * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Protocol Version | Reserved1 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Framing Capabilities | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Bearer Capabilities | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Maximum Channels | Firmware Revision | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | | * + Host Name (64 octets) + * | | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | | * + Vendor String (64 octets) + * | | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ typedef struct pptp_startccreq { u_int16_t version; u_int16_t reserved1; u_int32_t framing_cap; u_int32_t bearer_cap; u_int16_t max_channels; u_int16_t firmware_rev; u_int8_t hostname[PPTP_HOSTNAME_LEN]; u_int8_t vendor[PPTP_VENDOR_LEN]; } pptp_startccreq_t; /* * Structure of PPTP Start-Control-Connection-Reply * * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Protocol Version | Result Code | Error Code | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Framing Capabilities | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Bearer Capabilities | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Maximum Channels | Firmware Revision | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | | * + Host Name (64 octets) + * | | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | | * + Vendor String (64 octets) + * | | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ typedef struct pptp_startccrep { u_int16_t version; u_int8_t result_code; u_int8_t error_code; u_int32_t framing_cap; u_int32_t bearer_cap; u_int16_t max_channels; u_int16_t firmware_rev; u_int8_t hostname[PPTP_HOSTNAME_LEN]; u_int8_t vendor[PPTP_VENDOR_LEN]; } pptp_startccrep_t; /* * Structure of PPTP Outgoing-Call-Request * * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Call ID | Call Serial Number | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Minimum BPS | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Maximum BPS | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Bearer Type | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Framing Type | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Packet Recv. Window Size | Packet Processing Delay | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Phone Number Length | Reserved1 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | | * + Phone Number (64 octets) + * | | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | | * + Subaddress (64 octets) + * | | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ typedef struct pptp_outgoingreq { u_int16_t call_id; u_int16_t call_sn; u_int32_t min_bps; u_int32_t max_bps; u_int32_t bearer_type; u_int32_t framing_type; u_int16_t recv_window_size; u_int16_t packet_proc_delay; u_int16_t phone_num_len; u_int16_t reserved1; u_int8_t phone_num[PPTP_PHONENUM_LEN]; u_int8_t subaddress[PPTP_SUBADDRESS_LEN]; } pptp_outgoingreq_t; /* * Structure of PPTP Outgoing-Call-Reply * * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Call ID | Peer's Call ID | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Result Code | Error Code | Cause Code | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Connect Speed | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Packet Recv. Window Size | Packet Processing Delay | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Physical Channel ID | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ typedef struct pptp_outgoingrep { u_int16_t call_id; u_int16_t peer_call_id; u_int8_t result_code; u_int8_t error_code; u_int16_t cause_code; u_int32_t connect_speed; u_int16_t recv_window_size; u_int16_t packet_proc_delay; u_int32_t phy_channel_id; } pptp_outgoingrep_t; /* * Structure of PPTP Set-Link-Info * * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Peer's Call ID | Reserved1 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Send ACCM | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Receive ACCM | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ typedef struct pptp_setlinkinfo { u_int16_t peer_call_id; u_int16_t reserved1; u_int32_t send_accm; u_int32_t receive_accm; } pptp_setlinkinfo_t; /* * Structure of PPTP Call-Clear-Request * * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Call ID | Reserved1 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * */ typedef struct pptp_callclearreq { u_int16_t call_id; u_int16_t reserved; } pptp_callclearreq_t; /* * Structure of PPTP Call-Disconnect-Notify * * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Call ID | Result Code | Error Code | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Cause Code | Reserved1 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | | * + Call Statistics (128 octets) + * | | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * */ typedef struct pptp_calldiscntfy { u_int16_t call_id; u_int8_t result_code; u_int8_t error_code; u_int16_t cause_code; u_int16_t reserved; u_int8_t call_stats[128]; } pptp_calldiscntfy_t; /* * Main PPTP function */ void dump_pptp(packet_t *); #endif ipgrab-0.9.10/src/radius.c0000644000175000001440000002722610637734556014526 0ustar farooqusers/**************************************************************************** ** File: radius.c ** ** Author: Mike Borella ** ** Comments: Support for decoding RADIUS packets. ** ** $Id: radius.c,v 1.5 2007/06/25 12:47:42 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "radius.h" #include "iana.h" #include "radius_3gpp2.h" /* * Types of RADIUS codes */ #define RADIUS_CODE_ACCESSREQUEST 1 #define RADIUS_CODE_ACCESSACCEPT 2 #define RADIUS_CODE_ACCESSREJECT 3 #define RADIUS_CODE_ACCOUNTINGREQUEST 4 #define RADIUS_CODE_ACCOUNTINGRESPONSE 5 #define RADIUS_CODE_ACCESSCHALLENGE 11 /* * RADIUS code map */ strmap_t radius_code_map[] = { { RADIUS_CODE_ACCESSREQUEST, "access request" }, { RADIUS_CODE_ACCESSACCEPT, "access accept" }, { RADIUS_CODE_ACCESSREJECT, "access reject" }, { RADIUS_CODE_ACCOUNTINGREQUEST, "accounting request" }, { RADIUS_CODE_ACCOUNTINGRESPONSE, "accounting response" }, { RADIUS_CODE_ACCESSCHALLENGE, "access challenge" }, { 0, ""} }; /* * RADIUS attributes */ #define RADIUS_ATTR_USERNAME 1 #define RADIUS_ATTR_USERPASSWORD 2 #define RADIUS_ATTR_CHAPPASSWORD 3 #define RADIUS_ATTR_NASIPADDR 4 #define RADIUS_ATTR_NASPORT 5 #define RADIUS_ATTR_SERVICETYPE 6 #define RADIUS_ATTR_FRAMEDPROTOCOL 7 #define RADIUS_ATTR_FRAMEDIPADDR 8 #define RADIUS_ATTR_FRAMEDIPNETMASK 9 #define RADIUS_ATTR_CLASS 25 #define RADIUS_ATTR_VENDORSPECIFIC 26 #define RADIUS_ATTR_CALLINGSTATIONID 31 #define RADIUS_ATTR_LOGINLATSERVICE 34 #define RADIUS_ATTR_ACCTSTATUSTYPE 40 #define RADIUS_ATTR_ACCTINPUTOCTETS 42 #define RADIUS_ATTR_ACCTOUTPUTOCTETS 43 #define RADIUS_ATTR_ACCTSESSIONID 44 #define RADIUS_ATTR_ACCTSESSIONTIME 46 #define RADIUS_ATTR_EVENTTIMESTAMP 55 #define RADIUS_ATTR_CHAPCHALLENGE 60 #define RADIUS_ATTR_NASPORTTYPE 61 /* * RADIUS attribute map */ strmap_t radius_attr_map[] = { { RADIUS_ATTR_USERNAME, "user name" }, { RADIUS_ATTR_USERPASSWORD, "user password" }, { RADIUS_ATTR_CHAPPASSWORD, "CHAP password" }, { RADIUS_ATTR_NASIPADDR, "NAS IP address" }, { RADIUS_ATTR_NASPORT, "NAS port" }, { RADIUS_ATTR_SERVICETYPE, "service type" }, { RADIUS_ATTR_FRAMEDPROTOCOL, "framed protocol" }, { RADIUS_ATTR_FRAMEDIPADDR, "framed IP address" }, { RADIUS_ATTR_FRAMEDIPNETMASK, "framed IP netmask" }, { RADIUS_ATTR_CLASS, "class" }, { RADIUS_ATTR_VENDORSPECIFIC, "vendor specific" }, { RADIUS_ATTR_CALLINGSTATIONID, "calling station ID" }, { RADIUS_ATTR_LOGINLATSERVICE, "login-LAT-service" }, { RADIUS_ATTR_ACCTSTATUSTYPE, "accounting status type" }, { RADIUS_ATTR_ACCTSESSIONID, "accounting session id" }, { RADIUS_ATTR_ACCTINPUTOCTETS, "accounting input octets" }, { RADIUS_ATTR_ACCTOUTPUTOCTETS, "accounting output octets" }, { RADIUS_ATTR_ACCTSESSIONTIME, "accounting session time" }, { RADIUS_ATTR_EVENTTIMESTAMP, "event timestamp" }, { RADIUS_ATTR_CHAPCHALLENGE, "CHAP challenge" }, { RADIUS_ATTR_NASPORTTYPE, "NAS port type" }, { 0, ""} }; /* * RADIUS packet format */ typedef struct radius_ { u_int8_t code; u_int8_t identifier; u_int16_t length; u_int8_t authenticator[16]; } radius_header_t; extern struct arg_t * my_args; extern strmap_t iana_enterprise_map[]; /*---------------------------------------------------------------------------- ** ** dump_radius_vendorspecific() ** ** Parse and dump a vendor specific RADIUS attribute. ** Returns the number of bytes read or -1 on error. ** **---------------------------------------------------------------------------- */ void dump_radius_vendorspecific(packet_t * pkt, u_int8_t type, u_int8_t length) { u_int32_t vendor; if (get_packet_bytes((u_int8_t *) &vendor, pkt, 4) == 0) return; /* Conversions */ vendor = ntohl(vendor); /* Get the vendor specific info */ switch(vendor) { case IANA_ENTERPRISE_3GPP2: dump_radius_3gpp2(pkt, type, length); break; default: { u_int8_t * value; /* Allocate memory for the value then get it */ value = my_malloc(length-5); if (get_packet_bytes(value, pkt, length-6) == 0) return; value[length-5] = '\0'; /* Display */ if (my_args->m) { display_minimal_string(map2str(radius_attr_map, type)); display_minimal_string("["); display_minimal_string(map2str(iana_enterprise_map, vendor)); display_minimal_string("]: "); display_minimal(value, length-6, DISP_HEX); } else { display_strmap("Attribute type", type, radius_attr_map); display(" Length", &length, 1, DISP_DEC); display_strmap(" Vendor", vendor, iana_enterprise_map); display(" Value", value, length-6, DISP_HEX_MULTILINE); } my_free(value); } break; } /* switch */ } /*---------------------------------------------------------------------------- ** ** dump_radius_attribute() ** ** Parse and dump a single RADIUS attribute. Returns the number of bytes read. ** ** **---------------------------------------------------------------------------- */ int dump_radius_attribute(packet_t * pkt) { u_int8_t type; u_int8_t length; u_int8_t * generic_value; /* Get the code */ if (get_packet_bytes(&type, pkt, 1) == 0) return 0; /* Get the length */ if (get_packet_bytes(&length, pkt, 1) == 0) return 0; /* Decide how to proceed based on the code */ switch(type) { /* These cases are for all attributes to be printed as text strings */ case RADIUS_ATTR_USERNAME: case RADIUS_ATTR_CLASS: case RADIUS_ATTR_CALLINGSTATIONID: case RADIUS_ATTR_LOGINLATSERVICE: { u_int8_t * username; /* Allocate memory for the username then get it */ username = my_malloc(length-1); if (get_packet_bytes(username, pkt, length-2) == 0) return 0; username[length-1] = '\0'; /* Display */ if (my_args->m) { display_minimal_string(map2str(radius_attr_map, type)); display_minimal_string(": "); display_minimal_string(username); } else { display_strmap("Attribute type", type, radius_attr_map); display(" Length", &length, 1, DISP_DEC); display_string(" Value", username); } my_free(username); } break; /* These cases are for all attributes to be printed as 4 byte ints */ case RADIUS_ATTR_NASPORT: case RADIUS_ATTR_SERVICETYPE: /* should have its own parser */ case RADIUS_ATTR_FRAMEDPROTOCOL: /* should have its own parser */ case RADIUS_ATTR_NASPORTTYPE: /* should have its own parser */ case RADIUS_ATTR_EVENTTIMESTAMP: case RADIUS_ATTR_ACCTSESSIONTIME: case RADIUS_ATTR_ACCTINPUTOCTETS: case RADIUS_ATTR_ACCTOUTPUTOCTETS: { u_int32_t byte4; if (get_packet_bytes((u_int8_t *) &byte4, pkt, 4) == 0) return 0; /* Conversions */ byte4 = ntohl(byte4); /* Display */ if (my_args->m) { display_minimal_string(map2str(radius_attr_map, type)); display_minimal_string(": "); display_minimal((u_int8_t *) &byte4, 4, DISP_DEC); } else { display_strmap("Attribute type", type, radius_attr_map); display(" Length", &length, 1, DISP_DEC); display(" Value", (u_int8_t *) &byte4, 4, DISP_DEC); } } break; /* These cases are for all attributes to be printed as IP addresses */ case RADIUS_ATTR_NASIPADDR: case RADIUS_ATTR_FRAMEDIPADDR: case RADIUS_ATTR_FRAMEDIPNETMASK: { u_int32_t addr; if (get_packet_bytes((u_int8_t *) &addr, pkt, 4) == 0) return 0; /* Display */ if (my_args->m) { display_minimal_string(map2str(radius_attr_map, type)); display_minimal_string(": "); display_minimal((u_int8_t *) &addr, 4, DISP_DOTTEDDEC); } else { display_strmap("Attribute type", type, radius_attr_map); display(" Length", &length, 1, DISP_DEC); display(" Address", (u_int8_t *) &addr, 4, DISP_DOTTEDDEC); } } break; case RADIUS_ATTR_VENDORSPECIFIC: dump_radius_vendorspecific(pkt, type, length); break; /* These cases are for all attributes to be printed as hex */ case RADIUS_ATTR_CHAPCHALLENGE: case RADIUS_ATTR_USERPASSWORD: case RADIUS_ATTR_CHAPPASSWORD: default: { /* Allocate memory for the value then get it */ generic_value = my_malloc(length-2); if (get_packet_bytes(generic_value, pkt, length-2) == 0) return 0; /* Display */ if (my_args->m) { display_minimal_string(map2str(radius_attr_map, type)); display_minimal_string(": "); display_minimal(generic_value, length-2, DISP_HEX); } else { display_strmap("Attribute type", type, radius_attr_map); display(" Length", &length, 1, DISP_DEC); display(" Value", generic_value, length-2, DISP_HEX_MULTILINE); } /* Free the memory of the value */ my_free(generic_value); } break; } return length; } /*---------------------------------------------------------------------------- ** ** dump_radius() ** ** Parse and dump RADIUS packets ** **---------------------------------------------------------------------------- */ void dump_radius(packet_t *pkt) { radius_header_t radius; int len; int first; /* Set the layer */ set_layer(LAYER_TRANSPORT); /* Get the RADIUS header */ if (get_packet_bytes((u_int8_t *) &radius, pkt, sizeof(radius_header_t)) == 0) return; /* Conversions */ radius.length = ntohs(radius.length); /* Display */ if (my_args->m) { display_minimal_string("| RADIUS "); display_minimal_string(map2str(radius_code_map, radius.code)); display_minimal_string(" "); display_minimal(&radius.identifier, 1, DISP_DEC); display_minimal_string(" ("); } else { display_header_banner("RADIUS"); display_strmap("Code", radius.code, radius_code_map); display("Identifier", &radius.identifier, 1, DISP_DEC); display("Length", (u_int8_t *) &radius.length, 2, DISP_DEC); display("Authenticator", (u_int8_t *) &radius.authenticator, 16, DISP_HEX); } /* Read all of the attributes */ /* Get length of attributes in bytes */ len = radius.length - sizeof(radius_header_t); first = 1; while(1) { if (len <= 0) break; if (first != 1 && my_args->m) display_minimal_string(", "); len = len - dump_radius_attribute(pkt); first = 0; } /* Final close paren for minimal mode */ if (my_args->m) display_minimal_string(")"); /* Dump the hex buffer */ hexbuffer_flush(); return; } ipgrab-0.9.10/src/radius.h0000644000175000001440000000220710530527426014507 0ustar farooqusers/**************************************************************************** ** File: radius.h ** ** Author: Mike Borella ** ** Comments: Header file for RADIUS support. ** ** $Id: radius.h,v 1.3 2006/11/21 07:47:34 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef RADIUS_H #define RADIUS_H #include "global.h" #include "local.h" void dump_radius(packet_t *); #endif ipgrab-0.9.10/src/radius_3gpp2.c0000644000175000001440000002316710530527426015525 0ustar farooqusers/**************************************************************************** ** File: radius_3gpp2.c ** ** Author: Mike Borella ** ** Comments: Support for decoding 3GPP2 RADIUS attributes. ** ** $Id: radius_3gpp2.c,v 1.4 2006/11/21 07:47:34 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "radius_3gpp2.h" #include "iana.h" /* * 3GPP2 vendor specific attributes */ #define RADIUS_ATTR_3GPP2_IKEPSKREQUEST 1 #define RADIUS_ATTR_3GPP2_SECURITYLEVEL 2 #define RADIUS_ATTR_3GPP2_IKEPSK 3 #define RADIUS_ATTR_3GPP2_REVERSETUNNEL 4 #define RADIUS_ATTR_3GPP2_DIFFSERVCLASS 5 #define RADIUS_ATTR_3GPP2_HAADDR 7 #define RADIUS_ATTR_3GPP2_SERVINGPCFADDR 9 #define RADIUS_ATTR_3GPP2_BSID 10 #define RADIUS_ATTR_3GPP2_USERZONE 11 #define RADIUS_ATTR_3GPP2_FORWARDMUX 12 #define RADIUS_ATTR_3GPP2_REVERSEMUX 13 #define RADIUS_ATTR_3GPP2_MNHAKEY 14 #define RADIUS_ATTR_3GPP2_MNHAKEYREQUEST 15 #define RADIUS_ATTR_3GPP2_SERVICEOPTION 16 #define RADIUS_ATTR_3GPP2_FORTRAFFICTYPE 17 #define RADIUS_ATTR_3GPP2_REVTRAFFICTYPE 18 #define RADIUS_ATTR_3GPP2_FUNDFRAMESIZE 19 #define RADIUS_ATTR_3GPP2_FORFUNDRC 20 #define RADIUS_ATTR_3GPP2_REVFUNDRC 21 #define RADIUS_ATTR_3GPP2_IPTECHNOLOGY 22 #define RADIUS_ATTR_3GPP2_COMPTUNNELIND 23 #define RADIUS_ATTR_3GPP2_RELEASEINDICATOR 24 #define RADIUS_ATTR_3GPP2_BADPPPFRAMECOUNT 25 #define RADIUS_ATTR_3GPP2_NUMACTIVETRANS 30 #define RADIUS_ATTR_3GPP2_SDBOCTETCNTTERM 31 #define RADIUS_ATTR_3GPP2_SDBOCTETCNTORIG 32 #define RADIUS_ATTR_3GPP2_NUMSDBTERM 33 #define RADIUS_ATTR_3GPP2_NUMSDBORIG 34 #define RADIUS_ATTR_3GPP2_IPQOS 36 #define RADIUS_ATTR_3GPP2_AIRLINKQOS 39 #define RADIUS_ATTR_3GPP2_AIRLINKRECTYPE 40 #define RADIUS_ATTR_3GPP2_RPSESSIONID 41 #define RADIUS_ATTR_3GPP2_AIRLINKSEQNO 42 #define RADIUS_ATTR_3GPP2_NUMHDLCBYTESRECVD 43 #define RADIUS_ATTR_3GPP2_CORRELATIONID 44 #define RADIUS_ATTR_3GPP2_MOBILEORIGTERMIND 45 #define RADIUS_ATTR_3GPP2_INBMIPOCTETCNT 46 #define RADIUS_ATTR_3GPP2_OUTMIPOCTETCNT 47 #define RADIUS_ATTR_3GPP2_SESSIONCONTINUE 48 #define RADIUS_ATTR_3GPP2_ACTIVETIME 49 #define RADIUS_ATTR_3GPP2_DCCHFRAMEFORMAT 50 #define RADIUS_ATTR_3GPP2_SESSIONBEGIN 51 #define RADIUS_ATTR_3GPP2_SOURCEIPV6ADDR 52 #define RADIUS_ATTR_3GPP2_ESN 52 #define RADIUS_ATTR_3GPP2_IPV6PDSNADDR 53 #define RADIUS_ATTR_3GPP2_DNSUPDATEREQD 54 /* * 3GPP2 vendor specific attribute map */ strmap_t radius_attr_3gpp2_map[] = { { RADIUS_ATTR_3GPP2_IKEPSKREQUEST, "IKE preshared key request" }, { RADIUS_ATTR_3GPP2_SECURITYLEVEL, "security level" }, { RADIUS_ATTR_3GPP2_IKEPSK, "IKE preshared key" }, { RADIUS_ATTR_3GPP2_REVERSETUNNEL, "reverse tunnel" }, { RADIUS_ATTR_3GPP2_HAADDR, "home agent address" }, { RADIUS_ATTR_3GPP2_SERVINGPCFADDR, "serving PCF address" }, { RADIUS_ATTR_3GPP2_BSID, "BSID" }, { RADIUS_ATTR_3GPP2_USERZONE, "user zone" }, { RADIUS_ATTR_3GPP2_FORWARDMUX, "forward MUX option" }, { RADIUS_ATTR_3GPP2_REVERSEMUX, "reverse MUX option" }, { RADIUS_ATTR_3GPP2_MNHAKEY, "MN-HA key" }, { RADIUS_ATTR_3GPP2_MNHAKEYREQUEST, "MN-HA key request" }, { RADIUS_ATTR_3GPP2_SERVICEOPTION, "service option" }, { RADIUS_ATTR_3GPP2_FORTRAFFICTYPE, "forward fundamental traffic type" }, { RADIUS_ATTR_3GPP2_REVTRAFFICTYPE, "reverse fundamental traffic type" }, { RADIUS_ATTR_3GPP2_FUNDFRAMESIZE, "fundamental frame size" }, { RADIUS_ATTR_3GPP2_FORFUNDRC, "forward fundamental RC" }, { RADIUS_ATTR_3GPP2_REVFUNDRC, "reverse fundamental RC" }, { RADIUS_ATTR_3GPP2_IPTECHNOLOGY, "IP technology" }, { RADIUS_ATTR_3GPP2_COMPTUNNELIND, "compulsory tunnel indicator" }, { RADIUS_ATTR_3GPP2_RELEASEINDICATOR, "release indicator" }, { RADIUS_ATTR_3GPP2_BADPPPFRAMECOUNT, "bad PPP frame count" }, { RADIUS_ATTR_3GPP2_NUMACTIVETRANS, "number of active transitions" }, { RADIUS_ATTR_3GPP2_SDBOCTETCNTTERM, "SDB octet count terminating" }, { RADIUS_ATTR_3GPP2_SDBOCTETCNTORIG, "SDB octet count originating" }, { RADIUS_ATTR_3GPP2_NUMSDBTERM, "number of SDBs terminating" }, { RADIUS_ATTR_3GPP2_NUMSDBORIG, "number of SDBs originating" }, { RADIUS_ATTR_3GPP2_IPQOS, "IP QoS" }, { RADIUS_ATTR_3GPP2_AIRLINKQOS, "airlink QoS" }, { RADIUS_ATTR_3GPP2_AIRLINKRECTYPE, "airlink record type" }, { RADIUS_ATTR_3GPP2_RPSESSIONID, "RP session ID" }, { RADIUS_ATTR_3GPP2_AIRLINKSEQNO, "airlink sequence number" }, { RADIUS_ATTR_3GPP2_NUMHDLCBYTESRECVD,"number of HDLC bytes received" }, { RADIUS_ATTR_3GPP2_CORRELATIONID, "correlation ID" }, { RADIUS_ATTR_3GPP2_MOBILEORIGTERMIND,"mobile orig/term indicator" }, { RADIUS_ATTR_3GPP2_INBMIPOCTETCNT, "inbound mobile IP octet count" }, { RADIUS_ATTR_3GPP2_OUTMIPOCTETCNT, "outbound mobile IP octet count" }, { RADIUS_ATTR_3GPP2_SESSIONCONTINUE, "session continue" }, { RADIUS_ATTR_3GPP2_SOURCEIPV6ADDR, "source IPv6 address" }, { RADIUS_ATTR_3GPP2_ESN, "ESN" }, { RADIUS_ATTR_3GPP2_IPV6PDSNADDR, "IPv6 DNS address" }, { RADIUS_ATTR_3GPP2_DNSUPDATEREQD, "DNS update required" }, { 0, ""} }; extern struct arg_t * my_args; extern strmap_t iana_enterprise_map[]; extern strmap_t radius_attr_map[]; /*---------------------------------------------------------------------------- ** ** dump_radius_3gpp2() ** ** Parse and dump a vendor specific RADIUS attribute. ** Returns the number of bytes read or -1 on error. ** **---------------------------------------------------------------------------- */ void dump_radius_3gpp2(packet_t * pkt, u_int8_t type, u_int8_t length) { u_int8_t vendortype; u_int8_t vendorlength; /* Get the vendor type and length */ if (get_packet_bytes((u_int8_t *) &vendortype, pkt, 1) == 0) return; if (get_packet_bytes((u_int8_t *) &vendorlength, pkt, 1) == 0) return; /* Display everything so far */ if (my_args->m) { display_minimal_string(map2str(radius_attr_map, type)); display_minimal_string("["); display_minimal_string(map2str(iana_enterprise_map, IANA_ENTERPRISE_3GPP2)); display_minimal_string("]: "); display_minimal_string(map2str(radius_attr_3gpp2_map, vendortype)); display_minimal_string(" "); } else { display_strmap("Attribute type", type, radius_attr_map); display(" Length", &length, 1, DISP_DEC); display_strmap(" Vendor", IANA_ENTERPRISE_3GPP2, iana_enterprise_map); display_strmap(" Type", vendortype, radius_attr_3gpp2_map); display(" Length", &vendorlength, 1, DISP_DEC); } /* Based on the vendor type, decode the data field */ switch(vendortype) { /* This is for attributes that are 4 byte integers */ case RADIUS_ATTR_3GPP2_IKEPSKREQUEST: case RADIUS_ATTR_3GPP2_SECURITYLEVEL: case RADIUS_ATTR_3GPP2_REVERSETUNNEL: case RADIUS_ATTR_3GPP2_USERZONE: case RADIUS_ATTR_3GPP2_FORWARDMUX: case RADIUS_ATTR_3GPP2_REVERSEMUX: case RADIUS_ATTR_3GPP2_MNHAKEYREQUEST: case RADIUS_ATTR_3GPP2_SERVICEOPTION: case RADIUS_ATTR_3GPP2_FORTRAFFICTYPE: case RADIUS_ATTR_3GPP2_REVTRAFFICTYPE: case RADIUS_ATTR_3GPP2_FUNDFRAMESIZE: case RADIUS_ATTR_3GPP2_FORFUNDRC: case RADIUS_ATTR_3GPP2_REVFUNDRC: case RADIUS_ATTR_3GPP2_IPTECHNOLOGY: case RADIUS_ATTR_3GPP2_COMPTUNNELIND: case RADIUS_ATTR_3GPP2_BADPPPFRAMECOUNT: { u_int32_t value; /* Get the value */ if (get_packet_bytes((u_int8_t *) &value, pkt, 4) == 0) return; /* Conversion */ value = ntohl(value); /* Display it */ if (my_args->m) display_minimal((u_int8_t *) &value, 4, DISP_DEC); else display(" Value", (u_int8_t *) &value, 4, DISP_DEC); } break; case RADIUS_ATTR_3GPP2_HAADDR: case RADIUS_ATTR_3GPP2_SERVINGPCFADDR: { u_int32_t addr; if (get_packet_bytes((u_int8_t *) &addr, pkt, 4) == 0) return; /* Display */ if (my_args->m) display_minimal((u_int8_t *) &addr, 4, DISP_DOTTEDDEC); else display(" Address", (u_int8_t *) &addr, 4, DISP_DOTTEDDEC); } break; /* This is for attributes that are hex strings */ case RADIUS_ATTR_3GPP2_IKEPSK: default: { u_int8_t * generic_value; /* Allocate memory for the value then get it */ generic_value = my_malloc(vendorlength-2); if (get_packet_bytes(generic_value, pkt, vendorlength-2) == 0) return; /* Display */ if (my_args->m) display_minimal(generic_value, vendorlength-2, DISP_HEX); else display(" Value", generic_value, vendorlength-2, DISP_HEX_MULTILINE); /* Free the memory of the value */ my_free(generic_value); } break; } /* switch */ } ipgrab-0.9.10/src/radius_3gpp2.h0000644000175000001440000000232407377022314015523 0ustar farooqusers/**************************************************************************** ** File: radius_3gpp2.h ** ** Author: Mike Borella ** ** Comments: Header file for RADIUS 3GPP2 vendor specific attribute support. ** ** $Id: radius_3gpp2.h,v 1.1 2001/11/21 22:03:56 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef RADIUS_3GPP2_H #define RADIUS_3GPP2_H #include "global.h" #include "local.h" void dump_radius_3gpp2(packet_t *, u_int8_t, u_int8_t); #endif ipgrab-0.9.10/src/raw.c0000644000175000001440000000317307304522724014010 0ustar farooqusers/**************************************************************************** ** ** File: raw.c ** ** Author: Mike Borella ** ** Comments: Dump raw data link (IP) packets ** ** $Id: raw.c,v 1.5 2001/05/28 19:24:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "raw.h" #include "ip_protocols.h" extern struct arg_t *my_args; /*---------------------------------------------------------------------------- ** ** dump_raw() ** ** Process packets from the DLT_RAW interface type ** **---------------------------------------------------------------------------- */ void dump_raw(packet_t *pkt) { /* Set the layer */ set_layer(LAYER_DATALINK); /* * Dump header announcement */ if (my_args->m) { /* raw header announcement need not be displayed */ } else { display_header_banner_ts("Raw IP", pkt->timestamp); } dump_ip(pkt); } ipgrab-0.9.10/src/raw.h0000644000175000001440000000216107153266450014014 0ustar farooqusers/**************************************************************************** ** ** File: raw.h ** ** Author: Mike Borella ** ** Comments: Dump raw data link packets ** ** $Id: raw.h,v 1.3 2000/08/30 20:23:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef RAW_H #define RAW_H #include "global.h" #include "local.h" void dump_raw(packet_t *); #endif ipgrab-0.9.10/src/rip.c0000644000175000001440000001550507414717761014024 0ustar farooqusers/**************************************************************************** ** File: rip.c ** ** Author: Mike Borella ** ** Comments: Dump RIP header information. ** ** $Id: rip.c,v 1.14 2002/01/03 00:04:01 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "global.h" #include "rip.h" #define HOLDER_SIZE 64 /* * RIP command map */ strmap_t rip_command_map [] = { { RIP_CMD_RQ, "request" }, { RIP_CMD_RP, "reply" }, { RIP_CMD_POLL, "poll" }, { RIP_CMD_POLL_ENTRY, "poll entry" }, { 0, "" } }; extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** dump_rip() ** ** Parse RIP packet and dump fields ** **---------------------------------------------------------------------------- */ void dump_rip(packet_t *pkt) { ripv1_header_t ripv1; ripv1_route_header_t ripv1_route; ripv2_header_t ripv2; ripv2_route_header_t ripv2_route; ripv2_auth_header_t ripv2_auth; char holder[HOLDER_SIZE]; u_int16_t address_family; int route_count; /* Set the layer */ set_layer(LAYER_APPLICATION); /* * Look at the version to determine whether to use v1 or v2 */ if (look_packet_bytes((u_int8_t *) &ripv1, pkt, sizeof(ripv1_header_t)) == 0) return; if (ripv1.version == 1) { /* RIP v1 processing here */ /* * Get the RIP v1 static header */ if (get_packet_bytes((u_int8_t *) &ripv1, pkt, sizeof(ripv1_header_t)) == 0) return; /* * Dump header */ if (my_args->m) { display_minimal_string("| RIPv1 "); display_minimal_string(map2str(rip_command_map, ripv1.command)); display_minimal_string(" "); } else { /* announcement */ display_header_banner("RIPv1 Header"); snprintf(holder, HOLDER_SIZE, "%d (%s)", ripv1.command, map2str(rip_command_map, ripv1.command)); display_string("Command", holder); display("Version", (u_int8_t *) &ripv1.version, 1, DISP_DEC); display("MBZ", (u_int8_t *) &ripv1.mbz, 2, DISP_DEC); } /* * Do the individual routes. */ route_count = 0; while(1) { if (get_packet_bytes((u_int8_t *) &ripv1_route, pkt, sizeof(ripv1_route_header_t)) == 0) break; /* * Conversions */ ripv1_route.addr_fam = ntohs(ripv1_route.addr_fam); ripv1_route.metric = ntohl(ripv1_route.metric); /* * Dump route header */ if (my_args->m) { /* for minimal mode, we'll just count the routes */ route_count++; } else { display("Address family", (u_int8_t *) &ripv1_route.addr_fam, 2, DISP_DEC); display("MBZ", (u_int8_t *) &ripv1_route.mbz1, 2, DISP_DEC); display_ipv4("IP address", (u_int8_t *) &ripv1_route.ipaddr); display("MBZ", (u_int8_t *) &ripv1_route.mbz2, 8, DISP_HEX); display("Metric", (u_int8_t *) &ripv1_route.metric, 4, DISP_DEC); } } } else { /* RIP v2 processing here */ /* * Get the RIP v2 static header */ if (get_packet_bytes((u_int8_t *) &ripv2, pkt, sizeof(ripv2_header_t)) == 0) return; /* * Conversions */ ripv2.domain = ntohs(ripv2.domain); /* * Dump header */ if (my_args->m) { display_minimal_string("| RIPv2 "); display_minimal_string(map2str(rip_command_map, ripv2.command)); display_minimal_string(" "); } else { /* announcement */ display_header_banner("RIPv2 Header"); snprintf(holder, HOLDER_SIZE, "%d (%s)", ripv2.command, map2str(rip_command_map, ripv2.command)); display_string("Command", holder); display("Version", (u_int8_t *) &ripv2.version, 1, DISP_DEC); display("Domain", (u_int8_t *) &ripv2.domain, 2, DISP_DEC); } /* * Do the individual routes. * First look at the address family to determine the header type. */ route_count = 0; while (1) { if (look_packet_bytes((u_int8_t *) &address_family, pkt, 2) == 0) break;; /* * If its an auth header, deal with it - otherwise its a regular * route header */ if (address_family == 0xffff) { if (get_packet_bytes((u_int8_t *) &ripv2_auth, pkt, sizeof(ripv2_auth_header_t)) == 0) return; /* * Conversions */ ripv2_auth.addr_fam = ntohs(ripv2_auth.addr_fam); ripv2_auth.type = ntohs(ripv2_auth.type); /* * Dump auth header */ if (my_args->m) { /* not sure what to do here... */ } else { display("Address family", (u_int8_t *) &ripv2_auth.addr_fam, 2, DISP_DEC); display("Type", (u_int8_t *) &ripv2_auth.type, 2, DISP_DEC); display_string("Password", ripv2_auth.passwd); } } else { if (get_packet_bytes((u_int8_t *) &ripv2_route, pkt, sizeof(ripv2_route_header_t)) == 0) return; /* * Conversions */ ripv2_route.addr_fam = ntohs(ripv2_route.addr_fam); ripv2_route.route_tag = ntohs(ripv2_route.route_tag); ripv2_route.metric = ntohl(ripv2_route.metric); /* * Dump route header */ if (my_args->m) { /* just count the routes for minimal mode */ route_count++; } else { display("Address family", (u_int8_t *) &ripv2_route.addr_fam, 2, DISP_DEC); display("Route tag", (u_int8_t *) &ripv2_route.route_tag, 2, DISP_DEC); display_ipv4("IP address", (u_int8_t *) &ripv2_route.ipaddr); display_ipv4("Netmask", (u_int8_t *) &ripv2_route.netmask); display_ipv4("Next hop", (u_int8_t *) &ripv2_route.next_hop); display("Metric", (u_int8_t *) &ripv2_route.metric, 4, DISP_DEC); } } } /* while */ } /* display routes for minimal mode */ if (my_args->m) { display_minimal((u_int8_t *) &route_count, 4, DISP_DEC); display_minimal_string(" routes "); } } ipgrab-0.9.10/src/rip.h0000644000175000001440000000421310637736556014027 0ustar farooqusers/**************************************************************************** ** File: rip.h ** ** Author: Mike Borella ** ** Comments: Structure of RIP packets ** ** $Id: rip.h,v 1.6 2007/06/25 13:04:46 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef RIP_H #define RIP_H #include "global.h" #include "local.h" /* * RIP commands */ #define RIP_CMD_RQ 1 #define RIP_CMD_RP 2 #define RIP_CMD_POLL 5 #define RIP_CMD_POLL_ENTRY 6 /* * Static part of RIP v1 header */ typedef struct ripv1_header { u_int8_t command; u_int8_t version; u_int16_t mbz; } ripv1_header_t; /* * RIP v1 route header */ typedef struct ripv1_route_header { u_int16_t addr_fam; u_int16_t mbz1; u_int32_t ipaddr; u_int8_t mbz2[8]; u_int32_t metric; } ripv1_route_header_t; /* * Static part of RIP v2 header */ typedef struct ripv2_header { u_int8_t command; u_int8_t version; u_int16_t domain; } ripv2_header_t; /* * RIP v2 route header */ typedef struct ripv2_route_header { u_int16_t addr_fam; u_int16_t route_tag; u_int32_t ipaddr; u_int32_t netmask; u_int32_t next_hop; u_int32_t metric; } ripv2_route_header_t; /* * RIP v2 authentication header */ typedef struct ripv2_auth_header { u_int16_t addr_fam; u_int16_t type; u_int8_t passwd[16]; } ripv2_auth_header_t; void dump_rip(packet_t *pkt); #endif ipgrab-0.9.10/src/ripng.c0000644000175000001440000000662610530527426014343 0ustar farooqusers/**************************************************************************** ** File: ripng.c ** ** Author: Mike Borella ** ** Comments: Dump RIPng header information. ** ** $Id: ripng.c,v 1.10 2006/11/21 07:47:34 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "global.h" #include "ripng.h" #define HOLDER_SIZE 64 /* * RIPng command map */ strmap_t ripng_command_map [] = { { RIPNG_CMD_RQ, "request" }, { RIPNG_CMD_RP, "reply" }, { 0, "" } }; extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** dump_ripng() ** ** Parse RIPng packet and dump fields ** **---------------------------------------------------------------------------- */ void dump_ripng(packet_t *pkt) { ripng_header_t ripng; ripng_route_header_t ripng_route; char holder[HOLDER_SIZE]; int route_count; /* Set the layer */ set_layer(LAYER_APPLICATION); /* * Get the RIPng static header */ if (get_packet_bytes((u_int8_t *) &ripng, pkt, sizeof(ripng_header_t)) == 0) return; /* * Dump header */ if (my_args->m) { display_minimal_string("| RIPng "); display_minimal_string(map2str(ripng_command_map, ripng.command)); display_minimal_string(" "); } else { /* announcement */ display_header_banner("RIPng Header"); snprintf(holder, HOLDER_SIZE, "%d (%s)", ripng.command, map2str(ripng_command_map, ripng.command)); display_string("Command", holder); display("Version", (u_int8_t *) &ripng.version, 1, DISP_DEC); display("MBZ", (u_int8_t *) &ripng.mbz, 2, DISP_DEC); } /* * Do the individual routes. */ route_count = 0; while (1) { if (get_packet_bytes((u_int8_t *) &ripng_route, pkt, sizeof(ripng_route_header_t)) == 0) break; /* * Conversions */ ripng_route.route_tag = ntohs(ripng_route.route_tag); /* * Dump route header */ if (my_args->m) { /* just count routes in minimal mode */ route_count++; } else { display_ipv6("Address", (u_int8_t *) &ripng_route.address); display("Route tag", (u_int8_t *) &ripng_route.route_tag, 2, DISP_DEC); display("Netmask", (u_int8_t *) &ripng_route.netmask, 1, DISP_DEC); display("Metric", (u_int8_t *) &ripng_route.metric, 1, DISP_DEC); } } /* while */ /* display route count in minimal mode */ if (my_args->m) { display_minimal((u_int8_t *) &route_count, 4, DISP_DEC); display_minimal_string(" routes "); } } ipgrab-0.9.10/src/ripng.h0000644000175000001440000000304510637736725014354 0ustar farooqusers/**************************************************************************** ** File: ripng.h ** ** Author: Mike Borella ** ** Comments: Structure of RIPng packets ** ** $Id: ripng.h,v 1.6 2007/06/25 13:06:29 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef RIPNG_H #define RIPNG_H #include "global.h" #include "local.h" /* * RIP commands */ #define RIPNG_CMD_RQ 1 #define RIPNG_CMD_RP 2 /* * Static part of RIPng header */ typedef struct ripng_header { u_int8_t command; u_int8_t version; u_int16_t mbz; } ripng_header_t; /* * RIPng route header */ typedef struct ripng_route_header { u_int8_t address[16]; u_int16_t route_tag; u_int8_t netmask; u_int8_t metric; } ripng_route_header_t; void dump_ripng(packet_t *pkt); #endif ipgrab-0.9.10/src/rsip.c0000644000175000001440000001022507153031046014162 0ustar farooqusers/**************************************************************************** ** File: rsip.c ** ** Author: Mike Borella ** ** Comments: Dump RSIP header information ** *****************************************************************************/ #include #include "global.h" #include "addrtoname.h" #include "rsip.h" /* * RSIP parameters */ #define RSIP_PARAM_ADDR_REQ 0 #define RSIP_PARAM_NUM_PORTS 1 #define RSIP_PARAM_ADDR 2 #define RSIP_PARAM_PORT_RANGE 3 #define RSIP_PARAM_LEASE_TIME 4 #define RSIP_PARAM_ERROR 5 #define RSIP_PARAM_CLIENT_ID 6 #define RSIP_PARAM_BIND_ID 7 #define RSIP_PARAM_MESSAGE_ID 8 #define RSIP_PARAM_TUNNEL_TYPE 9 #define RSIP_PARAM_METHOD 10 #define RSIP_PARAM_VENDOR 11 #define RSIP_MESSAGE_ERROR_RESP 1 #define RSIP_MESSAGE_REGISTER_REQ 2 #define RSIP_MESSAGE_REGISTER_RESP 3 #define RSIP_MESSAGE_DE_REGISTER_REQ 4 #define RSIP_MESSAGE_DE_REGISTER_RESP 5 #define RSIP_MESSAGE_ASSIGN_REQ_ADDR 6 #define RSIP_MESSAGE_ASSIGN_REQ_PORT 7 #define RSIP_MESSAGE_ASSIGN_REQ_EXT 8 #define RSIP_MESSAGE_ASSIGN_RESP_ADDR 9 #define RSIP_MESSAGE_ASSIGN_RESP_PORT 10 #define RSIP_MESSAGE_ASSIGN_RESP_EXT 11 #define RSIP_MESSAGE_FREE_REQ 12 #define RSIP_MESSAGE_FREE_RESP 13 #define RSIP_MESSAGE_QUERY_REQ 14 #define RSIP_MESSAGE_QUERY_RESP 15 #define RSIP_MESSAGE_DEALLOCATE 16 #define RSIP_MESSAGE_OK 17 #define RSIP_MESSAGE_LISTEN_REQ 18 #define RSIP_MESSAGE_LISTEN_RESP 19 #define RSIP_MESSAGE_LAST 20 /* not a real message, an EOL ptr */ #define PARAM_LEN 32 /* * Map parameters to strings */ char *rsip_param[] = { "address request", "number of ports", "address", "port range", "lease time", "error", "client ID", "bind ID", "message ID", "tunnel type", "method", "vendor specific" }; /* * Map messages to string descriptions */ char *rsip_messages[] = { "", "error response", "register request", "register response", "deregister request", "deregister response", "assign request address", "assign request port", "assign request extension", "assign response address", "assign response port", "assign response extension", "free request", "free response", "query request", "query response", "deallocate", "ok", "listen request", "listen response" }; /*---------------------------------------------------------------------------- ** ** dump_rsip_param() ** ** Parse and dump an RSIP parameter ** **---------------------------------------------------------------------------- */ int dump_rsip_param(u_char *p) { u_int16_t len; printf("Parameter: %s\n", rsip_param[(int) *p]); memcpy((void *) &len, (void *) p+1, 2); len = ntohs(len); if (p + len + 3> p+10) /* fix me!!! */ { printf("Bad parameter length"); return -1; } printf(" Length: %d\n", len); switch((int ) *p) { case RSIP_PARAM_CLIENT_ID: { u_int32_t clientid; memcpy((void *) &clientid, (void *) p+3, 4); printf(" Client ID: %d\n", ntohl(clientid)); } break; case RSIP_PARAM_MESSAGE_ID: { u_int32_t messageid; memcpy((void *) &messageid, (void *) p+3, 4); printf(" Message ID: %d\n", ntohl(messageid)); } break; } return len + 3; } /*---------------------------------------------------------------------------- ** ** dump_rsip() ** ** Parse RSIP packet and dump parameters ** **---------------------------------------------------------------------------- */ void dump_rsip(u_char *bp, int length) { u_char *ep = bp + length; u_char *p; int message; int len; /* * Grab the message type */ message = *bp; /* * Print it */ printf("-----------------------------------------------------------------\n"); printf(" RSIP Packet\n"); printf("-----------------------------------------------------------------\n"); printf("Message type: %s\n", rsip_messages[message]); /* * Print parameters */ p = bp+1; while(p < ep) { len = dump_rsip_param(p); if (len == -1) break; p = p + len; } } ipgrab-0.9.10/src/rsip.h0000644000175000001440000000052607104345556014204 0ustar farooqusers/**************************************************************************** ** ** File: rsip.h ** ** Author: Mike Borella ** ** Comments: RSIP header info ** *****************************************************************************/ /* * RSIP port number */ #define RSIP_PORT 4455 void dump_rsip(u_char *bp, int length); ipgrab-0.9.10/src/rsvp.c0000644000175000001440000000616210637731453014216 0ustar farooqusers/**************************************************************************** ** File: rsvp.c ** ** Author: Mike Borella ** ** Comments: ** ** $Id: rsvp.c,v 1.4 2007/06/25 12:20:59 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "global.h" #include "rsvp.h" extern struct arg_t *my_args; /* * Types of RSVP messages */ #define RSVP_MSG_PATH 1 #define RSVP_MSG_RESV 2 #define RSVP_MSG_PATHERR 3 #define RSVP_MSG_RESVERR 4 #define RSVP_MSG_PATHTEAR 5 #define RSVP_MSG_RESVTEAR 6 #define RSVP_MSG_RESVCONF 7 /* * RSVP message type map */ strmap_t rsvp_msgtype_map [] = { { RSVP_MSG_PATH, "Path" }, { RSVP_MSG_RESV, "Resv" }, { RSVP_MSG_PATHERR, "PathErr" }, { RSVP_MSG_RESVERR, "ResvErr" }, { RSVP_MSG_PATHTEAR, "PathTear" }, { RSVP_MSG_RESVTEAR, "ResvTear" }, { RSVP_MSG_RESVCONF, "ResvConf" } }; /*---------------------------------------------------------------------------- ** ** dump_rsvp() ** ** Displays RSVP packets ** **---------------------------------------------------------------------------- */ void dump_rsvp(packet_t *pkt) { rsvp_header_t rsvp; u_int8_t version; u_int8_t flags; /* Set the layer */ set_layer(LAYER_APPLICATION); /* Stats accounting */ stats_update(STATS_IP); /* Get the common header */ if (get_packet_bytes((u_int8_t *) &rsvp, pkt, sizeof(rsvp_header_t)) == 0) return; /* Conversions */ version = rsvp.version; flags = rsvp.flags; rsvp.checksum = ntohs(rsvp.checksum); rsvp.length = ntohs(rsvp.length); /* Dump the fields */ if (!my_args->m) { display_header_banner("RSVP Header"); display("Version", (u_int8_t *) &version, 1, DISP_DEC); display("Flags", (u_int8_t *) &flags, 1, DISP_HEX); display_strmap("Message type", rsvp.msg_type, rsvp_msgtype_map); display("Checksum", (u_int8_t *) &rsvp.checksum, 2, DISP_DEC); display("Send TTL", (u_int8_t *) &rsvp.send_ttl, 1, DISP_DEC); display("Reserved", (u_int8_t *) &rsvp.reserved, 1, DISP_DEC); display("Length", (u_int8_t *) &rsvp.length, 2, DISP_DEC); } else { /* Something for the minimal mode as well. */ display_minimal_string ( " |RSVPv" ); display_minimal ( (u_int8_t *) &version, 1, DISP_DEC ); display_minimal_string ( " " ); display_minimal_string ( map2str ( rsvp_msgtype_map, rsvp.msg_type ) ); } } ipgrab-0.9.10/src/rsvp.h0000644000175000001440000000263607257726274014236 0ustar farooqusers/**************************************************************************** ** File: rsvp.h ** ** Author: Mike Borella ** ** Comments: ** ** $Id: rsvp.h,v 1.1 2001/03/26 20:55:24 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef RSVP_H #define RSVP_H #include "global.h" #include "local.h" /* * RSVP common header */ typedef struct rsvp_header { #if defined(WORDS_BIGENDIAN) u_int8_t version:4, flags:4; #else u_int8_t flags:4, version:4; #endif u_int8_t msg_type; u_int16_t checksum; u_int8_t send_ttl; u_int8_t reserved; u_int16_t length; } rsvp_header_t; void dump_rsvp(packet_t *); #endif ipgrab-0.9.10/src/rtcp.c0000644000175000001440000003246710637730013014172 0ustar farooqusers/**************************************************************************** ** File: rtcp.c ** ** Author: Mike Borella ** ** Comments: Dump RTCP header information. ** ** $Id: rtcp.c,v 1.4 2007/06/25 12:07:39 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "rtcp.h" /* * Static part of RTCP header * * 0 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |V=2|P| RC | PT | length | header * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * */ typedef struct rtcp_header { #if defined(WORDS_BIGENDIAN) u_int8_t version:2, padding:1, rc_sc:5; #else u_int8_t rc_sc:5, padding:1, version:2; #endif u_int8_t packet_type; u_int16_t length; } rtcp_header_t; /* * RTCP SR packet type sender info portion * * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | SSRC of sender | * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ * | NTP timestamp, most significant word | sender * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ info * | NTP timestamp, least significant word | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | RTP timestamp | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | sender's packet count | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | sender's octet count | * +---------------------------------------------------------------+ */ typedef struct rtcp_sr_senderinfo { u_int32_t sender_ssrc; u_int32_t timestamp_MSW; u_int32_t timestamp_LSW; u_int32_t timestamp_RTP; u_int32_t sender_pkt_cnt; u_int32_t sender_octet_cnt; } rtcp_sr_senderinfo_t; /* * RTCP SR report block * * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ * | SSRC_1 (SSRC of first source) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | fraction lost | cumulative number of packets lost | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | extended highest sequence number received | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | interarrival jitter | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | last SR (LSR) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | delay since last SR (DLSR) | * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ */ typedef struct rtcp_sr_reportblock { u_int32_t ssrc; u_int8_t frac_lost; u_int8_t packets_lost[3]; u_int32_t ext_seqno_recvd; u_int32_t jitter; u_int32_t lsr; u_int32_t delay_since_lsr; } rtcp_sr_reportblock_t; /* * RTCP packet type definitions */ #define RTCP_PACKETTYPE_SR 200 #define RTCP_PACKETTYPE_RR 201 #define RTCP_PACKETTYPE_SDES 202 #define RTCP_PACKETTYPE_BYE 203 #define RTCP_PACKETTYPE_APP 204 /* * RTCP payload type map */ strmap_t rtcp_packettype_map[] = { { RTCP_PACKETTYPE_SR, "sender report" }, { RTCP_PACKETTYPE_RR, "receiver report" }, { RTCP_PACKETTYPE_SDES, "source description" }, { RTCP_PACKETTYPE_BYE, "bye" }, { RTCP_PACKETTYPE_APP, "application" }, { 0, ""} }; extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** dump_rtcp_sr() ** ** Parse RTCP sender report fields ** **---------------------------------------------------------------------------- */ void dump_rtcp_sr(packet_t * pkt, int count) { rtcp_sr_senderinfo_t senderinfo; rtcp_sr_reportblock_t reportblock; int reports_seen; /* Get the sender info */ if (get_packet_bytes((u_int8_t *) &senderinfo, pkt, sizeof(senderinfo)) == 0) return; /* Conversions */ senderinfo.sender_ssrc = ntohl(senderinfo.sender_ssrc); senderinfo.timestamp_MSW = ntohl(senderinfo.timestamp_MSW); senderinfo.timestamp_LSW = ntohl(senderinfo.timestamp_LSW); senderinfo.timestamp_RTP = ntohl(senderinfo.timestamp_RTP); senderinfo.sender_pkt_cnt = ntohl(senderinfo.sender_pkt_cnt); senderinfo.sender_octet_cnt = ntohl(senderinfo.sender_octet_cnt); /* Display */ if (my_args->m) { display_minimal((u_int8_t *) &senderinfo.sender_ssrc, 4, DISP_DEC); display_minimal_string(" "); } else { display("Sender SSRC", (u_int8_t *) &senderinfo.sender_ssrc, 4, DISP_DEC); display("Timestamp MSW", (u_int8_t *) &senderinfo.timestamp_MSW, 4, DISP_DEC); display("Timestamp LSW", (u_int8_t *) &senderinfo.timestamp_LSW, 4, DISP_DEC); display("RTP timestamp", (u_int8_t *) &senderinfo.timestamp_RTP, 4, DISP_DEC); display("Sender packet count", (u_int8_t *) &senderinfo.sender_pkt_cnt, 4, DISP_DEC); display("Sender octet count", (u_int8_t *) &senderinfo.sender_octet_cnt, 4, DISP_DEC); } /* Loop over report blocks */ reports_seen = 0; while(reports_seen < count) { /* Get the report block */ if (get_packet_bytes((u_int8_t *) &reportblock, pkt, sizeof(reportblock)) == 0) break; /* Conversions */ reportblock.ssrc = ntohl(reportblock.ssrc); reportblock.ext_seqno_recvd = ntohl(reportblock.ext_seqno_recvd); reportblock.jitter = ntohl(reportblock.jitter); reportblock.lsr = ntohl(reportblock.lsr); reportblock.delay_since_lsr = ntohl(reportblock.delay_since_lsr); reverse_byte_order ( ( u_int8_t * ) &reportblock.packets_lost, 3 ); /* Display */ if (my_args->m) { display_minimal((u_int8_t *) &reportblock.ssrc, 4, DISP_DEC); display_minimal_string(" "); } else { display("SSRC", (u_int8_t *) &reportblock.ssrc, 4, DISP_DEC); display(" Fraction lost", (u_int8_t *) &reportblock.frac_lost, 1, DISP_DEC); display(" Packets lost", (u_int8_t *) &reportblock.packets_lost, 3, DISP_DEC); display(" Highest seqno received", (u_int8_t *) &reportblock.ext_seqno_recvd, 4, DISP_DEC); display(" Jitter", (u_int8_t *) &reportblock.jitter, 4, DISP_DEC); display(" Last SR", (u_int8_t *) &reportblock.lsr, 4, DISP_DEC); display(" Delay since last SR", (u_int8_t *) &reportblock.delay_since_lsr, 4, DISP_DEC); } reports_seen ++; } } /*---------------------------------------------------------------------------- ** ** dump_rtcp_rr() ** ** Parse RTCP receiver report fields ** **---------------------------------------------------------------------------- */ void dump_rtcp_rr(packet_t * pkt, int count) { rtcp_sr_reportblock_t reportblock; int reports_seen; u_int32_t ssrc; /* Get the SSRC */ if (get_packet_bytes((u_int8_t *) &ssrc, pkt, 4) == 0) return; /* Conversions */ ssrc = ntohl(ssrc); /* Display */ if (my_args->m) { display_minimal((u_int8_t *) &ssrc, 4, DISP_DEC); display_minimal_string(" "); } else display("SSRC", (u_int8_t *) &ssrc, 4, DISP_DEC); /* Loop over report blocks */ reports_seen = 0; while(reports_seen < count) { /* Get the report block */ if (get_packet_bytes((u_int8_t *) &reportblock, pkt, sizeof(reportblock)) == 0) break; /* Conversions */ reportblock.ssrc = ntohl(reportblock.ssrc); reportblock.ext_seqno_recvd = ntohl(reportblock.ext_seqno_recvd); reportblock.jitter = ntohl(reportblock.jitter); reportblock.lsr = ntohl(reportblock.lsr); reportblock.delay_since_lsr = ntohl(reportblock.delay_since_lsr); reverse_byte_order ( ( u_int8_t * ) &reportblock.packets_lost, 3 ); /* Display */ if (my_args->m) { display_minimal((u_int8_t *) &reportblock.ssrc, 4, DISP_DEC); display_minimal_string(" "); } else { display("SSRC", (u_int8_t *) &reportblock.ssrc, 4, DISP_DEC); display(" Fraction lost", (u_int8_t *) &reportblock.frac_lost, 1, DISP_DEC); display(" Packets lost", (u_int8_t *) &reportblock.packets_lost, 3, DISP_DEC); display(" Highest seqno received", (u_int8_t *) &reportblock.ext_seqno_recvd, 4, DISP_DEC); display(" Jitter", (u_int8_t *) &reportblock.jitter, 4, DISP_DEC); display(" Last SR", (u_int8_t *) &reportblock.lsr, 4, DISP_DEC); display(" Delay since last SR", (u_int8_t *) &reportblock.delay_since_lsr, 4, DISP_DEC); } reports_seen ++; } } /*---------------------------------------------------------------------------- ** ** dump_rtcp_sdes() ** ** Parse RTCP source description fields ** **---------------------------------------------------------------------------- */ void dump_rtcp_sdes(packet_t * pkt, int count) { u_int32_t ssrc; u_int8_t type; u_int8_t length; u_int8_t * string; int chunks_read; int pad_len; chunks_read = 0; while(chunks_read < count) { /* Get the ssrc, type and length */ if (get_packet_bytes((u_int8_t *) &ssrc, pkt, 4) == 0) break; /* Conversions */ ssrc = ntohl(ssrc); /* Display */ if (my_args->m) { display_minimal((u_int8_t *) &ssrc, 4, DISP_DEC); display_minimal_string(" "); } else display("SSRC/CSRC", (u_int8_t *) &ssrc, 4, DISP_DEC); /* Loop through items */ while (1) { u_int8_t byte; if (get_packet_bytes((u_int8_t *) &type, pkt, 1) == 0) break; if (get_packet_bytes((u_int8_t *) &length, pkt, 1) == 0) break; /* Allocate memory for the string then get it */ string = my_malloc(length+1); if (get_packet_bytes(string, pkt, length) == 0) break; string[length] = '\0'; /* Display */ if (my_args->m) { display_minimal_string(string); display_minimal_string(" "); } else { display(" Type", (u_int8_t *) &type, 1, DISP_DEC); display(" Length", (u_int8_t *) &length, 1, DISP_DEC); display_string(" SDES", string); } /* Free string memory */ my_free(string); /* Look for a null terminator */ if (look_packet_bytes((u_int8_t *) &byte, pkt, 1) == 0) break; if (byte == 0) break; } /* Figure out the pad and skip by it */ pad_len = 4 - (length+2) % 4; if (skip_packet_bytes(pkt, pad_len) == 0) break; chunks_read ++; } } /*---------------------------------------------------------------------------- ** ** dump_rtcp() ** ** Parse RTCP packet and dump fields ** **---------------------------------------------------------------------------- */ void dump_rtcp(packet_t * pkt) { rtcp_header_t rtcp; u_int8_t packet_type; u_int8_t padding; u_int8_t version; u_int8_t count; u_int16_t bytes_remaining; /* Set the layer */ set_layer(LAYER_APPLICATION); while(1) { /* Get the fixed RTCP header */ if (get_packet_bytes((u_int8_t *) &rtcp, pkt, sizeof(rtcp)) == 0) break; /* Conversions */ packet_type = rtcp.packet_type; padding = rtcp.padding; version = rtcp.version; count = rtcp.rc_sc; rtcp.length = ntohs(rtcp.length); /* Set the number of bytes remaining */ bytes_remaining = 4 * rtcp.length; /* Display */ if (my_args->m) { display_minimal_string("| RTCPv"); display_minimal((u_int8_t *) &version, 1, DISP_DEC); display_minimal_string(" "); display_minimal_string(map2str(rtcp_packettype_map, packet_type)); display_minimal_string(" "); } else { display_header_banner("RTCP Header"); display("Version", (u_int8_t *) &version, 1, DISP_DEC); display("Padding", (u_int8_t *) &padding, 1, DISP_DEC); display("Report/source count", (u_int8_t *) &count, 1, DISP_DEC); display_strmap("Packet type", packet_type, rtcp_packettype_map); display("Length", (u_int8_t *) &rtcp.length, 2, DISP_DEC); } switch(packet_type) { case RTCP_PACKETTYPE_SR: dump_rtcp_sr(pkt, count); break; case RTCP_PACKETTYPE_RR: dump_rtcp_rr(pkt, count); break; case RTCP_PACKETTYPE_SDES: dump_rtcp_sdes(pkt, count); break; default: break; } } /* Dump the hex buffer */ hexbuffer_flush(); } ipgrab-0.9.10/src/rtcp.h0000644000175000001440000000216307361413472014174 0ustar farooqusers/**************************************************************************** ** File: rtcp.h ** ** Author: Mike Borella ** ** Comments: Structure of RTCP packets ** ** $Id: rtcp.h,v 1.1 2001/10/11 22:03:38 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef RTCP_H #define RTCP_H #include "global.h" #include "local.h" void dump_rtcp(packet_t *); #endif ipgrab-0.9.10/src/rtp.c0000644000175000001440000001551707361402206014024 0ustar farooqusers/**************************************************************************** ** File: rtp.c ** ** Author: Mike Borella ** ** Comments: Dump RTP header information. ** ** $Id: rtp.c,v 1.7 2001/10/11 20:43:50 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "rtp.h" /* * Static part of RTP header * 0 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |V=2|P|X| CC |M| PT | sequence number | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | timestamp | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | synchronization source (SSRC) identifier | * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ * | contributing source (CSRC) identifiers | * | .... | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ typedef struct rtp_header { #if defined(WORDS_BIGENDIAN) u_int8_t version:2, padding:1, extension:1, csrc_count:4; #else u_int8_t csrc_count:4, extension:1, padding:1, version:2; #endif #if defined(WORDS_BIGENDIAN) u_int8_t marker:1, payload_type:7; #else u_int8_t payload_type:7, marker:1; #endif u_int16_t seqno; u_int32_t timestamp; u_int32_t ssrc; } rtp_header_t; /* * RTP payload type definitions */ #define RTP_PAYLOADTYPE_PCMU 0 #define RTP_PAYLOADTYPE_1016 1 #define RTP_PAYLOADTYPE_G72632 2 #define RTP_PAYLOADTYPE_GSM 3 #define RTP_PAYLOADTYPE_G723 4 #define RTP_PAYLOADTYPE_DVI48000 5 #define RTP_PAYLOADTYPE_DVI416000 6 #define RTP_PAYLOADTYPE_LPC 7 #define RTP_PAYLOADTYPE_PCMA 8 #define RTP_PAYLOADTYPE_G722 9 #define RTP_PAYLOADTYPE_L161CH 10 #define RTP_PAYLOADTYPE_L162CH 11 #define RTP_PAYLOADTYPE_QCELP 12 #define RTP_PAYLOADTYPE_RESERVED1 13 #define RTP_PAYLOADTYPE_MPA 14 #define RTP_PAYLOADTYPE_G728 15 #define RTP_PAYLOADTYPE_DVI411025 16 #define RTP_PAYLOADTYPE_DVI422050 17 #define RTP_PAYLOADTYPE_G729 18 #define RTP_PAYLOADTYPE_RESERVED2 19 #define RTP_PAYLOADTYPE_CELB 25 #define RTP_PAYLOADTYPE_JPEG 26 #define RTP_PAYLOADTYPE_NV 28 #define RTP_PAYLOADTYPE_H261 31 #define RTP_PAYLOADTYPE_MPV 32 #define RTP_PAYLOADTYPE_MP2T 33 #define RTP_PAYLOADTYPE_H263 34 /* * RTP payload type map */ strmap_t rtp_payloadtype_map[] = { { RTP_PAYLOADTYPE_PCMU, "PCMU" }, { RTP_PAYLOADTYPE_1016, "1016" }, { RTP_PAYLOADTYPE_G72632, "G726-32" }, { RTP_PAYLOADTYPE_G723, "G723" }, { RTP_PAYLOADTYPE_DVI48000, "DVI4 8000Hz" }, { RTP_PAYLOADTYPE_DVI416000, "DVI4 16000Hz" }, { RTP_PAYLOADTYPE_LPC, "LPC" }, { RTP_PAYLOADTYPE_PCMA, "PCMA" }, { RTP_PAYLOADTYPE_G722, "G722" }, { RTP_PAYLOADTYPE_L161CH, "L16 one channel" }, { RTP_PAYLOADTYPE_L162CH, "L16 two channels" }, { RTP_PAYLOADTYPE_QCELP, "QCELP" }, { RTP_PAYLOADTYPE_RESERVED1, "reserved" }, { RTP_PAYLOADTYPE_MPA, "MPA" }, { RTP_PAYLOADTYPE_G728, "G728" }, { RTP_PAYLOADTYPE_DVI411025, "DVI4 11025Hz" }, { RTP_PAYLOADTYPE_DVI422050, "DVI4 22050Hz" }, { RTP_PAYLOADTYPE_G729, "G729" }, { RTP_PAYLOADTYPE_RESERVED2, "reserved" }, { RTP_PAYLOADTYPE_CELB, "CELB" }, { RTP_PAYLOADTYPE_JPEG, "JPEG" }, { RTP_PAYLOADTYPE_NV, "NV" }, { RTP_PAYLOADTYPE_H261, "H261" }, { RTP_PAYLOADTYPE_MPV, "MPV" }, { RTP_PAYLOADTYPE_MP2T, "MP2T" }, { RTP_PAYLOADTYPE_H263, "H263" }, { 0, ""} }; extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** dump_rtp() ** ** Parse RTP packet and dump fields ** **---------------------------------------------------------------------------- */ void dump_rtp(packet_t * pkt) { rtp_header_t rtp; u_int8_t payload_type; u_int8_t marker; u_int8_t csrc_count; u_int8_t extension; u_int8_t padding; u_int8_t version; u_int8_t i; /* Set the layer */ set_layer(LAYER_APPLICATION); /* Get the fixed RTP header */ if (get_packet_bytes((u_int8_t *) &rtp, pkt, sizeof(rtp)) == 0) return; /* Conversions */ payload_type = rtp.payload_type; marker = rtp.marker; csrc_count = rtp.csrc_count; extension = rtp.extension; padding = rtp.padding; version = rtp.version; rtp.seqno = ntohs(rtp.seqno); rtp.timestamp = ntohl(rtp.timestamp); rtp.ssrc = ntohl(rtp.ssrc); /* Display */ if (my_args->m) { display_minimal_string("| RTPv"); display_minimal((u_int8_t *) &version, 1, DISP_DEC); display_minimal_string(" ("); display_minimal_string(map2str(rtp_payloadtype_map, payload_type)); display_minimal_string(","); display_minimal((u_int8_t *) &rtp.seqno, 2, DISP_DEC); display_minimal_string(") "); } else { display_header_banner("RTP Header"); display("Version", (u_int8_t *) &version, 1, DISP_DEC); display("Padding", (u_int8_t *) &padding, 1, DISP_DEC); display("Extension", (u_int8_t *) &extension, 1, DISP_DEC); display("CSRC count", (u_int8_t *) &csrc_count, 1, DISP_DEC); display("Marker", (u_int8_t *) &marker, 1, DISP_DEC); display_strmap("Payload type", payload_type, rtp_payloadtype_map); display("Sequence number", (u_int8_t *) &rtp.seqno, 2, DISP_DEC); display("Timestamp", (u_int8_t *) &rtp.timestamp, 4, DISP_DEC); display("SSRC", (u_int8_t *) &rtp.ssrc, 4, DISP_DEC); /* Dump contributing sources */ for (i=0; i < csrc_count; i++) { u_int32_t csrc; if (get_packet_bytes((u_int8_t *) &csrc, pkt, sizeof(u_int32_t)) == 0) return; display("CSRC", (u_int8_t *) &csrc, 4, DISP_DEC); } } /* Dump the hex buffer */ hexbuffer_flush(); } ipgrab-0.9.10/src/rtp.h0000644000175000001440000000215507361402206014023 0ustar farooqusers/**************************************************************************** ** File: rtp.h ** ** Author: Mike Borella ** ** Comments: Structure of RTP packets ** ** $Id: rtp.h,v 1.5 2001/10/11 20:43:50 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef RTP_H #define RTP_H #include "global.h" #include "local.h" void dump_rtp(packet_t *); #endif ipgrab-0.9.10/src/sdp.c0000644000175000001440000000422107304522724014000 0ustar farooqusers/**************************************************************************** ** File: sdp.c ** ** Author: Mike Borella ** ** Comments: Dump SDP header information. Like SIP, we just dump the ** Header contents in plaintext. ** ** Maybe we'll try to "decode" these headers into something intelligble ** later... ** ** $Id: sdp.c,v 1.8 2001/05/28 19:24:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "sdp.h" #define LINE_SIZE 1500 extern struct arg_t *my_args; /*---------------------------------------------------------------------------- ** ** dump_sdp() ** ** Parse SDP and dump fields ** **---------------------------------------------------------------------------- */ void dump_sdp(packet_t *pkt, int length) { char line[LINE_SIZE]; int len; int total_length = 0; /* Set the layer */ set_layer(LAYER_APPLICATION); if (my_args->m) { display_minimal_string("SDP "); /* maybe do something more intelligent here... */ } else { /* announcement */ display_header_banner("SDP Headers"); /* get each line one at a time */ while(1) { len = get_packet_line(line, length-total_length, pkt); if (len <= 0) break; total_length += len; display("Header", (u_int8_t *) line, len, DISP_STRING_MULTILINE); if (total_length > length) break; } /* dump the hexbuffer */ hexbuffer_flush(); } } ipgrab-0.9.10/src/sdp.h0000644000175000001440000000211007301315010013761 0ustar farooqusers/**************************************************************************** ** File: sdp.h ** ** Author: Mike Borella ** ** $Id: sdp.h,v 1.4 2001/05/18 21:54:16 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef SDP_H #define SDP_H #include "global.h" #include "local.h" void dump_sdp(packet_t *, int); #endif ipgrab-0.9.10/src/sip.c0000644000175000001440000000677307304522724014023 0ustar farooqusers/**************************************************************************** ** File: sip.c ** ** Author: Mike Borella ** ** Comments: Dump SIP header information. I didn't try to do anything ** fancy with this - I just dump the plaintext headers. This makes ** debugging easier since parsing is such a pain to get right. ** ** $Id: sip.c,v 1.9 2001/05/28 19:24:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "global.h" #include "sip.h" #include "sdp.h" #define LINE_SIZE 1500 #define FALSE 0 #define TRUE 1 extern struct arg_t *my_args; /*---------------------------------------------------------------------------- ** ** dump_sip() ** ** Parse SIP packet and dump fields. ** **---------------------------------------------------------------------------- */ void dump_sip(packet_t *pkt) { char *ptr; char line[LINE_SIZE]; int use_sdp = FALSE; int i; int len; int seen_nonws; int content_length=0; /* Set the layer */ set_layer(LAYER_APPLICATION); if (!my_args->m) { /* announcement */ display_header_banner("SIP Headers"); while(1) { len = get_packet_line(line, LINE_SIZE, pkt); if (len <= 0) break; /* * If we have a line of all whitespace, that's the end of the SIP * headers. */ seen_nonws = 0; for (i=0; im) { if (!strncmp("content-type", line, 12)) { ptr = &line[14]; while(isspace(*ptr)) ptr++; if (!strncmp("application/sdp", ptr, 15)) use_sdp = TRUE; } /* Capture the content length so that we can pass it to SDP */ if (!strncmp("content-length", line, 14)) { char temp[32]; int i = 0; /* skip whitespace */ ptr = &line[16]; while(isspace(*ptr)) ptr++; /* copy the numerals */ while(isdigit(*ptr)) { temp[i] = *ptr; i++; ptr++; } temp[i] = '\0'; content_length = atoi(temp); } } } /* dump the hexbuffer */ hexbuffer_flush(); if (use_sdp) dump_sdp(pkt, content_length); } else { /* Minimal mode processing. Just display the first line */ display_minimal_string("SIP "); len = get_packet_line(line, LINE_SIZE, pkt); if (len > 0) { display_minimal_string(line); display_minimal_string(" "); } } } ipgrab-0.9.10/src/sip.h0000644000175000001440000000210607153266450014015 0ustar farooqusers/**************************************************************************** ** ** File: sip.h ** ** Author: Mike Borella ** ** $Id: sip.h,v 1.4 2000/08/30 20:23:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef SIP_H #define SIP_H #include "global.h" #include "local.h" void dump_sip(packet_t *); #endif ipgrab-0.9.10/src/slip.c0000644000175000001440000000365407304522724014172 0ustar farooqusers/**************************************************************************** ** File: slip.c ** ** Author: Michael S. Borella ** ** Comments: Dump slip packets ** ** $Id: slip.c,v 1.5 2001/05/28 19:24:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "global.h" #include "slip.h" #include "ip.h" #define SLIP_HDRLEN 16 extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** dump_slip() ** ** Process packets from the DLT_RAW interface type ** **---------------------------------------------------------------------------- */ void dump_slip(packet_t *pkt) { u_int8_t slip_header[SLIP_HDRLEN]; /* Set the layer */ set_layer(LAYER_DATALINK); /* * Get slip header */ if (get_packet_bytes(slip_header, pkt, SLIP_HDRLEN) == 0) return; /* * Dump headers */ if (my_args->m) { if (my_args->T) display_minimal_string("SLIP "); else display_minimal_string("| SLIP "); } else { /* * Dump header announcement */ display_header_banner_ts("Slip", pkt->timestamp); } /* * Dump the IP Packet */ dump_ip(pkt); } ipgrab-0.9.10/src/slip.h0000644000175000001440000000216307153266450014174 0ustar farooqusers/**************************************************************************** ** ** File: slip.h ** ** Author: Michael S. Borella ** ** Comments: Dump slip packets ** ** $Id: slip.h,v 1.3 2000/08/30 20:23:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef SLIP_H #define SLIP_H #include "global.h" #include "local.h" void dump_slip(packet_t *); #endif ipgrab-0.9.10/src/slp.c0000644000175000001440000001171207414717761014024 0ustar farooqusers/**************************************************************************** ** File: sip.c ** ** Author: Mike Borella ** ** Comments: Dump SLP header. More parsing later ** ** $Id: slp.c,v 1.5 2002/01/03 00:04:01 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "global.h" #include "slp.h" #define HOLDER_SIZE 64 strmap_t slp_msgtype_map[] = { { SLP_MSGTYPE_SRVRQST, "service request" }, { SLP_MSGTYPE_SRVRPLY, "service reply" }, { SLP_MSGTYPE_SRVREG, "service registration" }, { SLP_MSGTYPE_SRVDEREG, "service deregistration" }, { SLP_MSGTYPE_SRVACK, "service acknowledge" }, { SLP_MSGTYPE_ATTRRQST, "attribute request" }, { SLP_MSGTYPE_ATTRRPLY, "attribute reply" }, { SLP_MSGTYPE_DAADVERT, "DA advertisement" }, { SLP_MSGTYPE_SRVTYPERQST, "service type request" }, { SLP_MSGTYPE_SRVTYPERPLY, "service type reply" }, { SLP_MSGTYPE_SAADVERT, "SA advertisement" }, { 0, "" } }; extern struct arg_t *my_args; /*---------------------------------------------------------------------------- ** ** dump_slp() ** ** Parse SLP packet and dump fields. ** **---------------------------------------------------------------------------- */ void dump_slp(packet_t *pkt) { slpv1_header_t slpv1; slpv2_header_t slpv2; char holder[HOLDER_SIZE]; u_int8_t ver; /* Set the layer */ set_layer(LAYER_APPLICATION); /* * Look at the first byte to determine the version */ if (look_packet_bytes((u_int8_t *) &ver, pkt, 1) == 0) return; switch(ver) { case 1: /* Get the header */ if (get_packet_bytes((u_int8_t *) &slpv1, pkt, 12) == 0) return; /* Conversions */ slpv1.length = ntohs(slpv1.length); slpv1.char_encoding = ntohs(slpv1.char_encoding); slpv1.xid = ntohs(slpv1.xid); if (my_args->m) { /* In minimal mode lets just dump the version and operation */ display_minimal_string("| SLPv1 "); display_minimal_string(map2str(slp_msgtype_map, slpv1.function_id)); display_minimal_string(" "); } else { /* announcement */ display_header_banner("SLPv1 Header"); /* dump the version and operation */ display("Version", (u_int8_t *) &slpv1.version, 1, DISP_DEC); snprintf(holder, HOLDER_SIZE, "%d (%s)", slpv1.function_id, map2str(slp_msgtype_map, slpv1.function_id)); display_string("Operation", holder); display("Length", (u_int8_t *) &slpv1.length, 2, DISP_DEC); display("Flags/Reserved", (u_int8_t *) &slpv1.flags_rsrvd, 1, DISP_HEX); display("Dialect", (u_int8_t *) &slpv1.dialect, 1, DISP_DEC); display("Language code", (u_int8_t *) &slpv1.lang_code, 2, DISP_STRING); display("Character encoding", (u_int8_t *) &slpv1.char_encoding, 2, DISP_DEC); display("XID", (u_int8_t *) &slpv1.xid, 2, DISP_DEC); } break; case 2: /* Get the header */ if (get_packet_bytes((u_int8_t *) &slpv2, pkt, 14) == 0) return; /* Conversions */ reverse_byte_order((u_int8_t *) &slpv2.length, 3); slpv2.flags_rsrvd = ntohs(slpv2.flags_rsrvd); reverse_byte_order((u_int8_t *) &slpv2.next_ext_offset, 3); slpv2.xid = ntohs(slpv2.xid); slpv2.lang_tag_length = ntohs(slpv2.lang_tag_length); if (my_args->m) { /* In minimal mode lets just dump the version and operation */ display_minimal_string("| SLPv2 "); display_minimal_string(map2str(slp_msgtype_map, slpv2.function_id)); display_minimal_string(" "); } else { /* announcement */ display_header_banner("SLPv2 Header"); /* dump the version and operation */ display("Version", (u_int8_t *) &slpv2.version, 1, DISP_DEC); snprintf(holder, HOLDER_SIZE, "%d (%s)", slpv1.function_id, map2str(slp_msgtype_map, slpv1.function_id)); display_string("Operation", holder); display("Length", (u_int8_t *) &slpv2.length, 3, DISP_DEC); display("Flags/Reserved", (u_int8_t *) &slpv2.flags_rsrvd, 2, DISP_HEX); display("Next extension offset", (u_int8_t *) &slpv2.next_ext_offset, 3, DISP_DEC); display("XID", (u_int8_t *) &slpv2.xid, 2, DISP_DEC); display("Language tag length", (u_int8_t *) &slpv2.lang_tag_length, 2, DISP_DEC); } default: break; } } ipgrab-0.9.10/src/slp.h0000644000175000001440000000404707153266450014026 0ustar farooqusers/**************************************************************************** ** ** File: slp.h ** ** Author: Mike Borella ** ** $Id: slp.h,v 1.3 2000/08/30 20:23:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef SLP_H #define SLP_H #include "global.h" #include "local.h" #define SLP_MSGTYPE_SRVRQST 1 #define SLP_MSGTYPE_SRVRPLY 2 #define SLP_MSGTYPE_SRVREG 3 #define SLP_MSGTYPE_SRVDEREG 4 #define SLP_MSGTYPE_SRVACK 5 #define SLP_MSGTYPE_ATTRRQST 6 #define SLP_MSGTYPE_ATTRRPLY 7 #define SLP_MSGTYPE_DAADVERT 8 #define SLP_MSGTYPE_SRVTYPERQST 9 #define SLP_MSGTYPE_SRVTYPERPLY 10 #define SLP_MSGTYPE_SAADVERT 11 /* * Fixed portion of SLPv1 header */ typedef struct slpv1_header { u_int8_t version; u_int8_t function_id; u_int16_t length; u_int8_t flags_rsrvd; u_int8_t dialect; u_int16_t lang_code; u_int16_t char_encoding; u_int16_t xid; } slpv1_header_t; /* * Fixed portion of SLPv2 header */ typedef struct slpv2_header { u_int8_t version; u_int8_t function_id; u_int8_t length[3]; u_int16_t flags_rsrvd; u_int8_t next_ext_offset[3]; u_int16_t xid; u_int16_t lang_tag_length; } slpv2_header_t; void dump_slp(packet_t *); #endif ipgrab-0.9.10/src/snmp.c0000644000175000001440000001350707346232437014203 0ustar farooqusers/* snmp.c ** ** Glen Wiley ** ** this provides the means to decompose an snmp v1 packet (pdu) ** ** NOTE: I am relying on the ucd snmp library for much of the heavy ** lifting ** ** $Id: snmp.c,v 1.10 2001/09/07 20:59:11 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** */ #include "ipgsnmp.h" #include #include #include #ifdef HAVE_STRING_H # include #else # ifdef HAVE_STRINGS_H # include # endif #endif /* these are taken from the source dist. of ucd-libsnmp */ #ifdef HAVE_ASN1_H # include "asn1.h" #endif #ifdef HAVE_SNMP_H # include "snmp.h" #endif extern struct arg_t *my_args; #if !defined(HAVE_LIBSNMP) || !defined(HAVE_ASN1_H) /*---------------------------------------- dump_snmp */ void dump_snmp(packet_t *pkt) { return; } /* dump_snmp */ #else /* HAVE_LIBSNMP */ /* we pull this many bytes for the community string (max) */ #define COMMUNITY_LENGTH 40 int snmp_dumpheader(u_char **, u_int32_t *, int *); int snmp_dumpv1pdu(u_char *, u_int32_t, int); const int npdutypes = 9; const char *pdutypes[] = { "get request" , "get-next request" , "response" , "set request" , "v1 trap" , "get-bulk request" , "v2 inform" , "v2 trap" , "report" }; /*---------------------------------------- dump_snmp */ void dump_snmp(packet_t *pkt) { /* we will keep the storage we allocate and grow it as needed * this will be more efficient than repeated malloc/free */ static u_int8_t *pktdata = NULL; static u_int32_t pktdatasz = 0; u_char *data; int snmpver = -1; u_int32_t nbytes; /* Set the layer */ set_layer(LAYER_APPLICATION); /* get all of the remaining data from the packet so that we can * pass it on to the asn parse api */ nbytes = get_packet_apparentbytesleft(pkt); if(nbytes > pktdatasz) { pktdata = (u_int8_t *) realloc(pktdata, nbytes); pktdatasz = nbytes; if(pktdata == NULL) { fprintf(stderr, "realloc error, %d: %s", errno, strerror(errno)); exit(1); } } if(get_packet_bytes(pktdata, pkt, nbytes) == 0) { return; } /* break out the SNMP version, community and pdu */ if (my_args->m) { display_minimal_string("| SNMPv"); } else { display_header_banner("SNMP"); } data = pktdata; if(snmp_dumpheader(&data, &nbytes, &snmpver) == 0) { if(snmpver == SNMP_VERSION_1 || snmpver == SNMP_VERSION_2c) { snmp_dumpv1pdu(data, nbytes, snmpver); } else if(snmpver == SNMP_VERSION_3) { } else { /* TODO: notify user that we can not stomach this pdu */ } } else { /* TODO: notify the user that the pdu type is either not supported * or contains format errors */ } return; } /* dump_snmp */ /*---------------------------------------- snmp_dumpheader * parses and dumps the snmp header * the values pointed to by datap, nbytesp and snmpver are updated * as a side-effect of this function * return 0 on success, 1 if errors occurred in the header */ int snmp_dumpheader(u_char **datap, u_int32_t *nbytesp, int *snmpver) { u_char type; int retval = 1; int length; long version; char *verstr; char community[COMMUNITY_LENGTH + 1]; /*-------------------- first try to get the snmp version */ *datap = asn_parse_sequence(*datap, nbytesp, &type , (ASN_SEQUENCE | ASN_CONSTRUCTOR), "version"); if(*datap) { *datap = asn_parse_int(*datap, nbytesp, &type, &version, sizeof(version)); if(*datap) { *snmpver = version; switch(*snmpver) { case SNMP_VERSION_1: verstr = "1"; break; case SNMP_VERSION_2c: verstr = "2c"; break; case SNMP_VERSION_sec: /* not supported */ verstr = "sec"; break; case SNMP_VERSION_2p: verstr = "2p"; break; case SNMP_VERSION_2star: /* not supported */ verstr = "2star"; break; case SNMP_VERSION_2u: /* not supported */ verstr = "2u"; break; case SNMP_VERSION_3: verstr = "3"; break; default: verstr = ""; *snmpver = -1; break; } /* get community */ } /* if(*datap) */ else { verstr = ""; } if(*snmpver != -1) retval = 0; if (my_args->m) { display_minimal_string(verstr); display_minimal_string(" "); } else { display_string("version", verstr); } } /* if(*datap) */ /*-------------------- get community if version is ok */ /* TODO: community only shows up here for some versions */ if(*snmpver == SNMP_VERSION_1 || *snmpver == SNMP_VERSION_2c) { length = COMMUNITY_LENGTH; *datap = asn_parse_string(*datap, nbytesp, &type, community, &length); if(*datap) { community[length] = '\0'; } else { retval = 1; strcpy(community, ""); } if (my_args->m) { display_minimal_string(community); display_minimal_string(" "); } else { display_string("community", community); } } return retval; } /* snmp_dumpheader */ /*---------------------------------------- snmp_dumpv1pdu * return 0 on success */ int snmp_dumpv1pdu(u_char *data, u_int32_t nbytes, int snmpver) { int retval = 0; return retval; } /* snmp_dumpv1pdu */ #endif /* HAVE_LIBSNMP */ /* snmp.c */ ipgrab-0.9.10/src/spx.c0000644000175000001440000000462307304522724014032 0ustar farooqusers/**************************************************************************** ** File: spx.c ** ** Author: Mike Borella ** ** Comments: Dump SPX header information ** ** $Id: spx.c,v 1.6 2001/05/28 19:24:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "global.h" #include "spx.h" extern struct arg_t *my_args; /*---------------------------------------------------------------------------- ** ** dump_spx() ** ** Parse SPX header and dump fields ** **---------------------------------------------------------------------------- */ void dump_spx(packet_t *pkt) { spx_header_t spx; /* Set the layer */ set_layer(LAYER_TRANSPORT); /* * Get the SPX header */ if (get_packet_bytes((u_int8_t *) &spx, pkt, 12) == 0) return; /* * Conversions */ spx.s_id = ntohs(spx.s_id); spx.d_id = ntohs(spx.d_id); spx.seqno = ntohs(spx.seqno); spx.ackno = ntohs(spx.ackno); spx.allocno = ntohs(spx.allocno); /* * Dump header */ if (!my_args->n) { if (my_args->m) { display_minimal_string("| SPX "); } else { /* announcement */ display_header_banner("SPX Header"); /* fields */ display("Connection control", (u_int8_t *) &spx.cc, 1, DISP_DEC); display("Data stream type", (u_int8_t *) &spx.ds_type, 1, DISP_DEC); display("Source conn ID", (u_int8_t *) &spx.s_id, 2, DISP_DEC); display("Dest conn ID", (u_int8_t *) &spx.d_id, 2, DISP_DEC); display("Sequence number", (u_int8_t *) &spx.seqno, 2, DISP_DEC); display("Ack number", (u_int8_t *) &spx.ackno, 2, DISP_DEC); display("Allocation number", (u_int8_t *) &spx.allocno, 2, DISP_DEC); } } } ipgrab-0.9.10/src/spx.h0000644000175000001440000000275107153266450014042 0ustar farooqusers/**************************************************************************** ** File: spx.h ** ** Author: Mike Borella ** ** Comments: Dump SPX header format and such ** ** $Id: spx.h,v 1.3 2000/08/30 20:23:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef SPX_H #define SPX_H #include "global.h" #include "local.h" typedef struct spx_header { u_int8_t cc; /* connection control */ u_int8_t ds_type; /* data stream type */ u_int16_t s_id; /* source connection id */ u_int16_t d_id; /* destination connection id */ u_int16_t seqno; /* sequence number */ u_int16_t ackno; /* acknowledgement number */ u_int16_t allocno; /* allocation number */ } spx_header_t; void dump_spx(packet_t *); #endif ipgrab-0.9.10/src/ssh.c0000644000175000001440000000665110530527426014017 0ustar farooqusers/**************************************************************************** ** File: ssh.c ** ** Author: Mike Borella ** ** Comments: SSH protocol module. ** ** Ok, this is very weak support, but here are the difficulties. SSH is ** rather stateful, which means you decode packets based on the contents ** of previous packets. And I'm not just talking about the crypto, but ** the protocol itself. So if you look at an SSH packet midstream, you ** can't read it because of the crypto, but you may not be able to figure ** out *where* certain plaintext fields might be because you don't know if ** it is version 1 or 2. So I'm not sure what else we can do with this ** module, but this simple parser is at least a start. ** ** $Id: ssh.c,v 1.8 2006/11/21 07:47:34 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "ssh.h" extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** dump_ssh() ** ** Parse and display SSH packets ** **---------------------------------------------------------------------------- */ void dump_ssh(packet_t *pkt) { u_int8_t * payload; u_int32_t size; /* * SHH doesn't have "message types" or any other neat way of decoding * packets in a stateless fashion. Therefore, we'll just grab the whole * damn thing and work from there... */ /* Set the layer */ set_layer(LAYER_APPLICATION); /* find the paylaod size, then allocate memory and read the packet */ size = get_packet_apparentbytesleft(pkt); if (size <= 0) return; payload = (u_int8_t *) my_malloc (size+1); payload[size] = '\0'; if (get_packet_bytes(payload, pkt, size) == 0) { my_free(payload); return; } /* * If the payload is printable, we'll assume that its a string we * can display. If not, its the binary format version of the message. * We subtract 1 to get rid of the \n on the end. */ if (isprint_str(payload, size)) { payload[size-1] = '\0'; /* null terminate over the \n */ if (my_args->m) { display_minimal_string("| "); display_minimal_string(payload); } else { display_header_banner("SSH"); display_string("Version", payload); } } else { if (my_args->m) { } else { u_int32_t packet_length; memcpy((void *) &packet_length, payload, 4); packet_length = ntohl(packet_length); display_header_banner("SSH"); display("Packet length", (u_int8_t *) &packet_length, 4, DISP_DEC); display("Payload", (u_int8_t *) payload+4, size-4, DISP_HEX_MULTILINE); } } /* free memory, of course */ my_free(payload); /* dump the hex buffer */ hexbuffer_flush(); } ipgrab-0.9.10/src/ssh.h0000644000175000001440000000215707171140047014016 0ustar farooqusers/**************************************************************************** ** File: ssh.h ** ** Author: Mike Borella ** ** Comments: Definitions for SSH parsing ** ** $Id: ssh.h,v 1.1 2000/10/11 19:31:51 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef SSH_H #define SSH_H #include "global.h" #include "local.h" void dump_ssh(packet_t *); #endif ipgrab-0.9.10/src/state.c0000644000175000001440000000736110637725101014337 0ustar farooqusers/**************************************************************************** ** ** File: state.c ** ** Author: Mike Borella ** ** Comments: Support for per-packet state. Basically, this module allows ** us to save a handful of information about each packet, such as IP ** addresses and port numbers. Then this information is available to ** application layer decodes. One example where this is necessary is ** TFTP. ** ** $Id: state.c,v 1.2 2007/06/25 11:42:57 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "state.h" /* store the packet state in this data structure */ typedef struct packet_state { u_int32_t srcaddr; u_int32_t dstaddr; u_int16_t srcport; u_int16_t dstport; } packet_state_t; static packet_state_t state; /*---------------------------------------------------------------------------- ** ** state_set_srcaddr(u_int32_t) ** ** Set source IP address ** **---------------------------------------------------------------------------- */ void state_set_srcaddr(u_int32_t a) { state.srcaddr = a; } /*---------------------------------------------------------------------------- ** ** state_set_dstaddr(u_int32_t) ** ** Set destination IP address ** **---------------------------------------------------------------------------- */ void state_set_dstaddr(u_int32_t a) { state.dstaddr = a; } /*---------------------------------------------------------------------------- ** ** state_set_srcport(u_int16_t) ** ** Set source port ** **---------------------------------------------------------------------------- */ void state_set_srcport(u_int16_t p) { state.srcport = p; } /*---------------------------------------------------------------------------- ** ** state_set_dstport(u_int16_t) ** ** Set destination port ** **---------------------------------------------------------------------------- */ void state_set_dstport(u_int16_t p) { state.dstport = p; } /*---------------------------------------------------------------------------- ** ** state_get_srcaddr() ** ** Get source IP address ** **---------------------------------------------------------------------------- */ u_int32_t state_get_srcaddr(void) { return state.srcaddr; } /*---------------------------------------------------------------------------- ** ** state_get_dstaddr() ** ** Get destination IP address ** **---------------------------------------------------------------------------- */ u_int32_t state_get_dstaddr(void) { return state.dstaddr; } /*---------------------------------------------------------------------------- ** ** state_get_srcport() ** ** Get source port ** **---------------------------------------------------------------------------- */ u_int16_t state_get_srcport(void) { return state.srcport; } /*---------------------------------------------------------------------------- ** ** state_get_dstport() ** ** Get destination port ** **---------------------------------------------------------------------------- */ u_int16_t state_get_dstport(void) { return state.dstport; } ipgrab-0.9.10/src/state.h0000644000175000001440000000270307360703112014334 0ustar farooqusers/**************************************************************************** ** ** File: state.h ** ** Author: Mike Borella ** ** Header Definitions for packet level state ** ** $Id: state.h,v 1.1 2001/10/09 23:20:42 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef STATE_H #define STATE_H #include "global.h" /* * Function prototypes */ void state_set_srcaddr(u_int32_t); void state_set_dstaddr(u_int32_t); void state_set_srcport(u_int16_t); void state_set_dstport(u_int16_t); u_int32_t state_get_srcaddr(void); u_int32_t state_get_dstaddr(void); u_int16_t state_get_srcport(void); u_int16_t state_get_dstport(void); #endif ipgrab-0.9.10/src/stats.c0000644000175000001440000001306407346217606014363 0ustar farooqusers/**************************************************************************** ** ** File: stats.c ** ** Author: Mike Borella ** ** Comments: Statistics collection module ** ** $Id: stats.c,v 1.2 2001/09/07 19:27:02 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "global.h" #include "error.h" #include "stats.h" typedef struct stats { int ip; int udp; int tcp; int ipx; int gre; int icmp; int ipv6; int icmpv6; int ospf; int rsvp; int arp; int ah; int esp; int igmp; } stats_t; stats_t statistics; static int stats_counted_ip = 0; static int stats_counted_udp = 0; static int stats_counted_tcp = 0; static int stats_paused = 0; /* when set, stats will not be counted */ /*---------------------------------------------------------------------------- ** ** stats_ispaused() ** ** Check if stats counting is paused ** **---------------------------------------------------------------------------- */ inline int stats_ispaused(void) { return stats_paused; } /*---------------------------------------------------------------------------- ** ** stats_pause() ** ** Temporarily stop doing stats. Typically used when an ICMP packet is ** encountered so that the encapsulated IP/UDP/TCP headers are not counted. ** **---------------------------------------------------------------------------- */ inline void stats_pause(void) { stats_paused = 1; } /*---------------------------------------------------------------------------- ** ** stats_unpause() ** ** Restart doing stats. Typically used at the begining of processing each ** packet. ** **---------------------------------------------------------------------------- */ inline void stats_unpause(void) { stats_paused = 0; } /*---------------------------------------------------------------------------- ** ** stats_reset() ** **---------------------------------------------------------------------------- */ inline void stats_reset(void) { stats_counted_ip = 0; stats_counted_udp = 0; stats_counted_tcp = 0; } /*---------------------------------------------------------------------------- ** ** stats_init() ** **---------------------------------------------------------------------------- */ inline void stats_init(void) { memset(&statistics, 0, sizeof(stats_t)); } /*---------------------------------------------------------------------------- ** ** stats_update() ** **---------------------------------------------------------------------------- */ inline void stats_update(int type) { if (stats_ispaused()) return; switch(type) { case STATS_IP: /* Avoid double counting tunneled packets */ if (stats_counted_ip) return; stats_counted_ip = 1; statistics.ip++; break; case STATS_UDP: /* Avoid double counting tunneled packets */ if (stats_counted_udp) return; stats_counted_udp = 1; statistics.udp++; break; case STATS_TCP: /* Avoid double counting tunneled packets */ if (stats_counted_tcp) return; stats_counted_tcp = 1; statistics.tcp++; break; case STATS_IPX: statistics.ipx++; break; case STATS_GRE: statistics.gre++; break; case STATS_ICMP: statistics.icmp++; stats_pause(); break; case STATS_IPV6: statistics.ipv6++; break; case STATS_ICMPV6: statistics.icmpv6++; stats_pause(); break; case STATS_OSPF: statistics.ospf++; break; case STATS_RSVP: statistics.rsvp++; break; case STATS_ARP: statistics.arp++; break; case STATS_AH: statistics.ah++; break; case STATS_ESP: statistics.esp++; break; case STATS_IGMP: statistics.igmp++; break; default: error_fatal("unknown packet type for statistics: %d\n", type); break; } } /*---------------------------------------------------------------------------- ** ** stats_dump() ** **---------------------------------------------------------------------------- */ inline void stats_dump(void) { fprintf(stderr, "ARP: %d\n", statistics.arp); fprintf(stderr, "IP: %d\n", statistics.ip); fprintf(stderr, "ICMP: %d\n", statistics.icmp); fprintf(stderr, "IGMP: %d\n", statistics.igmp); fprintf(stderr, "UDP: %d\n", statistics.udp); fprintf(stderr, "TCP: %d\n", statistics.tcp); fprintf(stderr, "IPX: %d\n", statistics.ipx); fprintf(stderr, "GRE: %d\n", statistics.gre); fprintf(stderr, "IPv6: %d\n", statistics.ipv6); fprintf(stderr, "ICMPv6: %d\n", statistics.icmpv6); fprintf(stderr, "OSPF: %d\n", statistics.ospf); fprintf(stderr, "RSVP: %d\n", statistics.rsvp); fprintf(stderr, "AH: %d\n", statistics.ah); fprintf(stderr, "ESP: %d\n", statistics.esp); } ipgrab-0.9.10/src/stats.h0000644000175000001440000000333207346217606014365 0ustar farooqusers/**************************************************************************** ** ** File: stats.h ** ** Author: Mike Borella ** ** Header file for statistics collection ** ** $Id: stats.h,v 1.2 2001/09/07 19:27:02 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef STATS_H #define STATS_H #include "global.h" /* * Types of packets to collect stats on */ #define STATS_IP 0 #define STATS_UDP 1 #define STATS_TCP 2 #define STATS_IPX 3 #define STATS_GRE 4 #define STATS_ICMP 5 #define STATS_IPV6 6 #define STATS_ICMPV6 7 #define STATS_OSPF 8 #define STATS_RSVP 9 #define STATS_ARP 10 #define STATS_AH 11 #define STATS_ESP 12 #define STATS_IGMP 13 /* * Function prototypes */ inline void stats_init(void); inline void stats_update(int type); inline void stats_dump(void); inline void stats_reset(void); inline void stats_pause(void); inline void stats_unpause(void); #endif ipgrab-0.9.10/src/strmap.c0000644000175000001440000000323110530527426014517 0ustar farooqusers/**************************************************************************** ** File: strmap.c ** ** Author: Mike Borella ** ** Comments: Map IANA numbers to string ** ** $Id: strmap.c,v 1.6 2006/11/21 07:47:34 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "strmap.h" /*---------------------------------------------------------------------------- ** ** map2str() ** ** Convert an IANA protocol number to a descriptive string. This process ** is slow, so maybe we shouldn't do it in "fast mode"...whatever that may ** become. ** ** Returns the target string, or "unknown" if we don't find the target. ** **---------------------------------------------------------------------------- */ inline char * map2str(strmap_t *sm, u_int32_t index) { int i = 0; while(strlen(sm[i].string) != 0) { if (sm[i].number == index) return sm[i].string; i++; } return "unknown"; } ipgrab-0.9.10/src/strmap.h0000644000175000001440000000245107153031046014522 0ustar farooqusers/**************************************************************************** ** File: strmap.h ** ** Author: Mike Borella ** ** Comments: Header file for mapping IANA numbers to strings ** ** $Id: strmap.h,v 1.3 2000/08/29 21:59:02 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef STRMAP_H #define STRMAP_H #include "global.h" /* * This is a way of converting an IANA assigned "protocol number" to a string */ typedef struct strmap { u_int32_t number; char * string; } strmap_t; char * map2str(strmap_t *, u_int32_t); #endif ipgrab-0.9.10/src/tcp.c0000644000175000001440000002225410530527426014005 0ustar farooqusers/**************************************************************************** ** ** File: tcp.c ** ** Author: Mike Borella ** ** Comments: Dump TCP header information. ** ** $Id: tcp.c,v 1.26 2006/11/21 07:47:34 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "global.h" #include "ip_services.h" #include "tcp.h" #include "payload.h" #define HOLDER_SIZE 64 /* * TCP option map */ strmap_t tcp_option_map [] = { { TCP_OPTION_EOL, "end of options" }, { TCP_OPTION_NOP, "no op" }, { TCP_OPTION_MSS, "maximum segment size" }, { TCP_OPTION_WS, "window scale" }, { TCP_OPTION_SACKOK, "SACK permitted" }, { TCP_OPTION_SACK, "SACK" }, { TCP_OPTION_TS, "timestamp" }, { 192, "cwnd" }, { 0, "" } }; extern struct arg_t *my_args; extern strmap_t port_map[]; /*---------------------------------------------------------------------------- ** ** dump_tcp_options() ** ** Parse TCP options ** **---------------------------------------------------------------------------- */ void dump_tcp_options(packet_t *pkt, u_int8_t length) { u_int8_t option_bytes_read; char holder[HOLDER_SIZE]; u_int8_t option_length; u_int8_t kind; u_int16_t mss; u_int32_t ts1, ts2; #ifdef DEBUG printf("\nEntering TCP options\n"); #endif option_bytes_read = 0; while(option_bytes_read < length) { /* read the kind of option */ if (get_packet_bytes((u_int8_t *) &kind, pkt, 1) == 0) return; option_bytes_read ++; /* take care of the 1-byte options */ if (kind == TCP_OPTION_EOL || kind == TCP_OPTION_NOP) { if (!my_args->m) { snprintf(holder, HOLDER_SIZE, "%d (%s)", kind, map2str(tcp_option_map, kind)); display_string("Option", holder); } continue; } /* display the option's name */ if (!my_args->m) { snprintf(holder, HOLDER_SIZE, "%d (%s)", kind, map2str(tcp_option_map, kind)); display_string("Option", holder); } else { display_minimal_string("<"); display_minimal_string(map2str(tcp_option_map, kind)); } /* get and display the length field */ if (get_packet_bytes((u_int8_t *) &option_length, pkt, 1) == 0) return; if (!my_args->m) display(" Length", (u_int8_t *) &option_length, 1, DISP_DEC); option_bytes_read += 1; /* read the 'length'-2 bytes because the field counts kind and itself */ if (get_packet_bytes((u_int8_t *) holder, pkt, option_length-2) == 0) return; option_bytes_read += (option_length - 2); /* read the field */ switch(kind) { case TCP_OPTION_EOL: case TCP_OPTION_NOP: /* these should be taken care of above... */ break; case TCP_OPTION_MSS: memcpy((void *) &mss, holder, 2); mss = ntohs(mss); if (!my_args->m) display(" MSS", (u_int8_t *) &mss, 2, DISP_DEC); else { display_minimal_string(" "); display_minimal((u_int8_t *) &mss, 2, DISP_DEC); display_minimal_string(">"); } break; case TCP_OPTION_WS: if (!my_args->m) display(" Shift count", (u_int8_t *) holder, 1, DISP_DEC); else { display_minimal_string(" "); display_minimal((u_int8_t *) holder, 1, DISP_DEC); display_minimal_string(">"); } break; case TCP_OPTION_TS: memcpy((void *) &ts1, holder, 4); ts1 = ntohl(ts1); memcpy((void *) &ts2, holder+4, 4); ts2 = ntohl(ts2); if (!my_args->m) { display(" Timestamp value", (u_int8_t *) &ts1, 4, DISP_DEC); display(" Timestamp reply", (u_int8_t *) &ts2, 4, DISP_DEC); } else { display_minimal_string(" "); display_minimal((u_int8_t *) &ts1, 4, DISP_DEC); display_minimal_string(" "); display_minimal((u_int8_t *) &ts2, 4, DISP_DEC); display_minimal_string(">"); } break; /* case 64: display_minimal_string(" "); memcpy((void *) &ts1, holder, 4); ts1 = ntohl(ts1); display_minimal((u_int8_t *) &ts1, 4, DISP_DEC); display_minimal_string(">"); break; */ default: if (my_args->m) display_minimal_string(">"); break; } } /* while */ /* * Trailing space for minimal mode */ if (my_args->m) display_minimal_string(" "); #ifdef DEBUG printf("\nLeaving TCP options\n"); #endif } /*---------------------------------------------------------------------------- ** ** dump_tcp() ** ** Parse TCP header and dump fields ** **---------------------------------------------------------------------------- */ void dump_tcp(packet_t *pkt) { tcp_header_t tcp; u_int8_t hlen, unused; char flag_str[8]; service_func_t app_src; service_func_t app_dst; char holder[64]; #ifdef DEBUG printf("\nEntering TCP\n"); #endif /* Set the layer */ set_layer(LAYER_TRANSPORT); /* * Stats accounting */ stats_update(STATS_TCP); /* * Grab the static TCP header */ if (get_packet_bytes((u_int8_t *) &tcp, pkt, 20) == 0) return; /* * Conversions */ tcp.src = ntohs(tcp.src); tcp.dst = ntohs(tcp.dst); tcp.seq_number = ntohl(tcp.seq_number); tcp.ack_number = ntohl(tcp.ack_number); hlen = tcp.header_length; unused = tcp.unused; tcp.window = ntohs(tcp.window); tcp.checksum = ntohs(tcp.checksum); tcp.urgent = ntohs(tcp.urgent); /* * Prepare flag string */ flag_str[0] = '\0'; if (tcp.flags & TCP_FLAG_SYN) strcat(flag_str, "S"); if (tcp.flags & TCP_FLAG_FIN) strcat(flag_str, "F"); if (tcp.flags & TCP_FLAG_RST) strcat(flag_str, "R"); if (tcp.flags & TCP_FLAG_PSH) strcat(flag_str, "P"); if (tcp.flags & TCP_FLAG_ACK) strcat(flag_str, "A"); if (tcp.flags & TCP_FLAG_URG) strcat(flag_str, "U"); /* * Minimal mode */ if (my_args->m) { display_minimal_string("| TCP "); display_minimal((u_int8_t *) &tcp.src, 2, DISP_DEC); display_minimal_string("->"); display_minimal((u_int8_t *) &tcp.dst, 2, DISP_DEC); display_minimal_string(" ("); display_minimal(flag_str, strlen(flag_str), DISP_STRING); display_minimal_string(","); display_minimal((u_int8_t *) &tcp.seq_number, 4, DISP_DEC); display_minimal_string(","); display_minimal((u_int8_t *) &tcp.ack_number, 4, DISP_DEC); display_minimal_string(","); display_minimal((u_int8_t *) &tcp.window, 2, DISP_DEC); display_minimal_string(") "); } else { /* Dump TCP header announcement */ display_header_banner("TCP Header"); /* port fields */ display_strmap("Source port", tcp.src, port_map); display_strmap("Destination port", tcp.dst, port_map); /* sequence and acknowledgement */ display("Sequence number", (u_int8_t *) &tcp.seq_number, 4, DISP_DEC); display("Acknowledgement number", (u_int8_t *) &tcp.ack_number, 4, DISP_DEC); /* header length and unused bits */ snprintf(holder, HOLDER_SIZE, "%d (%d bytes)", hlen, hlen*4); display_string("Header length", holder); display("Unused", (u_int8_t *) &unused, 1, DISP_DEC); /* flags */ display("Flags", (u_int8_t *) &flag_str, strlen(flag_str), DISP_STRING); /* window size, checksum and urgent ptr */ display("Window size", (u_int8_t *) &tcp.window, 2, DISP_DEC); display("Checksum", (u_int8_t *) &tcp.checksum, 2, DISP_DEC); display("Urgent", (u_int8_t *) &tcp.urgent, 2, DISP_DEC); } /* Add state */ state_set_srcport(tcp.src); state_set_dstport(tcp.dst); /* * Handle any options. There should be option(s) if the header length * is > 20 bytes (5 words). Pass in the total length of the options. */ if (hlen > 5) dump_tcp_options(pkt, hlen*4 - 20); /* dump the hex buffer */ hexbuffer_flush(); /* * If there is something left of the packet, process the application * data */ if (get_packet_apparentbytesleft(pkt)) { /* * Let's try to decode the application from the port number. If both * match a decoder, we choose the lowest, assuming that the higher * one is probably ephemeral. */ app_src = port2func(tcp.src); app_dst = port2func(tcp.dst); if (app_src && app_dst) { if (tcp.src < tcp.dst) app_src(pkt); else app_dst(pkt); } else { if (app_src) app_src(pkt); else if (app_dst) app_dst(pkt); } } #ifdef DEBUG printf("\nLeaving TCP\n"); #endif return; } ipgrab-0.9.10/src/tcp.h0000644000175000001440000000440007153266450014007 0ustar farooqusers/**************************************************************************** ** ** File: tcp.h ** ** Author: Mike Borella ** ** Comments: Generic TCP header structure - an attempt at OS independence ** ** $Id: tcp.h,v 1.6 2000/08/30 20:23:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef TCP_H #define TCP_H #include "global.h" #include "local.h" /* * TCP flags */ #define TCP_FLAG_FIN 0x01 #define TCP_FLAG_SYN 0x02 #define TCP_FLAG_RST 0x04 #define TCP_FLAG_PSH 0x08 #define TCP_FLAG_ACK 0x10 #define TCP_FLAG_URG 0x20 /* * TCP options */ #define TCP_OPTION_EOL 0 #define TCP_OPTION_NOP 1 #define TCP_OPTION_MSS 2 #define TCP_OPTION_WS 3 #define TCP_OPTION_SACKOK 4 #define TCP_OPTION_SACK 5 #define TCP_OPTION_TS 8 /* * TCP header */ typedef struct tcp_header { u_int16_t src; /* source port */ u_int16_t dst; /* destination port */ u_int32_t seq_number; /* sequence number */ u_int32_t ack_number; /* acknowledgement number */ #ifdef WORDS_BIGENDIAN u_int8_t header_length:4, /* data offset */ unused:4; /* (unused) */ #else u_int8_t unused:4, /* (unused) */ header_length:4; /* data offset */ #endif u_int8_t flags; u_int16_t window; /* window */ u_int16_t checksum; /* checksum */ u_int16_t urgent; /* urgent pointer */ } tcp_header_t; void dump_tcp(packet_t *); #endif ipgrab-0.9.10/src/template.c0000644000175000001440000000236707304500453015031 0ustar farooqusers/**************************************************************************** ** File: XXX.c ** ** Author: Mike Borella ** ** Comments: ** ** $Id: template.c,v 1.2 2001/05/28 16:47:39 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "xxx.h" extern struct arg_t * my_args; /*---------------------------------------------------------------------------- ** ** xxx() ** ** ** **---------------------------------------------------------------------------- */ void xxx(packet_t *pkt) { } ipgrab-0.9.10/src/template.h0000644000175000001440000000212407153266450015035 0ustar farooqusers/**************************************************************************** ** File: xxx.h ** ** Author: Mike Borella ** ** Comments: ** ** $Id: template.h,v 1.2 2000/08/30 20:23:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef XXX_H #define XXX_H #include "global.h" #include "local.h" void xxx(packet_t *); #endif ipgrab-0.9.10/src/tftp.c0000644000175000001440000001407207360703112014166 0ustar farooqusers/**************************************************************************** ** File: tftp.c ** ** Author: Mike Borella ** ** Comments: TFTP protocol module. ** ** $Id: tftp.c,v 1.1 2001/10/09 23:20:42 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "tftp.h" #include "dynports.h" extern struct arg_t * my_args; #define FILENAME_SIZE 128 #define MODE_SIZE 64 /* TFTP opcodes */ #define TFTP_OPCODE_READ 1 #define TFTP_OPCODE_WRITE 2 #define TFTP_OPCODE_DATA 3 #define TFTP_OPCODE_ACK 4 #define TFTP_OPCODE_ERROR 5 /* TFTP opcode map */ strmap_t tftp_opcode_map[] = { { TFTP_OPCODE_READ, "read request" }, { TFTP_OPCODE_WRITE, "write request" }, { TFTP_OPCODE_DATA, "data" }, { TFTP_OPCODE_ACK, "acknowledgement" }, { TFTP_OPCODE_ERROR, "error" }, { 0, ""} }; /*---------------------------------------------------------------------------- ** ** dump_tftp() ** ** Parse and display TFTP packets ** **---------------------------------------------------------------------------- */ void dump_tftp(packet_t *pkt) { u_int16_t opcode; struct timeval t; /* Set the layer */ set_layer(LAYER_APPLICATION); /* Get the opcode */ if (get_packet_bytes((u_int8_t *) &opcode, pkt, 2) == 0) return; /* Conversions */ opcode = ntohs(opcode); /* Announcement */ if (!my_args->m) display_header_banner("TFTP"); else display_minimal_string("| TFTP "); switch(opcode) { case TFTP_OPCODE_READ: case TFTP_OPCODE_WRITE: { u_int8_t filename [FILENAME_SIZE]; u_int8_t mode [MODE_SIZE]; /* read the filename and mode */ if (get_packet_string(filename, FILENAME_SIZE, pkt) == 0) return; if (get_packet_string(mode, MODE_SIZE, pkt) == 0) return; if (my_args->m) { display_minimal_string(map2str(tftp_opcode_map, opcode)); display_minimal_string(" ("); display_minimal_string(filename); display_minimal_string(","); display_minimal_string(mode); display_minimal_string(")"); } else { display_strmap("Opcode", opcode, tftp_opcode_map); display_string("Filename", filename); display_string("Mode", mode); } /* set up a dynamic port binding to the source port */ gettimeofday(&t, NULL); dynports_add(state_get_srcport(), dump_tftp, t.tv_sec); } break; case TFTP_OPCODE_DATA: { u_int16_t block; u_int8_t * data; u_int32_t n; /* refresh up a dynamic port binding to the source and dest port */ dynports_refresh(state_get_srcport(), dump_tftp); dynports_refresh(state_get_dstport(), dump_tftp); /* read the block # */ if (get_packet_bytes((u_int8_t *) &block, pkt, 2) == 0) return; /* conversions */ block = ntohs(block); /* find out length of data field */ n = get_packet_apparentbytesleft(pkt); if (n <= 0) return; /* Allocate memory */ data = my_malloc(n+1); /* read data portion */ if (get_packet_bytes(data, pkt, n) == 0) return; if (my_args->m) { display_minimal_string(map2str(tftp_opcode_map, opcode)); display_minimal_string(" block "); display_minimal((u_int8_t *) &block, 2, DISP_DEC); } else { display_strmap("Opcode", opcode, tftp_opcode_map); display("Block", (u_int8_t *) &block, 2, DISP_DEC); display("Data", data, n, DISP_HEX_MULTILINE); } /* free memory for data */ my_free(data); } break; case TFTP_OPCODE_ACK: { u_int16_t block; /* refresh up a dynamic port binding to the source and dest port */ dynports_refresh(state_get_srcport(), dump_tftp); dynports_refresh(state_get_dstport(), dump_tftp); /* read the block # */ if (get_packet_bytes((u_int8_t *) &block, pkt, 2) == 0) return; /* conversions */ block = ntohs(block); if (my_args->m) { display_minimal_string(map2str(tftp_opcode_map, opcode)); display_minimal_string(" block "); display_minimal((u_int8_t *) &block, 2, DISP_DEC); } else { display_strmap("Opcode", opcode, tftp_opcode_map); display("Block", (u_int8_t *) &block, 2, DISP_DEC); } } break; case TFTP_OPCODE_ERROR: { u_int16_t errorcode; u_int8_t * msg; u_int32_t n; /* refresh up a dynamic port binding to the source and dest port */ dynports_refresh(state_get_srcport(), dump_tftp); dynports_refresh(state_get_dstport(), dump_tftp); /* read the block # */ if (get_packet_bytes((u_int8_t *) &errorcode, pkt, 2) == 0) return; /* conversions */ errorcode = ntohs(errorcode); /* find out length of msg field */ n = get_packet_apparentbytesleft(pkt); if (n <= 0) return; /* Allocate memory */ msg = my_malloc(n+1); /* read data portion */ if (get_packet_string(msg, n, pkt) == 0) return; if (my_args->m) { display_minimal_string(map2str(tftp_opcode_map, opcode)); display_minimal_string(" ("); display_minimal((u_int8_t *) &errorcode, 2, DISP_DEC); display_minimal_string(","); display_minimal_string(msg); display_minimal_string(")"); } else { display_strmap("Opcode", opcode, tftp_opcode_map); display("Error", (u_int8_t *) &error, 2, DISP_DEC); display_string("Message", msg); } /* free memory for data */ my_free(msg); } break; default: break; } /* dump the hex buffer */ hexbuffer_flush(); } ipgrab-0.9.10/src/tftp.h0000644000175000001440000000216507360703112014173 0ustar farooqusers/**************************************************************************** ** File: tftp.h ** ** Author: Mike Borella ** ** Comments: Definitions for TFTP parsing ** ** $Id: tftp.h,v 1.1 2001/10/09 23:20:42 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef TFTP_H #define TFTP_H #include "global.h" #include "local.h" void dump_tftp(packet_t *); #endif ipgrab-0.9.10/src/udp.c0000644000175000001440000000611007374605314014005 0ustar farooqusers/**************************************************************************** ** File: udp.c ** ** Author: Mike Borella ** ** Comments: Dump UDP header information ** ** $Id: udp.c,v 1.19 2001/11/15 00:22:36 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #include "global.h" #include "ip_services.h" #include "udp.h" #include "payload.h" extern struct arg_t *my_args; extern strmap_t port_map[]; /*---------------------------------------------------------------------------- ** ** dump_udp() ** ** Parse UDP header and dump fields ** **---------------------------------------------------------------------------- */ void dump_udp(packet_t *pkt) { udp_header_t udp; service_func_t app_src; service_func_t app_dst; /* Set the layer */ set_layer(LAYER_TRANSPORT); /* Stats accounting */ stats_update(STATS_UDP); /* * Get the UDP header */ if (get_packet_bytes((u_int8_t *) &udp, pkt, 8) == 0) return; /* * Conversions */ udp.src = ntohs(udp.src); udp.dst = ntohs(udp.dst); udp.length = ntohs(udp.length); udp.checksum = ntohs(udp.checksum); /* * Minimal mode */ if (my_args->m && !my_args->t) { display_minimal_string("| UDP "); display_minimal((u_int8_t *) &udp.src, 2, DISP_DEC); display_minimal_string("->"); display_minimal((u_int8_t *) &udp.dst, 2, DISP_DEC); display_minimal_string(" "); } else if (!my_args->t) { /* announcement */ display_header_banner("UDP Header"); /* dump fields */ display_strmap("Source port", udp.src, port_map); display_strmap("Destination port", udp.dst, port_map); display("Length", (char *) &udp.length, 2, DISP_DEC); display("Checksum", (char *) &udp.checksum, 2, DISP_DEC); } /* Add state */ state_set_srcport(udp.src); state_set_dstport(udp.dst); /* dump the hex buffer */ if (!my_args->t) hexbuffer_flush(); /* * Let's try to decode the application from the port number. If both * match a decoder, we choose the lowest, assuming that the higher * one is probably ephemeral. */ app_src = port2func(udp.src); app_dst = port2func(udp.dst); if (app_src && app_dst) { if (udp.src < udp.dst) app_src(pkt); else app_dst(pkt); } else { if (app_src) app_src(pkt); else if (app_dst) app_dst(pkt); } return; } ipgrab-0.9.10/src/udp.h0000644000175000001440000000241107153266450014011 0ustar farooqusers/**************************************************************************** ** File: udp.h ** ** Author: Mike Borella ** ** Comments: Generic UDP header structure - an attempt at OS independence ** ** $Id: udp.h,v 1.5 2000/08/30 20:23:04 mborella Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #ifndef UDP_H #define UDP_H #include "global.h" #include "local.h" typedef struct udp_header { u_int16_t src; u_int16_t dst; u_int16_t length; u_int16_t checksum; } udp_header_t; void dump_udp(packet_t *); #endif ipgrab-0.9.10/src/utilities.c0000644000175000001440000001461610637712631015237 0ustar farooqusers/**************************************************************************** ** File: utilities.c ** ** Author: Mike Borella ** ** Comments: General utility functions that are not tied to IPgrab in any ** particular way. ** ** $Id: utilities.c,v 1.13 2007/06/25 10:14:49 farooq-i-azam Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Library General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** *****************************************************************************/ #define BUF_SIZE 128 #include "utilities.h" #include "error.h" #include /* These headers must follow the global includes */ #include /* otherwise FREEBESD barfs */ #include #define SPACESTR_SIZE 128 char space_str[SPACESTR_SIZE]; /*---------------------------------------------------------------------------- ** ** reverse_byte_order() ** ** Reverses the byte order of an arbitrarily long byte string ** **---------------------------------------------------------------------------- */ inline void reverse_byte_order(u_int8_t *s, int len) { u_int8_t * temp; int i; temp = (u_int8_t *) my_malloc(len); for (i = 0; i < len; i++) temp[len-i-1] = s[i]; memcpy(s, temp, len); my_free(temp); } /*---------------------------------------------------------------------------- ** ** isspace_str(char *s, int len) ** ** Returns 1 if the first len bytes of s are whitespace, 0 otherwise. ** **---------------------------------------------------------------------------- */ inline int isspace_str(char *s, int len) { int i; for (i = 0; i < len; i++) { if (!isspace(s[i])) return 0; } return 1; } /*---------------------------------------------------------------------------- ** ** isprint_str(char *s, int len) ** ** Returns 1 if the first len bytes of s are printable, 0 otherwise. ** **---------------------------------------------------------------------------- */ inline int isprint_str(char *s, int len) { int i; for (i = 0; i < len; i++) { if (!(isprint(s[i]) || isspace(s[i]))) return 0; } return 1; } /*---------------------------------------------------------------------------- ** ** argv2str(char **) ** ** Converts an argv[][] style array of strings into a single string, with ** the original string separated by spaces ** **---------------------------------------------------------------------------- */ inline char * argv2str(char **argv) { char **p; u_int len = 0; char *buf; char *src, *dst; p = argv; if (*p == 0) return 0; while (*p) len += strlen(*p++) + 1; buf = (char *) my_malloc (len); p = argv; dst = buf; while ((src = *p++) != NULL) { while ((*dst++ = *src++) != '\0'); dst[-1] = ' '; } dst[-1] = '\0'; return buf; } /*---------------------------------------------------------------------------- ** ** my_malloc() ** ** Performs a malloc but tests for error conditions. ** **---------------------------------------------------------------------------- */ inline void * my_malloc(size_t n) { void * p; /* make sure that we always allocate something in the zero case */ if (n == 0) n = 1; /* do it */ p = malloc(n); if (p == NULL) error_fatal("can't allocate memory: %d bytes", n); return p; } /*---------------------------------------------------------------------------- ** ** my_free() ** ** Frees memory safely by checking for the viability of the pointer ** **---------------------------------------------------------------------------- */ inline void my_free(void * p) { if (p) free(p); } /*---------------------------------------------------------------------------- ** ** dump_hex_and_text() ** ** Displays a buffer in split hex and text format. Kind of like DOS debug :) ** **---------------------------------------------------------------------------- */ inline void dump_hex_and_text(char * buffer, int len) { char hexbuf [BUF_SIZE]; char charbuf [BUF_SIZE]; char * buf_ptr; char * buf_end; int i; /* Set the start and end pointers */ buf_ptr = buffer; buf_end = buffer+len-1; /* Scan each subset and display in hex and ascii format */ do { memset(hexbuf, 0, BUF_SIZE); memset(charbuf, 0, BUF_SIZE); for(i=0;i<18;i++) { if(buf_ptr < buf_end) { snprintf(hexbuf+(i*3), BUF_SIZE-1,"%.2X ",buf_ptr[0] & 0xFF); if(*buf_ptr > 0x1F && *buf_ptr < 0x7E) snprintf(charbuf+i, BUF_SIZE-1,"%c",buf_ptr[0]); else snprintf(charbuf+i, BUF_SIZE-1, "."); buf_ptr++; } } printf("%-54s %s\n",hexbuf,charbuf); } while(buf_ptr < buf_end); } /*---------------------------------------------------------------------------- ** ** ipaddr_space() ** ** Takes an IP address in network byte order, and figures out how many ** spaces are needed to pretty print it so that it lines up with other ** addresses in minimal mode. ** ** Returns -1 on error. **---------------------------------------------------------------------------- */ inline int ipaddr_space(u_int32_t ipaddr) { char * ptr; struct in_addr * ip_holder; ip_holder = (struct in_addr *) &ipaddr; ptr = inet_ntoa(*ip_holder); if (ptr) return 15-strlen(ptr); else return -1; } /*---------------------------------------------------------------------------- ** ** make_space_str() ** ** Given a number of bytes, returns a string of that size. Note that this ** string is a global, defined above. ** ** Returns NULL if the number of sapces requested is not sane (smaller than 0 ** or bigger than SPACESTR_SIZE). ** **---------------------------------------------------------------------------- */ inline char * make_space_str(int n) { int i; if (n < 0 || n > SPACESTR_SIZE-1) return NULL; for (i=0; i