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.
util/util.h@0:d494b853ce97, 2010-10-12 (annotated)
- Committer:
- etherealflaim
- Date:
- Tue Oct 12 05:32:59 2010 +0000
- Revision:
- 0:d494b853ce97
- Child:
- 4:88fc7fa58931
Initial Publish - Slightly unfinished, but usable
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
etherealflaim | 0:d494b853ce97 | 1 | #ifndef UTIL_H |
etherealflaim | 0:d494b853ce97 | 2 | #define UTIL_H |
etherealflaim | 0:d494b853ce97 | 3 | |
etherealflaim | 0:d494b853ce97 | 4 | #include "types.h" |
etherealflaim | 0:d494b853ce97 | 5 | #include "log.h" |
etherealflaim | 0:d494b853ce97 | 6 | |
etherealflaim | 0:d494b853ce97 | 7 | inline bool is_nonzero_mem(u8 *start, unsigned int bytes) |
etherealflaim | 0:d494b853ce97 | 8 | { |
etherealflaim | 0:d494b853ce97 | 9 | for (; bytes--; ++start) if (*start) return true; |
etherealflaim | 0:d494b853ce97 | 10 | return false; |
etherealflaim | 0:d494b853ce97 | 11 | } |
etherealflaim | 0:d494b853ce97 | 12 | |
etherealflaim | 0:d494b853ce97 | 13 | inline bool is_zero_mem(u8 *start, unsigned int bytes) |
etherealflaim | 0:d494b853ce97 | 14 | { |
etherealflaim | 0:d494b853ce97 | 15 | for (; bytes--; ++start) if (*start) return false; |
etherealflaim | 0:d494b853ce97 | 16 | return true; |
etherealflaim | 0:d494b853ce97 | 17 | } |
etherealflaim | 0:d494b853ce97 | 18 | |
etherealflaim | 0:d494b853ce97 | 19 | inline bool is_equal_mem(u8 *a, u8 *b, unsigned int bytes) |
etherealflaim | 0:d494b853ce97 | 20 | { |
etherealflaim | 0:d494b853ce97 | 21 | for (; bytes--; ++a, ++b) if (*a != *b) return false; |
etherealflaim | 0:d494b853ce97 | 22 | return true; |
etherealflaim | 0:d494b853ce97 | 23 | } |
etherealflaim | 0:d494b853ce97 | 24 | |
etherealflaim | 0:d494b853ce97 | 25 | #endif |