Unparse can fill in a vrt header and trailer from an expanded header.
namespace vrt {
+ static const size_t HEADER_MAX_N32_BIT_WORDS = 7;
+ static const size_t TRAILER_MAX_N32_BIT_WORDS = 1;
+
/*!
* \brief All headers and trailer for VRT IF-Data, Extension-Data,
* IF-Context and Extension-Context packets.
bool trailer_p() const { return (header & VRTH_HAS_TRAILER) != 0 && data_p(); }
- // parser
+ /*!
+ * \brief unparse expanded header, fill-in the words of a vrt packet header and trailer
+ * This method is only intended to fill the buffers with header and trailer information.
+ * The actual handling of the separate header, payload, trailer buffers is up to the caller.
+ */
+ static void unparse(const expanded_header *hdr, // in
+ size_t n32_bit_words_payload, // in
+ uint32_t *header, // out
+ size_t *n32_bit_words_header, // out
+ uint32_t *trailer, // out
+ size_t *n32_bit_words_trailer);// out
/*!
* \brief parse packet, fill-in expanded header, start of payload and len of payload
noinst_HEADERS = \
data_handler.h \
expanded_header_cw_tables.h \
- expanded_header_switch_body.h \
+ expanded_header_parse_switch_body.h \
+ expanded_header_unparse_switch_body.h \
socket_rx_buffer.h
EXTRA_DIST = \
gen_cw_tables.py \
- gen_switch_body.py
+ gen_parse_switch_body.py \
+ gen_unparse_switch_body.py
return cw;
}
+ void expanded_header::unparse(const expanded_header *h, // in
+ size_t n32_bit_words_payload, // in
+ uint32_t *header, // out
+ size_t *n32_bit_words_header, // out
+ uint32_t *trailer, // out
+ size_t *n32_bit_words_trailer){// out
+ int cw = compute_codeword(*h);
+ //fills in the header (except word0), header length, trailer, trailer length
+ switch (cw & 0x1f){
+#include "expanded_header_unparse_switch_body.h"
+ }
+ //fill in the header word 0 with the calculated length
+ size_t n32_bit_words_packet = *n32_bit_words_header + n32_bit_words_payload + *n32_bit_words_trailer;
+ header[0] = htonl((h->header & ~VRTH_PKT_SIZE_MASK) | (n32_bit_words_packet & VRTH_PKT_SIZE_MASK));
+ }
+
bool
expanded_header::parse(const uint32_t *packet, // in
size_t n32_bit_words_packet, // in
// h->header, cw, cw_header_len(cw), cw_trailer_len(cw));
switch (cw & 0x1f){
-#include "expanded_header_switch_body.h"
+#include "expanded_header_parse_switch_body.h"
}
return true;
--- /dev/null
+ case 0:
+ h->stream_id = 0;
+ h->class_id = 0;
+ h->integer_secs = 0;
+ h->fractional_secs = 0;
+ h->trailer = 0;
+ break;
+
+ case 1:
+ h->stream_id = ntohl(p[1]);
+ h->class_id = 0;
+ h->integer_secs = 0;
+ h->fractional_secs = 0;
+ h->trailer = 0;
+ break;
+
+ case 2:
+ h->stream_id = 0;
+ h->class_id = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]);
+ h->integer_secs = 0;
+ h->fractional_secs = 0;
+ h->trailer = 0;
+ break;
+
+ case 3:
+ h->stream_id = ntohl(p[1]);
+ h->class_id = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]);
+ h->integer_secs = 0;
+ h->fractional_secs = 0;
+ h->trailer = 0;
+ break;
+
+ case 4:
+ h->stream_id = 0;
+ h->class_id = 0;
+ h->integer_secs = ntohl(p[1]);
+ h->fractional_secs = 0;
+ h->trailer = 0;
+ break;
+
+ case 5:
+ h->stream_id = ntohl(p[1]);
+ h->class_id = 0;
+ h->integer_secs = ntohl(p[2]);
+ h->fractional_secs = 0;
+ h->trailer = 0;
+ break;
+
+ case 6:
+ h->stream_id = 0;
+ h->class_id = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]);
+ h->integer_secs = ntohl(p[3]);
+ h->fractional_secs = 0;
+ h->trailer = 0;
+ break;
+
+ case 7:
+ h->stream_id = ntohl(p[1]);
+ h->class_id = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]);
+ h->integer_secs = ntohl(p[4]);
+ h->fractional_secs = 0;
+ h->trailer = 0;
+ break;
+
+ case 8:
+ h->stream_id = 0;
+ h->class_id = 0;
+ h->integer_secs = 0;
+ h->fractional_secs = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]);
+ h->trailer = 0;
+ break;
+
+ case 9:
+ h->stream_id = ntohl(p[1]);
+ h->class_id = 0;
+ h->integer_secs = 0;
+ h->fractional_secs = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]);
+ h->trailer = 0;
+ break;
+
+ case 10:
+ h->stream_id = 0;
+ h->class_id = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]);
+ h->integer_secs = 0;
+ h->fractional_secs = ((uint64_t)(ntohl(p[3])) << 32) | ntohl(p[4]);
+ h->trailer = 0;
+ break;
+
+ case 11:
+ h->stream_id = ntohl(p[1]);
+ h->class_id = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]);
+ h->integer_secs = 0;
+ h->fractional_secs = ((uint64_t)(ntohl(p[4])) << 32) | ntohl(p[5]);
+ h->trailer = 0;
+ break;
+
+ case 12:
+ h->stream_id = 0;
+ h->class_id = 0;
+ h->integer_secs = ntohl(p[1]);
+ h->fractional_secs = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]);
+ h->trailer = 0;
+ break;
+
+ case 13:
+ h->stream_id = ntohl(p[1]);
+ h->class_id = 0;
+ h->integer_secs = ntohl(p[2]);
+ h->fractional_secs = ((uint64_t)(ntohl(p[3])) << 32) | ntohl(p[4]);
+ h->trailer = 0;
+ break;
+
+ case 14:
+ h->stream_id = 0;
+ h->class_id = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]);
+ h->integer_secs = ntohl(p[3]);
+ h->fractional_secs = ((uint64_t)(ntohl(p[4])) << 32) | ntohl(p[5]);
+ h->trailer = 0;
+ break;
+
+ case 15:
+ h->stream_id = ntohl(p[1]);
+ h->class_id = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]);
+ h->integer_secs = ntohl(p[4]);
+ h->fractional_secs = ((uint64_t)(ntohl(p[5])) << 32) | ntohl(p[6]);
+ h->trailer = 0;
+ break;
+
+ case 16:
+ h->stream_id = 0;
+ h->class_id = 0;
+ h->integer_secs = 0;
+ h->fractional_secs = 0;
+ h->trailer = ntohl(p[len-1]);
+ break;
+
+ case 17:
+ h->stream_id = ntohl(p[1]);
+ h->class_id = 0;
+ h->integer_secs = 0;
+ h->fractional_secs = 0;
+ h->trailer = ntohl(p[len-1]);
+ break;
+
+ case 18:
+ h->stream_id = 0;
+ h->class_id = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]);
+ h->integer_secs = 0;
+ h->fractional_secs = 0;
+ h->trailer = ntohl(p[len-1]);
+ break;
+
+ case 19:
+ h->stream_id = ntohl(p[1]);
+ h->class_id = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]);
+ h->integer_secs = 0;
+ h->fractional_secs = 0;
+ h->trailer = ntohl(p[len-1]);
+ break;
+
+ case 20:
+ h->stream_id = 0;
+ h->class_id = 0;
+ h->integer_secs = ntohl(p[1]);
+ h->fractional_secs = 0;
+ h->trailer = ntohl(p[len-1]);
+ break;
+
+ case 21:
+ h->stream_id = ntohl(p[1]);
+ h->class_id = 0;
+ h->integer_secs = ntohl(p[2]);
+ h->fractional_secs = 0;
+ h->trailer = ntohl(p[len-1]);
+ break;
+
+ case 22:
+ h->stream_id = 0;
+ h->class_id = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]);
+ h->integer_secs = ntohl(p[3]);
+ h->fractional_secs = 0;
+ h->trailer = ntohl(p[len-1]);
+ break;
+
+ case 23:
+ h->stream_id = ntohl(p[1]);
+ h->class_id = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]);
+ h->integer_secs = ntohl(p[4]);
+ h->fractional_secs = 0;
+ h->trailer = ntohl(p[len-1]);
+ break;
+
+ case 24:
+ h->stream_id = 0;
+ h->class_id = 0;
+ h->integer_secs = 0;
+ h->fractional_secs = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]);
+ h->trailer = ntohl(p[len-1]);
+ break;
+
+ case 25:
+ h->stream_id = ntohl(p[1]);
+ h->class_id = 0;
+ h->integer_secs = 0;
+ h->fractional_secs = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]);
+ h->trailer = ntohl(p[len-1]);
+ break;
+
+ case 26:
+ h->stream_id = 0;
+ h->class_id = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]);
+ h->integer_secs = 0;
+ h->fractional_secs = ((uint64_t)(ntohl(p[3])) << 32) | ntohl(p[4]);
+ h->trailer = ntohl(p[len-1]);
+ break;
+
+ case 27:
+ h->stream_id = ntohl(p[1]);
+ h->class_id = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]);
+ h->integer_secs = 0;
+ h->fractional_secs = ((uint64_t)(ntohl(p[4])) << 32) | ntohl(p[5]);
+ h->trailer = ntohl(p[len-1]);
+ break;
+
+ case 28:
+ h->stream_id = 0;
+ h->class_id = 0;
+ h->integer_secs = ntohl(p[1]);
+ h->fractional_secs = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]);
+ h->trailer = ntohl(p[len-1]);
+ break;
+
+ case 29:
+ h->stream_id = ntohl(p[1]);
+ h->class_id = 0;
+ h->integer_secs = ntohl(p[2]);
+ h->fractional_secs = ((uint64_t)(ntohl(p[3])) << 32) | ntohl(p[4]);
+ h->trailer = ntohl(p[len-1]);
+ break;
+
+ case 30:
+ h->stream_id = 0;
+ h->class_id = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]);
+ h->integer_secs = ntohl(p[3]);
+ h->fractional_secs = ((uint64_t)(ntohl(p[4])) << 32) | ntohl(p[5]);
+ h->trailer = ntohl(p[len-1]);
+ break;
+
+ case 31:
+ h->stream_id = ntohl(p[1]);
+ h->class_id = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]);
+ h->integer_secs = ntohl(p[4]);
+ h->fractional_secs = ((uint64_t)(ntohl(p[5])) << 32) | ntohl(p[6]);
+ h->trailer = ntohl(p[len-1]);
+ break;
+
+++ /dev/null
- case 0:
- h->stream_id = 0;
- h->class_id = 0;
- h->integer_secs = 0;
- h->fractional_secs = 0;
- h->trailer = 0;
- break;
-
- case 1:
- h->stream_id = ntohl(p[1]);
- h->class_id = 0;
- h->integer_secs = 0;
- h->fractional_secs = 0;
- h->trailer = 0;
- break;
-
- case 2:
- h->stream_id = 0;
- h->class_id = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]);
- h->integer_secs = 0;
- h->fractional_secs = 0;
- h->trailer = 0;
- break;
-
- case 3:
- h->stream_id = ntohl(p[1]);
- h->class_id = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]);
- h->integer_secs = 0;
- h->fractional_secs = 0;
- h->trailer = 0;
- break;
-
- case 4:
- h->stream_id = 0;
- h->class_id = 0;
- h->integer_secs = ntohl(p[1]);
- h->fractional_secs = 0;
- h->trailer = 0;
- break;
-
- case 5:
- h->stream_id = ntohl(p[1]);
- h->class_id = 0;
- h->integer_secs = ntohl(p[2]);
- h->fractional_secs = 0;
- h->trailer = 0;
- break;
-
- case 6:
- h->stream_id = 0;
- h->class_id = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]);
- h->integer_secs = ntohl(p[3]);
- h->fractional_secs = 0;
- h->trailer = 0;
- break;
-
- case 7:
- h->stream_id = ntohl(p[1]);
- h->class_id = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]);
- h->integer_secs = ntohl(p[4]);
- h->fractional_secs = 0;
- h->trailer = 0;
- break;
-
- case 8:
- h->stream_id = 0;
- h->class_id = 0;
- h->integer_secs = 0;
- h->fractional_secs = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]);
- h->trailer = 0;
- break;
-
- case 9:
- h->stream_id = ntohl(p[1]);
- h->class_id = 0;
- h->integer_secs = 0;
- h->fractional_secs = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]);
- h->trailer = 0;
- break;
-
- case 10:
- h->stream_id = 0;
- h->class_id = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]);
- h->integer_secs = 0;
- h->fractional_secs = ((uint64_t)(ntohl(p[3])) << 32) | ntohl(p[4]);
- h->trailer = 0;
- break;
-
- case 11:
- h->stream_id = ntohl(p[1]);
- h->class_id = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]);
- h->integer_secs = 0;
- h->fractional_secs = ((uint64_t)(ntohl(p[4])) << 32) | ntohl(p[5]);
- h->trailer = 0;
- break;
-
- case 12:
- h->stream_id = 0;
- h->class_id = 0;
- h->integer_secs = ntohl(p[1]);
- h->fractional_secs = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]);
- h->trailer = 0;
- break;
-
- case 13:
- h->stream_id = ntohl(p[1]);
- h->class_id = 0;
- h->integer_secs = ntohl(p[2]);
- h->fractional_secs = ((uint64_t)(ntohl(p[3])) << 32) | ntohl(p[4]);
- h->trailer = 0;
- break;
-
- case 14:
- h->stream_id = 0;
- h->class_id = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]);
- h->integer_secs = ntohl(p[3]);
- h->fractional_secs = ((uint64_t)(ntohl(p[4])) << 32) | ntohl(p[5]);
- h->trailer = 0;
- break;
-
- case 15:
- h->stream_id = ntohl(p[1]);
- h->class_id = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]);
- h->integer_secs = ntohl(p[4]);
- h->fractional_secs = ((uint64_t)(ntohl(p[5])) << 32) | ntohl(p[6]);
- h->trailer = 0;
- break;
-
- case 16:
- h->stream_id = 0;
- h->class_id = 0;
- h->integer_secs = 0;
- h->fractional_secs = 0;
- h->trailer = ntohl(p[len-1]);
- break;
-
- case 17:
- h->stream_id = ntohl(p[1]);
- h->class_id = 0;
- h->integer_secs = 0;
- h->fractional_secs = 0;
- h->trailer = ntohl(p[len-1]);
- break;
-
- case 18:
- h->stream_id = 0;
- h->class_id = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]);
- h->integer_secs = 0;
- h->fractional_secs = 0;
- h->trailer = ntohl(p[len-1]);
- break;
-
- case 19:
- h->stream_id = ntohl(p[1]);
- h->class_id = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]);
- h->integer_secs = 0;
- h->fractional_secs = 0;
- h->trailer = ntohl(p[len-1]);
- break;
-
- case 20:
- h->stream_id = 0;
- h->class_id = 0;
- h->integer_secs = ntohl(p[1]);
- h->fractional_secs = 0;
- h->trailer = ntohl(p[len-1]);
- break;
-
- case 21:
- h->stream_id = ntohl(p[1]);
- h->class_id = 0;
- h->integer_secs = ntohl(p[2]);
- h->fractional_secs = 0;
- h->trailer = ntohl(p[len-1]);
- break;
-
- case 22:
- h->stream_id = 0;
- h->class_id = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]);
- h->integer_secs = ntohl(p[3]);
- h->fractional_secs = 0;
- h->trailer = ntohl(p[len-1]);
- break;
-
- case 23:
- h->stream_id = ntohl(p[1]);
- h->class_id = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]);
- h->integer_secs = ntohl(p[4]);
- h->fractional_secs = 0;
- h->trailer = ntohl(p[len-1]);
- break;
-
- case 24:
- h->stream_id = 0;
- h->class_id = 0;
- h->integer_secs = 0;
- h->fractional_secs = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]);
- h->trailer = ntohl(p[len-1]);
- break;
-
- case 25:
- h->stream_id = ntohl(p[1]);
- h->class_id = 0;
- h->integer_secs = 0;
- h->fractional_secs = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]);
- h->trailer = ntohl(p[len-1]);
- break;
-
- case 26:
- h->stream_id = 0;
- h->class_id = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]);
- h->integer_secs = 0;
- h->fractional_secs = ((uint64_t)(ntohl(p[3])) << 32) | ntohl(p[4]);
- h->trailer = ntohl(p[len-1]);
- break;
-
- case 27:
- h->stream_id = ntohl(p[1]);
- h->class_id = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]);
- h->integer_secs = 0;
- h->fractional_secs = ((uint64_t)(ntohl(p[4])) << 32) | ntohl(p[5]);
- h->trailer = ntohl(p[len-1]);
- break;
-
- case 28:
- h->stream_id = 0;
- h->class_id = 0;
- h->integer_secs = ntohl(p[1]);
- h->fractional_secs = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]);
- h->trailer = ntohl(p[len-1]);
- break;
-
- case 29:
- h->stream_id = ntohl(p[1]);
- h->class_id = 0;
- h->integer_secs = ntohl(p[2]);
- h->fractional_secs = ((uint64_t)(ntohl(p[3])) << 32) | ntohl(p[4]);
- h->trailer = ntohl(p[len-1]);
- break;
-
- case 30:
- h->stream_id = 0;
- h->class_id = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]);
- h->integer_secs = ntohl(p[3]);
- h->fractional_secs = ((uint64_t)(ntohl(p[4])) << 32) | ntohl(p[5]);
- h->trailer = ntohl(p[len-1]);
- break;
-
- case 31:
- h->stream_id = ntohl(p[1]);
- h->class_id = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]);
- h->integer_secs = ntohl(p[4]);
- h->fractional_secs = ((uint64_t)(ntohl(p[5])) << 32) | ntohl(p[6]);
- h->trailer = ntohl(p[len-1]);
- break;
-
--- /dev/null
+ case 0:
+ *n32_bit_words_header = 1;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 1:
+ header[1] = htonl(h->stream_id);
+ *n32_bit_words_header = 2;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 2:
+ header[1] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[2] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ *n32_bit_words_header = 3;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 3:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ *n32_bit_words_header = 4;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 4:
+ header[1] = htonl(h->integer_secs);
+ *n32_bit_words_header = 2;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 5:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl(h->integer_secs);
+ *n32_bit_words_header = 3;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 6:
+ header[1] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[2] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ header[3] = htonl(h->integer_secs);
+ *n32_bit_words_header = 4;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 7:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ header[4] = htonl(h->integer_secs);
+ *n32_bit_words_header = 5;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 8:
+ header[1] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[2] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 3;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 9:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 4;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 10:
+ header[1] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[2] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[4] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 5;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 11:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ header[4] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[5] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 6;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 12:
+ header[1] = htonl(h->integer_secs);
+ header[2] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 4;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 13:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl(h->integer_secs);
+ header[3] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[4] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 5;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 14:
+ header[1] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[2] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ header[3] = htonl(h->integer_secs);
+ header[4] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[5] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 6;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 15:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ header[4] = htonl(h->integer_secs);
+ header[5] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[6] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 7;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 16:
+ *n32_bit_words_header = 1;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 17:
+ header[1] = htonl(h->stream_id);
+ *n32_bit_words_header = 2;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 18:
+ header[1] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[2] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ *n32_bit_words_header = 3;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 19:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ *n32_bit_words_header = 4;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 20:
+ header[1] = htonl(h->integer_secs);
+ *n32_bit_words_header = 2;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 21:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl(h->integer_secs);
+ *n32_bit_words_header = 3;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 22:
+ header[1] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[2] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ header[3] = htonl(h->integer_secs);
+ *n32_bit_words_header = 4;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 23:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ header[4] = htonl(h->integer_secs);
+ *n32_bit_words_header = 5;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 24:
+ header[1] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[2] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 3;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 25:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 4;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 26:
+ header[1] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[2] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[4] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 5;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 27:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ header[4] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[5] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 6;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 28:
+ header[1] = htonl(h->integer_secs);
+ header[2] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 4;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 29:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl(h->integer_secs);
+ header[3] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[4] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 5;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 30:
+ header[1] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[2] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ header[3] = htonl(h->integer_secs);
+ header[4] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[5] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 6;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 31:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ header[4] = htonl(h->integer_secs);
+ header[5] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[6] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 7;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
--- /dev/null
+#!/usr/bin/env python
+#
+# Copyright 2009 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+import sys
+
+# dispatch codeword bits
+HAS_STREAM_ID = 1 << 0;
+HAS_CLASS_ID = 1 << 1;
+HAS_INTEGER_SECS = 1 << 2;
+HAS_FRACTIONAL_SECS = 1 << 3;
+HAS_TRAILER = 1 << 4;
+
+def do_case(f, cw):
+
+ def do32(name, mask, index):
+ f.write(" ")
+ if cw & mask:
+ f.write("h->%s = ntohl(p[%d]);\n" % (name, index))
+ return 1
+ else:
+ f.write("h->%s = 0;\n" % (name,))
+ return 0
+
+ def do64(name, mask, index):
+ f.write(" ")
+ if cw & mask:
+ f.write("h->%s = ((uint64_t)(ntohl(p[%d])) << 32) | ntohl(p[%d]);\n" % (name, index, index+1))
+ return 2
+ else:
+ f.write("h->%s = 0;\n" % (name,))
+ return 0
+
+ def dotrailer(name, mask):
+ f.write(" ")
+ if cw & mask:
+ f.write("h->%s = ntohl(p[len-1]);\n" % (name,))
+ return 1
+ else:
+ f.write("h->%s = 0;\n" % (name,))
+ return 0
+
+ f.write(" case %d:\n" % (cw,))
+
+ index = 1
+ index += do32("stream_id", HAS_STREAM_ID, index)
+ index += do64("class_id", HAS_CLASS_ID, index)
+ index += do32("integer_secs", HAS_INTEGER_SECS, index)
+ index += do64("fractional_secs", HAS_FRACTIONAL_SECS, index)
+ dotrailer("trailer", HAS_TRAILER)
+
+ f.write(" break;\n\n")
+
+
+def main():
+ f = sys.stdout
+
+ for cw in range(32):
+ do_case(f, cw)
+
+
+if __name__ == '__main__':
+ main()
+++ /dev/null
-#!/usr/bin/env python
-#
-# Copyright 2009 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-
-import sys
-
-# dispatch codeword bits
-HAS_STREAM_ID = 1 << 0;
-HAS_CLASS_ID = 1 << 1;
-HAS_INTEGER_SECS = 1 << 2;
-HAS_FRACTIONAL_SECS = 1 << 3;
-HAS_TRAILER = 1 << 4;
-
-def do_case(f, cw):
-
- def do32(name, mask, index):
- f.write(" ")
- if cw & mask:
- f.write("h->%s = ntohl(p[%d]);\n" % (name, index))
- return 1
- else:
- f.write("h->%s = 0;\n" % (name,))
- return 0
-
- def do64(name, mask, index):
- f.write(" ")
- if cw & mask:
- f.write("h->%s = ((uint64_t)(ntohl(p[%d])) << 32) | ntohl(p[%d]);\n" % (name, index, index+1))
- return 2
- else:
- f.write("h->%s = 0;\n" % (name,))
- return 0
-
- def dotrailer(name, mask):
- f.write(" ")
- if cw & mask:
- f.write("h->%s = ntohl(p[len-1]);\n" % (name,))
- return 1
- else:
- f.write("h->%s = 0;\n" % (name,))
- return 0
-
- f.write(" case %d:\n" % (cw,))
-
- index = 1
- index += do32("stream_id", HAS_STREAM_ID, index)
- index += do64("class_id", HAS_CLASS_ID, index)
- index += do32("integer_secs", HAS_INTEGER_SECS, index)
- index += do64("fractional_secs", HAS_FRACTIONAL_SECS, index)
- dotrailer("trailer", HAS_TRAILER)
-
- f.write(" break;\n\n")
-
-
-def main():
- f = sys.stdout
-
- for cw in range(32):
- do_case(f, cw)
-
-
-if __name__ == '__main__':
- main()
--- /dev/null
+#!/usr/bin/env python
+#
+# Copyright 2009 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+import sys
+
+# dispatch codeword bits
+HAS_STREAM_ID = 1 << 0;
+HAS_CLASS_ID = 1 << 1;
+HAS_INTEGER_SECS = 1 << 2;
+HAS_FRACTIONAL_SECS = 1 << 3;
+HAS_TRAILER = 1 << 4;
+
+def do_case(f, cw):
+
+ def do32(name, mask, index):
+ if cw & mask:
+ f.write(" header[%d] = htonl(h->%s);\n" % (index, name))
+ return 1
+ return 0
+
+ def do64(name, mask, index):
+ if cw & mask:
+ f.write(" header[%d] = htonl((uint32_t)((h->%s >> 32) & 0xffffffff));\n" % (index, name))
+ f.write(" header[%d] = htonl((uint32_t)((h->%s >> 0) & 0xffffffff));\n" % (index+1, name))
+ return 2
+ return 0
+
+ def dolength(index):
+ f.write(" *n32_bit_words_header = %d;\n"%index)
+
+ def dotrailer(name, mask):
+ if cw & mask:
+ f.write(" trailer[%d] = htonl(h->%s);\n" % (0, name))
+ f.write(" *n32_bit_words_trailer = 1;\n")
+ return 1
+ else:
+ f.write(" *n32_bit_words_trailer = 0;\n")
+ return 0
+
+ f.write(" case %d:\n" % (cw,))
+
+ index = 1
+ index += do32("stream_id", HAS_STREAM_ID, index)
+ index += do64("class_id", HAS_CLASS_ID, index)
+ index += do32("integer_secs", HAS_INTEGER_SECS, index)
+ index += do64("fractional_secs", HAS_FRACTIONAL_SECS, index)
+ dolength(index)
+ dotrailer("trailer", HAS_TRAILER)
+
+ f.write(" break;\n\n")
+
+
+def main():
+ f = sys.stdout
+
+ for cw in range(32):
+ do_case(f, cw)
+
+
+if __name__ == '__main__':
+ main()