Azinix

pktTfc.c File Reference

Routines for creating packets. More...

#include "pkt.h"

Go to the source code of this file.

Functions

util_byte_array_tPkt_CreateIcmpPkt (array_t *typeArray, array_t *codeArray, array_t *idArray, array_t *seqArray)
 Create an ICMP packet.
util_byte_array_tPkt_CreateUdpPkt (array_t *srcPorts, array_t *destPorts, array_t *sizes, array_t *byteStrings)
 Create a UDP packet.
util_byte_array_tPkt_CreateTcpPkt (array_t *srcPorts, array_t *destPorts, array_t *seqNums, array_t *ackNums, st_table *flags, array_t *sizes, array_t *byteStrings)
 Create a TCP packet.
util_byte_array_tPkt_CreateIpPkt (array_t *srcIps, array_t *destIps, st_table *ipFlagsTable, array_t *offsets, array_t *ids, st_table *ipOptions, array_t *ttls, util_byte_array_t *l4Payload, int l4Protocol)
 Create a IP packet.
Pkt_EthernetHdr_tPkt_CreateEthPkt (char *srcMac, char *destMac, util_byte_array_t *l3Payload, u_int16_t l3Protocol)
 Create Ethernet packet with given params.
Pkt_EthernetHdr_tPkt_CreateRandEthPkt (array_t *tmpArray)
 Create a random ethernet packet.
array_tPkt_SeedRandEthPktArray (Pkt_ByteOrder_t byteOrder, int numSeeds, Pkt_TfcMode_t *tfcMode)
 Create a random ethernet packet; only tcp for now.
void Pkt_HTON (Pkt_EthernetHdr_t *anEth)
 Take an ethernet packet and convert it to network order.
void Pkt_NTOH (Pkt_EthernetHdr_t *anEth)
 Take an ethernet packet and convert it to host order.


Detailed Description

Routines for creating packets.

Definition in file pktTfc.c.


Function Documentation

Pkt_EthernetHdr_t* Pkt_CreateEthPkt ( char *  srcMac,
char *  destMac,
util_byte_array_t l3Payload,
u_int16_t  l3Protocol 
)

Create Ethernet packet with given params.

Definition at line 604 of file pktTfc.c.

util_byte_array_t* Pkt_CreateIcmpPkt ( array_t typeArray,
array_t codeArray,
array_t idArray,
array_t seqArray 
)

Create an ICMP packet.

See also:
Pkt_CreateTcpPkt

Definition at line 44 of file pktTfc.c.

util_byte_array_t* Pkt_CreateIpPkt ( array_t srcIps,
array_t destIps,
st_table ipFlagsTable,
array_t offsets,
array_t ids,
st_table ipOptions,
array_t ttls,
util_byte_array_t l4Payload,
int  l4Protocol 
)

Create a IP packet.

User defines the "interesting" source and dest IP addresses. If any of these arrays are empty, we take the corresponding field to be unconstrained.

Payload is constructed by calling function, which is responsible for freeing it.

Definition at line 476 of file pktTfc.c.

Pkt_EthernetHdr_t* Pkt_CreateRandEthPkt ( array_t tmpArray  ) 

Create a random ethernet packet.

For other systems, use Pkt_NetworkByteOrder_c for packet For narya, use Pkt_HostByteOrder_c for packet

numSeeds is the number of packets that the routine uses for seeding the array.

Definition at line 739 of file pktTfc.c.

util_byte_array_t* Pkt_CreateTcpPkt ( array_t srcPorts,
array_t destPorts,
array_t seqNums,
array_t ackNums,
st_table flags,
array_t sizes,
array_t byteStrings 
)

Create a TCP packet.

User defines the "interesting" source and dest ports, seq numbers, ack numbers, sizes, and byteStrings to be inserted in the packet. If any of these arrays are empty, we take the corresponding field to be un-constrained. Otherwise, the field takes a value with equal likelihood from the correp array. (The array can be of length 1, which is useful for directed testing.)

User also define flags to be set by a st_table containing strings "fin", "syn", "rst", "psh", "ack", "urg", "ece", "cwr" - default is set with prob 0.5. If the st_table is NIL, flags are set at random.

Since there is no length field in the tcp header, we return a util_byte_array_t *, with the bytes entry being the actual packet, and the length entry being the length of the packet.

Definition at line 242 of file pktTfc.c.

util_byte_array_t* Pkt_CreateUdpPkt ( array_t srcPorts,
array_t destPorts,
array_t sizes,
array_t byteStrings 
)

Create a UDP packet.

User defines the "interesting" source and dest ports, and byteStrings to be inserted in the packet.

See also:
Pkt_CreateTcpPkt

Definition at line 126 of file pktTfc.c.

void Pkt_HTON ( Pkt_EthernetHdr_t anEth  ) 

Take an ethernet packet and convert it to network order.

Definition at line 859 of file pktTfc.c.

void Pkt_NTOH ( Pkt_EthernetHdr_t anEth  ) 

Take an ethernet packet and convert it to host order.

Definition at line 918 of file pktTfc.c.

array_t* Pkt_SeedRandEthPktArray ( Pkt_ByteOrder_t  byteOrder,
int  numSeeds,
Pkt_TfcMode_t tfcMode 
)

Create a random ethernet packet; only tcp for now.

Definition at line 754 of file pktTfc.c.