Loading...
Searching...
No Matches
rlp.h
Go to the documentation of this file.
/*
* GSM RLP (Radio Link Protocol) as used in CSD (3GPP TS 44.022)
*
* Copyright (C) 2022-2023 Harald Welte <laforge@osmocom.org>
*
* All Rights Reserved
*
* 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.
*/
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include <osmocom/core/utils.h>
enum osmo_rlp_ftype {
OSMO_RLP_FT_U,
OSMO_RLP_FT_S,
OSMO_RLP_FT_IS,
};
extern const struct value_string osmo_rlp_ftype_vals[];
enum osmo_rlp_u_ftype {
OSMO_RLP_U_FT_SABM = 0x07,
OSMO_RLP_U_FT_UA = 0x0c,
OSMO_RLP_U_FT_DISC = 0x08,
OSMO_RLP_U_FT_DM = 0x03,
OSMO_RLP_U_FT_NULL = 0x0f,
OSMO_RLP_U_FT_UI = 0x00,
OSMO_RLP_U_FT_XID = 0x17,
OSMO_RLP_U_FT_TEST = 0x1c,
OSMO_RLP_U_FT_REMAP = 0x11,
};
extern const struct value_string osmo_rlp_ftype_u_vals[];
enum osmo_rlp_s_ftype {
OSMO_RLP_S_FT_RR = 0,
OSMO_RLP_S_FT_REJ = 2,
OSMO_RLP_S_FT_RNR = 1,
OSMO_RLP_S_FT_SREJ = 3,
};
extern const struct value_string osmo_rlp_ftype_s_vals[];
struct osmo_rlp_frame_decoded {
uint8_t version;
enum osmo_rlp_ftype ftype;
enum osmo_rlp_u_ftype u_ftype;
enum osmo_rlp_s_ftype s_ftype;
bool c_r;
bool p_f;
uint8_t s_bits;
uint16_t n_s;
uint16_t n_r;
uint32_t fcs;
uint8_t info[536/8];
uint16_t info_len;
};
int osmo_rlp_decode(struct osmo_rlp_frame_decoded *out, uint8_t version, const uint8_t *data, size_t data_len);
int osmo_rlp_encode(uint8_t *out, size_t out_size, const struct osmo_rlp_frame_decoded *in);
uint32_t osmo_rlp_fcs_compute(const uint8_t *in, size_t in_len);
osmo_rlp_decode
int osmo_rlp_decode(struct osmo_rlp_frame_decoded *out, uint8_t version, const uint8_t *data, size_t data_len)
decode a RLP frame into its abstract representation.
Definition rlp.c:69
osmo_rlp_u_ftype
osmo_rlp_u_ftype
RLP U-Frame Type as per 3GPP TS 24.022 Section 5.2.1.
Definition rlp.h:39
osmo_rlp_encode
int osmo_rlp_encode(uint8_t *out, size_t out_size, const struct osmo_rlp_frame_decoded *in)
encode a RLP frame from its abstract representation.
Definition rlp.c:122
osmo_rlp_ftype_u_vals
const struct value_string osmo_rlp_ftype_u_vals[]
Definition rlp.c:39
osmo_rlp_s_ftype
osmo_rlp_s_ftype
RLP S-Frame type as per 3GPP TS 24.022 Section 5.2.1.
Definition rlp.h:53
osmo_rlp_ftype_s_vals
const struct value_string osmo_rlp_ftype_s_vals[]
Definition rlp.c:52
osmo_rlp_fcs_compute
uint32_t osmo_rlp_fcs_compute(const uint8_t *in, size_t in_len)
compute RLP FCS according to 3GPP TS 24.022 Section 4.4.
Definition rlp.c:230
osmo_rlp_ftype_vals
const struct value_string osmo_rlp_ftype_vals[]
Definition rlp.c:32
osmo_rlp_ftype
osmo_rlp_ftype
RLP frame type as per 3GPP TS 24.022 Section 5.2.1.
Definition rlp.h:31
OSMO_RLP_U_FT_REMAP
@ OSMO_RLP_U_FT_REMAP
Definition rlp.h:48
OSMO_RLP_U_FT_TEST
@ OSMO_RLP_U_FT_TEST
Definition rlp.h:47
OSMO_RLP_U_FT_XID
@ OSMO_RLP_U_FT_XID
Definition rlp.h:46
OSMO_RLP_U_FT_UI
@ OSMO_RLP_U_FT_UI
Definition rlp.h:45
OSMO_RLP_U_FT_DISC
@ OSMO_RLP_U_FT_DISC
Definition rlp.h:42
OSMO_RLP_U_FT_DM
@ OSMO_RLP_U_FT_DM
Definition rlp.h:43
OSMO_RLP_U_FT_SABM
@ OSMO_RLP_U_FT_SABM
Definition rlp.h:40
OSMO_RLP_U_FT_NULL
@ OSMO_RLP_U_FT_NULL
Definition rlp.h:44
OSMO_RLP_U_FT_UA
@ OSMO_RLP_U_FT_UA
Definition rlp.h:41
OSMO_RLP_S_FT_SREJ
@ OSMO_RLP_S_FT_SREJ
Definition rlp.h:57
OSMO_RLP_S_FT_RR
@ OSMO_RLP_S_FT_RR
Definition rlp.h:54
OSMO_RLP_S_FT_RNR
@ OSMO_RLP_S_FT_RNR
Definition rlp.h:56
OSMO_RLP_S_FT_REJ
@ OSMO_RLP_S_FT_REJ
Definition rlp.h:55
OSMO_RLP_FT_S
@ OSMO_RLP_FT_S
Definition rlp.h:33
OSMO_RLP_FT_IS
@ OSMO_RLP_FT_IS
Definition rlp.h:34
OSMO_RLP_FT_U
@ OSMO_RLP_FT_U
Definition rlp.h:32
osmo_rlp_frame_decoded
Data structure representing one decoded RLP frame.
Definition rlp.h:62
osmo_rlp_frame_decoded::ftype
enum osmo_rlp_ftype ftype
Definition rlp.h:64
osmo_rlp_frame_decoded::p_f
bool p_f
Definition rlp.h:68
osmo_rlp_frame_decoded::info_len
uint16_t info_len
Definition rlp.h:74
osmo_rlp_frame_decoded::fcs
uint32_t fcs
Definition rlp.h:72
osmo_rlp_frame_decoded::n_s
uint16_t n_s
Definition rlp.h:70
osmo_rlp_frame_decoded::s_bits
uint8_t s_bits
Definition rlp.h:69
osmo_rlp_frame_decoded::c_r
bool c_r
Definition rlp.h:67
osmo_rlp_frame_decoded::n_r
uint16_t n_r
Definition rlp.h:71
osmo_rlp_frame_decoded::version
uint8_t version
Definition rlp.h:63
osmo_rlp_frame_decoded::info
uint8_t info[536/8]
Definition rlp.h:73
osmo_rlp_frame_decoded::u_ftype
enum osmo_rlp_u_ftype u_ftype
Definition rlp.h:65
osmo_rlp_frame_decoded::s_ftype
enum osmo_rlp_s_ftype s_ftype
Definition rlp.h:66
value_string
utils.h