diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/Documentation/Configure.help linux-2.4.19-magnet/Documentation/Configure.help
--- linux-2.4.19/Documentation/Configure.help	Fri Aug  2 18:39:42 2002
+++ linux-2.4.19-magnet/Documentation/Configure.help	Fri Nov  8 08:44:34 2002
@@ -25280,6 +25280,146 @@
 
   If unsure, say N.
 
+MAGNET Kernel Instrumentation
+CONFIG_MAGNET
+  MAGNET: Monitoring Apparatus for General kerNel Event Tracing
+
+  MAGNET is a highly efficient mechanism for exporting kernel events
+  to user space. Events are timestamped from the cycle counter
+  available in nearly all contemporary CPUs. MAGNET was orignally
+  developed to instrument the network subsystem but now instruments
+  several kernel subsystems.
+
+  MAGNET is of primary interest to designers, researchers, and
+  implementors. Even though the overhead associated with it is low and
+  can be safely used by anyone, it is of special interest and hence
+  should be disabled by most people. Say N here.
+
+  Saying Y here will only add the MAGNET instrumentation mechanism.
+  You must select the specific subsystems to instrument from the list
+  below.
+
+  See Documentation/magnet.txt for information on how to use MAGNET.
+
+MAGNET Instrumentation Buffer Size
+CONFIG_MAGNET_BUFSIZE
+  Sets the size of the MAGNET instrumentation buffer in the kernel.
+
+  The default value yields a very low likelihood that event records
+  will be lost on most machines. Increasing the value decreases the
+  probability of event loss, but also decreases amount of kernel
+  memory available for other purposes.
+
+MAGNET Extended Instrumentation
+CONFIG_MAGNET_EXTENDED
+  Enabling this option allows kernel parameters to be exported in
+  event records. Using it increases the size of event records which
+  adds overhead but provides information which may not be available by
+  other means,
+
+  Currently, extended information for network events exports TCP, UDP
+  and IP headers. (Exporting Ethernet headers is in the process of
+  being implemented.) Extended information for other events can easily
+  be added.
+
+  Saying Y here will only add extended instrumentation mechanisms. You
+  must select the specific subsystems to instrument from the list
+  below.
+
+MAGNET Debugging Code (EXPERIMENTAL)
+CONFIG_MAGNET_DEBUG
+  Select to enable debugging code in the MAGNET instrumention. This is
+  of interest to MAGNET developers only. Normally, you would say N
+  here.
+
+MAGNET Benchmarking Code (EXPERIMENTAL)
+CONFIG_MAGNET_BENCHMARK
+  Select to benchmark the MAGNET function wich adds events to the
+  event buffer. This allows the overhead of MAGNET to be estimated by
+  appending a benchmark event after regular instrumentation points.
+  Normally, you would say N here.
+
+MAGNET Network Instrumentation
+CONFIG_MAGNET_NET
+  Select to enable networking instrumention.
+
+  Saying Y here only enables the selection of instrumentation for
+  individual network subsystems. You must select the specific
+  subsystems to instrument from the list below.
+
+MAGNET Socket Instrumentation
+CONFIG_MAGNET_SOCK
+  Select to record socket-layer information about open/close and
+  send/recv calls.
+
+MAGNET Extended Socket Instrumentation
+CONFIG_MAGNET_SOCK_EXT
+  Select to enable extended information about socket-related
+  event.
+
+MAGNET TCP Instrumentation
+CONFIG_MAGNET_TCP
+  Select to record TCP-layer information about data passed down from
+  the socket layer or data passed up from the IP layer.
+
+MAGNET Extended TCP Instrumentation
+CONFIG_MAGNET_TCP_EXT
+  Select to enable extended information about TCP-related events.
+
+MAGNET UDP Instrumentation
+CONFIG_MAGNET_UDP
+  Select to record UDP-layer information about data passed down from
+  the socket layer or data passed up from the IP layer.
+
+MAGNET Extended UDP Instrumentation
+CONFIG_MAGNET_UDP_EXT
+  Select to enable extended information about UDP-related events.
+
+MAGNET IP Instrumentation
+CONFIG_MAGNET_IP
+  Select to record IP-layer information about data passed down from
+  the TCP/UDP layers or data passed up from the device layer.
+
+MAGNET Extended IP Instrumentation
+CONFIG_MAGNET_IP_EXT
+  Select to enable extended information about IP-related events.
+
+MAGNET Generic Network Device Instrumentation
+CONFIG_MAGNET_DEV_NET
+  Select to record network device information about data passed down
+  from the IP layer or data passed up from the actual device driver.
+
+  Note: you are only likely to want this if the device driver for your
+  hardware has not been instrumented yet.
+
+MAGNET Ethernet Instrumentation
+CONFIG_MAGNET_DEV_ETH
+  Select to record selected ethernet device information about data
+  passed down from the device layer or data passed up from the
+  hardware.
+
+  Note: not all ethernet devices have been instrumented. If yours is
+  not, select the generic network device instrumentation above.
+
+MAGNET Extended Ethernet Instrumentation
+CONFIG_MAGNET_DEV_ETH_EXT
+  NOTICE: DO NOT enable this option. It is very likely to cause a
+  kernel oops!
+
+  Select to enable extended information about selected
+  Ethernet-related events.
+
+MAGNET Task Instrumentation
+CONFIG_MAGNET_TASK
+  Select to record task-related information about task
+  creation/destruction events (fork() and exit()) and context switch
+  events. (The latter records when the schedule() function execution
+  begins and ends.)
+
+MAGNET Extended task Instrumentation
+CONFIG_MAGNET_TASK_EXT
+  Select to enable extended information about task-related events.
+
 #
 # A couple of things I keep forgetting:
 #   capitalize: AppleTalk, Ethernet, DOS, DMA, FAT, FTP, Internet,
@@ -25596,6 +25736,7 @@
 # LocalWords:  DMX Domex dmx wellington ftdi sio Accton Billington Corega FEter
 # LocalWords:  MELCO LUA PNA Linksys SNC chkdsk AWACS Webcam RAMFS Ramfs ramfs
 # LocalWords:  ramfiles MAKEDEV pty WDTPCI APA apa
+# LocalWords:  MAGNET recv
 #
 # The following sets edit modes for GNU EMACS
 # Local Variables:
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/Documentation/magnet-install.txt linux-2.4.19-magnet/Documentation/magnet-install.txt
--- linux-2.4.19/Documentation/magnet-install.txt	Wed Dec 31 17:00:00 1969
+++ linux-2.4.19-magnet/Documentation/magnet-install.txt	Thu Nov 14 14:23:07 2002
@@ -0,0 +1,294 @@
+#
+# MAGNET - Monitoring Apparatus for General kerNel Event Tracing
+#
+# Version:	@(#)magnet-install.txt	2.0.0	2002/10/22
+#
+# Authors: Jeff Hay and Mark K. Gardner, radiant-software@lanl.gov
+#
+# History:
+#
+#   2001-03-06 1.0.0  internal release
+#   2002-10-22 2.0.0  public release
+#
+# License:
+#
+# Copyright 2002. The Regents of the University of California.
+#
+# This material was produced under U.S. Government contract
+# W-7405-ENG-36 for Los Alamos National Laboratory, which is operated
+# by the University of California for the U.S. Department of Energy.
+# The Government is granted for itself and other acting on its behalf
+# a paid-up, non-exclusive, irrevocable worldwide license in the
+# material to reproduce, prepare derivative works, and perform
+# publicly and display publicly. Beginning five (5) years after
+# November 6, 2002, subject to additional five-year worldwide
+# renewals, the Government is granted for itself and others acting on
+# its behalf a paid-up, nonexclusive, irrevocable worldwide license
+# in this material to reproduce, prepare derivative works, distribute
+# copies to the public, perform publicly and display publicly, and to
+# permit others to do so. NEITHER THE UNITED STATES NOR THE UNITED
+# STATES DEPARTMENT OF ENERGY, NOR THE UNIVERSITY OF CALIFORNIA, NOR
+# ANY OF THEIR EMPLOYEES, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+# ASSUMES ANY LEGAL LIABLITY OR RESPONSIBILITY FOR THE ACCURACY,
+# COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT,
+# OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE
+# PRIVATELY OWNED RIGHTS.
+#
+# Additionally, this program is free software; you can distribute 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 any later version. Accordingly, 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.
+#
+
+        Step-by-Step instructions on how to install MAGNET
+
+The following instructions assume familiarity in building a kernel
+from source. 
+
+(For more information on how to build a kernel, see
+http://www.linuxdoc.org/HOWTO/Kernel-HOWTO.html. Also some
+distributions have their own way to build a kernel, e.g., Debian. It
+is best to use your distribution's way if there is one.)
+
+1. MAGNET-ize the Linux kernel
+
+  a. Get an official kernel release (e.g., 2.4.19) from
+     http://www.kernel.org/, your favorite Linux kernel repository or
+     from your distribution's repository. Install it, usually in
+     /usr/src. Change to the kernel directory.
+
+  b. Download the MAGNET patch for your kernel version, e.g.,
+     patch-2.4.19-magnet.
+
+     (If a patch for your kernel version is not yet available, select
+     the closest patch. You may need to do some manual work to get the
+     patch installed.)
+
+  c. Patch the kernel "patch -p1 < patch-2.4.19-magnet".
+
+2. Configure the kernel
+
+  a. Configure the kernel with the necessary options for your
+     hardware.
+
+     Make sure to check "YES" when to "Prompt for development and/or
+     incomplete code/drivers" under "Code maturity level options".
+
+  b. Select "MAGNET kernel instrumentation" under the "Kernel hacking"
+     option to enable various choices about configuring MAGNET.
+     Configure MAGNET appropriately.
+
+3. Make, install and activate the MAGNET-ized kernel
+
+4. Build the user-space tools: mkmagnet, magnet-read, magnet-parse and
+   magnet-dump
+
+  a. Make the tools: "cd magnet; make -f Makefile.tools"
+
+  b. Install the tools  in /usr/sbin: "make -f Makefile.tools install"
+
+5. Check for a MAGNET-ized kernel
+
+  a. Reboot.
+
+  b. The existence of /proc/magnet indicates that MAGNET is installed
+     properly. Cat /proc/magnet to see details about the installation.
+
+6. Create MAGNET device file (typically /dev/magnet) by checking
+   /proc/magnet and using the the major/minor numbers found there to
+   create /dev/magnet with mknod.
+
+7. Test MAGNET
+
+  a. Create an empty trace file: "mkmagnet -b <size> <tracefile>"
+
+  b. Collect events: "magnet-read <tracefile>"
+
+  c. Parse events: "magnet-parse <tracefile> > <file>"
+
+8. Optionally enable unattended data collection
+
+   NOTE:  magnet.cron has not been extensively tested since v1.0.0.
+
+  a. Modify the configuration lines of the scripts (magnet.cron and
+     magnet.copy) to reflect your environment.
+
+  b. Create cron job for magnet.cron: "crontab -e"
+
+     # Set up MAGNET to run every day at 12:34 AM
+     34 0 * * * /usr/sbin/magnet.cron
+
+  c. Optionally enable MAGNET at boot-time by placing a symbolic link
+     to magnet.cron in the appropriate rc directory. For example,
+
+     cd /etc/rc3.d
+     ln -s /bin/magnet.cron S89magnet
+
+
+Example:
+
+In this section, we give an example of how we build a MAGNET-ized
+kernel. 
+
+Note: We highly recommend the Debian distribution (www.debian.org) as
+it makes package management almost painless. Since that is the
+distribution we use, the example below shows the steps necessary to
+build and install a MAGNET-ized kernel under Debian.
+
+1. MAGNET-ize the Linux kernel
+
+  a. Get kernel source from kernel.org
+
+       > wget ftp://ftp.kernel.org/pub/linux/kernel/v2.4/linux-2.4.19.tar.bz2
+       > tar jxpf linux-2.4.18.tar.bz2
+       > mv linux-2.4.19 magnet-2.4.18
+
+or download from the Debian
+     distribution:
+
+       > apt-get install kernel-source-2.4.19
+       > cd /usr/src
+       > tar jxpf kernel-source-2.4.19.tar.bz2
+       > mv kernel-source-2.4.19 magnet-2.4.18
+
+  b. Get MAGNET patch off our web site and place in 
+     /usr/src/magnet-2.4.19
+
+  c. Patch the kernel
+
+       > cd magnet-2.4.19
+       > patch -p1 < patch-2.4.19-magnet
+
+2. Configure the kernel
+
+  a. Configure for your hardware. (Here we see one of the benefits of
+     using Debian. A copy of the configuration files for installed
+     kernels are kept in /boot. Copy one of them as your initial
+     configuration.)
+
+       > cp /boot/config-2.4.19 .config
+       > make <config|menuconfig|xconfig>
+
+     Change any options as appropriate but make sure that "Prompt for
+     development and/or incomplete code/drivers" under "Code maturity
+     level options" has been enabled in order to display MAGNET
+     options.
+
+  b. Select "MAGNET kernel instrumentation" under the "Kernel hacking"
+     option to enable various choices about configuring MAGNET. Also
+     select which subsystems you wish to instrument, as shown.
+
+       [*] MAGNET kernel instrumentation
+         (256)   Buffer size (default 256 pages)
+         [*]   Extended instrumentation
+         [ ]   Debugging code
+         [ ]   Benchmarking code
+         [*]   Network instrumentation
+         [*]     Socket layer
+         [ ]       Extended socket instrumentation
+         [*]     TCP layer
+         [ ]       Extended TCP instrumentation
+         [*]     UDP layer
+         [ ]       Eextended UDP instrumentation
+         [*]     IP layer
+         [ ]       Extended IP instrumentation
+         [ ]     Generic network device
+         [*]     Ethernet devices
+         [ ]       Extended ethernet instrumentation
+         [ ]   Task scheduling instrumentation
+
+3. Make, install and activate the MAGNET-ized kernel.
+
+   Here is where Debian really shines!
+
+     > make-kpkg --rootcmd fakeroot clean
+     > make-kpkg --rootcmd fakeroot --revision 1.0 \
+         --append_to_version '-magnet' kernel_image
+     > sudo dpkg -i /usr/src/kernel-image-2.4.19-magnet_1.0_i386.deb
+
+   The latter command may prompt you to create a boot floppy or to
+   install a boot block to activate the new kernel, as shown below.
+   Answer as appropriate. (Typically the defaults are fine so just hit
+   the carriage return twice.)
+
+     Would you like to create a boot floppy now? [No] <cr>
+     You already have a LILO configuration in /etc/lilo.conf
+     Install a boot block using the existing /etc/lilo.conf? [Yes] <cr>
+
+   There... building and installing a kernel is not too painful is it!
+
+   (Note: you may also want to specify modules_image if you have any
+   kernel modules not included in the kernel source that need to be
+   built. The details of doing this are beyond the scope of this
+   document, but the synopsis is that all modules with source code in
+   /usr/src/modules will have package built by make-kpkg ...
+   modules_image" and deposited in /usr/src. Install them with dpkg.)
+
+4. Build and install user-space tools
+
+    > cd /usr/src/magnet-2.4.19/magnet
+    > make -f Makefile.tools
+    > make -f Makefile.tools install
+
+5. Check for a MAGNET-ized kernel
+
+  a. Reboot
+
+  b. Check for /proc/magnet
+
+     > cat /proc/magnet
+
+       ---------------------------------------------------------------
+       MAGNET: Monitoring Apparatus for General kerNel Event Tracing
+       ---------------------------------------------------------------
+       Version: 2.0.0
+       Device Name: /dev/magnet
+       Device Number: 10, 63
+       Buffer Size: 1024 KB (256 pages)
+       Record size: 20 bytes
+       Extended Info: off
+       Socket: on
+       TCP: on
+       UDP: on
+       IP: on
+       Task: off
+       ---------------------------------------------------------------
+       RADIANT (http://www.lanl.gov/radiant)
+       ---------------------------------------------------------------
+
+6. Create MAGNET device file (typically /dev/magnet)
+
+  a. Use magnet.cron to create /dev/magnet
+
+       > magnet.cron
+
+  b. Alternatively, create by hand
+
+       > mknod /dev/magnet c <major> <minor>
+
+     where the major and minor numbers are obtained from /proc/magnet
+     as above.
+
+7. Test MAGNET
+
+  a. Create an empty trace file
+
+    > cd /tmp
+    > mkmagnet mytrace.mag
+
+  b. Collect events
+
+    > magnet-read mytrace.mag
+
+  c. Parse events into human readible form
+
+    > magnet-parse mytrace.mag > mytrace.txt
+
+8. Optionally enable unattended data collection (see above)
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/Documentation/magnet.txt linux-2.4.19-magnet/Documentation/magnet.txt
--- linux-2.4.19/Documentation/magnet.txt	Wed Dec 31 17:00:00 1969
+++ linux-2.4.19-magnet/Documentation/magnet.txt	Thu Nov 14 14:23:29 2002
@@ -0,0 +1,277 @@
+#
+# MAGNET - Monitoring Apparatus for General kerNel Event Tracing
+#
+# Version:	@(#)magnet.txt	2.0.0	2002/10/22
+#
+# Authors: Jeff Hay and Mark K. Gardner, radiant-software@lanl.gov
+#
+# History:
+#
+#   2001-03-06 1.0.0  internal release
+#   2002-10-22 2.0.0  public release
+#
+# License:
+#
+# Copyright 2002. The Regents of the University of California.
+#
+# This material was produced under U.S. Government contract
+# W-7405-ENG-36 for Los Alamos National Laboratory, which is operated
+# by the University of California for the U.S. Department of Energy.
+# The Government is granted for itself and other acting on its behalf
+# a paid-up, non-exclusive, irrevocable worldwide license in the
+# material to reproduce, prepare derivative works, and perform
+# publicly and display publicly. Beginning five (5) years after
+# November 6, 2002, subject to additional five-year worldwide
+# renewals, the Government is granted for itself and others acting on
+# its behalf a paid-up, nonexclusive, irrevocable worldwide license
+# in this material to reproduce, prepare derivative works, distribute
+# copies to the public, perform publicly and display publicly, and to
+# permit others to do so. NEITHER THE UNITED STATES NOR THE UNITED
+# STATES DEPARTMENT OF ENERGY, NOR THE UNIVERSITY OF CALIFORNIA, NOR
+# ANY OF THEIR EMPLOYEES, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+# ASSUMES ANY LEGAL LIABLITY OR RESPONSIBILITY FOR THE ACCURACY,
+# COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT,
+# OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE
+# PRIVATELY OWNED RIGHTS.
+#
+# Additionally, this program is free software; you can distribute 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 any later version. Accordingly, 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.
+#
+
+MAGNET -- Monitoring Apparatus for General kerNel Event Tracing
+
+MAGNET, a research tool created by Los Alamos National Laboratory's
+RADIANT (Research and Development in Advanced Networking Technology)
+team <radiant-software@lanl.gov>, is a low-overhead, high-performance
+generic kernel event monitoring mechanism suitable for benchmarking,
+debugging and measuring performance. While MAGNET can be used to
+monitor any kernel event, this release contains direct support for
+monitoring the network protocol stack and CPU context switches.
+
+========================================================================
+
+History:
+
+This is the second release of MAGNET and the first release to see
+external dissemination. Furthermore, with this release we have subtly
+changed the name. Instead of MAGNeT, standing for "a Monitor for
+Application Generated NEtwork Traffic", MAGNET now stands for
+"Monitoring Apparatus for Generic kerNel Event Tracing" to emphasize
+that the mechanisms are useful for monitoring any kernel event, not
+just network traffic.
+
+The first release was a prototype used to demonstrate feasibility and
+good performance. Many of the published papers about MAGNET describe
+the implementation in the first release. For this reason, we are
+continuing to make the first release available. We emphasize, however,
+that the first release is for historical purposes only. Do not use it.
+
+The second release is much more flexible and robust, as well as having
+a more general trace file format. Various variable and field names
+have been changed to emphasize MAGNET's general applicability for
+monitoring any kernel event. The organization within the kernel has
+also been generalized as well. The configuration options for MAGNET
+are now located under the "Kernel Hacking" category. Based on feedback
+we have received, the configuration process is much more flexible and
+allows the instrumentation to be enabled independently.
+
+========================================================================
+
+Monitoring Network Traffic:
+
+In contrast to traditional traffic monitoring solutions which are
+designed to report traffic on the wire, which may or may not reflect
+the actual traffic patterns that applications generate, MAGNET is
+designed to show network traffic as it progresses through the stack.
+Frequently, application-level and wire-level traffic differ
+dramatically hence MAGNET provides greater insight into the networking
+demands of applications, as well as the effect of each layer in the
+networking stack.
+
+At strategic points in the processing of network traffic (for example,
+when the TCP code hands a packet of data to the IP layer, or when the
+kernel socket code hands data from the TCP layer to the running
+application), an event record, including a high-resolution timestamp,
+is added to a non-swappable kernel circular buffer. The event records
+are read by a user-level application which simply mmaps() the kernel
+circular buffer and reads out of it as it is updated. We have shown
+that this design has minimal impact on system performance.
+
+Currently, the socket, TCP, UDP. and IP layers have been instrumented.
+These have been tested on i386 and PowerPC platforms. The generic
+network device layer has also been instrumented, along with selected
+Ethernet drivers (eepro100, tulip and acenic). Optionally, extended
+information in the form of TCP, UDP and IP headers can be recorded for
+each event (at the cost of a larger performance impact, of course). In
+this mode, MAGNET can be used by protocol designers and implementors
+to debug the workings of their protocols under known conditions.
+
+========================================================================
+
+Monitoring Tasks:
+
+In addition to network instrumentation, task creation (fork()),
+termination (exit()) and context switches have been instrumented with
+no noticeable impact on performance. The latter shows that the
+mechanisms MAGNET provides are light-weight enough that all kernel
+events can be monitored.
+
+========================================================================
+
+Things to keep in mind:
+
+The parameter field for network send/recv operations gives the size of
+the data at that layer including the size of applicable headers. For
+example, sending 80 bytes via TCP yields the following sizes: 80 bytes
+for socket send, 112 bytes for TCP send, 132 bytes for IP send and 146
+bytes for Ethernet send. (The TCP-send size is 112 rather than 100
+bytes because of the TCP options that Linux nearly always sends.)
+Likeweise, sending 136 bytes via UDP yields the following sizes: 136
+bytes for socket send, 144 for UDP send, 164 for IP send and 178 for
+Ethernet send.
+
+DO NOT enable extended information for the Ethernet drivers. There is
+a NULL pointer problem which is guaranteed to oops your kernel! This
+will hopefully be fixed in a maintenance release.
+
+========================================================================
+
+Future:
+
+Currently, the identifier field of the MAGNET data record is
+0x00000000 for Ethernet, generic network device and IP receives,
+rather than a valid socket ID, because socket look-up does not occur
+until UDP/TCP. We are considering looking up the socket early but have
+not implemented it.
+
+More testing needs to be done on the extended data capability. Based
+on internal testing, we believe the code to be correct but welcome
+feedback and bug fixes. The Ethernet extended data NULL pointer bug
+needs to be squashed.
+
+We intend to instrument drivers for all the NICs we have. Besides
+those listed above, we will be instrumenting the Broadcom and e1000
+drivers eventually. Those who are interested in instrumenting other
+drivers are encouraged to send patches licensed under the GPL.
+
+We are also considering the possibility of instrumenting other kernel
+subsystems as needed. Please instrument any subsystems of interest to
+you and send us patches.
+
+========================================================================
+
+Files: 
+
+MAGNET currently consists of the following files:
+
+include/linux/magnet.h
+
+  Header file to describe MAGNET data types, for both kernel and
+  user-level programs. Also defines kernel function prototypes.
+
+magnet/magnet.c
+
+  The code to maintain the circular kernel buffer and perform MAGNET
+  initialization and tear-down.
+
+magnet/magnet-read.c
+
+  User-level program to read MAGNET data from the kernel buffer. This
+  program works by memory mapping a pre-existing file and transferring
+  bytes of data from the kernel to the file. Useful in its own right
+  for reading events from the kernel buffer, it is also a model of how
+  to write such an application.
+
+magnet/magnet-parse.c
+
+  Program for reading binary trace files collected from the kernel
+  buffer by magnet-read. It converts the data in a human-readable
+  form, taking into account endian and cycle timing issues.
+
+magnet/magnet-dump.c
+
+  Program for reading binary trace files collected from the kernel
+  buffer by magnet-read. It displays the data in a raw, hexadecimal
+  form. Good for debugging modifications to both the kernel code and
+  user-level tools
+
+magnet/mkmagnet.c
+
+  Program to create an empty MAGNET trace files to be filled with data
+  by magnet-read.
+
+magnet/Config.in
+magnet/Makefile
+magnet/Makefile.tools
+
+  The kernel configuration and make files for MAGNET. The file
+  Makefile.tools is used to build mkmagnet, magnet-read, magnet-parse
+  and magnet-dump (via make -f Makefile.tools).
+
+magnet/magnet.cron
+magnet/magnet.copy
+
+  Simple shell scripts to automate running the above user space
+  program to collect and archive data. magnet.cron also takes care of
+  creating the magnet device file (see below). They are relics of v1.0
+  and may require updating or modification.
+
+Documentation/magnet.txt
+Documentation/magnet-install.txt
+
+  Text files containing information about MAGNET and its installation.
+
+/proc/magnet
+
+  Reading this file displays various information about the currently
+  running MAGNET version, including size of data packets, size of the
+  kernel buffer, major/minor numbers for /dev/magnet, comfiguration
+  options and other details.
+
+/dev/magnet
+
+   A special device file must be created to perform the mmap()ing from
+   the kernel to user-level space. /proc/magnet contains the
+   major/minor mode numbers this special file requires.
+
+MAGNET also consists of modifications to several kernel files.
+
+========================================================================
+
+Compilation options:
+
+The following hierarchy of kernel compilation options are available:
+
+CONFIG_MAGNET
+  CONFIG_MAGNET_BUFSIZE
+  CONFIG_MAGNET_EXTENDED
+  CONFIG_MAGNET_DEBUG
+  CONFIG_MAGNET_BENCHMARK
+  CONFIG_MAGNET_NET
+    CONFIG_MAGNET_SOCK
+      CONFIG_MAGNET_SOCK_EXT
+    CONFIG_MAGNET_TCP
+      CONFIG_MAGNET_TCP_EXT
+    CONFIG_MAGNET_UDP
+      CONFIG_MAGNET_UDP_EXT
+    CONFIG_MAGNET_IP
+      CONFIG_MAGNET_IP_EXT
+    CONFIG_MAGNET_DEV_NET
+    CONFIG_MAGNET_DEV_ETH
+      CONFIG_MAGNET_DEV_ETH_EXT
+  CONFIG_MAGNET_TASK
+    CONFIG_MAGNET_TASK_EXT
+
+For more information see Document/Configure.help or select help for a
+specific item within a configuration utility (e.g., menuconfig).
+
+========================================================================
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/Makefile linux-2.4.19-magnet/Makefile
--- linux-2.4.19/Makefile	Fri Aug  2 18:39:46 2002
+++ linux-2.4.19-magnet/Makefile	Fri Nov  8 07:44:00 2002
@@ -125,7 +125,7 @@
 NETWORKS	=net/network.o
 
 LIBS		=$(TOPDIR)/lib/lib.a
-SUBDIRS		=kernel drivers mm fs net ipc lib
+SUBDIRS		=kernel drivers mm fs net ipc lib magnet
 
 DRIVERS-n :=
 DRIVERS-y :=
@@ -188,6 +188,7 @@
 DRIVERS-$(CONFIG_BLUEZ) += drivers/bluetooth/bluetooth.o
 DRIVERS-$(CONFIG_HOTPLUG_PCI) += drivers/hotplug/vmlinux-obj.o
 DRIVERS-$(CONFIG_ISDN_BOOL) += drivers/isdn/vmlinux-obj.o
+DRIVERS-$(CONFIG_MAGNET) += magnet/libmagnet.a
 
 DRIVERS := $(DRIVERS-y)
 
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/arch/i386/config.in linux-2.4.19-magnet/arch/i386/config.in
--- linux-2.4.19/arch/i386/config.in	Fri Aug  2 18:39:42 2002
+++ linux-2.4.19-magnet/arch/i386/config.in	Tue Nov 12 17:23:45 2002
@@ -425,4 +425,10 @@
    bool '  Compile the kernel with frame pointers' CONFIG_FRAME_POINTER
 fi
 
+# Enable/disable MAGNET 
+bool 'MAGNET kernel instrumentation' CONFIG_MAGNET
+if [ "$CONFIG_MAGNET" = "y" ]; then
+ 	 source magnet/Config.in
+fi
+
 endmenu
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/arch/ppc/config.in linux-2.4.19-magnet/arch/ppc/config.in
--- linux-2.4.19/arch/ppc/config.in	Fri Aug  2 18:39:43 2002
+++ linux-2.4.19-magnet/arch/ppc/config.in	Tue Nov 12 17:23:52 2002
@@ -401,4 +401,11 @@
 bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ
 bool 'Include kgdb kernel debugger' CONFIG_KGDB
 bool 'Include xmon kernel debugger' CONFIG_XMON
+
+# Enable/disable MAGNET 
+bool 'MAGNET kernel instrumentation' CONFIG_MAGNET
+if [ "$CONFIG_MAGNET" = "y" ]; then
+ 	 source magnet/Config.in
+fi
+
 endmenu
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/drivers/net/acenic.c linux-2.4.19-magnet/drivers/net/acenic.c
--- linux-2.4.19/drivers/net/acenic.c	Fri Aug  2 18:39:44 2002
+++ linux-2.4.19-magnet/drivers/net/acenic.c	Fri Nov  8 13:00:14 2002
@@ -84,6 +84,10 @@
 #include <asm/uaccess.h>
 
 
+#ifdef CONFIG_MAGNET_DEV_ETH
+#include <linux/magnet.h>
+#endif /* CONFIG_MAGNET_DEV_ETH */
+
 #undef INDEX_DEBUG
 
 #ifdef CONFIG_ACENIC_OMIT_TIGON_I
@@ -2276,6 +2280,11 @@
 			skb->ip_summed = CHECKSUM_NONE;
 		}
 
+#ifdef CONFIG_MAGNET_DEV_ETH
+			/* Mark recv: MAC header already stripped off; add size back */
+			MAGNET_ADD(MAGNET_ETH_RECV, skb->sk, skb->len + 14, MAGNET_NO_DATA);
+#endif /* CONFIG_MAGNET_DEV_ETH */
+
 		/* send it up */
 #if ACENIC_DO_VLAN
 		if (ap->vlgrp && (bd_flags & BD_FLG_VLAN_TAG)) {
@@ -2828,6 +2837,11 @@
 		}
 	}
 #endif
+
+#ifdef CONFIG_MAGNET_DEV_ETH
+	/* Mark xmit */
+	MAGNET_ADD(MAGNET_ETH_SEND, skb->sk, skb->len, MAGNET_NO_DATA);
+#endif /* CONFIG_MAGNET_DEV_ETH */
 
  	wmb();
  	ap->tx_prd = idx;
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/drivers/net/eepro100.c linux-2.4.19-magnet/drivers/net/eepro100.c
--- linux-2.4.19/drivers/net/eepro100.c	Fri Aug  2 18:39:44 2002
+++ linux-2.4.19-magnet/drivers/net/eepro100.c	Tue Nov 12 18:49:45 2002
@@ -115,6 +115,10 @@
 #include <linux/skbuff.h>
 #include <linux/ethtool.h>
 
+#ifdef CONFIG_MAGNET_DEV_ETH
+#include <linux/magnet.h>
+#endif /* CONFIG_MAGNET_DEV_ETH */
+
 MODULE_AUTHOR("Maintainer: Andrey V. Savochkin <saw@saw.sw.com.sg>");
 MODULE_DESCRIPTION("Intel i82557/i82558/i82559 PCI EtherExpressPro driver");
 MODULE_LICENSE("GPL");
@@ -1436,6 +1440,11 @@
 	outb(CUResume, ioaddr + SCBCmd);
 	sp->last_cmd = (struct descriptor *)&sp->tx_ring[entry];
 
+#ifdef CONFIG_MAGNET_DEV_ETH
+	/* Mark xmit */
+	MAGNET_ADD(MAGNET_ETH_SEND, skb->sk, skb->len, MAGNET_NO_DATA);
+#endif /* CONFIG_MAGNET_DEV_ETH */
+
 	/* Leave room for set_rx_mode(). If there is no more space than reserved
 	   for multicast filter mark the ring as full. */
 	if ((int)(sp->cur_tx - sp->dirty_tx) >= TX_QUEUE_LIMIT) {
@@ -1793,6 +1802,11 @@
 						PKT_BUF_SZ + sizeof(struct RxFD), PCI_DMA_FROMDEVICE);
 			}
 			skb->protocol = eth_type_trans(skb, dev);
+
+#ifdef CONFIG_MAGNET_DEV_ETH
+			MAGNET_ADD(MAGNET_ETH_RECV, skb->sk, pkt_len, MAGNET_NO_DATA);
+#endif /* CONFIG_MAGNET_DEV_ETH */
+
 			netif_rx(skb);
 			sp->stats.rx_packets++;
 			sp->stats.rx_bytes += pkt_len;
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/drivers/net/tulip/interrupt.c linux-2.4.19-magnet/drivers/net/tulip/interrupt.c
--- linux-2.4.19/drivers/net/tulip/interrupt.c	Fri Nov  9 14:45:35 2001
+++ linux-2.4.19-magnet/drivers/net/tulip/interrupt.c	Fri Nov  8 13:01:03 2002
@@ -19,6 +19,10 @@
 #include <linux/etherdevice.h>
 #include <linux/pci.h>
 
+#ifdef CONFIG_MAGNET_DEV_ETH
+#include <linux/magnet.h>
+#endif /* CONFIG_MAGNET_DEV_ETH */
+
 
 int tulip_rx_copybreak;
 unsigned int tulip_max_interrupt_work;
@@ -209,6 +213,12 @@
 				tp->rx_buffers[entry].mapping = 0;
 			}
 			skb->protocol = eth_type_trans(skb, dev);
+
+#ifdef CONFIG_MAGNET_DEV_ETH
+			/* Mark recv (MAC header already stripped off; add size back) */
+			MAGNET_ADD(MAGNET_ETH_RECV, skb->sk, skb->len + 14, MAGNET_NO_DATA);
+#endif /* CONFIG_MAGNET_DEV_ETH */
+
 #ifdef CONFIG_NET_HW_FLOWCONTROL
                         mit_sel =
 #endif
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/drivers/net/tulip/tulip_core.c linux-2.4.19-magnet/drivers/net/tulip/tulip_core.c
--- linux-2.4.19/drivers/net/tulip/tulip_core.c	Fri Aug  2 18:39:44 2002
+++ linux-2.4.19-magnet/drivers/net/tulip/tulip_core.c	Fri Nov  8 07:47:48 2002
@@ -35,6 +35,10 @@
 #include <asm/pbm.h>
 #endif
 
+#ifdef CONFIG_MAGNET_DEV_ETH
+#include <linux/magnet.h>
+#endif /* CONFIG_MAGNET_DEV_ETH */
+
 static char version[] __devinitdata =
 	"Linux Tulip driver version " DRV_VERSION " (" DRV_RELDATE ")\n";
 
@@ -707,6 +711,11 @@
 	u32 flag;
 	dma_addr_t mapping;
 	unsigned long eflags;
+
+#ifdef CONFIG_MAGNET_DEV_ETH
+	/* Mark xmit */
+	MAGNET_ADD(MAGNET_ETH_SEND, skb->sk, skb->len, MAGNET_NO_DATA);
+#endif /* CONFIG_MAGNET_DEV_ETH */
 
 	spin_lock_irqsave(&tp->lock, eflags);
 
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/include/linux/magnet.h linux-2.4.19-magnet/include/linux/magnet.h
--- linux-2.4.19/include/linux/magnet.h	Wed Dec 31 17:00:00 1969
+++ linux-2.4.19-magnet/include/linux/magnet.h	Thu Nov 14 14:22:42 2002
@@ -0,0 +1,372 @@
+/*
+-- MAGNET -- Monitoring Apparatus for General kerNel Event Tracing
+--
+-- Version:	@(#)magnet.h	2.0.0	2002/10/22
+--
+-- Authors: Jeff Hay and Mark K. Gardner, radiant-software@lanl.gov
+--
+-- History:
+--
+--   2001-03-06 1.0.0  internal release
+--   2002-10-22 2.0.0  public release
+--
+-- License:
+--
+-- Copyright 2002. The Regents of the University of California.
+--
+-- This material was produced under U.S. Government contract
+-- W-7405-ENG-36 for Los Alamos National Laboratory, which is operated
+-- by the University of California for the U.S. Department of Energy.
+-- The Government is granted for itself and other acting on its behalf
+-- a paid-up, non-exclusive, irrevocable worldwide license in the
+-- material to reproduce, prepare derivative works, and perform
+-- publicly and display publicly. Beginning five (5) years after
+-- November 6, 2002, subject to additional five-year worldwide
+-- renewals, the Government is granted for itself and others acting on
+-- its behalf a paid-up, nonexclusive, irrevocable worldwide license
+-- in this material to reproduce, prepare derivative works, distribute
+-- copies to the public, perform publicly and display publicly, and to
+-- permit others to do so. NEITHER THE UNITED STATES NOR THE UNITED
+-- STATES DEPARTMENT OF ENERGY, NOR THE UNIVERSITY OF CALIFORNIA, NOR
+-- ANY OF THEIR EMPLOYEES, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+-- ASSUMES ANY LEGAL LIABLITY OR RESPONSIBILITY FOR THE ACCURACY,
+-- COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT,
+-- OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE
+-- PRIVATELY OWNED RIGHTS.
+--
+-- Additionally, this program is free software; you can distribute 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 any later version. Accordingly, 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.
+*/
+
+#ifndef _MAGNET_H
+#define _MAGNET_H
+
+#include <asm/page.h>  /* Need PAGE_SIZE definition */
+#include <asm/timex.h>
+
+#ifdef __KERNEL__
+#include <linux/ip.h>
+#include <linux/tcp.h>
+#include <linux/udp.h>
+#include <linux/if_ether.h>
+typedef struct ethhdr ETHHDR;
+#include <net/sock.h>
+#else /* ! __KERNEL__ */
+#include <netinet/ip.h>
+#include <netinet/tcp.h>
+#include <netinet/udp.h>
+#include <netinet/if_ether.h>
+typedef struct ether_header ETHHDR;
+#include <sys/types.h>
+#endif /* __KERNEL__ */
+
+
+#ifndef CONFIG_MAGNET_BUFSIZE
+#define CONFIG_MAGNET_BUFSIZE 256
+#endif /*CONFIG_MAGNET_BUFSIZE */
+#define MAGNET_DATA_SIZE  (CONFIG_MAGNET_BUFSIZE * PAGE_SIZE)
+
+/*
+-- MAGNET version number:  MM.NN.RR.VV (0xMMNNRRVV), where
+--                 Major:  MM
+--                 Minor:  NN
+--              Revision:  RR
+--              Reserved:  VV (currently 0x00)
+--
+--   History:
+--
+--      0.00.00  Before MAGNET version numbers
+--      0.01.00  CPU cycle counter in KHz not Hz.
+--      0.02.00  PowerPC port, endian-aware
+--      0.03.00  Added socket open and close events
+--      0.04.00  Added date info record
+--      0.05.00  Added CPU instrumentation
+--      0.06.00  Generalization and clean up for release
+--      1.00.00  First public release
+--      2.00.00  Second public release (extensive changes)
+*/
+#define MAGNET_MAJOR    2
+#define MAGNET_MINOR    0
+#define MAGNET_REVISION 0
+
+/* Make sure version data is valid then construct version */
+#if MAGNET_MAJOR > 255
+#error MAGNET_MAJOR > 255
+#endif
+#if MAGNET_MINOR > 255
+#error MAGNET_MINOR > 255
+#endif
+#if MAGNET_REVISION > 255
+#error MAGNET_REVISION > 255
+#endif
+#define MAGNET_MKVERSION(m,n,r) (((((m<<8)+n)<<8)+r)<<8)
+#define MAGNET_VERSION \
+	MAGNET_MKVERSION(MAGNET_MAJOR,MAGNET_MINOR,MAGNET_REVISION)
+
+/*
+-- MAGNET event types
+*/
+typedef enum {
+  MAGNET_LOST           = 0x00000000, /* Lost [param=lost-records-count] */
+
+  MAGNET_SOCK_OPEN      = 0x00000001, /* App called open() [param=socktype] */
+  MAGNET_SOCK_CLOSE     = 0x00000002, /* App called close() [param=0] */
+  MAGNET_SOCK_SEND      = 0x00000003, /* App called send() */
+  MAGNET_SOCK_RECV      = 0x00000004, /* App called recv() */
+
+  MAGNET_TCP_SEND       = 0x00000005, /* Using TCP to send a msg */
+  MAGNET_TCP_RECV       = 0x00000006, /* Using TCP to recv a msg */
+
+  MAGNET_UDP_SEND       = 0x00000007, /* Using UDP to send a msg */
+  MAGNET_UDP_RECV       = 0x00000008, /* Using UDP to recv a msg */
+
+  MAGNET_IP_SEND        = 0x00000009, /* Using IP to send a msg  */
+  MAGNET_IP_RECV        = 0x0000000A, /* Using IP to recv a msg  */
+
+  MAGNET_ETH_SEND       = 0x0000000B, /* Using Ethernet to send a msg */
+  MAGNET_ETH_RECV       = 0x0000000C, /* Using Ethernet to recv a msg */
+
+  MAGNET_DEV_SEND       = 0x0000000D, /* Using device to send a msg */
+  MAGNET_DEV_RECV       = 0x0000000E, /* Using device to recv a msg */
+
+  MAGNET_TASK_FORK      = 0x00000100, /* Create a process  */
+  MAGNET_TASK_EXIT      = 0x00000101, /* Exit from a process  */
+  MAGNET_TASK_CTX_IN    = 0x00000102, /* Before CTX switch */
+  MAGNET_TASK_CTX_OUT   = 0x00000103, /* After CTX switch  */
+
+  MAGNET_SYSINFO        = 0x01234567, /* System Info */
+  MAGNET_DATEINFO       = 0x01234568, /* Date Info */
+
+  MAGNET_BENCHMARK      = 0xFFFFFFFE, /* Timing magnet_add [param=cycles] */
+
+  MAGNET_EMPTY          = 0xFFFFFFFF, /* Empty slot */
+} MAGNET_EVENT;
+
+/*
+-- Data and routines for extended instrumentation.
+--
+-- Using these significantly adds to the space magnet packets take up
+-- in memory, but provides very detailed reporting about the current
+-- running state.
+--
+-- Note: need to make more platform-generic... 
+--       Right now it is Linux-specific.
+*/
+
+/*
+-- Use these to construct/destruct the parameter field of SOCK_OPEN:
+--
+--    Format: PPPPSSTT, where PPPP is the process id, 
+--                            SS is socket file descriptor
+--                            TT is the socket type (e.g., TCP, UDP)
+*/
+#define magnet_mksockparm(p,s,t) ((((p << 8) | s) << 8) | t)
+#define magnet_sockparm_getpid(p)  ((p >> 16) & 0XFFFF)
+#define magnet_sockparm_getsid(p)  ((p >> 8) & 0xFF)
+#define magnet_sockparm_gettype(p) (p & 0xFF)
+
+struct magnet_sock {
+	int  domain;
+	int  protocol;
+};
+
+#define MAGNET_TCPHDR_SIZE  60 /* TCP hdr is up to 60 bytes with opts */
+struct magnet_tcp {
+	struct tcphdr  hdr;
+	unsigned char  opt[MAGNET_TCPHDR_SIZE - sizeof(struct tcphdr)];
+#ifdef CONFIG_MAGNET_TCP_INFO
+	struct tcp_info info; // Still need to implement fill and parse!
+#endif /* CONFIG_MAGNET_TCP_INFO */
+};
+
+#define MAGNET_UDPHDR_SIZE sizeof(struct udphdr)
+struct magnet_udp {
+	struct udphdr  hdr;
+};
+
+#define MAGNET_IPHDR_SIZE 60 /* IP hdr is up to 60 bytes with options */
+struct magnet_ip {
+	struct iphdr   hdr;
+	unsigned char  opt[MAGNET_IPHDR_SIZE - sizeof(struct iphdr)];
+};
+
+struct magnet_eth {
+	ETHHDR  hdr;
+};
+
+struct magnet_task {
+	pid_t  pid;
+};
+
+/* All of the conditional-cruft is to minimize overhead! */
+union magnet_ext_data {
+#	ifdef CONFIG_MAGNET_SOCK_EXT
+  struct magnet_sock  sock;
+#	endif /* CONFIG_MAGNET_SOCK_EXT */
+#	ifdef CONFIG_MAGNET_TCP_EXT
+  struct magnet_tcp   tcp;
+#	endif /* CONFIG_MAGNET_TCP_EXT */
+#	ifdef CONFIG_MAGNET_UDP_EXT
+  struct magnet_udp   udp;
+#	endif /* CONFIG_MAGNET_UDP_EXT */
+#	ifdef CONFIG_MAGNET_IP_EXT
+  struct magnet_ip    ip;
+#	endif /* CONFIG_MAGNET_DEV_ETH_EXT */
+#	ifdef CONFIG_MAGNET_DEV_ETH_EXT
+  struct magnet_eth    eth;
+#	endif /* CONFIG_MAGNET_IP_EXT */
+#	ifdef CONFIG_MAGNET_TASK_EXT
+  struct magnet_task  task;
+#	endif /* CONFIG_MAGNET_TASK_EXT */
+};
+
+/*
+-- MAGNET record format - the interpretation depends on event type:
+--
+--   Field         System-Info        Date-Info               All-Other
+--   ---------     --------------     -------------------     ----------
+--   event         MAGNET_SYSINFO     MAGNET_DATEINFO         event
+--   id            MAGNET_VERSION     seconds-since-epoch     id
+--   timestamp     combined-sizes     timestamp               timestamp
+--   parm          cpu-speed          usec-past-seconds       parm
+--   data          -                  -                       data
+--
+-- where combined-sizes = (MAGNET_DATA_Size << 32) | sizeof(struct magnet_data)
+*/
+struct magnet_data {
+	unsigned int           event;      /* Kind of event */
+  unsigned int           id;         /* Abstract identifier */
+  unsigned long long     timestamp;  /* Time of event (cycle counter) */
+  unsigned int           param;      /* Usually size (in bytes) of event... */
+                                     /* ...but is processor ID for tasks */
+#ifdef CONFIG_MAGNET_EXTENDED
+	union magnet_ext_data  data;       /* Event-specific extended data */
+#endif /* CONFIG_MAGNET_EXTENDED */
+} __attribute__ ((packed));
+
+/*============================================================================
+--
+-- Everything below here is only meant for kernel mode.
+--
+-- NOTE: the crufty conditionals are meant to reduce overhead where possible.
+--
+*/
+#ifdef __KERNEL__
+
+/* Initialize MAGNET */
+extern void magnet_init(void);
+
+/* Add an event to a per-socket queue */
+#ifdef CONFIG_MAGNET_EXTENDED
+extern void magnet_add(unsigned int event, unsigned int id, int param, 
+		unsigned int size, union magnet_ext_data *data);
+#else
+	extern void magnet_add(unsigned int event, unsigned int id, int param);
+#endif /* CONFIG_MAGNET_EXTENDED */
+
+#define MAGNET_EXT(x) ((union magnet_ext_data *) x) /* Convenience Macro */
+
+#ifdef CONFIG_MAGNET_EXTENDED
+#	define MAGNET_NO_DATA  0, NULL
+# ifndef CONFIG_MAGNET_BENCHMARK
+#	  define MAGNET_ADD(e, i, p, d) magnet_add(e, (unsigned int) i, p, d)
+#  else
+#	  define MAGNET_ADD(e, i, p, d) \
+      { unsigned long long t2, t1 = get_cycles(); \
+        magnet_add(e, (unsigned int) i, p, d); \
+        t2 = get_cycles(); \
+        magnet_add(MAGNET_BENCHMARK, 0, t2 - t1, MAGNET_NO_DATA); \
+      }
+#  endif /* CONFIG_MAGNET_BENCHMARK */
+#else
+#	define MAGNET_NO_DATA
+# ifndef CONFIG_MAGNET_BENCHMARK
+#	  define MAGNET_ADD(e, i, p, d) magnet_add(e, (unsigned int) i, p)
+#  else
+#	  define MAGNET_ADD(e, i, p, d) \
+      { unsigned long long t2, t1 = get_cycles(); \
+        magnet_add(e, (unsigned int) i, p); \
+        t2 = get_cycles(); \
+        magnet_add(MAGNET_BENCHMARK, 0, t2 - t1); \
+      }
+#  endif /* CONFIG_MAGNET_BENCHMARK */
+#endif /* CONFIG_MAGNET_EXTENDED */
+
+#ifdef CONFIG_MAGNET_EXTENDED
+#	ifdef CONFIG_MAGNET_SOCK_EXT
+#		define MAGNET_SOCK_DATA(sock) sizeof(struct magnet_sock), MAGNET_EXT(sock)
+#	else
+#		define MAGNET_SOCK_DATA(sock) MAGNET_NO_DATA
+#	endif /* CONFIG_MAGNET_SOCK_EXT */
+#else
+#	define MAGNET_SOCK_DATA(sock)
+#endif /* CONFIG_MAGNET_EXTENDED */
+
+#ifdef CONFIG_MAGNET_EXTENDED
+#	ifdef CONFIG_MAGNET_TCP_EXT
+#		define MAGNET_TCP_DATA(tcp) \
+			/* Since TCP extended data may not be working yet, play it safe! */ \
+			tcp ? 4 * tcp->doff : MAGNET_TCPHDR_SIZE, MAGNET_EXT(tcp)
+#	else
+#		define MAGNET_TCP_DATA(tcp) MAGNET_NO_DATA
+#	endif /* CONFIG_MAGNET_TCP_EXT */
+#else
+#	define MAGNET_TCP_DATA(size,tcp)
+#endif /* CONFIG_MAGNET_EXTENDED */
+
+#ifdef CONFIG_MAGNET_EXTENDED
+#	ifdef CONFIG_MAGNET_UDP_EXT
+#		define MAGNET_UDP_DATA(udp) sizeof(struct udphdr), MAGNET_EXT(udp)
+#	else
+#		define MAGNET_UDP_DATA(udp) MAGNET_NO_DATA
+#	endif /* CONFIG_MAGNET_UDP_EXT */
+#else
+#	define MAGNET_UDP_DATA(udp)
+#endif /* CONFIG_MAGNET_EXTENDED */
+
+#ifdef CONFIG_MAGNET_EXTENDED
+#	ifdef CONFIG_MAGNET_IP_EXT
+#		define MAGNET_IP_DATA(ip) \
+			/* Since IP extended data may not be working yet, play it safe! */ \
+			ip ? 4 * ip->ihl : MAGNET_IPHDR_SIZE, MAGNET_EXT(ip)
+#	else
+#		define MAGNET_IP_DATA(ip) MAGNET_NO_DATA
+#	endif /* CONFIG_MAGNET_IP_EXT */
+#else
+#	define MAGNET_IP_DATA(size,ip)
+#endif /* CONFIG_MAGNET_EXTENDED */
+
+#ifdef CONFIG_MAGNET_EXTENDED
+#	ifdef CONFIG_MAGNET_DEV_ETH_EXT
+#		define MAGNET_ETH_DATA(eth) \
+			eth ? sizeof(struct ethhdr) : 0, MAGNET_EXT(eth)
+#	else
+#		define MAGNET_ETH_DATA(eth) MAGNET_NO_DATA
+#	endif /* CONFIG_MAGNET_DEV_ETH_EXT */
+#else
+#	define MAGNET_ETH_DATA(eth)
+#endif /* CONFIG_MAGNET_EXTENDED */
+
+#ifdef CONFIG_MAGNET_EXTENDED
+#	ifdef CONFIG_MAGNET_TASK_EXT
+#		define MAGNET_TASK_DATA(task) sizeof(pid_t), MAGNET_EXT(&task->pid)
+#	else
+#		define MAGNET_TASK_DATA(task) MAGNET_NO_DATA
+#	endif /* CONFIG_MAGNET_TASK_EXT */
+#else
+#	define MAGNET_TASK_DATA(tsk)
+#endif /* CONFIG_MAGNET_EXTENDED */
+
+#endif /* __KERNEL__ */
+/*===========================================================================*/
+
+#endif	/* _MAGNET_H */
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/init/main.c linux-2.4.19-magnet/init/main.c
--- linux-2.4.19/init/main.c	Fri Aug  2 18:39:46 2002
+++ linux-2.4.19-magnet/init/main.c	Tue Nov 12 17:22:37 2002
@@ -69,6 +69,10 @@
 #include <asm/smp.h>
 #endif
 
+#ifdef CONFIG_MAGNET
+#include <linux/magnet.h>
+#endif /* CONFIG_MAGNET */
+
 /*
  * Versions of gcc older than that listed below may actually compile
  * and link okay, but the end product can have subtle run time bugs.
@@ -522,6 +526,11 @@
 #ifdef CONFIG_TC
 	tc_init();
 #endif
+
+#ifdef CONFIG_MAGNET
+  /* MAGNET Instrumentation Interface. */
+	magnet_init();
+#endif /* CONFIG_MAGNET */
 
 	/* Networking initialization needs a process context */ 
 	sock_init();
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/kernel/exit.c linux-2.4.19-magnet/kernel/exit.c
--- linux-2.4.19/kernel/exit.c	Fri Aug  2 18:39:46 2002
+++ linux-2.4.19-magnet/kernel/exit.c	Fri Nov  8 07:43:15 2002
@@ -21,6 +21,10 @@
 #include <asm/pgtable.h>
 #include <asm/mmu_context.h>
 
+#ifdef CONFIG_MAGNET_TASK
+#include <linux/magnet.h>
+#endif /* CONFIG_MAGNET_TASK */
+
 extern void sem_exit (void);
 extern struct task_struct *child_reaper;
 
@@ -472,6 +476,9 @@
 
 	tsk->exit_code = code;
 	exit_notify();
+#ifdef CONFIG_MAGNET_TASK
+	MAGNET_ADD(MAGNET_TASK_EXIT, tsk, code, MAGNET_TASK_DATA(tsk));
+#endif /* CONFIG_MAGNET_TASK */
 	schedule();
 	BUG();
 /*
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/kernel/fork.c linux-2.4.19-magnet/kernel/fork.c
--- linux-2.4.19/kernel/fork.c	Fri Aug  2 18:39:46 2002
+++ linux-2.4.19-magnet/kernel/fork.c	Fri Nov  8 07:43:15 2002
@@ -28,6 +28,10 @@
 #include <asm/uaccess.h>
 #include <asm/mmu_context.h>
 
+#ifdef CONFIG_MAGNET_TASK
+#include <linux/magnet.h>
+#endif /* CONFIG_MAGNET_TASK */
+
 /* The idle threads do not count.. */
 int nr_threads;
 int nr_running;
@@ -750,6 +754,10 @@
 
 	if (p->ptrace & PT_PTRACED)
 		send_sig(SIGSTOP, p, 1);
+
+#ifdef CONFIG_MAGNET_TASK
+	MAGNET_ADD(MAGNET_TASK_FORK, p, 0, MAGNET_TASK_DATA(p));
+#endif /* CONFIG_MAGNET_TASK */
 
 	wake_up_process(p);		/* do this last */
 	++total_forks;
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/kernel/sched.c linux-2.4.19-magnet/kernel/sched.c
--- linux-2.4.19/kernel/sched.c	Fri Aug  2 18:39:46 2002
+++ linux-2.4.19-magnet/kernel/sched.c	Fri Nov  8 10:16:59 2002
@@ -33,6 +33,10 @@
 #include <asm/uaccess.h>
 #include <asm/mmu_context.h>
 
+#ifdef CONFIG_MAGNET_TASK
+#include <linux/magnet.h>
+#endif /* CONFIG_MAGNET_TASK */
+
 extern void timer_bh(void);
 extern void tqueue_bh(void);
 extern void immediate_bh(void);
@@ -553,6 +557,10 @@
 	struct list_head *tmp;
 	int this_cpu, c;
 
+#ifdef CONFIG_MAGNET_TASK
+	MAGNET_ADD(MAGNET_TASK_CTX_OUT, current, current->processor, 
+			MAGNET_TASK_DATA(current));
+#endif /* CONFIG_MAGNET_TASK */
 
 	spin_lock_prefetch(&runqueue_lock);
 
@@ -701,6 +709,12 @@
 	reacquire_kernel_lock(current);
 	if (current->need_resched)
 		goto need_resched_back;
+
+#ifdef CONFIG_MAGNET_TASK
+	MAGNET_ADD(MAGNET_TASK_CTX_IN, current, current->processor, 
+			MAGNET_TASK_DATA(current));
+#endif /* CONFIG_MAGNET_TASK */
+
 	return;
 }
 
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/magnet/Config.in linux-2.4.19-magnet/magnet/Config.in
--- linux-2.4.19/magnet/Config.in	Wed Dec 31 17:00:00 1969
+++ linux-2.4.19-magnet/magnet/Config.in	Thu Nov 14 14:24:12 2002
@@ -0,0 +1,100 @@
+#
+# MAGNET -- Monitoring Apparatus for General kerNel Event Tracing
+#
+# Version:	@(#)Config.in	2.0.0	2002/10/22
+#
+# Authors: Jeff Hay and Mark K. Gardner, radiant-software@lanl.gov
+#
+# History:
+#
+#   2001-03-06 1.0.0  internal release
+#   2002-10-22 2.0.0  public release
+#
+# License:
+#
+# Copyright 2002. The Regents of the University of California.
+#
+# This material was produced under U.S. Government contract
+# W-7405-ENG-36 for Los Alamos National Laboratory, which is operated
+# by the University of California for the U.S. Department of Energy.
+# The Government is granted for itself and other acting on its behalf
+# a paid-up, non-exclusive, irrevocable worldwide license in the
+# material to reproduce, prepare derivative works, and perform
+# publicly and display publicly. Beginning five (5) years after
+# November 6, 2002, subject to additional five-year worldwide
+# renewals, the Government is granted for itself and others acting on
+# its behalf a paid-up, nonexclusive, irrevocable worldwide license
+# in this material to reproduce, prepare derivative works, distribute
+# copies to the public, perform publicly and display publicly, and to
+# permit others to do so. NEITHER THE UNITED STATES NOR THE UNITED
+# STATES DEPARTMENT OF ENERGY, NOR THE UNIVERSITY OF CALIFORNIA, NOR
+# ANY OF THEIR EMPLOYEES, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+# ASSUMES ANY LEGAL LIABLITY OR RESPONSIBILITY FOR THE ACCURACY,
+# COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT,
+# OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE
+# PRIVATELY OWNED RIGHTS.
+#
+# Additionally, this program is free software; you can distribute 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 any later version. Accordingly, 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.
+#
+
+int  '  Buffer size (default 256 pages)' CONFIG_MAGNET_BUFSIZE 256
+bool '  Extended instrumentation' CONFIG_MAGNET_EXTENDED
+bool '  Debugging code' CONFIG_MAGNET_DEBUG
+bool '  Benchmarking code' CONFIG_MAGNET_BENCHMARK
+
+bool '  Network instrumentation' CONFIG_MAGNET_NET
+if [ "$CONFIG_MAGNET_NET" = "y" ]; then
+	bool '    Socket layer' CONFIG_MAGNET_SOCK
+	if [ "$CONFIG_MAGNET_SOCK" = "y" ]; then
+		if [ "$CONFIG_MAGNET_EXTENDED" = "y" ]; then
+			bool '      Extended socket instrumentation' CONFIG_MAGNET_SOCK_EXT
+		fi # CONFIG_MAGNET_EXTENDED
+	fi # CONFIG_MAGNET_SOCK
+
+	bool '    TCP layer' CONFIG_MAGNET_TCP
+	if [ "$CONFIG_MAGNET_TCP" = "y" ]; then
+		if [ "$CONFIG_MAGNET_EXTENDED" = "y" ]; then
+			bool '      Extended TCP instrumentation' CONFIG_MAGNET_TCP_EXT
+		fi # CONFIG_MAGNET_EXTENDED
+	fi # CONFIG_MAGNET_TCP
+
+	bool '    UDP layer' CONFIG_MAGNET_UDP
+	if [ "$CONFIG_MAGNET_UDP" = "y" ]; then
+		if [ "$CONFIG_MAGNET_EXTENDED" = "y" ]; then
+			bool '      Eextended UDP instrumentation' CONFIG_MAGNET_UDP_EXT
+		fi # CONFIG_MAGNET_EXTENDED
+	fi # CONFIG_MAGNET_UDP
+
+	bool '    IP layer' CONFIG_MAGNET_IP
+	if [ "$CONFIG_MAGNET_IP" = "y" ]; then
+		if [ "$CONFIG_MAGNET_EXTENDED" = "y" ]; then
+			bool '      Extended IP instrumentation' CONFIG_MAGNET_IP_EXT
+		fi # CONFIG_MAGNET_EXTENDED
+	fi # CONFIG_MAGNET_IP
+
+	bool '    Generic network device' CONFIG_MAGNET_DEV_NET
+
+	bool '    Ethernet devices' CONFIG_MAGNET_DEV_ETH
+	if [ "$CONFIG_MAGNET_DEV_ETH" = "y" ]; then
+		if [ "$CONFIG_MAGNET_EXTENDED" = "MKG" ]; then
+			bool '      Extended ethernet instrumentation' CONFIG_MAGNET_DEV_ETH_EXT
+		fi # CONFIG_MAGNET_EXTENDED
+	fi # CONFIG_MAGNET_DEV_ETH
+fi # CONFIG_MAGNET_NET
+
+bool '  Task scheduling instrumentation' CONFIG_MAGNET_TASK
+if [ "$CONFIG_MAGNET_EXTENDED" = "y" ]; then
+	if [ "$CONFIG_MAGNET_TASK" = "y" ]; then
+		bool '      Extended TASK instrumentation' CONFIG_MAGNET_TASK_EXT
+	fi # CONFIG_MAGNET_TASK
+fi # CONFIG_MAGNET_EXTENDED
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/magnet/GPL linux-2.4.19-magnet/magnet/GPL
--- linux-2.4.19/magnet/GPL	Wed Dec 31 17:00:00 1969
+++ linux-2.4.19-magnet/magnet/GPL	Thu Sep 16 11:44:00 1999
@@ -0,0 +1,340 @@
+		    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.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    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.
+
+  <signature of Ty Coon>, 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.
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/magnet/Makefile linux-2.4.19-magnet/magnet/Makefile
--- linux-2.4.19/magnet/Makefile	Wed Dec 31 17:00:00 1969
+++ linux-2.4.19-magnet/magnet/Makefile	Thu Nov 14 14:24:37 2002
@@ -0,0 +1,63 @@
+#
+# MAGNET -- Monitoring Apparatus for General kerNel Event Tracing
+#
+# Version:	@(#)Makefile	2.0.0	2002/10/22
+#
+# Authors: Jeff Hay and Mark K. Gardner, radiant-software@lanl.gov
+#
+# History:
+#
+#   2001-03-06 1.0.0  internal release
+#   2002-10-22 2.0.0  public release
+#
+# License:
+#
+# Copyright 2002. The Regents of the University of California.
+#
+# This material was produced under U.S. Government contract
+# W-7405-ENG-36 for Los Alamos National Laboratory, which is operated
+# by the University of California for the U.S. Department of Energy.
+# The Government is granted for itself and other acting on its behalf
+# a paid-up, non-exclusive, irrevocable worldwide license in the
+# material to reproduce, prepare derivative works, and perform
+# publicly and display publicly. Beginning five (5) years after
+# November 6, 2002, subject to additional five-year worldwide
+# renewals, the Government is granted for itself and others acting on
+# its behalf a paid-up, nonexclusive, irrevocable worldwide license
+# in this material to reproduce, prepare derivative works, distribute
+# copies to the public, perform publicly and display publicly, and to
+# permit others to do so. NEITHER THE UNITED STATES NOR THE UNITED
+# STATES DEPARTMENT OF ENERGY, NOR THE UNIVERSITY OF CALIFORNIA, NOR
+# ANY OF THEIR EMPLOYEES, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+# ASSUMES ANY LEGAL LIABLITY OR RESPONSIBILITY FOR THE ACCURACY,
+# COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT,
+# OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE
+# PRIVATELY OWNED RIGHTS.
+#
+# Additionally, this program is free software; you can distribute 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 any later version. Accordingly, 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.
+#
+
+
+# Note1! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+# Note 2! The CFLAGS definition is now in the main makefile...
+
+O_TARGET := libmagnet.a
+
+export-objs = magnet.o
+
+obj-y = magnet.o
+
+include $(TOPDIR)/Rules.make
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/magnet/Makefile.tools linux-2.4.19-magnet/magnet/Makefile.tools
--- linux-2.4.19/magnet/Makefile.tools	Wed Dec 31 17:00:00 1969
+++ linux-2.4.19-magnet/magnet/Makefile.tools	Thu Nov 14 14:24:52 2002
@@ -0,0 +1,117 @@
+#
+# MAGNET -- Monitoring Apparatus for General kerNel Event Tracing
+#
+# Version:	@(#)Makefile.tools	2.0.0	2002/10/22
+#
+# Authors: Jeff Hay and Mark K. Gardner, radiant-software@lanl.gov
+#
+# History:
+#
+#   2001-03-06 1.0.0  internal release
+#   2002-10-22 2.0.0  public release
+#
+# License:
+#
+# Copyright 2002. The Regents of the University of California.
+#
+# This material was produced under U.S. Government contract
+# W-7405-ENG-36 for Los Alamos National Laboratory, which is operated
+# by the University of California for the U.S. Department of Energy.
+# The Government is granted for itself and other acting on its behalf
+# a paid-up, non-exclusive, irrevocable worldwide license in the
+# material to reproduce, prepare derivative works, and perform
+# publicly and display publicly. Beginning five (5) years after
+# November 6, 2002, subject to additional five-year worldwide
+# renewals, the Government is granted for itself and others acting on
+# its behalf a paid-up, nonexclusive, irrevocable worldwide license
+# in this material to reproduce, prepare derivative works, distribute
+# copies to the public, perform publicly and display publicly, and to
+# permit others to do so. NEITHER THE UNITED STATES NOR THE UNITED
+# STATES DEPARTMENT OF ENERGY, NOR THE UNIVERSITY OF CALIFORNIA, NOR
+# ANY OF THEIR EMPLOYEES, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+# ASSUMES ANY LEGAL LIABLITY OR RESPONSIBILITY FOR THE ACCURACY,
+# COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT,
+# OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE
+# PRIVATELY OWNED RIGHTS.
+#
+# Additionally, this program is free software; you can distribute 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 any later version. Accordingly, 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.
+#
+
+CC         = gcc
+CFLAGS     = -g -O3 -Wall -I../include
+#CFLAGS     = -g -Wall -I../include
+LDFLAGS    = 
+
+TARGETS    = mkmagnet magnet-read magnet-parse magnet-dump
+
+HDR        = 
+SRC        = mkmagnet.c magnet-read.c magnet-parse.c magnet-dump.c eswap.c
+OBJ        = $(SRC:.c=.o)
+
+FILES      = $(SRC) $(HDR)
+DEPEND    += $(SRC:.c=.d)
+
+#===============================================================================
+#
+#	targets
+#
+#===============================================================================
+
+#.SUFFIXES:
+#.SUFFIXES:	.c .h .o
+.PHONY: all
+
+all: $(TARGETS)
+
+%.o: %.c
+	$(CC) -c $(CFLAGS) $< -o $@
+
+%: %.o eswap.o
+	$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $^
+
+install: $(TARGETS)
+	/usr/bin/install -p -s -o root -g root -m 0755 $? /usr/sbin
+
+#===============================================================================
+#
+#	dependencies, clean, backup, installation ...
+#
+#===============================================================================
+
+.PHONY: clean distclean
+
+%.d: %.c
+	@echo Recreating $@
+	@$(SHELL) -ec '$(CC) -MM $(CFLAGS) $< \
+		| sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \
+			[ -s $@ ] || rm -f $@' 2> /dev/null
+
+# automatically generate dependencies
+depend: $(DEPEND)
+
+# clean
+clean:
+	-rm -f core $(OBJ)
+
+# really clean
+distclean: clean
+	-rm -f *~ $(DEPEND) $(TARGETS)
+
+# include the file created by "make depend" that contains all the dependencies
+-include $(DEPEND)
+
+################################################################################
+#
+#	End of Makefile
+#
+################################################################################
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/magnet/eswap.c linux-2.4.19-magnet/magnet/eswap.c
--- linux-2.4.19/magnet/eswap.c	Wed Dec 31 17:00:00 1969
+++ linux-2.4.19-magnet/magnet/eswap.c	Thu Nov 14 14:25:06 2002
@@ -0,0 +1,81 @@
+/*
+-- MAGNET -- Monitoring Apparatus for General kerNel Event Tracing
+--
+-- Version:	@(#)eswap.c	2.0.0	2002/10/22
+--
+-- Authors: Jeff Hay and Mark K. Gardner, radiant-software@lanl.gov
+--
+-- History:
+--
+--   2002-10-22 2.0.0  public release
+--
+-- License:
+--
+-- Copyright 2002. The Regents of the University of California.
+--
+-- This material was produced under U.S. Government contract
+-- W-7405-ENG-36 for Los Alamos National Laboratory, which is operated
+-- by the University of California for the U.S. Department of Energy.
+-- The Government is granted for itself and other acting on its behalf
+-- a paid-up, non-exclusive, irrevocable worldwide license in the
+-- material to reproduce, prepare derivative works, and perform
+-- publicly and display publicly. Beginning five (5) years after
+-- November 6, 2002, subject to additional five-year worldwide
+-- renewals, the Government is granted for itself and others acting on
+-- its behalf a paid-up, nonexclusive, irrevocable worldwide license
+-- in this material to reproduce, prepare derivative works, distribute
+-- copies to the public, perform publicly and display publicly, and to
+-- permit others to do so. NEITHER THE UNITED STATES NOR THE UNITED
+-- STATES DEPARTMENT OF ENERGY, NOR THE UNIVERSITY OF CALIFORNIA, NOR
+-- ANY OF THEIR EMPLOYEES, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+-- ASSUMES ANY LEGAL LIABLITY OR RESPONSIBILITY FOR THE ACCURACY,
+-- COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT,
+-- OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE
+-- PRIVATELY OWNED RIGHTS.
+--
+-- Additionally, this program is free software; you can distribute 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 any later version. Accordingly, 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.
+*/
+
+#include "eswap.h"
+
+/*
+-- Performs big<->little endian translation of a generic buffer
+*/
+void eswap(unsigned char *buffer, int length) {
+  int count, temp;
+
+  for (count = 0; count < (length >> 1); count++) {
+    temp = buffer[length - count - 1] & 0x0FF;
+    buffer[length - count - 1] = buffer[count] & 0x0FF;
+    buffer[count] = temp & 0x0FF;
+  }
+
+  return;
+}
+
+/*
+-- Performs big<->little endian translation of int-sized values
+*/
+int eswap_int(int value) {
+  eswap((char *) &value, sizeof(int));
+  return value;
+}
+
+/*
+-- Performs big<->little endian translation of longlong-sized values
+*/
+long long eswap_longlong(long long value) {
+  eswap((unsigned char *) &value, sizeof(long long));
+  return value;
+}
+
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/magnet/eswap.h linux-2.4.19-magnet/magnet/eswap.h
--- linux-2.4.19/magnet/eswap.h	Wed Dec 31 17:00:00 1969
+++ linux-2.4.19-magnet/magnet/eswap.h	Thu Nov 14 14:25:19 2002
@@ -0,0 +1,56 @@
+/*
+-- MAGNET -- Monitoring Apparatus for General kerNel Event Tracing
+--
+-- Version:	@(#)eswap.h	2.0.0	2002/10/22
+--
+-- Authors: Mark K. Gardner, radiant-software@lanl.gov
+--
+-- History:
+--
+--   2002-10-22 2.0.0  public release
+--
+-- License:
+--
+-- Copyright 2002. The Regents of the University of California.
+--
+-- This material was produced under U.S. Government contract
+-- W-7405-ENG-36 for Los Alamos National Laboratory, which is operated
+-- by the University of California for the U.S. Department of Energy.
+-- The Government is granted for itself and other acting on its behalf
+-- a paid-up, non-exclusive, irrevocable worldwide license in the
+-- material to reproduce, prepare derivative works, and perform
+-- publicly and display publicly. Beginning five (5) years after
+-- November 6, 2002, subject to additional five-year worldwide
+-- renewals, the Government is granted for itself and others acting on
+-- its behalf a paid-up, nonexclusive, irrevocable worldwide license
+-- in this material to reproduce, prepare derivative works, distribute
+-- copies to the public, perform publicly and display publicly, and to
+-- permit others to do so. NEITHER THE UNITED STATES NOR THE UNITED
+-- STATES DEPARTMENT OF ENERGY, NOR THE UNIVERSITY OF CALIFORNIA, NOR
+-- ANY OF THEIR EMPLOYEES, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+-- ASSUMES ANY LEGAL LIABLITY OR RESPONSIBILITY FOR THE ACCURACY,
+-- COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT,
+-- OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE
+-- PRIVATELY OWNED RIGHTS.
+--
+-- Additionally, this program is free software; you can distribute 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 any later version. Accordingly, 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.
+*/
+
+#ifndef _ESWAP_H
+#define _ESWAP_H
+
+extern void      eswap(unsigned char *buffer, int length);
+extern int       eswap_int(int value);
+extern long long eswap_longlong(long long value);
+
+#endif /* _ESWAP_H */
Binary files linux-2.4.19/magnet/magnet-dump and linux-2.4.19-magnet/magnet/magnet-dump differ
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/magnet/magnet-dump.c linux-2.4.19-magnet/magnet/magnet-dump.c
--- linux-2.4.19/magnet/magnet-dump.c	Wed Dec 31 17:00:00 1969
+++ linux-2.4.19-magnet/magnet/magnet-dump.c	Thu Nov 14 14:26:55 2002
@@ -0,0 +1,193 @@
+/*
+-- MAGNET -- Monitoring Apparatus for General kerNel Event Tracing
+--
+-- Version:	@(#)magnet-dump.c	2.0.0	2002/10/22
+--
+-- Author: Mark K. Gardner, radiant-software@lanl.gov
+--
+-- History:
+--
+--   2002-10-22 2.0.0  public release
+--
+-- License:
+--
+-- Copyright 2002. The Regents of the University of California.
+--
+-- This material was produced under U.S. Government contract
+-- W-7405-ENG-36 for Los Alamos National Laboratory, which is operated
+-- by the University of California for the U.S. Department of Energy.
+-- The Government is granted for itself and other acting on its behalf
+-- a paid-up, non-exclusive, irrevocable worldwide license in the
+-- material to reproduce, prepare derivative works, and perform
+-- publicly and display publicly. Beginning five (5) years after
+-- November 6, 2002, subject to additional five-year worldwide
+-- renewals, the Government is granted for itself and others acting on
+-- its behalf a paid-up, nonexclusive, irrevocable worldwide license
+-- in this material to reproduce, prepare derivative works, distribute
+-- copies to the public, perform publicly and display publicly, and to
+-- permit others to do so. NEITHER THE UNITED STATES NOR THE UNITED
+-- STATES DEPARTMENT OF ENERGY, NOR THE UNIVERSITY OF CALIFORNIA, NOR
+-- ANY OF THEIR EMPLOYEES, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+-- ASSUMES ANY LEGAL LIABLITY OR RESPONSIBILITY FOR THE ACCURACY,
+-- COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT,
+-- OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE
+-- PRIVATELY OWNED RIGHTS.
+--
+-- Additionally, this program is free software; you can distribute 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 any later version. Accordingly, 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.
+*/
+
+#include <getopt.h>
+#include <linux/magnet.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include "eswap.h"
+
+
+#define error(fmt, args...) \
+	fprintf(stderr, "-- Error:  " fmt "\n" "", ## args)
+
+
+static int          verbose = 0;
+static const char  *helpstr = 
+	"usage: %s <option>* <filename>*\n"
+	"\n"
+	"   Dump a MAGNET trace as hexidecimal records.\n"
+	"\n"
+	" Options:\n"
+	"   -h            help\n"
+	"   -v            verbose\n"
+	"\n"
+	"Input comes from <filename>. If <filename> is \"-\" or unspecified,\n"
+	"stdin is read. Output goes to stdout.\n";
+
+
+void usage(const char *prog) {
+	fprintf(stderr, helpstr, prog);
+}
+
+int dump(FILE *in) {
+	unsigned int        event, id;
+	unsigned long long  timestamp;
+	int                 size;
+	unsigned int        recsize = 0, swap = 0;
+	int                 i, records = 0, extrasize = 0;
+
+	printf("%10s %10s %18s %10s   %s\n", 
+			"Event", "ID", "Timestamp", "Size", "Ext");
+
+	while (fread(&event, sizeof(event), 1, in) == 1 && 
+				 fread(&id, sizeof(id), 1, in) == 1 && 
+				 fread(&timestamp, sizeof(timestamp), 1, in) == 1 && 
+				 fread(&size, sizeof(size), 1, in) == 1) {
+
+		if (records == 0) {
+			/* Figure out endian-ness */
+			if (event == eswap_int(MAGNET_SYSINFO)) {
+				swap = 1;
+			} else if (event != MAGNET_SYSINFO) {
+				fputs("-- Error: unknown endian format\n", stderr);
+				return 1;
+			}
+		}
+
+		if (swap) {
+			event = eswap_int(event);
+			id = eswap_int(id);
+			timestamp = eswap_int(timestamp);
+			size = eswap_int(size);
+		}
+
+		if (records == 0) {
+			recsize = timestamp & 0xFFFFFFFF;
+			extrasize = recsize - sizeof(event) - sizeof(id) - 
+				sizeof(timestamp) - sizeof(size);
+		}
+
+		printf("0x%08X 0x%08X 0x%016llX %10d", event, id, timestamp, size);
+
+		if (extrasize > 0) {
+			fputs("  ", stdout);
+			for (i = 0; i < extrasize; i++) {
+				unsigned char  byte;
+				if (fread(&byte, sizeof(byte), 1, in) != 1) {
+					fputs("-- Error: could not read extra data, aborting.\n", stderr);
+					return 1;
+				}
+				printf(" 0x%02X", byte);
+			}
+		}
+		fputc('\n', stdout);
+		records++;
+	}
+
+	return 0;
+}
+
+
+int main(int argc, char *argv[]) {
+	FILE         *infile;
+	int           c, errors = 0;
+
+  opterr = 0; /* disable getopt generated error msg */
+  while ((c = getopt(argc, argv, "hv")) != -1) {
+		switch (c) {
+		 case 'h':
+			usage(argv[0]);
+			return 0;
+		 case 'v':
+			verbose = (verbose ? 0 : 1);
+			break;
+		 default:
+			errors++;
+		}
+	}
+	if (errors) {
+		usage(argv[0]);
+		return 1;
+	}
+
+	if (optind == argc) {
+		/* Read from stdin */
+		if (dump(stdin) != 0){
+			error("error encounted in MAGNET trace from stdin");
+			return 1;
+		}
+	} else {
+		while (optind < argc) {
+			char *fname = argv[optind];
+
+			if (strcmp(fname, "-") == 0) {
+				if ((infile = fdopen(0, "r")) == NULL) {
+					error("unable to open \"-\" (stdin)");
+					optind++;
+					continue;
+				}
+				fname = "stdin";
+			} else if ((infile = fopen(fname, "r")) == NULL) {
+				error("unable to read input file \"%s\"", fname);
+				optind++;
+				continue;
+			}
+
+			if (dump(infile) != 0) {
+				error("error encounted in MAGNET trace \"%s\"", fname);
+				optind++;
+				continue;
+			}
+			fclose(infile);
+			optind++;
+		}
+	}
+
+	return 0;
+}
Binary files linux-2.4.19/magnet/magnet-parse and linux-2.4.19-magnet/magnet/magnet-parse differ
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/magnet/magnet-parse.c linux-2.4.19-magnet/magnet/magnet-parse.c
--- linux-2.4.19/magnet/magnet-parse.c	Wed Dec 31 17:00:00 1969
+++ linux-2.4.19-magnet/magnet/magnet-parse.c	Thu Nov 14 14:26:42 2002
@@ -0,0 +1,1169 @@
+/*
+-- MAGNET -- Monitoring Apparatus for General kerNel Event Tracing
+--
+-- Version:	@(#)magnet-parse.c	2.0.0	2002/10/22
+--
+-- Authors: Jeff Hay and Mark K. Gardner, radiant-software@lanl.gov
+--
+-- History:
+--
+--   2001-03-06 1.0.0  internal release
+--   2002-10-22 2.0.0  public release
+--
+-- License:
+--
+-- Copyright 2002. The Regents of the University of California.
+--
+-- This material was produced under U.S. Government contract
+-- W-7405-ENG-36 for Los Alamos National Laboratory, which is operated
+-- by the University of California for the U.S. Department of Energy.
+-- The Government is granted for itself and other acting on its behalf
+-- a paid-up, non-exclusive, irrevocable worldwide license in the
+-- material to reproduce, prepare derivative works, and perform
+-- publicly and display publicly. Beginning five (5) years after
+-- November 6, 2002, subject to additional five-year worldwide
+-- renewals, the Government is granted for itself and others acting on
+-- its behalf a paid-up, nonexclusive, irrevocable worldwide license
+-- in this material to reproduce, prepare derivative works, distribute
+-- copies to the public, perform publicly and display publicly, and to
+-- permit others to do so. NEITHER THE UNITED STATES NOR THE UNITED
+-- STATES DEPARTMENT OF ENERGY, NOR THE UNIVERSITY OF CALIFORNIA, NOR
+-- ANY OF THEIR EMPLOYEES, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+-- ASSUMES ANY LEGAL LIABLITY OR RESPONSIBILITY FOR THE ACCURACY,
+-- COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT,
+-- OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE
+-- PRIVATELY OWNED RIGHTS.
+--
+-- Additionally, this program is free software; you can distribute 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 any later version. Accordingly, 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.
+*/
+
+/*
+-- To do:
+--
+--   * Verify checksums
+--   * Parse Ethernet headers
+--   * Parse IP options
+*/
+
+#include <arpa/inet.h>
+#include <getopt.h>
+#include <netdb.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <time.h>
+
+/* Define all available extended types */
+#define CONFIG_MAGNET_EXTENDED     1
+#define CONFIG_MAGNET_SOCK_EXT     1
+#define CONFIG_MAGNET_TCP_EXT      1
+#define CONFIG_MAGNET_UDP_EXT      1
+#define CONFIG_MAGNET_IP_EXT       1
+#define CONFIG_MAGNET_DEV_EXT      1
+#define CONFIG_MAGNET_DEV_ETH_EXT  1
+#define CONFIG_MAGNET_TASK_EXT     1
+#include <linux/magnet.h>
+
+#include "eswap.h"
+
+
+#define MAX_BUFFER  256
+#define MAX_VERSION   3
+
+#define HEADERFMT      "%*s %10s %9s %s"
+#define RECORDFMT      "%*.*f 0x%08X %9d %s"
+#define RECORDFMTSOCK  "%*.*f 0x%08X %9d %s pid %u sid %u type %s"
+#define EXTRAFMT       "%*.*f 0x%08X %9d %s %s"
+#define EXTRAFMTSOCK   "%*.*f 0x%08X %9d %s pid %u sid %u type %s %s"
+
+
+#define warning(fmt, args...) \
+	fflush(stdout);fprintf(stderr, "-- Warning:  " fmt "\n" "", ## args)
+#define error(fmt, args...) \
+	fflush(stdout);fprintf(stderr, "-- Error:  " fmt "\n" "", ## args)
+#define cprint(fmt, args...) \
+	fprintf(stderr, fmt "\n" "", ## args)
+#define hprint(fmt, args...) \
+	printf("# " fmt "\n" "", ## args)
+#define bprint(fmt, args...) \
+	cprint(fmt, ## args), hprint(fmt, ## args)
+#define tprint(fmt, args...) \
+	printf(fmt "\n" "", ## args)
+
+#define updating_snprintf(buf, size, fmt, args...) { \
+	int n = snprintf(buf, size, fmt, ## args); \
+	if (n > 0) { \
+		buf += n; \
+		size -= n; \
+	} \
+}
+
+#define OPT_MIN_BUFSIZE       4
+
+/* RFC 793, 1323 & 2018 */
+#define TCPOPT_KIND_EOL    0x00
+#define TCPOPT_KIND_NOP    0x01
+#define TCPOPT_KIND_MSS    0x02
+#define TCPOPT_LEN_MSS        4
+#define TCPOPT_KIND_WS     0x03
+#define TCPOPT_LEN_WS         3
+#define TCPOPT_KIND_SACKOK 0x04
+#define TCPOPT_LEN_SACKOK     2
+#define TCPOPT_KIND_SACK   0x05
+#define TCPOPT_KIND_TS     0x08
+#define TCPOPT_LEN_TS        10
+
+/* RFC 791 */
+#define IPOPT_KIND_EOL     0x00
+#define IPOPT_KIND_NOP     0x01
+#define IPOPT_KIND_SEC     0x82
+#define IPOPT_LEN_SEC        11
+#define IPOPT_KIND_LSRR    0x83
+#define IPOPT_LEN_LSRR_MIN    3
+#define IPOPT_PTR_LSRR_MIN    4
+#define IPOPT_KIND_SSRR    0x89
+#define IPOPT_LEN_SSRR_MIN    3
+#define IPOPT_PTR_SSRR_MIN    4
+#define IPOPT_KIND_RR      0x07
+#define IPOPT_LEN_RR_MIN      3
+#define IPOPT_PTR_RR_MIN      4
+#define IPOPT_KIND_SI      0x88
+#define IPOPT_LEN_SI          4
+#define IPOPT_KIND_ITS     0x44
+#define IPOPT_LEN_ITS_MIN     4
+#define IPOPT_PTR_ITS_MIN     5
+
+typedef enum {
+	UNKNOWN_ENDIAN, NATIVE_ENDIAN, OTHER_ENDIAN
+} ENDIAN;
+
+typedef struct timeval timeval;
+
+typedef struct {
+	unsigned long long  both;
+	unsigned int        buffer;
+	unsigned int        record;
+} size_info;
+
+typedef struct {
+	unsigned long long  timestamp;     /* In cycles           */
+	unsigned int        cps;           /* Cycles/sec          */
+	unsigned int        seconds;       /* Since epoch         */
+	unsigned int        microseconds;  /* Beyond seconds      */
+	double              starttime;     /* Seconds since epoch */
+	double              endtime;       /* Seconds since epoch */
+	double              elapsed;       /* Seconds since epoch */
+	int                 width;         /* field width         */
+	int                 precision;     /* decimal places      */
+} date_info;
+
+typedef struct {
+	int                 size;
+	char               *data;
+} extra_info;
+
+typedef struct {
+	unsigned long long  bytes;
+	unsigned long long  records;
+} stat_info;
+
+typedef struct {
+	const char         *fname;
+	unsigned int        version;
+	ENDIAN              endian;
+	stat_info           stats;
+	size_info           sizes;
+	date_info           date;
+	extra_info          extra;
+} trace_info;
+
+
+static int          verbose = 0;
+static char         buffer[MAX_BUFFER];
+static const char  *helpstr = 
+	"usage: %s <option>* <filename>*\n"
+	"\n"
+	"   Parse a MAGNET trace into human readable form.\n"
+	"\n"
+	" Options:\n"
+	"   -h            help\n"
+	"   -v            verbose\n"
+	"\n"
+	"Input comes from <filename>. If <filename> is \"-\" or unspecified,\n"
+	"stdin is read. Output goes to stdout.\n";
+
+
+/*
+-- Functions dealing with time, dates and timestamps.
+*/
+static char *date2str(date_info *date, int size, char *buffer) {
+	struct tm  *t = gmtime((time_t *) &date->seconds);
+	char       *s = asctime(t);
+
+	if (s == NULL) {
+		s = "ERROR: unable to convert date";
+	} else {
+		char *nptr = strchr(s, '\n');
+		char *cptr = strrchr(s, ':');
+
+		if (nptr != NULL) {
+			*nptr = '\0'; // Get rid of newline
+		}
+		if (cptr == NULL) {
+			s = "ERROR: invalid UTC date";
+		} else {
+			cptr += 3;      // Skip colon and seconds characters
+			*cptr = '\0';   // Terminate first chunk
+			cptr++;         // Point to second chunk
+
+			snprintf(buffer, size, "%s.%d %s", s, date->microseconds, cptr);
+			s = buffer;
+		}
+	}
+
+	return s;
+}
+
+static double ts2sec(trace_info *trace, unsigned long long timestamp) {
+	double  diff = timestamp - trace->date.timestamp;
+	return trace->date.starttime + diff / trace->date.cps;
+}
+
+/*
+-- Compute the precision (significant digits) of time.
+*/
+int precision(int value) {
+	int        v, n = 0;
+
+	for (v = 1; v < value; v *= 10) {
+		n++;
+	}
+
+	return n;
+}
+
+/*
+-- Returns a string representation of a MAGNET event name
+*/
+char *magnet_name(int event) {
+	char  *name;
+
+	switch (event) {
+	 case MAGNET_LOST:
+		name = "Lost";
+		break;
+	 case MAGNET_SYSINFO:
+		name = "SysInfo";
+		break;
+	 case MAGNET_DATEINFO:
+		name = "DateInfo";
+		break;
+
+		/* MAGNET_APP_LAYER */
+	 case MAGNET_SOCK_OPEN:
+		name = "Sock_Open";
+		break;
+	 case MAGNET_SOCK_CLOSE:
+		name = "Sock_Close";
+		break;
+	 case MAGNET_SOCK_SEND:
+		name = "Sock_Send";
+		break;
+	 case MAGNET_SOCK_RECV:
+		name = "Sock_Recv";
+		break;
+
+		/* MAGNET_TRANS_LAYER */
+	 case MAGNET_TCP_SEND:
+		name = "TCP_Send";
+		break;
+	 case MAGNET_TCP_RECV:
+		name = "TCP_Recv";
+		break;
+	 case MAGNET_UDP_SEND:
+		name = "UDP_Send";
+		break;
+	 case MAGNET_UDP_RECV:
+		name = "UDP_Recv";
+		break;
+
+		/* MAGNET_NET_LAYER */
+	 case MAGNET_IP_SEND:
+		name = "IP_Send";
+		break;
+	 case MAGNET_IP_RECV:
+		name = "IP_Recv";
+		break;
+
+		/* MAGNET_DEV_LAYER */
+	 case MAGNET_ETH_SEND:
+		name = "Eth_Send";
+		break;
+	 case MAGNET_ETH_RECV:
+		name = "Eth_Recv";
+		break;
+	 case MAGNET_DEV_SEND:
+		name = "Dev_Send";
+		break;
+	 case MAGNET_DEV_RECV:
+		name = "Dev_Recv";
+		break;
+
+		/* MAGNET_TASK_LAYER */
+	 case MAGNET_TASK_FORK:
+		name = "Task_Fork";
+		break;
+	 case MAGNET_TASK_EXIT:
+		name = "Task_Exit";
+		break;
+	 case MAGNET_TASK_CTX_IN:
+		name = "Task_CTX_In";
+		break;
+	 case MAGNET_TASK_CTX_OUT:
+		name = "Task_CTX_Out";
+		break;
+
+	 case MAGNET_BENCHMARK:
+		name = "Benchmark";
+		break;
+
+	 default:
+		snprintf(buffer, MAX_BUFFER, "Unknown_%u", event);
+		name = buffer;
+	}
+
+	return name;
+}
+
+/*
+-- Returns a string representation of an IP type-of-service
+*/
+const char *ip_tos(unsigned int tos) {
+	const char  *name;
+
+	if (IPTOS_PREC(tos)) {
+		error("precidence of TOS field is non-zero (0x%02X), ignoring...", 
+				IPTOS_PREC(tos));
+	}
+
+	switch (IPTOS_TOS(tos)) {
+	 case 0:
+		name = "N"; /* Normal */
+		break;
+	 case IPTOS_LOWDELAY:
+		name = "D"; /* Min Delay */
+		break;
+	 case IPTOS_THROUGHPUT:
+		name = "T"; /* Max Throughput */
+		break;
+	 case IPTOS_RELIABILITY:
+		name = "R"; /* Max Reliability */
+		break;
+	 case IPTOS_LOWCOST:
+		name = "C"; /* Min Cost */
+		break;
+	 default:
+		snprintf(buffer, MAX_BUFFER, "Invalid_TOS_0x%02X", IPTOS_TOS(tos));
+		name = buffer;
+	}
+
+	return name;
+}
+
+/*
+-- Returns a string representation of IP fragment information.
+*/
+const char *ip_frag_offset(unsigned int frag) {
+	unsigned int offset = frag & IP_OFFMASK;
+
+	switch (frag & ~IP_OFFMASK) {
+	 case 0:
+		snprintf(buffer, MAX_BUFFER, "N@%u", offset); /* No Frag Flag  */
+		break;
+	 case IP_RF:
+		snprintf(buffer, MAX_BUFFER, "R@%u", offset); /* Reserved Frag */
+		break;
+	 case IP_DF:
+		snprintf(buffer, MAX_BUFFER, "D@%u", offset); /* Don't Frag    */
+		break;
+	 case IP_MF:
+		snprintf(buffer, MAX_BUFFER, "M@%u", offset); /* More Frag     */
+		break;
+	 default:
+		snprintf(buffer, MAX_BUFFER, "I@%u", offset); /* Invalid Frag  */
+	}
+
+	return buffer;
+}
+
+/*
+-- Returns a string representation of the TCP flags.
+*/
+const char *tcp_flags(struct tcphdr *tcp) {
+	snprintf(buffer, MAX_BUFFER, "%s%s%s%s%s%s", 
+			tcp->urg ? "U" : "", tcp->ack ? "A" : "", tcp->psh ? "P" : "", 
+			tcp->rst ? "R" : "", tcp->syn ? "S" : "", tcp->fin ? "F" : "");
+	if (strlen(buffer) == 0) {
+#if MAX_BUFFER < 2
+#	error MAX_BUFFER must be >= 2!
+#endif
+		buffer[0] = 'N';
+		buffer[1] = '\0';
+	}
+	return buffer;
+}
+
+char *socket_type(int type) {
+	char *typestr;
+
+	switch (type) {
+	 case SOCK_DGRAM:
+		typestr = "SOCK_DGRAM";
+		break;
+	 case SOCK_STREAM:
+		typestr = "SOCK_STREAM";
+		break;
+	 default:
+		typestr = "SOCK_UNKNOWN";
+	}
+
+	return typestr;
+}
+
+char *socket_domain(int domain) {
+	char *domainstr;
+
+	/* Not all protocol families have been included yet! */
+	switch (domain) {
+	 case PF_UNSPEC:
+		domainstr = "PF_UNSPEC";
+		break;
+	 case PF_LOCAL:
+		domainstr = "PF_LOCAL";
+		break;
+	 case PF_INET:
+	  domainstr = "PF_INET";
+		break;
+	 case PF_AX25:
+		domainstr = "PF_AX25";
+		break;
+	 case PF_IPX:
+		domainstr = "PF_IPX";
+		break;
+	 case PF_APPLETALK:
+		domainstr = "PF_APPLETALK";
+		break;
+	 case PF_PACKET:
+		domainstr = "PF_PACKET";
+		break;
+	 default:
+		domainstr = "PF_UNKNOWN";
+	}
+
+	return domainstr;
+}
+
+int translate_socket_extra(struct magnet_sock *sock, int size, char *buffer) {
+	char            *domain, pbuffer[MAX_BUFFER], *pname;
+	struct protoent *protocol;
+
+	domain = socket_domain(sock->domain);
+	protocol = getprotobynumber(sock->protocol);
+	if (protocol == NULL) {
+		snprintf(pbuffer, MAX_BUFFER, "%u", sock->protocol);
+		pname = pbuffer;
+	} else {
+		pname = protocol->p_name;
+	}
+
+	return snprintf(buffer, size, "domain %s protocol %s", domain, pname);
+}
+
+
+int translate_tcp_options(int count, const char *options, 
+		int size, char *buffer) {
+	int  i, optcnt = 0;
+	char *p = buffer;
+
+	if (size < OPT_MIN_BUFSIZE) {
+		error("input buffer to translate_tcp_options is too small");
+		return 0;
+	}
+
+	updating_snprintf(p, size, "<");
+	for (i = 0; i < count && size > 1; ) {
+		int kind = options[i++];
+		switch (kind) {
+		 case TCPOPT_KIND_EOL:
+			/* All options have been seen. There may still be padding though. */
+			updating_snprintf(p, size, " pad");
+			optcnt++;
+			break;
+		 case TCPOPT_KIND_NOP:
+			if (verbose) {
+				updating_snprintf(p, size, " nop");
+			}
+			optcnt++;
+			break;
+		 case TCPOPT_KIND_MSS:
+			if (options[i] != TCPOPT_LEN_MSS) {
+				warning("invalid length (%u) in TCP MSS option", options[i]);
+			}
+			i++;
+			updating_snprintf(p, size, " mss %u", ntohs(*((short *) &options[i])));
+			i += 2;
+			optcnt++;
+		 	break;
+		 case TCPOPT_KIND_WS:
+			if (options[i] != TCPOPT_LEN_WS) {
+				warning("invalid length (%u) in TCP window scale option", options[i]);
+			}
+			i++;
+			updating_snprintf(p, size, " wscale %u", options[i]);
+			i++;
+			optcnt++;
+		 	break;
+		 case TCPOPT_KIND_SACKOK:
+			if (options[i] != TCPOPT_LEN_SACKOK) {
+				warning("invalid length (%u) in TCP SackOK option", options[i]);
+			}
+			updating_snprintf(p, size, " sackOK");
+			i++;
+			optcnt++;
+			break;
+		 case TCPOPT_KIND_SACK:
+		 {
+			 int j, len = options[i++] - 2;
+			 updating_snprintf(p, size, " sack");
+			 for (j = 0; j < len; j += 8) {
+				 updating_snprintf(p, size, " %u %u", 
+						 ntohl(*((unsigned int *) &options[i])), 
+						 ntohl(*((unsigned int *) &options[i+4])));
+				 i += 8;
+			 }
+		 }
+			optcnt++;
+			break;
+		 case TCPOPT_KIND_TS:
+			if (options[i] != TCPOPT_LEN_TS) {
+				warning("invalid length (%u) in TCP time stamp option", options[i]);
+			}
+			i++;
+			updating_snprintf(p, size, " timestamp %u %u",
+					ntohl(*((unsigned int *) &options[i])), 
+					ntohl(*((unsigned int *) &options[i+4])));
+			i += 8;
+			optcnt++;
+			break;
+		 default:
+			updating_snprintf(p, size, " UNKNOWN_KIND_0x%02X", kind);
+			optcnt++;
+			break;
+		}
+	}
+	updating_snprintf(p, size, " >");
+
+	return 0;
+}
+
+
+int translate_tcp_extra(struct magnet_tcp *tcp, int size, char *buffer) {
+	char options[MAX_BUFFER];
+	int  count = translate_tcp_options(4*tcp->hdr.doff - sizeof(struct tcphdr), 
+			tcp->opt, MAX_BUFFER, options);
+
+	if (count > 0) {
+		return snprintf(buffer, size,
+				"src %u dst %u seq %u ack %u hlen %u flags %s "
+				"win %u csum 0x%04X urg %u",
+				ntohs(tcp->hdr.source), ntohs(tcp->hdr.dest), 
+				ntohl(tcp->hdr.seq), ntohl(tcp->hdr.ack_seq), 
+				4 * tcp->hdr.doff, tcp_flags(&tcp->hdr), ntohs(tcp->hdr.window),
+				ntohs(tcp->hdr.check), ntohs(tcp->hdr.urg_ptr));
+	} else {
+		return snprintf(buffer, size,
+				"src %u dst %u seq %u ack %u hlen %u flags %s "
+				"win %u csum 0x%04X urg %u %s",
+				ntohs(tcp->hdr.source), ntohs(tcp->hdr.dest), 
+				ntohl(tcp->hdr.seq), ntohl(tcp->hdr.ack_seq), 
+				4 * tcp->hdr.doff, tcp_flags(&tcp->hdr), ntohs(tcp->hdr.window),
+				ntohs(tcp->hdr.check), ntohs(tcp->hdr.urg_ptr), options);
+	}
+}
+
+int translate_udp_extra(struct magnet_udp *udp, int size, char *buffer) {
+	return snprintf(buffer, size, "sport %u dport %u len %u csum 0x%04X",
+		ntohs(udp->hdr.source), ntohs(udp->hdr.dest), 
+		ntohs(udp->hdr.len), ntohs(udp->hdr.check));
+}
+
+int translate_ip_options(int count, const char *options, 
+		int size, char *buffer) {
+	int  i, optcnt = 0;
+	char *p = buffer;
+
+	if (size < OPT_MIN_BUFSIZE) {
+		error("input buffer to translate_tcp_options is too small");
+		return 0;
+	}
+
+	updating_snprintf(p, size, "<");
+	for (i = 0; i < count && size > 1; ) {
+		int kind = options[i++];
+		switch (kind) {
+		 case IPOPT_KIND_EOL:
+			/* All options have been seen. There may still be padding though. */
+			updating_snprintf(p, size, " pad");
+			optcnt++;
+			break;
+		 case IPOPT_KIND_NOP:
+			if (verbose) {
+				updating_snprintf(p, size, " nop");
+			}
+			optcnt++;
+			break;
+		 case IPOPT_KIND_SEC:
+			if (options[i] != IPOPT_LEN_SEC) {
+				warning("invalid length (%u) in IP security option", options[i]);
+			}
+			updating_snprintf(p, size, " sec NOT_IMPL");
+			i += IPOPT_LEN_SEC;
+			optcnt++;
+		 	break;
+		 case IPOPT_KIND_LSRR:
+		 {
+			 int len = options[i++];
+			 if (len < IPOPT_LEN_LSRR_MIN || options[i] < IPOPT_PTR_LSRR_MIN) {
+				 warning("invalid length (%u) or pointer (%d) in IP LSRR option", 
+						 len, options[i]);
+			 }
+			i++;
+			updating_snprintf(p, size, " lsrr NOT_IMPL");
+			i += len - IPOPT_LEN_LSRR_MIN;
+			optcnt++;
+		 }
+		 	break;
+		 case IPOPT_KIND_SSRR:
+		 {
+			 int len = options[i++];
+			 if (len < IPOPT_LEN_SSRR_MIN || options[i] < IPOPT_PTR_SSRR_MIN) {
+				 warning("invalid length (%u) or pointer (%d) in IP SSRR option", 
+						 len, options[i]);
+			 }
+			i++;
+			updating_snprintf(p, size, " ssrr NOT_IMPL");
+			i += len - IPOPT_LEN_SSRR_MIN;
+			optcnt++;
+		 }
+		 	break;
+		 case IPOPT_KIND_RR:
+		 {
+			 int len = options[i++];
+			 if (len < IPOPT_LEN_RR_MIN || options[i] < IPOPT_PTR_RR_MIN) {
+				 warning("invalid length (%u) or pointer (%d) in IP RR option", 
+						 len, options[i]);
+			 }
+			i++;
+			updating_snprintf(p, size, " rr NOT_IMPL");
+			i += len - IPOPT_LEN_RR_MIN;
+			optcnt++;
+		 }
+		 	break;
+		 case IPOPT_KIND_SI:
+			if (options[i] != IPOPT_LEN_SI) {
+				warning("invalid length (%u) in IP SI option", options[i]);
+			}
+			updating_snprintf(p, size, " si NOT_IMPL");
+			i += IPOPT_LEN_SI;
+			optcnt++;
+		 	break;
+		 case IPOPT_KIND_ITS:
+		 {
+			 int len = options[i++];
+			 if (len < IPOPT_LEN_ITS_MIN || options[i] < IPOPT_PTR_ITS_MIN) {
+				 warning("invalid length (%u) or pointer (%d) in IP ITS option", 
+						 len, options[i]);
+			 }
+			i++;
+			updating_snprintf(p, size, " its NOT_IMPL");
+			i += len - IPOPT_LEN_ITS_MIN;
+			optcnt++;
+		 }
+		 	break;
+		 default:
+			updating_snprintf(p, size, " UNKNOWN_KIND_0x%02X", kind);
+			optcnt++;
+			break;
+		}
+	}
+	updating_snprintf(p, size, " >");
+
+	return 0;
+}
+
+
+int translate_ip_extra(struct magnet_ip *ip, int size, char *buffer) {
+	char saddr[MAX_BUFFER];
+	char options[MAX_BUFFER];
+
+	strncpy(saddr, inet_ntoa(*((struct in_addr *) &ip->hdr.saddr)), MAX_BUFFER);
+	translate_ip_options(4 * ip->hdr.ihl - sizeof(struct iphdr),
+			ip->opt, MAX_BUFFER, options);
+
+	if (strncmp(options, "< >", 3) == 0) {
+		return snprintf(buffer, size,
+				"vers %u hlen %u tos %s tlen %u id %u frag %s "
+				"ttl %u proto %u csum 0x%04X src %s dst %s",
+				ip->hdr.version, 4 * ip->hdr.ihl, ip_tos(ntohs(ip->hdr.tos)), 
+				ntohs(ip->hdr.tot_len), ntohs(ip->hdr.id), 
+				ip_frag_offset(ntohs(ip->hdr.frag_off)), 
+				ip->hdr.ttl, ip->hdr.protocol, ntohs(ip->hdr.check), 
+				saddr, inet_ntoa(*((struct in_addr *) &ip->hdr.daddr)));
+	} else {
+		return snprintf(buffer, size,
+				"vers %u hlen %u tos %s tlen %u id %u frag %s "
+				"ttl %u proto %u csum 0x%04X src %s dst %s %s",
+				ip->hdr.version, 4 * ip->hdr.ihl, ip_tos(ntohs(ip->hdr.tos)), 
+				ntohs(ip->hdr.tot_len), ntohs(ip->hdr.id), 
+				ip_frag_offset(ntohs(ip->hdr.frag_off)), 
+				ip->hdr.ttl, ip->hdr.protocol, ntohs(ip->hdr.check), 
+				saddr, inet_ntoa(*((struct in_addr *) &ip->hdr.daddr)), options);
+	}
+}
+
+int translate_eth_extra(struct magnet_eth *eth, int size, char *buffer) {
+	return snprintf(buffer, size,
+			"src %02X:%02X:%02X:%02X:%02X:%02X dst %02X:%02X:%02X:%02X:%02X:%02X "
+			"type %d",
+			eth->hdr.ether_dhost[0], eth->hdr.ether_dhost[1], 
+			eth->hdr.ether_dhost[2], eth->hdr.ether_dhost[3], 
+			eth->hdr.ether_dhost[4], eth->hdr.ether_dhost[5], 
+			eth->hdr.ether_shost[0], eth->hdr.ether_shost[1], 
+			eth->hdr.ether_shost[2], eth->hdr.ether_shost[3], 
+			eth->hdr.ether_shost[4], eth->hdr.ether_shost[5], 
+			eth->hdr.ether_type);
+}
+
+int translate_task_extra(struct magnet_task *task, int size, char *buffer) {
+	return snprintf(buffer, size, "TASK pid %d", task->pid);
+}
+
+/*
+-- Processes MAGNET protocol-specific extra data to ASCII text.
+-- (Right now it just dumps the bytes in hex...)
+*/
+char *translate_extra_data(extra_info *extra, int event) {
+	static char            buffer[MAX_BUFFER];
+	union magnet_ext_data *data = (union magnet_ext_data *) extra->data;
+	int                    count = 0;
+
+	if (extra->size > sizeof(*data)) {
+		error("invalid size of extra data (%d vs. %d)", extra->size, sizeof(*data));
+		return NULL;
+	}
+
+	switch (event) {
+	 case MAGNET_SOCK_OPEN:
+		count += translate_socket_extra(&data->sock, MAX_BUFFER, buffer);
+		break;
+
+	 case MAGNET_TCP_SEND:
+	 case MAGNET_TCP_RECV:
+		count += translate_tcp_extra(&data->tcp, MAX_BUFFER, buffer);
+		break;
+
+	 case MAGNET_UDP_SEND:
+	 case MAGNET_UDP_RECV:
+		count += translate_udp_extra(&data->udp, MAX_BUFFER, buffer);
+		break;
+
+	 case MAGNET_IP_SEND:
+	 case MAGNET_IP_RECV:
+		count += translate_ip_extra(&data->ip, MAX_BUFFER, buffer);
+		break;
+
+	 case MAGNET_ETH_SEND:
+	 case MAGNET_ETH_RECV:
+		count += translate_eth_extra(&data->eth, MAX_BUFFER, buffer);
+		break;
+
+	 case MAGNET_TASK_FORK:
+	 case MAGNET_TASK_EXIT:
+	 case MAGNET_TASK_CTX_IN:
+	 case MAGNET_TASK_CTX_OUT:
+		count += translate_task_extra(&data->task, MAX_BUFFER, buffer);
+		break;
+
+   /* These don't have extra data currently. */
+	 case MAGNET_SOCK_CLOSE:
+	 case MAGNET_SOCK_SEND:
+	 case MAGNET_SOCK_RECV:
+
+	 case MAGNET_BENCHMARK:
+	 default:
+	}
+	buffer[count] = '\0';
+
+	return buffer;
+}
+
+void print_info(trace_info *trace) {
+	char  *date = date2str(&trace->date, MAX_BUFFER, buffer);
+
+	/* Compute output width and precision */
+	trace->date.precision = precision(trace->date.cps);
+	trace->date.width = precision((int) trace->date.starttime) + 1;
+	trace->date.width += trace->date.precision;
+
+	/* Print headers to both console and trace */
+	bprint("MAGNET:   %s", 
+			"Monitoring Apparatus for General kerNel Event Tracing");
+	bprint("Author:   %s", "RADIANT (http://www.lanl.gov/radiant/)");
+	bprint("Version:  %d.%d.%d",
+			(trace->version & 0xFF000000) >> 24,
+			(trace->version & 0xFF0000) >> 16,
+			(trace->version & 0xFF00) >> 8);
+	bprint("Trace:    %s", trace->fname);
+	bprint("Date:     %s UTC -> %*.*f seconds", date, 
+			trace->date.width, trace->date.precision, trace->date.starttime);
+	bprint("CPS:      %d Hz", trace->date.cps);
+	bprint("Buffer:   %d bytes", trace->sizes.buffer);
+	bprint("Record:   %d bytes", trace->sizes.record);
+
+	hprint(HEADERFMT, -trace->date.width + 2, "Seconds", "ID", "Parm", "Type");
+}
+
+/*
+-- Read the extra data in a record.
+*/
+int read_extra(FILE *infile, extra_info *extra) {
+	if (extra->data == NULL) {
+		return 1;
+	}
+	if (extra->size > 0 && fread(extra->data, extra->size, 1, infile) < 1 ) {
+		return 1;
+	}
+
+	return 0;
+}
+
+/*
+-- Reads a MAGNET SYSINFO record and translates in to human-readable form
+-- on STDOUT. (Other messages to STDERR.) Returns 0 on success and 1 on 
+-- failure.
+*/
+int translate_sysinfo(FILE *infile, trace_info *trace) {
+	unsigned int        event;
+	unsigned long long  sizes;
+	
+	/* First word contains SYSINFO event, in some endianess */
+	if (fread(&event, sizeof(event), 1, infile) < 1) {
+		return 1;
+	}
+	if (event == MAGNET_SYSINFO) {
+		trace->endian = NATIVE_ENDIAN;
+	} else if (eswap_int(event) == MAGNET_SYSINFO) {
+		trace->endian = OTHER_ENDIAN;
+	} else {
+		trace->endian = UNKNOWN_ENDIAN;
+		error("trace file is in unknown endian format");
+		return 1;
+	}
+
+	/* Next word contains version info */
+	if (fread(&trace->version, sizeof(trace->version), 1, infile) < 1 ) {
+		return 1;
+	}
+	if (trace->endian == OTHER_ENDIAN) {
+	  trace->version = eswap_int(trace->version);
+	}
+
+	/* Next long long contains buffer_size and record_size info */
+	if (fread(&trace->sizes.both, sizeof(trace->sizes.both), 1, infile) < 1 ) {
+		return 1;
+	}
+	if (trace->endian == OTHER_ENDIAN) {
+	  trace->sizes.both = eswap_longlong(trace->sizes.both);
+	}
+	trace->sizes.buffer = (trace->sizes.both & 0xFFFFFFFF00000000) >> 32;
+	if (trace->sizes.buffer < 1) {
+		error("negative buffer size (%d) in trace \"%s\"\n", 
+				trace->sizes.buffer, trace->fname);
+		return 1;
+	}
+	trace->sizes.record = (trace->sizes.both & 0xFFFFFFFF);
+	if (trace->sizes.record < 1) {
+		error("negative record size (%d) in trace \"%s\"\n", 
+				trace->sizes.record, trace->fname);
+		return 1;
+	}
+
+	/* Next word contains CPU speed in KHz. */
+	if (fread(&trace->date.cps, sizeof(trace->date.cps), 1, infile) < 1) {
+		return 1;
+	}
+	if (trace->endian == OTHER_ENDIAN) {
+		trace->date.cps = eswap_int(trace->date.cps);
+	}
+	trace->date.cps *= 1000; /* Was KHz */
+
+	/* Skip over remaining data in this record */
+	trace->extra.size = trace->sizes.record - sizeof(event) - 
+		sizeof(trace->version) - sizeof(sizes) - sizeof(trace->date.cps);
+	trace->extra.data = malloc(trace->extra.size);
+	if (trace->extra.data == NULL) {
+		error("unable to allocate memory for extra data");
+		return 1;
+	}
+	if (read_extra(infile, &trace->extra) != 0) {
+		error("unable to skip over extra data");
+		return 1;
+	}
+
+	return 0;
+}
+
+/*
+-- Reads a MAGNET DATEINFO record and translates in to human-readable form
+-- on STDOUT. (Other messages to STDERR.) Returns 0 on success and 1 on 
+-- failure.
+*/
+int translate_dateinfo(FILE *infile, trace_info *trace) {
+	unsigned int  event;
+
+	/* First word contains DATEINFO event */
+	if (fread(&event, sizeof(event), 1, infile) < 1) {
+		error("unable to read DATEINFO event");
+		return 1;
+	}
+	if (trace->endian == OTHER_ENDIAN) {
+	  event = eswap_int(event);
+	}
+	if (event != MAGNET_DATEINFO) {
+		error("expecting DATEINFO event");
+		return 1;
+	}
+
+	/* Next word contains start time in seconds since epoch */
+	if (fread(&trace->date.seconds, 
+					sizeof(trace->date.seconds), 1, infile) < 1 ) {
+		error("unable to read DATEINFO start time");
+		return 1;
+	}
+	if (trace->endian == OTHER_ENDIAN) {
+	  trace->date.seconds = eswap_int(trace->date.seconds);
+	}
+
+	/* Next long long contains timestamp */
+	if (fread(&trace->date.timestamp, 
+					sizeof(trace->date.timestamp), 1, infile) < 1 ) {
+		error("unable to read DATEINFO timestamp");
+		return 1;
+	}
+	if (trace->endian == OTHER_ENDIAN) {
+		trace->date.timestamp = eswap_longlong(trace->date.timestamp);
+	}
+
+	/* Next word contains microseconds portion of start time since epoch */
+	if (fread(&trace->date.microseconds, 
+					sizeof(trace->date.microseconds), 1, infile) < 1) {
+		error("unable to read DATEINFO start time");
+		return 1;
+	}
+	if (trace->endian == OTHER_ENDIAN) {
+		trace->date.microseconds = eswap_int(trace->date.microseconds);
+	}
+
+	trace->date.starttime = trace->date.seconds 
+		+ (double) trace->date.microseconds / (double) 1000000;
+
+	/* Skip over remaining data in this record */
+	if (read_extra(infile, &trace->extra) != 0) {
+		error("unable to skip over extra data");
+		return 1;
+	}
+
+	return 0;
+}
+
+/*
+-- Translate a single record from infile, using the given information
+-- about the trace format. Returns 0 on success or 1 on failure.
+*/
+int translate_record(FILE *infile, trace_info *trace) {
+	unsigned int        event, id, size;
+	unsigned long long  timestamp;
+	double              time;
+
+	/* Read in all standard information */
+	if (fread(&event, sizeof(event), 1, infile) < 1 ||
+	    fread(&id, sizeof(id), 1, infile) < 1 ||
+			fread(&timestamp, sizeof(timestamp), 1, infile) < 1 ||
+	    fread(&size, sizeof(size), 1, infile) < 1) {
+		goto fail;
+	}
+
+	/* Read in extra data (remainder of record) */
+	if (read_extra(infile, &trace->extra) != 0) {
+		goto fail;
+	}
+	
+	/* Perform endian translation, if needed */
+	if (trace->endian == OTHER_ENDIAN) {
+		id = eswap_int(id);
+		event = eswap_int(event);
+		timestamp = eswap_longlong(timestamp);
+		size = eswap_int(size);
+	}
+
+	time = ts2sec(trace, timestamp);
+	trace->date.endtime = time;
+
+	if (event == MAGNET_EMPTY) {
+		error("found empty record... Stopping.\n");
+		goto fail;
+	} else if (trace->extra.size > 0) {
+		char *extrastr = translate_extra_data(&trace->extra, event);
+		/* This is special cased because it is the only encoded param so far! */
+		if (event == MAGNET_SOCK_OPEN) {
+			tprint(EXTRAFMTSOCK, trace->date.width, trace->date.precision, time, 
+					id, size, magnet_name(event), magnet_sockparm_getpid(size),
+					magnet_sockparm_getsid(size), 
+					socket_type(magnet_sockparm_gettype(size)), extrastr);
+		} else {
+			tprint(EXTRAFMT, trace->date.width, trace->date.precision, time, 
+					id, size, magnet_name(event), extrastr);
+		}
+	} else {
+		/* This is special cased because it is the only encoded param so far! */
+		if (event == MAGNET_SOCK_OPEN) {
+			tprint(RECORDFMTSOCK, trace->date.width, trace->date.precision, time, 
+					id, size, magnet_name(event), magnet_sockparm_getpid(size),
+					magnet_sockparm_getsid(size), 
+					socket_type(magnet_sockparm_gettype(size)));
+		} else {
+			tprint(RECORDFMT, trace->date.width, trace->date.precision, time, 
+					id, size, magnet_name(event));
+		}
+	}
+
+	return 0;	
+
+ fail:
+	return 1;
+}
+
+/*
+-- Reads a MAGNET trace from infile and translates in to human-readable form
+-- on STDOUT. (Other messages to STDERR.) Returns 0 on success and 1 on 
+-- failure.
+*/
+int translate_trace(const char *fname, FILE *infile) {
+	trace_info  trace;
+
+	trace.fname = fname;
+
+	/* First two records should be SYSINFO and DATEINFO... */
+	if (translate_sysinfo(infile, &trace) != 0 || 
+			translate_dateinfo(infile, &trace) != 0) {
+		error("error reading MAGNET trace \"%s\"", fname);
+		return 1;
+	}
+	print_info(&trace);
+
+	/* Followed by regular data records... */
+	trace.stats.records = 2; /* Already read SYSINFO and DATEINFO... */
+	trace.stats.bytes = 2 * trace.sizes.record;
+	while (translate_record(infile, &trace) == 0) {
+		trace.stats.records++;
+		trace.stats.bytes += trace.sizes.record;
+	}
+	fflush(stdout);
+
+	trace.date.elapsed = trace.date.endtime - trace.date.starttime;
+
+	cprint("Summary:  %llu bytes %llu records %0.3f seconds", 
+			trace.stats.bytes, trace.stats.records, trace.date.elapsed);
+
+	if (trace.extra.data) {
+		free(trace.extra.data);
+		trace.extra.size = 0;
+		trace.extra.data = NULL;
+	}
+
+	return 0;
+}
+
+void usage(const char *prog) {
+	fprintf(stderr, helpstr, prog);
+}
+
+int main(int argc, char *argv[]) {
+	FILE         *infile;
+	int           c, errors = 0;
+
+  opterr = 0; /* disable getopt generated error msg */
+  while ((c = getopt(argc, argv, "hv")) != -1) {
+		switch (c) {
+		 case 'h':
+			usage(argv[0]);
+			return 0;
+		 case 'v':
+			verbose = (verbose ? 0 : 1);
+			break;
+		 default:
+			errors++;
+		}
+	}
+	if (errors) {
+		usage(argv[0]);
+		return 1;
+	}
+
+	if (optind == argc) {
+		/* Read from stdin */
+		if (translate_trace("stdin", stdin) != 0){
+			error("error encounted in MAGNET trace from stdin");
+			return 1;
+		}
+	} else {
+		while (optind < argc) {
+			char *fname = argv[optind];
+
+			if (strcmp(fname, "-") == 0) {
+				if ((infile = fdopen(0, "r")) == NULL) {
+					error("unable to open \"-\" (stdin)");
+					optind++;
+					continue;
+				}
+				fname = "stdin";
+			} else if ((infile = fopen(fname, "r")) == NULL) {
+				error("unable to read input file \"%s\"", fname);
+				optind++;
+				continue;
+			}
+
+			if (translate_trace(fname, infile) != 0) {
+				error("error encounted in MAGNET trace \"%s\"", fname);
+				optind++;
+				continue;
+			}
+			fclose(infile);
+			optind++;
+		}
+	}
+
+	return 0;
+}
Binary files linux-2.4.19/magnet/magnet-read and linux-2.4.19-magnet/magnet/magnet-read differ
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/magnet/magnet-read.c linux-2.4.19-magnet/magnet/magnet-read.c
--- linux-2.4.19/magnet/magnet-read.c	Wed Dec 31 17:00:00 1969
+++ linux-2.4.19-magnet/magnet/magnet-read.c	Thu Nov 14 14:27:15 2002
@@ -0,0 +1,340 @@
+/*
+-- MAGNET -- Monitoring Apparatus for General kerNel Event Tracing
+--
+-- Version:	@(#)magnet-read.c	2.0.0	2002/10/22
+--
+-- Authors: Jeff Hay and Mark K. Gardner, radiant-software@lanl.gov
+--
+-- History:
+--
+--   2001-03-06 1.0.0  internal release
+--   2002-10-22 2.0.0  public release
+--
+-- License:
+--
+-- Copyright 2002. The Regents of the University of California.
+--
+-- This material was produced under U.S. Government contract
+-- W-7405-ENG-36 for Los Alamos National Laboratory, which is operated
+-- by the University of California for the U.S. Department of Energy.
+-- The Government is granted for itself and other acting on its behalf
+-- a paid-up, non-exclusive, irrevocable worldwide license in the
+-- material to reproduce, prepare derivative works, and perform
+-- publicly and display publicly. Beginning five (5) years after
+-- November 6, 2002, subject to additional five-year worldwide
+-- renewals, the Government is granted for itself and others acting on
+-- its behalf a paid-up, nonexclusive, irrevocable worldwide license
+-- in this material to reproduce, prepare derivative works, distribute
+-- copies to the public, perform publicly and display publicly, and to
+-- permit others to do so. NEITHER THE UNITED STATES NOR THE UNITED
+-- STATES DEPARTMENT OF ENERGY, NOR THE UNIVERSITY OF CALIFORNIA, NOR
+-- ANY OF THEIR EMPLOYEES, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+-- ASSUMES ANY LEGAL LIABLITY OR RESPONSIBILITY FOR THE ACCURACY,
+-- COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT,
+-- OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE
+-- PRIVATELY OWNED RIGHTS.
+--
+-- Additionally, this program is free software; you can distribute 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 any later version. Accordingly, 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.
+*/
+
+#include <errno.h>
+#include <fcntl.h>
+#include <getopt.h>
+#include <string.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <sys/time.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <linux/magnet.h>
+#include "eswap.h"
+
+#define DEFAULT_DEVNAME     "/dev/magnet"
+#define DEFAULT_SLEEP_TIME  1000 /* in microseconds */
+#define MAX_FNAME            256
+
+#define error(fmt, args...) \
+	fprintf(stderr, "-- Error:  " fmt "\n" "", ## args)
+#define warning(fmt, args...) \
+	fprintf(stderr, "-- Warning:  " fmt "\n" "", ## args)
+
+typedef unsigned long long  UINT64;
+
+int                 verbose        = 0;
+int                 trace          = -1;
+int                 magnet         = -1;
+unsigned int        written        = 0;
+struct magnet_data *kernel_data    = NULL;
+int                 kernel_bufsize = 0;
+struct magnet_data *save_data      = NULL;
+struct stat         trace_stat;
+UINT64              start_time;
+double              ave_delay      = 0;
+unsigned int        min_copied_per = 0;
+unsigned int        max_copied_per = 0;
+unsigned int        active_count   = 0;
+
+struct sigaction    act;
+struct sigaction    oact_term;
+struct sigaction    oact_int;
+
+static const char *helpstr =
+	"-- Usage: %s <options> <trace-file>\n"
+	"\n"
+	" Options:\n"
+	"  -h         help\n"
+	"  -v         verbose\n"
+	"  -s <time>  sleep time between reads in microseconds (default: %d)\n"
+	"  -d <path>  MAGNET device (default: %s)\n";
+
+void delay(int sec, int usec) {
+	struct timeval  timeout;
+	timeout.tv_sec = sec;
+	timeout.tv_usec = usec;
+	select(0, NULL, NULL, NULL, &timeout);
+}
+
+UINT64 get_usec(void) {
+	struct timeval  tv;
+
+	if (gettimeofday(&tv, NULL) == -1) {
+		warning("unable to get time-of-day, %s", strerror(errno));
+	}
+	return 1000000LL * tv.tv_sec + tv.tv_usec;
+}
+
+void get_sizes(struct magnet_data *data, int *bufsize, int *recsize) {
+	unsigned long long sizes;
+
+	/* Take into account endian format */
+	if (data->event == MAGNET_SYSINFO) {
+		sizes = data->timestamp;
+	} else if (eswap_int(data->event) == MAGNET_SYSINFO) {
+		sizes = eswap_int(data->timestamp);
+	} else {
+		error("unknown endian format");
+		exit(1);
+	}
+
+	*bufsize = (sizes & 0xFFFFFFFF00000000) >> 32;
+	*recsize =  sizes & 0x00000000FFFFFFFF;
+}
+
+void read_kernel_data(unsigned int max_bytes, unsigned int sleep_time) {
+	/*
+	-- We use explicit arithmetic on void pointer because it gives
+	-- greater flexibility. (We can accomodate normal or extended
+	-- event records without recompiling magnet-read.)
+	*/
+	unsigned int  sleep_sec = sleep_time / 1000000;
+	unsigned int  sleep_usec = sleep_time % 1000000;
+	double        seconds = sleep_time / 1000000.0;
+	void         *current = kernel_data;
+	void         *trace_data = save_data;
+	unsigned int  bufsize, recsize;
+	void         *kernel_last_byte;
+
+	/* Wait for SYSINFO record to become valid */
+	while (((struct magnet_data *) current)->timestamp == 0 || 
+		((struct magnet_data *) current)->timestamp == 0xFFFFFFFFFFFFFFFF) {
+		delay(sleep_sec, sleep_usec);
+	}
+
+	/* Get buffer and record sizes from SYSINFO record */
+	get_sizes(kernel_data, &bufsize, &recsize);
+	printf("Record size is %u bytes\n", recsize);
+	printf("Kernel buffer size is %u events (%u bytes)\n", 
+			bufsize / recsize, bufsize);
+	kernel_last_byte = (char *) kernel_data + recsize * (bufsize / recsize) - 1;
+
+	printf("Sleep time is %0.6f seconds\n", seconds);
+
+	if (verbose) {
+		printf("Recording a maximum of %d bytes...\n", max_bytes);
+	}
+	written = 0;
+	start_time = get_usec();
+	while (written < max_bytes) {
+		active_count++;
+		while (written < max_bytes && 
+				((struct magnet_data *) current)->timestamp != 0) {
+			memcpy(trace_data, current, recsize);
+			((struct magnet_data *) current)->timestamp = 0;
+			written += recsize;
+			current += recsize;
+			trace_data += recsize;
+			if (current > kernel_last_byte) {
+				current = kernel_data;
+			}
+		}
+		delay(sleep_sec, sleep_usec);
+  }
+}
+
+void terminate(int signal) {
+	UINT64  end_time = get_usec();
+	int     events;
+	double  elapsed_time;
+
+	if (verbose) {
+		fputs("Closing trace file\n", stdout);
+	}
+  msync(save_data, written, MS_SYNC);
+  munmap(save_data, trace_stat.st_size);
+  munlock(save_data, trace_stat.st_size);
+  if (written < trace_stat.st_size) {
+    ftruncate(trace, written);
+	}
+  close(trace);
+
+	if (verbose) {
+		fputs("Unmapping MAGNET kernel buffer\n", stdout);
+	}
+  munmap(kernel_data, MAGNET_DATA_SIZE);
+  close(magnet);  
+
+	if (verbose) {
+		fputs("De-installing signal handlers\n", stdout);
+	}
+  if (sigaction(SIGTERM, &oact_term, NULL) < 0) {
+    error("error: Failed to restore SIGTERM signal handler\n");
+	}
+  if (sigaction(SIGINT, &oact_int, NULL) < 0) {
+    error("error: Failed to restore SIGINT signal handler\n");
+	}
+
+	elapsed_time = (end_time - start_time) / 1000000.0;
+	events = written / sizeof(struct magnet_data);
+  printf("Captured %u events (%u bytes) "
+			"in %0.2f seconds (%0.2f events/second)\n", 
+			events, written, elapsed_time, events / elapsed_time);
+
+  exit(0);
+}
+
+void usage(const char *prog) {
+	fprintf(stderr, helpstr, prog, DEFAULT_SLEEP_TIME, DEFAULT_DEVNAME);
+}
+
+int main(int argc, char *argv[]) {
+	int   errors = 0, sleep_time = DEFAULT_SLEEP_TIME, c;
+	char  devname[MAX_FNAME], *fname;
+
+	strncpy(devname, DEFAULT_DEVNAME, MAX_FNAME);
+
+  opterr = 0; /* disable getopt generated error msg */
+  while ((c = getopt(argc, argv, "hvs:d:")) != -1) {
+		switch (c) {
+		 case 'h':
+			usage(argv[0]);
+			return 0;
+		 case 'v':
+			verbose = (verbose ? 0 : 1);
+			break;
+		 case 's':
+			sleep_time = atoi(optarg);
+			if (sleep_time < 0) {
+				error("sleep time is negative");
+				errors++;
+				continue;
+			}
+			break;
+		 case 'd':
+			strncpy(devname, optarg, MAX_FNAME);
+			break;
+		 default:
+			errors++;
+		}
+	}
+	if (errors) {
+		usage(argv[0]);
+		return 1;
+	}
+	if (optind >= argc) {
+		error("no trace file specified");
+		return 1;
+	}
+	fname = argv[optind];
+
+  if (verbose) {
+		fputs("Opening MAGNET device\n", stderr);
+	}
+  if ((magnet = open(devname, O_RDONLY)) == -1) {
+    error("-- Error: cannot open \"%s\", %s\n", 
+				devname, strerror(errno));
+    return 1;
+  }
+
+  /* Map the shared memory region into our own space */
+	if (verbose) {
+		fputs("Mapping MAGNET kernel buffer\n", stdout);
+	}
+	kernel_data = (struct magnet_data *) 
+		mmap(NULL, MAGNET_DATA_SIZE, PROT_READ, MAP_PRIVATE, magnet, 0);
+  if ((void *) kernel_data == MAP_FAILED) {
+		error("-- Error: cannot mmap MAGNET memory region, %s", strerror(errno));
+		return 1;
+  }
+
+  if (verbose) {
+		fputs("Opening trace file\n", stderr);
+	}
+  if ((trace = open(fname, O_RDWR | O_NDELAY)) <= 0) {
+	  error("-- Error: cannot open trace file \"%s\". "
+				"Create it with mkmagnet\n", fname);
+	  return 1;
+  }
+  if (fstat(trace, &trace_stat) != 0) {
+	  error("-- Error: cannot stat trace file \"%s\"\n", fname);
+	  return 1;
+  }
+  if (trace_stat.st_size <= 0) {
+	  error("trace file must have a non-zero length");
+	  return 1;
+  }
+
+	if (verbose) {
+		fputs("Mapping trace file\n", stdout);
+	}
+  save_data = (struct magnet_data *)
+		mmap(NULL, trace_stat.st_size, PROT_WRITE, MAP_SHARED, trace, 0);
+  if ((void *) save_data == MAP_FAILED) {
+		error("-- Error: could not mmap trace file, %s", strerror(errno));
+	  return 1;
+  }
+  mlock(save_data, trace_stat.st_size);
+
+  /* Set up SIGTERM handler */
+	if (verbose) {
+		fputs("Installing signal handlers\n", stdout);
+	}
+  act.sa_handler = &terminate;
+  sigemptyset(&act.sa_mask);
+  act.sa_flags = 0;
+  if (sigaction(SIGTERM, &act, &oact_term) < 0) {
+    error("cannot install SIGTERM signal handler");
+		return 1;
+	}
+  if (sigaction(SIGINT, &act, &oact_int) < 0) {
+    error("cannot install SIGINT signal handler");
+		return 1;
+	}
+
+  read_kernel_data(trace_stat.st_size, sleep_time);
+
+  terminate(SIGTERM);
+
+  return 0;
+}
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/magnet/magnet.c linux-2.4.19-magnet/magnet/magnet.c
--- linux-2.4.19/magnet/magnet.c	Wed Dec 31 17:00:00 1969
+++ linux-2.4.19-magnet/magnet/magnet.c	Thu Nov 14 14:25:33 2002
@@ -0,0 +1,535 @@
+/*
+-- MAGNET -- Monitoring Apparatus for General kerNel Event Tracing
+--
+-- Version:	@(#)magnet.c	2.0.0	2002/10/22
+--
+-- Authors: Jeff Hay and Mark K. Gardner, radiant-software@lanl.gov
+--
+-- History:
+--
+--   2001-03-06 1.0.0  internal release
+--   2002-10-22 2.0.0  public release
+--
+-- License:
+--
+-- Copyright 2002. The Regents of the University of California.
+--
+-- This material was produced under U.S. Government contract
+-- W-7405-ENG-36 for Los Alamos National Laboratory, which is operated
+-- by the University of California for the U.S. Department of Energy.
+-- The Government is granted for itself and other acting on its behalf
+-- a paid-up, non-exclusive, irrevocable worldwide license in the
+-- material to reproduce, prepare derivative works, and perform
+-- publicly and display publicly. Beginning five (5) years after
+-- November 6, 2002, subject to additional five-year worldwide
+-- renewals, the Government is granted for itself and others acting on
+-- its behalf a paid-up, nonexclusive, irrevocable worldwide license
+-- in this material to reproduce, prepare derivative works, distribute
+-- copies to the public, perform publicly and display publicly, and to
+-- permit others to do so. NEITHER THE UNITED STATES NOR THE UNITED
+-- STATES DEPARTMENT OF ENERGY, NOR THE UNIVERSITY OF CALIFORNIA, NOR
+-- ANY OF THEIR EMPLOYEES, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+-- ASSUMES ANY LEGAL LIABLITY OR RESPONSIBILITY FOR THE ACCURACY,
+-- COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT,
+-- OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE
+-- PRIVATELY OWNED RIGHTS.
+--
+-- Additionally, this program is free software; you can distribute 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 any later version. Accordingly, 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.
+*/
+
+#include <asm/io.h>
+#include <asm/page.h>
+#include <linux/config.h>
+#include <linux/fs.h>
+#include <linux/kernel.h>
+#include <linux/miscdevice.h>
+#include <linux/magnet.h>
+#include <linux/mm.h>
+#include <linux/pagemap.h>
+#include <linux/proc_fs.h>
+#include <linux/skbuff.h>
+#include <linux/smp_lock.h>
+#include <linux/stddef.h>
+#include <linux/wrapper.h>
+#include <net/dst.h>
+#include <net/route.h>
+#include <net/sock.h>
+
+/* What we need to determine CPU speed (see magnet_cpu_speed() below) */
+#ifdef __powerpc__
+#include <asm/prom.h>
+#else
+extern unsigned long cpu_khz;
+#endif
+
+
+static int  magnet_setup(void);
+static void magnet_destroy(void);
+static int  magnet_open(struct inode *inode, struct file *file);
+static int  magnet_close(struct inode *inode, struct file *file);
+static int  magnet_mmap(struct file *file, struct vm_area_struct *vma);
+static int  magnet_proc_read(char *page, char **start, off_t offset, 
+                             int count, int *eof, void *data);
+
+static struct proc_dir_entry *magnet_dir, *magnet_file;
+
+/*
+-- mmap() structures to facilitate user/kernel shared memory
+*/
+static struct file_operations magnet_fops = {
+  mmap:    magnet_mmap,
+  open:    magnet_open,
+  release: magnet_close
+};
+
+/*
+-- This corresponds with a /dev/magnet device with major number 10,
+-- minor MISC_DYNAMIC_MINOR (normally 63)
+*/
+static struct miscdevice magnet_device = {
+  minor:  MISC_DYNAMIC_MINOR,
+  name:   "magnet",
+  fops:   &magnet_fops
+};
+
+/*
+-- Globbal socket instrumentation variables 
+*/
+static unsigned long  magnet_lock_flags; /* lock circular buffer       */
+static spinlock_t     magnet_spinlock = SPIN_LOCK_UNLOCKED;
+
+static char          *magnet_data;       /* kernel-space magnet buffer */
+static char          *magnet_last_byte;  /* last byte of kernel buffer */
+static char          *magnet_data_offs;  /* where kernel is in buffer  */
+static unsigned int   magnet_lost_pkts;  /* count of lost events       */
+
+
+/* 
+-- Routines to access magnet data
+*/
+extern int magnet_proc_read(char *page, char **start, off_t offset, 
+		int count, int *eof, void *data) {
+	int len = 0;
+
+	len += snprintf(page + len, count - len,
+			"---------------------------------------------------------------\n");
+	len += snprintf(page + len,  count - len,
+			"MAGNET: Monitoring Apparatus for General kerNel Event Tracing\n");
+	len += snprintf(page + len,  count - len,
+			"---------------------------------------------------------------\n");
+
+	len += snprintf(page + len, count - len, "Version: %d.%d.%d\n", 
+		       (MAGNET_VERSION & 0x0FF000000) >> 24, 
+		       (MAGNET_VERSION & 0x0FF0000) >> 16, 
+		       (MAGNET_VERSION & 0x0FF00) >> 8); 
+
+	len += snprintf(page + len, count - len, 
+			"Device Name: /dev/%s\n", magnet_device.name);
+	len += snprintf(page + len,  count - len,
+			"Device Number: 10, %d\n", magnet_device.minor);
+	len += snprintf(page + len,  count - len, 
+			"Buffer Size: %ld KB (%ld pages)\n", 
+			(MAGNET_DATA_SIZE / 1024), (MAGNET_DATA_SIZE / PAGE_SIZE));
+	len += snprintf(page + len,  count - len,
+			"Record size: %d bytes\n", sizeof(struct magnet_data));
+
+	len += snprintf(page + len, count - len, "Extended Info: ");
+#ifdef CONFIG_MAGNET_EXTENDED
+	len += snprintf(page + len, count - len, "on\n");
+#else
+	len += snprintf(page + len, count - len, "off\n");
+#endif
+
+	len += snprintf(page + len, count - len, "Debugging Code: ");
+#ifdef CONFIG_MAGNET_DEBUG
+	len += snprintf(page + len, count - len, "on\n");
+#else
+	len += snprintf(page + len, count - len, "off\n");
+#endif
+
+	len += snprintf(page + len, count - len, "Benchmarking: ");
+#ifdef CONFIG_MAGNET_BENCHMARK
+	len += snprintf(page + len, count - len, "on\n");
+#else
+	len += snprintf(page + len, count - len, "off\n");
+#endif
+
+	len += snprintf(page + len, count - len, "Socket: ");
+#ifdef CONFIG_MAGNET_SOCK
+#ifdef CONFIG_MAGNET_SOCK_EXT
+	len += snprintf(page + len, count - len, "extended\n");
+#else
+	len += snprintf(page + len, count - len, "on\n");
+#endif
+#else
+	len += snprintf(page + len, count - len, "off\n");
+#endif
+	len += snprintf(page + len, count - len, "TCP: ");
+#ifdef CONFIG_MAGNET_TCP
+#ifdef CONFIG_MAGNET_TCP_EXT
+	len += snprintf(page + len, count - len, "extended\n");
+#else
+	len += snprintf(page + len, count - len, "on\n");
+#endif
+#else
+	len += snprintf(page + len, count - len, "off\n");
+#endif
+	len += snprintf(page + len, count - len, "UDP: ");
+#ifdef CONFIG_MAGNET_UDP
+#ifdef CONFIG_MAGNET_UDP_EXT
+	len += snprintf(page + len, count - len, "extended\n");
+#else
+	len += snprintf(page + len, count - len, "on\n");
+#endif
+#else
+	len += snprintf(page + len, count - len, "off\n");
+#endif
+	len += snprintf(page + len, count - len, "IP: ");
+#ifdef CONFIG_MAGNET_IP
+#ifdef CONFIG_MAGNET_IP_EXT
+	len += snprintf(page + len, count - len, "extended\n");
+#else
+	len += snprintf(page + len, count - len, "on\n");
+#endif
+#else
+	len += snprintf(page + len, count - len, "off\n");
+#endif
+	len += snprintf(page + len, count - len, "Network Device: ");
+#ifdef CONFIG_MAGNET_DEV
+	len += snprintf(page + len, count - len, "on\n");
+#else
+	len += snprintf(page + len, count - len, "off\n");
+#endif
+	len += snprintf(page + len, count - len, "Ethernet: ");
+#ifdef CONFIG_MAGNET_DEV_ETH
+#ifdef CONFIG_MAGNET_DEV_ETH_EXT
+	len += snprintf(page + len, count - len, "extended\n");
+#else
+	len += snprintf(page + len, count - len, "on\n");
+#endif
+#else
+	len += snprintf(page + len, count - len, "off\n");
+#endif
+
+	len += snprintf(page + len, count - len, "Task: ");
+#ifdef CONFIG_MAGNET_TASK
+	len += snprintf(page + len, count - len, "on\n");
+#else
+	len += snprintf(page + len, count - len, "off\n");
+#endif /* CONFIG_MAGNET_TASK */
+
+	len += snprintf(page + len,  count - len,
+			"---------------------------------------------------------------\n");
+	len += snprintf(page + len,  count - len,
+			"RADIANT (http://www.lanl.gov/radiant)\n");
+
+	len += snprintf(page + len,  count - len,
+			"---------------------------------------------------------------\n");
+
+	return len;
+} 
+
+/*
+-- Determines the CPU speed; done here so we have a common place to
+-- extract this information on any platform (since the code in the
+-- /arch tree doesn't do a good job of abstracting this information
+-- for us).
+-- 
+-- Returns speed in Kcycles/second.
+--
+-- This is the only part of MAGNET that is really platform dependent,
+-- as there is no common way to get this info across all Linux
+-- platforms. However, /arch/(platform)/kernel/setup.c usually
+-- contains the necessary steps.... (for displaying the CPU speed in
+-- /proc/cpuinfo)
+*/
+unsigned int magnet_cpu_speed(void) {
+#ifdef __powerpc__
+	int *clock = (int *) get_property(find_type_devices("cpu"), 
+			"clock-frequency", NULL);
+	return (*clock / 1000);
+#else
+	/* Don't know the architecture; assume i386 family... */
+	return cpu_khz;
+#endif
+}
+
+/*
+-- Internal function to add a record to circular kernel buffer.
+--
+-- Note: the interface changes depending on whether or not we are
+-- saving the extended data. We want to use as few cycles as possible.
+*/
+#ifndef CONFIG_MAGNET_EXTENDED
+static __inline__ void magnet_add_internal(unsigned int event, unsigned int id,
+		int param, long long now) {
+#else
+static __inline__ void magnet_add_internal(unsigned int event, unsigned int id,
+		int param, long long now, int size, union magnet_ext_data *data) {
+#endif /*  CONFIG_MAGNET_EXTENDED */
+	unsigned int          recsize = sizeof(struct magnet_data);
+	struct magnet_data   *cur;
+
+	/* Make sure kernel buffer is available */
+	if (magnet_data == NULL) {
+		return;
+	}
+
+	/* Grab a spinlock to be SMP and interrupt safe */
+	spin_lock_irqsave(&magnet_spinlock, magnet_lock_flags);
+
+ try_save:
+	cur = (struct magnet_data *) magnet_data_offs;
+	if (cur->timestamp == 0) {
+#ifdef CONFIG_MAGNET_EXTENDED
+		memset(&cur->data, 0, sizeof(struct magnet_data)); /* Clear record */
+#endif /* CONFIG_MAGNET_DEBUG && CONFIG_MAGNET_EXTENDED */
+		if (magnet_lost_pkts > 0) {
+			cur->event  = MAGNET_LOST;
+			cur->id     = 0;
+			cur->param  = magnet_lost_pkts;
+		} else {
+			cur->event  = event;
+			cur->id     = id;
+			cur->param  = param;
+#ifdef CONFIG_MAGNET_EXTENDED
+			memcpy(&cur->data, data, size);
+#endif /*  CONFIG_MAGNET_EXTENDED */
+		}
+		/* Write timestamp last as a signal to user-space program */
+		cur->timestamp = now;
+
+		/* Index to next slot */
+		magnet_data_offs += recsize;
+		if (magnet_data_offs > magnet_last_byte) {
+			magnet_data_offs = magnet_data; 
+		}
+
+		/* Packets were lost so retry saving record */
+		if (magnet_lost_pkts > 0) {
+			magnet_lost_pkts = 0;
+			goto try_save;
+		}
+	} else {
+		magnet_lost_pkts++;
+	}
+
+	spin_unlock_irqrestore(&magnet_spinlock, magnet_lock_flags);
+}
+
+/*
+-- External function to add a record to circular kernel buffer.
+--
+-- Note: the interface changes depending on whether or not we are
+-- saving the extended data. We want to use as few cycles as possible.
+*/
+#ifndef CONFIG_MAGNET_EXTENDED
+void magnet_add(unsigned int event, unsigned int id, int param) {
+#else
+void magnet_add(unsigned int event, unsigned int id, int param, 
+		unsigned int size, union magnet_ext_data *data) {
+#endif /* CONFIG_MAGNET_EXTENDED */
+	unsigned long long  now;
+
+	now = get_cycles(); /* This must be first for best accuracy! */
+#ifndef CONFIG_MAGNET_EXTENDED
+	magnet_add_internal(event, id, param, now);
+#else
+	magnet_add_internal(event, id, param, now, size, data);
+#endif /* CONFIG_MAGNET_EXTENDED */
+}
+EXPORT_SYMBOL(magnet_add);
+
+/*
+-- Internal function to add a SYSINFO record to circular kernel buffer.
+*/
+static void magnet_add_sysinfo(void) {
+	unsigned int speed = magnet_cpu_speed();
+	unsigned long long sizes = 
+		(((unsigned long long) MAGNET_DATA_SIZE) << 32) | 
+		(unsigned long long) sizeof(struct magnet_data);
+
+#ifndef CONFIG_MAGNET_EXTENDED
+	magnet_add_internal(MAGNET_SYSINFO, MAGNET_VERSION, speed, sizes);
+#else
+	magnet_add_internal(MAGNET_SYSINFO, MAGNET_VERSION, speed, sizes, 
+			MAGNET_NO_DATA);
+#endif /* CONFIG_MAGNET_EXTENDED */
+}
+
+/*
+-- Internal function to add a DATEINFO record to circular kernel buffer.
+*/
+static void magnet_add_dateinfo(void) {
+	unsigned long long  before, after, timestamp;
+  struct timeval timev;
+
+	before = get_cycles();
+  do_gettimeofday(&timev);
+	after = get_cycles();
+	timestamp = (before + after) / 2;
+
+#ifndef CONFIG_MAGNET_EXTENDED
+  magnet_add_internal(MAGNET_DATEINFO, timev.tv_sec, timev.tv_usec, timestamp);
+#else
+  magnet_add_internal(MAGNET_DATEINFO, timev.tv_sec, timev.tv_usec, timestamp, 
+			MAGNET_NO_DATA);
+#endif /* CONFIG_MAGNET_EXTENDED */
+}
+
+
+/* Initialize socket instrumentation interface */
+static int magnet_setup(void) {
+	struct page *page;
+	int error;
+
+	/* Initialize kernel-space pointer into buffer */
+	magnet_data_offs = magnet_data;
+	magnet_last_byte = magnet_data + sizeof(struct magnet_data) * 
+		(MAGNET_DATA_SIZE / sizeof(struct magnet_data)) - 1;
+
+	/* Create magnet proc file for reporting status */
+	magnet_file = create_proc_read_entry("magnet", S_IRUGO, 
+			&proc_root, magnet_proc_read, NULL);
+	if (magnet_file == NULL) {
+		error = -ENOMEM;
+		goto out;
+	}
+
+	/* Pin down our buffer's pages, so they can't be swapped out */
+	for (page = virt_to_page(magnet_data);
+	     page < virt_to_page(magnet_data + MAGNET_DATA_SIZE);
+	     page++)
+		mem_map_reserve(page);
+
+	/* Register as a misc char device for doing mmap's */	
+	error = misc_register(&magnet_device);
+
+ out:
+	return error;
+}
+
+/* Called at boot-time when subsystems are being initialized */
+void magnet_init(void) {
+	printk(KERN_INFO "MAGNET: kernel monitoring instrumentation\n");
+
+#ifdef CONFIG_MAGNET_EXTENDED
+	printk(KERN_INFO "MAGNET: extended instrumentation records\n");
+#endif
+
+#ifdef CONFIG_MAGNET_NET
+	printk(KERN_INFO "MAGNET: monitoring network protocol stack\n");
+#ifdef CONFIG_MAGNET_SOCK
+	printk(KERN_INFO "MAGNET: monitoring socket layer\n");
+#endif
+#ifdef CONFIG_MAGNET_TCP
+	printk(KERN_INFO "MAGNET: monitoring TCP layer\n");
+#endif
+#ifdef CONFIG_MAGNET_UDP
+	printk(KERN_INFO "MAGNET: monitoring UDP layer\n");
+#endif
+#ifdef CONFIG_MAGNET_IP
+	printk(KERN_INFO "MAGNET: monitoring IP layer\n");
+#endif
+#ifdef CONFIG_MAGNET_DEV_NET
+	printk(KERN_INFO "MAGNET: monitoring generic network device layer\n");
+#endif
+#ifdef CONFIG_MAGNET_DEV_ETH
+	printk(KERN_INFO "MAGNET: monitoring ethernet device layer\n");
+#endif
+#endif
+
+#ifdef CONFIG_MAGNET_TASK
+	printk(KERN_INFO "MAGNET: monitoring tasks\n");
+#endif
+
+	if ((magnet_data = (char *)__get_free_pages(
+		GFP_ATOMIC, get_order(MAGNET_DATA_SIZE))) == NULL)
+		printk(KERN_ERR "MAGNET: no memory for instrumentation buffer\n");
+	else
+		magnet_setup();
+	return;
+}
+
+/*
+-- Teardown socket instrumentation interface (this is never called
+-- in the current implementation. Code listed here to make converting
+-- this to a module "easy"....)
+*/
+static void magnet_destroy(void) {
+	struct page *page;
+
+	/* disable mmap()ing of buffer space */
+	misc_deregister(&magnet_device);
+
+	/* un-pin buffer space */
+	for (page = virt_to_page(magnet_data);
+	     page < virt_to_page(magnet_data + MAGNET_DATA_SIZE);
+	     page++)
+		mem_map_unreserve(page);
+
+	/* remove /proc information hook */
+	proc_net_remove("magnet");
+
+	return;
+}
+
+/*
+-- mmap() shared-memory routines 
+*/
+static int magnet_open(struct inode *inode, struct file *file) {
+	/* Do nothing, just to make the VFS happy... */
+	return 0;
+}
+
+static int magnet_close(struct inode *inode, struct file *file) {
+	/* Do nothing, just to make the VFS happy... */
+	return 0;
+}
+
+static int magnet_mmap(struct file *file, struct vm_area_struct *vma) {
+	/* Set up the shared memory to user-level process */
+	unsigned long size = (unsigned long)(vma->vm_end - vma->vm_start);
+	
+	/* First, make sure we're within bounds */
+	if (size > MAGNET_DATA_SIZE)
+		return -EINVAL;
+
+	lock_kernel();
+
+	/* Step through our buffer a page at a time, and remap each page
+	   into the user-mode address space */
+	if (remap_page_range(vma->vm_start, 
+			     virt_to_phys(magnet_data),
+			     size, PAGE_SHARED)) {
+		printk(KERN_ERR "MAGNET: remapping failed\n");
+		return -EAGAIN;
+	}
+
+	/* Don't swap this VMA out! */
+	vma->vm_flags |= VM_SHM | VM_LOCKED | VM_IO;
+
+	/* Clear the memory so user doesn't read old information */
+	memset(magnet_data, 0, size);
+	magnet_data_offs = magnet_data;
+	magnet_lost_pkts = 0;
+
+	unlock_kernel();
+
+	/* Add system and date information `to the beginning of the dump */
+	magnet_add_sysinfo();
+	magnet_add_dateinfo();
+
+	/* Success! */
+	return 0;
+}
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/magnet/magnet.copy linux-2.4.19-magnet/magnet/magnet.copy
--- linux-2.4.19/magnet/magnet.copy	Wed Dec 31 17:00:00 1969
+++ linux-2.4.19-magnet/magnet/magnet.copy	Thu Nov 14 14:25:48 2002
@@ -0,0 +1,88 @@
+#!/bin/sh
+#
+# MAGNET -- Monitoring Apparatus for General kerNel Event Tracing
+#
+# Version:	@(#)magnet.copy	2.0.0	2002/10/22
+#
+# Authors: Jeff Hay and Mark K. Gardner, radiant-software@lanl.gov
+#
+# History:
+#
+#   2001-03-06 1.0.0  internal release
+#   2002-10-22 2.0.0  public release
+#
+# License:
+#
+# Copyright 2002. The Regents of the University of California.
+#
+# This material was produced under U.S. Government contract
+# W-7405-ENG-36 for Los Alamos National Laboratory, which is operated
+# by the University of California for the U.S. Department of Energy.
+# The Government is granted for itself and other acting on its behalf
+# a paid-up, non-exclusive, irrevocable worldwide license in the
+# material to reproduce, prepare derivative works, and perform
+# publicly and display publicly. Beginning five (5) years after
+# November 6, 2002, subject to additional five-year worldwide
+# renewals, the Government is granted for itself and others acting on
+# its behalf a paid-up, nonexclusive, irrevocable worldwide license
+# in this material to reproduce, prepare derivative works, distribute
+# copies to the public, perform publicly and display publicly, and to
+# permit others to do so. NEITHER THE UNITED STATES NOR THE UNITED
+# STATES DEPARTMENT OF ENERGY, NOR THE UNIVERSITY OF CALIFORNIA, NOR
+# ANY OF THEIR EMPLOYEES, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+# ASSUMES ANY LEGAL LIABLITY OR RESPONSIBILITY FOR THE ACCURACY,
+# COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT,
+# OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE
+# PRIVATELY OWNED RIGHTS.
+#
+# Additionally, this program is free software; you can distribute 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 any later version. Accordingly, 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.
+#
+
+###
+#   Sample MAGNET archiving script.  Copies any gzipped files in the
+#   directory given as the first parameter to a directory on a remote
+#   machine, using scp (or any other rcp-like command).
+###
+
+# Configurable parameters:
+
+# Host to archive to
+ARCH_HOST=server
+
+# Directory to archive to
+ARCH_DIR=/data/magnet/thishost
+
+# RCP-like program
+RCP=/usr/local/bin/scp
+RCP_OPTS="-qp"
+
+# Archive log file
+ARCH_FILE=/var/log/magnet
+
+####################################################################
+
+if [ "$1" = "" -o ! -d "$1" ]; then
+  echo "$0: Invalid directory to archive: syntax \"$0 <arch_dir>\""
+  exit 1
+fi
+
+for FILE in `ls $1/*.gz`
+do
+  echo -n `date`": " >> $ARCH_FILE
+  echo "Archiving $FILE to $ARCH_HOST" >> $ARCH_FILE
+  $RCP $RCP_OPTS $FILE $ARCH_HOST:$ARCH_DIR/ >> $ARCH_FILE 2>&1
+  if [ $? -eq 0 ]; then
+    rm -f $FILE
+  fi
+done
+
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/magnet/magnet.cron linux-2.4.19-magnet/magnet/magnet.cron
--- linux-2.4.19/magnet/magnet.cron	Wed Dec 31 17:00:00 1969
+++ linux-2.4.19-magnet/magnet/magnet.cron	Thu Nov 14 14:26:03 2002
@@ -0,0 +1,172 @@
+#!/bin/sh
+#
+# MAGNET -- Monitoring Apparatus for General kerNel Event Tracing
+#
+# Version:	@(#)magnet.cron	2.0.0	2002/10/22
+#
+# Authors: Jeff Hay and Mark K. Gardner, radiant-software@lanl.gov
+#
+# History:
+#
+#   2001-03-06 1.0.0  internal release
+#   2002-10-22 2.0.0  public release
+#
+# License:
+#
+# Copyright 2002. The Regents of the University of California.
+#
+# This material was produced under U.S. Government contract
+# W-7405-ENG-36 for Los Alamos National Laboratory, which is operated
+# by the University of California for the U.S. Department of Energy.
+# The Government is granted for itself and other acting on its behalf
+# a paid-up, non-exclusive, irrevocable worldwide license in the
+# material to reproduce, prepare derivative works, and perform
+# publicly and display publicly. Beginning five (5) years after
+# November 6, 2002, subject to additional five-year worldwide
+# renewals, the Government is granted for itself and others acting on
+# its behalf a paid-up, nonexclusive, irrevocable worldwide license
+# in this material to reproduce, prepare derivative works, distribute
+# copies to the public, perform publicly and display publicly, and to
+# permit others to do so. NEITHER THE UNITED STATES NOR THE UNITED
+# STATES DEPARTMENT OF ENERGY, NOR THE UNIVERSITY OF CALIFORNIA, NOR
+# ANY OF THEIR EMPLOYEES, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+# ASSUMES ANY LEGAL LIABLITY OR RESPONSIBILITY FOR THE ACCURACY,
+# COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT,
+# OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE
+# PRIVATELY OWNED RIGHTS.
+#
+# Additionally, this program is free software; you can distribute 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 any later version. Accordingly, 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.
+#
+
+#################################################################
+#    This is a wrapper script for the MAGNET tools.  It is
+# primairly intended to be run from cron, or upon bootup.  The
+# script:
+#       o Ensures that the kernel is running MAGNET code
+#         + Aborts gracefully if non-MAGNET-ized
+#       o Ensures that the proper MAGNET device file exists
+#         + Creates the file if it does not exist
+#         + Modifies device numbers if necessary
+#       o Compresses any un-compressed MAGNET data
+#       o Calls the Archive script to archive the data
+#       o Generates a new MAGNET data storage file
+#       o Runs magnet-read with proper parameters 
+#         (as a background process)
+#
+# Configurable parameters for the script follow.  Script must
+# be run suid root. The following programs must be in the 
+# current path when the script is run:
+#
+# ls echo date dc cut rm mknod kill awk ps hostname gzip
+#
+# If the first parameter to this script is "-n", the script will
+# echo the commands it would normally execute to stdout, and will
+# NOT execute them.
+#################################################################
+
+# Set up the following constants to conform to your system
+#   - Path names should NOT end with a "/"
+
+# Complete path to magnet binary files
+MAGNET_BIN="/bin/magnet"
+
+# Complete path to magnet data storage area
+MAGNET_DATA="/data/magnet"
+
+# Size of MAGNET data storage files, in Megabytes
+MAGNET_SAVESIZE=100
+
+# Parameters to pass to "magnet-read"
+MAGNET_OPTS=""
+
+# MAGNET archiving script name
+# This script is called to move all gzipped files in $MAGNET_DATA
+# to an archival location.  $MAGNET_DATA is passed as first param.
+# The script is guarented to be called when MAGNET is NOT running.
+# This var may be set to empty
+MAGNET_ARCHIVE="$MAGNET_BIN/magnet.copy"
+
+# End of configurable options
+##################################################################
+
+##################################################################
+# Set up some constants for this incarnation of MAGNET
+
+# Name of MAGNET /proc file (shouldn't ever change)
+MAGNAME="/proc/net/magnet"
+
+# Pattern to match in /proc file for MAGNET Device Name
+MAGDEVNAME="Device Name"
+
+# Pattern to match in /proc file for MAGNET Device Numbers
+MAGDEVNUM="Device Number"
+
+# Names of MAGNET executable files
+MKMAGNET="mkmagnet"
+MAGNETREAD="magnet-read"
+
+# End of constant setup
+##################################################################
+
+# Set up "-n" functionality
+if [ "$1" == "-n" ]; then
+  CMD="echo"
+fi
+
+# First, determine if we are running a MAGNET-ized kernel
+ls $MAGNAME > /dev/null 2>&1
+if [ $? -ne 0 ]; then
+  echo "$0: Not running Magnet-ized kernel; aborting."
+  exit 1
+fi
+
+# Make sure we have proper MAGNET device file (device name/number match)
+#
+DEVICE=`grep "$MAGDEVNAME" $MAGNAME | cut -f2 -d:`
+DNUM=`grep "$MAGDEVNUM" $MAGNAME | cut -f2 -d:`
+EXIST=`ls -l $DEVICE` > /dev/null 2>&1
+NEWDEV=$?
+DEVNUM=`echo $EXIST | cut -f5-6 -d" "`
+if [ $NEWDEV -ne 0 -o " $DEVNUM" != "$DNUM" ]; then
+  $CMD rm -f $DEVICE
+  $CMD mknod $DEVICE c $DMAJOR `echo $DNUM | awk 'BEGIN {FS=","}{print $1 $2}'`
+fi
+
+# Generate a unique file name for the storage file
+HOST=`hostname`
+UNIQUE=`date +"%d%b%Y-%H%M%S"`
+FNAME="$MAGNET_DATA/$HOST.$UNIQUE"
+
+# Make the new storage file
+$CMD $MAGNET_BIN/$MKMAGNET $FNAME `echo "1024 1024 $MAGNET_SAVESIZE * * p" | dc`
+
+# There's a chance (ie, we're running from cron) that magnet-read is
+# currently running.  If so, send the TERM signal to it (this
+# works for multiple running instances)
+MPID=`ps -e | awk '{ if ($4 == "'$MAGNETREAD'") {print $1} }'`
+if [ "$MPID" != "" ]; then
+  $CMD kill $MPID
+fi
+
+# Compress and Archive latest MAGNET storage file(s)
+for STORE in `ls $MAGNET_DATA | grep -v ".gz" | grep -v $HOST.$UNIQUE`
+do
+  $CMD gzip $MAGNET_DATA/$STORE
+done
+# Call Archive script to off-load the old storage files
+if [ "$MAGNET_ARCHIVE" != "" ]; then
+  $CMD $MAGNET_ARCHIVE $MAGNET_DATA
+fi
+
+# All's ready; re-run MAGNET
+$CMD $MAGNET_BIN/$MAGNETREAD $MAGNET_OPTS $DEVICE $FNAME &
Binary files linux-2.4.19/magnet/mkmagnet and linux-2.4.19-magnet/magnet/mkmagnet differ
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/magnet/mkmagnet.c linux-2.4.19-magnet/magnet/mkmagnet.c
--- linux-2.4.19/magnet/mkmagnet.c	Wed Dec 31 17:00:00 1969
+++ linux-2.4.19-magnet/magnet/mkmagnet.c	Thu Nov 14 14:26:15 2002
@@ -0,0 +1,153 @@
+/*
+-- MAGNET -- Monitoring Apparatus for General kerNel Event Tracing
+--
+-- Version:	@(#)mkmagnet.c	2.0.0	2002/10/22
+--
+-- Authors: Jeff Hay and Mark K. Gardner, radiant-software@lanl.gov
+--
+-- History:
+--
+--   2001-03-06 1.0.0  internal release
+--   2002-10-22 2.0.0  public release
+--
+-- License:
+--
+-- Copyright 2002. The Regents of the University of California.
+--
+-- This material was produced under U.S. Government contract
+-- W-7405-ENG-36 for Los Alamos National Laboratory, which is operated
+-- by the University of California for the U.S. Department of Energy.
+-- The Government is granted for itself and other acting on its behalf
+-- a paid-up, non-exclusive, irrevocable worldwide license in the
+-- material to reproduce, prepare derivative works, and perform
+-- publicly and display publicly. Beginning five (5) years after
+-- November 6, 2002, subject to additional five-year worldwide
+-- renewals, the Government is granted for itself and others acting on
+-- its behalf a paid-up, nonexclusive, irrevocable worldwide license
+-- in this material to reproduce, prepare derivative works, distribute
+-- copies to the public, perform publicly and display publicly, and to
+-- permit others to do so. NEITHER THE UNITED STATES NOR THE UNITED
+-- STATES DEPARTMENT OF ENERGY, NOR THE UNIVERSITY OF CALIFORNIA, NOR
+-- ANY OF THEIR EMPLOYEES, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+-- ASSUMES ANY LEGAL LIABLITY OR RESPONSIBILITY FOR THE ACCURACY,
+-- COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT,
+-- OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE
+-- PRIVATELY OWNED RIGHTS.
+--
+-- Additionally, this program is free software; you can distribute 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 any later version. Accordingly, 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.
+*/
+
+#include <getopt.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <linux/magnet.h>
+
+#define DEFAULT_SIZE  (1024*1024*10)
+#define BUFFER_SIZE   (1024*1024)
+
+#define error(fmt, args...) \
+	fprintf(stderr, "-- Error:  " fmt "\n" "", ## args)
+
+
+static int          verbose = 0;
+static const char *helpstr = 
+	"usage: %s <options>* <filename>*\n"
+	"\n"
+	"   Make an empty MAGNeT trace file prior to reading records\n"
+	"   from the kernel buffer.\n"
+	"\n"
+	" Options:\n"
+	"   -h            help\n"
+	"   -v            verbose\n"
+	"   -b bytes      maximum size of trace file (default %d)\n"
+	"\n"
+	"Output goes to <filename>. (If <filename> is \"-\" or unspecified,\n"
+	"stdout is written.\n";
+
+void usage(const char *prog) {
+	fprintf(stderr, helpstr, prog, DEFAULT_SIZE);
+}
+
+int main(int argc, char *argv[]) {
+  int    size = DEFAULT_SIZE, c, errors = 0;
+  void  *buffer;
+
+  opterr = 0; /* disable getopt generated error msg */
+  while ((c = getopt(argc, argv, "hvb:")) != -1) {
+		switch (c) {
+		 case 'h':
+			usage(argv[0]);
+			return 0;
+		 case 'v':
+			verbose = (verbose ? 0 : 1);
+			break;
+		 case 'b':
+			size = atoi(optarg);
+			break;
+		 default:
+			errors++;
+		}
+	}
+	if (errors) {
+		usage(argv[0]);
+		return 1;
+	}
+
+	/* Allocate temporary buffer */
+  if ((buffer = malloc(BUFFER_SIZE)) == NULL) {
+    error("unable to allocate temporary data buffer");
+    return 1;
+  }
+	/* Keep value is in sync with include/linux/magnet.h */
+	memset(buffer, 0xFF, BUFFER_SIZE); 
+
+	if (optind == argc) {
+		/* Write to stdout */
+		
+	} else {
+		while (optind < argc) {
+			char *fname = argv[optind];
+			FILE *out;
+			int   s;
+
+			if (strcmp(fname, "-") == 0) {
+				if ((out = fdopen(1, "wb")) == NULL) {
+					error("unable to open \"-\" (stdout)");
+					optind++;
+					continue;
+				}
+			} else if ((out = fopen(fname, "wb")) == NULL) {
+				error("unable to open output file \"%s\"", fname);
+				optind++;
+				continue;
+			}
+
+			s = size;
+			while (s > BUFFER_SIZE) {
+				fwrite(buffer, BUFFER_SIZE, 1, out);
+				s -= BUFFER_SIZE;
+			}
+			if (s > 0) {
+				fwrite(buffer, s, 1, out);
+			}
+
+			fclose(out);  
+			optind++;
+		}
+	}
+
+  free(buffer);
+
+  return 0;
+}
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/net/core/dev.c linux-2.4.19-magnet/net/core/dev.c
--- linux-2.4.19/net/core/dev.c	Fri Aug  2 18:39:46 2002
+++ linux-2.4.19-magnet/net/core/dev.c	Fri Nov  8 10:47:01 2002
@@ -108,6 +108,10 @@
 extern int plip_init(void);
 #endif
 
+#ifdef CONFIG_MAGNET_DEV_NET
+#include <linux/magnet.h>
+#endif /* CONFIG_MAGNET_DEV_NET */
+
 
 /* This define, if set, will randomly drop a packet when congestion
  * is more than moderate.  It helps fairness in the multi-interface
@@ -1007,6 +1011,11 @@
 			return -ENOMEM;
 	}
 
+#ifdef CONFIG_MAGNET_DEV_NET
+				/* Mark device xmit */
+				MAGNET_ADD(MAGNET_DEV_SEND, skb->sk, skb->len, MAGNET_NO_DATA);
+#endif /* CONFIG_MAGNET_DEV_NET */
+
 	/* Grab device queue */
 	spin_lock_bh(&dev->queue_lock);
 	q = dev->qdisc;
@@ -1217,6 +1226,10 @@
 	int this_cpu = smp_processor_id();
 	struct softnet_data *queue;
 	unsigned long flags;
+
+#ifdef CONFIG_MAGNET_DEV_NET
+	MAGNET_ADD(MAGNET_DEV_RECV, (unsigned int) skb->sk, skb->len, MAGNET_NO_DATA);
+#endif /* CONFIG_MAGNET_DEV_NET */
 
 	if (skb->stamp.tv_sec == 0)
 		do_gettimeofday(&skb->stamp);
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/net/ipv4/ip_input.c linux-2.4.19-magnet/net/ipv4/ip_input.c
--- linux-2.4.19/net/ipv4/ip_input.c	Fri Aug  2 18:39:46 2002
+++ linux-2.4.19-magnet/net/ipv4/ip_input.c	Tue Nov 12 21:25:09 2002
@@ -144,6 +144,10 @@
 #include <linux/mroute.h>
 #include <linux/netlink.h>
 
+#ifdef CONFIG_MAGNET_IP
+#include <linux/magnet.h>
+#endif /* CONFIG_MAGNET_IP */
+
 /*
  *	SNMP management statistics
  */
@@ -244,6 +248,12 @@
 		struct inet_protocol *ipprot;
 		int flag;
 
+#ifdef CONFIG_MAGNET_IP
+		/* Mark IP hand-off to the upper layer protocol */
+//		MAGNET_ADD(MAGNET_IP_RECV, (unsigned int) raw_sk, skb->len, 
+//		    MAGNET_IP_DATA(skb->nh.iph));
+#endif /* CONFIG_MAGNET_IP */
+
 		/* If there maybe a raw socket we must check - if not we
 		 * don't care less
 		 */
@@ -433,6 +443,11 @@
 				skb->ip_summed = CHECKSUM_NONE;
 		}
 	}
+
+#ifdef CONFIG_MAGNET_IP
+	MAGNET_ADD(MAGNET_IP_RECV, (unsigned int) skb->sk, skb->len, 
+			MAGNET_IP_DATA(skb->nh.iph));
+#endif /* CONFIG_MAGNET_IP */
 
 	return NF_HOOK(PF_INET, NF_IP_PRE_ROUTING, skb, dev, NULL,
 		       ip_rcv_finish);
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/net/ipv4/ip_output.c linux-2.4.19-magnet/net/ipv4/ip_output.c
--- linux-2.4.19/net/ipv4/ip_output.c	Fri Aug  2 18:39:46 2002
+++ linux-2.4.19-magnet/net/ipv4/ip_output.c	Fri Nov  8 07:43:15 2002
@@ -78,6 +78,10 @@
 #include <linux/mroute.h>
 #include <linux/netlink.h>
 
+#ifdef CONFIG_MAGNET_IP
+#include <linux/magnet.h>
+#endif /* CONFIG_MAGNET_IP */
+
 /*
  *      Shall we try to damage output packets if routing dev changes?
  */
@@ -152,6 +156,11 @@
 	}
 	ip_send_check(iph);
 
+#ifdef CONFIG_MAGNET_IP
+  /* Mark IP hand-off to the physical layer */
+  MAGNET_ADD(MAGNET_IP_SEND, sk, skb->len, MAGNET_IP_DATA(iph));
+#endif /* CONFIG_MAGNET_IP */
+
 	/* Send it out. */
 	return NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
 		       output_maybe_reroute);
@@ -397,6 +406,11 @@
 		ip_options_build(skb, opt, sk->daddr, rt, 0);
 	}
 
+#ifdef CONFIG_MAGNET_IP
+  /* Mark IP receipt from ULP */
+  MAGNET_ADD(MAGNET_IP_SEND, sk, skb->len, MAGNET_IP_DATA(iph));
+#endif /* CONFIG_MAGNET_IP */
+
 	return NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
 		       ip_queue_xmit2);
 
@@ -600,6 +614,11 @@
 
 		nfrags++;
 
+#ifdef CONFIG_MAGNET_IP
+		/* Mark IP hand-off to the physical layer */
+		MAGNET_ADD(MAGNET_IP_SEND, sk, skb->len, MAGNET_IP_DATA(skb->nh.iph));
+#endif /* CONFIG_MAGNET_IP */
+
 		err = NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, 
 			      skb->dst->dev, output_maybe_reroute);
 		if (err) {
@@ -710,6 +729,11 @@
 
 	if (err)
 		goto error_fault;
+
+#ifdef CONFIG_MAGNET_IP
+  /* Mark IP hand-off to the physical layer */
+  MAGNET_ADD(MAGNET_IP_SEND, sk, skb->len, MAGNET_IP_DATA(iph));
+#endif /* CONFIG_MAGNET_IP */
 
 	err = NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
 		      output_maybe_reroute);
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/net/ipv4/tcp.c linux-2.4.19-magnet/net/ipv4/tcp.c
--- linux-2.4.19/net/ipv4/tcp.c	Fri Aug  2 18:39:46 2002
+++ linux-2.4.19-magnet/net/ipv4/tcp.c	Fri Nov  8 07:43:15 2002
@@ -259,6 +259,10 @@
 #include <asm/uaccess.h>
 #include <asm/ioctls.h>
 
+#ifdef CONFIG_MAGNET_TCP
+#include <linux/magnet.h>
+#endif /* CONFIG_MAGNET_TCP */
+
 int sysctl_tcp_fin_timeout = TCP_FIN_TIMEOUT;
 
 struct tcp_mib	tcp_statistics[NR_CPUS*2];
@@ -1694,6 +1698,10 @@
 		}
 
 		if (!(flags&MSG_TRUNC)) {
+#ifdef CONFIG_MAGNET_TCP
+      /* Mark the TCP hand-off to Socket */
+      MAGNET_ADD(MAGNET_TCP_RECV, sk, used, MAGNET_TCP_DATA(skb->h.th));
+#endif /* CONFIG_MAGNET_TCP */
 			err = skb_copy_datagram_iovec(skb, offset, msg->msg_iov, used);
 			if (err) {
 				/* Exception. Bailout! */
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/net/ipv4/tcp_ipv4.c linux-2.4.19-magnet/net/ipv4/tcp_ipv4.c
--- linux-2.4.19/net/ipv4/tcp_ipv4.c	Fri Aug  2 18:39:46 2002
+++ linux-2.4.19-magnet/net/ipv4/tcp_ipv4.c	Fri Nov  8 07:43:15 2002
@@ -63,6 +63,10 @@
 #include <linux/stddef.h>
 #include <linux/ipsec.h>
 
+#ifdef CONFIG_MAGNET_TCP
+#include <linux/magnet.h>
+#endif /* CONFIG_MAGNET_TCP */
+
 extern int sysctl_ip_dynaddr;
 extern int sysctl_ip_default_ttl;
 int sysctl_tcp_tw_reuse = 0;
@@ -1753,6 +1757,11 @@
 
 	if (!sk)
 		goto no_tcp_socket;
+
+#ifdef CONFIG_MAGNET_TCP
+	/* Mark TCP receive from IP layer */
+	MAGNET_ADD(MAGNET_TCP_RECV, sk, skb->len, MAGNET_TCP_DATA(skb->h.th));
+#endif /* CONFIG_MAGNET_TCP */
 
 process:
 	if(!ipsec_sk_policy(sk,skb))
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/net/ipv4/tcp_output.c linux-2.4.19-magnet/net/ipv4/tcp_output.c
--- linux-2.4.19/net/ipv4/tcp_output.c	Fri Aug  2 18:39:46 2002
+++ linux-2.4.19-magnet/net/ipv4/tcp_output.c	Fri Nov  8 07:43:15 2002
@@ -41,6 +41,10 @@
 #include <linux/compiler.h>
 #include <linux/smp_lock.h>
 
+#ifdef CONFIG_MAGNET_TCP
+#include <linux/magnet.h>
+#endif /* CONFIG_MAGNET_TCP */
+
 /* People can turn this off for buggy TCP's found in printers etc. */
 int sysctl_tcp_retrans_collapse = 1;
 
@@ -275,6 +279,11 @@
 
 		TCP_INC_STATS(TcpOutSegs);
 
+#ifdef CONFIG_MAGNET_TCP
+    /* Mark TCP hand-off to the IP layer */
+    MAGNET_ADD(MAGNET_TCP_SEND, sk, skb->len, MAGNET_TCP_DATA(skb->h.th));
+#endif /* CONFIG_MAGNET_TCP */
+
 		err = tp->af_specific->queue_xmit(skb);
 		if (err <= 0)
 			return err;
@@ -305,6 +314,11 @@
 void tcp_send_skb(struct sock *sk, struct sk_buff *skb, int force_queue, unsigned cur_mss)
 {
 	struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp);
+
+#ifdef CONFIG_MAGNET_TCP
+  /* Mark the socket hand-off to TCP */
+  MAGNET_ADD(MAGNET_TCP_SEND, sk, skb->len, MAGNET_TCP_DATA(skb->h.th));
+#endif /* CONFIG_MAGNET_TCP */
 
 	/* Advance write_seq and place onto the write_queue. */
 	tp->write_seq = TCP_SKB_CB(skb)->end_seq;
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/net/ipv4/udp.c linux-2.4.19-magnet/net/ipv4/udp.c
--- linux-2.4.19/net/ipv4/udp.c	Fri Aug  2 18:39:46 2002
+++ linux-2.4.19-magnet/net/ipv4/udp.c	Fri Nov  8 07:43:15 2002
@@ -94,6 +94,10 @@
 #include <net/inet_common.h>
 #include <net/checksum.h>
 
+#ifdef CONFIG_MAGNET_UDP
+#include <linux/magnet.h>
+#endif /* CONFIG_MAGNET_UDP */
+
 /*
  *	Snmp MIB for the UDP layer
  */
@@ -540,6 +544,11 @@
 	ufh.iov = msg->msg_iov;
 	ufh.wcheck = 0;
 
+#ifdef CONFIG_MAGNET_UDP
+	/* Mark UDP hand-off to the IP layer */
+	MAGNET_ADD(MAGNET_UDP_SEND, sk, ulen, MAGNET_UDP_DATA(&ufh.uh));
+#endif /* CONFIG_MAGNET_UDP */
+
 	/* RFC1122: OK.  Provides the checksumming facility (MUST) as per */
 	/* 4.1.3.4. It's configurable by the application via setsockopt() */
 	/* (MAY) and it defaults to on (MUST). */
@@ -682,6 +691,11 @@
 		ip_cmsg_recv(msg, skb);
 	err = copied;
   
+#ifdef CONFIG_MAGNET_UDP
+	/* Mark UDP hand-off to socket layer */
+	MAGNET_ADD(MAGNET_UDP_RECV, sk, skb->len, MAGNET_UDP_DATA(skb->h.uh));
+#endif /* CONFIG_MAGNET_UDP */
+
 out_free:
   	skb_free_datagram(sk, skb);
 out:
diff -NPBbruw --exclude=*.d --exclude=.* --exclude=*~ --exclude=*.vars --exclude=debian --exclude=soundmodem --exclude=asm --exclude=config --exclude=autoconf* --exclude=*.ver --exclude=modversions.h --exclude=version.h --exclude=xMake*.log* linux-2.4.19/net/socket.c linux-2.4.19-magnet/net/socket.c
--- linux-2.4.19/net/socket.c	Fri Aug  2 18:39:46 2002
+++ linux-2.4.19-magnet/net/socket.c	Fri Nov  8 07:43:15 2002
@@ -85,6 +85,10 @@
 #include <net/scm.h>
 #include <linux/netfilter.h>
 
+#ifdef CONFIG_MAGNET_SOCK
+#include <linux/magnet.h>
+#endif /* CONFIG_MAGNET_SOCK */
+
 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
 static ssize_t sock_read(struct file *file, char *buf,
 			 size_t size, loff_t *ppos);
@@ -484,6 +488,10 @@
  
 void sock_release(struct socket *sock)
 {
+#ifdef CONFIG_MAGNET_SOCK
+	MAGNET_ADD(MAGNET_SOCK_CLOSE, (unsigned int) sock->sk, 0, MAGNET_NO_DATA);
+#endif /* CONFIG_MAGNET_SOCK */
+
 	if (sock->ops) 
 		sock->ops->release(sock);
 
@@ -505,6 +513,9 @@
 
 	err = scm_send(sock, msg, &scm);
 	if (err >= 0) {
+#ifdef CONFIG_MAGNET_SOCK
+    MAGNET_ADD(MAGNET_SOCK_SEND, (unsigned int) sock->sk, size, MAGNET_NO_DATA);
+#endif /* CONFIG_MAGNET_SOCK */
 		err = sock->ops->sendmsg(sock, msg, size, &scm);
 		scm_destroy(&scm);
 	}
@@ -520,6 +531,9 @@
 	size = sock->ops->recvmsg(sock, msg, size, flags, &scm);
 	if (size >= 0)
 		scm_recv(sock, msg, &scm, flags);
+#ifdef CONFIG_MAGNET_SOCK
+  MAGNET_ADD(MAGNET_SOCK_RECV, (unsigned int) sock->sk, size, MAGNET_NO_DATA);
+#endif /* CONFIG_MAGNET_SOCK */
 
 	return size;
 }
@@ -910,6 +924,17 @@
 	if (retval < 0)
 		goto out_release;
 
+#ifdef CONFIG_MAGNET_SOCK
+	{
+		struct magnet_sock  data;
+		data.domain = family;
+		data.protocol = protocol;
+		MAGNET_ADD(MAGNET_SOCK_OPEN, (unsigned int) sock->sk, 
+				magnet_mksockparm(current->pid, retval, type), 
+				MAGNET_SOCK_DATA(&data));
+	}
+#endif /* CONFIG_MAGNET_SOCK */
+ 
 out:
 	/* It may be already another descriptor 8) Not kernel problem. */
 	return retval;
@@ -1078,6 +1103,17 @@
 	if ((err = sock_map_fd(newsock)) < 0)
 		goto out_release;
 
+#ifdef CONFIG_MAGNET_SOCK
+	{
+		struct magnet_sock  data;
+		data.domain = sock->sk->family;
+		data.protocol = sock->sk->protocol;
+		MAGNET_ADD(MAGNET_SOCK_OPEN, (unsigned int) newsock->sk, 
+				magnet_mksockparm(current->pid, err, newsock->type), 
+				MAGNET_SOCK_DATA(&data));
+	}
+#endif /* CONFIG_MAGNET_SOCK */
+ 
 out_put:
 	sockfd_put(sock);
 out: