libosmogsm  0.6.3
Osmocom GSM library
lapdm.h
Go to the documentation of this file.
1 #ifndef _OSMOCOM_LAPDM_H
2 #define _OSMOCOM_LAPDM_H
3 
4 #include <osmocom/gsm/l1sap.h>
6 
14 enum lapdm_mode {
17 };
18 
19 struct lapdm_entity;
20 
22 struct lapdm_msg_ctx {
23  struct lapdm_datalink *dl;
24  int lapdm_fmt;
25  uint8_t chan_nr;
26  uint8_t link_id;
27  uint8_t ta_ind; /* TA indicated by network */
28  uint8_t tx_power_ind; /* MS power indicated by network */
29 };
30 
33  struct lapd_datalink dl; /* \brief common LAPD */
36  struct lapdm_entity *entity;
37 };
38 
41  DL_SAPI0 = 0,
42  DL_SAPI3 = 1,
43  _NR_DL_SAPI
44 };
45 
46 typedef int (*lapdm_cb_t)(struct msgb *msg, struct lapdm_entity *le, void *ctx);
47 
48 #define LAPDM_ENT_F_EMPTY_FRAME 0x0001
49 #define LAPDM_ENT_F_POLLING_ONLY 0x0002
50 
52 struct lapdm_entity {
54  struct lapdm_datalink datalink[_NR_DL_SAPI];
56  int tx_pending;
58  unsigned int flags;
59 
60  void *l1_ctx;
61  void *l3_ctx;
63  osmo_prim_cb l1_prim_cb;
64  lapdm_cb_t l3_cb;
68 
69  uint8_t ta; /* TA used and indicated to network */
70  uint8_t tx_power; /* MS power used and indicated to network */
71 };
72 
74 struct lapdm_channel {
75  struct llist_head list;
76  char *name;
79 };
80 
81 const char *get_rsl_name(int value);
82 extern const char *lapdm_state_names[];
83 
84 /* initialize a LAPDm entity */
85 void lapdm_entity_init(struct lapdm_entity *le, enum lapdm_mode mode, int t200);
86 void lapdm_channel_init(struct lapdm_channel *lc, enum lapdm_mode mode);
87 
88 /* deinitialize a LAPDm entity */
89 void lapdm_entity_exit(struct lapdm_entity *le);
90 void lapdm_channel_exit(struct lapdm_channel *lc);
91 
92 /* input into layer2 (from layer 1) */
93 int lapdm_phsap_up(struct osmo_prim_hdr *oph, struct lapdm_entity *le);
94 
95 /* input into layer2 (from layer 3) */
96 int lapdm_rslms_recvmsg(struct msgb *msg, struct lapdm_channel *lc);
97 
98 void lapdm_channel_set_l3(struct lapdm_channel *lc, lapdm_cb_t cb, void *ctx);
99 void lapdm_channel_set_l1(struct lapdm_channel *lc, osmo_prim_cb cb, void *ctx);
100 
101 int lapdm_entity_set_mode(struct lapdm_entity *le, enum lapdm_mode mode);
103 
104 void lapdm_entity_reset(struct lapdm_entity *le);
105 void lapdm_channel_reset(struct lapdm_channel *lc);
106 
107 void lapdm_entity_set_flags(struct lapdm_entity *le, unsigned int flags);
108 void lapdm_channel_set_flags(struct lapdm_channel *lc, unsigned int flags);
109 
110 int lapdm_phsap_dequeue_prim(struct lapdm_entity *le, struct osmo_phsap_prim *pp);
111 
114 #endif /* _OSMOCOM_LAPDM_H */