]> git.rkrishnan.org Git - tahoe-lafs/zfec.git/blob - zfec/zfec/fec.h
zfec: yet another tweak to the licence
[tahoe-lafs/zfec.git] / zfec / zfec / fec.h
1 /**
2  * zfec -- fast forward error correction library with Python interface
3  */
4
5 typedef unsigned char gf;
6
7 typedef struct {
8   unsigned long magic;
9   unsigned k, n;                     /* parameters of the code */
10   gf* enc_matrix;
11 } fec_t;
12
13 /**
14  * param k the number of blocks required to reconstruct
15  * param m the total number of blocks created
16  */
17 fec_t* fec_new(unsigned k, unsigned m);
18 void fec_free(fec_t* p);
19
20 /**
21  * @param inpkts the "primary blocks" i.e. the chunks of the input data
22  * @param fecs buffers into which the secondary blocks will be written
23  * @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
24  * @param num_block_nums the length of the block_nums array
25  */
26 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);
27
28 /**
29  * @param inpkts an array of packets (size k)
30  * @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)
31  * @param index an array of the blocknums of the packets in inpkts
32  * @param sz size of a packet in bytes
33  */
34 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);
35
36
37 /**
38  * zfec -- fast forward error correction library with Python interface
39  * 
40  * Copyright (C) 2007 Allmydata, Inc.
41  * Author: Zooko Wilcox-O'Hearn
42  * 
43  * This file is part of zfec.
44  * 
45  * This program is free software; you can redistribute it and/or modify it
46  * under the terms of the GNU General Public License as published by the Free
47  * Software Foundation; either version 2 of the License, or (at your option)
48  * any later version, with the added permission that, if you become obligated
49  * to release a derived work under this licence (as per section 2.b), you may
50  * delay the fulfillment of this obligation for up to 12 months.  See the file
51  * COPYING for details.
52  *
53  * If you would like to inquire about a commercial relationship with Allmydata,
54  * Inc., please contact partnerships@allmydata.com and visit
55  * http://allmydata.com/.
56  * 
57  * This program is distributed in the hope that it will be useful, but WITHOUT
58  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
59  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
60  * more details.
61  */
62
63 /*
64  * Much of this work is derived from the "fec" software by Luigi Rizzo, et 
65  * al., the copyright notice and licence terms of which are included below 
66  * for reference.
67  * 
68  * fec.h -- forward error correction based on Vandermonde matrices
69  * 980614
70  * (C) 1997-98 Luigi Rizzo (luigi@iet.unipi.it)
71  *
72  * Portions derived from code by Phil Karn (karn@ka9q.ampr.org),
73  * Robert Morelos-Zaragoza (robert@spectra.eng.hawaii.edu) and Hari
74  * Thirumoorthy (harit@spectra.eng.hawaii.edu), Aug 1995
75  *
76  * Modifications by Dan Rubenstein (see Modifications.txt for 
77  * their description.
78  * Modifications (C) 1998 Dan Rubenstein (drubenst@cs.umass.edu)
79  *
80  * Redistribution and use in source and binary forms, with or without
81  * modification, are permitted provided that the following conditions
82  * are met:
83
84  * 1. Redistributions of source code must retain the above copyright
85  *    notice, this list of conditions and the following disclaimer.
86  * 2. Redistributions in binary form must reproduce the above
87  *    copyright notice, this list of conditions and the following
88  *    disclaimer in the documentation and/or other materials
89  *    provided with the distribution.
90  *
91  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND
92  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
93  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
94  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS
95  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
96  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
97  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
98  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
99  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
100  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
101  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
102  * OF SUCH DAMAGE.
103  */
104