diff options
author | Josh Blum <josh@joshknows.com> | 2010-03-03 01:19:00 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-03-03 01:19:00 -0800 |
commit | bb8417526c14bd49192c159cbdc52f5ea0063784 (patch) | |
tree | 6f8d8e0fe7cc8bb1698d4f37ba53e8f464f55b7f /host/lib/transport | |
parent | 8e8221dc380fb275a17dcd0abbfaea108f44505f (diff) | |
download | uhd-bb8417526c14bd49192c159cbdc52f5ea0063784.tar.gz uhd-bb8417526c14bd49192c159cbdc52f5ea0063784.tar.bz2 uhd-bb8417526c14bd49192c159cbdc52f5ea0063784.zip |
Making use of vrt lib in the usrp2 io_impl.
Added a packet size param to the vrt pack and unpack.
Diffstat (limited to 'host/lib/transport')
-rw-r--r-- | host/lib/transport/vrt.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/host/lib/transport/vrt.cpp b/host/lib/transport/vrt.cpp index 40b26d31f..19bfc1d19 100644 --- a/host/lib/transport/vrt.cpp +++ b/host/lib/transport/vrt.cpp @@ -26,6 +26,7 @@ void vrt::pack( uint32_t *header_buff, //output size_t &num_header_words32, //output size_t num_payload_words32, //input + size_t &num_packet_words32, //output size_t packet_count //input ){ uint32_t vrt_hdr_flags = 0; @@ -47,10 +48,12 @@ void vrt::pack( vrt_hdr_flags |= (metadata.start_of_burst)? (0x1 << 25) : 0; vrt_hdr_flags |= (metadata.end_of_burst)? (0x1 << 24) : 0; + num_packet_words32 = num_header_words32 + num_payload_words32; + //fill in complete header word header_buff[0] = htonl(vrt_hdr_flags | ((packet_count & 0xf) << 16) | - ((num_header_words32 + num_payload_words32) & 0xffff) + (num_packet_words32 & 0xffff) ); } @@ -59,6 +62,7 @@ void vrt::unpack( const uint32_t *header_buff, //input size_t &num_header_words32, //output size_t &num_payload_words32, //output + size_t num_packet_words32, //input size_t &packet_count //output ){ //clear the metadata @@ -70,8 +74,8 @@ void vrt::unpack( packet_count = (vrt_hdr_word >> 16) & 0xf; //failure cases - if (packet_words32 == 0) //FIXME check the packet length before we continue - throw std::runtime_error("bad vrt header"); + if (packet_words32 == 0 or num_packet_words32 < packet_words32) + throw std::runtime_error("bad vrt header or packet fragment"); if (vrt_hdr_word & (0x7 << 29)) throw std::runtime_error("unsupported vrt packet type"); |