![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
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.
net/ethernet.h
- Committer:
- etherealflaim
- Date:
- 2010-10-12
- Revision:
- 3:c32d9660b888
- Parent:
- 2:e8e09adc41fc
- Child:
- 6:66c4cd9073aa
File content as of revision 3:c32d9660b888:
#ifndef ETHERNET_H #define ETHERNET_H #include "net.h" /// \file Ethernet frames /// Ethernet MAC address memory map typedef struct { unsigned char octet[6]; ///< Individual octsts of the MAC address } Ethernet_MAC; /// Ethernet II Frame Header Memory map typedef struct { /// Destination MAC address (6 octets) Ethernet_MAC destination; /// Source MAC address (6 octets) Ethernet_MAC source; // (optional) VLAN Tag (unsupported) /// Ethernet type or length (only <0x600 or 0x0800 IPv4 supported) u16 ethertype; /// Payload (used for memory mapping; has zero size) unsigned char payload[]; } Ethernet_FrameHeader; /// Convert from wire to host or host to wire endian-ness inline void fix_endian_ethernet(Ethernet_FrameHeader *header) { fix_endian_u16(&header->ethertype); } /// Print out an ethernet packet inline void print_ethernet(Ethernet_FrameHeader *frame) { main_log.printf("Ethernet frame:"); u8 *src = frame->source.octet; u8 *dst = frame->destination.octet; main_log.printf(" Source: MAC - %02X:%02X:%02X:%02X:%02X:%02X", src[6], src[7], src[8], src[9], src[10], src[11]); main_log.printf(" Dest: MAC - %02X:%02X:%02X:%02X:%02X:%02X", dst[0], dst[1], dst[2], dst[3], dst[4], dst[5]); main_log.printf(" Ethertype: 0x%04X", frame->ethertype); } #endif