]> git.rkrishnan.org Git - tahoe-lafs/zfec.git/blob - zfec/zfec/fec.h
zfec: update licensing and attribution docs
[tahoe-lafs/zfec.git] / zfec / zfec / fec.h
1 /**
2  * zfec -- fast forward error correction library with Python interface
3  */
4
5 #include <stddef.h>
6
7 typedef unsigned char gf;
8
9 typedef struct {
10   unsigned long magic;
11   unsigned k, n;                     /* parameters of the code */
12   gf* enc_matrix;
13 } fec_t;
14
15 /**
16  * param k the number of blocks required to reconstruct
17  * param m the total number of blocks created
18  */
19 fec_t* fec_new(unsigned k, unsigned m);
20 void fec_free(fec_t* p);
21
22 /**
23  * @param inpkts the "primary blocks" i.e. the chunks of the input data
24  * @param fecs buffers into which the secondary blocks will be written
25  * @param block_nums the numbers of the desired blocks -- including both primary blocks (the id < k) which fec_encode() ignores and check blocks (the id >= k) which fec_encode() will produce and store into the buffers of the fecs parameter
26  * @param num_block_nums the length of the block_nums array
27  */
28 void fec_encode(const fec_t* code, const gf*restrict const*restrict const src, gf*restrict const*restrict const fecs, const unsigned*restrict const block_nums, size_t num_block_nums, size_t sz);
29
30 /**
31  * @param inpkts an array of packets (size k)
32  * @param outpkts an array of buffers into which the reconstructed output packets will be written (only packets which are not present in the inpkts input will be reconstructed and written to outpkts)
33  * @param index an array of the blocknums of the packets in inpkts
34  * @param sz size of a packet in bytes
35  */
36 void fec_decode(const fec_t* code, const gf*restrict const*restrict const inpkts, gf*restrict const*restrict const outpkts, const unsigned*restrict const index, size_t sz);
37
38
39 /**
40  * zfec -- fast forward error correction library with Python interface
41  * 
42  * Copyright (C) 2007 Allmydata, Inc.
43  * Author: Zooko Wilcox-O'Hearn
44  * 
45  * This file is part of zfec.
46  * 
47  * See README.txt for licensing information.
48  */
49
50 /*
51  * Much of this work is derived from the "fec" software by Luigi Rizzo, et 
52  * al., the copyright notice and licence terms of which are included below 
53  * for reference.
54  * 
55  * fec.h -- forward error correction based on Vandermonde matrices
56  * 980614
57  * (C) 1997-98 Luigi Rizzo (luigi@iet.unipi.it)
58  *
59  * Portions derived from code by Phil Karn (karn@ka9q.ampr.org),
60  * Robert Morelos-Zaragoza (robert@spectra.eng.hawaii.edu) and Hari
61  * Thirumoorthy (harit@spectra.eng.hawaii.edu), Aug 1995
62  *
63  * Modifications by Dan Rubenstein (see Modifications.txt for 
64  * their description.
65  * Modifications (C) 1998 Dan Rubenstein (drubenst@cs.umass.edu)
66  *
67  * Redistribution and use in source and binary forms, with or without
68  * modification, are permitted provided that the following conditions
69  * are met:
70
71  * 1. Redistributions of source code must retain the above copyright
72  *    notice, this list of conditions and the following disclaimer.
73  * 2. Redistributions in binary form must reproduce the above
74  *    copyright notice, this list of conditions and the following
75  *    disclaimer in the documentation and/or other materials
76  *    provided with the distribution.
77  *
78  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND
79  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
80  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
81  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS
82  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
83  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
84  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
85  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
86  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
87  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
88  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
89  * OF SUCH DAMAGE.
90  */
91