#include "pkt.h"
Go to the source code of this file.
Functions | |
| int | Pkt_EthPacketWriteToFile (int fd, Pkt_EthernetHdr_t *anEthPkt, unsigned int length) |
| Write an ethernet frame to file. File is assumed to be open and writable. Format: length followed by sequence of bytes. | |
| int | Pkt_EthPacketReadFromFile (int fd, Pkt_EthernetHdr_t **anEthPktPtr) |
| Read an Ethernet frame from a file Returns NIL if the file is empty, and otherwise a pointer to the frame. Caller is responsible for freeing the memory allocated for the frame. | |
| array_t * | Pkt_CreatePktsFromString (char *pktFile) |
| Create a packets from a textual description. | |
| Pkt_EthernetHdr_t * | Pkt_CreatePktFromString (char *pktString) |
| Create single packet from string. | |
Definition in file pktFile.c.
| Pkt_EthernetHdr_t* Pkt_CreatePktFromString | ( | char * | pktString | ) |
| array_t* Pkt_CreatePktsFromString | ( | char * | pktFile | ) |
Create a packets from a textual description.
protocol: ip, udp, tcp, icmp offset is from 0 to 2^13 - 1 ttl is from 0 to 255 ipflag:RB,DF,MF (one of) tcpflag:fin,syn,rst,psh,ack,urg,ece,cwr (one of) ipoptions:EOOL,NOP,SEC,LSR,TS,E-SEC,CIPSO,RR,SID,SSR,ZSU, MTUP,MTUR,FINN,VISA,ENCODE,IMITD,EIP,TR,ADDEXT,RTRALT,SDB,NSAPA,DPS,UMP size is size of ENTIRE packet, including header (but not ethernet part) content:"foo" --- use escapes, etc. appropriately
Ex. srcip:192.168.1.1; destip:1.2.3.4; ipflags:MF; ipoptions:EOOL; offset:1234; id:100; ttl:255; protocol:tcp; srcport:80; destport:80; seq:100; ack:100; tcpflag:fin; size:100; content:"foo";
| int Pkt_EthPacketReadFromFile | ( | int | fd, | |
| Pkt_EthernetHdr_t ** | anEthPktPtr | |||
| ) |
| int Pkt_EthPacketWriteToFile | ( | int | fd, | |
| Pkt_EthernetHdr_t * | anEthPkt, | |||
| unsigned int | length | |||
| ) |
Write an ethernet frame to file. File is assumed to be open and writable. Format: length followed by sequence of bytes.
If we used fprintf, we would need both the FILE * fp AND the int fd as there's no simple way to go from one to the other. (We don't wan't to pass in the file name as the we'd have to keep opening and closing the file.)
The alternative is to write the length using write itself, but then we need to worry about the byte order. (Or perhaps not, as we can just read back without worrying about the order, its the same in both cases.