FreeCalypso > hg > fc-selenite
comparison src/g23m-gprs/sndcp/sndcp_sds.c @ 1:d393cd9bb723
src/g23m-*: initial import from Magnetite
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 15 Jul 2018 04:40:46 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:b6a5e36de839 | 1:d393cd9bb723 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GPRS (8441) | |
4 | Modul : sndcp_sds.c | |
5 +----------------------------------------------------------------------------- | |
6 | Copyright 2002 Texas Instruments Berlin, AG | |
7 | All rights reserved. | |
8 | | |
9 | This file is confidential and a trade secret of Texas | |
10 | Instruments Berlin, AG | |
11 | The receipt of or possession of this file does not convey | |
12 | any rights to reproduce or disclose its contents or to | |
13 | manufacture, use, or sell anything it may describe, in | |
14 | whole, or in part, without the specific written consent of | |
15 | Texas Instruments Berlin, AG. | |
16 +----------------------------------------------------------------------------- | |
17 | Purpose : This modul is part of the entity SNDCP and implements all | |
18 | functions to handles the incoming process internal signals as | |
19 | described in the SDL-documentation (SD-statemachine) | |
20 +----------------------------------------------------------------------------- | |
21 */ | |
22 | |
23 | |
24 #define ENTITY_SNDCP | |
25 | |
26 /*==== INCLUDES =============================================================*/ | |
27 | |
28 #include "typedefs.h" /* to get Condat data types */ | |
29 #include "vsi.h" /* to get a lot of macros */ | |
30 #include "macdef.h" | |
31 #include "gsm.h" /* to get a lot of macros */ | |
32 #include "prim.h" /* to get the definitions of used SAP and directions */ | |
33 | |
34 #include "dti.h" | |
35 | |
36 #include "sndcp.h" /* to get the global entity definitions */ | |
37 #include "sndcp_f.h" /* to get the functions to access the global arrays*/ | |
38 | |
39 #include "sndcp_sdf.h" /* to get the internal functions of this service */ | |
40 #include "sndcp_nds.h" /* to get signals to nd service */ | |
41 | |
42 | |
43 /*==== CONST ================================================================*/ | |
44 | |
45 /*==== LOCAL VARS ===========================================================*/ | |
46 | |
47 /*==== PRIVATE FUNCTIONS ====================================================*/ | |
48 | |
49 /*==== PUBLIC FUNCTIONS =====================================================*/ | |
50 | |
51 /* | |
52 +------------------------------------------------------------------------------ | |
53 | Function : sig_cia_sd_cia_decomp_ind | |
54 +------------------------------------------------------------------------------ | |
55 | Description : Handles the internal signal SIG_CIA_SD_CIA_DECOMP_CNF | |
56 | | |
57 | Parameters : cia_decomp_ind, p_id | |
58 | | |
59 +------------------------------------------------------------------------------ | |
60 */ | |
61 GLOBAL void sig_cia_sd_cia_decomp_ind (T_CIA_DECOMP_IND* cia_decomp_ind, UBYTE p_id) | |
62 { | |
63 UBYTE sapi_index = 0; | |
64 UBYTE sapi = 0; | |
65 UBYTE nsapi = cia_decomp_ind->pdu_ref.ref_nsapi; | |
66 BOOL rec = FALSE; | |
67 T_SN_UNITDATA_IND* sn_unitdata_ind = NULL; | |
68 | |
69 TRACE_ISIG( "sig_cia_sd_cia_decomp_ind" ); | |
70 | |
71 /* | |
72 * set service instance according to sapi in primitive | |
73 */ | |
74 sndcp_get_nsapi_sapi(cia_decomp_ind->pdu_ref.ref_nsapi, &sapi); | |
75 sndcp_get_sapi_index(sapi, &sapi_index); | |
76 sndcp_data->sd = & sndcp_data->sd_base[sapi_index]; | |
77 | |
78 switch( sndcp_get_nsapi_rec_state(nsapi) ) | |
79 { | |
80 case SD_UNACK_DISCARD: | |
81 case SD_UNACK_RECEIVE_FIRST_SEGMENT: | |
82 case SD_UNACK_RECEIVE_SUBSEQUENT_SEGMENT: | |
83 { | |
84 MALLOC(sn_unitdata_ind, sizeof(T_SN_UNITDATA_IND)); | |
85 | |
86 #ifdef _SNDCP_DTI_2_ | |
87 sn_unitdata_ind->desc_list2.first = cia_decomp_ind->desc_list2.first; | |
88 sn_unitdata_ind->desc_list2.list_len = | |
89 cia_decomp_ind->desc_list2.list_len; | |
90 #endif /*_SNDCP_DTI_2_*/ | |
91 | |
92 #ifdef SNDCP_TRACE_ALL | |
93 sndcp_data->cia.cia_decomp_ind_number[nsapi] --; | |
94 TRACE_EVENT_P1("number of cia_decomp_ind: % d", | |
95 sndcp_data->cia.cia_decomp_ind_number[nsapi]); | |
96 #endif /* SNDCP_TRACE_ALL */ | |
97 | |
98 | |
99 sn_unitdata_ind->nsapi = nsapi; | |
100 | |
101 sn_unitdata_ind->p_id = p_id; | |
102 sd_is_nsapi_rec(nsapi, &rec); | |
103 if (rec) { | |
104 sig_sd_nd_unitdata_ind(nsapi, sn_unitdata_ind); | |
105 sd_set_nsapi_rec(nsapi, FALSE); | |
106 sd_get_unitdata_if_nec(sapi); | |
107 } else { | |
108 if (sndcp_data->sd->cur_sn_unitdata_ind[nsapi] NEQ NULL) | |
109 { | |
110 #ifndef NTRACE | |
111 #ifdef SNDCP_TRACE_ALL | |
112 TRACE_EVENT_P1("Discard cur_sn.. in %s", sndcp_data->sd->state_name); | |
113 #endif /* SNDCP_TRACE_ALL */ | |
114 #endif /* NTRACE */ | |
115 sd_delete_cur_sn_unitdata_ind(nsapi); | |
116 } | |
117 sndcp_data->sd->cur_sn_unitdata_ind[nsapi] = sn_unitdata_ind; | |
118 sndcp_set_nsapi_rec_state(nsapi, SD_UNACK_WAIT_NSAPI); | |
119 } | |
120 } | |
121 MFREE(cia_decomp_ind); | |
122 break; | |
123 default: | |
124 TRACE_ERROR( "SIG_CIA_SD_CIA_DECOMP_IND unexpected" ); | |
125 MFREE_PRIM(cia_decomp_ind); | |
126 break; | |
127 } | |
128 } /* sig_cia_sd_cia_decomp_ind() */ | |
129 | |
130 /* | |
131 +------------------------------------------------------------------------------ | |
132 | Function : sig_mg_sd_delete_npdus | |
133 +------------------------------------------------------------------------------ | |
134 | Description : Handles the internal signal SIG_MG_SD_DELETE_NPDUS | |
135 | | |
136 | Parameters : | |
137 | | |
138 +------------------------------------------------------------------------------ | |
139 */ | |
140 GLOBAL void sig_mg_sd_delete_npdus (UBYTE nsapi, | |
141 UBYTE sapi) | |
142 { | |
143 UBYTE sapi_index = 0; | |
144 | |
145 TRACE_ISIG( "sig_mg_sd_delete_npdus" ); | |
146 | |
147 /* | |
148 * set service instance according to sapi in primitive | |
149 */ | |
150 sndcp_get_sapi_index(sapi, &sapi_index); | |
151 sndcp_data->sd = & sndcp_data->sd_base[sapi_index]; | |
152 | |
153 switch( sndcp_get_nsapi_rec_state(nsapi) ) | |
154 { | |
155 case SD_UNACK_DISCARD: | |
156 break; | |
157 case SD_UNACK_RECEIVE_FIRST_SEGMENT: | |
158 case SD_UNACK_RECEIVE_SUBSEQUENT_SEGMENT: | |
159 if (sndcp_data->sd->cur_sn_unitdata_ind[nsapi] != NULL) { | |
160 sd_delete_cur_sn_unitdata_ind(nsapi); | |
161 sndcp_set_nsapi_rec_state(nsapi, SD_UNACK_RECEIVE_FIRST_SEGMENT); | |
162 } else { | |
163 sndcp_set_nsapi_rec_state(nsapi, SD_UNACK_RECEIVE_FIRST_SEGMENT); | |
164 } | |
165 break; | |
166 case SD_UNACK_WAIT_NSAPI: | |
167 if (sndcp_data->sd->cur_sn_unitdata_ind[nsapi] != NULL) { | |
168 sd_delete_cur_sn_unitdata_ind(nsapi); | |
169 sd_get_unitdata_if_nec(sapi); | |
170 sndcp_set_nsapi_rec_state(nsapi, SD_UNACK_RECEIVE_FIRST_SEGMENT); | |
171 } | |
172 break; | |
173 default: | |
174 TRACE_ERROR( "SIG_MG_SD_DELETE_NPDUS unexpected" ); | |
175 break; | |
176 } | |
177 } /* sig_mg_sd_delete_npdus() */ | |
178 | |
179 /* | |
180 +------------------------------------------------------------------------------ | |
181 | Function : sig_mg_sd_getunitdata | |
182 +------------------------------------------------------------------------------ | |
183 | Description : Handles the internal signal SIG_MG_SD_GETUNITDATA | |
184 | | |
185 | Parameters : sapi | |
186 | | |
187 +------------------------------------------------------------------------------ | |
188 */ | |
189 GLOBAL void sig_mg_sd_getunitdata (UBYTE sapi, UBYTE nsapi) | |
190 { | |
191 UBYTE sapi_index = 0; | |
192 | |
193 TRACE_ISIG( "sig_mg_sd_getunitdata" ); | |
194 | |
195 /* | |
196 * set service instance according to sapi in primitive | |
197 */ | |
198 sndcp_get_sapi_index(sapi, &sapi_index); | |
199 sndcp_data->sd = & sndcp_data->sd_base[sapi_index]; | |
200 | |
201 switch( GET_STATE(SD) ) | |
202 { | |
203 case SD_DEFAULT: | |
204 sd_get_unitdata_if_nec(sapi); | |
205 sndcp_set_nsapi_rec_state(nsapi, SD_UNACK_RECEIVE_FIRST_SEGMENT); | |
206 break; | |
207 default: | |
208 TRACE_ERROR( "SIG_MG_SD_GETUNITDATA unexpected" ); | |
209 break; | |
210 } | |
211 } /* sig_mg_sd_getunitdata() */ | |
212 | |
213 | |
214 | |
215 | |
216 /* | |
217 +------------------------------------------------------------------------------ | |
218 | Function : sig_nd_sd_getunitdata_req | |
219 +------------------------------------------------------------------------------ | |
220 | Description : Handles the internal signal SIG_ND_SD_GETUNITDATA_REQ | |
221 | | |
222 | Parameters : affected sapi, affected nsapi | |
223 | | |
224 +------------------------------------------------------------------------------ | |
225 */ | |
226 GLOBAL void sig_nd_sd_getunitdata_req (UBYTE sapi, | |
227 UBYTE nsapi) | |
228 { | |
229 UBYTE sapi_index = 0; | |
230 | |
231 TRACE_ISIG( "sig_nd_sd_getunitdata_req" ); | |
232 | |
233 /* | |
234 * set service instance according to sapi in primitive | |
235 */ | |
236 sndcp_get_sapi_index(sapi, &sapi_index); | |
237 sndcp_data->sd = & sndcp_data->sd_base[sapi_index]; | |
238 | |
239 switch( sndcp_get_nsapi_rec_state(nsapi) ) | |
240 { | |
241 case SD_UNACK_DISCARD: | |
242 case SD_UNACK_RECEIVE_FIRST_SEGMENT: | |
243 case SD_UNACK_RECEIVE_SUBSEQUENT_SEGMENT: | |
244 sd_set_nsapi_rec(nsapi, TRUE); | |
245 break; | |
246 case SD_UNACK_WAIT_NSAPI: | |
247 if (sndcp_data->sd->cur_sn_unitdata_ind[nsapi] NEQ NULL) { | |
248 /* | |
249 * Send the just reassembled N-PDU (must be present because of state!). | |
250 */ | |
251 sig_sd_nd_unitdata_ind(nsapi, sndcp_data->sd->cur_sn_unitdata_ind[nsapi]); | |
252 sndcp_data->sd->cur_sn_unitdata_ind[nsapi] = NULL; | |
253 sd_get_unitdata_if_nec(sapi); | |
254 sndcp_set_nsapi_rec_state(nsapi, SD_UNACK_RECEIVE_FIRST_SEGMENT); | |
255 } else { | |
256 /* | |
257 * Set the receptive for the given nsapi. | |
258 */ | |
259 sd_set_nsapi_rec(nsapi, TRUE); | |
260 } | |
261 break; | |
262 default: | |
263 TRACE_ERROR( "SIG_ND_SD_GETUNITDATA_REQ unexpected" ); | |
264 break; | |
265 } | |
266 } /* sig_nd_sd_getunitdata_req() */ | |
267 | |
268 /* | |
269 +------------------------------------------------------------------------------ | |
270 | Function : sig_mg_sd_reset_ind | |
271 +------------------------------------------------------------------------------ | |
272 | Description : Handles the internal signal SIG_MG_SD_RESET_IND | |
273 | | |
274 | Parameters : affected nsapi | |
275 | | |
276 +------------------------------------------------------------------------------ | |
277 */ | |
278 GLOBAL void sig_mg_sd_reset_ind (UBYTE nsapi) | |
279 { | |
280 TRACE_ISIG( "sig_mg_sd_reset_ind" ); | |
281 | |
282 switch( sndcp_get_nsapi_rec_state(nsapi) ) | |
283 { | |
284 case SD_UNACK_DISCARD: | |
285 case SD_UNACK_RECEIVE_FIRST_SEGMENT: | |
286 case SD_UNACK_RECEIVE_SUBSEQUENT_SEGMENT: | |
287 case SD_UNACK_WAIT_NSAPI: | |
288 sndcp_data->cur_dcomp[nsapi] = 0; | |
289 sndcp_data->cur_pcomp[nsapi] = 0; | |
290 break; | |
291 default: | |
292 TRACE_ERROR( "SIG_MG_SD_RESET_IND unexpected" ); | |
293 break; | |
294 } | |
295 } /* sig_mg_sd_reset_ind() */ | |
296 | |
297 | |
298 /* | |
299 +------------------------------------------------------------------------------ | |
300 | Function : sig_pd_sd_unitdata_ind | |
301 +------------------------------------------------------------------------------ | |
302 | Description : Handles the signal PD_SD_UNITDATA_IND | |
303 | | |
304 | Parameters : *ll_unitdata_ind - Ptr to primitive payload | |
305 | | |
306 +------------------------------------------------------------------------------ | |
307 */ | |
308 GLOBAL void sig_pd_sd_unitdata_ind ( T_LL_UNITDATA_IND *ll_unitdata_ind ) | |
309 { | |
310 UBYTE sapi_index = 0; | |
311 BOOL valid = FALSE; | |
312 UBYTE nsapi = 0; | |
313 | |
314 TRACE_ISIG( "sig_pd_sd_unitdata_ind" ); | |
315 | |
316 /* | |
317 * set service instance according to sapi in primitive | |
318 */ | |
319 sndcp_get_sapi_index(ll_unitdata_ind->sapi, &sapi_index); | |
320 sndcp_data->sd = & sndcp_data->sd_base[sapi_index]; | |
321 | |
322 sd_get_nsapi(ll_unitdata_ind, &nsapi); | |
323 sndcp_data->big_head[nsapi] = FALSE; | |
324 | |
325 /* | |
326 * LLC has now "used up" it's pending LL_GETUNITDATA_REQ and will have | |
327 * to wait for the next one. | |
328 */ | |
329 sndcp_data->sd->llc_may_send = FALSE; | |
330 | |
331 switch( sndcp_get_nsapi_rec_state(nsapi) ) | |
332 { | |
333 case SD_UNACK_DISCARD: | |
334 /* | |
335 * Invalid segments are discarded without error notification | |
336 */ | |
337 sd_is_seg_valid(ll_unitdata_ind, &valid); | |
338 if (!valid) { | |
339 if (ll_unitdata_ind != NULL) { | |
340 UBYTE sapi = ll_unitdata_ind->sapi; | |
341 PFREE(ll_unitdata_ind); | |
342 sd_get_unitdata_if_nec(sapi); | |
343 } | |
344 return; | |
345 } | |
346 if (sd_f_bit(ll_unitdata_ind)) { | |
347 if (sd_m_bit(ll_unitdata_ind)) { | |
348 sd_un_d_f1_m1(ll_unitdata_ind); | |
349 } else { | |
350 sd_un_d_f1_m0(ll_unitdata_ind); | |
351 } | |
352 } else { | |
353 if (sd_m_bit(ll_unitdata_ind)) { | |
354 sd_un_d_f0_m1(ll_unitdata_ind); | |
355 } else { | |
356 sd_un_d_f0_m0(ll_unitdata_ind); | |
357 } | |
358 } | |
359 break; | |
360 case SD_UNACK_RECEIVE_FIRST_SEGMENT: | |
361 /* | |
362 * Invalid segments are discarded without error notification | |
363 */ | |
364 sd_is_seg_valid(ll_unitdata_ind, &valid); | |
365 if (!valid) { | |
366 if (ll_unitdata_ind != NULL) { | |
367 UBYTE sapi = ll_unitdata_ind->sapi; | |
368 PFREE (ll_unitdata_ind); | |
369 sd_get_unitdata_if_nec(sapi); | |
370 } | |
371 return; | |
372 } | |
373 if (sd_f_bit(ll_unitdata_ind)) { | |
374 if (sd_m_bit(ll_unitdata_ind)) { | |
375 sd_un_f_f1_m1(ll_unitdata_ind); | |
376 } else { | |
377 sd_un_f_f1_m0(ll_unitdata_ind); | |
378 } | |
379 } else { | |
380 if (sd_m_bit(ll_unitdata_ind)) { | |
381 sd_un_f_f0_m1(ll_unitdata_ind); | |
382 } else { | |
383 sd_un_f_f0_m0(ll_unitdata_ind); | |
384 } | |
385 } | |
386 | |
387 break; | |
388 case SD_UNACK_RECEIVE_SUBSEQUENT_SEGMENT: | |
389 /* | |
390 * Invalid segments are discarded without error notification | |
391 */ | |
392 sd_is_seg_valid(ll_unitdata_ind, &valid); | |
393 if (!valid) { | |
394 if (ll_unitdata_ind != NULL) { | |
395 UBYTE sapi = ll_unitdata_ind->sapi; | |
396 PFREE(ll_unitdata_ind); | |
397 sd_get_unitdata_if_nec(sapi); | |
398 } | |
399 return; | |
400 } | |
401 if (sd_f_bit(ll_unitdata_ind)) { | |
402 if (sd_m_bit(ll_unitdata_ind)) { | |
403 sd_un_s_f1_m1(ll_unitdata_ind); | |
404 } else { | |
405 sd_un_s_f1_m0(ll_unitdata_ind); | |
406 } | |
407 } else { | |
408 if (sd_m_bit(ll_unitdata_ind)) { | |
409 sd_un_s_f0_m1(ll_unitdata_ind); | |
410 } else { | |
411 sd_un_s_f0_m0(ll_unitdata_ind); | |
412 } | |
413 } | |
414 | |
415 break; | |
416 | |
417 case SD_UNACK_WAIT_NSAPI: | |
418 /* | |
419 * This NSAPI is waiting for the DL flow control prim | |
420 * from upper layer. The data for other NSAPI's could get passed, | |
421 * but since this packet is for the blocked NSAPI, the prim is discarded | |
422 * and next packet is not requested. | |
423 */ | |
424 if (ll_unitdata_ind != NULL) { | |
425 PFREE (ll_unitdata_ind); | |
426 } | |
427 break; | |
428 | |
429 default: | |
430 TRACE_ERROR( "SIG_PD_SD_UNITDATA_IND unexpected" ); | |
431 if (ll_unitdata_ind != NULL) { | |
432 UBYTE sapi = ll_unitdata_ind->sapi; | |
433 PFREE (ll_unitdata_ind); | |
434 sd_get_unitdata_if_nec(sapi); | |
435 } | |
436 break; | |
437 } | |
438 | |
439 } /* sig_pd_sd_unitdata_ind() */ | |
440 | |
441 /* | |
442 +------------------------------------------------------------------------------ | |
443 | Function : sig_cia_sd_getunitdata | |
444 +------------------------------------------------------------------------------ | |
445 | Description : Handles the internal signal SIG_CIA_SD_GETUNITDATA | |
446 | | |
447 | Parameters : sapi | |
448 | | |
449 +------------------------------------------------------------------------------ | |
450 */ | |
451 GLOBAL void sig_cia_sd_getunitdata (UBYTE sapi, UBYTE nsapi) | |
452 { | |
453 UBYTE sapi_index = 0; | |
454 | |
455 TRACE_ISIG( "sig_cia_sd_getunitdata" ); | |
456 | |
457 /* | |
458 * set service instance according to sapi in primitive | |
459 */ | |
460 sndcp_get_sapi_index(sapi, &sapi_index); | |
461 sndcp_data->sd = & sndcp_data->sd_base[sapi_index]; | |
462 | |
463 switch( sndcp_get_nsapi_rec_state(nsapi) ) | |
464 { | |
465 case SD_UNACK_DISCARD: | |
466 case SD_UNACK_RECEIVE_FIRST_SEGMENT: | |
467 case SD_UNACK_RECEIVE_SUBSEQUENT_SEGMENT: | |
468 case SD_UNACK_WAIT_NSAPI: | |
469 sd_get_unitdata_if_nec(sapi); | |
470 break; | |
471 default: | |
472 TRACE_ERROR( "SIG_CIA_SD_GETUNITDATA unexpected" ); | |
473 break; | |
474 } | |
475 } /* sig_cia_sd_getunitdata() */ | |
476 |