00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef PROTO_IP4_HH_
00023 # define PROTO_IP4_HH_
00024
00025 extern "C"
00026 {
00027 # include <inttypes.h>
00028 }
00029
00030 # include <wipal/tool/addr.hh>
00031
00033 namespace ip4
00034 {
00035
00037 typedef tool::addr<uint8_t, 4, false, '.'> addr;
00038
00040 namespace proto
00041 {
00042
00044 enum proto
00045 {
00046 ICMP = 1,
00047 TCP = 6,
00048 UDP = 17,
00049 ICMPv6 = 58
00050 };
00051
00052 }
00053
00055 struct header
00056 {
00058 enum addr_index
00059 {
00060 sa = 0,
00061 da = 1,
00062 };
00063
00064 union
00065 {
00066
00067 uint8_t version;
00068 uint8_t headerlength;
00069 };
00070
00071 uint8_t dsfield;
00072 uint16_t iplen;
00073 uint16_t identifier;
00074
00075 union
00076 {
00077
00078 uint16_t flags;
00079 uint16_t fragoffset;
00080 };
00081
00082 uint8_t ttl;
00083 uint8_t ipproto;
00084 uint16_t checksum;
00085 addr addrs[2];
00086
00087 } __attribute__((__packed__));
00088
00089 }
00090
00091 #endif // ! PROTO_IP4_HH_