blob: 113d4bd17f3b123ec6506742111e0bc74fab5aa3 [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 *
Neels Hofmeyr02de87b2020-09-18 18:00:50 +020024 */
25#pragma once
26
27#include <osmocom/gsm/protocol/gsm_49_031.h>
28
29struct osmo_bsslap_err;
30struct osmo_gad_err;
31
32struct osmo_bssmap_le_err {
33 int rc;
34 enum bssmap_le_msgt msg_type;
35 enum bssmap_le_iei iei;
36 enum lcs_cause cause;
37 struct osmo_bsslap_err *bsslap_err;
38 struct osmo_gad_err *gad_err;
39 char *logmsg;
40};
41
42struct osmo_bssap_le_err {
43 int rc;
44 struct osmo_bssmap_le_err *bssmap_le_err;
45 void *dtap_err;
46 char *logmsg;
47};
48
49enum bssmap_le_msgt osmo_bssmap_le_msgt(const uint8_t *data, uint8_t len);
50
51extern const struct value_string osmo_bssmap_le_msgt_names[];
52static inline const char *osmo_bssmap_le_msgt_name(enum bssmap_le_msgt val)
53{ return get_value_string(osmo_bssmap_le_msgt_names, val); }
54
55extern const struct value_string osmo_bssmap_le_iei_names[];
56static inline const char *osmo_bssmap_le_iei_name(enum bssmap_le_iei val)
57{ return get_value_string(osmo_bssmap_le_iei_names, val); }
58
59int osmo_lcs_cause_enc(struct msgb *msg, const struct lcs_cause_ie *lcs_cause);
60int osmo_lcs_cause_dec(struct lcs_cause_ie *lcs_cause,
61 enum bssmap_le_msgt msgt, enum bssmap_le_iei iei,
62 struct osmo_bssmap_le_err **err, void *err_ctx,
63 const uint8_t *data, uint8_t len);
64
65int osmo_bssap_le_pdu_to_str_buf(char *buf, size_t buflen, const struct bssap_le_pdu *bssap_le);
66char *osmo_bssap_le_pdu_to_str_c(void *ctx, const struct bssap_le_pdu *bssap_le);
67
68struct msgb *osmo_bssap_le_enc(const struct bssap_le_pdu *pdu);
69int osmo_bssap_le_dec(struct bssap_le_pdu *pdu, struct osmo_bssap_le_err **err, void *err_ctx, struct msgb *msg);
70
71uint8_t osmo_bssmap_le_ie_enc_location_type(struct msgb *msg, const struct bssmap_le_location_type *location_type);
72int osmo_bssmap_le_ie_dec_location_type(struct bssmap_le_location_type *lt,
73 enum bssmap_le_msgt msgt, enum bssmap_le_iei iei,
74 struct osmo_bssmap_le_err **err, void *err_ctx,
75 const uint8_t *elem, uint8_t len);
76
77/*! @} */