libosmogsm 1.9.0.196-9975
Osmocom GSM library
lapdm.h
Go to the documentation of this file.
1#pragma once
2
3#include <osmocom/gsm/l1sap.h>
6
15};
16
17struct lapdm_entity;
18
23 uint8_t chan_nr;
24 uint8_t link_id;
25 uint8_t ta_ind; /* TA indicated by network */
26 uint8_t tx_power_ind; /* MS power indicated by network */
27 uint32_t fn;
28};
29
32 struct lapd_datalink dl; /* common LAPD */
38 uint32_t t200_fn;
39 uint32_t t200_timeout;
40};
41
47};
48
49typedef int (*lapdm_cb_t)(struct msgb *msg, struct lapdm_entity *le, void *ctx);
50
51#define LAPDM_ENT_F_EMPTY_FRAME 0x0001
52#define LAPDM_ENT_F_POLLING_ONLY 0x0002
53#define LAPDM_ENT_F_DROP_2ND_REJ 0x0004
54#define LAPDM_ENT_F_RTS 0x0008
55
63 unsigned int flags;
64
65 void *l1_ctx;
66 void *l3_ctx;
73
74 uint8_t ta; /* TA used and indicated to network */
75 uint8_t tx_power; /* MS power used and indicated to network */
76};
77
81 char *name;
84};
85
86const char *get_rsl_name(int value);
87extern const char *lapdm_state_names[];
88
89struct lapdm_datalink *lapdm_datalink_for_sapi(struct lapdm_entity *le, uint8_t sapi);
90
91/* initialize a LAPDm entity */
92void lapdm_entity_init(struct lapdm_entity *le, enum lapdm_mode mode, int t200)
93 OSMO_DEPRECATED("Use lapdm_entity_init3() instead");
95 const int *t200_ms, int n200)
96 OSMO_DEPRECATED("Use lapdm_entity_init3() instead");
98 const int *t200_ms, int n200, const char *name_pfx);
100 OSMO_DEPRECATED_OUTSIDE("Use lapdm_channel_init3() instead");
102 const int *t200_ms_dcch, const int *t200_ms_acch, enum gsm_chan_t chan_t);
104 const int *t200_ms_dcch, const int *t200_ms_acch, enum gsm_chan_t chan_t,
105 const char *name_pfx);
106/* deinitialize a LAPDm entity */
107void lapdm_entity_exit(struct lapdm_entity *le);
108void lapdm_channel_exit(struct lapdm_channel *lc);
109
110/* input into layer2 (from layer 1) */
111int lapdm_phsap_up(struct osmo_prim_hdr *oph, struct lapdm_entity *le);
112
113/* input into layer2 (from layer 3) */
114int lapdm_rslms_recvmsg(struct msgb *msg, struct lapdm_channel *lc);
115
116void lapdm_channel_set_l3(struct lapdm_channel *lc, lapdm_cb_t cb, void *ctx);
117void lapdm_channel_set_l1(struct lapdm_channel *lc, osmo_prim_cb cb, void *ctx);
118
121
122void lapdm_entity_reset(struct lapdm_entity *le);
123void lapdm_channel_reset(struct lapdm_channel *lc);
124
125void lapdm_entity_set_flags(struct lapdm_entity *le, unsigned int flags);
126void lapdm_channel_set_flags(struct lapdm_channel *lc, unsigned int flags);
127
128void lapdm_entity_set_t200_fn(struct lapdm_entity *le, const uint32_t *t200_fn);
129void lapdm_channel_set_t200_fn(struct lapdm_channel *lc, const uint32_t *t200_fn_dcch, const uint32_t *t200_fn_acch);
130
131int lapdm_phsap_dequeue_prim(struct lapdm_entity *le, struct osmo_phsap_prim *pp);
132int lapdm_phsap_dequeue_prim_fn(struct lapdm_entity *le, struct osmo_phsap_prim *pp, uint32_t fn);
133void lapdm_t200_fn(struct lapdm_entity *le, uint32_t fn);
134
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
int(* lapdm_cb_t)(struct msgb *msg, struct lapdm_entity *le, void *ctx)
Definition: lapdm.h:49
const char * get_rsl_name(int value)
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
struct lapdm_datalink * lapdm_datalink_for_sapi(struct lapdm_entity *le, uint8_t sapi)
Definition: lapdm.c:315
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
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
void lapdm_entity_set_flags(struct lapdm_entity *le, unsigned int flags)
Set the flags of a LAPDm entity.
Definition: lapdm.c:1629
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
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 datalink SAPIs.
Definition: lapdm.h:43
void lapdm_entity_exit(struct lapdm_entity *le)
flush and release all resoures in LAPDm entity
Definition: lapdm.c:292
const char * lapdm_state_names[]
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
void lapdm_entity_reset(struct lapdm_entity *le)
Reset an entire LAPDm entity and all its datalinks.
Definition: lapdm.c:1609
int lapdm_phsap_up(struct osmo_prim_hdr *oph, struct lapdm_entity *le)
Receive a PH-SAP primitive from L1.
Definition: lapdm.c:1041
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
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
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
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
void lapdm_t200_fn(struct lapdm_entity *le, uint32_t fn)
Get receive frame number from L1.
Definition: lapdm.c:564
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
void lapdm_channel_reset(struct lapdm_channel *lc)
Reset a LAPDm channel with all its entities.
Definition: lapdm.c:1622
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
void lapdm_channel_exit(struct lapdm_channel *lc)
Definition: lapdm.c:309
lapdm_mode
LAPDm mode/role.
Definition: lapdm.h:12
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
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
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
SAPI 1.
Definition: lapdm.h:45
@ _NR_DL_SAPI
Definition: lapdm.h:46
@ DL_SAPI0
SAPI 0.
Definition: lapdm.h:44
@ LAPDM_MODE_MS
behave like a MS (mobile phone)
Definition: lapdm.h:13
@ LAPDM_MODE_BTS
behave like a BTS (network)
Definition: lapdm.h:14
int(* osmo_prim_cb)(struct osmo_prim_hdr *oph, void *ctx)
#define OSMO_DEPRECATED_OUTSIDE(text)
#define OSMO_DEPRECATED(text)
uint8_t mode
Definition: gsm_04_08.h:1
uint8_t msg[0]
Definition: gsm_08_08.h:8
GSM utility functions, e.g.
gsm_chan_t
Definition: gsm_utils.h:235
the two lapdm_entities that form a GSM logical channel (ACCH + DCCH)
Definition: lapdm.h:79
struct llist_head list
internal linked list
Definition: lapdm.h:80
char * name
human-readable name
Definition: lapdm.h:81
struct lapdm_entity lapdm_dcch
Dedicated Control Channel.
Definition: lapdm.h:83
struct lapdm_entity lapdm_acch
Associated Control Channel.
Definition: lapdm.h:82
a LAPDm Entity
Definition: lapdm.h:57
unsigned int flags
Definition: lapdm.h:63
enum lapdm_mode mode
are we in BTS mode or MS mode
Definition: lapdm.h:62
void * l3_ctx
context for layer3 instance
Definition: lapdm.h:66
struct lapdm_datalink datalink[_NR_DL_SAPI]
the SAPIs of the LAPDm entity
Definition: lapdm.h:59
osmo_prim_cb l1_prim_cb
callback for sending prims to L1
Definition: lapdm.h:68
int last_tx_dequeue
last entity that was dequeued
Definition: lapdm.h:60
struct lapdm_channel * lapdm_ch
pointer to lapdm_channel of which we're part
Definition: lapdm.h:72
lapdm_cb_t l3_cb
callback for sending stuff to L3
Definition: lapdm.h:69
void * l1_ctx
context for layer1 instance
Definition: lapdm.h:65
uint8_t tx_power
Definition: lapdm.h:75
int tx_pending
currently a pending frame not confirmed by L1
Definition: lapdm.h:61
uint8_t ta
Definition: lapdm.h:74
LAPDm message context.
Definition: lapdm.h:20
int lapdm_fmt
Definition: lapdm.h:22
uint8_t tx_power_ind
Definition: lapdm.h:26
uint8_t link_id
Definition: lapdm.h:24
uint8_t ta_ind
Definition: lapdm.h:25
struct lapdm_datalink * dl
Definition: lapdm.h:21
uint32_t fn
Definition: lapdm.h:27
uint8_t chan_nr
Definition: lapdm.h:23
primitive header for PH-SAP primitives
Definition: l1sap.h:166