\doxysection{isdnhdlc.\+h}
\label{isdnhdlc_8h_source}\index{include/osmocom/core/isdnhdlc.h@{include/osmocom/core/isdnhdlc.h}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 \textcolor{comment}{/*}}
\DoxyCodeLine{2 \textcolor{comment}{ * isdnhdlc.h  -\/-\/  General purpose ISDN HDLC decoder.}}
\DoxyCodeLine{3 \textcolor{comment}{ *}}
\DoxyCodeLine{4 \textcolor{comment}{ * Implementation of a HDLC decoder/encoder in software.}}
\DoxyCodeLine{5 \textcolor{comment}{ * Necessary because some ISDN devices don't have HDLC}}
\DoxyCodeLine{6 \textcolor{comment}{ * controllers.}}
\DoxyCodeLine{7 \textcolor{comment}{ *}}
\DoxyCodeLine{8 \textcolor{comment}{ * Copyright (C)}}
\DoxyCodeLine{9 \textcolor{comment}{ *      2009    Karsten Keil            <keil@b1-\/systems.de>}}
\DoxyCodeLine{10 \textcolor{comment}{ *      2002    Wolfgang Mües           <wolfgang@iksw-\/muees.de>}}
\DoxyCodeLine{11 \textcolor{comment}{ *      2001    Frode Isaksen           <fisaksen@bewan.com>}}
\DoxyCodeLine{12 \textcolor{comment}{ *      2001    Kai Germaschewski       <kai.germaschewski@gmx.de>}}
\DoxyCodeLine{13 \textcolor{comment}{ *}}
\DoxyCodeLine{14 \textcolor{comment}{ * This program is free software; you can redistribute it and/or modify}}
\DoxyCodeLine{15 \textcolor{comment}{ * it under the terms of the GNU General Public License as published by}}
\DoxyCodeLine{16 \textcolor{comment}{ * the Free Software Foundation; either version 2 of the License, or}}
\DoxyCodeLine{17 \textcolor{comment}{ * (at your option) any later version.}}
\DoxyCodeLine{18 \textcolor{comment}{ *}}
\DoxyCodeLine{19 \textcolor{comment}{ * This program is distributed in the hope that it will be useful,}}
\DoxyCodeLine{20 \textcolor{comment}{ * but WITHOUT ANY WARRANTY; without even the implied warranty of}}
\DoxyCodeLine{21 \textcolor{comment}{ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the}}
\DoxyCodeLine{22 \textcolor{comment}{ * GNU General Public License for more details.}}
\DoxyCodeLine{23 \textcolor{comment}{ */}}
\DoxyCodeLine{24 }
\DoxyCodeLine{25 \textcolor{preprocessor}{\#pragma once}}
\DoxyCodeLine{26 }
\DoxyCodeLine{27 \textcolor{preprocessor}{\#include <stdint.h>}}
\DoxyCodeLine{28 }
\DoxyCodeLine{29 \textcolor{keyword}{struct }osmo\_isdnhdlc\_vars \{}
\DoxyCodeLine{30         \textcolor{keywordtype}{int} bit\_shift;}
\DoxyCodeLine{31         \textcolor{keywordtype}{int} hdlc\_bits1;}
\DoxyCodeLine{32         \textcolor{keywordtype}{int} data\_bits;}
\DoxyCodeLine{33         \textcolor{keywordtype}{int} ffbit\_shift;     \textcolor{comment}{/* encoding only */}}
\DoxyCodeLine{34         \textcolor{keywordtype}{int} state;}
\DoxyCodeLine{35         \textcolor{keywordtype}{int} dstpos;}
\DoxyCodeLine{36 }
\DoxyCodeLine{37         uint16\_t crc;}
\DoxyCodeLine{38 }
\DoxyCodeLine{39         uint8\_t cbin;}
\DoxyCodeLine{40         uint8\_t shift\_reg;}
\DoxyCodeLine{41         uint8\_t ffvalue;}
\DoxyCodeLine{42 }
\DoxyCodeLine{43         \textcolor{comment}{/* set if transferring data */}}
\DoxyCodeLine{44         uint32\_t data\_received:1;}
\DoxyCodeLine{45         \textcolor{comment}{/* set if D channel (send idle instead of flags) */}}
\DoxyCodeLine{46         uint32\_t dchannel:1;}
\DoxyCodeLine{47         \textcolor{comment}{/* set if 56K adaptation */}}
\DoxyCodeLine{48         uint32\_t do\_adapt56:1;}
\DoxyCodeLine{49         \textcolor{comment}{/* set if in closing phase (need to send CRC + flag) */}}
\DoxyCodeLine{50         uint32\_t do\_closing:1;}
\DoxyCodeLine{51         \textcolor{comment}{/* set if data is bitreverse */}}
\DoxyCodeLine{52         uint32\_t do\_bitreverse:1;}
\DoxyCodeLine{53 \};}
\DoxyCodeLine{54 }
\DoxyCodeLine{55 \textcolor{comment}{/* Feature Flags */}}
\DoxyCodeLine{56 \textcolor{preprocessor}{\#define OSMO\_HDLC\_F\_56KBIT      0x01}}
\DoxyCodeLine{57 \textcolor{preprocessor}{\#define OSMO\_HDLC\_F\_DCHANNEL    0x02}}
\DoxyCodeLine{58 \textcolor{preprocessor}{\#define OSMO\_HDLC\_F\_BITREVERSE  0x04}}
\DoxyCodeLine{59 }
\DoxyCodeLine{60 \textcolor{comment}{/*}}
\DoxyCodeLine{61 \textcolor{comment}{  The return value from isdnhdlc\_decode is}}
\DoxyCodeLine{62 \textcolor{comment}{  the frame length, 0 if no complete frame was decoded,}}
\DoxyCodeLine{63 \textcolor{comment}{  or a negative error number}}
\DoxyCodeLine{64 \textcolor{comment}{*/}}
\DoxyCodeLine{65 \textcolor{preprocessor}{\#define OSMO\_HDLC\_FRAMING\_ERROR     1}}
\DoxyCodeLine{66 \textcolor{preprocessor}{\#define OSMO\_HDLC\_CRC\_ERROR         2}}
\DoxyCodeLine{67 \textcolor{preprocessor}{\#define OSMO\_HDLC\_LENGTH\_ERROR      3}}
\DoxyCodeLine{68 }
\DoxyCodeLine{69 \textcolor{keyword}{extern} \textcolor{keywordtype}{void}     osmo\_isdnhdlc\_rcv\_init(\textcolor{keyword}{struct} osmo\_isdnhdlc\_vars *hdlc, uint32\_t features);}
\DoxyCodeLine{70 }
\DoxyCodeLine{71 \textcolor{keyword}{extern} \textcolor{keywordtype}{int}      osmo\_isdnhdlc\_decode(\textcolor{keyword}{struct} osmo\_isdnhdlc\_vars *hdlc, \textcolor{keyword}{const} uint8\_t *src,}
\DoxyCodeLine{72                                      \textcolor{keywordtype}{int} slen, \textcolor{keywordtype}{int} *count, uint8\_t *dst, \textcolor{keywordtype}{int} dsize);}
\DoxyCodeLine{73 }
\DoxyCodeLine{74 \textcolor{keyword}{extern} \textcolor{keywordtype}{void}     osmo\_isdnhdlc\_out\_init(\textcolor{keyword}{struct} osmo\_isdnhdlc\_vars *hdlc, uint32\_t features);}
\DoxyCodeLine{75 }
\DoxyCodeLine{76 \textcolor{keyword}{extern} \textcolor{keywordtype}{int}      osmo\_isdnhdlc\_encode(\textcolor{keyword}{struct} osmo\_isdnhdlc\_vars *hdlc, \textcolor{keyword}{const} uint8\_t *src,}
\DoxyCodeLine{77                                      uint16\_t slen, \textcolor{keywordtype}{int} *count, uint8\_t *dst, \textcolor{keywordtype}{int} dsize);}

\end{DoxyCode}
