\doxysection{oap\+\_\+client.\+h}
\label{oap__client_8h_source}\index{include/osmocom/gsm/oap\_client.h@{include/osmocom/gsm/oap\_client.h}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 \textcolor{comment}{/* Osmocom Authentication Protocol API */}}
\DoxyCodeLine{2 }
\DoxyCodeLine{3 \textcolor{comment}{/* (C) 2015 by Sysmocom s.f.m.c. GmbH}}
\DoxyCodeLine{4 \textcolor{comment}{ * All Rights Reserved}}
\DoxyCodeLine{5 \textcolor{comment}{ *}}
\DoxyCodeLine{6 \textcolor{comment}{ * Author: Neels Hofmeyr}}
\DoxyCodeLine{7 \textcolor{comment}{ *}}
\DoxyCodeLine{8 \textcolor{comment}{ * This program is free software; you can redistribute it and/or modify}}
\DoxyCodeLine{9 \textcolor{comment}{ * it under the terms of the GNU General Public License as published by}}
\DoxyCodeLine{10 \textcolor{comment}{ * the Free Software Foundation; either version 2 of the License, or}}
\DoxyCodeLine{11 \textcolor{comment}{ * (at your option) any later version.}}
\DoxyCodeLine{12 \textcolor{comment}{ *}}
\DoxyCodeLine{13 \textcolor{comment}{ * This program is distributed in the hope that it will be useful,}}
\DoxyCodeLine{14 \textcolor{comment}{ * but WITHOUT ANY WARRANTY; without even the implied warranty of}}
\DoxyCodeLine{15 \textcolor{comment}{ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the}}
\DoxyCodeLine{16 \textcolor{comment}{ * GNU General Public License for more details.}}
\DoxyCodeLine{17 \textcolor{comment}{ *}}
\DoxyCodeLine{18 \textcolor{comment}{ * You should have received a copy of the GNU General Public License}}
\DoxyCodeLine{19 \textcolor{comment}{ * along with this program.  If not, see <http://www.gnu.org/licenses/>.}}
\DoxyCodeLine{20 \textcolor{comment}{ *}}
\DoxyCodeLine{21 \textcolor{comment}{ * SPDX-\/License-\/Identifier: GPL-\/2.0+}}
\DoxyCodeLine{22 \textcolor{comment}{ */}}
\DoxyCodeLine{23 }
\DoxyCodeLine{24 \textcolor{preprocessor}{\#pragma once}}
\DoxyCodeLine{25 }
\DoxyCodeLine{26 \textcolor{preprocessor}{\#include <stdint.h>}}
\DoxyCodeLine{27 }
\DoxyCodeLine{28 \textcolor{keyword}{struct }msgb;}
\DoxyCodeLine{29 \textcolor{keyword}{struct }osmo\_oap\_message;}
\DoxyCodeLine{30 }
\DoxyCodeLine{31 \textcolor{comment}{/* This is the config part for vty. It is essentially copied in}}
\DoxyCodeLine{32 \textcolor{comment}{ * oap\_client\_state, where values are copied over once the config is}}
\DoxyCodeLine{33 \textcolor{comment}{ * considered valid. */}}
\DoxyCodeLine{34 \textcolor{keyword}{struct }osmo\_oap\_client\_config \{}
\DoxyCodeLine{35         uint16\_t client\_id;}
\DoxyCodeLine{36         \textcolor{keywordtype}{int} secret\_k\_present;}
\DoxyCodeLine{37         uint8\_t secret\_k[16];}
\DoxyCodeLine{38         \textcolor{keywordtype}{int} secret\_opc\_present;}
\DoxyCodeLine{39         uint8\_t secret\_opc[16];}
\DoxyCodeLine{40 \};}
\DoxyCodeLine{41 }
\DoxyCodeLine{42 \textcolor{comment}{/* The runtime state of the OAP client. client\_id and the secrets are in fact}}
\DoxyCodeLine{43 \textcolor{comment}{ * duplicated from oap\_client\_config, so that a separate validation of the}}
\DoxyCodeLine{44 \textcolor{comment}{ * config data is possible, and so that only a struct oap\_client\_state* is}}
\DoxyCodeLine{45 \textcolor{comment}{ * passed around. */}}
\DoxyCodeLine{46 \textcolor{keyword}{struct }osmo\_oap\_client\_state \{}
\DoxyCodeLine{47         \textcolor{keyword}{enum} \{}
\DoxyCodeLine{48                 OSMO\_OAP\_UNINITIALIZED = 0,       \textcolor{comment}{/* just allocated. */}}
\DoxyCodeLine{49                 OSMO\_OAP\_DISABLED,             \textcolor{comment}{/* disabled by config. */}}
\DoxyCodeLine{50                 OSMO\_OAP\_INITIALIZED,               \textcolor{comment}{/* enabled, config is valid. */}}
\DoxyCodeLine{51                 OSMO\_OAP\_REQUESTED\_CHALLENGE,}
\DoxyCodeLine{52                 OSMO\_OAP\_SENT\_CHALLENGE\_RESULT,}
\DoxyCodeLine{53                 OSMO\_OAP\_REGISTERED}
\DoxyCodeLine{54         \} state;}
\DoxyCodeLine{55         uint16\_t client\_id;}
\DoxyCodeLine{56         uint8\_t secret\_k[16];}
\DoxyCodeLine{57         uint8\_t secret\_opc[16];}
\DoxyCodeLine{58         \textcolor{keywordtype}{int} registration\_failures;}
\DoxyCodeLine{59 \};}
\DoxyCodeLine{60 }
\DoxyCodeLine{61 \textcolor{comment}{/* From config, initialize state. Return 0 on success. */}}
\DoxyCodeLine{62 \textcolor{keywordtype}{int} osmo\_oap\_client\_init(\textcolor{keyword}{struct} osmo\_oap\_client\_config *config,}
\DoxyCodeLine{63                          \textcolor{keyword}{struct} osmo\_oap\_client\_state *state);}
\DoxyCodeLine{64 }
\DoxyCodeLine{65 \textcolor{comment}{/* Construct an OAP registration message and return in *msg\_tx. Use}}
\DoxyCodeLine{66 \textcolor{comment}{ * state-\/>client\_id and update state-\/>state.}}
\DoxyCodeLine{67 \textcolor{comment}{ * Return 0 on success, or a negative value on error.}}
\DoxyCodeLine{68 \textcolor{comment}{ * If an error is returned, *msg\_tx is guaranteed to be NULL. */}}
\DoxyCodeLine{69 \textcolor{keywordtype}{int} osmo\_oap\_client\_register(\textcolor{keyword}{struct} osmo\_oap\_client\_state *state, \textcolor{keyword}{struct} msgb **msg\_tx);}
\DoxyCodeLine{70 }
\DoxyCodeLine{71 \textcolor{comment}{/* Decode and act on a received OAP message msg\_rx. Update state-\/>state.  If a}}
\DoxyCodeLine{72 \textcolor{comment}{ * non-\/NULL pointer is returned in *msg\_tx, that msgb should be sent to the OAP}}
\DoxyCodeLine{73 \textcolor{comment}{ * server (and freed) by the caller. The received msg\_rx is not freed.}}
\DoxyCodeLine{74 \textcolor{comment}{ * Return 0 on success, or a negative value on error.}}
\DoxyCodeLine{75 \textcolor{comment}{ * If an error is returned, *msg\_tx is guaranteed to be NULL. */}}
\DoxyCodeLine{76 \textcolor{keywordtype}{int} osmo\_oap\_client\_handle(\textcolor{keyword}{struct} osmo\_oap\_client\_state *state,}
\DoxyCodeLine{77                            \textcolor{keyword}{const} \textcolor{keyword}{struct} msgb *msg\_rx, \textcolor{keyword}{struct} msgb **msg\_tx);}
\DoxyCodeLine{78 }
\DoxyCodeLine{79 \textcolor{comment}{/* Allocate a msgb and in it, return the encoded oap\_client\_msg. Return}}
\DoxyCodeLine{80 \textcolor{comment}{ * NULL on error. (Like oap\_client\_encode(), but also allocates a msgb.)}}
\DoxyCodeLine{81 \textcolor{comment}{ * About the name: the idea is do\_something(oap\_client\_encoded(my\_struct))}}
\DoxyCodeLine{82 \textcolor{comment}{ */}}
\DoxyCodeLine{83 \textcolor{keyword}{struct }msgb *osmo\_oap\_client\_encoded(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_oap\_message *oap\_client\_msg);}

\end{DoxyCode}
