UHD
003.005.003-781-g91040b6f
|
00001 // 00002 // Copyright 2010-2013 Ettus Research LLC 00003 // 00004 // This program is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 // 00017 00018 #ifndef INCLUDED_UHD_TRANSPORT_VRT_IF_PACKET_HPP 00019 #define INCLUDED_UHD_TRANSPORT_VRT_IF_PACKET_HPP 00020 00021 #include <uhd/config.hpp> 00022 #include <boost/cstdint.hpp> 00023 #include <cstddef> //size_t 00024 00025 namespace uhd{ namespace transport{ 00026 00027 namespace vrt{ 00028 00030 static const size_t num_vrl_words32 = 3; 00031 00033 static const size_t max_if_hdr_words32 = 7; //hdr+sid+cid+tsi+tsf 00034 00040 struct UHD_API if_packet_info_t 00041 { 00042 if_packet_info_t(void); 00043 00044 //link layer type - always set for pack and unpack 00045 enum link_type_t 00046 { 00047 LINK_TYPE_NONE = 0x0, 00048 LINK_TYPE_CHDR = 0x1, 00049 LINK_TYPE_VRLP = 0x2, 00050 } link_type; 00051 00052 //packet type 00053 enum packet_type_t 00054 { 00055 PACKET_TYPE_DATA = 0x0, 00056 PACKET_TYPE_IF_EXT = 0x1, 00057 PACKET_TYPE_CONTEXT = 0x2, //extension context: has_sid = true 00058 } packet_type; 00059 00060 //size fields 00061 size_t num_payload_words32; //required in pack, derived in unpack 00062 size_t num_payload_bytes; //required in pack, derived in unpack 00063 size_t num_header_words32; //derived in pack, derived in unpack 00064 size_t num_packet_words32; //derived in pack, required in unpack 00065 00066 //header fields 00067 size_t packet_count; 00068 bool sob, eob; 00069 00070 //optional fields 00071 bool has_sid; boost::uint32_t sid; 00072 bool has_cid; boost::uint64_t cid; 00073 bool has_tsi; boost::uint32_t tsi; 00074 bool has_tsf; boost::uint64_t tsf; 00075 bool has_tlr; boost::uint32_t tlr; 00076 }; 00077 00083 UHD_API void if_hdr_pack_be( 00084 boost::uint32_t *packet_buff, 00085 if_packet_info_t &if_packet_info 00086 ); 00087 00093 UHD_API void if_hdr_unpack_be( 00094 const boost::uint32_t *packet_buff, 00095 if_packet_info_t &if_packet_info 00096 ); 00097 00103 UHD_API void if_hdr_pack_le( 00104 boost::uint32_t *packet_buff, 00105 if_packet_info_t &if_packet_info 00106 ); 00107 00113 UHD_API void if_hdr_unpack_le( 00114 const boost::uint32_t *packet_buff, 00115 if_packet_info_t &if_packet_info 00116 ); 00117 00118 UHD_INLINE if_packet_info_t::if_packet_info_t(void): 00119 link_type(LINK_TYPE_NONE), 00120 packet_type(PACKET_TYPE_DATA), 00121 num_payload_words32(0), 00122 num_payload_bytes(0), 00123 num_header_words32(0), 00124 num_packet_words32(0), 00125 packet_count(0), 00126 sob(false), eob(false), 00127 has_sid(false), sid(0), 00128 has_cid(false), cid(0), 00129 has_tsi(false), tsi(0), 00130 has_tsf(false), tsf(0), 00131 has_tlr(false), tlr(0) 00132 {} 00133 00134 } //namespace vrt 00135 00136 }} //namespace 00137 00138 #endif /* INCLUDED_UHD_TRANSPORT_VRT_IF_PACKET_HPP */