This is a low-level network debugging utility that utilizes raw packet i/o to construct and deconstruct tcp, udp, ipv4, arp, and icmp packets over ethernet.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Sniffer Class Reference

Sniffer Class Reference

Demo - Ethernet Packet Sniffer. More...

#include <sniffer.h>

Public Member Functions

 Sniffer ()
 Constructor.
bool inject (void *data, unsigned int bytes)
 Inject the raw ethernet frame.
bool inject (Ethernet_MAC dest, u16 ethertype, void *packet, unsigned int bytes)
 Inject the raw payload into an ethernet frame with the given destination and ethertype.
void wait_for_data ()
 Wait until there is more data to receive.
void next ()
 Wait for an ethernet frame (will be stored in appropriate class member pointers)
void decode_ethernet (void *frame)
 Decode the given ethernet frame.
void decode_arp (ARP_Packet *packet)
 Decode the given ARP packet.
void decode_ip (IP_PacketHeader *packet)
 Decode the given IPv4 packet.
template<class T >
void attach_tcp (T *inst, void(T::*func)(TCP_SegmentHeader *tcp_packet, u32 data_bytes))
 Attach a member function to be called on all TCP packets.
void attach_tcp (void(*func)(TCP_SegmentHeader *tcp_packet, u32 data_bytes))
 Attach a non-member function to be called on all TCP packets.

Data Fields

Ethernet_FrameHeaderframe_header
 Ethernet Frame Header (incoming)
IP_PacketHeaderip_packet
 IP Packet Header (incoming)
ARP_Packetarp_packet
 ARP Packet (incoming)
TCP_SegmentHeadertcp_packet
 TCP Packet (incoming)
UDP_Packetudp_packet
 UDP Packet (incoming)
ICMP_Packeticmp_packet
 ICMP Packet (incoming)
unsigned int data_bytes
 Generic - total data bytes.

Detailed Description

Demo - Ethernet Packet Sniffer.

Definition at line 53 of file sniffer.h.


Constructor & Destructor Documentation

Sniffer (  )

Constructor.

Definition at line 98 of file sniffer.h.


Member Function Documentation

void attach_tcp ( T *  inst,
void(T::*)(TCP_SegmentHeader *tcp_packet, u32 data_bytes func 
)

Attach a member function to be called on all TCP packets.

Definition at line 257 of file sniffer.h.

void attach_tcp ( void(*)(TCP_SegmentHeader *tcp_packet, u32 data_bytes func )

Attach a non-member function to be called on all TCP packets.

Definition at line 263 of file sniffer.h.

void decode_arp ( ARP_Packet packet )

Decode the given ARP packet.

Definition at line 209 of file sniffer.h.

void decode_ethernet ( void *  frame )

Decode the given ethernet frame.

Definition at line 189 of file sniffer.h.

void decode_ip ( IP_PacketHeader packet )

Decode the given IPv4 packet.

Definition at line 217 of file sniffer.h.

bool inject ( Ethernet_MAC  dest,
u16  ethertype,
void *  packet,
unsigned int  bytes 
)

Inject the raw payload into an ethernet frame with the given destination and ethertype.

Definition at line 118 of file sniffer.h.

bool inject ( void *  data,
unsigned int  bytes 
)

Inject the raw ethernet frame.

Definition at line 106 of file sniffer.h.

void next (  )

Wait for an ethernet frame (will be stored in appropriate class member pointers)

Definition at line 173 of file sniffer.h.

void wait_for_data (  )

Wait until there is more data to receive.

Definition at line 154 of file sniffer.h.


Field Documentation

ARP Packet (incoming)

Definition at line 82 of file sniffer.h.

unsigned int data_bytes

Generic - total data bytes.

Definition at line 94 of file sniffer.h.

Ethernet Frame Header (incoming)

Definition at line 76 of file sniffer.h.

ICMP Packet (incoming)

Definition at line 91 of file sniffer.h.

IP Packet Header (incoming)

Definition at line 79 of file sniffer.h.

TCP Packet (incoming)

Definition at line 85 of file sniffer.h.

UDP Packet (incoming)

Definition at line 88 of file sniffer.h.