\doxysection{gsm23003.\+h}
\label{gsm23003_8h_source}\index{include/osmocom/gsm/gsm23003.h@{include/osmocom/gsm/gsm23003.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 <stdbool.h>}}
\DoxyCodeLine{7 }
\DoxyCodeLine{8 \textcolor{comment}{/* 23.003 Chapter 12.1 */}}
\DoxyCodeLine{9 \textcolor{keyword}{struct }osmo\_plmn\_id \{}
\DoxyCodeLine{10         uint16\_t mcc;}
\DoxyCodeLine{11         uint16\_t mnc;}
\DoxyCodeLine{12         \textcolor{keywordtype}{bool} mnc\_3\_digits; \textcolor{comment}{/*< ignored and implied true if mnc > 99, otherwise defines leading zeros. */}}
\DoxyCodeLine{13 \};}
\DoxyCodeLine{14 }
\DoxyCodeLine{15 \textcolor{comment}{/* 4.1 */}}
\DoxyCodeLine{16 \textcolor{keyword}{struct }osmo\_location\_area\_id \{}
\DoxyCodeLine{17         \textcolor{keyword}{struct }osmo\_plmn\_id plmn;}
\DoxyCodeLine{18         uint16\_t lac;}
\DoxyCodeLine{19 \};}
\DoxyCodeLine{20 }
\DoxyCodeLine{21 \textcolor{comment}{/* 4.2 */}}
\DoxyCodeLine{22 \textcolor{keyword}{struct }osmo\_routing\_area\_id \{}
\DoxyCodeLine{23         \textcolor{keyword}{struct }osmo\_location\_area\_id lac;}
\DoxyCodeLine{24         uint8\_t rac;}
\DoxyCodeLine{25 \};}
\DoxyCodeLine{26 }
\DoxyCodeLine{27 \textcolor{comment}{/* 4.3.1 */}}
\DoxyCodeLine{28 \textcolor{keyword}{struct }osmo\_cell\_global\_id \{}
\DoxyCodeLine{29         \textcolor{keyword}{struct }osmo\_location\_area\_id lai;}
\DoxyCodeLine{30         uint16\_t cell\_identity;}
\DoxyCodeLine{31 \};}
\DoxyCodeLine{32 }
\DoxyCodeLine{33 \textcolor{comment}{/* 3GPP TS 48.018:}}
\DoxyCodeLine{34 \textcolor{comment}{ * 8c.1.4.1.1 GERAN BSS identification (RIM)}}
\DoxyCodeLine{35 \textcolor{comment}{ * sec 11.3.9 Cell Identifier */}}
\DoxyCodeLine{36 \textcolor{keyword}{struct }osmo\_cell\_global\_id\_ps \{}
\DoxyCodeLine{37         \textcolor{keyword}{struct }osmo\_routing\_area\_id rai;}
\DoxyCodeLine{38         uint16\_t cell\_identity;}
\DoxyCodeLine{39 \};}
\DoxyCodeLine{40 }
\DoxyCodeLine{44 \textcolor{keyword}{enum} osmo\_cgi\_part \{}
\DoxyCodeLine{45         OSMO\_CGI\_PART\_PLMN = 1,}
\DoxyCodeLine{46         OSMO\_CGI\_PART\_LAC = 2,}
\DoxyCodeLine{47         OSMO\_CGI\_PART\_CI = 4,}
\DoxyCodeLine{48         OSMO\_CGI\_PART\_RAC = 8,}
\DoxyCodeLine{49 \};}
\DoxyCodeLine{50 }
\DoxyCodeLine{51 \textcolor{comment}{/* Actually defined in 3GPP TS 48.008 3.2.2.27 Cell Identifier List,}}
\DoxyCodeLine{52 \textcolor{comment}{ * but conceptually belongs with the above structures. */}}
\DoxyCodeLine{53 \textcolor{keyword}{struct }osmo\_lac\_and\_ci\_id \{}
\DoxyCodeLine{54         uint16\_t lac;}
\DoxyCodeLine{55         uint16\_t ci;}
\DoxyCodeLine{56 \};}
\DoxyCodeLine{57 }
\DoxyCodeLine{58 \textcolor{comment}{/* 12.5 */}}
\DoxyCodeLine{59 \textcolor{keyword}{struct }osmo\_service\_area\_id \{}
\DoxyCodeLine{60         \textcolor{keyword}{struct }osmo\_location\_area\_id lai;}
\DoxyCodeLine{61         uint16\_t sac;}
\DoxyCodeLine{62 \};}
\DoxyCodeLine{63 }
\DoxyCodeLine{64 \textcolor{comment}{/* 12.6 */}}
\DoxyCodeLine{65 \textcolor{keyword}{struct }osmo\_shared\_network\_area\_id \{}
\DoxyCodeLine{66         \textcolor{keyword}{struct }osmo\_plmn\_id plmn;}
\DoxyCodeLine{67         uint32\_t snac;}
\DoxyCodeLine{68 \};}
\DoxyCodeLine{69 }
\DoxyCodeLine{70 \textcolor{comment}{/* 5.1 */}}
\DoxyCodeLine{71 \textcolor{keyword}{enum} osmo\_gsn\_addr\_type \{}
\DoxyCodeLine{72         GSN\_ADDR\_TYPE\_IPV4    = 0,}
\DoxyCodeLine{73         GSN\_ADDR\_TYPE\_IPV6    = 1,}
\DoxyCodeLine{74 \};}
\DoxyCodeLine{75 }
\DoxyCodeLine{76 \textcolor{comment}{/* 5.1 */}}
\DoxyCodeLine{77 \textcolor{keyword}{struct }osmo\_gsn\_address \{}
\DoxyCodeLine{78         \textcolor{keyword}{enum} osmo\_gsn\_addr\_type type;}
\DoxyCodeLine{79         uint8\_t length;}
\DoxyCodeLine{80         uint8\_t addr[16];}
\DoxyCodeLine{81 \};}
\DoxyCodeLine{82 }
\DoxyCodeLine{83 \textcolor{comment}{/* 19.4.2.3 */}}
\DoxyCodeLine{84 \textcolor{keyword}{struct }osmo\_tracking\_area\_id \{}
\DoxyCodeLine{85         \textcolor{keyword}{struct }osmo\_plmn\_id plmn;}
\DoxyCodeLine{86         uint16\_t tac;}
\DoxyCodeLine{87 \};}
\DoxyCodeLine{88 }
\DoxyCodeLine{89 \textcolor{keyword}{struct }osmo\_eutran\_cell\_global\_id \{}
\DoxyCodeLine{90         \textcolor{keyword}{struct }osmo\_plmn\_id plmn;}
\DoxyCodeLine{91         uint32\_t eci; \textcolor{comment}{/* FIXME */}}
\DoxyCodeLine{92 \};}
\DoxyCodeLine{93 }
\DoxyCodeLine{94 \textcolor{comment}{/* 2.8.1 */}}
\DoxyCodeLine{95 \textcolor{keyword}{struct }osmo\_mme\_id \{}
\DoxyCodeLine{96         uint16\_t group\_id;}
\DoxyCodeLine{97         uint8\_t code;}
\DoxyCodeLine{98 \};}
\DoxyCodeLine{99 }
\DoxyCodeLine{100 \textcolor{comment}{/* 2.8.1 */}}
\DoxyCodeLine{101 \textcolor{keyword}{struct }osmo\_gummei \{}
\DoxyCodeLine{102         \textcolor{keyword}{struct }osmo\_plmn\_id plmn;}
\DoxyCodeLine{103         \textcolor{keyword}{struct }osmo\_mme\_id mme;}
\DoxyCodeLine{104 \};}
\DoxyCodeLine{105 }
\DoxyCodeLine{106 \textcolor{comment}{/* 2.8.1 */}}
\DoxyCodeLine{107 \textcolor{keyword}{struct }osmo\_guti \{}
\DoxyCodeLine{108         \textcolor{keyword}{struct }osmo\_gummei gummei;}
\DoxyCodeLine{109         uint32\_t mtmsi;}
\DoxyCodeLine{110 \};}
\DoxyCodeLine{111 }
\DoxyCodeLine{112 \textcolor{keywordtype}{bool} osmo\_imsi\_str\_valid(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *imsi);}
\DoxyCodeLine{113 \textcolor{keywordtype}{bool} osmo\_msisdn\_str\_valid(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *msisdn);}
\DoxyCodeLine{114 \textcolor{keywordtype}{bool} osmo\_imei\_str\_valid(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *imei, \textcolor{keywordtype}{bool} with\_15th\_digit);}
\DoxyCodeLine{115 }
\DoxyCodeLine{116 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *osmo\_mcc\_name(uint16\_t mcc);}
\DoxyCodeLine{117 \textcolor{keywordtype}{char} *osmo\_mcc\_name\_buf(\textcolor{keywordtype}{char} *buf, \textcolor{keywordtype}{size\_t} buf\_len, uint16\_t mcc);}
\DoxyCodeLine{118 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *osmo\_mcc\_name\_c(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *ctx, uint16\_t mcc);}
\DoxyCodeLine{119 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *osmo\_mnc\_name(uint16\_t mnc, \textcolor{keywordtype}{bool} mnc\_3\_digits);}
\DoxyCodeLine{120 \textcolor{keywordtype}{char} *osmo\_mnc\_name\_buf(\textcolor{keywordtype}{char} *buf, \textcolor{keywordtype}{size\_t} buf\_len, uint16\_t mnc, \textcolor{keywordtype}{bool} mnc\_3\_digits);}
\DoxyCodeLine{121 \textcolor{keywordtype}{char} *osmo\_mnc\_name\_c(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *ctx, uint16\_t mnc, \textcolor{keywordtype}{bool} mnc\_3\_digits);}
\DoxyCodeLine{122 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *osmo\_plmn\_name(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_plmn\_id *plmn);}
\DoxyCodeLine{123 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *osmo\_plmn\_name2(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_plmn\_id *plmn);}
\DoxyCodeLine{124 \textcolor{keywordtype}{char} *osmo\_plmn\_name\_buf(\textcolor{keywordtype}{char} *buf, \textcolor{keywordtype}{size\_t} buf\_len, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_plmn\_id *plmn);}
\DoxyCodeLine{125 \textcolor{keywordtype}{char} *osmo\_plmn\_name\_c(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *ctx, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_plmn\_id *plmn);}
\DoxyCodeLine{126 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *osmo\_lai\_name(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_location\_area\_id *lai);}
\DoxyCodeLine{127 \textcolor{keywordtype}{char} *osmo\_lai\_name\_buf(\textcolor{keywordtype}{char} *buf, \textcolor{keywordtype}{size\_t} buf\_len, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_location\_area\_id *lai);}
\DoxyCodeLine{128 \textcolor{keywordtype}{char} *osmo\_lai\_name\_c(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *ctx, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_location\_area\_id *lai);}
\DoxyCodeLine{129 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *osmo\_rai\_name2(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_routing\_area\_id *rai);}
\DoxyCodeLine{130 \textcolor{keywordtype}{char} *osmo\_rai\_name2\_buf(\textcolor{keywordtype}{char} *buf, \textcolor{keywordtype}{size\_t} buf\_len, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_routing\_area\_id *rai);}
\DoxyCodeLine{131 \textcolor{keywordtype}{char} *osmo\_rai\_name2\_c(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *ctx, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_routing\_area\_id *rai);}
\DoxyCodeLine{132 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *osmo\_cgi\_name(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_cell\_global\_id *cgi);}
\DoxyCodeLine{133 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *osmo\_cgi\_name2(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_cell\_global\_id *cgi);}
\DoxyCodeLine{134 \textcolor{keywordtype}{char} *osmo\_cgi\_name\_buf(\textcolor{keywordtype}{char} *buf, \textcolor{keywordtype}{size\_t} buf\_len, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_cell\_global\_id *cgi);}
\DoxyCodeLine{135 \textcolor{keywordtype}{char} *osmo\_cgi\_name\_c(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *ctx, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_cell\_global\_id *cgi);}
\DoxyCodeLine{136 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *osmo\_cgi\_ps\_name(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_cell\_global\_id\_ps *cgi\_ps);}
\DoxyCodeLine{137 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *osmo\_cgi\_ps\_name2(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_cell\_global\_id\_ps *cgi\_ps);}
\DoxyCodeLine{138 \textcolor{keywordtype}{char} *osmo\_cgi\_ps\_name\_buf(\textcolor{keywordtype}{char} *buf, \textcolor{keywordtype}{size\_t} buf\_len, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_cell\_global\_id\_ps *cgi\_ps);}
\DoxyCodeLine{139 \textcolor{keywordtype}{char} *osmo\_cgi\_ps\_name\_c(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *ctx, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_cell\_global\_id\_ps *cgi\_ps);}
\DoxyCodeLine{140 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *osmo\_sai\_name(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_service\_area\_id *sai);}
\DoxyCodeLine{141 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *osmo\_sai\_name2(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_service\_area\_id *sai);}
\DoxyCodeLine{142 \textcolor{keywordtype}{char} *osmo\_sai\_name\_buf(\textcolor{keywordtype}{char} *buf, \textcolor{keywordtype}{size\_t} buf\_len, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_service\_area\_id *sai);}
\DoxyCodeLine{143 \textcolor{keywordtype}{char} *osmo\_sai\_name\_c(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *ctx, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_service\_area\_id *sai);}
\DoxyCodeLine{144 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *osmo\_gummei\_name(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_gummei *gummei);}
\DoxyCodeLine{145 \textcolor{keywordtype}{char} *osmo\_gummei\_name\_buf(\textcolor{keywordtype}{char} *buf, \textcolor{keywordtype}{size\_t} buf\_len, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_gummei *gummei);}
\DoxyCodeLine{146 \textcolor{keywordtype}{char} *osmo\_gummei\_name\_c(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *ctx, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_gummei *gummei);}
\DoxyCodeLine{147 }
\DoxyCodeLine{148 \textcolor{keywordtype}{void} osmo\_plmn\_to\_bcd(uint8\_t *bcd\_dst, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_plmn\_id *plmn);}
\DoxyCodeLine{149 \textcolor{keywordtype}{void} osmo\_plmn\_from\_bcd(\textcolor{keyword}{const} uint8\_t *bcd\_src, \textcolor{keyword}{struct} osmo\_plmn\_id *plmn);}
\DoxyCodeLine{150 }
\DoxyCodeLine{151 \textcolor{keywordtype}{int} osmo\_mnc\_from\_str(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *mnc\_str, uint16\_t *mnc, \textcolor{keywordtype}{bool} *mnc\_3\_digits);}
\DoxyCodeLine{152 }
\DoxyCodeLine{153 \textcolor{comment}{/* Convert string to MCC.}}
\DoxyCodeLine{154 \textcolor{comment}{ * \(\backslash\)param mcc\_str[in]   String representation of an MCC, with or without leading zeros.}}
\DoxyCodeLine{155 \textcolor{comment}{ * \(\backslash\)param mcc[out]      MCC result buffer, or NULL.}}
\DoxyCodeLine{156 \textcolor{comment}{ * \(\backslash\)returns zero on success, -\/EINVAL in case of surplus characters, negative errno in case of conversion}}
\DoxyCodeLine{157 \textcolor{comment}{ *          errors. In case of error, do not modify the out-\/arguments.}}
\DoxyCodeLine{158 \textcolor{comment}{ */}}
\DoxyCodeLine{159 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{int} osmo\_mcc\_from\_str(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *mcc\_str, uint16\_t *mcc)}
\DoxyCodeLine{160 \{}
\DoxyCodeLine{161         \textcolor{keywordflow}{return} osmo\_mnc\_from\_str(mcc\_str, mcc, NULL);}
\DoxyCodeLine{162 \}}
\DoxyCodeLine{163 }
\DoxyCodeLine{164 \textcolor{keywordtype}{int} osmo\_mnc\_cmp(uint16\_t a\_mnc, \textcolor{keywordtype}{bool} a\_mnc\_3\_digits, uint16\_t b\_mnc, \textcolor{keywordtype}{bool} b\_mnc\_3\_digits);}
\DoxyCodeLine{165 \textcolor{keywordtype}{int} osmo\_plmn\_cmp(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_plmn\_id *a, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_plmn\_id *b);}
\DoxyCodeLine{166 \textcolor{keywordtype}{int} osmo\_lai\_cmp(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_location\_area\_id *a, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_location\_area\_id *b);}
\DoxyCodeLine{167 \textcolor{keywordtype}{int} osmo\_rai\_cmp(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_routing\_area\_id *a, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_routing\_area\_id *b);}
\DoxyCodeLine{168 \textcolor{keywordtype}{int} osmo\_cgi\_cmp(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_cell\_global\_id *a, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_cell\_global\_id *b);}
\DoxyCodeLine{169 \textcolor{keywordtype}{int} osmo\_cgi\_ps\_cmp(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_cell\_global\_id\_ps *a, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_cell\_global\_id\_ps *b);}
\DoxyCodeLine{170 }
\DoxyCodeLine{171 \textcolor{keywordtype}{int} osmo\_gen\_home\_network\_domain(\textcolor{keywordtype}{char} *out, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_plmn\_id *plmn);}
\DoxyCodeLine{172 \textcolor{keywordtype}{int} osmo\_parse\_home\_network\_domain(\textcolor{keyword}{struct} osmo\_plmn\_id *out, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *in);}
\DoxyCodeLine{173 \textcolor{keywordtype}{int} osmo\_gen\_mme\_domain(\textcolor{keywordtype}{char} *out, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_gummei *gummei);}
\DoxyCodeLine{174 \textcolor{keywordtype}{int} osmo\_gen\_mme\_group\_domain(\textcolor{keywordtype}{char} *out, uint16\_t mmegi, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_plmn\_id *plmn);}
\DoxyCodeLine{175 \textcolor{keywordtype}{int} osmo\_parse\_mme\_domain(\textcolor{keyword}{struct} osmo\_gummei *out, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *in);}

\end{DoxyCode}
