libosmocore  0.9.3
Osmocom core library
include/osmocom/core/crc8gen.h
Go to the documentation of this file.
00001 /*
00002  * crc8gen.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_crc8gen_code {
00040         int bits;           
00041         uint8_t poly;      
00042         uint8_t init;      
00043         uint8_t remainder; 
00044 };
00045 
00046 uint8_t osmo_crc8gen_compute_bits(const struct osmo_crc8gen_code *code,
00047                                     const ubit_t *in, int len);
00048 int osmo_crc8gen_check_bits(const struct osmo_crc8gen_code *code,
00049                              const ubit_t *in, int len, const ubit_t *crc_bits);
00050 void osmo_crc8gen_set_bits(const struct osmo_crc8gen_code *code,
00051                             const ubit_t *in, int len, ubit_t *crc_bits);
00052 
00053 
00056 /* vim: set syntax=c: */