00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00026 #ifndef HH_SENF_Packets_DefaultBundle_EthernetPacket_
00027 #define HH_SENF_Packets_DefaultBundle_EthernetPacket_ 1
00028
00029
00030 #include <senf/Socket/Protocols/Raw/MACAddress.hh>
00031 #include <senf/Packets/Packets.hh>
00032
00033
00034
00035
00036 namespace senf {
00037
00045 struct MACAddressParser
00046 : public ValueParserBase<MACAddressParser, MACAddress, 6u>
00047 {
00048 MACAddressParser(data_iterator i, state_type s) : Base(i,s) {}
00049
00050 value_type value() const { return MACAddress::from_data(i()); }
00051 void value(value_type const & v) { std::copy(v.begin(), v.end(), i()); }
00052
00053 using Base::operator=;
00054 };
00055
00062 struct EthernetPacketParser : public PacketParserBase
00063 {
00064 # include SENF_FIXED_PARSER()
00065
00066 SENF_PARSER_FIELD( destination, MACAddressParser );
00067 SENF_PARSER_FIELD( source, MACAddressParser );
00068 SENF_PARSER_FIELD( type_length, UInt16Parser );
00069
00070 SENF_PARSER_FINALIZE(EthernetPacketParser);
00071 };
00072
00080 struct EtherTypes {
00081 typedef boost::uint16_t key_t;
00082 };
00083
00101 struct EthernetPacketType
00102 : public PacketTypeBase,
00103 public PacketTypeMixin<EthernetPacketType, EtherTypes>
00104 {
00105 #ifndef DOXYGEN
00106 typedef PacketTypeMixin<EthernetPacketType, EtherTypes> mixin;
00107 #endif
00108 typedef ConcretePacket<EthernetPacketType> packet;
00109 typedef EthernetPacketParser parser;
00110
00111 using mixin::nextPacketRange;
00112 using mixin::initSize;
00113 using mixin::init;
00114
00115 static factory_t nextPacketType(packet p);
00117 static void dump(packet p, std::ostream & os);
00118 static void finalize(packet p);
00119 };
00120
00124 typedef ConcretePacket<EthernetPacketType> EthernetPacket;
00125
00126
00133 struct EthVLanPacketParser : public PacketParserBase
00134 {
00135 # include SENF_FIXED_PARSER()
00136
00137 SENF_PARSER_BITFIELD( priority, 3, unsigned );
00138 SENF_PARSER_BITFIELD( cfi, 1, bool );
00139 SENF_PARSER_BITFIELD( vlanId, 12, unsigned );
00140
00141 SENF_PARSER_FIELD( type, UInt16Parser );
00142
00143 SENF_PARSER_FINALIZE(EthVLanPacketParser);
00144 };
00145
00163 struct EthVLanPacketType
00164 : public PacketTypeBase,
00165 public PacketTypeMixin<EthVLanPacketType, EtherTypes>
00166 {
00167 #ifndef DOXYGEN
00168 typedef PacketTypeMixin<EthVLanPacketType, EtherTypes> mixin;
00169 #endif
00170 typedef ConcretePacket<EthVLanPacketType> packet;
00171 typedef EthVLanPacketParser parser;
00172
00173 using mixin::nextPacketRange;
00174 using mixin::nextPacketType;
00175 using mixin::initSize;
00176 using mixin::init;
00177
00180 static key_t nextPacketKey(packet p)
00181 { return p->type(); }
00182
00184 static void dump(packet p, std::ostream & os);
00185 static void finalize(packet p);
00186 };
00187
00191 typedef ConcretePacket<EthVLanPacketType> EthVLanPacket;
00192
00193 }
00194
00195
00196
00197
00198
00199 #endif
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210