summaryrefslogtreecommitdiff
path: root/vrt/lib
diff options
context:
space:
mode:
authorJosh Blum2009-12-17 16:48:54 -0800
committerJosh Blum2009-12-17 18:01:25 -0800
commitfc4fa0a1894f0f85be1a76e48b922effb3d5dd9b (patch)
treeb7ed4d7dedf55c0340fa93d793daa7fb3cd13261 /vrt/lib
parent754299932325a5b6c02587cf7dcf444b3b1080ae (diff)
downloadgnuradio-fc4fa0a1894f0f85be1a76e48b922effb3d5dd9b.tar.gz
gnuradio-fc4fa0a1894f0f85be1a76e48b922effb3d5dd9b.tar.bz2
gnuradio-fc4fa0a1894f0f85be1a76e48b922effb3d5dd9b.zip
Added unparse capability to the vrt expanded header.
Unparse can fill in a vrt header and trailer from an expanded header.
Diffstat (limited to 'vrt/lib')
-rw-r--r--vrt/lib/Makefile.am6
-rw-r--r--vrt/lib/expanded_header.cc18
-rw-r--r--vrt/lib/expanded_header_parse_switch_body.h (renamed from vrt/lib/expanded_header_switch_body.h)0
-rw-r--r--vrt/lib/expanded_header_unparse_switch_body.h272
-rwxr-xr-xvrt/lib/gen_parse_switch_body.py (renamed from vrt/lib/gen_switch_body.py)0
-rwxr-xr-xvrt/lib/gen_unparse_switch_body.py79
6 files changed, 372 insertions, 3 deletions
diff --git a/vrt/lib/Makefile.am b/vrt/lib/Makefile.am
index 3a758eeac..f2fcce0c6 100644
--- a/vrt/lib/Makefile.am
+++ b/vrt/lib/Makefile.am
@@ -42,9 +42,11 @@ libvrt_la_LIBADD =
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
diff --git a/vrt/lib/expanded_header.cc b/vrt/lib/expanded_header.cc
index bd1d92e53..64e97ef97 100644
--- a/vrt/lib/expanded_header.cc
+++ b/vrt/lib/expanded_header.cc
@@ -71,6 +71,22 @@ namespace vrt {
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
@@ -109,7 +125,7 @@ namespace vrt {
// 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;
diff --git a/vrt/lib/expanded_header_switch_body.h b/vrt/lib/expanded_header_parse_switch_body.h
index 40e575c2c..40e575c2c 100644
--- a/vrt/lib/expanded_header_switch_body.h
+++ b/vrt/lib/expanded_header_parse_switch_body.h
diff --git a/vrt/lib/expanded_header_unparse_switch_body.h b/vrt/lib/expanded_header_unparse_switch_body.h
new file mode 100644
index 000000000..ca6e14989
--- /dev/null
+++ b/vrt/lib/expanded_header_unparse_switch_body.h
@@ -0,0 +1,272 @@
+ 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;
+
diff --git a/vrt/lib/gen_switch_body.py b/vrt/lib/gen_parse_switch_body.py
index 105fa76a7..105fa76a7 100755
--- a/vrt/lib/gen_switch_body.py
+++ b/vrt/lib/gen_parse_switch_body.py
diff --git a/vrt/lib/gen_unparse_switch_body.py b/vrt/lib/gen_unparse_switch_body.py
new file mode 100755
index 000000000..6c7cd01b3
--- /dev/null
+++ b/vrt/lib/gen_unparse_switch_body.py
@@ -0,0 +1,79 @@
+#!/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()