blob: 1c750c8a7d22891f12f3dbc2c055fad6681eaebb [file] [log] [blame]
Neels Hofmeyr02de87b2020-09-18 18:00:50 +02001/*! \addtogroup bssmap_le
2 * @{
3 * \file bssmap_le.h
4 * Message encoding and decoding for 3GPP TS 49.031 BSSMAP-LE.
5 */
6/*
7 * (C) 2020 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
8 * All Rights Reserved
9 *
10 * Author: Neels Hofmeyr <neels@hofmeyr.de>
11 *
12 * SPDX-License-Identifier: GPL-2.0+
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 *
28 */
29#pragma once
30
31#include <osmocom/gsm/protocol/gsm_49_031.h>
32
33struct osmo_bsslap_err;
34struct osmo_gad_err;
35
36struct osmo_bssmap_le_err {
37 int rc;
38 enum bssmap_le_msgt msg_type;
39 enum bssmap_le_iei iei;
40 enum lcs_cause cause;
41 struct osmo_bsslap_err *bsslap_err;
42 struct osmo_gad_err *gad_err;
43 char *logmsg;
44};
45
46struct osmo_bssap_le_err {
47 int rc;
48 struct osmo_bssmap_le_err *bssmap_le_err;
49 void *dtap_err;
50 char *logmsg;
51};
52
53enum bssmap_le_msgt osmo_bssmap_le_msgt(const uint8_t *data, uint8_t len);
54
55extern const struct value_string osmo_bssmap_le_msgt_names[];
56static inline const char *osmo_bssmap_le_msgt_name(enum bssmap_le_msgt val)
57{ return get_value_string(osmo_bssmap_le_msgt_names, val); }
58
59extern const struct value_string osmo_bssmap_le_iei_names[];
60static inline const char *osmo_bssmap_le_iei_name(enum bssmap_le_iei val)
61{ return get_value_string(osmo_bssmap_le_iei_names, val); }
62
63int osmo_lcs_cause_enc(struct msgb *msg, const struct lcs_cause_ie *lcs_cause);
64int osmo_lcs_cause_dec(struct lcs_cause_ie *lcs_cause,
65 enum bssmap_le_msgt msgt, enum bssmap_le_iei iei,
66 struct osmo_bssmap_le_err **err, void *err_ctx,
67 const uint8_t *data, uint8_t len);
68
69int osmo_bssap_le_pdu_to_str_buf(char *buf, size_t buflen, const struct bssap_le_pdu *bssap_le);
70char *osmo_bssap_le_pdu_to_str_c(void *ctx, const struct bssap_le_pdu *bssap_le);
71
72struct msgb *osmo_bssap_le_enc(const struct bssap_le_pdu *pdu);
73int osmo_bssap_le_dec(struct bssap_le_pdu *pdu, struct osmo_bssap_le_err **err, void *err_ctx, struct msgb *msg);
74
75uint8_t osmo_bssmap_le_ie_enc_location_type(struct msgb *msg, const struct bssmap_le_location_type *location_type);
76int osmo_bssmap_le_ie_dec_location_type(struct bssmap_le_location_type *lt,
77 enum bssmap_le_msgt msgt, enum bssmap_le_iei iei,
78 struct osmo_bssmap_le_err **err, void *err_ctx,
79 const uint8_t *elem, uint8_t len);
80
81/*! @} */