X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FIntParser.ih;h=16099c1cfc1c8ee0568c1cce552c3257e26b9603;hb=a1fdb7bb122f0b05be809a922d4b7ef5e125fa67;hp=404c3cc682b03d8ee18d5396ef678281fb5a47b7;hpb=f73fa16ed5abdce272ac77f8b8b9ef2b9922c266;p=senf.git diff --git a/Packets/IntParser.ih b/Packets/IntParser.ih index 404c3cc..16099c1 100644 --- a/Packets/IntParser.ih +++ b/Packets/IntParser.ih @@ -1,8 +1,8 @@ // $Id$ // // Copyright (C) 2006 -// Fraunhofer Institute for Open Communication Systems (FOKUS) -// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify @@ -23,8 +23,8 @@ /** \file \brief IntParser internal header */ -#ifndef IH_IntParser_ -#define IH_IntParser_ 1 +#ifndef IH_SENF_Packets_IntParser_ +#define IH_SENF_Packets_IntParser_ 1 // Custom includes #include "PacketTypes.hh" @@ -96,7 +96,7 @@ namespace packet { // Network byte order integer extraction /** \brief Internal: Extract 16bit network byte order value - + \internal */ inline boost::uint16_t parse_uint16(iterator i) @@ -105,7 +105,7 @@ namespace packet { } /** \brief Internal: Write 16bit network byte order value - + \internal */ inline void write_uint16(iterator i, boost::uint16_t v) @@ -114,8 +114,27 @@ namespace packet { i[1] = ( v ) & 0xff; } + /** \brief Internal: Extract 16bit least significant bit order value + + \internal + */ + inline boost::uint16_t parse_uint16LSB(iterator i) + { + return i[0] | i[1]<<8; + } + + /** \brief Internal: Write 16bit least significant bit order value + + \internal + */ + inline void write_uint16LSB(iterator i, boost::uint16_t v) + { + i[0] = ( v ) & 0xff; + i[1] = ( v >> 8 ) & 0xff; + } + /** \brief Internal: Extract 24bit network byte order value - + \internal */ inline boost::uint32_t parse_uint24(iterator i) @@ -124,7 +143,7 @@ namespace packet { } /** \brief Internal: Write 24bit network byte order value - + \internal */ inline void write_uint24(iterator i, boost::uint32_t v) @@ -135,7 +154,7 @@ namespace packet { } /** \brief Internal: Extract 32bit network byte order value - + \internal */ inline boost::uint32_t parse_uint32(iterator i) @@ -144,7 +163,7 @@ namespace packet { } /** \brief Internal: Write 32bit network byte order value - + \internal */ inline void write_uint32(iterator i, boost::uint32_t v) @@ -155,10 +174,87 @@ namespace packet { i[3] = ( v ) & 0xff; } + /** \brief Internal: Extract 32bit network byte order value + + \internal + */ + inline boost::uint32_t parse_uint32LSB(iterator i) + { + return i[0] | i[1]<<8 | i[2]<<16 | i[3]<<24; + } + + /** \brief Internal: Write 32bit network byte order value + + \internal + */ + inline void write_uint32LSB(iterator i, boost::uint32_t v) + { + i[3] = ( v >> 24 ) & 0xff; + i[2] = ( v >> 16 ) & 0xff; + i[1] = ( v >> 8 ) & 0xff; + i[0] = ( v ) & 0xff; + } + + /** \brief Internal: Extract 64bit network byte order value + + \internal + */ + inline boost::uint64_t parse_uint64(iterator i) + { + return ((boost::uint64_t)i[7]) | ((boost::uint64_t)i[6])<<8 + | ((boost::uint64_t)i[5])<<16 | ((boost::uint64_t)i[4])<<24 + | ((boost::uint64_t)i[3])<<32 | ((boost::uint64_t)i[2])<<40 + | ((boost::uint64_t)i[1])<<48 | ((boost::uint64_t)i[0])<<56; + } + + /** \brief Internal: Write 64bit network byte order value + + \internal + */ + inline void write_uint64(iterator i, boost::uint64_t v) + { + i[0] = ( v >> 56 ) & 0xff; + i[1] = ( v >> 48 ) & 0xff; + i[2] = ( v >> 40 ) & 0xff; + i[3] = ( v >> 32 ) & 0xff; + i[4] = ( v >> 24 ) & 0xff; + i[5] = ( v >> 16 ) & 0xff; + i[6] = ( v >> 8 ) & 0xff; + i[7] = ( v ) & 0xff; + } + + /** \brief Internal: Extract 64bit least significant bit order value + + \internal + */ + inline boost::uint64_t parse_uint64LSB(iterator i) + { + return ((boost::uint64_t)i[0]) | ((boost::uint64_t)i[1])<<8 + | ((boost::uint64_t)i[2])<<16 | ((boost::uint64_t)i[3])<<24 + | ((boost::uint64_t)i[4])<<32 | ((boost::uint64_t)i[5])<<40 + | ((boost::uint64_t)i[6])<<48 | ((boost::uint64_t)i[7])<<56; + } + + /** \brief Internal: Write 64bit least significant bit order value + + \internal + */ + inline void write_uint64LSB(iterator i, boost::uint64_t v) + { + i[0] = ( v ) & 0xff; + i[1] = ( v >> 8 ) & 0xff; + i[2] = ( v >> 16 ) & 0xff; + i[3] = ( v >> 24 ) & 0xff; + i[4] = ( v >> 32 ) & 0xff; + i[5] = ( v >> 40 ) & 0xff; + i[6] = ( v >> 48 ) & 0xff; + i[7] = ( v >> 56 ) & 0xff; + } + /////////////////////////////////////////////////////////////////////////// // bitfield extraction - // Doxygen doesn't like this stuff ... + // Doxygen doesn't like this stuff ... # ifndef DOXYGEN @@ -245,7 +341,7 @@ namespace packet { /** \brief Internal: Bitfield read/write helper \internal - + Using template specializations, this class provides optimized bitfield parsers and writers. For each number of bytes the bitfield covers (from 1 to 5 bytes), a template specialization is provided in \c parse_bitfield_i. @@ -263,7 +359,7 @@ namespace packet { ///////////////////////////////ih.e//////////////////////////////////////// #endif - + // Local Variables: // mode: c++ // fill-column: 100