\doxysection{gsm48.\+h}
\label{gsm48_8h_source}\index{include/osmocom/gsm/gsm48.h@{include/osmocom/gsm/gsm48.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 <stdbool.h>}}
\DoxyCodeLine{6 }
\DoxyCodeLine{7 \textcolor{preprocessor}{\#include <osmocom/core/defs.h>}}
\DoxyCodeLine{8 \textcolor{preprocessor}{\#include <osmocom/core/msgb.h>}}
\DoxyCodeLine{9 }
\DoxyCodeLine{10 \textcolor{preprocessor}{\#include <osmocom/gsm/tlv.h>}}
\DoxyCodeLine{11 \textcolor{preprocessor}{\#include <osmocom/gsm/protocol/gsm\_04\_08.h>}}
\DoxyCodeLine{12 \textcolor{preprocessor}{\#include <osmocom/gsm/protocol/gsm\_23\_003.h>}}
\DoxyCodeLine{13 \textcolor{preprocessor}{\#include <osmocom/gsm/gsm48\_ie.h>}}
\DoxyCodeLine{14 \textcolor{preprocessor}{\#include <osmocom/gsm/gsm23003.h>}}
\DoxyCodeLine{15 }
\DoxyCodeLine{16 \textcolor{comment}{/* reserved according to GSM 03.03 § 2.4 */}}
\DoxyCodeLine{17 \textcolor{preprocessor}{\#define GSM\_RESERVED\_TMSI   0xFFFFFFFF}}
\DoxyCodeLine{18 }
\DoxyCodeLine{19 \textcolor{comment}{/* Valid MCC and MNC range from 0 to 999.}}
\DoxyCodeLine{20 \textcolor{comment}{ * To mark an invalid / unset MNC, this value shall be used. */}}
\DoxyCodeLine{21 \textcolor{preprocessor}{\#define GSM\_MCC\_MNC\_INVALID 0xFFFF}}
\DoxyCodeLine{22 }
\DoxyCodeLine{23 \textcolor{comment}{/* A parsed GPRS routing area.}}
\DoxyCodeLine{24 \textcolor{comment}{ * Preferably use struct osmo\_routing\_area\_id, it is better integrated with API like osmo\_plmn\_cmp().}}
\DoxyCodeLine{25 \textcolor{comment}{ */}}
\DoxyCodeLine{26 \textcolor{keyword}{struct }gprs\_ra\_id \{}
\DoxyCodeLine{27         uint16\_t        mcc;}
\DoxyCodeLine{28         uint16\_t        mnc;}
\DoxyCodeLine{29         \textcolor{keywordtype}{bool}            mnc\_3\_digits;}
\DoxyCodeLine{30         uint16\_t        lac;}
\DoxyCodeLine{31         uint8\_t         rac;}
\DoxyCodeLine{32 \};}
\DoxyCodeLine{33 }
\DoxyCodeLine{34 \textcolor{keyword}{extern} \textcolor{keyword}{const} \textcolor{keyword}{struct }tlv\_definition gsm48\_att\_tlvdef;}
\DoxyCodeLine{35 \textcolor{keyword}{extern} \textcolor{keyword}{const} \textcolor{keyword}{struct }tlv\_definition gsm48\_rr\_att\_tlvdef;}
\DoxyCodeLine{36 \textcolor{keyword}{extern} \textcolor{keyword}{const} \textcolor{keyword}{struct }tlv\_definition gsm48\_mm\_att\_tlvdef;}
\DoxyCodeLine{37 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *gsm48\_cc\_state\_name(uint8\_t state);}
\DoxyCodeLine{38 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *gsm48\_cc\_msg\_name(uint8\_t msgtype);}
\DoxyCodeLine{39 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *gsm48\_rr\_msg\_name(uint8\_t msgtype);}
\DoxyCodeLine{40 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *gsm48\_rr\_short\_pd\_msg\_name(uint8\_t msgtype);}
\DoxyCodeLine{41 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *rr\_cause\_name(uint8\_t cause);}
\DoxyCodeLine{42 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *osmo\_rai\_name(\textcolor{keyword}{const} \textcolor{keyword}{struct} gprs\_ra\_id *rai);}
\DoxyCodeLine{43 \textcolor{keywordtype}{char} *osmo\_rai\_name\_buf(\textcolor{keywordtype}{char} *buf, \textcolor{keywordtype}{size\_t} buf\_len, \textcolor{keyword}{const} \textcolor{keyword}{struct} gprs\_ra\_id *rai);}
\DoxyCodeLine{44 \textcolor{keywordtype}{char} *osmo\_rai\_name\_c(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *ctx, \textcolor{keyword}{const} \textcolor{keyword}{struct} gprs\_ra\_id *rai);}
\DoxyCodeLine{45 \textcolor{keywordtype}{void} osmo\_rai\_to\_gprs(\textcolor{keyword}{struct} gprs\_ra\_id *dest, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_routing\_area\_id *src);}
\DoxyCodeLine{46 \textcolor{keywordtype}{void} gprs\_rai\_to\_osmo(\textcolor{keyword}{struct} osmo\_routing\_area\_id *dest, \textcolor{keyword}{const} \textcolor{keyword}{struct} gprs\_ra\_id *src);}
\DoxyCodeLine{47 }
\DoxyCodeLine{48 \textcolor{keywordtype}{int} gsm48\_decode\_lai(\textcolor{keyword}{struct} gsm48\_loc\_area\_id *lai, uint16\_t *mcc,}
\DoxyCodeLine{49                      uint16\_t *mnc, uint16\_t *lac)}
\DoxyCodeLine{50         OSMO\_DEPRECATED("{}Use gsm48\_decode\_lai2() instead, to not lose leading zeros in the MNC"{});}
\DoxyCodeLine{51 \textcolor{keywordtype}{void} gsm48\_decode\_lai2(const struct gsm48\_loc\_area\_id *lai, struct osmo\_location\_area\_id *decoded);}
\DoxyCodeLine{52 \textcolor{keywordtype}{void} gsm48\_generate\_lai(struct gsm48\_loc\_area\_id *lai48, uint16\_t mcc,}
\DoxyCodeLine{53                         uint16\_t mnc, uint16\_t lac)}
\DoxyCodeLine{54         OSMO\_DEPRECATED("{}Use gsm48\_generate\_lai2() instead, to not lose leading zeros in the MNC"{});}
\DoxyCodeLine{55 \textcolor{keywordtype}{void} gsm48\_generate\_lai2(struct gsm48\_loc\_area\_id *lai48, const struct osmo\_location\_area\_id *lai);}
\DoxyCodeLine{56 }
\DoxyCodeLine{57 \textcolor{preprocessor}{\#define GSM48\_MID\_MAX\_SIZE      11}}
\DoxyCodeLine{58 \textcolor{keywordtype}{int} gsm48\_generate\_mid\_from\_tmsi(uint8\_t *buf, uint32\_t tmsi)}
\DoxyCodeLine{59         OSMO\_DEPRECATED\_OUTSIDE(\textcolor{stringliteral}{"{}Instead use: l = msgb\_tl\_put(msg, GSM48\_IE\_MOBILE\_ID);"{}}}
\DoxyCodeLine{60                                 \textcolor{stringliteral}{"{} *l = osmo\_mobile\_identity\_encode\_msgb(...)"{}});}
\DoxyCodeLine{61 \textcolor{keywordtype}{int} gsm48\_generate\_mid\_from\_imsi(uint8\_t *buf, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *imsi)}
\DoxyCodeLine{62         OSMO\_DEPRECATED\_OUTSIDE(\textcolor{stringliteral}{"{}Instead use: l = msgb\_tl\_put(msg, GSM48\_IE\_MOBILE\_ID);"{}}}
\DoxyCodeLine{63                                 \textcolor{stringliteral}{"{} *l = osmo\_mobile\_identity\_encode\_msgb(...)"{}});}
\DoxyCodeLine{64 uint8\_t gsm48\_generate\_mid(uint8\_t *buf, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *\textcolor{keywordtype}{id}, uint8\_t mi\_type)}
\DoxyCodeLine{65         OSMO\_DEPRECATED\_OUTSIDE(\textcolor{stringliteral}{"{}Instead use: l = msgb\_tl\_put(msg, GSM48\_IE\_MOBILE\_ID);"{}}}
\DoxyCodeLine{66                                 \textcolor{stringliteral}{"{} *l = osmo\_mobile\_identity\_encode\_msgb(...)"{}});}
\DoxyCodeLine{67 }
\DoxyCodeLine{68 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *gsm48\_mi\_type\_name(uint8\_t mi);}
\DoxyCodeLine{69 \textcolor{comment}{/* Convert encoded Mobile Identity (10.5.1.4) to string */}}
\DoxyCodeLine{70 \textcolor{keywordtype}{int} gsm48\_mi\_to\_string(\textcolor{keywordtype}{char} *\textcolor{keywordtype}{string}, \textcolor{keywordtype}{int} str\_len, \textcolor{keyword}{const} uint8\_t *mi, \textcolor{keywordtype}{int} mi\_len)}
\DoxyCodeLine{71         OSMO\_DEPRECATED\_OUTSIDE(\textcolor{stringliteral}{"{}Instead use osmo\_mobile\_identity\_decode()"{}});}
\DoxyCodeLine{72 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *osmo\_mi\_name(\textcolor{keyword}{const} uint8\_t *mi, uint8\_t mi\_len)}
\DoxyCodeLine{73         OSMO\_DEPRECATED\_OUTSIDE(\textcolor{stringliteral}{"{}Instead use osmo\_mobile\_identity\_to\_str\_c()"{}});}
\DoxyCodeLine{74 \textcolor{keywordtype}{char} *osmo\_mi\_name\_buf(\textcolor{keywordtype}{char} *buf, \textcolor{keywordtype}{size\_t} buf\_len, \textcolor{keyword}{const} uint8\_t *mi, uint8\_t mi\_len)}
\DoxyCodeLine{75         OSMO\_DEPRECATED\_OUTSIDE(\textcolor{stringliteral}{"{}Instead use osmo\_mobile\_identity\_to\_str\_buf()"{}});}
\DoxyCodeLine{76 \textcolor{keywordtype}{char} *osmo\_mi\_name\_c(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *ctx, \textcolor{keyword}{const} uint8\_t *mi, uint8\_t mi\_len)}
\DoxyCodeLine{77         OSMO\_DEPRECATED\_OUTSIDE(\textcolor{stringliteral}{"{}Instead use osmo\_mobile\_identity\_to\_str\_c()"{}});}
\DoxyCodeLine{78 }
\DoxyCodeLine{81 \textcolor{keyword}{struct }osmo\_mobile\_identity \{}
\DoxyCodeLine{83         uint8\_t type;}
\DoxyCodeLine{86         \textcolor{keyword}{union }\{}
\DoxyCodeLine{88                 \textcolor{keywordtype}{char} imsi[GSM23003\_IMSI\_MAX\_DIGITS + 1];}
\DoxyCodeLine{90                 \textcolor{keywordtype}{char} imei[GSM23003\_IMEI\_NUM\_DIGITS + 1];}
\DoxyCodeLine{92                 \textcolor{keywordtype}{char} imeisv[GSM23003\_IMEISV\_NUM\_DIGITS + 1];}
\DoxyCodeLine{94                 uint32\_t tmsi;}
\DoxyCodeLine{95         \};}
\DoxyCodeLine{96 \};}
\DoxyCodeLine{97 }
\DoxyCodeLine{98 \textcolor{keywordtype}{int} osmo\_mobile\_identity\_to\_str\_buf(\textcolor{keywordtype}{char} *buf, \textcolor{keywordtype}{size\_t} buflen, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_mobile\_identity *mi);}
\DoxyCodeLine{99 \textcolor{keywordtype}{char} *osmo\_mobile\_identity\_to\_str\_c(\textcolor{keywordtype}{void} *ctx, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_mobile\_identity *mi);}
\DoxyCodeLine{100 \textcolor{keywordtype}{int} osmo\_mobile\_identity\_cmp(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_mobile\_identity *a, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_mobile\_identity *b);}
\DoxyCodeLine{101 \textcolor{keywordtype}{int} osmo\_mobile\_identity\_decode(\textcolor{keyword}{struct} osmo\_mobile\_identity *mi, \textcolor{keyword}{const} uint8\_t *mi\_data, uint8\_t mi\_len,}
\DoxyCodeLine{102                                 \textcolor{keywordtype}{bool} allow\_hex);}
\DoxyCodeLine{103 \textcolor{keywordtype}{int} osmo\_mobile\_identity\_decode\_from\_l3\_buf(\textcolor{keyword}{struct} osmo\_mobile\_identity *mi, \textcolor{keyword}{const} uint8\_t *l3\_data, \textcolor{keywordtype}{size\_t} l3\_len,}
\DoxyCodeLine{104                                             \textcolor{keywordtype}{bool} allow\_hex);}
\DoxyCodeLine{105 \textcolor{keywordtype}{int} osmo\_mobile\_identity\_decode\_from\_l3(\textcolor{keyword}{struct} osmo\_mobile\_identity *mi, \textcolor{keyword}{struct} msgb *msg, \textcolor{keywordtype}{bool} allow\_hex);}
\DoxyCodeLine{106 \textcolor{keywordtype}{int} osmo\_mobile\_identity\_encoded\_len(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_mobile\_identity *mi, \textcolor{keywordtype}{int} *mi\_digits);}
\DoxyCodeLine{107 \textcolor{keywordtype}{int} osmo\_mobile\_identity\_encode\_buf(uint8\_t *buf, \textcolor{keywordtype}{size\_t} buflen, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_mobile\_identity *mi, \textcolor{keywordtype}{bool} allow\_hex);}
\DoxyCodeLine{108 \textcolor{keywordtype}{int} osmo\_mobile\_identity\_encode\_msgb(\textcolor{keyword}{struct} msgb *msg, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_mobile\_identity *mi, \textcolor{keywordtype}{bool} allow\_hex);}
\DoxyCodeLine{109 }
\DoxyCodeLine{110 \textcolor{comment}{/* Parse Routeing Area Identifier */}}
\DoxyCodeLine{111 \textcolor{keywordtype}{int} osmo\_routing\_area\_id\_decode(\textcolor{keyword}{struct} osmo\_routing\_area\_id *dst, \textcolor{keyword}{const} uint8\_t *ra\_data, \textcolor{keywordtype}{size\_t} ra\_data\_len);}
\DoxyCodeLine{112 \textcolor{keywordtype}{int} osmo\_routing\_area\_id\_encode\_buf(uint8\_t *buf, \textcolor{keywordtype}{size\_t} buflen, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_routing\_area\_id *src);}
\DoxyCodeLine{113 \textcolor{keywordtype}{int} osmo\_routing\_area\_id\_encode\_msgb(\textcolor{keyword}{struct} msgb *msg, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_routing\_area\_id *src);}
\DoxyCodeLine{114 \textcolor{keywordtype}{void} gsm48\_parse\_ra(\textcolor{keyword}{struct} gprs\_ra\_id *raid, \textcolor{keyword}{const} uint8\_t *buf);}
\DoxyCodeLine{115 \textcolor{keywordtype}{void} gsm48\_encode\_ra(\textcolor{keyword}{struct} gsm48\_ra\_id *out, \textcolor{keyword}{const} \textcolor{keyword}{struct} gprs\_ra\_id *raid);}
\DoxyCodeLine{116 \textcolor{keywordtype}{int} gsm48\_construct\_ra(uint8\_t *buf, \textcolor{keyword}{const} \textcolor{keyword}{struct} gprs\_ra\_id *raid) OSMO\_DEPRECATED(\textcolor{stringliteral}{"{}Use gsm48\_encode\_ra() instead"{}});}
\DoxyCodeLine{117 \textcolor{keywordtype}{bool} gsm48\_ra\_equal(\textcolor{keyword}{const} \textcolor{keyword}{struct} gprs\_ra\_id *raid1, \textcolor{keyword}{const} \textcolor{keyword}{struct} gprs\_ra\_id *raid2);}
\DoxyCodeLine{118 }
\DoxyCodeLine{119 \textcolor{keywordtype}{int} gsm48\_number\_of\_paging\_subchannels(\textcolor{keyword}{const} \textcolor{keyword}{struct} gsm48\_control\_channel\_descr *chan\_desc);}
\DoxyCodeLine{120 }
\DoxyCodeLine{121 \textcolor{keywordtype}{void} gsm48\_mcc\_mnc\_to\_bcd(uint8\_t *bcd\_dst, uint16\_t mcc, uint16\_t mnc)}
\DoxyCodeLine{122         OSMO\_DEPRECATED(\textcolor{stringliteral}{"{}Use osmo\_plmn\_to\_bcd() instead, to not lose leading zeros in the MNC"{}});}
\DoxyCodeLine{123 \textcolor{keywordtype}{void} gsm48\_mcc\_mnc\_from\_bcd(uint8\_t *bcd\_src, uint16\_t *mcc, uint16\_t *mnc)}
\DoxyCodeLine{124         OSMO\_DEPRECATED(\textcolor{stringliteral}{"{}Use osmo\_plmn\_from\_bcd() instead, to not lose leading zeros in the MNC"{}});}
\DoxyCodeLine{125 }
\DoxyCodeLine{126 \textcolor{keyword}{struct }gsm48\_hdr *gsm48\_push\_l3hdr(\textcolor{keyword}{struct} msgb *msg,}
\DoxyCodeLine{127                                    uint8\_t pdisc, uint8\_t msg\_type);}
\DoxyCodeLine{128 }
\DoxyCodeLine{129 \textcolor{preprocessor}{\#define gsm48\_push\_l3hdr\_tid(msg, pdisc, tid, msg\_type) \(\backslash\)}}
\DoxyCodeLine{130 \textcolor{preprocessor}{        gsm48\_push\_l3hdr(msg, (pdisc \& 0x0f) | (tid << 4), msg\_type)}}
\DoxyCodeLine{131 }
\DoxyCodeLine{132 \textcolor{keyword}{enum} gsm48\_chan\_mode gsm48\_chan\_mode\_to\_vamos(\textcolor{keyword}{enum} gsm48\_chan\_mode mode);}
\DoxyCodeLine{133 \textcolor{keyword}{enum} gsm48\_chan\_mode gsm48\_chan\_mode\_to\_non\_vamos(\textcolor{keyword}{enum} gsm48\_chan\_mode mode);}

\end{DoxyCode}
