libosmocore
0.9.3
Osmocom core library
|
00001 /* 00002 * crc16gen.h 00003 * 00004 * Copyright (C) 2011 Sylvain Munaut <tnt@246tNt.com> 00005 * 00006 * All Rights Reserved 00007 * 00008 * This program is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License along 00019 * with this program; if not, write to the Free Software Foundation, Inc., 00020 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00021 */ 00022 00023 #pragma once 00024 00034 #include <stdint.h> 00035 #include <osmocom/core/bits.h> 00036 00037 00039 struct osmo_crc16gen_code { 00040 int bits; 00041 uint16_t poly; 00042 uint16_t init; 00043 uint16_t remainder; 00044 }; 00045 00046 uint16_t osmo_crc16gen_compute_bits(const struct osmo_crc16gen_code *code, 00047 const ubit_t *in, int len); 00048 int osmo_crc16gen_check_bits(const struct osmo_crc16gen_code *code, 00049 const ubit_t *in, int len, const ubit_t *crc_bits); 00050 void osmo_crc16gen_set_bits(const struct osmo_crc16gen_code *code, 00051 const ubit_t *in, int len, ubit_t *crc_bits); 00052 00053 00056 /* vim: set syntax=c: */