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

Files at this revision

API Documentation at this revision

Comitter:
etherealflaim
Date:
Tue Oct 12 06:21:05 2010 +0000
Parent:
3:c32d9660b888
Child:
5:c56386b9fc33
Commit message:
More documentation updates

Changed in this revision

net/udp.h Show annotated file Show diff for this revision Revisions of this file
scanner.h Show annotated file Show diff for this revision Revisions of this file
sniffer.h Show annotated file Show diff for this revision Revisions of this file
util/log.h Show annotated file Show diff for this revision Revisions of this file
util/types.h Show annotated file Show diff for this revision Revisions of this file
util/util.h Show annotated file Show diff for this revision Revisions of this file
--- a/net/udp.h	Tue Oct 12 06:14:19 2010 +0000
+++ b/net/udp.h	Tue Oct 12 06:21:05 2010 +0000
@@ -9,11 +9,11 @@
 
 /// UDP Packet memory map
 typedef struct {
-  u16 source_port;
-  u16 destination_port;
-  u16 length; // entire datagram in bytes
-  u16 checksum;
-  u8 data[];
+  u16 source_port;       ///< Source port (1-65535)
+  u16 destination_port;  ///< Destination port (1-65535) 
+  u16 length;            ///< Entire datagram size in bytes
+  u16 checksum;          ///< Checksum
+  u8 data[];             ///< Data memory map
 } UDP_Packet;
 
 /// Convert from wire to host or host to wire endianness
--- a/scanner.h	Tue Oct 12 06:14:19 2010 +0000
+++ b/scanner.h	Tue Oct 12 06:21:05 2010 +0000
@@ -12,6 +12,7 @@
 #define SCANNER_PADSIZE   0
 #define SCANNER_FRAMESIZE (sizeof(Ethernet_FrameHeader) + sizeof(IP_PacketHeader) + sizeof(TCP_SegmentHeader) + SCANNER_PADSIZE)
 
+/// Demo - TCP Port Scanner
 class Scanner
 {
 private:
--- a/sniffer.h	Tue Oct 12 06:14:19 2010 +0000
+++ b/sniffer.h	Tue Oct 12 06:21:05 2010 +0000
@@ -41,7 +41,7 @@
   virtual inline Result operator() (Arg1 x, Arg2 y) const { return (inst->*pfunc)(x,y); }
 };
 
-
+/// Demo - Ethernet Packet Sniffer
 class Sniffer {
 public:
   Ethernet_MAC mac;
--- a/util/log.h	Tue Oct 12 06:14:19 2010 +0000
+++ b/util/log.h	Tue Oct 12 06:21:05 2010 +0000
@@ -8,8 +8,7 @@
 
 #define LOG_BUFSIZE 4096
 
-
-
+/// Enumeration used to enable/disable various serial lines in the logger
 typedef enum {
   LOG_USB = 0,
   LOG_SER_9_10,
@@ -18,6 +17,7 @@
   LOG_MAX
 } SerialLines;
 
+/// Combination serial/file logger
 class Log {
 private:
   // Accomodate all 3 serial ports and USB
@@ -28,6 +28,7 @@
   LocalFileSystem local;
 
 public:
+  /// Constructor
   inline Log() : local("local")
   {
     // Write to file
@@ -48,20 +49,20 @@
     }
   }
 
-  // Enable logging to the given serial line
+  /// Enable logging to the given serial line
   inline void enable(SerialLines idx)
   {
     m_enable[idx] = true;
   }
   
-  // Disable logging to the given serial line
+  /// Disable logging to the given serial line
   inline void disable(SerialLines idx)
   {
     m_enable[idx] = false;
   }
   
-  // This can log messages up to 4095 characters and has printf semantics
-  // All log messages include an implicit \r\n at the end
+  /// This can log messages up to 4095 characters and has printf semantics
+  /// All log messages include an implicit \r\n at the end
   inline bool printf(char *format, ...)
   {
     static char buffer[LOG_BUFSIZE];
@@ -88,6 +89,7 @@
     return true;
   } // printf
   
+  /// Put the given string (no implicit \r\n) on all enabled serial lines and to the logfile
   bool puts(const char *str)
   {
     // Write to file
--- a/util/types.h	Tue Oct 12 06:14:19 2010 +0000
+++ b/util/types.h	Tue Oct 12 06:21:05 2010 +0000
@@ -1,8 +1,13 @@
 #ifndef TYPES_H
 #define TYPES_H
 
+/// Unsigned 8 bit value
 typedef unsigned char u8;
+
+/// Unsigned 16 bit value
 typedef unsigned short u16;
+
+/// Unsigned 32 bit value
 typedef unsigned int u32;
 
 #endif
\ No newline at end of file
--- a/util/util.h	Tue Oct 12 06:14:19 2010 +0000
+++ b/util/util.h	Tue Oct 12 06:21:05 2010 +0000
@@ -4,18 +4,21 @@
 #include "types.h"
 #include "log.h"
 
+/// Is any byte memory at start for bytes nonzero?
 inline bool is_nonzero_mem(u8 *start, unsigned int bytes)
 {
   for (; bytes--; ++start) if (*start) return true;
   return false;
 }
 
+/// Are all bytes at start for bytes zero?
 inline bool is_zero_mem(u8 *start, unsigned int bytes)
 {
   for (; bytes--; ++start) if (*start) return false;
   return true;
 }
 
+/// Are the memory locations at and and b equal for bytes?
 inline bool is_equal_mem(u8 *a, u8 *b, unsigned int bytes)
 {
   for (; bytes--; ++a, ++b) if (*a != *b) return false;