Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

rubicon_ethernet.c File Reference

Ethernet protocol decoder. More...

#include "../../main/protoplug.h"
#include "../../main/types.h"
#include "../../main/policy.h"
#include "../../main/memory.h"

Go to the source code of this file.

Defines

#define DEBUG_ETHERNET   0

Functions

int pluginRegister (INPLUG **inp, ANPLUG **anp, PROTOPLUG **protop, OUTPLUG **outp, int(*DecodeCallback)(PACKET*,PROTO))
 Registration function. More...

int pluginInit (int ct, char **inits)
 Initialise the plugin. More...

int pluginCleanup (int reason)
 Cleanup the plugin. More...

int pluginDecode (PACKET *p, PROTO protocol)
 Decodes the packet for this protocol. More...

int pluginTest (PACKET *p, char *arg, char *val)
 Performs a 'test' on the data. More...

int pluginPrint (PACKET *p, char *args, int(*print)(char *fmt, ...))
 Prints a specific field. More...

int pluginMkTest (PROTO p, char *val, char *test, char *field, POLICY_TEST *pTest)
 Translates a string description of a field and value to test into a policy test. More...


Variables

PROTOPLUGpp = (PROTOPLUG*)0


Detailed Description

Ethernet protocol decoder.

Definition in file rubicon_ethernet.c.


Define Documentation

#define DEBUG_ETHERNET   0
 

Definition at line 17 of file rubicon_ethernet.c.


Function Documentation

int pluginCleanup ( int reason )
 

Cleanup the plugin.

Parameters:
reason   (int) The reason for the cleanup.

This call should always be made before closing the program, or reinitialising the plugin. It frees all the memory allocated and still held internally (i.e. it doesn't free memory that it has a pointer to but has passed elsewhere). Additionally, files are closed etc.

Definition at line 102 of file rubicon_ethernet.c.

int pluginDecode ( PACKET * p,
PROTO protocol )
 

Decodes the packet for this protocol.

Parameters:
p   (PACKET*) The packet to decode
protocol   (PROTO) The protocol to decode

The plugin attempts to detect whether this protocol is the next undecoded protocol in the packet. If it is, then it is decoded (i.e. pointers to the header, footer and payload are given), and the protocol descriptor is appended to the packet. If the protocol isn't the next, then the decode callback function will be used to attempt to decode until it is found, or no more can be decoded.

Definition at line 126 of file rubicon_ethernet.c.

int pluginInit ( int ct,
char ** inits )
 

Initialise the plugin.

Parameters:
ct   (int) Number of initialisation strings
inits   (char **) Array of ct initialisation strings

Definition at line 85 of file rubicon_ethernet.c.

int pluginMkTest ( PROTO p,
char * val,
char * test,
char * field,
POLICY_TEST * pTest )
 

Translates a string description of a field and value to test into a policy test.

Parameters:
p   (PROTO) Protocol
val   (char*) Value
test   (char*) Test type
field   (char*) Field
pTest   (POLICY_TEST*) The policy test to populate

This function allows the plugin to describe in policy form the test to perform for the specified string test. The pTest function is to be populated (and so must not be NULL) and it is then inserted into the policy.

Definition at line 190 of file rubicon_ethernet.c.

int pluginPrint ( PACKET * p,
char * args,
int(* print)(char *fmt,...) )
 

Prints a specific field.

Parameters:
p   (PACKET*) The packet to test
args   (char*) The test to perform
print   (function pointer) The function to call to print out to

This function prints the field specified by args of packet p. It does this using the 'print' function. This is to allow the same function to be able to print to a growable buffer in memory, a pipe, stream, or file. The print function should be used as printf would be used - indeed most of the time this will essentially be a wrapper around vfprintf or vsprintf. This allows the protocol plugin to decide _how_ it prints the field, for example an IP address can be printed in dotted form instead of just a long.

Definition at line 167 of file rubicon_ethernet.c.

int pluginRegister ( INPLUG ** inp,
ANPLUG ** anp,
PROTOPLUG ** protop,
OUTPLUG ** outp,
int(* DecodeCallback)(PACKET *,PROTO) )
 

Registration function.

Parameters:
inp   (INPLUG**) Placeholder for input plugin descriptor
anp   (ANPLUG**) Placeholder for analysis plugin descriptor
protop   (PROTOPLUG**) Placeholder for protocol plugin descriptor
outp   (OUTPLUG**) Placeholder for output plugin descriptor
DecodeCallback   (function ptr) Pointer to generic decode function

This function is called by the main process in order to register the plugin. The function then populates the placeholders for the plugin types it supports, and sets all others to null. The DecodeCallback function is stored in case the plugin ever wants to decode anything.

Definition at line 40 of file rubicon_ethernet.c.

int pluginTest ( PACKET * p,
char * arg,
char * val )
 

Performs a 'test' on the data.

Parameters:
p   (PACKET*) The packet to test
arg   (char*) The test to perform
val   (char*) The value to check for

This function is used to perform 'special' tests which cannot be performed by just comparing a header to a value. This is esepcially common in the higher layer protocols. It is also used for optional header fields and to check for special conditions such as valid or invalid checksums.

Definition at line 145 of file rubicon_ethernet.c.


Variable Documentation

PROTOPLUG * pp = (PROTOPLUG*)0
 

Definition at line 24 of file rubicon_udp.c.


Generated at Mon Jul 8 15:16:50 2002 for RUBICON by doxygen1.2.1 written by Dimitri van Heesch, © 1997-2000