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