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