3 * Copyright 2009 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #ifndef INCLUDED_VRT_EXPANDED_HEADER_H
22 #define INCLUDED_VRT_EXPANDED_HEADER_H
31 * \brief All headers and trailer for VRT IF-Data, Extension-Data,
32 * IF-Context and Extension-Context packets.
34 * There are fields allocated for each possible header. Their content may
35 * or may not be valid. Check the header field to confirm their validity.
36 * All values are in host-endian format.
38 struct expanded_header {
39 uint32_t header; // first word of all packets
40 uint32_t stream_id; // optional stream identifier
41 uint64_t class_id; // optional class identifier
42 uint32_t integer_secs; // optional integer seconds timestamp
43 uint64_t fractional_secs; // optional fractional seconds timestamp
44 uint32_t trailer; // optional trailer (only possible in data pkts)
47 : header(0) /*, stream_id(0), class_id(0),
48 integer_secs(0), fractional_secs(0), trailer(0)*/ {}
51 int pkt_type() const {
52 return (header & VRTH_PT_MASK) >> 28;
55 int pkt_cnt() const { return vrth_pkt_cnt(header); }
56 size_t pkt_size() const { return vrth_pkt_size(header); }
59 // packet type predicates
60 bool if_data_p() const { return s_if_data[pkt_type()]; }
61 bool ext_data_p() const { return s_ext_data[pkt_type()]; }
62 bool if_context_p() const { return (header & VRTH_PT_MASK) == VRTH_PT_IF_CONTEXT; }
63 bool ext_context_p() const { return (header & VRTH_PT_MASK) == VRTH_PT_EXT_CONTEXT; }
65 bool data_p() const { return s_data[pkt_type()]; } // if_data_p() || ext_data_p()
66 bool context_p() const { return s_context[pkt_type()]; } // if_context_p() || ext_context_p()
68 // optional info predicates
69 bool stream_id_p() const { return s_stream_id[pkt_type()]; }
70 bool class_id_p() const { return (header & VRTH_HAS_CLASSID) != 0; }
71 bool integer_secs_p() const { return (header & VRTH_TSI_MASK) != 0; }
72 bool fractional_secs_p() const { return (header & VRTH_TSF_MASK) != 0; }
73 bool trailer_p() const { return (header & VRTH_HAS_TRAILER) != 0 && data_p(); }
79 * \brief parse packet, fill-in expanded header, start of payload and len of payload
81 static bool parse(const uint32_t *packet, // in
82 size_t n32_bit_words_packet, // in
83 expanded_header *hdr, // out
84 const uint32_t **payload, // out
85 size_t *n32_bit_words_payload); // out
88 static unsigned char s_if_data[16];
89 static unsigned char s_ext_data[16];
90 static unsigned char s_data[16];
91 static unsigned char s_context[16];
92 static unsigned char s_stream_id[16];
99 #endif /* INCLUDED_VRT_EXPANDED_HEADER_H */