summaryrefslogtreecommitdiff
path: root/mcast_image.h
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2007-08-14 00:50:39 +0800
committerDavid Woodhouse <dwmw2@infradead.org>2007-08-14 00:50:39 +0800
commit01cb1f06df65fefad36143fa3a55d69aecf4a1c0 (patch)
tree03468db2abc95a10e11a19ca015d1888bd401576 /mcast_image.h
parent34a3278c85e883e3279b14acd57b02610c1039e3 (diff)
Import FEC code from Luigi Rizzo's RMDP
Paper: http://info.iet.unipi.it/~luigi/mccr6.ps.gz Code: http://info.iet.unipi.it/~luigi/rmdp980703.tgz Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'mcast_image.h')
-rw-r--r--mcast_image.h33
1 files changed, 31 insertions, 2 deletions
diff --git a/mcast_image.h b/mcast_image.h
index 96aa752..26c675e 100644
--- a/mcast_image.h
+++ b/mcast_image.h
@@ -1,14 +1,16 @@
#include <stdint.h>
-#define PKT_SIZE 1400
+#define PKT_SIZE 1410
struct image_pkt_hdr {
uint32_t resend;
uint32_t totcrc;
uint32_t nr_blocks;
uint32_t blocksize;
+ uint32_t block_crc;
uint32_t block_nr;
- uint32_t block_ofs;
+ uint16_t pkt_nr;
+ uint16_t nr_pkts;
uint32_t thislen;
uint32_t thiscrc;
};
@@ -17,3 +19,30 @@ struct image_pkt {
struct image_pkt_hdr hdr;
unsigned char data[PKT_SIZE];
};
+
+struct fec_parms;
+
+/* k - number of actual data packets
+ * n - total number of packets including data and redundant packets
+ * (actual packet size isn't relevant here) */
+struct fec_parms *fec_new(int k, int n);
+void fec_free(struct fec_parms *p);
+
+/* src - array of (n) pointers to data packets
+ * fec - buffer for packet to be generated
+ * index - index of packet to be generated (0 <= index < n)
+ * sz - data packet size
+ */
+void fec_encode(struct fec_parms *code, unsigned char *src[],
+ unsigned char *fec, int index, int sz);
+
+/* data - array of (k) pointers to data packets, in arbitrary order (see i)
+ * i - indices of (data) packets
+ * sz - data packet size
+ *
+ * Will never fail as long as you give it (k) individual data packets.
+ * Will re-order the (data) pointers but not the indices -- data packets
+ * are ordered on return.
+ */
+int fec_decode(struct fec_parms *code, unsigned char *data[],
+ int i[], int sz);