SSF.OS.OSPFv2.test
Class OSPFMonitor

java.lang.Object
  |
  +--SSF.OS.OSPFv2.test.OSPFMonitor
All Implemented Interfaces:
SSF.OS.ProtocolMonitor

public class OSPFMonitor
extends java.lang.Object
implements SSF.OS.ProtocolMonitor

Implements a tcpDump utility for OSPF protocol traffic. Some of the code for writing binary tcpdump files is "stolen" from SSF.OS.binaryTcpDump. The monitor is used from an IP session, so it also gets all non-OSPF packets. For simplicity, these are simply ignored.


Field Summary
private  java.lang.String fileName
          Name of the binary tcpdump file
private  SSF.OS.ProtocolSession ipSession
          Pointer to the IP session
private  java.io.FileOutputStream outstream
          File to write the tcpdump to.
private  byte[] rbuf
           
private  int rct
           
 
Constructor Summary
OSPFMonitor()
          Constructor.
 
Method Summary
 void config(SSF.OS.ProtocolSession ownerProtocol, com.renesys.raceway.DML.Configuration cfg)
          configure the Monitor ProtocolSession[ name ip use SSF.OS.IP monitor[ use SSF.OS.OSPFv2.test.OSPFMonitor file ] ]
private  void dump_ospf_lsa(SSF.OS.OSPFv2.LSA lsa)
          Dumps a single OSPF LSA
private  void dump_ospf_packet(SSF.OS.OSPFv2.Packet ospfHdr)
          Dumps an OSPF packet
private  void dump(SSF.OS.PacketEvent pe)
          Dump a single packet event
private  byte getOspfOptions(boolean[] opts)
          Creates an OSPF options byte from a bool array
 void init()
          Initialize the monitor.
private  void raw_commit()
          Write buffered bytes to the printstream
private  void raw(int len, long val)
          Write 1, 2, or 4 bytes to buffer in network byte order
private  void rawh(int len, long val)
          Write 1, 2, or 4 bytes to buffer in host order
private  void rawPacket(SSF.OS.PacketEvent pkt, long atTime)
          Write raw packet bytes to the output stream.
 void receive(SSF.OS.ProtocolMessage packet, SSF.OS.ProtocolSession fromSession, SSF.OS.ProtocolSession toSession)
          peek at every IP packet push()ed into IP
private  void write_raw_file_header()
          Write the generic file header for TCP binary dump files
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

outstream

private java.io.FileOutputStream outstream
File to write the tcpdump to.

ipSession

private SSF.OS.ProtocolSession ipSession
Pointer to the IP session

fileName

private java.lang.String fileName
Name of the binary tcpdump file

rbuf

private byte[] rbuf

rct

private int rct
Constructor Detail

OSPFMonitor

public OSPFMonitor()
Constructor.
Method Detail

config

public void config(SSF.OS.ProtocolSession ownerProtocol,
                   com.renesys.raceway.DML.Configuration cfg)
            throws com.renesys.raceway.DML.configException
configure the Monitor
 ProtocolSession[ name ip use SSF.OS.IP
         monitor[ use SSF.OS.OSPFv2.test.OSPFMonitor
             file 
         ]
 ]
 
Specified by:
config in interface SSF.OS.ProtocolMonitor

init

public void init()
Initialize the monitor. This creates the file for the tcpdump.
Specified by:
init in interface SSF.OS.ProtocolMonitor

receive

public void receive(SSF.OS.ProtocolMessage packet,
                    SSF.OS.ProtocolSession fromSession,
                    SSF.OS.ProtocolSession toSession)
peek at every IP packet push()ed into IP
Specified by:
receive in interface SSF.OS.ProtocolMonitor

dump

private void dump(SSF.OS.PacketEvent pe)
Dump a single packet event

rawPacket

private void rawPacket(SSF.OS.PacketEvent pkt,
                       long atTime)
Write raw packet bytes to the output stream.

dump_ospf_packet

private void dump_ospf_packet(SSF.OS.OSPFv2.Packet ospfHdr)
Dumps an OSPF packet

dump_ospf_lsa

private void dump_ospf_lsa(SSF.OS.OSPFv2.LSA lsa)
Dumps a single OSPF LSA

getOspfOptions

private byte getOspfOptions(boolean[] opts)
Creates an OSPF options byte from a bool array

raw

private void raw(int len,
                 long val)
Write 1, 2, or 4 bytes to buffer in network byte order

rawh

private void rawh(int len,
                  long val)
Write 1, 2, or 4 bytes to buffer in host order

raw_commit

private void raw_commit()
Write buffered bytes to the printstream

write_raw_file_header

private void write_raw_file_header()
Write the generic file header for TCP binary dump files