public class Format
extends java.lang.Object
Format f = new Format("/path/to/file"); f.setFilterProperties(fmtprop); // Sets the filtering properties for this format f.formatProlog(); // Format the prolog Prolog pro = f.getProlog(); System.out.println(pro.toString()); if(!pro.invalidData()) { // The is not a valid trace Frame rec; while((rec=f.getNextRecord())!=null) { // Get the records System.out.print(rec.getRecNum()); // Print out the Frame Number System.out.println(rec.getTime()); // Print out the time IPPacket p = rec.getPacket(); // Get this records packet Header h = p.getHeader(); // Get the first header if(p.getType()==IPPacket.IP6) { // If IP6 IPPacket if(h.getType()==Header.IP6) { // If IP6 Header IP6Header ip6 = (IP6Header) h; // Cast to IP6 so we can access methods System.out.println(h.getName()); // Print the name System.out.println("IP6 src:"+ip6.getSrcAddr() + " dst:" + ip6.getDstAddr()); System.out.println(ip6.printHexHeader()); // Print the header as hex // Print a string representation of the header. System.out.println(ip6.toString(prop)); while((h=h.getNextHeader())!=null) { // Get the rest of the headers if(h.getType()==Header.TCP) { // If its a TCP header TCPHeader tcp = (TCPHeader) h; // Cast so we can access methods System.out.println("TCP src:" + tcp.getSrcPort() + " dst:" + tcp.getDstPort()); System.out.println(tcp.toString(prop)); } else if(h.getType()==Header.UDP) { // If its a UDP header UDPHeader udp = (UDPHeader) h; // Cast so we can access methods System.out.println("UDP src:" + udp.getSrcPort() + " dst:" + udp.getDstPort()); System.out.println(udp.toString(prop)); } } } } } }Format can be run as a program as follows:
Options:java com.ibm.as400.commtrace.Format [ options ]
Constructor and Description |
---|
Format()
Default constructor.
|
Format(AS400 sys)
Creates a new Format.
|
Format(FormatProperties prop,
java.lang.String outfile,
java.lang.String infile)
Constructs a new
Format object. |
Format(IFSFileInputStream file)
Creates a Format object on the given IFSFileInputStream.
|
Format(java.lang.String filename)
Creates a Format object on the given local file.
|
Format(java.lang.String[] args)
Creates a Format object on the given binary trace.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
addBanner()
Return a String containing the banner.
|
int |
close()
Closes this format object.
|
boolean |
formatProlog()
Formats the prolog.
|
int |
getIntFromFile()
Reads in an int from the input stream.
|
Frame |
getNextRecord()
Retrieves the next record from the given trace.
|
int |
getNumberOfTCPRecords()
Returns the number of tcp records in this trace.
|
Prolog |
getProlog()
Returns the prolog of this trace.
|
java.lang.String |
getRecFromFile()
Reads a Frame from the input stream.
|
int |
getRecsProcessed()
Returns the number of records that have been formatted.
|
static void |
main(java.lang.String[] args)
Called by the JVM to Format a file.
|
int |
openIFSFile()
Opens an ObjectInputStream and IFSFileInputStream on the file specified earlier.
|
int |
openIFSFile(java.lang.String outfile)
Opens an ObjectInputStream and IFSFileInputStream on the outfile.
|
int |
openLclFile()
Opens an ObjectInputStream and FileInputStream on the file specified on the command line.
|
int |
openLclFile(java.lang.String outfile)
Opens an ObjectInputStream and FileInputStream on the outfile.
|
void |
setFilterProperties(FormatProperties prop)
Sets the Properties for this Format.
|
void |
setInFileStream(java.io.InputStream infile)
Sets the input stream to read the data from.
|
void |
setOutFile(java.lang.String outfile)
Sets the output file to open a OutputStream on.
|
void |
setSystem(AS400 system)
Sets the system to use for all IBM i connections.
|
int |
toIFSBinFile()
Format the trace and write the results to a binary IFS file on the system
we are connected to.
|
int |
toIFSTxtFile()
Formats the trace and sends the output to an IFS text file on the system we are bound to.
|
int |
toLclBinFile()
Format the trace and write the results to a binary file on the local PC.
|
int |
toLclTxtFile()
Formats the trace and sends the output to an IFS text file on the system we are bound to.
|
public Format()
public Format(AS400 sys)
sys
- The system that this object should connect to.public Format(FormatProperties prop, java.lang.String outfile, java.lang.String infile)
Format
object.prop
- The FormatProperties object to filter by.outfile
- The file to write the formatted trace data to.infile
- The name of the file to read from.public Format(java.lang.String[] args)
args
- The command line arguments to be used to format the file.public Format(java.lang.String filename)
filename
- The file to format.public Format(IFSFileInputStream file)
file
- The input stream to read the data off of.public void setFilterProperties(FormatProperties prop)
prop
- Properties for this Format.public void setOutFile(java.lang.String outfile)
outfile
- The file to open a OutputStream on.public void setInFileStream(java.io.InputStream infile)
infile
- The open InputStream to read from.public void setSystem(AS400 system)
system
- The system to connect to.public int toIFSTxtFile()
public int toLclTxtFile()
public int toIFSBinFile()
public int toLclBinFile()
public int openIFSFile()
public int openIFSFile(java.lang.String outfile)
outfile
- public int openLclFile()
public int openLclFile(java.lang.String outfile)
outfile
- The file to read in.public int close()
public java.lang.String getRecFromFile()
public int getIntFromFile()
public boolean formatProlog()
public Frame getNextRecord()
public java.lang.String addBanner()
public int getRecsProcessed()
public Prolog getProlog()
public int getNumberOfTCPRecords()
public static void main(java.lang.String[] args)
args
- The arguments from the command line.