X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FDefaultBundle%2FIpV4Packet.hh;h=0dd83445e3932c0e940a6cb96c89d0fc49f8cfb4;hb=f1fc7057fa65a9509651d08c6c134d136fbb0424;hp=8bd7c699c20b32422a5508ded86020b271d34022;hpb=a4e052fb8832499ef5e3ae4e563ea01b834010c2;p=senf.git
diff --git a/Packets/DefaultBundle/IpV4Packet.hh b/Packets/DefaultBundle/IpV4Packet.hh
index 8bd7c69..0dd8344 100644
--- a/Packets/DefaultBundle/IpV4Packet.hh
+++ b/Packets/DefaultBundle/IpV4Packet.hh
@@ -20,10 +20,14 @@
// Free Software Foundation, Inc.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+/** \file
+ \brief IpV4Packet public header */
+
#ifndef HH_IpV4Packet_
#define HH_IpV4Packet_ 1
// Custom includes
+#include "Socket/Protocols/INet/INet4Address.hh"
#include "Packets/Packets.hh"
//#include "IpV4Packet.mpp"
@@ -31,6 +35,27 @@
namespace senf {
+ /** \brief Parse in IpV4 address
+
+ \see INet4Address
+ */
+ struct Parse_INet4Address : public PacketParserBase
+ {
+ Parse_INet4Address(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {}
+
+ ///////////////////////////////////////////////////////////////////////////
+
+ typedef INet4Address value_type;
+ static const size_type fixed_bytes = 4u;
+
+ value_type value() const { return value_type::from_data(i()); }
+ void value(value_type const & v) { std::copy(v.begin(), v.end(), i()); }
+ operator value_type() { return value(); }
+ byte & operator[](size_type index) { return *boost::next(i(),index); }
+ Parse_INet4Address const & operator= (value_type const & other)
+ { value(other); return *this; }
+ };
+
/** \brief Parse an IpV4 packet
Parser implementing the IpV4 header. The fields implemented are:
@@ -51,6 +76,7 @@ namespace senf {
typedef Parse_Flag < 2 > Parse_MF;
typedef Parse_UIntField < 3, 16 > Parse_Frag;
typedef Parse_UInt32 Parse_32bit;
+ typedef Parse_INet4Address Parse_Addr;
# ifndef DOXYGEN
@@ -69,25 +95,25 @@ namespace senf {
((Field )( ttl, Parse_8bit ))
((Field )( protocol, Parse_8bit ))
((Field )( crc, Parse_16bit ))
- ((Field )( source, Parse_32bit ))
- ((Field )( destination, Parse_32bit )) );
+ ((Field )( source, Parse_Addr ))
+ ((Field )( destination, Parse_Addr )) );
# else
- Parse_Version version();
- Parse_IHL ihl();
- Parse_8bit tos();
- Parse_16bit length();
- Parse_16bit identifier();
- Parse_R reserved();
- Parse_DF df();
- Parse_MF mf();
- Parse_Frag frag();
- Parse_8bit ttl();
- Parse_8bit protocol();
- Parse_16bit crc();
- Parse_32bit source();
- Parse_32bit destination();
+ Parse_Version version() const;
+ Parse_IHL ihl() const;
+ Parse_8bit tos() const;
+ Parse_16bit length() const;
+ Parse_16bit identifier() const;
+ Parse_R reserved() const;
+ Parse_DF df() const;
+ Parse_MF mf() const;
+ Parse_Frag frag() const;
+ Parse_8bit ttl() const;
+ Parse_8bit protocol() const;
+ Parse_16bit crc() const;
+ Parse_Addr source() const;
+ Parse_Addr destination() const;
# endif
@@ -100,7 +126,7 @@ namespace senf {
This registeres packets with their IP protocol number.
- \see Protocol numbers
+ \see Protocol numbers \n
PacketRegistry
*/
struct IpTypes {