\doxysection{lapd\+\_\+core.\+h}
\label{lapd__core_8h_source}\index{include/osmocom/isdn/lapd\_core.h@{include/osmocom/isdn/lapd\_core.h}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 }
\DoxyCodeLine{4 \textcolor{preprocessor}{\#pragma once}}
\DoxyCodeLine{5 }
\DoxyCodeLine{6 \textcolor{preprocessor}{\#include <stdint.h>}}
\DoxyCodeLine{7 }
\DoxyCodeLine{8 \textcolor{preprocessor}{\#include <osmocom/core/timer.h>}}
\DoxyCodeLine{9 \textcolor{preprocessor}{\#include <osmocom/core/msgb.h>}}
\DoxyCodeLine{10 \textcolor{preprocessor}{\#include <osmocom/gsm/prim.h>}}
\DoxyCodeLine{11 }
\DoxyCodeLine{17 \textcolor{preprocessor}{\#define LOGDL(dl, level, fmt, args...) \(\backslash\)}}
\DoxyCodeLine{18 \textcolor{preprocessor}{        LOGP(DLLAPD, level, "{}(\%s) "{}}  fmt, (dl)-\/>name, \#\# args)}
\DoxyCodeLine{19 }
\DoxyCodeLine{21 \textcolor{keyword}{enum} osmo\_dl\_prim \{}
\DoxyCodeLine{22         PRIM\_DL\_UNIT\_DATA,     }
\DoxyCodeLine{23         PRIM\_DL\_DATA,               }
\DoxyCodeLine{24         PRIM\_DL\_EST,         }
\DoxyCodeLine{25         PRIM\_DL\_REL,         }
\DoxyCodeLine{26         PRIM\_DL\_SUSP,               }
\DoxyCodeLine{27         PRIM\_DL\_RES,         }
\DoxyCodeLine{28         PRIM\_DL\_RECON,             }
\DoxyCodeLine{29         PRIM\_MDL\_ERROR,           }
\DoxyCodeLine{30 \};}
\DoxyCodeLine{31 }
\DoxyCodeLine{32 \textcolor{comment}{/* Uses the same values as RLL, so no conversion for GSM is required. */}}
\DoxyCodeLine{33 \textcolor{preprocessor}{\#define MDL\_CAUSE\_T200\_EXPIRED          0x01}}
\DoxyCodeLine{34 \textcolor{preprocessor}{\#define MDL\_CAUSE\_REEST\_REQ             0x02}}
\DoxyCodeLine{35 \textcolor{preprocessor}{\#define MDL\_CAUSE\_UNSOL\_UA\_RESP         0x03}}
\DoxyCodeLine{36 \textcolor{preprocessor}{\#define MDL\_CAUSE\_UNSOL\_DM\_RESP         0x04}}
\DoxyCodeLine{37 \textcolor{preprocessor}{\#define MDL\_CAUSE\_UNSOL\_DM\_RESP\_MF      0x05}}
\DoxyCodeLine{38 \textcolor{preprocessor}{\#define MDL\_CAUSE\_UNSOL\_SPRV\_RESP       0x06}}
\DoxyCodeLine{39 \textcolor{preprocessor}{\#define MDL\_CAUSE\_SEQ\_ERR               0x07}}
\DoxyCodeLine{40 \textcolor{preprocessor}{\#define MDL\_CAUSE\_UFRM\_INC\_PARAM        0x08}}
\DoxyCodeLine{41 \textcolor{preprocessor}{\#define MDL\_CAUSE\_SFRM\_INC\_PARAM        0x09}}
\DoxyCodeLine{42 \textcolor{preprocessor}{\#define MDL\_CAUSE\_IFRM\_INC\_MBITS        0x0a}}
\DoxyCodeLine{43 \textcolor{preprocessor}{\#define MDL\_CAUSE\_IFRM\_INC\_LEN          0x0b}}
\DoxyCodeLine{44 \textcolor{preprocessor}{\#define MDL\_CAUSE\_FRM\_UNIMPL            0x0c}}
\DoxyCodeLine{45 \textcolor{preprocessor}{\#define MDL\_CAUSE\_SABM\_MF               0x0d}}
\DoxyCodeLine{46 \textcolor{preprocessor}{\#define MDL\_CAUSE\_SABM\_INFO\_NOTALL      0x0e}}
\DoxyCodeLine{47 \textcolor{preprocessor}{\#define MDL\_CAUSE\_FRMR                  0x0f}}
\DoxyCodeLine{48 }
\DoxyCodeLine{50 \textcolor{keyword}{struct }mdl\_error\_ind\_param \{}
\DoxyCodeLine{51         uint8\_t cause;             }
\DoxyCodeLine{52 \};}
\DoxyCodeLine{53 }
\DoxyCodeLine{55 \textcolor{keyword}{struct }dl\_rel\_req\_param \{}
\DoxyCodeLine{56         uint8\_t mode;               }
\DoxyCodeLine{57 \};}
\DoxyCodeLine{58 }
\DoxyCodeLine{60 \textcolor{keyword}{struct }osmo\_dlsap\_prim \{}
\DoxyCodeLine{61         \textcolor{keyword}{struct }osmo\_prim\_hdr oph; }
\DoxyCodeLine{62         \textcolor{keyword}{union }\{}
\DoxyCodeLine{63                 \textcolor{keyword}{struct }mdl\_error\_ind\_param error\_ind;}
\DoxyCodeLine{64                 \textcolor{keyword}{struct }dl\_rel\_req\_param rel\_req;}
\DoxyCodeLine{65         \} u;                   }
\DoxyCodeLine{66 \};}
\DoxyCodeLine{67 }
\DoxyCodeLine{69 \textcolor{keyword}{enum} lapd\_mode \{}
\DoxyCodeLine{70         LAPD\_MODE\_USER,           }
\DoxyCodeLine{71         LAPD\_MODE\_NETWORK,     }
\DoxyCodeLine{72 \};}
\DoxyCodeLine{73 }
\DoxyCodeLine{75 \textcolor{keyword}{enum} lapd\_state \{}
\DoxyCodeLine{76         LAPD\_STATE\_NULL = 0,}
\DoxyCodeLine{77         LAPD\_STATE\_TEI\_UNASS,}
\DoxyCodeLine{78         LAPD\_STATE\_ASS\_TEI\_WAIT,}
\DoxyCodeLine{79         LAPD\_STATE\_EST\_TEI\_WAIT,}
\DoxyCodeLine{80         LAPD\_STATE\_IDLE,}
\DoxyCodeLine{81         LAPD\_STATE\_SABM\_SENT,}
\DoxyCodeLine{82         LAPD\_STATE\_DISC\_SENT,}
\DoxyCodeLine{83         LAPD\_STATE\_MF\_EST,}
\DoxyCodeLine{84         LAPD\_STATE\_TIMER\_RECOV,}
\DoxyCodeLine{85 \};}
\DoxyCodeLine{86 }
\DoxyCodeLine{88 \textcolor{preprocessor}{\#define LAPD\_F\_RTS              0x0001}}
\DoxyCodeLine{89 \textcolor{preprocessor}{\#define LAPD\_F\_DROP\_2ND\_REJ     0x0002}}
\DoxyCodeLine{90 }
\DoxyCodeLine{92 \textcolor{keyword}{enum} lapd\_t200\_rts \{}
\DoxyCodeLine{93         LAPD\_T200\_RTS\_OFF = 0,}
\DoxyCodeLine{94         LAPD\_T200\_RTS\_PENDING,}
\DoxyCodeLine{95         LAPD\_T200\_RTS\_RUNNING,}
\DoxyCodeLine{96 \};}
\DoxyCodeLine{97 }
\DoxyCodeLine{99 \textcolor{keyword}{enum} lapd\_format \{}
\DoxyCodeLine{100         LAPD\_FORM\_UKN = 0,}
\DoxyCodeLine{101         LAPD\_FORM\_I,}
\DoxyCodeLine{102         LAPD\_FORM\_S,}
\DoxyCodeLine{103         LAPD\_FORM\_U,}
\DoxyCodeLine{104 \};}
\DoxyCodeLine{105 }
\DoxyCodeLine{107 \textcolor{keyword}{struct }lapd\_msg\_ctx \{}
\DoxyCodeLine{108         \textcolor{keyword}{struct }lapd\_datalink *dl;}
\DoxyCodeLine{109         \textcolor{keywordtype}{int} n201;}
\DoxyCodeLine{110         \textcolor{comment}{/* address */}}
\DoxyCodeLine{111         uint8\_t cr;}
\DoxyCodeLine{112         uint8\_t sapi;}
\DoxyCodeLine{113         uint8\_t tei;}
\DoxyCodeLine{114         uint8\_t lpd;}
\DoxyCodeLine{115         \textcolor{comment}{/* control */}}
\DoxyCodeLine{116         uint8\_t format;}
\DoxyCodeLine{117         uint8\_t p\_f; \textcolor{comment}{/* poll / final bit */}}
\DoxyCodeLine{118         uint8\_t n\_send;}
\DoxyCodeLine{119         uint8\_t n\_recv;}
\DoxyCodeLine{120         uint8\_t s\_u; \textcolor{comment}{/* S or repectivly U function bits */}}
\DoxyCodeLine{121         \textcolor{comment}{/* length */}}
\DoxyCodeLine{122         \textcolor{keywordtype}{int}     length;}
\DoxyCodeLine{123         uint8\_t more;}
\DoxyCodeLine{124 \};}
\DoxyCodeLine{125 }
\DoxyCodeLine{126 \textcolor{keyword}{struct }lapd\_cr\_ent \{}
\DoxyCodeLine{127         uint8\_t cmd;}
\DoxyCodeLine{128         uint8\_t resp;}
\DoxyCodeLine{129 \};}
\DoxyCodeLine{130 }
\DoxyCodeLine{131 \textcolor{keyword}{struct }lapd\_history \{}
\DoxyCodeLine{132         \textcolor{keyword}{struct }msgb *msg; \textcolor{comment}{/* message to be sent / NULL, if histoy is empty */}}
\DoxyCodeLine{133         \textcolor{keywordtype}{int}     more; \textcolor{comment}{/* if message is fragmented */}}
\DoxyCodeLine{134 \};}
\DoxyCodeLine{135 }
\DoxyCodeLine{137 \textcolor{keyword}{struct }lapd\_datalink \{}
\DoxyCodeLine{138         int (*send\_dlsap)(\textcolor{keyword}{struct }osmo\_dlsap\_prim *dp, \textcolor{keyword}{struct }lapd\_msg\_ctx *lctx);}
\DoxyCodeLine{139         int (*send\_ph\_data\_req)(\textcolor{keyword}{struct }lapd\_msg\_ctx *lctx, \textcolor{keyword}{struct }msgb *msg);}
\DoxyCodeLine{140         int (*update\_pending\_frames)(\textcolor{keyword}{struct }lapd\_msg\_ctx *lctx);}
\DoxyCodeLine{141         \textcolor{keyword}{struct }\{}
\DoxyCodeLine{143                 \textcolor{keyword}{struct }lapd\_cr\_ent loc2rem;}
\DoxyCodeLine{144                 \textcolor{keyword}{struct }lapd\_cr\_ent rem2loc;}
\DoxyCodeLine{145         \} cr;}
\DoxyCodeLine{146         \textcolor{keyword}{enum} lapd\_mode mode; }
\DoxyCodeLine{147         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} lapd\_flags; }
\DoxyCodeLine{148         \textcolor{keywordtype}{int} use\_sabme; }
\DoxyCodeLine{149         \textcolor{keywordtype}{int} reestablish; }
\DoxyCodeLine{150         \textcolor{keywordtype}{int} n200, n200\_est\_rel; }
\DoxyCodeLine{151         \textcolor{keyword}{struct }lapd\_msg\_ctx lctx; }
\DoxyCodeLine{152         \textcolor{keywordtype}{int} maxf; }
\DoxyCodeLine{153         uint8\_t k; }
\DoxyCodeLine{154         uint8\_t v\_range; }
\DoxyCodeLine{155         uint8\_t v\_send;   }
\DoxyCodeLine{156         uint8\_t v\_ack;     }
\DoxyCodeLine{157         uint8\_t v\_recv;   }
\DoxyCodeLine{158         uint32\_t state; }
\DoxyCodeLine{159         \textcolor{keywordtype}{int} seq\_err\_cond; }
\DoxyCodeLine{160         uint8\_t own\_busy; }
\DoxyCodeLine{161         uint8\_t peer\_busy; }
\DoxyCodeLine{162         \textcolor{keywordtype}{int} t200\_sec, t200\_usec; }
\DoxyCodeLine{163         \textcolor{keywordtype}{int} t203\_sec, t203\_usec; }
\DoxyCodeLine{164         \textcolor{keyword}{enum} lapd\_t200\_rts t200\_rts; }
\DoxyCodeLine{165         \textcolor{keyword}{struct }osmo\_timer\_list t200; }
\DoxyCodeLine{166         \textcolor{keyword}{struct }osmo\_timer\_list t203; }
\DoxyCodeLine{167         uint8\_t retrans\_ctr; }
\DoxyCodeLine{168         \textcolor{keyword}{struct }llist\_head tx\_queue; }
\DoxyCodeLine{169         \textcolor{keyword}{struct }llist\_head send\_queue; }
\DoxyCodeLine{170         \textcolor{keyword}{struct }msgb *send\_buffer; }
\DoxyCodeLine{171         \textcolor{keywordtype}{int} send\_out; }
\DoxyCodeLine{172         \textcolor{keyword}{struct }lapd\_history *tx\_hist; }
\DoxyCodeLine{173         uint8\_t range\_hist; }
\DoxyCodeLine{174         \textcolor{keyword}{struct }msgb *rcv\_buffer; }
\DoxyCodeLine{175         \textcolor{keyword}{struct }msgb *cont\_res; }
\DoxyCodeLine{176         \textcolor{keywordtype}{char} *name; }
\DoxyCodeLine{177 \};}
\DoxyCodeLine{178 }
\DoxyCodeLine{179 \textcolor{keywordtype}{void} lapd\_dl\_init(\textcolor{keyword}{struct} lapd\_datalink *dl, uint8\_t k, uint8\_t v\_range, \textcolor{keywordtype}{int} maxf)}
\DoxyCodeLine{180         OSMO\_DEPRECATED(\textcolor{stringliteral}{"{}Use lapd\_dl\_init2() instead"{}});}
\DoxyCodeLine{181 \textcolor{keywordtype}{void} lapd\_dl\_init2(\textcolor{keyword}{struct} lapd\_datalink *dl, uint8\_t k, uint8\_t v\_range, \textcolor{keywordtype}{int} maxf, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name);}
\DoxyCodeLine{182 \textcolor{keywordtype}{void} lapd\_dl\_set\_name(\textcolor{keyword}{struct} lapd\_datalink *dl, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name);}
\DoxyCodeLine{183 \textcolor{keywordtype}{void} lapd\_dl\_exit(\textcolor{keyword}{struct} lapd\_datalink *dl);}
\DoxyCodeLine{184 \textcolor{keywordtype}{void} lapd\_dl\_reset(\textcolor{keyword}{struct} lapd\_datalink *dl);}
\DoxyCodeLine{185 \textcolor{keywordtype}{int} lapd\_dl\_set\_flags(\textcolor{keyword}{struct} lapd\_datalink *dl, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} flags);}
\DoxyCodeLine{186 \textcolor{keywordtype}{int} lapd\_set\_mode(\textcolor{keyword}{struct} lapd\_datalink *dl, \textcolor{keyword}{enum} lapd\_mode mode);}
\DoxyCodeLine{187 \textcolor{keywordtype}{int} lapd\_ph\_data\_ind(\textcolor{keyword}{struct} msgb *msg, \textcolor{keyword}{struct} lapd\_msg\_ctx *lctx);}
\DoxyCodeLine{188 \textcolor{keywordtype}{int} lapd\_ph\_rts\_ind(\textcolor{keyword}{struct} lapd\_msg\_ctx *lctx);}
\DoxyCodeLine{189 \textcolor{keywordtype}{int} lapd\_recv\_dlsap(\textcolor{keyword}{struct} osmo\_dlsap\_prim *dp, \textcolor{keyword}{struct} lapd\_msg\_ctx *lctx);}
\DoxyCodeLine{190 \textcolor{keywordtype}{int} lapd\_t200\_timeout(\textcolor{keyword}{struct} lapd\_datalink *dl);}
\DoxyCodeLine{191 }

\end{DoxyCode}
