4 #include "osmocore/protocol/gsm_04_08.h"
6 #define GSM_TA_CM 55385
9 #define GSM48_RR_EST_REQ 0x10
10 #define GSM48_RR_EST_IND 0x12
11 #define GSM48_RR_EST_CNF 0x11
12 #define GSM48_RR_REL_IND 0x22
13 #define GSM48_RR_SYNC_IND 0x32
14 #define GSM48_RR_DATA_REQ 0x40
15 #define GSM48_RR_DATA_IND 0x42
16 #define GSM48_RR_UNIT_DATA_IND 0x52
17 #define GSM48_RR_ABORT_REQ 0x60
18 #define GSM48_RR_ABORT_IND 0x62
19 #define GSM48_RR_ACT_REQ 0x70
21 #define RR_EST_CAUSE_EMERGENCY 1
22 #define RR_EST_CAUSE_REESTAB_TCH_F 2
23 #define RR_EST_CAUSE_REESTAB_TCH_H 3
24 #define RR_EST_CAUSE_REESTAB_2_TCH_H 4
25 #define RR_EST_CAUSE_ANS_PAG_ANY 5
26 #define RR_EST_CAUSE_ANS_PAG_SDCCH 6
27 #define RR_EST_CAUSE_ANS_PAG_TCH_F 7
28 #define RR_EST_CAUSE_ANS_PAG_TCH_ANY 8
29 #define RR_EST_CAUSE_ORIG_TCHF 9
30 #define RR_EST_CAUSE_LOC_UPD 12
31 #define RR_EST_CAUSE_OTHER_SDCCH 13
33 #define RR_REL_CAUSE_UNDEFINED 0
34 #define RR_REL_CAUSE_NORMAL 1
35 #define RR_REL_CAUSE_NOT_AUTHORIZED 2
36 #define RR_REL_CAUSE_RA_FAILURE 3
37 #define RR_REL_CAUSE_T3122 4
38 #define RR_REL_CAUSE_TRY_LATER 5
39 #define RR_REL_CAUSE_EMERGENCY_ONLY 6
40 #define RR_REL_CAUSE_LOST_SIGNAL 7
42 #define L3_ALLOC_SIZE 256
43 #define L3_ALLOC_HEADROOM 64
45 #define RR_ALLOC_SIZE 256
46 #define RR_ALLOC_HEADROOM 64
48 /* GSM 04.08 RR-SAP header */
50 uint32_t msg_type; /* RR-* primitive */
55 #define GSM48_RR_ST_IDLE 0
56 #define GSM48_RR_ST_CONN_PEND 1
57 #define GSM48_RR_ST_DEDICATED 2
58 #define GSM48_RR_ST_REL_PEND 3
60 /* channel description */
63 uint8_t h; /* using hopping */
64 uint16_t arfcn; /* dedicated mode */
67 uint8_t chan_nr; /* type, slot, sub slot */
69 uint8_t ta; /* timing advance */
70 uint8_t mob_alloc_lv[9]; /* len + up to 64 bits */
71 uint8_t start_t1, start_t2, start_t3; /* start. time */
75 struct gsm48_rr_meas {
90 /* RR sublayer instance */
91 struct gsm48_rrlayer {
92 struct osmocom_ms *ms;
95 /* queue for RSL-SAP message upwards */
96 struct llist_head rsl_upqueue;
98 /* queue for messages while RR connection is built up */
99 struct llist_head downqueue;
102 struct timer_list t_rel_wait; /* wait for L2 to transmit UA */
103 struct timer_list t3110;
104 struct timer_list t3122;
105 struct timer_list t3124;
106 struct timer_list t3126;
109 struct timer_list temp_rach_ti; /* temporary timer */
112 /* states if RR-EST-REQ was used */
114 struct msgb *rr_est_msg;
116 /* channel request states */
117 uint8_t wait_assign; /* waiting for assignment state */
118 uint8_t n_chan_req; /* number left, incl. current */
119 uint8_t chan_req_val; /* current request value */
120 uint8_t chan_req_mask; /* mask of random bits */
122 /* cr_hist must be signed and greater 8 bit, -1 = no value */
124 /* current channel descriptions */
125 struct gsm48_rr_cd cd_now;
127 /* current cipering */
129 uint8_t cipher_type; /* 10.5.2.9 */
131 /* special states when changing channel */
132 uint8_t hando_susp_state;
133 uint8_t assign_susp_state;
134 uint8_t resume_last_state;
135 struct gsm48_rr_cd cd_last;
138 struct gsm48_rr_meas meas;
142 uint32_t ba_range[16];
145 const char *get_rr_name(int value);
146 extern int gsm48_rr_init(struct osmocom_ms *ms);
147 extern int gsm48_rr_exit(struct osmocom_ms *ms);
148 int gsm48_rsl_dequeue(struct osmocom_ms *ms);
149 int gsm48_rr_downmsg(struct osmocom_ms *ms, struct msgb *msg);
150 struct msgb *gsm48_l3_msgb_alloc(void);
151 struct msgb *gsm48_rr_msgb_alloc(int msg_type);
152 int gsm48_decode_lai(struct gsm48_loc_area_id *lai, uint16_t *mcc,
153 uint16_t *mnc, uint16_t *lac);
154 int gsm48_rr_enc_cm2(struct osmocom_ms *ms, struct gsm48_classmark2 *cm);
155 int gsm48_rr_tx_rand_acc(struct osmocom_ms *ms, struct msgb *msg);
156 int gsm48_rr_los(struct osmocom_ms *ms);
157 extern const char *gsm48_rr_state_names[];
159 #endif /* _GSM48_RR_H */