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