diff options
author | Harald Welte <laforge@gnumonks.org> | 2016-04-27 18:32:35 +0200 |
---|---|---|
committer | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2016-12-11 03:42:58 +0100 |
commit | c0f00072929b126b21ba7bdfa2c93327ba652d08 (patch) | |
tree | 92442c5f1ab1b533ba27047093e8676b7b5223f3 /include | |
parent | 9795cf1b126d5567dbd0a25b56e9ba75be9513c1 (diff) |
import oap message parsing / encoding from openbsc.git; AGPL->GPL
In the process, also:
* Change the license from AGPLv3 to GPLv2-or-later;
* correct spelling of 'sysmocom' to lowercase;
* add '2016' to the copyright;
* rename to osmo_*;
* add API docs;
* add logging category DLOAP: define id and add to internal_cat;
* redirect all oap.c logging to DLOAP.
A unit test will follow in a subsequent patch, since it needs a minor tweak for
decoding of boolean values.
The related openbsc change-id is I2f06aaa6eb54eafa860cfed8e72e41d82ff1c4cf.
Tweaked-by: Neels Hofmeyr
Change-Id: If5099e60681a215e798b6675f21813f26769c253
Diffstat (limited to 'include')
-rw-r--r-- | include/Makefile.am | 1 | ||||
-rw-r--r-- | include/osmocom/core/logging.h | 3 | ||||
-rw-r--r-- | include/osmocom/gsm/oap.h | 72 |
3 files changed, 75 insertions, 1 deletions
diff --git a/include/Makefile.am b/include/Makefile.am index c1256916..0a300a84 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -82,6 +82,7 @@ nobase_include_HEADERS = \ osmocom/gsm/mncc.h \ osmocom/gsm/prim.h \ osmocom/gsm/l1sap.h \ + osmocom/gsm/oap.h \ osmocom/gsm/protocol/gsm_03_40.h \ osmocom/gsm/protocol/gsm_03_41.h \ osmocom/gsm/protocol/gsm_04_08.h \ diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index cc3919b6..1ca348a2 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -93,7 +93,8 @@ void logp(int subsys, const char *file, int line, int cont, const char *format, #define DLGTP -9 /*!< GTP (GPRS Tunneling Protocol */ #define DLSTATS -10 /*!< Statistics */ #define DLGSUP -11 /*!< Generic Subscriber Update Protocol */ -#define OSMO_NUM_DLIB 11 /*!< Number of logging sub-systems in libraries */ +#define DLOAP -12 /*!< Osmocom Authentication Protocol */ +#define OSMO_NUM_DLIB 12 /*!< Number of logging sub-systems in libraries */ /*! Configuration of singgle log category / sub-system */ struct log_category { diff --git a/include/osmocom/gsm/oap.h b/include/osmocom/gsm/oap.h new file mode 100644 index 00000000..d973013a --- /dev/null +++ b/include/osmocom/gsm/oap.h @@ -0,0 +1,72 @@ +/* Osmocom Authentication Protocol message encoder/decoder */ + +/* (C) 2015-2016 by sysmocom s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Neels Hofmeyr + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#pragma once + +#include <stdint.h> +#include <osmocom/core/msgb.h> +#include <osmocom/gsm/protocol/gsm_04_08_gprs.h> + +/*! \brief Information Element Identifiers for OAP IEs. + * They match osmo_gsup_iei (so far). */ +enum osmo_oap_iei { + OAP_CAUSE_IE = 0x02, + OAP_RAND_IE = 0x20, + OAP_AUTN_IE = 0x23, + OAP_XRES_IE = 0x24, + OAP_AUTS_IE = 0x25, + OAP_CLIENT_ID_IE = 0x30, +}; + +/*! \brief OAP message types */ +enum osmo_oap_message_type { + OAP_MSGT_REGISTER_REQUEST = 0b00000100, + OAP_MSGT_REGISTER_ERROR = 0b00000101, + OAP_MSGT_REGISTER_RESULT = 0b00000110, + + OAP_MSGT_CHALLENGE_REQUEST = 0b00001000, + OAP_MSGT_CHALLENGE_ERROR = 0b00001001, + OAP_MSGT_CHALLENGE_RESULT = 0b00001010, + + OAP_MSGT_SYNC_REQUEST = 0b00001100, + OAP_MSGT_SYNC_ERROR = 0b00001101, + OAP_MSGT_SYNC_RESULT = 0b00001110, +}; + +/*! \brief Parsed/decoded OAP protocol message */ +struct osmo_oap_message { + enum osmo_oap_message_type message_type; + enum gsm48_gmm_cause cause; + uint16_t client_id; + int rand_present; + uint8_t rand[16]; + int autn_present; + uint8_t autn[16]; + int xres_present; + uint8_t xres[8]; + int auts_present; + uint8_t auts[16]; +}; + +int osmo_oap_decode(struct osmo_oap_message *oap_msg, const uint8_t *data, + size_t data_len); +void osmo_oap_encode(struct msgb *msg, const struct osmo_oap_message *oap_msg); |