libosmogsm  1.6.0.113-b17c
Osmocom GSM library
lapdm.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <osmocom/gsm/l1sap.h>
6 
12 enum lapdm_mode {
15 };
16 
17 struct lapdm_entity;
18 
20 struct lapdm_msg_ctx {
21  struct lapdm_datalink *dl;
22  int lapdm_fmt;
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 };
28 
31  struct lapd_datalink dl; /* common LAPD */
32  struct lapdm_msg_ctx mctx;
34  struct lapdm_entity *entity;
35 };
36 
39  DL_SAPI0 = 0,
40  DL_SAPI3 = 1,
42 };
43 
44 typedef int (*lapdm_cb_t)(struct msgb *msg, struct lapdm_entity *le, void *ctx);
45 
46 #define LAPDM_ENT_F_EMPTY_FRAME 0x0001
47 #define LAPDM_ENT_F_POLLING_ONLY 0x0002
48 
50 struct lapdm_entity {
52  struct lapdm_datalink datalink[_NR_DL_SAPI];
54  int tx_pending;
56  unsigned int flags;
57 
58  void *l1_ctx;
59  void *l3_ctx;
66 
67  uint8_t ta; /* TA used and indicated to network */
68  uint8_t tx_power; /* MS power used and indicated to network */
69 };
70 
72 struct lapdm_channel {
73  struct llist_head list;
74  char *name;
75  struct lapdm_entity lapdm_acch;
76  struct lapdm_entity lapdm_dcch;
77 };
78 
79 const char *get_rsl_name(int value);
80 extern const char *lapdm_state_names[];
81 
82 struct lapdm_datalink *lapdm_datalink_for_sapi(struct lapdm_entity *le, uint8_t sapi);
83 
84 /* initialize a LAPDm entity */
85 void lapdm_entity_init(struct lapdm_entity *le, enum lapdm_mode mode, int t200)
86  OSMO_DEPRECATED("Use lapdm_entity_init3() instead");
87 void lapdm_entity_init2(struct lapdm_entity *le, enum lapdm_mode mode,
88  const int *t200_ms, int n200)
89  OSMO_DEPRECATED("Use lapdm_entity_init3() instead");
90 void lapdm_entity_init3(struct lapdm_entity *le, enum lapdm_mode mode,
91  const int *t200_ms, int n200, const char *name_pfx);
92 void lapdm_channel_init(struct lapdm_channel *lc, enum lapdm_mode mode)
93  OSMO_DEPRECATED_OUTSIDE("Use lapdm_channel_init3() instead");
95  const int *t200_ms_dcch, const int *t200_ms_acch, enum gsm_chan_t chan_t);
97  const int *t200_ms_dcch, const int *t200_ms_acch, enum gsm_chan_t chan_t,
98  const char *name_pfx);
99 /* deinitialize a LAPDm entity */
100 void lapdm_entity_exit(struct lapdm_entity *le);
101 void lapdm_channel_exit(struct lapdm_channel *lc);
102 
103 /* input into layer2 (from layer 1) */
104 int lapdm_phsap_up(struct osmo_prim_hdr *oph, struct lapdm_entity *le);
105 
106 /* input into layer2 (from layer 3) */
107 int lapdm_rslms_recvmsg(struct msgb *msg, struct lapdm_channel *lc);
108 
109 void lapdm_channel_set_l3(struct lapdm_channel *lc, lapdm_cb_t cb, void *ctx);
110 void lapdm_channel_set_l1(struct lapdm_channel *lc, osmo_prim_cb cb, void *ctx);
111 
112 int lapdm_entity_set_mode(struct lapdm_entity *le, enum lapdm_mode mode);
114 
115 void lapdm_entity_reset(struct lapdm_entity *le);
116 void lapdm_channel_reset(struct lapdm_channel *lc);
117 
118 void lapdm_entity_set_flags(struct lapdm_entity *le, unsigned int flags);
119 void lapdm_channel_set_flags(struct lapdm_channel *lc, unsigned int flags);
120 
121 int lapdm_phsap_dequeue_prim(struct lapdm_entity *le, struct osmo_phsap_prim *pp);
122 
void lapdm_channel_exit(struct lapdm_channel *lc)
Definition: lapdm.c:305
struct lapdm_datalink * dl
Definition: lapdm.h:21
LAPDm message context.
Definition: lapdm.h:20
void lapdm_entity_set_flags(struct lapdm_entity *le, unsigned int flags)
Set the flags of a LAPDm entity.
Definition: lapdm.c:1494
#define OSMO_DEPRECATED(text)
struct lapdm_channel * lapdm_ch
pointer to lapdm_channel of which we&#39;re part
Definition: lapdm.h:65
behave like a MS (mobile phone)
Definition: lapdm.h:13
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:258
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:189
void lapdm_channel_reset(struct lapdm_channel *lc)
Reset a LAPDm channel with all its entities.
Definition: lapdm.c:1487
uint8_t tx_power_ind
Definition: lapdm.h:26
unsigned int flags
Definition: lapdm.h:56
int tx_pending
currently a pending frame not confirmed by L1
Definition: lapdm.h:54
const char * get_rsl_name(int value)
void * l1_ctx
context for layer1 instance
Definition: lapdm.h:58
the two lapdm_entities that form a GSM logical channel (ACCH + DCCH)
Definition: lapdm.h:72
SAPI 0.
Definition: lapdm.h:39
const char * lapdm_state_names[]
struct lapdm_datalink * lapdm_datalink_for_sapi(struct lapdm_entity *le, uint8_t sapi)
Definition: lapdm.c:311
void * l3_ctx
context for layer3 instance
Definition: lapdm.h:59
SAPI 1.
Definition: lapdm.h:40
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:1466
void lapdm_entity_exit(struct lapdm_entity *le)
flush and release all resoures in LAPDm entity
Definition: lapdm.c:289
int lapdm_rslms_recvmsg(struct msgb *msg, struct lapdm_channel *lc)
Receive a RSLms Message buffers from Layer 3.
Definition: lapdm.c:1390
int lapdm_phsap_up(struct osmo_prim_hdr *oph, struct lapdm_entity *le)
Receive a PH-SAP primitive from L1.
Definition: lapdm.c:890
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:244
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:158
int lapdm_entity_set_mode(struct lapdm_entity *le, enum lapdm_mode mode)
Set the lapdm_mode of a LAPDm entity.
Definition: lapdm.c:1419
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:1457
char * name
human-readable name
Definition: lapdm.h:74
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:176
#define OSMO_DEPRECATED_OUTSIDE(text)
behave like a BTS (network)
Definition: lapdm.h:14
void lapdm_entity_reset(struct lapdm_entity *le)
Reset an entire LAPDm entity and all its datalinks.
Definition: lapdm.c:1475
uint8_t mode
Definition: gsm_04_08.h:690
int(* osmo_prim_cb)(struct osmo_prim_hdr *oph, void *ctx)
uint8_t msg[0]
Definition: gsm_08_08.h:529
uint8_t ta
Definition: lapdm.h:67
osmo_prim_cb l1_prim_cb
callback for sending prims to L1
Definition: lapdm.h:61
lapdm_mode
LAPDm mode/role.
Definition: lapdm.h:12
int last_tx_dequeue
last entity that was dequeued
Definition: lapdm.h:53
uint8_t link_id
Definition: lapdm.h:24
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:228
gsm_chan_t
Definition: gsm_utils.h:226
Definition: lapdm.h:41
int lapdm_channel_set_mode(struct lapdm_channel *lc, enum lapdm_mode mode)
Set the lapdm_mode of a LAPDm channel.
Definition: lapdm.c:1445
int(* lapdm_cb_t)(struct msgb *msg, struct lapdm_entity *le, void *ctx)
Definition: lapdm.h:44
uint8_t tx_power
Definition: lapdm.h:68
lapdm_cb_t l3_cb
callback for sending stuff to L3
Definition: lapdm.h:62
int lapdm_fmt
Definition: lapdm.h:22
lapdm_dl_sapi
LAPDm datalink SAPIs.
Definition: lapdm.h:38
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:1500
a LAPDm Entity
Definition: lapdm.h:50
primitive related stuff
int lapdm_phsap_dequeue_prim(struct lapdm_entity *le, struct osmo_phsap_prim *pp)
dequeue a msg that&#39;s pending transmission via L1 and wrap it into a osmo_phsap_prim ...
Definition: lapdm.c:419
uint8_t ta_ind
Definition: lapdm.h:25
primitive header for PH-SAP primitives
Definition: l1sap.h:158
GSM utility functions, e.g.
uint8_t chan_nr
Definition: lapdm.h:23