\doxysection{frame\+\_\+relay.\+h}
\label{frame__relay_8h_source}\index{include/osmocom/gprs/frame\_relay.h@{include/osmocom/gprs/frame\_relay.h}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 }
\DoxyCodeLine{3 \textcolor{comment}{/* (C) 2020 Harald Welte <laforge@gnumonks.org>}}
\DoxyCodeLine{4 \textcolor{comment}{ * (C) 2020 sysmocom -\/ s.f.m.c. GmbH}}
\DoxyCodeLine{5 \textcolor{comment}{ * Author: Alexander Couzens <lynxis@fe80.eu>}}
\DoxyCodeLine{6 \textcolor{comment}{ *}}
\DoxyCodeLine{7 \textcolor{comment}{ * All Rights Reserved}}
\DoxyCodeLine{8 \textcolor{comment}{ *}}
\DoxyCodeLine{9 \textcolor{comment}{ * SPDX-\/License-\/Identifier: GPL-\/2.0+}}
\DoxyCodeLine{10 \textcolor{comment}{ *}}
\DoxyCodeLine{11 \textcolor{comment}{ * This program is free software; you can redistribute it and/or modify}}
\DoxyCodeLine{12 \textcolor{comment}{ * it under the terms of the GNU General Public License as published by}}
\DoxyCodeLine{13 \textcolor{comment}{ * the Free Software Foundation; either version 2 of the License, or}}
\DoxyCodeLine{14 \textcolor{comment}{ * (at your option) any later version.}}
\DoxyCodeLine{15 \textcolor{comment}{ *}}
\DoxyCodeLine{16 \textcolor{comment}{ * This program is distributed in the hope that it will be useful,}}
\DoxyCodeLine{17 \textcolor{comment}{ * but WITHOUT ANY WARRANTY; without even the implied warranty of}}
\DoxyCodeLine{18 \textcolor{comment}{ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the}}
\DoxyCodeLine{19 \textcolor{comment}{ * GNU General Public License for more details.}}
\DoxyCodeLine{20 \textcolor{comment}{ *}}
\DoxyCodeLine{21 \textcolor{comment}{ * You should have received a copy of the GNU General Public License}}
\DoxyCodeLine{22 \textcolor{comment}{ * along with this program.  If not, see <http://www.gnu.org/licenses/>.}}
\DoxyCodeLine{23 \textcolor{comment}{ *}}
\DoxyCodeLine{24 \textcolor{comment}{ */}}
\DoxyCodeLine{25 }
\DoxyCodeLine{26 \textcolor{preprocessor}{\#pragma once}}
\DoxyCodeLine{27 }
\DoxyCodeLine{28 \textcolor{preprocessor}{\#include <osmocom/core/linuxlist.h>}}
\DoxyCodeLine{29 \textcolor{preprocessor}{\#include <osmocom/core/timer.h>}}
\DoxyCodeLine{30 \textcolor{preprocessor}{\#include <osmocom/core/utils.h>}}
\DoxyCodeLine{31 }
\DoxyCodeLine{32 \textcolor{preprocessor}{\#include <stdint.h>}}
\DoxyCodeLine{33 }
\DoxyCodeLine{34 \textcolor{keyword}{struct }osmo\_tdef;}
\DoxyCodeLine{35 \textcolor{keyword}{struct }msgb;}
\DoxyCodeLine{36 \textcolor{keyword}{struct }vty;}
\DoxyCodeLine{37 }
\DoxyCodeLine{38 \textcolor{keyword}{enum} osmo\_fr\_role \{}
\DoxyCodeLine{39         FR\_ROLE\_USER\_EQUIPMENT,}
\DoxyCodeLine{40         FR\_ROLE\_NETWORK\_EQUIPMENT,}
\DoxyCodeLine{41 \};}
\DoxyCodeLine{42 }
\DoxyCodeLine{43 \textcolor{comment}{/* 48.016 § 6.1.4.2 default maximum information field size of 1600 octets */}}
\DoxyCodeLine{44 \textcolor{preprocessor}{\#define FRAME\_RELAY\_MTU 1600}}
\DoxyCodeLine{45 \textcolor{comment}{/* FR DLC header is 2 byte */}}
\DoxyCodeLine{46 \textcolor{preprocessor}{\#define FRAME\_RELAY\_SDU (FRAME\_RELAY\_MTU -\/ 2)}}
\DoxyCodeLine{47 }
\DoxyCodeLine{48 \textcolor{keyword}{extern} \textcolor{keyword}{const} \textcolor{keyword}{struct }value\_string osmo\_fr\_role\_names[];}
\DoxyCodeLine{49 }
\DoxyCodeLine{50 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *osmo\_fr\_role\_str(\textcolor{keyword}{enum} osmo\_fr\_role role) \{}
\DoxyCodeLine{51         \textcolor{keywordflow}{return} get\_value\_string(osmo\_fr\_role\_names, role);}
\DoxyCodeLine{52 \}}
\DoxyCodeLine{53 }
\DoxyCodeLine{54 \textcolor{keyword}{struct }osmo\_fr\_network \{}
\DoxyCodeLine{55         \textcolor{keyword}{struct }llist\_head links;}
\DoxyCodeLine{56 }
\DoxyCodeLine{57         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} n391;          \textcolor{comment}{/* full status polling counter */}}
\DoxyCodeLine{58         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} n392;          \textcolor{comment}{/* error threshold */}}
\DoxyCodeLine{59         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} n393;          \textcolor{comment}{/* monitored events count */}}
\DoxyCodeLine{60 }
\DoxyCodeLine{61         \textcolor{keyword}{struct }osmo\_tdef *T\_defs;        \textcolor{comment}{/* T391, T392 */}}
\DoxyCodeLine{62 \};}
\DoxyCodeLine{63 }
\DoxyCodeLine{64 \textcolor{keyword}{struct }osmo\_fr\_dlc;}
\DoxyCodeLine{65 }
\DoxyCodeLine{66 \textcolor{comment}{/* Frame Relay Link */}}
\DoxyCodeLine{67 \textcolor{keyword}{struct }osmo\_fr\_link \{}
\DoxyCodeLine{68         \textcolor{comment}{/* list in osmo\_fr\_network.links */}}
\DoxyCodeLine{69         \textcolor{keyword}{struct }llist\_head list;}
\DoxyCodeLine{70         \textcolor{keyword}{struct }osmo\_fr\_network *net;}
\DoxyCodeLine{71         \textcolor{keyword}{enum} osmo\_fr\_role role;}
\DoxyCodeLine{72         \textcolor{comment}{/* human-\/readable name */}}
\DoxyCodeLine{73         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name;}
\DoxyCodeLine{74 }
\DoxyCodeLine{75         \textcolor{comment}{/* value of the last received send sequence number field in the}}
\DoxyCodeLine{76 \textcolor{comment}{         * link integrity verification information element */}}
\DoxyCodeLine{77         uint8\_t last\_rx\_seq;}
\DoxyCodeLine{78 }
\DoxyCodeLine{79         \textcolor{comment}{/* value of the send sequence number field of the last link}}
\DoxyCodeLine{80 \textcolor{comment}{         * integrity verification information element sent */}}
\DoxyCodeLine{81         uint8\_t last\_tx\_seq;}
\DoxyCodeLine{82 }
\DoxyCodeLine{83         \textcolor{keyword}{struct }osmo\_timer\_list t391;}
\DoxyCodeLine{84         \textcolor{keyword}{struct }osmo\_timer\_list t392;}
\DoxyCodeLine{85 }
\DoxyCodeLine{86         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} polling\_count;}
\DoxyCodeLine{87         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} err\_count;}
\DoxyCodeLine{88         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} succeed;}
\DoxyCodeLine{89         \textcolor{comment}{/* the type of the last status enquiry */}}
\DoxyCodeLine{90         uint8\_t expected\_rep;}
\DoxyCodeLine{91         \textcolor{keywordtype}{bool} state;}
\DoxyCodeLine{92 }
\DoxyCodeLine{93         \textcolor{comment}{/* list of data link connections at this link */}}
\DoxyCodeLine{94         \textcolor{keyword}{struct }llist\_head dlc\_list;}
\DoxyCodeLine{95 }
\DoxyCodeLine{96         \textcolor{comment}{/* optional call-\/back to be called for each PDU received on an unknown DLC */}}
\DoxyCodeLine{97         int (*unknown\_dlc\_rx\_cb)(\textcolor{keywordtype}{void} *cb\_data, \textcolor{keyword}{struct }msgb *msg);}
\DoxyCodeLine{98         \textcolor{keywordtype}{void} *unknown\_dlc\_rx\_cb\_data;}
\DoxyCodeLine{99 }
\DoxyCodeLine{100         \textcolor{comment}{/* call-\/back to be called for transmitting on the underlying hardware */}}
\DoxyCodeLine{101         int (*tx\_cb)(\textcolor{keywordtype}{void} *data, \textcolor{keyword}{struct }msgb *msg);}
\DoxyCodeLine{102         \textcolor{comment}{/* optional call-\/back to be called each time the status changes active/inactive */}}
\DoxyCodeLine{103         void (*status\_cb)(\textcolor{keyword}{struct }osmo\_fr\_link *link, \textcolor{keywordtype}{void} *cb\_data, \textcolor{keywordtype}{bool} active);}
\DoxyCodeLine{104         \textcolor{keywordtype}{void} *cb\_data;}
\DoxyCodeLine{105 \};}
\DoxyCodeLine{106 }
\DoxyCodeLine{107 \textcolor{comment}{/* Frame Relay Data Link Connection */}}
\DoxyCodeLine{108 \textcolor{keyword}{struct }osmo\_fr\_dlc \{}
\DoxyCodeLine{109         \textcolor{comment}{/* entry in fr\_link.dlc\_list */}}
\DoxyCodeLine{110         \textcolor{keyword}{struct }llist\_head list;}
\DoxyCodeLine{111         \textcolor{keyword}{struct }osmo\_fr\_link *link;}
\DoxyCodeLine{112 }
\DoxyCodeLine{113         uint16\_t dlci;}
\DoxyCodeLine{114 }
\DoxyCodeLine{115         \textcolor{comment}{/* is this DLC marked active for traffic? */}}
\DoxyCodeLine{116         \textcolor{keywordtype}{bool} active;}
\DoxyCodeLine{117         \textcolor{comment}{/* was this DLC newly added? */}}
\DoxyCodeLine{118         \textcolor{keywordtype}{bool} add;}
\DoxyCodeLine{119         \textcolor{comment}{/* is this DLC about to be destroyed */}}
\DoxyCodeLine{120         \textcolor{keywordtype}{bool} del;}
\DoxyCodeLine{121 }
\DoxyCodeLine{122         \textcolor{comment}{/* The local state needs to be transferred to the USER;}}
\DoxyCodeLine{123 \textcolor{comment}{         * NET must wait until USER confirms it implicitly by a seq number check */}}
\DoxyCodeLine{124         \textcolor{keywordtype}{bool} state\_send;}
\DoxyCodeLine{125 }
\DoxyCodeLine{126         \textcolor{comment}{/* call-\/back to be called for each PDU received on this DLC */}}
\DoxyCodeLine{127         int (*rx\_cb)(\textcolor{keywordtype}{void} *cb\_data, \textcolor{keyword}{struct }msgb *msg);}
\DoxyCodeLine{128         \textcolor{comment}{/* optional call-\/back to be called each time the status changes active/inactive */}}
\DoxyCodeLine{129         void (*status\_cb)(\textcolor{keyword}{struct }osmo\_fr\_dlc *dlc, \textcolor{keywordtype}{void} *cb\_data, \textcolor{keywordtype}{bool} active);}
\DoxyCodeLine{130         \textcolor{keywordtype}{void} *cb\_data;}
\DoxyCodeLine{131 \};}
\DoxyCodeLine{132 }
\DoxyCodeLine{133 \textcolor{comment}{/* allocate a frame relay network */}}
\DoxyCodeLine{134 \textcolor{keyword}{struct }osmo\_fr\_network *osmo\_fr\_network\_alloc(\textcolor{keywordtype}{void} *ctx);}
\DoxyCodeLine{135 \textcolor{keywordtype}{void} osmo\_fr\_network\_free(\textcolor{keyword}{struct} osmo\_fr\_network *net);}
\DoxyCodeLine{136 \textcolor{keywordtype}{void} osmo\_fr\_network\_dump\_vty(\textcolor{keyword}{struct} vty *vty, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_fr\_network *net);}
\DoxyCodeLine{137 }
\DoxyCodeLine{138 \textcolor{comment}{/* allocate a frame relay link in a given network */}}
\DoxyCodeLine{139 \textcolor{keyword}{struct }osmo\_fr\_link *osmo\_fr\_link\_alloc(\textcolor{keyword}{struct} osmo\_fr\_network *net, \textcolor{keyword}{enum} osmo\_fr\_role role, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name);}
\DoxyCodeLine{140 }
\DoxyCodeLine{141 \textcolor{comment}{/* free a frame link in a given network */}}
\DoxyCodeLine{142 \textcolor{keywordtype}{void} osmo\_fr\_link\_free(\textcolor{keyword}{struct} osmo\_fr\_link *link);}
\DoxyCodeLine{143 }
\DoxyCodeLine{144 \textcolor{comment}{/* allocate a data link connectoin on a given framerelay link */}}
\DoxyCodeLine{145 \textcolor{keyword}{struct }osmo\_fr\_dlc *osmo\_fr\_dlc\_alloc(\textcolor{keyword}{struct} osmo\_fr\_link *link, uint16\_t dlci);}
\DoxyCodeLine{146 \textcolor{keywordtype}{void} osmo\_fr\_dlc\_free(\textcolor{keyword}{struct} osmo\_fr\_dlc *dlc);}
\DoxyCodeLine{147 }
\DoxyCodeLine{148 \textcolor{keyword}{struct }osmo\_fr\_dlc *osmo\_fr\_dlc\_by\_dlci(\textcolor{keyword}{struct} osmo\_fr\_link *link, uint16\_t dlci);}
\DoxyCodeLine{149 }
\DoxyCodeLine{150 \textcolor{keywordtype}{int} osmo\_fr\_rx(\textcolor{keyword}{struct} msgb *msg);}
\DoxyCodeLine{151 \textcolor{keywordtype}{int} osmo\_fr\_tx\_dlc(\textcolor{keyword}{struct} msgb *msg);}

\end{DoxyCode}
