blob: ef83b7940e0f6f9ca7f6241b6ea94ac122da1787 [file] [log] [blame]
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02001/*! \file oap.h
2 * Osmocom Authentication Protocol message encoder/decoder. */
3/*
4 * (C) 2015-2016 by sysmocom s.f.m.c. GmbH
Harald Weltec0f00072016-04-27 18:32:35 +02005 * All Rights Reserved
6 *
7 * Author: Neels Hofmeyr
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 *
22 */
23
24#pragma once
25
26#include <stdint.h>
27#include <osmocom/core/msgb.h>
28#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
29
Neels Hofmeyr87e45502017-06-20 00:17:59 +020030/*! Information Element Identifiers for OAP IEs.
Harald Weltec0f00072016-04-27 18:32:35 +020031 * They match osmo_gsup_iei (so far). */
32enum osmo_oap_iei {
33 OAP_CAUSE_IE = 0x02,
34 OAP_RAND_IE = 0x20,
35 OAP_AUTN_IE = 0x23,
36 OAP_XRES_IE = 0x24,
37 OAP_AUTS_IE = 0x25,
38 OAP_CLIENT_ID_IE = 0x30,
39};
40
Neels Hofmeyr87e45502017-06-20 00:17:59 +020041/*! OAP message types */
Harald Weltec0f00072016-04-27 18:32:35 +020042enum osmo_oap_message_type {
43 OAP_MSGT_REGISTER_REQUEST = 0b00000100,
44 OAP_MSGT_REGISTER_ERROR = 0b00000101,
45 OAP_MSGT_REGISTER_RESULT = 0b00000110,
46
47 OAP_MSGT_CHALLENGE_REQUEST = 0b00001000,
48 OAP_MSGT_CHALLENGE_ERROR = 0b00001001,
49 OAP_MSGT_CHALLENGE_RESULT = 0b00001010,
50
51 OAP_MSGT_SYNC_REQUEST = 0b00001100,
52 OAP_MSGT_SYNC_ERROR = 0b00001101,
53 OAP_MSGT_SYNC_RESULT = 0b00001110,
54};
55
Neels Hofmeyr87e45502017-06-20 00:17:59 +020056/*! Parsed/decoded OAP protocol message */
Harald Weltec0f00072016-04-27 18:32:35 +020057struct osmo_oap_message {
58 enum osmo_oap_message_type message_type;
59 enum gsm48_gmm_cause cause;
60 uint16_t client_id;
61 int rand_present;
62 uint8_t rand[16];
63 int autn_present;
64 uint8_t autn[16];
65 int xres_present;
66 uint8_t xres[8];
67 int auts_present;
Neels Hofmeyr8352d312017-02-02 20:05:14 +010068 uint8_t auts[14];
Harald Weltec0f00072016-04-27 18:32:35 +020069};
70
71int osmo_oap_decode(struct osmo_oap_message *oap_msg, const uint8_t *data,
72 size_t data_len);
73void osmo_oap_encode(struct msgb *msg, const struct osmo_oap_message *oap_msg);