libosmogsm
0.9.3
Osmocom GSM library
|
00001 #pragma once 00002 00003 #include <osmocom/gsm/l1sap.h> 00004 #include <osmocom/gsm/lapd_core.h> 00005 00013 enum lapdm_mode { 00014 LAPDM_MODE_MS, 00015 LAPDM_MODE_BTS, 00016 }; 00017 00018 struct lapdm_entity; 00019 00021 struct lapdm_msg_ctx { 00022 struct lapdm_datalink *dl; 00023 int lapdm_fmt; 00024 uint8_t chan_nr; 00025 uint8_t link_id; 00026 uint8_t ta_ind; /* TA indicated by network */ 00027 uint8_t tx_power_ind; /* MS power indicated by network */ 00028 }; 00029 00031 struct lapdm_datalink { 00032 struct lapd_datalink dl; /* \brief common LAPD */ 00033 struct lapdm_msg_ctx mctx; 00035 struct lapdm_entity *entity; 00036 }; 00037 00039 enum lapdm_dl_sapi { 00040 DL_SAPI0 = 0, 00041 DL_SAPI3 = 1, 00042 _NR_DL_SAPI 00043 }; 00044 00045 typedef int (*lapdm_cb_t)(struct msgb *msg, struct lapdm_entity *le, void *ctx); 00046 00047 #define LAPDM_ENT_F_EMPTY_FRAME 0x0001 00048 #define LAPDM_ENT_F_POLLING_ONLY 0x0002 00049 00051 struct lapdm_entity { 00053 struct lapdm_datalink datalink[_NR_DL_SAPI]; 00054 int last_tx_dequeue; 00055 int tx_pending; 00056 enum lapdm_mode mode; 00057 unsigned int flags; 00058 00059 void *l1_ctx; 00060 void *l3_ctx; 00062 osmo_prim_cb l1_prim_cb; 00063 lapdm_cb_t l3_cb; 00066 struct lapdm_channel *lapdm_ch; 00067 00068 uint8_t ta; /* TA used and indicated to network */ 00069 uint8_t tx_power; /* MS power used and indicated to network */ 00070 }; 00071 00073 struct lapdm_channel { 00074 struct llist_head list; 00075 char *name; 00076 struct lapdm_entity lapdm_acch; 00077 struct lapdm_entity lapdm_dcch; 00078 }; 00079 00080 const char *get_rsl_name(int value); 00081 extern const char *lapdm_state_names[]; 00082 00083 struct lapdm_datalink *lapdm_datalink_for_sapi(struct lapdm_entity *le, uint8_t sapi); 00084 00085 /* initialize a LAPDm entity */ 00086 void lapdm_entity_init(struct lapdm_entity *le, enum lapdm_mode mode, int t200); 00087 void lapdm_channel_init(struct lapdm_channel *lc, enum lapdm_mode mode); 00088 00089 /* deinitialize a LAPDm entity */ 00090 void lapdm_entity_exit(struct lapdm_entity *le); 00091 void lapdm_channel_exit(struct lapdm_channel *lc); 00092 00093 /* input into layer2 (from layer 1) */ 00094 int lapdm_phsap_up(struct osmo_prim_hdr *oph, struct lapdm_entity *le); 00095 00096 /* input into layer2 (from layer 3) */ 00097 int lapdm_rslms_recvmsg(struct msgb *msg, struct lapdm_channel *lc); 00098 00099 void lapdm_channel_set_l3(struct lapdm_channel *lc, lapdm_cb_t cb, void *ctx); 00100 void lapdm_channel_set_l1(struct lapdm_channel *lc, osmo_prim_cb cb, void *ctx); 00101 00102 int lapdm_entity_set_mode(struct lapdm_entity *le, enum lapdm_mode mode); 00103 int lapdm_channel_set_mode(struct lapdm_channel *lc, enum lapdm_mode mode); 00104 00105 void lapdm_entity_reset(struct lapdm_entity *le); 00106 void lapdm_channel_reset(struct lapdm_channel *lc); 00107 00108 void lapdm_entity_set_flags(struct lapdm_entity *le, unsigned int flags); 00109 void lapdm_channel_set_flags(struct lapdm_channel *lc, unsigned int flags); 00110 00111 int lapdm_phsap_dequeue_prim(struct lapdm_entity *le, struct osmo_phsap_prim *pp); 00112