\doxysection{crc16.\+h}
\label{crc16_8h_source}\index{include/osmocom/core/crc16.h@{include/osmocom/core/crc16.h}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 }
\DoxyCodeLine{7 \textcolor{comment}{/*}}
\DoxyCodeLine{8 \textcolor{comment}{ *      crc16.h -\/ CRC-\/16 routine}}
\DoxyCodeLine{9 \textcolor{comment}{ *}}
\DoxyCodeLine{10 \textcolor{comment}{ * Implements the standard CRC-\/16:}}
\DoxyCodeLine{11 \textcolor{comment}{ * -\/ Width 16}}
\DoxyCodeLine{12 \textcolor{comment}{ * -\/ Poly  0x8005 (x\string^16 + x\string^15 + x\string^2 + 1)}}
\DoxyCodeLine{13 \textcolor{comment}{ * -\/ Init  0}}
\DoxyCodeLine{14 \textcolor{comment}{ *}}
\DoxyCodeLine{15 \textcolor{comment}{ * Copyright (c) 2005 Ben Gardner <bgardner@wabtec.com>}}
\DoxyCodeLine{16 \textcolor{comment}{ *}}
\DoxyCodeLine{17 \textcolor{comment}{ * This source code is licensed under the GNU General Public License,}}
\DoxyCodeLine{18 \textcolor{comment}{ * Version 2. See the file COPYING for more details.}}
\DoxyCodeLine{19 \textcolor{comment}{ */}}
\DoxyCodeLine{20 }
\DoxyCodeLine{21 \textcolor{preprocessor}{\#pragma once}}
\DoxyCodeLine{22 }
\DoxyCodeLine{23 \textcolor{preprocessor}{\#include <stdint.h>}}
\DoxyCodeLine{24 }
\DoxyCodeLine{25 \textcolor{preprocessor}{\#include <sys/types.h>}}
\DoxyCodeLine{26 }
\DoxyCodeLine{27 \textcolor{keyword}{extern} uint16\_t \textcolor{keyword}{const} osmo\_crc16\_table[256];}
\DoxyCodeLine{28 }
\DoxyCodeLine{29 \textcolor{keyword}{extern} uint16\_t osmo\_crc16(uint16\_t crc, \textcolor{keyword}{const} uint8\_t *buffer, \textcolor{keywordtype}{size\_t} len);}
\DoxyCodeLine{30 }
\DoxyCodeLine{32 \textcolor{keyword}{static} \textcolor{keyword}{inline} uint16\_t osmo\_crc16\_byte(uint16\_t crc, \textcolor{keyword}{const} uint8\_t data)}
\DoxyCodeLine{33 \{}
\DoxyCodeLine{34         \textcolor{keywordflow}{return} (crc >> 8) \string^ osmo\_crc16\_table[(crc \string^ data) \& 0xff];}
\DoxyCodeLine{35 \}}
\DoxyCodeLine{36 }
\DoxyCodeLine{37 }
\DoxyCodeLine{38 }
\DoxyCodeLine{39 \textcolor{keyword}{extern} uint16\_t \textcolor{keyword}{const} osmo\_crc16\_ccitt\_table[256];}
\DoxyCodeLine{40 }
\DoxyCodeLine{41 \textcolor{keyword}{extern} uint16\_t osmo\_crc16\_ccitt(uint16\_t crc, \textcolor{keyword}{const} uint8\_t *buffer, \textcolor{keywordtype}{size\_t} len);}
\DoxyCodeLine{42 }
\DoxyCodeLine{44 \textcolor{keyword}{static} \textcolor{keyword}{inline} uint16\_t osmo\_crc16\_ccitt\_byte(uint16\_t crc, \textcolor{keyword}{const} uint8\_t data)}
\DoxyCodeLine{45 \{}
\DoxyCodeLine{46         \textcolor{keywordflow}{return} (crc >> 8) \string^ osmo\_crc16\_ccitt\_table[(crc \string^ data) \& 0xff];}
\DoxyCodeLine{47 \}}
\DoxyCodeLine{48 }

\end{DoxyCode}
