Loading...
Searching...
No Matches
lapdm.h
Go to the documentation of this file.
#pragma once
#include <osmocom/gsm/l1sap.h>
#include <osmocom/gsm/gsm_utils.h>
#include <osmocom/gsm/lapd_core.h>
enum lapdm_mode {
LAPDM_MODE_MS,
LAPDM_MODE_BTS,
};
struct lapdm_entity;
struct lapdm_msg_ctx {
struct lapdm_datalink *dl;
int lapdm_fmt;
uint8_t chan_nr;
uint8_t link_id;
uint8_t ta_ind; /* TA indicated by network */
uint8_t tx_power_ind; /* MS power indicated by network */
uint32_t fn;
};
struct lapdm_datalink {
struct lapd_datalink dl; /* common LAPD */
struct lapdm_msg_ctx mctx;
struct lapdm_entity *entity;
struct llist_head tx_ui_queue;
uint32_t t200_fn;
uint32_t t200_timeout;
};
enum lapdm_dl_sapi {
DL_SAPI0 = 0,
DL_SAPI3 = 1,
_NR_DL_SAPI
};
typedef int (*lapdm_cb_t)(struct msgb *msg, struct lapdm_entity *le, void *ctx);
#define LAPDM_ENT_F_EMPTY_FRAME 0x0001
#define LAPDM_ENT_F_POLLING_ONLY 0x0002
#define LAPDM_ENT_F_DROP_2ND_REJ 0x0004
#define LAPDM_ENT_F_RTS 0x0008
struct lapdm_entity {
struct lapdm_datalink datalink[_NR_DL_SAPI];
int last_tx_dequeue;
int tx_pending;
enum lapdm_mode mode;
unsigned int flags;
void *l1_ctx;
void *l3_ctx;
osmo_prim_cb l1_prim_cb;
lapdm_cb_t l3_cb;
struct lapdm_channel *lapdm_ch;
uint8_t ta; /* TA used and indicated to network */
uint8_t tx_power; /* MS power used and indicated to network */
};
struct lapdm_channel {
struct llist_head list;
char *name;
struct lapdm_entity lapdm_acch;
struct lapdm_entity lapdm_dcch;
};
const char *get_rsl_name(int value);
extern const char *lapdm_state_names[];
struct lapdm_datalink *lapdm_datalink_for_sapi(struct lapdm_entity *le, uint8_t sapi);
/* initialize a LAPDm entity */
void lapdm_entity_init(struct lapdm_entity *le, enum lapdm_mode mode, int t200)
OSMO_DEPRECATED("Use lapdm_entity_init3() instead");
void lapdm_entity_init2(struct lapdm_entity *le, enum lapdm_mode mode,
const int *t200_ms, int n200)
OSMO_DEPRECATED("Use lapdm_entity_init3() instead");
void lapdm_entity_init3(struct lapdm_entity *le, enum lapdm_mode mode,
const int *t200_ms, int n200, const char *name_pfx);
void lapdm_channel_init(struct lapdm_channel *lc, enum lapdm_mode mode)
OSMO_DEPRECATED_OUTSIDE("Use lapdm_channel_init3() instead");
int lapdm_channel_init2(struct lapdm_channel *lc, enum lapdm_mode mode,
const int *t200_ms_dcch, const int *t200_ms_acch, enum gsm_chan_t chan_t);
int lapdm_channel_init3(struct lapdm_channel *lc, enum lapdm_mode mode,
const int *t200_ms_dcch, const int *t200_ms_acch, enum gsm_chan_t chan_t,
const char *name_pfx);
/* deinitialize a LAPDm entity */
void lapdm_entity_exit(struct lapdm_entity *le);
void lapdm_channel_exit(struct lapdm_channel *lc);
/* input into layer2 (from layer 1) */
int lapdm_phsap_up(struct osmo_prim_hdr *oph, struct lapdm_entity *le);
/* input into layer2 (from layer 3) */
int lapdm_rslms_recvmsg(struct msgb *msg, struct lapdm_channel *lc);
void lapdm_channel_set_l3(struct lapdm_channel *lc, lapdm_cb_t cb, void *ctx);
void lapdm_channel_set_l1(struct lapdm_channel *lc, osmo_prim_cb cb, void *ctx);
int lapdm_entity_set_mode(struct lapdm_entity *le, enum lapdm_mode mode);
int lapdm_channel_set_mode(struct lapdm_channel *lc, enum lapdm_mode mode);
void lapdm_entity_reset(struct lapdm_entity *le);
void lapdm_channel_reset(struct lapdm_channel *lc);
void lapdm_entity_set_flags(struct lapdm_entity *le, unsigned int flags);
void lapdm_channel_set_flags(struct lapdm_channel *lc, unsigned int flags);
void lapdm_entity_set_t200_fn(struct lapdm_entity *le, const uint32_t *t200_fn);
void lapdm_channel_set_t200_fn(struct lapdm_channel *lc, const uint32_t *t200_fn_dcch, const uint32_t *t200_fn_acch);
int lapdm_phsap_dequeue_prim(struct lapdm_entity *le, struct osmo_phsap_prim *pp);
int lapdm_phsap_dequeue_prim_fn(struct lapdm_entity *le, struct osmo_phsap_prim *pp, uint32_t fn);
void lapdm_t200_fn(struct lapdm_entity *le, uint32_t fn);
flags
uint16_t flags
lapdm_entity_set_mode
int lapdm_entity_set_mode(struct lapdm_entity *le, enum lapdm_mode mode)
Set the lapdm_mode of a LAPDm entity.
Definition lapdm.c:1553
lapdm_cb_t
int(* lapdm_cb_t)(struct msgb *msg, struct lapdm_entity *le, void *ctx)
Definition lapdm.h:49
get_rsl_name
const char * get_rsl_name(int value)
lapdm_entity_init3
void lapdm_entity_init3(struct lapdm_entity *le, enum lapdm_mode mode, const int *t200_ms, int n200, const char *name_pfx)
initialize a LAPDm entity and all datalinks inside
Definition lapdm.c:191
lapdm_datalink_for_sapi
struct lapdm_datalink * lapdm_datalink_for_sapi(struct lapdm_entity *le, uint8_t sapi)
Definition lapdm.c:315
lapdm_channel_set_flags
void lapdm_channel_set_flags(struct lapdm_channel *lc, unsigned int flags)
Set the flags of all LAPDm entities in a LAPDm channel.
Definition lapdm.c:1650
lapdm_entity_init
void lapdm_entity_init(struct lapdm_entity *le, enum lapdm_mode mode, int t200) OSMO_DEPRECATED("Use lapdm_entity_init3() instead")
initialize a LAPDm entity and all datalinks inside
Definition lapdm.c:160
lapdm_entity_set_flags
void lapdm_entity_set_flags(struct lapdm_entity *le, unsigned int flags)
Set the flags of a LAPDm entity.
Definition lapdm.c:1629
lapdm_phsap_dequeue_prim_fn
int lapdm_phsap_dequeue_prim_fn(struct lapdm_entity *le, struct osmo_phsap_prim *pp, uint32_t fn)
dequeue a msg that's pending transmission via L1 and wrap it into a osmo_phsap_prim
Definition lapdm.c:501
lapdm_channel_set_l1
void lapdm_channel_set_l1(struct lapdm_channel *lc, osmo_prim_cb cb, void *ctx)
Set the L1 callback and context of a LAPDm channel.
Definition lapdm.c:1591
lapdm_dl_sapi
lapdm_dl_sapi
LAPDm datalink SAPIs.
Definition lapdm.h:43
lapdm_entity_exit
void lapdm_entity_exit(struct lapdm_entity *le)
flush and release all resoures in LAPDm entity
Definition lapdm.c:292
lapdm_state_names
const char * lapdm_state_names[]
lapdm_entity_set_t200_fn
void lapdm_entity_set_t200_fn(struct lapdm_entity *le, const uint32_t *t200_fn)
Set the T200 FN timer of a LAPDm entity.
Definition lapdm.c:1659
lapdm_entity_reset
void lapdm_entity_reset(struct lapdm_entity *le)
Reset an entire LAPDm entity and all its datalinks.
Definition lapdm.c:1609
lapdm_phsap_up
int lapdm_phsap_up(struct osmo_prim_hdr *oph, struct lapdm_entity *le)
Receive a PH-SAP primitive from L1.
Definition lapdm.c:1041
lapdm_channel_init3
int lapdm_channel_init3(struct lapdm_channel *lc, enum lapdm_mode mode, const int *t200_ms_dcch, const int *t200_ms_acch, enum gsm_chan_t chan_t, const char *name_pfx)
initialize a LAPDm channel and all its channels
Definition lapdm.c:261
lapdm_channel_init
void lapdm_channel_init(struct lapdm_channel *lc, enum lapdm_mode mode) OSMO_DEPRECATED_OUTSIDE("Use lapdm_channel_init3() instead")
initialize a LAPDm channel and all its channels
Definition lapdm.c:231
lapdm_channel_set_mode
int lapdm_channel_set_mode(struct lapdm_channel *lc, enum lapdm_mode mode)
Set the lapdm_mode of a LAPDm channel.
Definition lapdm.c:1579
lapdm_entity_init2
void lapdm_entity_init2(struct lapdm_entity *le, enum lapdm_mode mode, const int *t200_ms, int n200) OSMO_DEPRECATED("Use lapdm_entity_init3() instead")
initialize a LAPDm entity and all datalinks inside
Definition lapdm.c:178
lapdm_t200_fn
void lapdm_t200_fn(struct lapdm_entity *le, uint32_t fn)
Get receive frame number from L1.
Definition lapdm.c:564
lapdm_phsap_dequeue_prim
int lapdm_phsap_dequeue_prim(struct lapdm_entity *le, struct osmo_phsap_prim *pp)
dequeue a msg that's pending transmission via L1 and wrap it into a osmo_phsap_prim
Definition lapdm.c:579
lapdm_channel_reset
void lapdm_channel_reset(struct lapdm_channel *lc)
Reset a LAPDm channel with all its entities.
Definition lapdm.c:1622
lapdm_channel_set_l3
void lapdm_channel_set_l3(struct lapdm_channel *lc, lapdm_cb_t cb, void *ctx)
Set the L3 callback and context of a LAPDm channel.
Definition lapdm.c:1600
lapdm_channel_exit
void lapdm_channel_exit(struct lapdm_channel *lc)
Definition lapdm.c:309
lapdm_mode
lapdm_mode
LAPDm mode/role.
Definition lapdm.h:12
lapdm_channel_init2
int lapdm_channel_init2(struct lapdm_channel *lc, enum lapdm_mode mode, const int *t200_ms_dcch, const int *t200_ms_acch, enum gsm_chan_t chan_t)
initialize a LAPDm channel and all its channels
Definition lapdm.c:247
lapdm_channel_set_t200_fn
void lapdm_channel_set_t200_fn(struct lapdm_channel *lc, const uint32_t *t200_fn_dcch, const uint32_t *t200_fn_acch)
Set the T200 FN timer of all LAPDm entities in a LAPDm channel.
Definition lapdm.c:1671
lapdm_rslms_recvmsg
int lapdm_rslms_recvmsg(struct msgb *msg, struct lapdm_channel *lc)
Receive a RSLms Message buffers from Layer 3.
Definition lapdm.c:1524
DL_SAPI3
@ DL_SAPI3
SAPI 1.
Definition lapdm.h:45
_NR_DL_SAPI
@ _NR_DL_SAPI
Definition lapdm.h:46
DL_SAPI0
@ DL_SAPI0
SAPI 0.
Definition lapdm.h:44
LAPDM_MODE_MS
@ LAPDM_MODE_MS
behave like a MS (mobile phone)
Definition lapdm.h:13
LAPDM_MODE_BTS
@ LAPDM_MODE_BTS
behave like a BTS (network)
Definition lapdm.h:14
osmo_prim_cb
int(* osmo_prim_cb)(struct osmo_prim_hdr *oph, void *ctx)
OSMO_DEPRECATED_OUTSIDE
#define OSMO_DEPRECATED_OUTSIDE(text)
OSMO_DEPRECATED
#define OSMO_DEPRECATED(text)
mode
uint8_t mode
Definition gsm_04_08.h:1
msg
uint8_t msg[0]
Definition gsm_08_08.h:8
gsm_utils.h
GSM utility functions, e.g.
gsm_chan_t
gsm_chan_t
Definition gsm_utils.h:236
l1sap.h
lapd_core.h
lapd_datalink
lapdm_channel
the two lapdm_entities that form a GSM logical channel (ACCH + DCCH)
Definition lapdm.h:79
lapdm_channel::list
struct llist_head list
internal linked list
Definition lapdm.h:80
lapdm_channel::name
char * name
human-readable name
Definition lapdm.h:81
lapdm_channel::lapdm_dcch
struct lapdm_entity lapdm_dcch
Dedicated Control Channel.
Definition lapdm.h:83
lapdm_channel::lapdm_acch
struct lapdm_entity lapdm_acch
Associated Control Channel.
Definition lapdm.h:82
lapdm_datalink
LAPDm datalink like TS 04.06 / Section 3.5.2.
Definition lapdm.h:31
lapdm_datalink::t200_fn
uint32_t t200_fn
T200 timer in frames.
Definition lapdm.h:38
lapdm_datalink::mctx
struct lapdm_msg_ctx mctx
context of established connection
Definition lapdm.h:33
lapdm_datalink::t200_timeout
uint32_t t200_timeout
T200 timeout frame number.
Definition lapdm.h:39
lapdm_datalink::entity
struct lapdm_entity * entity
LAPDm entity we are part of.
Definition lapdm.h:35
lapdm_datalink::tx_ui_queue
struct llist_head tx_ui_queue
UI frames to L1.
Definition lapdm.h:37
lapdm_datalink::dl
struct lapd_datalink dl
Definition lapdm.h:32
lapdm_entity
a LAPDm Entity
Definition lapdm.h:57
lapdm_entity::flags
unsigned int flags
Definition lapdm.h:63
lapdm_entity::mode
enum lapdm_mode mode
are we in BTS mode or MS mode
Definition lapdm.h:62
lapdm_entity::l3_ctx
void * l3_ctx
context for layer3 instance
Definition lapdm.h:66
lapdm_entity::datalink
struct lapdm_datalink datalink[_NR_DL_SAPI]
the SAPIs of the LAPDm entity
Definition lapdm.h:59
lapdm_entity::l1_prim_cb
osmo_prim_cb l1_prim_cb
callback for sending prims to L1
Definition lapdm.h:68
lapdm_entity::last_tx_dequeue
int last_tx_dequeue
last entity that was dequeued
Definition lapdm.h:60
lapdm_entity::lapdm_ch
struct lapdm_channel * lapdm_ch
pointer to lapdm_channel of which we're part
Definition lapdm.h:72
lapdm_entity::l3_cb
lapdm_cb_t l3_cb
callback for sending stuff to L3
Definition lapdm.h:69
lapdm_entity::l1_ctx
void * l1_ctx
context for layer1 instance
Definition lapdm.h:65
lapdm_entity::tx_power
uint8_t tx_power
Definition lapdm.h:75
lapdm_entity::tx_pending
int tx_pending
currently a pending frame not confirmed by L1
Definition lapdm.h:61
lapdm_entity::ta
uint8_t ta
Definition lapdm.h:74
lapdm_msg_ctx
LAPDm message context.
Definition lapdm.h:20
lapdm_msg_ctx::lapdm_fmt
int lapdm_fmt
Definition lapdm.h:22
lapdm_msg_ctx::tx_power_ind
uint8_t tx_power_ind
Definition lapdm.h:26
lapdm_msg_ctx::link_id
uint8_t link_id
Definition lapdm.h:24
lapdm_msg_ctx::ta_ind
uint8_t ta_ind
Definition lapdm.h:25
lapdm_msg_ctx::dl
struct lapdm_datalink * dl
Definition lapdm.h:21
lapdm_msg_ctx::fn
uint32_t fn
Definition lapdm.h:27
lapdm_msg_ctx::chan_nr
uint8_t chan_nr
Definition lapdm.h:23
llist_head
msgb
osmo_phsap_prim
primitive header for PH-SAP primitives
Definition l1sap.h:166
osmo_prim_hdr