\doxysection{gprs\+\_\+bssgp.\+h}
\label{gprs__bssgp_8h_source}\index{include/osmocom/gprs/gprs\_bssgp.h@{include/osmocom/gprs/gprs\_bssgp.h}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 }
\DoxyCodeLine{3 \textcolor{preprocessor}{\#pragma once}}
\DoxyCodeLine{4 }
\DoxyCodeLine{5 \textcolor{preprocessor}{\#include <stdint.h>}}
\DoxyCodeLine{6 \textcolor{preprocessor}{\#include <osmocom/core/timer.h>}}
\DoxyCodeLine{7 \textcolor{preprocessor}{\#include <osmocom/core/linuxlist.h>}}
\DoxyCodeLine{8 }
\DoxyCodeLine{9 \textcolor{preprocessor}{\#include <osmocom/gsm/gsm48.h>}}
\DoxyCodeLine{10 \textcolor{preprocessor}{\#include <osmocom/gsm/prim.h>}}
\DoxyCodeLine{11 }
\DoxyCodeLine{12 \textcolor{preprocessor}{\#include <osmocom/gprs/protocol/gsm\_08\_18.h>}}
\DoxyCodeLine{13 \textcolor{preprocessor}{\#include <osmocom/gprs/protocol/gsm\_24\_301.h>}}
\DoxyCodeLine{14 \textcolor{preprocessor}{\#include <osmocom/gprs/gprs\_bssgp\_rim.h>}}
\DoxyCodeLine{15 }
\DoxyCodeLine{16 \textcolor{comment}{/* gprs\_bssgp\_util.c */}}
\DoxyCodeLine{17 }
\DoxyCodeLine{18 \textcolor{preprocessor}{\#define BSSGP\_PDUF\_UL   0x0001  }\textcolor{comment}{/* PDU may occur in uplink */}\textcolor{preprocessor}{}}
\DoxyCodeLine{19 \textcolor{preprocessor}{\#define BSSGP\_PDUF\_DL   0x0002  }\textcolor{comment}{/* PDU may occur in downlink */}\textcolor{preprocessor}{}}
\DoxyCodeLine{20 \textcolor{preprocessor}{\#define BSSGP\_PDUF\_SIG  0x0004  }\textcolor{comment}{/* PDU may occur on Signaling BVC */}\textcolor{preprocessor}{}}
\DoxyCodeLine{21 \textcolor{preprocessor}{\#define BSSGP\_PDUF\_PTP  0x0008  }\textcolor{comment}{/* PDU may occur on PTP BVC */}\textcolor{preprocessor}{}}
\DoxyCodeLine{22 \textcolor{preprocessor}{\#define BSSGP\_PDUF\_PTM  0x0010  }\textcolor{comment}{/* PDU may occur on PTM BVC */}\textcolor{preprocessor}{}}
\DoxyCodeLine{23 }
\DoxyCodeLine{24 \textcolor{keyword}{extern} \textcolor{keyword}{const} \textcolor{keyword}{struct }osmo\_tlv\_prot\_def osmo\_pdef\_bssgp;}
\DoxyCodeLine{25 }
\DoxyCodeLine{27 \textcolor{keyword}{static} \textcolor{keyword}{inline} uint32\_t bssgp\_pdu\_type\_flags(uint8\_t pdu\_type) \{}
\DoxyCodeLine{28         \textcolor{keywordflow}{return} osmo\_tlv\_prot\_msgt\_flags(\&osmo\_pdef\_bssgp, pdu\_type);}
\DoxyCodeLine{29 \}}
\DoxyCodeLine{30 }
\DoxyCodeLine{31 \textcolor{keyword}{typedef} int (*bssgp\_bvc\_send)(\textcolor{keywordtype}{void} *ctx, \textcolor{keyword}{struct }msgb *msg);}
\DoxyCodeLine{32 \textcolor{keyword}{extern} \textcolor{keyword}{struct }gprs\_ns\_inst *bssgp\_nsi;}
\DoxyCodeLine{33 \textcolor{keywordtype}{void} bssgp\_set\_bssgp\_callback(bssgp\_bvc\_send ns\_send, \textcolor{keywordtype}{void} *data);}
\DoxyCodeLine{34 \textcolor{keyword}{struct }msgb *bssgp\_msgb\_alloc(\textcolor{keywordtype}{void});}
\DoxyCodeLine{35 \textcolor{keyword}{struct }msgb *bssgp\_msgb\_copy(\textcolor{keyword}{const} \textcolor{keyword}{struct} msgb *msg, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name);}
\DoxyCodeLine{36 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *bssgp\_cause\_str(\textcolor{keyword}{enum} gprs\_bssgp\_cause cause);}
\DoxyCodeLine{37 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *bssgp\_pdu\_str(\textcolor{keyword}{enum} bssgp\_pdu\_type pdu);}
\DoxyCodeLine{38 \textcolor{keywordtype}{int} bssgp\_tx\_bvc\_reset\_nsei\_bvci(uint16\_t nsei, uint16\_t bvci, \textcolor{keyword}{enum} gprs\_bssgp\_cause cause, \textcolor{keyword}{const} \textcolor{keyword}{struct} gprs\_ra\_id *ra\_id, uint16\_t cell\_id);}
\DoxyCodeLine{39 \textcolor{comment}{/* Transmit a simple response such as BLOCK/UNBLOCK/RESET ACK/NACK */}}
\DoxyCodeLine{40 \textcolor{keywordtype}{int} bssgp\_tx\_simple\_bvci(uint8\_t pdu\_type, uint16\_t nsei,}
\DoxyCodeLine{41                          uint16\_t bvci, uint16\_t ns\_bvci);}
\DoxyCodeLine{42 \textcolor{comment}{/* Chapter 10.4.14: Status */}}
\DoxyCodeLine{43 \textcolor{keywordtype}{int} bssgp\_tx\_status(uint8\_t cause, uint16\_t *bvci, \textcolor{keyword}{struct} msgb *orig\_msg);}
\DoxyCodeLine{44 }
\DoxyCodeLine{45 \textcolor{keyword}{enum} bssgp\_prim \{}
\DoxyCodeLine{46         PRIM\_BSSGP\_DL\_UD,}
\DoxyCodeLine{47         PRIM\_BSSGP\_UL\_UD,}
\DoxyCodeLine{48         PRIM\_BSSGP\_PTM\_UD,}
\DoxyCodeLine{49 }
\DoxyCodeLine{50         PRIM\_BSSGP\_GMM\_SUSPEND,}
\DoxyCodeLine{51         PRIM\_BSSGP\_GMM\_RESUME,}
\DoxyCodeLine{52         PRIM\_BSSGP\_GMM\_PAGING,}
\DoxyCodeLine{53 }
\DoxyCodeLine{54         PRIM\_NM\_FLUSH\_LL,}
\DoxyCodeLine{55         PRIM\_NM\_LLC\_DISCARDED,}
\DoxyCodeLine{56         PRIM\_NM\_BVC\_RESET,}
\DoxyCodeLine{57         PRIM\_NM\_BVC\_BLOCK,}
\DoxyCodeLine{58         PRIM\_NM\_BVC\_UNBLOCK,}
\DoxyCodeLine{59         PRIM\_NM\_STATUS,}
\DoxyCodeLine{60 }
\DoxyCodeLine{61         PRIM\_BSSGP\_RIM\_PDU\_TRANSFER,}
\DoxyCodeLine{62 \};}
\DoxyCodeLine{63 }
\DoxyCodeLine{64 \textcolor{keyword}{struct }osmo\_bssgp\_prim \{}
\DoxyCodeLine{65         \textcolor{keyword}{struct }osmo\_prim\_hdr oph;}
\DoxyCodeLine{66 }
\DoxyCodeLine{67         \textcolor{comment}{/* common fields */}}
\DoxyCodeLine{68         uint16\_t nsei;}
\DoxyCodeLine{69         uint16\_t bvci;}
\DoxyCodeLine{70         uint32\_t tlli;}
\DoxyCodeLine{71         \textcolor{keyword}{struct }tlv\_parsed *tp;}
\DoxyCodeLine{72         \textcolor{keyword}{struct }gprs\_ra\_id *ra\_id;}
\DoxyCodeLine{73 }
\DoxyCodeLine{74         \textcolor{comment}{/* specific fields */}}
\DoxyCodeLine{75         \textcolor{keyword}{union }\{}
\DoxyCodeLine{76                 \textcolor{keyword}{struct }\{}
\DoxyCodeLine{77                         uint8\_t suspend\_ref;}
\DoxyCodeLine{78                 \} resume;}
\DoxyCodeLine{79                 \textcolor{keyword}{struct }bssgp\_ran\_information\_pdu rim\_pdu;}
\DoxyCodeLine{80         \} u;}
\DoxyCodeLine{81 \};}
\DoxyCodeLine{82 }
\DoxyCodeLine{83 \textcolor{comment}{/* gprs\_bssgp.c */}}
\DoxyCodeLine{84 }
\DoxyCodeLine{86 \textcolor{keyword}{struct }bssgp\_flow\_control \{}
\DoxyCodeLine{87         uint32\_t bucket\_size\_max;        }
\DoxyCodeLine{88         uint32\_t bucket\_leak\_rate;      }
\DoxyCodeLine{90         uint32\_t bucket\_counter;  }
\DoxyCodeLine{91         \textcolor{keyword}{struct }timeval time\_last\_pdu;      }
\DoxyCodeLine{93         \textcolor{comment}{/* the built-\/in queue */}}
\DoxyCodeLine{94         uint32\_t max\_queue\_depth;        }
\DoxyCodeLine{95         uint32\_t queue\_depth;                }
\DoxyCodeLine{96         \textcolor{keyword}{struct }llist\_head queue; }
\DoxyCodeLine{97         \textcolor{keyword}{struct }osmo\_timer\_list timer;       }
\DoxyCodeLine{100         int (*out\_cb)(\textcolor{keyword}{struct }bssgp\_flow\_control *fc, \textcolor{keyword}{struct }msgb *msg,}
\DoxyCodeLine{101                         uint32\_t llc\_pdu\_len, \textcolor{keywordtype}{void} *priv);}
\DoxyCodeLine{102 \};}
\DoxyCodeLine{103 }
\DoxyCodeLine{104 \textcolor{preprocessor}{\#define BVC\_S\_BLOCKED   0x0001}}
\DoxyCodeLine{105 }
\DoxyCodeLine{106 \textcolor{comment}{/* The per-\/BTS context that we keep on the SGSN side of the BSSGP link */}}
\DoxyCodeLine{107 \textcolor{keyword}{struct }bssgp\_bvc\_ctx \{}
\DoxyCodeLine{108         \textcolor{keyword}{struct }llist\_head list;}
\DoxyCodeLine{109 }
\DoxyCodeLine{110         \textcolor{keyword}{struct }gprs\_ra\_id ra\_id; }
\DoxyCodeLine{111         uint16\_t cell\_id; }
\DoxyCodeLine{113         \textcolor{comment}{/* NSEI and BVCI of underlying Gb link.  Together they}}
\DoxyCodeLine{114 \textcolor{comment}{         * uniquely identify a link to a BTS (5.4.4) */}}
\DoxyCodeLine{115         uint16\_t bvci;}
\DoxyCodeLine{116         uint16\_t nsei;}
\DoxyCodeLine{117 }
\DoxyCodeLine{118         uint32\_t state;}
\DoxyCodeLine{119 }
\DoxyCodeLine{120         \textcolor{keyword}{struct }rate\_ctr\_group *ctrg;}
\DoxyCodeLine{121 }
\DoxyCodeLine{122         \textcolor{keyword}{struct }bssgp\_flow\_control *fc;}
\DoxyCodeLine{124         uint32\_t bmax\_default\_ms;}
\DoxyCodeLine{126         uint32\_t r\_default\_ms;}
\DoxyCodeLine{127 }
\DoxyCodeLine{129         \textcolor{keywordtype}{bool} is\_sgsn;}
\DoxyCodeLine{130         \textcolor{comment}{/* we might want to add this as a shortcut later, avoiding the NSVC}}
\DoxyCodeLine{131 \textcolor{comment}{         * lookup for every packet, similar to a routing cache */}}
\DoxyCodeLine{132         \textcolor{comment}{//struct gprs\_nsvc *nsvc;}}
\DoxyCodeLine{133 \};}
\DoxyCodeLine{134 \textcolor{keyword}{extern} \textcolor{keyword}{struct }llist\_head bssgp\_bvc\_ctxts;}
\DoxyCodeLine{135 \textcolor{comment}{/* Create a BTS Context with BVCI+NSEI */}}
\DoxyCodeLine{136 \textcolor{keyword}{struct }bssgp\_bvc\_ctx *btsctx\_alloc(uint16\_t bvci, uint16\_t nsei);}
\DoxyCodeLine{137 \textcolor{comment}{/* Find a BTS Context based on parsed RA ID and Cell ID */}}
\DoxyCodeLine{138 \textcolor{keyword}{struct }bssgp\_bvc\_ctx *btsctx\_by\_raid\_cid(\textcolor{keyword}{const} \textcolor{keyword}{struct} gprs\_ra\_id *raid, uint16\_t cid);}
\DoxyCodeLine{139 \textcolor{comment}{/* Find a BTS context based on BVCI+NSEI tuple */}}
\DoxyCodeLine{140 \textcolor{keyword}{struct }bssgp\_bvc\_ctx *btsctx\_by\_bvci\_nsei(uint16\_t bvci, uint16\_t nsei);}
\DoxyCodeLine{141 \textcolor{comment}{/* Free a given BTS context */}}
\DoxyCodeLine{142 \textcolor{keywordtype}{void} bssgp\_bvc\_ctx\_free(\textcolor{keyword}{struct} bssgp\_bvc\_ctx *ctx);}
\DoxyCodeLine{143 }
\DoxyCodeLine{144 \textcolor{preprocessor}{\#define BVC\_F\_BLOCKED   0x0001}}
\DoxyCodeLine{145 }
\DoxyCodeLine{146 \textcolor{keyword}{enum} bssgp\_ctr \{}
\DoxyCodeLine{147         BSSGP\_CTR\_PKTS\_IN,}
\DoxyCodeLine{148         BSSGP\_CTR\_PKTS\_OUT,}
\DoxyCodeLine{149         BSSGP\_CTR\_BYTES\_IN,}
\DoxyCodeLine{150         BSSGP\_CTR\_BYTES\_OUT,}
\DoxyCodeLine{151         BSSGP\_CTR\_BLOCKED,}
\DoxyCodeLine{152         BSSGP\_CTR\_DISCARDED,}
\DoxyCodeLine{153         BSSGP\_CTR\_STATUS,}
\DoxyCodeLine{154 \};}
\DoxyCodeLine{155 }
\DoxyCodeLine{156 }
\DoxyCodeLine{157 \textcolor{preprocessor}{\#include <osmocom/gsm/tlv.h>}}
\DoxyCodeLine{158 \textcolor{preprocessor}{\#include <osmocom/gprs/gprs\_msgb.h>}}
\DoxyCodeLine{159 }
\DoxyCodeLine{160 \textcolor{comment}{/* BSSGP-\/UL-\/UNITDATA.ind */}}
\DoxyCodeLine{161 \textcolor{keywordtype}{int} bssgp\_rcvmsg(\textcolor{keyword}{struct} msgb *msg);}
\DoxyCodeLine{162 }
\DoxyCodeLine{163 \textcolor{comment}{/* BSSGP-\/DL-\/UNITDATA.req */}}
\DoxyCodeLine{164 \textcolor{keyword}{struct }bssgp\_lv \{}
\DoxyCodeLine{165         uint16\_t len;}
\DoxyCodeLine{166         uint8\_t *v;}
\DoxyCodeLine{167 \};}
\DoxyCodeLine{168 \textcolor{comment}{/* parameters for BSSGP downlink userdata transmission */}}
\DoxyCodeLine{169 \textcolor{keyword}{struct }bssgp\_dl\_ud\_par \{}
\DoxyCodeLine{170         uint32\_t *tlli;}
\DoxyCodeLine{171         \textcolor{keywordtype}{char} *imsi;}
\DoxyCodeLine{172         \textcolor{keyword}{struct }bssgp\_flow\_control *fc;}
\DoxyCodeLine{173         uint16\_t drx\_parms;}
\DoxyCodeLine{174         \textcolor{comment}{/* FIXME: priority */}}
\DoxyCodeLine{175         \textcolor{keyword}{struct }bssgp\_lv ms\_ra\_cap;}
\DoxyCodeLine{176         uint8\_t qos\_profile[3];}
\DoxyCodeLine{177 \};}
\DoxyCodeLine{178 \textcolor{keywordtype}{int} bssgp\_tx\_dl\_ud(\textcolor{keyword}{struct} msgb *msg, uint16\_t pdu\_lifetime,}
\DoxyCodeLine{179                    \textcolor{keyword}{struct} bssgp\_dl\_ud\_par *dup);}
\DoxyCodeLine{180 }
\DoxyCodeLine{181 uint16\_t bssgp\_parse\_cell\_id(\textcolor{keyword}{struct} gprs\_ra\_id *raid, \textcolor{keyword}{const} uint8\_t *buf);}
\DoxyCodeLine{182 \textcolor{keywordtype}{int} bssgp\_create\_cell\_id(uint8\_t *buf, \textcolor{keyword}{const} \textcolor{keyword}{struct} gprs\_ra\_id *raid,}
\DoxyCodeLine{183                          uint16\_t cid);}
\DoxyCodeLine{184 }
\DoxyCodeLine{185 \textcolor{keywordtype}{int} bssgp\_parse\_cell\_id2(\textcolor{keyword}{struct} osmo\_routing\_area\_id *raid, uint16\_t *cid,}
\DoxyCodeLine{186                          \textcolor{keyword}{const} uint8\_t *buf, \textcolor{keywordtype}{size\_t} buf\_len);}
\DoxyCodeLine{187 \textcolor{keywordtype}{int} bssgp\_create\_cell\_id2(uint8\_t *buf, \textcolor{keywordtype}{size\_t} buf\_len,}
\DoxyCodeLine{188                           \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_routing\_area\_id *raid,}
\DoxyCodeLine{189                           uint16\_t cid);}
\DoxyCodeLine{190 }
\DoxyCodeLine{191 \textcolor{comment}{/* Wrapper around TLV parser to parse BSSGP IEs */}}
\DoxyCodeLine{192 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{int} bssgp\_tlv\_parse(\textcolor{keyword}{struct} tlv\_parsed *tp, \textcolor{keyword}{const} uint8\_t *buf, \textcolor{keywordtype}{int} len)}
\DoxyCodeLine{193 \{}
\DoxyCodeLine{194         \textcolor{keywordflow}{return} tlv\_parse(tp, \&tvlv\_att\_def, buf, len, 0, 0);}
\DoxyCodeLine{195 \}}
\DoxyCodeLine{196 }
\DoxyCodeLine{198 \textcolor{keyword}{enum} bssgp\_paging\_mode \{}
\DoxyCodeLine{199         BSSGP\_PAGING\_PS,}
\DoxyCodeLine{200         BSSGP\_PAGING\_CS,}
\DoxyCodeLine{201 \};}
\DoxyCodeLine{202 }
\DoxyCodeLine{204 \textcolor{keyword}{enum} bssgp\_paging\_scope \{}
\DoxyCodeLine{205         BSSGP\_PAGING\_BSS\_AREA,             }
\DoxyCodeLine{206         BSSGP\_PAGING\_LOCATION\_AREA,   }
\DoxyCodeLine{207         BSSGP\_PAGING\_ROUTEING\_AREA,   }
\DoxyCodeLine{208         BSSGP\_PAGING\_BVCI,             }
\DoxyCodeLine{209 \};}
\DoxyCodeLine{210 }
\DoxyCodeLine{212 \textcolor{keyword}{struct }bssgp\_paging\_info \{}
\DoxyCodeLine{213         \textcolor{keyword}{enum} bssgp\_paging\_mode mode;       }
\DoxyCodeLine{214         \textcolor{keyword}{enum} bssgp\_paging\_scope scope;   }
\DoxyCodeLine{215         \textcolor{keyword}{struct }gprs\_ra\_id raid;           }
\DoxyCodeLine{216         uint16\_t bvci;                      }
\DoxyCodeLine{217         \textcolor{keywordtype}{char} *imsi;                 }
\DoxyCodeLine{218         uint32\_t *ptmsi;           }
\DoxyCodeLine{219         uint16\_t drx\_params;          }
\DoxyCodeLine{220         uint8\_t qos[3];                      }
\DoxyCodeLine{221 \};}
\DoxyCodeLine{222 }
\DoxyCodeLine{223 \textcolor{comment}{/* Send a single GMM-\/PAGING.req to a given NSEI/NS-\/BVCI */}}
\DoxyCodeLine{224 \textcolor{keywordtype}{int} bssgp\_tx\_paging(uint16\_t nsei, uint16\_t ns\_bvci,}
\DoxyCodeLine{225                     \textcolor{keyword}{struct} bssgp\_paging\_info *pinfo);}
\DoxyCodeLine{226 }
\DoxyCodeLine{227 \textcolor{keywordtype}{void} bssgp\_fc\_init(\textcolor{keyword}{struct} bssgp\_flow\_control *fc,}
\DoxyCodeLine{228                    uint32\_t bucket\_size\_max, uint32\_t bucket\_leak\_rate,}
\DoxyCodeLine{229                    uint32\_t max\_queue\_depth,}
\DoxyCodeLine{230                    \textcolor{keywordtype}{int} (*out\_cb)(\textcolor{keyword}{struct} bssgp\_flow\_control *fc, \textcolor{keyword}{struct} msgb *msg,}
\DoxyCodeLine{231                                  uint32\_t llc\_pdu\_len, \textcolor{keywordtype}{void} *priv));}
\DoxyCodeLine{232 }
\DoxyCodeLine{233 \textcolor{comment}{/* input function of the flow control implementation, called first}}
\DoxyCodeLine{234 \textcolor{comment}{ * for the MM flow control, and then as the MM flow control output}}
\DoxyCodeLine{235 \textcolor{comment}{ * callback in order to perform BVC flow control */}}
\DoxyCodeLine{236 \textcolor{keywordtype}{int} bssgp\_fc\_in(\textcolor{keyword}{struct} bssgp\_flow\_control *fc, \textcolor{keyword}{struct} msgb *msg,}
\DoxyCodeLine{237                 uint32\_t llc\_pdu\_len, \textcolor{keywordtype}{void} *priv);}
\DoxyCodeLine{238 }
\DoxyCodeLine{239 \textcolor{comment}{/* Initialize the Flow Control parameters for a new MS according to}}
\DoxyCodeLine{240 \textcolor{comment}{ * default values for the BVC specified by BVCI and NSEI */}}
\DoxyCodeLine{241 \textcolor{keywordtype}{int} bssgp\_fc\_ms\_init(\textcolor{keyword}{struct} bssgp\_flow\_control *fc\_ms, uint16\_t bvci,}
\DoxyCodeLine{242                      uint16\_t nsei, uint32\_t max\_queue\_depth);}
\DoxyCodeLine{243 }
\DoxyCodeLine{244 \textcolor{keywordtype}{void} bssgp\_flush\_all\_queues(\textcolor{keywordtype}{void});}
\DoxyCodeLine{245 \textcolor{keywordtype}{void} bssgp\_fc\_flush\_queue(\textcolor{keyword}{struct} bssgp\_flow\_control *fc);}
\DoxyCodeLine{246 }
\DoxyCodeLine{247 \textcolor{comment}{/* gprs\_bssgp\_vty.c */}}
\DoxyCodeLine{248 \textcolor{keywordtype}{int} bssgp\_vty\_init(\textcolor{keywordtype}{void});}
\DoxyCodeLine{249 \textcolor{keywordtype}{void} bssgp\_set\_log\_ss(\textcolor{keywordtype}{int} ss) OSMO\_DEPRECATED(\textcolor{stringliteral}{"{}Use DLBSSGP instead!\(\backslash\)n"{}});}
\DoxyCodeLine{250 }
\DoxyCodeLine{251 \textcolor{keywordtype}{int} bssgp\_prim\_cb(\textcolor{keyword}{struct} osmo\_prim\_hdr *oph, \textcolor{keywordtype}{void} *ctx);}

\end{DoxyCode}
