3 #include "uhal/log/log.hpp" 12 #include <arpa/inet.h> 51 return ( uint64_t ( s_MAC[0] ) << 40 ) | ( uint64_t ( s_MAC[1] ) << 32 ) | ( uint64_t ( s_MAC[2] ) << 24 ) | ( uint64_t ( s_MAC[3] ) << 16 ) | ( uint64_t ( s_MAC[4] ) << 8 ) | ( uint64_t ( s_MAC[5] ) );
59 return ntohl ( *reinterpret_cast<uint32_t*> ( s_IP ) );
67 return ntohs ( *reinterpret_cast<uint16_t*> ( s_port ) );
76 return ( uint64_t ( d_MAC[0] ) << 40 ) | ( uint64_t ( d_MAC[1] ) << 32 ) | ( uint64_t ( d_MAC[2] ) << 24 ) | ( uint64_t ( d_MAC[3] ) << 16 ) | ( uint64_t ( d_MAC[4] ) << 8 ) | ( uint64_t ( d_MAC[5] ) );
84 return ntohl ( *reinterpret_cast<uint32_t*> ( d_IP ) );
92 return ntohs ( *reinterpret_cast<uint16_t*> ( d_port ) );
100 return ntohs ( *reinterpret_cast<uint16_t*> ( l ) );
109 uint32_t lLength ( ( length()-8 ) >>2 );
110 std::vector<uint32_t> lReturn;
112 for ( uint32_t i=0 ; i!=lLength ; ++i )
114 lReturn.push_back ( *reinterpret_cast<uint32_t*> ( &d[i<<2] ) );
124 int main (
int argc,
char* argv[] )
128 std::ifstream file (
"etc/uhal/tests/wireshark.txt" );
130 if ( file.is_open() )
133 uint16_t lTemp , lValue;
134 uint8_t block[1500] = { 0 };
135 uint8_t* block_ptr = block;
137 while ( file.good() )
139 getline ( file,line );
143 log (
Info() ,
"Raw : " , line );
144 std::stringstream lStr ( line );
147 for ( uint32_t i=0 ; i!=16 ; ++i )
150 * ( block_ptr++ ) = uint8_t ( lValue );
155 if ( block_ptr != block )
166 std::vector<uint32_t> lData ( y.
data() );
167 std::vector<uint32_t>::const_iterator lBegin ( lData.begin() );
168 std::vector<uint32_t>::const_iterator lEnd ( lData.end() );
172 log (
Notice() ,
"Host To Target" );
173 lHostToTarget.
analyze ( lBegin , lEnd );
177 log (
Notice() ,
"Target to Host" );
178 lTargetToHost.
analyze ( lBegin , lEnd );
182 std::cout << std::string ( 122 ,
'-' ) << std::endl;
bool analyze(std::vector< uint32_t >::const_iterator &aIt, const std::vector< uint32_t >::const_iterator &aEnd, const bool &aContinueOnError=true)
Analyse an IPbus packet held as a vector of uint32_t's.
uint64_t source_MAC()
Return source MAC address.
uint16_t destination_port()
Return destination port.
std::vector< uint32_t > data()
Return payload.
Helper class to decode IPbus packets as passed from the Client to the Target.
uint32_t source_IP()
Return source IP address.
Helper class to decode IPbus packets as passed from the Target to the Client.
uint16_t length()
Return length.
Empty struct which acts as a dummy variable for passing the formatting information around...
uint16_t source_port()
Return source port.
uint64_t destination_MAC()
Return destination MAC address.
bool analyze(std::vector< uint32_t >::const_iterator &aIt, const std::vector< uint32_t >::const_iterator &aEnd, const bool &aContinueOnError=true)
Analyse an IPbus packet held as a vector of uint32_t's.
Struct for storing an ethernet frame.
int main(int argc, char *argv[])
Parse an IPbus 1.3 packet from a wireshark text file.
uint32_t destination_IP()
Return destination IP address.
_Integer< T, IntFmt<> > Integer(const T &aT)
Forward declare a function which creates an instance of the ultra-lightweight wrapper from an integer...