Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1 | #ifndef _GSM_DATA_H |
| 2 | #define _GSM_DATA_H |
| 3 | |
| 4 | #include <sys/types.h> |
| 5 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 6 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
| 7 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 8 | #define GSM_MAX_BTS 8 |
| 9 | #define BTS_MAX_TRX 8 |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 10 | #define TS_MAX_LCHAN 8 |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 11 | |
| 12 | #define HARDCODED_ARFCN 123 |
| 13 | |
| 14 | /* communications link with a BTS */ |
| 15 | struct gsm_bts_link { |
| 16 | struct gsm_bts *bts; |
| 17 | }; |
| 18 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 19 | enum gsm_phys_chan_config { |
| 20 | GSM_PCHAN_NONE, |
| 21 | GSM_PCHAN_CCCH, |
| 22 | GSM_PCHAN_CCCH_SDCCH4, |
| 23 | GSM_PCHAN_TCH_F, |
| 24 | GSM_PCHAN_TCH_H, |
| 25 | GSM_PCHAN_SDCCH8_SACCH8C, |
| 26 | GSM_PCHAN_UNKNOWN, |
| 27 | }; |
| 28 | |
| 29 | enum gsm_chan_t { |
| 30 | GSM_LCHAN_NONE, |
| 31 | GSM_LCHAN_SDCCH, |
| 32 | GSM_LCHAN_TCH_F, |
| 33 | GSM_LCHAN_TCH_H, |
| 34 | GSM_LCHAN_UNKNOWN, |
| 35 | }; |
| 36 | |
| 37 | struct gsm_lchan { |
| 38 | /* The TS that we're part of */ |
| 39 | struct gsm_bts_trx_ts *ts; |
| 40 | /* The logical subslot number in the TS */ |
| 41 | u_int8_t nr; |
| 42 | /* The lotical channel type */ |
| 43 | enum gsm_chan_t type; |
| 44 | /* To whom we are allocated at the moment */ |
| 45 | struct gsm_subscriber *subscr; |
| 46 | }; |
| 47 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 48 | #define BTS_TRX_F_ACTIVATED 0x0001 |
| 49 | /* One Timeslot in a TRX */ |
| 50 | struct gsm_bts_trx_ts { |
| 51 | struct gsm_bts_trx *trx; |
| 52 | /* number of this timeslot at the TRX */ |
| 53 | u_int8_t nr; |
| 54 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 55 | enum gsm_phys_chan_config pchan; |
| 56 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 57 | unsigned int flags; |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 58 | |
| 59 | struct gsm_lchan lchan[TS_MAX_LCHAN]; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | /* One TRX in a BTS */ |
| 63 | struct gsm_bts_trx { |
| 64 | struct gsm_bts *bts; |
| 65 | /* number of this TRX in the BTS */ |
| 66 | u_int8_t nr; |
| 67 | |
| 68 | u_int16_t arfcn; |
| 69 | struct gsm_bts_trx_ts ts[8]; |
| 70 | }; |
| 71 | |
| 72 | /* One BTS */ |
| 73 | struct gsm_bts { |
| 74 | struct gsm_network *network; |
| 75 | /* number of ths BTS in network */ |
| 76 | u_int8_t nr; |
| 77 | /* location area code of this BTS */ |
| 78 | u_int8_t location_area_code; |
| 79 | |
| 80 | /* Abis network management O&M handle */ |
| 81 | struct abis_nm_h *nmh; |
| 82 | /* number of this BTS on given E1 link */ |
| 83 | u_int8_t bts_nr; |
| 84 | |
| 85 | /* CCCH is on C0 */ |
| 86 | struct gsm_bts_trx *c0; |
| 87 | /* transceivers */ |
| 88 | int num_trx; |
| 89 | struct gsm_bts_trx trx[BTS_MAX_TRX+1]; |
| 90 | }; |
| 91 | |
| 92 | struct gsm_ms { |
| 93 | unsigned long imei; |
| 94 | }; |
| 95 | |
| 96 | struct gsm_network { |
| 97 | /* global parameters */ |
| 98 | u_int8_t country_code; |
| 99 | u_int8_t network_code; |
| 100 | |
| 101 | unsigned int num_bts; |
| 102 | /* private lists */ |
| 103 | struct gsm_bts bts[GSM_MAX_BTS+1]; |
| 104 | struct gsm_ms *ms; |
| 105 | struct gsm_subscriber *subscriber; |
| 106 | }; |
| 107 | |
| 108 | struct gsm_network *gsm_network_init(unsigned int num_bts, u_int8_t country_code, |
| 109 | u_int8_t network_code); |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 110 | |
| 111 | enum gsm_call_type { |
| 112 | GSM_CT_NONE, |
| 113 | GSM_CT_MO, |
| 114 | GSM_CT_MT, |
| 115 | }; |
| 116 | |
| 117 | enum gsm_call_state { |
| 118 | GSM_CSTATE_NONE, |
| 119 | }; |
| 120 | |
| 121 | /* One end of a call */ |
| 122 | struct gsm_call { |
| 123 | enum gsm_call_type type; |
| 124 | enum gsm_call_state state; |
| 125 | |
| 126 | /* the 'local' subscriber */ |
| 127 | struct gsm_subscriber *subscr; |
| 128 | }; |
Harald Welte | ad38464 | 2008-12-26 10:20:07 +0000 | [diff] [blame] | 129 | |
| 130 | enum gsm_e1_event { |
| 131 | EVT_E1_NONE, |
| 132 | EVT_E1_OML_UP, |
| 133 | EVT_E1_RSL_UP, |
| 134 | EVT_E1_OML_DN, |
| 135 | EVT_E1_RSL_DN, |
| 136 | }; |
| 137 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 138 | #endif |