1 /* 2 * Provides routines for encoding and decoding the extended Golay 3 * (24,12,8) code. 4 * 5 * This implementation will detect up to 4 errors in a codeword (without 6 * being able to correct them); it will correct up to 3 errors. 7 * 8 * We use guint32s to hold the 24-bit codewords, with the data part in 9 * the bottom 12 bits and the parity in bits 12-23. 10 * 11 * 12 * Wireshark - Network traffic analyzer 13 * By Gerald Combs <gerald@wireshark.org> 14 * Copyright 1998 Gerald Combs 15 * 16 * SPDX-License-Identifier: GPL-2.0-or-later 17 */ 18 #ifndef __GOLAY_H__ 19 #define __GOLAY_H__ 20 21 #include "ws_symbol_export.h" 22 23 /* encodes a 12-bit word to a 24-bit codeword 24 */ 25 WS_DLL_PUBLIC 26 guint32 golay_encode(guint w); 27 28 /* return a mask showing the bits which are in error in a received 29 * 24-bit codeword, or -1 if 4 errors were detected. 30 */ 31 WS_DLL_PUBLIC 32 gint32 golay_errors(guint32 codeword); 33 34 /* decode a received codeword. Up to 3 errors are corrected for; 4 35 errors are detected as uncorrectable (return -1); 5 or more errors 36 cause an incorrect correction. 37 */ 38 WS_DLL_PUBLIC 39 gint golay_decode(guint32 w); 40 41 #endif 42 43 /* 44 * Editor modelines 45 * 46 * Local Variables: 47 * c-basic-offset: 4 48 * tab-width: 8 49 * indent-tabs-mode: nil 50 * End: 51 * 52 * ex: set shiftwidth=4 tabstop=8 expandtab: 53 * :indentSize=4:tabSize=8:noTabs=true: 54 */ 55