FreeCalypso > hg > fc-tourmaline
comparison src/g23m-gprs/sndcp/sndcp_mgp.c @ 1:fa8dc04885d8
src/g23m-*: import from Magnetite
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 16 Oct 2020 06:25:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:4e78acac3d88 | 1:fa8dc04885d8 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GPRS (8441) | |
4 | Modul : sndcp_mgp.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 primitives as described in | |
19 | the SDL-documentation (MG-statemachine) | |
20 +----------------------------------------------------------------------------- | |
21 */ | |
22 | |
23 | |
24 | |
25 #define ENTITY_SNDCP | |
26 | |
27 /*==== INCLUDES =============================================================*/ | |
28 | |
29 #include "typedefs.h" /* to get Condat data types */ | |
30 #include "vsi.h" /* to get a lot of macros */ | |
31 #include "macdef.h" | |
32 #include "gsm.h" /* to get a lot of macros */ | |
33 #include "prim.h" /* to get the definitions of used SAP and directions */ | |
34 #include "dti.h" | |
35 #ifdef _SNDCP_DTI_2_ | |
36 #include <string.h> | |
37 #endif /* _SNDCP_DTI_2_ */ | |
38 | |
39 #include "sndcp.h" /* to get the global entity definitions */ | |
40 #include "sndcp_f.h" /* to get the functions to access the global arrays*/ | |
41 #include "sndcp_mgf.h" /* to get the local functions of service mg */ | |
42 #include "sndcp_nuf.h" | |
43 #include "sndcp_nus.h" /* to get the internal signals toservice nu */ | |
44 #include "sndcp_nds.h" /* to get the internal signals to service nd */ | |
45 #include "sndcp_cias.h" /* to get the internal signals to service cia */ | |
46 #include "sndcp_sds.h" /* to get the signals to sd service */ | |
47 #include "sndcp_sus.h" /* to get the internal signals to service su */ | |
48 #include "sndcp_suas.h" /* to get the internal signals to service sua */ | |
49 #include "sndcp_sdas.h" /* to get the signals to sda service */ | |
50 #include "sndcp_sdf.h" | |
51 #include "sndcp_sdaf.h" | |
52 | |
53 /*==== CONST ================================================================*/ | |
54 #define TCPIP_NAME "TCP" | |
55 /*==== LOCAL VARS ===========================================================*/ | |
56 | |
57 /*==== PRIVATE FUNCTIONS ====================================================*/ | |
58 | |
59 | |
60 /* | |
61 +------------------------------------------------------------------------------ | |
62 | Function : mg_est_cnf_est_pending | |
63 +------------------------------------------------------------------------------ | |
64 | Description : After receiving an ll_establish_cnf, an snsm_activate_res | |
65 | is sent to each waiting nsapi, sua and sda, sd are notified. | |
66 | | |
67 | Parameters : ll_establish_cnf | |
68 | | |
69 +------------------------------------------------------------------------------ | |
70 */ | |
71 LOCAL void mg_est_cnf_est_pending (T_LL_ESTABLISH_CNF* ll_establish_cnf) { | |
72 UBYTE nsapi = 0; | |
73 USHORT sapi_state = MG_IDLE; | |
74 | |
75 TRACE_FUNCTION( "mg_est_cnf_est_pending" ); | |
76 | |
77 /* | |
78 * If MG_REL_NEC_LOC/PEER is set for the affected sapi, there will be no | |
79 * nsapi waiting for LL_ESTABLISH_CNF. | |
80 * LL_RELEASE_REQ must be sent. | |
81 */ | |
82 sndcp_get_sapi_state(ll_establish_cnf->sapi, &sapi_state); | |
83 if ((sapi_state & MG_REL_NEC_LOC) > 0) { | |
84 PALLOC(ll_release_req, LL_RELEASE_REQ); | |
85 | |
86 ll_release_req->sapi = ll_establish_cnf->sapi; | |
87 ll_release_req->local = TRUE; | |
88 sndcp_unset_sapi_state(ll_release_req->sapi, MG_REL_NEC_LOC); | |
89 /* | |
90 * Set the "state" for the affected and sapi to MG_REL. | |
91 */ | |
92 sndcp_set_sapi_state(ll_establish_cnf->sapi, MG_REL); | |
93 sndcp_unset_sapi_state(ll_establish_cnf->sapi, MG_EST); | |
94 | |
95 PSEND(hCommLLC, ll_release_req); | |
96 return; | |
97 | |
98 } | |
99 | |
100 if ((sapi_state & MG_REL_NEC_PEER) > 0) { | |
101 PALLOC(ll_release_req, LL_RELEASE_REQ); | |
102 | |
103 ll_release_req->sapi = ll_establish_cnf->sapi; | |
104 ll_release_req->local = FALSE; | |
105 sndcp_unset_sapi_state(ll_release_req->sapi, MG_REL_NEC_PEER); | |
106 /* | |
107 * Set the "state" for the affected and sapi to MG_REL. | |
108 */ | |
109 sndcp_set_sapi_state(ll_establish_cnf->sapi, MG_REL); | |
110 sndcp_unset_sapi_state(ll_establish_cnf->sapi, MG_EST); | |
111 | |
112 PSEND(hCommLLC, ll_release_req); | |
113 | |
114 return; | |
115 } | |
116 if ((sapi_state & MG_XID_NEC) > 0) { | |
117 sndcp_unset_sapi_state(ll_establish_cnf->sapi, MG_EST); | |
118 return; | |
119 } | |
120 | |
121 | |
122 /* | |
123 * Send an SNSM_ACTIVATE_RES to all nsapis that are waiting for | |
124 * an LL_ESTABLISH_CNF. | |
125 */ | |
126 for (nsapi = 0; nsapi < SNDCP_NUMBER_OF_NSAPIS; nsapi++) { | |
127 | |
128 USHORT nsapi_state = MG_IDLE; | |
129 USHORT local_sapi_state = MG_IDLE; | |
130 UBYTE sapi = 0; | |
131 UBYTE sapi_index = 0; | |
132 | |
133 sndcp_get_nsapi_state(nsapi, &nsapi_state); | |
134 sndcp_get_nsapi_sapi(nsapi, &sapi); | |
135 sndcp_get_sapi_state(sapi, &local_sapi_state); | |
136 sndcp_get_sapi_index(sapi, &sapi_index); | |
137 if ((nsapi_state & MG_ACT) > 0 && | |
138 (local_sapi_state & MG_XID) == 0 && | |
139 sapi == ll_establish_cnf->sapi) { | |
140 | |
141 | |
142 #ifndef SNDCP_UPM_INCLUDED | |
143 mg_dti_open(nsapi); | |
144 #else | |
145 nu_ready_ind_if_nec(nsapi); | |
146 #endif | |
147 | |
148 mg_send_snsm_activate_res(nsapi); | |
149 | |
150 sndcp_unset_nsapi_state(nsapi, MG_ACT); | |
151 | |
152 } | |
153 if ((nsapi_state & MG_ACT) > 0 && | |
154 (local_sapi_state & MG_XID) > 0 && | |
155 sapi == ll_establish_cnf->sapi) { | |
156 | |
157 /* | |
158 * Open DTI connection. | |
159 */ | |
160 #ifndef SNDCP_UPM_INCLUDED | |
161 mg_dti_open(nsapi); | |
162 #else | |
163 nu_ready_ind_if_nec(nsapi); | |
164 #endif | |
165 | |
166 mg_send_snsm_activate_res(nsapi); | |
167 | |
168 /* | |
169 * Set nsapi state to MG_IDLE. | |
170 */ | |
171 sndcp_unset_nsapi_state(nsapi, MG_ACT); | |
172 | |
173 } | |
174 if (((local_sapi_state & MG_EST) > 0) && | |
175 ((nsapi_state & MG_ACT) == 0) && | |
176 ((local_sapi_state & MG_XID) > 0)) { | |
177 sig_mg_nu_reset_ack(nsapi, 0, 0, FALSE); | |
178 } | |
179 | |
180 | |
181 } /* for (nsapi... */ | |
182 | |
183 /* | |
184 * All nsapis at this sapi that use ack mode, enter recovery state. | |
185 */ | |
186 for (nsapi = 0; nsapi < SNDCP_NUMBER_OF_NSAPIS; nsapi ++) { | |
187 UBYTE sapi = 0; | |
188 BOOL ack = FALSE; | |
189 | |
190 sndcp_get_nsapi_sapi(nsapi, &sapi); | |
191 sndcp_get_nsapi_ack(nsapi, &ack); | |
192 if (ack && sapi == ll_establish_cnf->sapi) { | |
193 sig_mg_cia_delete_npdus(nsapi); | |
194 sig_mg_sua_delete_pdus(nsapi, sapi, FALSE); | |
195 sig_mg_nu_recover(nsapi); | |
196 sig_mg_nd_recover(nsapi); | |
197 } | |
198 } /* for all nsapis */ | |
199 | |
200 | |
201 sndcp_unset_sapi_state(ll_establish_cnf->sapi, MG_XID); | |
202 sndcp_unset_sapi_state(ll_establish_cnf->sapi, MG_EST); | |
203 | |
204 sndcp_set_sapi_ack(ll_establish_cnf->sapi, TRUE); | |
205 /* | |
206 * Service sda may now leave state SDA_ESTABLISH_REQUESTED. | |
207 */ | |
208 sig_mg_sda_end_est(ll_establish_cnf->sapi, TRUE); | |
209 /* | |
210 * Services su and sua may now leave suspend state. | |
211 */ | |
212 sig_mg_su_resume(ll_establish_cnf->sapi); | |
213 sig_mg_sua_resume(ll_establish_cnf->sapi); | |
214 mg_resume_affected_nus(ll_establish_cnf->sapi); | |
215 | |
216 /* | |
217 * If req xid has been changed during establishment, resend it. | |
218 */ | |
219 mg_resend_xid_if_nec(ll_establish_cnf->sapi); | |
220 | |
221 | |
222 } /* mg_est_cnf_est_pending() */ | |
223 | |
224 /* | |
225 +------------------------------------------------------------------------------ | |
226 | Function : mg_check_unset_nsapi_flow_ctrl_flag | |
227 +------------------------------------------------------------------------------ | |
228 | Description : This function checks if flow control is received before PDP | |
229 | activation for the nsapi by checking the bit in nsapi_rcv_rdy_b4_used flag | |
230 | for the NSAPI | |
231 | Depending on the mode calls the corresponding function to set the | |
232 | nsapi recv flag to true. | |
233 | In all cases unset the NSAPI bit in the nsapi_rcv_rdy_b4_used flag | |
234 | | |
235 | Parameters : affected nsapi, mode | |
236 | | |
237 +------------------------------------------------------------------------------ | |
238 */ | |
239 LOCAL void mg_check_unset_nsapi_flow_ctrl_flag (UBYTE nsapi, UBYTE mode) { | |
240 | |
241 /* check if flow control is received before PDP activation */ | |
242 if ((sndcp_data->nsapi_rcv_rdy_b4_used & (0x001 << nsapi)) > 0) | |
243 { | |
244 if (mode == SNDCP_ACK) | |
245 sda_set_nsapi_rec(nsapi, TRUE); | |
246 else if (mode == SNDCP_UNACK) | |
247 sd_set_nsapi_rec(nsapi, TRUE); | |
248 | |
249 /* Set flow control flag for the NSAPI to FALSE */ | |
250 sndcp_data->nsapi_rcv_rdy_b4_used &= ~(0x001 << nsapi); | |
251 } | |
252 } | |
253 | |
254 /* | |
255 +------------------------------------------------------------------------------ | |
256 | Function : mg_get_downlink_data | |
257 +------------------------------------------------------------------------------ | |
258 | Description : If at the given sapi an nsapi is active and using | |
259 | unacknowledged LLC operation mode then sig_mg_sd_getunitdata | |
260 | (sapi) is sent. | |
261 | If at the given sapi an nsapi is active and using | |
262 | acknowledged LLC operation mode then sig_mg_sda_getdata(sapi) | |
263 | is sent. | |
264 | | |
265 | Parameters : affected sapi | |
266 | | |
267 +------------------------------------------------------------------------------ | |
268 */ | |
269 LOCAL void mg_get_downlink_data (UBYTE sapi) { | |
270 | |
271 /* | |
272 * Are unack or ack nsapis used? | |
273 */ | |
274 UBYTE nsapi; | |
275 | |
276 TRACE_FUNCTION( "mg_get_downlink_data" ); | |
277 | |
278 for (nsapi = 0; nsapi < SNDCP_NUMBER_OF_NSAPIS; nsapi ++) { | |
279 BOOL used = FALSE; | |
280 | |
281 sndcp_is_nsapi_used(nsapi, &used); | |
282 if (used) { | |
283 UBYTE local_sapi = 0; | |
284 | |
285 sndcp_get_nsapi_sapi(nsapi, &local_sapi); | |
286 if (sapi == local_sapi) { | |
287 BOOL ack = FALSE; | |
288 USHORT nsapi_state = MG_IDLE; | |
289 USHORT sapi_state = MG_IDLE; | |
290 | |
291 sndcp_get_nsapi_state(nsapi, &nsapi_state); | |
292 sndcp_get_sapi_state(local_sapi, &sapi_state); | |
293 if (((sapi_state & MG_XID) == 0) && | |
294 ((sapi_state & MG_EST) == 0)) { | |
295 sndcp_get_nsapi_ack(nsapi, &ack); | |
296 if(ack){ | |
297 sig_mg_sda_getdata(sapi, nsapi); | |
298 } else { | |
299 sig_mg_sd_getunitdata(sapi, nsapi); | |
300 } | |
301 } | |
302 } | |
303 } | |
304 } /* for all nsapis */ | |
305 | |
306 } /* mg_get_downlink_data() */ | |
307 | |
308 | |
309 | |
310 | |
311 /* | |
312 +------------------------------------------------------------------------------ | |
313 | Function : mg_is_comp_available | |
314 +------------------------------------------------------------------------------ | |
315 | Description : is another compressor available | |
316 | | |
317 | Parameters : sapi, ack, kind, available | |
318 | | |
319 | Note: implementation dependent!!! | |
320 | | |
321 +------------------------------------------------------------------------------ | |
322 */ | |
323 LOCAL void mg_is_comp_available (UBYTE sapi, | |
324 BOOL ack, | |
325 UBYTE kind, | |
326 UBYTE msid, | |
327 BOOL* available) { | |
328 | |
329 UBYTE nsapi = 0; | |
330 USHORT nsapi_set = 0; | |
331 UBYTE sapi_index = 0; | |
332 BOOL local_ack = FALSE; | |
333 T_XID_BLOCK comp_xid_block; | |
334 U16 sapi_state = MG_IDLE; | |
335 | |
336 TRACE_FUNCTION( "mg_is_comp_available" ); | |
337 | |
338 sndcp_get_sapi_index(sapi, &sapi_index); | |
339 | |
340 /* | |
341 * Implementation dependent! | |
342 * Currently only implemented for VJ. | |
343 * Is requested xid block for the given SAPI holding a compressor of the | |
344 * given kind? | |
345 */ | |
346 if (sndcp_data->vj_count < SNDCP_MAX_VJ_COUNT) { | |
347 *available = TRUE; | |
348 return; | |
349 } | |
350 | |
351 /* | |
352 * If an XID negotiation is ongoing we have to look at the compressors in | |
353 * req_xid_block: is a compressor requested that will be used for the same | |
354 * LLC operation mode? | |
355 * If no negotiation is pending, we must look at the cur_xid_block of the | |
356 * SAPI. | |
357 * Note: since we have checked before that vj_count has already reached | |
358 * SNDCP_MAX_VJ_COUNT, ther must be an appropriate compressor on the | |
359 * used SAPI, current or requested which may also be used for this nsapi. | |
360 * No new compressor is available. | |
361 */ | |
362 | |
363 sndcp_get_sapi_state(sapi, &sapi_state); | |
364 | |
365 if (((sapi_state & MG_EST) == 0) && | |
366 ((sapi_state & MG_XID) == 0)) { | |
367 | |
368 comp_xid_block = sndcp_data->mg.cur_xid_block[sapi_index]; | |
369 } else { | |
370 comp_xid_block = sndcp_data->mg.req_xid_block[sapi_index]; | |
371 } | |
372 | |
373 | |
374 nsapi_set = comp_xid_block.vj.nsapis; | |
375 | |
376 if (! comp_xid_block.vj.is_set || | |
377 (comp_xid_block.vj.is_set && nsapi_set == 0)) { | |
378 *available = FALSE; | |
379 return; | |
380 } | |
381 | |
382 | |
383 /* | |
384 * If the LLC operation mode of the cur_xid_block is not equal to the | |
385 * given LLC operation mode, no compressor is available. | |
386 */ | |
387 for (nsapi = 0; nsapi < SNDCP_NUMBER_OF_NSAPIS; nsapi++) { | |
388 if (((1 << nsapi) & nsapi_set) > 0) { | |
389 break; | |
390 } | |
391 } | |
392 if(nsapi < SNDCP_NUMBER_OF_NSAPIS){ | |
393 sndcp_get_nsapi_ack(nsapi, &local_ack); | |
394 if ((local_ack && ack) || | |
395 (! local_ack && ack)) { | |
396 *available = TRUE; | |
397 return; | |
398 } | |
399 } else { | |
400 /* | |
401 * No nsapi yet using the compressor. | |
402 */ | |
403 *available = TRUE; | |
404 return; | |
405 } | |
406 *available = FALSE; | |
407 return; | |
408 | |
409 } /* mg_is_comp_available() */ | |
410 | |
411 /* | |
412 +------------------------------------------------------------------------------ | |
413 | Function : mg_ll_release_to_snsm_status | |
414 +------------------------------------------------------------------------------ | |
415 | Description : Converts ll_release_ind->cause to snsm_status_req->cause | |
416 | | |
417 | Parameters : ll_release_ind->error_cause | |
418 | Return : snsm_status_req->cause | |
419 | | |
420 +------------------------------------------------------------------------------ | |
421 */ | |
422 LOCAL U16 mg_ll_release_to_snsm_status (U16 ll_cause) { | |
423 | |
424 | |
425 switch (ll_cause) | |
426 { | |
427 #ifdef SNDCP_2to1 | |
428 return ll_cause; | |
429 #else /*SNDCP_2to1*/ | |
430 #ifdef SNDCP_UPM_INCLUDED | |
431 /* Here the cause values from LL sap is converted to | |
432 * cause values from CAUSE include SAP. This is because | |
433 * SM expects these cause values. | |
434 */ | |
435 case LL_RELCS_INVALID_XID: | |
436 return CAUSE_LLC_INVALID_XID; | |
437 case LL_RELCS_DM_RECEIVED: | |
438 return CAUSE_LLC_DM_RECEIVED; | |
439 case LL_RELCS_NO_PEER_RES: | |
440 return CAUSE_LLC_NO_PEER_RES; | |
441 case LL_RELCS_NORMAL: | |
442 return CAUSE_LLC_NORMAL_REL; | |
443 #endif /* SNDCP_UPM_INCLUDED */ | |
444 #endif /*SNDCP_2to1*/ | |
445 default: | |
446 return ll_cause; | |
447 } | |
448 | |
449 } /* mg_ll_release_to_snsm_status() */ | |
450 | |
451 /* | |
452 +------------------------------------------------------------------------------ | |
453 | Function : mg_ll_status_to_snsm_status | |
454 +------------------------------------------------------------------------------ | |
455 | Description : Converts ll_status_ind->error_cause to snsm_status_req->cause | |
456 | | |
457 | Parameters : ll_status_ind->error_cause | |
458 | Return : snsm_status_req->cause | |
459 | | |
460 +------------------------------------------------------------------------------ | |
461 */ | |
462 LOCAL U16 mg_ll_status_to_snsm_status (U16 ll_error_cause) { | |
463 | |
464 switch (ll_error_cause) | |
465 { | |
466 #ifdef SNDCP_2to1 | |
467 return ll_error_cause; | |
468 #else /*SNDCP_2to1*/ | |
469 #ifdef SNDCP_UPM_INCLUDED | |
470 /* Here the cause values from LL sap is converted to | |
471 * cause values from CAUSE include SAP. This is because | |
472 * SM expects these cause values. | |
473 */ | |
474 case LL_ERRCS_INVALID_XID: | |
475 return CAUSE_LLC_INVALID_XID; | |
476 case LL_ERRCS_NO_PEER_RES: | |
477 return CAUSE_LLC_NO_PEER_RES; | |
478 #endif /* SNDCP_UPM_INCLUDED */ | |
479 #endif /* SNDCP_2to1 */ | |
480 default: | |
481 return ll_error_cause; | |
482 | |
483 | |
484 } | |
485 } /* mg_ll_status_to_snsm_status() */ | |
486 | |
487 /* | |
488 +------------------------------------------------------------------------------ | |
489 | Function : mg_mod_ack_unack | |
490 +------------------------------------------------------------------------------ | |
491 | Description : An snsm_modify_ind has indicated that the operation mode of | |
492 | the affected nsapi changed from acknowledged to unacknowledged. | |
493 | | |
494 | Parameters : snsm_modify_ind | |
495 | | |
496 +------------------------------------------------------------------------------ | |
497 */ | |
498 #ifdef SNDCP_UPM_INCLUDED | |
499 LOCAL void mg_mod_ack_unack (T_SN_MODIFY_REQ* snsm_modify_ind) { | |
500 #else | |
501 LOCAL void mg_mod_ack_unack (T_SNSM_MODIFY_IND* snsm_modify_ind) { | |
502 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
503 | |
504 UBYTE nsapi = 0; | |
505 BOOL alone = TRUE; | |
506 | |
507 TRACE_FUNCTION( "mg_mod_ack_unack" ); | |
508 | |
509 mg_delete_npdus(snsm_modify_ind->nsapi); | |
510 sig_mg_nu_reset(snsm_modify_ind->nsapi, TRUE); | |
511 /* | |
512 * LL_RELEASE_IND expected, if this was the only ack nsapi on the affected | |
513 * sapi. | |
514 */ | |
515 while (nsapi < SNDCP_NUMBER_OF_NSAPIS && alone) { | |
516 | |
517 UBYTE sapi = 0; | |
518 BOOL ack = FALSE; | |
519 | |
520 sndcp_get_nsapi_sapi(nsapi, &sapi); | |
521 sndcp_get_nsapi_ack(nsapi, &ack); | |
522 alone = ! (nsapi != snsm_modify_ind->nsapi && | |
523 sapi == snsm_modify_ind->sapi && | |
524 ack); | |
525 | |
526 sndcp_set_nsapi_ack(snsm_modify_ind->nsapi, FALSE); | |
527 nsapi++; | |
528 } | |
529 if (alone) { | |
530 sndcp_data->mg.mod_expects |= MG_MOD_X_REL; | |
531 } | |
532 | |
533 } /* mg_mod_ack_unack() */ | |
534 | |
535 /* | |
536 +------------------------------------------------------------------------------ | |
537 | Function : mg_mod_nsapi_new | |
538 +------------------------------------------------------------------------------ | |
539 | Description : An snsm_modify_ind has indicated the creation of a new NSAPI. | |
540 | Actions similar to snsm_activate_ind are taken, but the | |
541 | establishment is never initiated by the MS. Everything | |
542 | concerning the given nsapi is set to acknowlegded, but the | |
543 | LLC establishment is expected to be done by the net. | |
544 | | |
545 | Parameters : snsm_modify_ind | |
546 | | |
547 +------------------------------------------------------------------------------ | |
548 */ | |
549 #ifdef SNDCP_UPM_INCLUDED | |
550 LOCAL void mg_mod_nsapi_new (T_SN_MODIFY_REQ* snsm_modify_ind) { | |
551 #else | |
552 LOCAL void mg_mod_nsapi_new (T_SNSM_MODIFY_IND* snsm_modify_ind) { | |
553 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
554 | |
555 /* | |
556 * LLC mode specified? | |
557 */ | |
558 BOOL spec = FALSE; | |
559 /* | |
560 * LLC mode acknowledged? | |
561 */ | |
562 BOOL b = FALSE; | |
563 | |
564 TRACE_FUNCTION( "mg_mod_nsapi_new" ); | |
565 | |
566 sndcp_set_nsapi_used(snsm_modify_ind->nsapi, TRUE); | |
567 sndcp_set_nsapi_qos(snsm_modify_ind->nsapi, | |
568 snsm_modify_ind->snsm_qos); | |
569 sndcp_set_nsapi_sapi(snsm_modify_ind->nsapi, | |
570 snsm_modify_ind->sapi); | |
571 sndcp_set_nsapi_prio(snsm_modify_ind->nsapi, | |
572 snsm_modify_ind->radio_prio); | |
573 #ifdef REL99 | |
574 sndcp_set_nsapi_pktflowid(snsm_modify_ind->nsapi, | |
575 snsm_modify_ind->pkt_flow_id); | |
576 #endif /*REL99*/ | |
577 | |
578 mg_is_ack(snsm_modify_ind->snsm_qos, &spec, &b); | |
579 if (spec) { | |
580 if (b) { | |
581 | |
582 BOOL ack = FALSE; | |
583 | |
584 /* | |
585 * The NSAPI will use acknowledged LLC operation mode. | |
586 */ | |
587 sndcp_set_nsapi_ack(snsm_modify_ind->nsapi, TRUE); | |
588 /* | |
589 * Is the affected SAPI already in ack mode? | |
590 */ | |
591 sndcp_get_sapi_ack(snsm_modify_ind->sapi, &ack); | |
592 /* | |
593 * Reset service nu to acknowledged LLC mode. | |
594 */ | |
595 #ifdef SNDCP_UPM_INCLUDED | |
596 sig_mg_nu_reset_ack(snsm_modify_ind->nsapi, | |
597 0, /*snsm_modify_ind->send_no, FIXME !!*/ | |
598 0, /*snsm_modify_ind->rec_no, FIXME !!*/ | |
599 TRUE); | |
600 #else | |
601 sig_mg_nu_reset_ack(snsm_modify_ind->nsapi, | |
602 snsm_modify_ind->send_no, | |
603 snsm_modify_ind->rec_no, | |
604 TRUE); | |
605 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
606 } | |
607 } | |
608 /* | |
609 * LL_ESTABLISH_IND expected. | |
610 */ | |
611 sndcp_data->mg.mod_expects |= MG_MOD_X_EST; | |
612 | |
613 } /* mg_mod_nsapi_new() */ | |
614 | |
615 /* | |
616 +------------------------------------------------------------------------------ | |
617 | Function : mg_mod_res_if_nec | |
618 +------------------------------------------------------------------------------ | |
619 | Description : The service var 'mod_expects' informs about the measures to be | |
620 | taken before an SNSM_MODIFY_RES is sent. | |
621 | If it is set to MG_MOD_X_READY then one SNSM_MODIFY_RES will be sent to each | |
622 | of the nsapis indicated in service var 'waiting_nsapis'. | |
623 | Sets 'waiting_nsapis' to 0. | |
624 | Sets 'mod_expects' to MG_MOD_X_NONE. | |
625 | | |
626 | Parameters : | |
627 | | |
628 +------------------------------------------------------------------------------ | |
629 */ | |
630 LOCAL void mg_mod_res_if_nec (void) { | |
631 | |
632 TRACE_FUNCTION( "mg_mod_res_if_nec" ); | |
633 | |
634 if (sndcp_data->mg.mod_expects == MG_MOD_X_READY) { | |
635 | |
636 UBYTE nsapi = 0; | |
637 | |
638 for (nsapi = 0; nsapi < SNDCP_NUMBER_OF_NSAPIS; nsapi++) { | |
639 if ((sndcp_data->mg.waiting_nsapis & (1 << nsapi)) > 0) { | |
640 | |
641 #ifdef SNDCP_UPM_INCLUDED | |
642 PALLOC (snsm_modify_res, SN_MODIFY_CNF); | |
643 #else | |
644 PALLOC (snsm_modify_res, SNSM_MODIFY_RES); | |
645 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
646 snsm_modify_res->nsapi = nsapi; | |
647 #ifdef SNDCP_UPM_INCLUDED | |
648 PSEND(hCommUPM, snsm_modify_res); | |
649 #else | |
650 PSEND(hCommSM, snsm_modify_res); | |
651 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
652 } | |
653 } | |
654 sndcp_data->mg.waiting_nsapis = 0; | |
655 sndcp_data->mg.mod_expects = MG_MOD_X_NONE; | |
656 } | |
657 } /* mg_mod_res_if_nec() */ | |
658 | |
659 /* | |
660 +------------------------------------------------------------------------------ | |
661 | Function : mg_mod_sapi_diff | |
662 +------------------------------------------------------------------------------ | |
663 | Description : An snsm_modify_ind has indicated that the new sapi for the | |
664 | affected context is different from the current one. | |
665 | | |
666 | Parameters : snsm_modify_ind | |
667 | | |
668 +------------------------------------------------------------------------------ | |
669 */ | |
670 #ifdef SNDCP_UPM_INCLUDED | |
671 LOCAL void mg_mod_sapi_diff (T_SN_MODIFY_REQ* snsm_modify_ind) { | |
672 #else | |
673 LOCAL void mg_mod_sapi_diff (T_SNSM_MODIFY_IND* snsm_modify_ind) { | |
674 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
675 | |
676 BOOL old_sapi_ack = FALSE; | |
677 BOOL alone = TRUE; | |
678 BOOL new_context_ack = FALSE; | |
679 BOOL new_context_ack_spec = FALSE; | |
680 BOOL new_sapi_est = FALSE; | |
681 UBYTE nsapi = 0; | |
682 UBYTE old_sapi = 0; | |
683 BOOL rec = FALSE; | |
684 UBYTE old_sapi_index, new_sapi_index = 0; | |
685 T_SN_UNITDATA_IND *temp_sn_unitdata = NULL; | |
686 | |
687 TRACE_FUNCTION( "mg_mod_sapi_diff" ); | |
688 | |
689 /* | |
690 * If old sapi was established and affected nsapi is only one connected | |
691 * in ack mode: LL_RELEASE_IND expected. | |
692 */ | |
693 sndcp_get_sapi_ack(snsm_modify_ind->sapi, &old_sapi_ack); | |
694 while (nsapi < SNDCP_NUMBER_OF_NSAPIS && alone) { | |
695 | |
696 UBYTE sapi = 0; | |
697 BOOL ack = FALSE; | |
698 | |
699 sndcp_get_nsapi_sapi(nsapi, &sapi); | |
700 sndcp_get_nsapi_ack(nsapi, &ack); | |
701 alone = ! (nsapi != snsm_modify_ind->nsapi && | |
702 sapi == snsm_modify_ind->sapi && | |
703 ack); | |
704 | |
705 | |
706 nsapi++; | |
707 } | |
708 | |
709 /* | |
710 * If new qos is ack and new sapi is not yet established: expect | |
711 * LL_ESTABLISH_IND. | |
712 */ | |
713 mg_is_ack(snsm_modify_ind->snsm_qos, | |
714 &new_context_ack_spec, | |
715 &new_context_ack); | |
716 | |
717 if (alone && !new_context_ack) { | |
718 sndcp_data->mg.mod_expects |= MG_MOD_X_REL; | |
719 } | |
720 | |
721 | |
722 sndcp_get_sapi_ack(snsm_modify_ind->sapi, &new_sapi_est); | |
723 if (! new_sapi_est) { | |
724 sndcp_data->mg.mod_expects |= MG_MOD_X_EST; | |
725 } | |
726 | |
727 /* Old & the New SAPI are UnAck Mode, send SNSM_MOD_CNF to SM and | |
728 * flowcontrol to LLC | |
729 */ | |
730 sndcp_get_nsapi_sapi(snsm_modify_ind->nsapi, &old_sapi); | |
731 sndcp_get_sapi_ack(old_sapi, &old_sapi_ack); | |
732 if(new_context_ack == old_sapi_ack && old_sapi_ack == FALSE) | |
733 { | |
734 sndcp_get_sapi_index(old_sapi, &old_sapi_index); | |
735 sndcp_data->sd = & sndcp_data->sd_base[old_sapi_index]; | |
736 sd_is_nsapi_rec(snsm_modify_ind->nsapi, &rec); | |
737 | |
738 /* Copy the Pointer, where Data on old Sapi was stored if any */ | |
739 if(sndcp_data->sd->cur_sn_unitdata_ind[snsm_modify_ind->nsapi] NEQ NULL) | |
740 { | |
741 temp_sn_unitdata = | |
742 sndcp_data->sd->cur_sn_unitdata_ind[snsm_modify_ind->nsapi]; | |
743 sndcp_data->sd->cur_sn_unitdata_ind[snsm_modify_ind->nsapi] = NULL; | |
744 } | |
745 | |
746 /* Set the old SAPI's NSAPI state to Non Receptive*/ | |
747 sd_set_nsapi_rec(snsm_modify_ind->nsapi, FALSE); | |
748 | |
749 /* Set the state of NSAPI associated with new SAPI same as Old SAPI */ | |
750 sndcp_get_sapi_index(snsm_modify_ind->sapi, &new_sapi_index); | |
751 sndcp_data->sd = & sndcp_data->sd_base[new_sapi_index]; | |
752 sd_set_nsapi_rec(snsm_modify_ind->nsapi, rec); | |
753 | |
754 sndcp_data->mg.mod_expects = MG_MOD_X_READY; | |
755 | |
756 /* | |
757 * Taking care of DOWNLINK Data, when PDP is Modified | |
758 * from one sapi to another. | |
759 */ | |
760 switch( sndcp_get_nsapi_rec_state(snsm_modify_ind->nsapi) ) | |
761 { | |
762 case SD_UNACK_RECEIVE_SUBSEQUENT_SEGMENT: | |
763 /* | |
764 * If the Receiving State is SD_UNACK_RECEIVE_SUBSEQUENT_SEGMENT, | |
765 * this means that SNDCP has not receive the whole N-PDU, | |
766 * it has received some SN-PDU's of the whole N-PDU. | |
767 * Hence we need to DELETE those SN-PDU's since PDP gets modified. | |
768 */ | |
769 sig_mg_cia_delete_npdus(snsm_modify_ind->nsapi); | |
770 sndcp_set_nsapi_rec_state(snsm_modify_ind->nsapi, | |
771 SD_UNACK_RECEIVE_FIRST_SEGMENT); | |
772 break; | |
773 | |
774 case SD_UNACK_WAIT_NSAPI: | |
775 /* | |
776 * If the Receiving State is SD_UNACK_WAIT_NSAPI, this means that | |
777 * SNDCP has received the whole N-PDU. | |
778 * Since SNDCP has not received the FLOW CONTROL from application, | |
779 * so it could not send the N-PDU to the application. | |
780 * In the meantime PDP gets modified.In this condition SNDCP needs | |
781 * to copy the N-PDU from the old sapi to the modified sapi. | |
782 */ | |
783 if(temp_sn_unitdata NEQ NULL) | |
784 { | |
785 sndcp_data->sd->cur_sn_unitdata_ind[snsm_modify_ind->nsapi] | |
786 = temp_sn_unitdata; | |
787 } | |
788 break; | |
789 | |
790 default: | |
791 /* | |
792 * It is assumed that if the Receiving State is SD_UNACK_DISCARD | |
793 * then SNDCP must have deleted all the SN-PDU,s that it might | |
794 * have received on the old sapi. Hence we need not have to do | |
795 * anything here. | |
796 */ | |
797 break; | |
798 } | |
799 | |
800 /* Flowcontrol to LLC for new SAPI to send downlink data after | |
801 * PDP Modification | |
802 */ | |
803 if(sndcp_data->sd->cur_sn_unitdata_ind[snsm_modify_ind->nsapi] EQ NULL) | |
804 { | |
805 sd_get_unitdata_if_nec(snsm_modify_ind->sapi); | |
806 } | |
807 } | |
808 /* | |
809 * Now switch to the new setting. | |
810 */ | |
811 sndcp_set_nsapi_sapi(snsm_modify_ind->nsapi, snsm_modify_ind->sapi); | |
812 | |
813 } /* mg_mod_sapi_diff() */ | |
814 | |
815 /* | |
816 +------------------------------------------------------------------------------ | |
817 | Function : mg_mod_unack_ack | |
818 +------------------------------------------------------------------------------ | |
819 | Description : An snsm_modify_ind has indicated that the operation mode of | |
820 | the affected nsapi changed from unacknowledged to acknowledged. | |
821 | | |
822 | Parameters : snsm_modify_ind | |
823 | | |
824 +------------------------------------------------------------------------------ | |
825 */ | |
826 #ifdef SNDCP_UPM_INCLUDED | |
827 LOCAL void mg_mod_unack_ack (T_SN_MODIFY_REQ* snsm_modify_ind) { | |
828 #else | |
829 LOCAL void mg_mod_unack_ack (T_SNSM_MODIFY_IND* snsm_modify_ind) { | |
830 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
831 | |
832 BOOL ack = FALSE; | |
833 | |
834 TRACE_FUNCTION( "mg_mod_unack_ack" ); | |
835 | |
836 mg_delete_npdus(snsm_modify_ind->nsapi); | |
837 sndcp_set_nsapi_ack(snsm_modify_ind->nsapi, TRUE); | |
838 sig_mg_nu_reset_ack(snsm_modify_ind->nsapi, 0, 0, TRUE); | |
839 /* | |
840 * LL_ESTABLISH_IND expected, if the sapi is not in established mode. | |
841 */ | |
842 sndcp_get_sapi_ack(snsm_modify_ind->sapi, &ack); | |
843 if (! ack) { | |
844 sndcp_data->mg.mod_expects |= MG_MOD_X_EST; | |
845 } | |
846 } /* mg_mod_unack_ack() */ | |
847 | |
848 | |
849 /* | |
850 +------------------------------------------------------------------------------ | |
851 | Function : mg_start_re_est_timer | |
852 +------------------------------------------------------------------------------ | |
853 | Description : According to GSM 4.65, 6.2.1.4, starts re-establishment timer | |
854 | | |
855 | Parameters : affected sapi | |
856 | | |
857 +------------------------------------------------------------------------------ | |
858 */ | |
859 LOCAL void mg_start_re_est_timer (UBYTE sapi) { | |
860 UBYTE sapi_index = 0; | |
861 | |
862 TRACE_FUNCTION( "mg_start_re_est_timer" ); | |
863 | |
864 sndcp_get_sapi_index(sapi, &sapi_index); | |
865 vsi_t_start(SNDCP_handle, sapi_index, MG_RE_EST_TIME); | |
866 | |
867 } /* mg_start_re_est_timer() */ | |
868 | |
869 | |
870 | |
871 | |
872 /*==== PUBLIC FUNCTIONS =====================================================*/ | |
873 | |
874 | |
875 /* | |
876 +------------------------------------------------------------------------------ | |
877 | Function : mg_exp_re_est_timer | |
878 +------------------------------------------------------------------------------ | |
879 | Description : Re establishment timer has expired | |
880 | | |
881 | Parameters : sapi_index | |
882 | | |
883 +------------------------------------------------------------------------------ | |
884 */ | |
885 GLOBAL void mg_exp_re_est_timer (UBYTE sapi_index) | |
886 { | |
887 TRACE_FUNCTION( "mg_exp_re_est_timer" ); | |
888 | |
889 sndcp_data->su = & sndcp_data->su_base[sapi_index]; | |
890 #ifdef SNDCP_UPM_INCLUDED | |
891 mg_re_negotiate_ack(sndcp_data->su->sapi, | |
892 CAUSE_SN_NO_PEER_RESPONSE); | |
893 #else | |
894 mg_re_negotiate_ack(sndcp_data->su->sapi, | |
895 LL_RELCS_NO_PEER_RES); | |
896 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
897 | |
898 } /* mg_exp_re_est_timer() */ | |
899 | |
900 /* | |
901 +------------------------------------------------------------------------------ | |
902 | Function : mg_ll_reset_ind | |
903 +------------------------------------------------------------------------------ | |
904 | Description : Handles the primitive LL_RESET_IND | |
905 | | |
906 | Parameters : *ll_reset_ind - Ptr to primitive payload | |
907 | | |
908 +------------------------------------------------------------------------------ | |
909 */ | |
910 GLOBAL void mg_ll_reset_ind ( T_LL_RESET_IND *ll_reset_ind ) | |
911 { | |
912 UBYTE nsapi = 0; | |
913 UBYTE sapi_index = 0; | |
914 BOOL ack = FALSE; | |
915 UBYTE sapi = 0; | |
916 | |
917 TRACE_FUNCTION( "mg_ll_reset_ind" ); | |
918 | |
919 switch( GET_STATE( MG ) ) | |
920 { | |
921 case MG_DEFAULT: | |
922 for (nsapi = 0; nsapi < SNDCP_NUMBER_OF_NSAPIS;nsapi++) { | |
923 BOOL used = 0; | |
924 | |
925 sndcp_is_nsapi_used(nsapi, &used); | |
926 if (! used) { | |
927 continue; | |
928 } | |
929 sig_mg_nu_reset_ind(nsapi); | |
930 sig_mg_nu_suspend(nsapi); | |
931 | |
932 sndcp_get_nsapi_sapi(nsapi, &sapi); | |
933 sndcp_get_nsapi_ack(nsapi, &ack); | |
934 | |
935 if (ack) { | |
936 sig_mg_sua_delete_pdus(nsapi, sapi, FALSE); | |
937 sig_mg_sda_reset_ind(nsapi); | |
938 sig_mg_nd_suspend(nsapi); | |
939 sndcp_set_nsapi_state(nsapi, MG_SEQ); | |
940 /* Set the flag as LL_ESTB_IND is expected | |
941 * before resend of buffered NPDU | |
942 */ | |
943 sndcp_set_sapi_state(sapi, MG_EST_IND); | |
944 } else { | |
945 sig_mg_su_delete_pdus(nsapi, sapi); | |
946 sig_mg_sd_reset_ind(nsapi); | |
947 } | |
948 sig_mg_nd_reset_ind(nsapi); | |
949 } | |
950 sig_mg_cia_reset_ind(); | |
951 /* | |
952 * Reset pending states and xid_block. | |
953 */ | |
954 for (sapi_index = 0; sapi_index < SNDCP_NUMBER_OF_SAPIS; sapi_index++) { | |
955 | |
956 sapi = (sndcp_data->sua_base[sapi_index]).sapi; | |
957 /* | |
958 * Reset SUA and SU services | |
959 */ | |
960 sig_mg_sua_n201(sapi, N201_I_DEFAULT); | |
961 sig_mg_sua_reset_ind(sapi); | |
962 sig_mg_su_n201(sapi, N201_U_DEFAULT); | |
963 sig_mg_su_reset_ind(sapi); | |
964 /* | |
965 * cnf_xid_block and req_xid_block initialized. | |
966 */ | |
967 sndcp_reset_xid_block(&sndcp_data->mg.cnf_xid_block[sapi_index]); | |
968 sndcp_reset_xid_block(&sndcp_data->mg.req_xid_block[sapi_index]); | |
969 | |
970 mg_reset_states_n_rej(sapi_index); | |
971 /* | |
972 * Init renegotiation counter and cur_xid_block with default values. | |
973 */ | |
974 sndcp_data->mg.renego[sapi_index] = 0; | |
975 | |
976 sndcp_reset_xid_block(&sndcp_data->mg.cur_xid_block[sapi_index]); | |
977 sig_mg_cia_new_xid (&sndcp_data->mg.cur_xid_block[sapi_index]); | |
978 } | |
979 sndcp_data->mg.mod_expects = MG_MOD_X_NONE; | |
980 sndcp_data->mg.waiting_nsapis = 0; | |
981 | |
982 break; | |
983 default: | |
984 TRACE_ERROR( "LL_RESET_IND unexpected" ); | |
985 break; | |
986 } | |
987 if (ll_reset_ind != NULL) { | |
988 PFREE (ll_reset_ind); | |
989 } | |
990 | |
991 } /* mg_ll_reset_ind() */ | |
992 | |
993 | |
994 | |
995 /* | |
996 +------------------------------------------------------------------------------ | |
997 | Function : mg_ll_establish_cnf | |
998 +------------------------------------------------------------------------------ | |
999 | Description : Handles the primitive LL_ESTABLISH_CNF | |
1000 | | |
1001 | Parameters : *ll_establish_cnf - Ptr to primitive payload | |
1002 | | |
1003 +------------------------------------------------------------------------------ | |
1004 */ | |
1005 GLOBAL void mg_ll_establish_cnf ( T_LL_ESTABLISH_CNF *ll_establish_cnf ) | |
1006 { | |
1007 UBYTE sapi_index = 0; | |
1008 USHORT state = 0; | |
1009 | |
1010 TRACE_FUNCTION( "mg_ll_establish_cnf" ); | |
1011 TRACE_EVENT_P1("ll_establish_cnf->n201_i: %d", ll_establish_cnf->n201_i); | |
1012 | |
1013 sndcp_get_sapi_index(ll_establish_cnf->sapi, &sapi_index); | |
1014 switch( GET_STATE( MG ) ) | |
1015 { | |
1016 case MG_DEFAULT: | |
1017 sndcp_get_sapi_state(ll_establish_cnf->sapi, &state); | |
1018 if ((state & MG_EST) > 0) { | |
1019 | |
1020 UBYTE dec_ret = 0; | |
1021 UBYTE check_ret = 0; | |
1022 | |
1023 /* | |
1024 * Reset all compressors at this SAPI in ack mode. | |
1025 */ | |
1026 mg_reset_comp_ack(ll_establish_cnf->sapi); | |
1027 /* | |
1028 * Set N201 values in uplink services. | |
1029 */ | |
1030 sig_mg_su_n201(ll_establish_cnf->sapi, ll_establish_cnf->n201_u); | |
1031 sig_mg_sua_n201(ll_establish_cnf->sapi, ll_establish_cnf->n201_i); | |
1032 | |
1033 /* | |
1034 * SDL label MG_EST_CNF_EST_XID_PENDING. | |
1035 */ | |
1036 mg_decode_xid(&(ll_establish_cnf->sdu), | |
1037 &(sndcp_data->mg.cnf_xid_block[sapi_index]), | |
1038 &dec_ret, | |
1039 ll_establish_cnf->sapi); | |
1040 if (dec_ret == MG_XID_OK) | |
1041 { | |
1042 /* | |
1043 * SDL label MG_CHECK_CNF_XID_ACK | |
1044 */ | |
1045 mg_check_cnf_xid(&check_ret, ll_establish_cnf->sapi); | |
1046 if (check_ret == MG_XID_OK) | |
1047 { | |
1048 | |
1049 /* | |
1050 * This is now similar to the reaction to LL_XID_CNF: | |
1051 */ | |
1052 /* | |
1053 * SDL Label MG_CNF_OK_ACK | |
1054 */ | |
1055 mg_set_cur_xid_block(ll_establish_cnf->sapi); | |
1056 /* | |
1057 * Reset nsapis or ntts that were assigned, but are not any more. | |
1058 */ | |
1059 mg_clean_xid(ll_establish_cnf->sapi); | |
1060 /* | |
1061 * Resume suspended data transfer on sapi will be done in | |
1062 * mg_est_cnf_est_pending(ll_establish_cnf). | |
1063 */ | |
1064 | |
1065 mg_est_cnf_est_pending(ll_establish_cnf); | |
1066 | |
1067 sndcp_get_sapi_state(ll_establish_cnf->sapi, &state); | |
1068 if (((state & MG_XID_NEC) > 0) | |
1069 && | |
1070 ((state & MG_REL) == 0)) { | |
1071 mg_resend_xid_if_nec(ll_establish_cnf->sapi); | |
1072 } | |
1073 | |
1074 } else { | |
1075 #ifdef SNDCP_UPM_INCLUDED | |
1076 mg_re_negotiate_ack(ll_establish_cnf->sapi, | |
1077 CAUSE_SN_INVALID_XID); | |
1078 #else | |
1079 mg_re_negotiate_ack(ll_establish_cnf->sapi, | |
1080 SNSM_RELCS_INVALID_XID); | |
1081 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
1082 } | |
1083 } else { | |
1084 #ifdef SNDCP_UPM_INCLUDED | |
1085 mg_re_negotiate_ack(ll_establish_cnf->sapi, | |
1086 CAUSE_SN_INVALID_XID); | |
1087 #else | |
1088 mg_re_negotiate_ack(ll_establish_cnf->sapi, | |
1089 SNSM_RELCS_INVALID_XID); | |
1090 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
1091 } | |
1092 break; | |
1093 | |
1094 } else { /* if ((state & MG_EST) > 0) */ | |
1095 | |
1096 PALLOC(ll_release_req, LL_RELEASE_REQ); | |
1097 | |
1098 sndcp_unset_sapi_state(ll_release_req->sapi, MG_REL_NEC_PEER); | |
1099 ll_release_req->sapi = ll_establish_cnf->sapi; | |
1100 ll_release_req->local = FALSE; | |
1101 /* | |
1102 * Set the "state" for the affected sapi to MG_REL. | |
1103 */ | |
1104 sndcp_set_sapi_state(ll_establish_cnf->sapi, MG_REL); | |
1105 | |
1106 PSEND(hCommLLC, ll_release_req); | |
1107 } | |
1108 break; | |
1109 default: | |
1110 TRACE_ERROR( "LL_ESTABLISH_CNF unexpected" ); | |
1111 break; | |
1112 } | |
1113 | |
1114 /* | |
1115 * Establish confirm has been computed. If no new XID is pending, | |
1116 * the req_xid_block may be reset. | |
1117 */ | |
1118 sndcp_get_sapi_state(ll_establish_cnf->sapi, &state); | |
1119 if (((state & MG_XID) == 0) && | |
1120 ((state & MG_EST) == 0)) { | |
1121 sndcp_reset_xid_block(&sndcp_data->mg.req_xid_block[sapi_index]); | |
1122 } | |
1123 | |
1124 if (ll_establish_cnf != NULL) { | |
1125 PFREE(ll_establish_cnf); | |
1126 } | |
1127 | |
1128 } /* mg_ll_establish_cnf() */ | |
1129 | |
1130 | |
1131 /* | |
1132 +------------------------------------------------------------------------------ | |
1133 | Function : mg_ll_status_ind | |
1134 +------------------------------------------------------------------------------ | |
1135 | Description : Handles the primitive LL_STATUS_IND | |
1136 | | |
1137 | Parameters : *ll_status_ind - Ptr to primitive payload | |
1138 | | |
1139 +------------------------------------------------------------------------------ | |
1140 */ | |
1141 GLOBAL void mg_ll_status_ind ( T_LL_STATUS_IND *ll_status_ind ) | |
1142 { | |
1143 USHORT sapi_state = MG_IDLE; | |
1144 | |
1145 TRACE_FUNCTION( "mg_ll_status_ind" ); | |
1146 | |
1147 switch( GET_STATE( MG ) ) | |
1148 { | |
1149 case MG_DEFAULT: | |
1150 { | |
1151 #ifdef SNDCP_UPM_INCLUDED | |
1152 PALLOC(snsm_status_req, SN_STATUS_IND); | |
1153 #else | |
1154 PALLOC(snsm_status_req, SNSM_STATUS_REQ); | |
1155 #endif | |
1156 snsm_status_req->sapi = ll_status_ind->sapi; | |
1157 | |
1158 #ifdef SNDCP_UPM_INCLUDED | |
1159 snsm_status_req->ps_cause.ctrl_value = CAUSE_is_from_llc; | |
1160 snsm_status_req->ps_cause.value.llc_cause = | |
1161 #ifdef SNDCP_2to1 | |
1162 mg_ll_status_to_snsm_status(ll_status_ind->ps_cause.value.llc_cause); | |
1163 #else /*SNDCP_2to1*/ | |
1164 mg_ll_status_to_snsm_status(ll_status_ind->error_cause); | |
1165 #endif /*SNDCP_2to1*/ | |
1166 | |
1167 PSEND(hCommUPM, snsm_status_req); | |
1168 | |
1169 #else /*SNDCP_UPM_INCLUDED*/ | |
1170 snsm_status_req->status_cause = | |
1171 #ifdef _SNDCP_DTI_2_ | |
1172 mg_ll_status_to_snsm_status(ll_status_ind->error_cause); | |
1173 #else /* _SNDCP_DTI_2_ */ | |
1174 (U8)mg_ll_status_to_snsm_status(ll_status_ind->error_cause); | |
1175 #endif /* _SNDCP_DTI_2_ */ | |
1176 | |
1177 PSEND(hCommSM, snsm_status_req); | |
1178 #endif /*SNDCP_UPM_INCLUDED*/ | |
1179 sndcp_get_sapi_state(ll_status_ind->sapi, &sapi_state); | |
1180 if ((sapi_state & MG_XID) != 0) | |
1181 { | |
1182 sig_mg_su_resume(ll_status_ind->sapi); | |
1183 sig_mg_sua_resume(ll_status_ind->sapi); | |
1184 mg_resume_affected_nus(ll_status_ind->sapi); | |
1185 sndcp_unset_sapi_state (ll_status_ind->sapi, MG_XID); | |
1186 } | |
1187 if ((sapi_state & MG_EST) != 0) | |
1188 { | |
1189 #ifdef SNDCP_UPM_INCLUDED | |
1190 if (snsm_status_req->ps_cause.value.llc_cause == | |
1191 CAUSE_LLC_NO_PEER_RES) { | |
1192 #else /* SNDCP_UPM_INCLUDED */ | |
1193 #ifdef _SNDCP_DTI_2_ | |
1194 if (snsm_status_req->status_cause == LL_RELCS_NO_PEER_RES) { | |
1195 #else /*_SNDCP_DTI_2_*/ | |
1196 if (snsm_status_req->status_cause == SNSM_RELCS_NO_PEER_RES) { | |
1197 #endif /* _SNDCP_DTI_2_*/ | |
1198 #endif /* SNDCP_UPM_INCLUDED */ | |
1199 mg_start_re_est_timer(ll_status_ind->sapi); | |
1200 } else { | |
1201 sig_mg_su_resume(ll_status_ind->sapi); | |
1202 sig_mg_sua_resume(ll_status_ind->sapi); | |
1203 mg_resume_affected_nus(ll_status_ind->sapi); | |
1204 sndcp_unset_sapi_state (ll_status_ind->sapi, MG_EST); | |
1205 } | |
1206 } | |
1207 } | |
1208 break; | |
1209 default: | |
1210 TRACE_ERROR( "LL_STATUS_IND unexpected" ); | |
1211 break; | |
1212 } | |
1213 | |
1214 if (ll_status_ind != NULL) { | |
1215 PFREE(ll_status_ind); | |
1216 } | |
1217 | |
1218 } /* mg_ll_status_ind() */ | |
1219 | |
1220 | |
1221 /* | |
1222 +------------------------------------------------------------------------------ | |
1223 | Function : mg_ll_establish_ind | |
1224 +------------------------------------------------------------------------------ | |
1225 | Description : Handles the primitive LL_ESTABLISH_IND | |
1226 | | |
1227 | Parameters : *ll_establish_ind - Ptr to primitive payload | |
1228 | | |
1229 +------------------------------------------------------------------------------ | |
1230 */ | |
1231 GLOBAL void mg_ll_establish_ind ( T_LL_ESTABLISH_IND *ll_establish_ind ) | |
1232 { | |
1233 USHORT sapi_state = 0; | |
1234 | |
1235 TRACE_FUNCTION( "mg_ll_establish_ind" ); | |
1236 | |
1237 switch( GET_STATE( MG ) ) | |
1238 { | |
1239 case MG_DEFAULT: | |
1240 sndcp_unset_sapi_state(ll_establish_ind->sapi, MG_EST_IND); | |
1241 /* | |
1242 * Reset all compressors at this SAPI in ack mode. | |
1243 */ | |
1244 mg_reset_comp_ack(ll_establish_ind->sapi); | |
1245 /* | |
1246 * If prim has been expected in course of modification, here it is. | |
1247 */ | |
1248 sndcp_data->mg.mod_expects &= ~ MG_MOD_X_EST; | |
1249 /* | |
1250 * Do we have a collision? | |
1251 */ | |
1252 sndcp_get_sapi_state(ll_establish_ind->sapi, &sapi_state); | |
1253 if ((sapi_state & MG_REL) > 0) { | |
1254 | |
1255 PFREE(ll_establish_ind); | |
1256 return; | |
1257 } | |
1258 | |
1259 | |
1260 if (((sapi_state & MG_XID) > 0) | |
1261 || | |
1262 ((sapi_state & MG_EST) > 0)) { | |
1263 /* | |
1264 * Is the establishment a re-establishment? | |
1265 */ | |
1266 BOOL re = FALSE; | |
1267 | |
1268 sndcp_get_sapi_ack(ll_establish_ind->sapi, &re); | |
1269 if (re) { | |
1270 mg_col_re(ll_establish_ind); | |
1271 } else { | |
1272 mg_col_no_re(ll_establish_ind); | |
1273 } | |
1274 } else { | |
1275 /* | |
1276 * Is the establishment a re-establishment? | |
1277 */ | |
1278 BOOL re = FALSE; | |
1279 | |
1280 sndcp_get_sapi_ack(ll_establish_ind->sapi, &re); | |
1281 if (re) { | |
1282 mg_no_col_re(ll_establish_ind); | |
1283 } else { | |
1284 mg_no_col_no_re(ll_establish_ind); | |
1285 } | |
1286 } | |
1287 /* | |
1288 * Now send snsm_modify_res, if expected. | |
1289 */ | |
1290 mg_mod_res_if_nec(); | |
1291 break; | |
1292 default: | |
1293 TRACE_ERROR( "LL_ESTABLISH_IND unexpected" ); | |
1294 break; | |
1295 } | |
1296 if (ll_establish_ind != NULL) { | |
1297 PFREE(ll_establish_ind); | |
1298 } | |
1299 | |
1300 } /* mg_ll_establish_ind() */ | |
1301 | |
1302 | |
1303 | |
1304 /* | |
1305 +------------------------------------------------------------------------------ | |
1306 | Function : mg_ll_release_cnf | |
1307 +------------------------------------------------------------------------------ | |
1308 | Description : Handles the primitive LL_RELEASE_CNF | |
1309 | | |
1310 | Parameters : *ll_release_cnf - Ptr to primitive payload | |
1311 | | |
1312 +------------------------------------------------------------------------------ | |
1313 */ | |
1314 GLOBAL void mg_ll_release_cnf ( T_LL_RELEASE_CNF *ll_release_cnf ) | |
1315 { | |
1316 UBYTE nsapi = 0; | |
1317 USHORT nsapi_state = MG_IDLE; | |
1318 UBYTE sapi = 0; | |
1319 USHORT sapi_state = MG_IDLE; | |
1320 | |
1321 TRACE_FUNCTION( "mg_ll_release_cnf" ); | |
1322 | |
1323 switch( GET_STATE( MG ) ) | |
1324 { | |
1325 case MG_DEFAULT: | |
1326 /* | |
1327 * Reset all compressors at this SAPI in ack mode. | |
1328 */ | |
1329 mg_reset_comp_ack(ll_release_cnf->sapi); | |
1330 | |
1331 for (nsapi = 0; nsapi < SNDCP_NUMBER_OF_NSAPIS; nsapi++) { | |
1332 sndcp_get_nsapi_state(nsapi, &nsapi_state); | |
1333 sndcp_get_nsapi_sapi(nsapi, &sapi); | |
1334 sndcp_get_sapi_state(ll_release_cnf->sapi, &sapi_state); | |
1335 if (((sapi_state & MG_REL) > 0 ) | |
1336 && | |
1337 ((nsapi_state & MG_DEACT) > 0 ) | |
1338 && | |
1339 ((sapi_state & MG_XID) == 0 )) { | |
1340 /* | |
1341 * Release is now completed, negotiate XID or deactivate context. | |
1342 */ | |
1343 if (sapi == ll_release_cnf->sapi) { | |
1344 BOOL nec = FALSE; | |
1345 | |
1346 mg_is_rel_comp_nec(nsapi, &nec); | |
1347 if (nec) { | |
1348 sndcp_set_sapi_state(sapi, MG_XID_NEC); | |
1349 sndcp_get_sapi_state(sapi, &sapi_state); | |
1350 } else { | |
1351 #ifdef SNDCP_UPM_INCLUDED | |
1352 PALLOC(snsm_deactivate_res, SN_DEACTIVATE_CNF); | |
1353 snsm_deactivate_res->nsapi = nsapi; | |
1354 #else | |
1355 PALLOC(snsm_deactivate_res, SNSM_DEACTIVATE_RES); | |
1356 snsm_deactivate_res->nsapi = nsapi; | |
1357 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
1358 | |
1359 /* | |
1360 * Now the NSAPI is not in use anymore: | |
1361 */ | |
1362 sndcp_set_nsapi_used(nsapi, FALSE); | |
1363 sndcp_set_nsapi_ack(nsapi, FALSE); | |
1364 /* | |
1365 * Set the "state" of the nsapi. | |
1366 */ | |
1367 sndcp_unset_nsapi_state(nsapi, MG_DEACT); | |
1368 | |
1369 #ifdef SNDCP_UPM_INCLUDED | |
1370 PSEND(hCommUPM, snsm_deactivate_res); | |
1371 #else /*#ifdef SNDCP_UPM_INCLUDED*/ | |
1372 PSEND(hCommSM, snsm_deactivate_res); | |
1373 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
1374 } | |
1375 } | |
1376 } | |
1377 if (((sapi_state & MG_REL) > 0 ) | |
1378 && | |
1379 ((nsapi_state & MG_DEACT) > 0 ) | |
1380 && | |
1381 ((sapi_state & MG_XID_NEC) > 0 )) { | |
1382 /* | |
1383 * Release is now completed, | |
1384 * Remove nspi from compressor. | |
1385 */ | |
1386 /* | |
1387 * Suspend uplink transfer for affected sapi. | |
1388 */ | |
1389 sig_mg_su_suspend(sapi); | |
1390 sig_mg_sua_suspend(sapi); | |
1391 mg_suspend_affected_nus(sapi); | |
1392 /* | |
1393 * Negotiate possible deactivation of compressors. | |
1394 */ | |
1395 mg_send_xid_req_del(sapi); | |
1396 } | |
1397 } | |
1398 sndcp_set_sapi_ack(ll_release_cnf->sapi, FALSE); | |
1399 sndcp_unset_sapi_state(ll_release_cnf->sapi, MG_REL); | |
1400 break; | |
1401 default: | |
1402 TRACE_ERROR( "LL_RELEASE_CNF unexpected" ); | |
1403 break; | |
1404 } | |
1405 if (ll_release_cnf != NULL) { | |
1406 PFREE(ll_release_cnf); | |
1407 } | |
1408 | |
1409 } /* mg_ll_release_cnf() */ | |
1410 | |
1411 | |
1412 | |
1413 /* | |
1414 +------------------------------------------------------------------------------ | |
1415 | Function : mg_ll_release_ind | |
1416 +------------------------------------------------------------------------------ | |
1417 | Description : Handles the primitive LL_RELEASE_IND | |
1418 | | |
1419 | Parameters : *ll_release_ind - Ptr to primitive payload | |
1420 | | |
1421 +------------------------------------------------------------------------------ | |
1422 */ | |
1423 GLOBAL void mg_ll_release_ind ( T_LL_RELEASE_IND *ll_release_ind ) | |
1424 { | |
1425 | |
1426 USHORT sapi_state = 0; | |
1427 U8 sapi_index = 0; | |
1428 | |
1429 TRACE_FUNCTION( "mg_ll_release_ind" ); | |
1430 | |
1431 switch( GET_STATE( MG ) ) | |
1432 { | |
1433 case MG_DEFAULT: | |
1434 | |
1435 sndcp_unset_sapi_state(ll_release_ind->sapi, | |
1436 MG_REL_NEC_LOC + MG_REL_NEC_PEER); | |
1437 sndcp_get_sapi_state(ll_release_ind->sapi, &sapi_state); | |
1438 | |
1439 /* | |
1440 * Service sda may now leave state SDA_ESTABLISH_REQUESTED. | |
1441 */ | |
1442 sig_mg_sda_end_est(ll_release_ind->sapi, FALSE); | |
1443 | |
1444 #ifdef SNDCP_2to1 | |
1445 if (((sapi_state & MG_EST) > 0) && | |
1446 ((ll_release_ind->ps_cause.ctrl_value == CAUSE_is_from_llc) && | |
1447 (ll_release_ind->ps_cause.value.llc_cause == CAUSE_LLC_NO_PEER_RES))) | |
1448 #else /*SNDCP_2to1*/ | |
1449 if (((sapi_state & MG_EST) > 0) && | |
1450 (ll_release_ind->cause == LL_RELCS_NO_PEER_RES)) | |
1451 #endif /*SNDCP_2to1*/ | |
1452 { | |
1453 | |
1454 /* | |
1455 * SNDCP waits for LL_ESTABLISH_CNF and cause is "no peer response". | |
1456 * According to GSM 4.65, 6.2.1.4 a re-establishment is tried after an | |
1457 * implementation specific amount of time. | |
1458 */ | |
1459 mg_start_re_est_timer(ll_release_ind->sapi); | |
1460 PFREE(ll_release_ind); | |
1461 return; | |
1462 } | |
1463 | |
1464 sndcp_unset_sapi_state(ll_release_ind->sapi, MG_EST); | |
1465 | |
1466 | |
1467 if ((sapi_state & MG_REL) > 0) { | |
1468 | |
1469 /* | |
1470 * SNDCP waits for LL_ESTABLISH_CNF and cause is "no peer response". | |
1471 * According to GSM 4.65, 6.2.1.4 a re-establishment is tried after an | |
1472 * implementation specific amount of time. | |
1473 */ | |
1474 PALLOC (ll_release_cnf, LL_RELEASE_CNF); | |
1475 ll_release_cnf->sapi = ll_release_ind->sapi; | |
1476 mg_ll_release_cnf(ll_release_cnf); | |
1477 PFREE(ll_release_ind); | |
1478 return; | |
1479 } | |
1480 | |
1481 /* | |
1482 * Reset all compressors at this SAPI in ack mode. | |
1483 */ | |
1484 mg_reset_comp_ack(ll_release_ind->sapi); | |
1485 /* | |
1486 * If release has been expected in course of modification, here it is. | |
1487 */ | |
1488 if ((sndcp_data->mg.mod_expects & MG_MOD_X_REL) > 0) { | |
1489 sndcp_data->mg.mod_expects -= MG_MOD_X_REL; | |
1490 } | |
1491 mg_del_comp_pdus_ack(ll_release_ind->sapi); | |
1492 sig_mg_su_resume(ll_release_ind->sapi); | |
1493 sig_mg_sua_resume(ll_release_ind->sapi); | |
1494 mg_resume_affected_nus(ll_release_ind->sapi); | |
1495 #ifdef SNDCP_2to1 | |
1496 if (((ll_release_ind->ps_cause.ctrl_value == CAUSE_is_from_llc)&& | |
1497 (ll_release_ind->ps_cause.value.llc_cause == CAUSE_LLC_DM_RECEIVED)) || | |
1498 ((ll_release_ind->ps_cause.ctrl_value == CAUSE_is_from_llc)&& | |
1499 (ll_release_ind->ps_cause.value.llc_cause == CAUSE_LLC_INVALID_XID)) || | |
1500 ((ll_release_ind->ps_cause.ctrl_value == CAUSE_is_from_llc)&& | |
1501 (ll_release_ind->ps_cause.value.llc_cause == CAUSE_LLC_NO_PEER_RES))) { | |
1502 #else /*SNDCP_2to1*/ | |
1503 if (ll_release_ind->cause == LL_RELCS_DM_RECEIVED || | |
1504 ll_release_ind->cause == LL_RELCS_INVALID_XID || | |
1505 ll_release_ind->cause == LL_RELCS_NO_PEER_RES) { | |
1506 #endif /*SNDCP_2to1*/ | |
1507 | |
1508 #ifdef SNDCP_UPM_INCLUDED | |
1509 PALLOC (snsm_status_req, SN_STATUS_IND); | |
1510 #ifdef SNDCP_2to1 | |
1511 if((ll_release_ind->ps_cause.ctrl_value == CAUSE_is_from_llc)&& | |
1512 (ll_release_ind->ps_cause.value.llc_cause == CAUSE_LLC_DM_RECEIVED)){ | |
1513 #else | |
1514 if (ll_release_ind->cause == LL_RELCS_DM_RECEIVED){ | |
1515 #endif | |
1516 UBYTE nsapi, sapi = 0; | |
1517 USHORT nsapi_set = 0; | |
1518 for (nsapi = 0; nsapi < SNDCP_NUMBER_OF_NSAPIS; nsapi++){ | |
1519 sndcp_get_nsapi_sapi(nsapi, &sapi); | |
1520 if(sapi == ll_release_ind->sapi){ | |
1521 BOOL ack = FALSE; | |
1522 sndcp_get_nsapi_ack(nsapi, &ack); | |
1523 if(ack){ | |
1524 nsapi_set |= (1 << nsapi); | |
1525 } | |
1526 } | |
1527 } | |
1528 snsm_status_req->nsapi_set = nsapi_set; | |
1529 } | |
1530 snsm_status_req->sapi = ll_release_ind->sapi; | |
1531 snsm_status_req->ps_cause.ctrl_value = CAUSE_is_from_llc; | |
1532 snsm_status_req->ps_cause.value.llc_cause = | |
1533 #ifdef SNDCP_2to1 | |
1534 mg_ll_release_to_snsm_status(ll_release_ind->ps_cause.value.llc_cause); | |
1535 #else /*SNDCP_2to1*/ | |
1536 mg_ll_release_to_snsm_status(ll_release_ind->cause); | |
1537 #endif /*SNDCP_2to1*/ | |
1538 PSEND(hCommUPM, snsm_status_req); | |
1539 #else /* SNDCP_UPM_INCLUDED */ | |
1540 PALLOC (snsm_status_req, SNSM_STATUS_REQ); | |
1541 snsm_status_req->sapi = ll_release_ind->sapi; | |
1542 snsm_status_req->status_cause = | |
1543 #ifdef _SNDCP_DTI_2_ | |
1544 mg_ll_release_to_snsm_status(ll_release_ind->cause); | |
1545 #else /* _SNDCP_DTI_2_ */ | |
1546 (U8)mg_ll_release_to_snsm_status(ll_release_ind->cause); | |
1547 #endif /* _SNDCP_DTI_2_ */ | |
1548 | |
1549 PSEND(hCommSM, snsm_status_req); | |
1550 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
1551 | |
1552 | |
1553 } | |
1554 sndcp_set_sapi_ack(ll_release_ind->sapi, FALSE); | |
1555 | |
1556 /* | |
1557 * Now send snsm_modify_res, if expected. | |
1558 */ | |
1559 mg_mod_res_if_nec(); | |
1560 break; | |
1561 default: | |
1562 TRACE_ERROR( "LL_RELEASE_IND unexpected" ); | |
1563 break; | |
1564 } | |
1565 /* | |
1566 * Establish confirm has been computed. If no new XID is pending, | |
1567 * the req_xid_block may be reset. | |
1568 */ | |
1569 sndcp_get_sapi_index(ll_release_ind->sapi, &sapi_index); | |
1570 sndcp_get_sapi_state(ll_release_ind->sapi, &sapi_state); | |
1571 if (((sapi_state & MG_XID) == 0) && | |
1572 ((sapi_state & MG_EST) == 0)) { | |
1573 sndcp_reset_xid_block(&sndcp_data->mg.req_xid_block[sapi_index]); | |
1574 } | |
1575 | |
1576 if (ll_release_ind != NULL) { | |
1577 PFREE(ll_release_ind); | |
1578 } | |
1579 | |
1580 } /* mg_ll_release_ind() */ | |
1581 | |
1582 | |
1583 | |
1584 /* | |
1585 +------------------------------------------------------------------------------ | |
1586 | Function : mg_ll_xid_cnf | |
1587 +------------------------------------------------------------------------------ | |
1588 | Description : Handles the primitive LL_XID_CNF | |
1589 | | |
1590 | Parameters : *ll_xid_cnf - Ptr to primitive payload | |
1591 | | |
1592 +------------------------------------------------------------------------------ | |
1593 */ | |
1594 GLOBAL void mg_ll_xid_cnf ( T_LL_XID_CNF* ll_xid_cnf ) | |
1595 { | |
1596 UBYTE dec_ret = 0; | |
1597 UBYTE check_ret = 0; | |
1598 UBYTE sapi_index = 0; | |
1599 | |
1600 TRACE_FUNCTION( "mg_ll_xid_cnf" ); | |
1601 | |
1602 sndcp_get_sapi_index(ll_xid_cnf->sapi, &sapi_index); | |
1603 | |
1604 #ifdef SNDCP_TRACE_ALL | |
1605 TRACE_EVENT("incoming xid block:"); | |
1606 sndcp_trace_sdu(&ll_xid_cnf->sdu); | |
1607 #endif | |
1608 | |
1609 switch( GET_STATE( MG ) ) | |
1610 { | |
1611 case MG_DEFAULT: | |
1612 | |
1613 sndcp_unset_sapi_state(ll_xid_cnf->sapi, MG_XID); | |
1614 | |
1615 mg_decode_xid(&(ll_xid_cnf->sdu), | |
1616 &(sndcp_data->mg.cnf_xid_block[sapi_index]), | |
1617 &dec_ret, | |
1618 ll_xid_cnf->sapi); | |
1619 if (dec_ret == MG_XID_OK) { | |
1620 mg_check_cnf_xid(&check_ret, ll_xid_cnf->sapi); | |
1621 if (check_ret == MG_XID_OK) { | |
1622 USHORT sapi_state = MG_IDLE; | |
1623 | |
1624 /* | |
1625 * SDL Label MG_CNF_OK | |
1626 */ | |
1627 mg_set_cur_xid_block(ll_xid_cnf->sapi); | |
1628 mg_xid_cnf_ok_res(ll_xid_cnf->sapi); | |
1629 /* | |
1630 * Reset nsapis or ntts that were assigned, but are not any more. | |
1631 */ | |
1632 mg_clean_xid(ll_xid_cnf->sapi), | |
1633 /* | |
1634 * Set n201. | |
1635 */ | |
1636 sig_mg_su_n201 (ll_xid_cnf->sapi, ll_xid_cnf->n201_u); | |
1637 sig_mg_sua_n201 (ll_xid_cnf->sapi, ll_xid_cnf->n201_i); | |
1638 | |
1639 /* | |
1640 * Resume suspended data transfer on sapi. | |
1641 */ | |
1642 | |
1643 sndcp_get_sapi_state(ll_xid_cnf->sapi, &sapi_state); | |
1644 if (((sapi_state & MG_XID) == 0) | |
1645 && | |
1646 ((sapi_state & MG_EST) == 0)) { | |
1647 | |
1648 sig_mg_su_resume(ll_xid_cnf->sapi); | |
1649 sig_mg_sua_resume(ll_xid_cnf->sapi); | |
1650 mg_resume_affected_nus(ll_xid_cnf->sapi); | |
1651 } | |
1652 | |
1653 /* | |
1654 * Now get downlink data. | |
1655 */ | |
1656 | |
1657 mg_get_downlink_data(ll_xid_cnf->sapi); | |
1658 | |
1659 /* | |
1660 * XID confirm has been computed. The negotiation is finished and | |
1661 * the req_xid_block may be reset. | |
1662 */ | |
1663 sndcp_get_sapi_state(ll_xid_cnf->sapi, &sapi_state); | |
1664 if (((sapi_state & MG_XID) == 0) && | |
1665 ((sapi_state & MG_EST) == 0)) { | |
1666 sndcp_reset_xid_block(&sndcp_data->mg.req_xid_block[sapi_index]); | |
1667 } | |
1668 } else { | |
1669 mg_re_negotiate(ll_xid_cnf->sapi); | |
1670 } | |
1671 } else { | |
1672 mg_re_negotiate(ll_xid_cnf->sapi); | |
1673 } | |
1674 break; | |
1675 default: | |
1676 TRACE_ERROR( "LL_XID_CNF unexpected" ); | |
1677 break; | |
1678 } | |
1679 if (ll_xid_cnf != NULL) { | |
1680 PFREE(ll_xid_cnf); | |
1681 sndcp_reset_xid_block(&sndcp_data->mg.cnf_xid_block[sapi_index]); | |
1682 } | |
1683 | |
1684 } /* mg_ll_xid_cnf() */ | |
1685 | |
1686 | |
1687 | |
1688 /* | |
1689 +------------------------------------------------------------------------------ | |
1690 | Function : mg_ll_xid_ind | |
1691 +------------------------------------------------------------------------------ | |
1692 | Description : Handles the primitive LL_XID_IND | |
1693 | | |
1694 | Parameters : *ll_xid_ind - Ptr to primitive payload | |
1695 | | |
1696 +------------------------------------------------------------------------------ | |
1697 */ | |
1698 GLOBAL void mg_ll_xid_ind ( T_LL_XID_IND *ll_xid_ind ) | |
1699 { | |
1700 UBYTE dec_ret = 0; | |
1701 UBYTE check_ret = 0; | |
1702 UBYTE sapi_index = 0; | |
1703 | |
1704 TRACE_FUNCTION( "mg_ll_xid_ind" ); | |
1705 | |
1706 sndcp_get_sapi_index(ll_xid_ind->sapi, &sapi_index); | |
1707 | |
1708 switch( GET_STATE( MG ) ) | |
1709 { | |
1710 case MG_DEFAULT: | |
1711 | |
1712 /* | |
1713 * Set N201 values in uplink services. | |
1714 */ | |
1715 sig_mg_su_n201(ll_xid_ind->sapi, ll_xid_ind->n201_u); | |
1716 sig_mg_sua_n201(ll_xid_ind->sapi, ll_xid_ind->n201_i); | |
1717 | |
1718 TRACE_EVENT_P3("l3_valid: %d, N201_I: %d, N201_U: %d", | |
1719 ll_xid_ind->xid_valid, ll_xid_ind->n201_i, | |
1720 ll_xid_ind->n201_i); | |
1721 | |
1722 /* | |
1723 * If SNDCP XID block is not valid, we are ready. | |
1724 */ | |
1725 if (ll_xid_ind->xid_valid == LL_XID_INVALID) { | |
1726 break; | |
1727 } | |
1728 /* | |
1729 * SNDCP XID block is valid and checked now. | |
1730 */ | |
1731 mg_decode_xid(&(ll_xid_ind->sdu), | |
1732 &(sndcp_data->mg.ind_xid_block[sapi_index]), | |
1733 &dec_ret, | |
1734 ll_xid_ind->sapi); | |
1735 if (dec_ret == MG_XID_OK) { | |
1736 mg_check_ind_xid(&check_ret, ll_xid_ind->sapi); | |
1737 if (check_ret == MG_XID_OK) { | |
1738 /* | |
1739 * Label MG_IND_OK | |
1740 */ | |
1741 USHORT res_sdu_bit_len = 0; | |
1742 UBYTE ntt = 0; | |
1743 BOOL v42_rej = FALSE; | |
1744 BOOL vj_rej = FALSE; | |
1745 USHORT sapi_state = MG_IDLE; | |
1746 | |
1747 mg_set_res_cur_xid_block(ll_xid_ind->sapi, &res_sdu_bit_len); | |
1748 | |
1749 /* | |
1750 * Add the extra space for ntts with nsapis == 0. | |
1751 */ | |
1752 for (ntt = 0; ntt < MG_MAX_ENTITIES; ntt++) { | |
1753 BOOL rej = FALSE; | |
1754 | |
1755 mg_get_sapi_dntt_rej(ll_xid_ind->sapi, ntt, &rej); | |
1756 if (rej) { | |
1757 /* | |
1758 * length of ntt octet and nsapis. | |
1759 */ | |
1760 res_sdu_bit_len += 32; | |
1761 v42_rej = TRUE; | |
1762 } | |
1763 mg_get_sapi_pntt_rej(ll_xid_ind->sapi, ntt, &rej); | |
1764 if (rej) { | |
1765 /* | |
1766 * length of ntt octet and nsapis. | |
1767 */ | |
1768 res_sdu_bit_len += 32; | |
1769 vj_rej = TRUE; | |
1770 } | |
1771 } | |
1772 if (! sndcp_data->mg.ind_xid_block[sapi_index].v42.is_set && | |
1773 v42_rej) { | |
1774 /* | |
1775 * Add length of parameter type and length. | |
1776 */ | |
1777 res_sdu_bit_len += 16; | |
1778 } | |
1779 if (! sndcp_data->mg.ind_xid_block[sapi_index].vj.is_set && | |
1780 vj_rej) { | |
1781 /* | |
1782 * Add length of parameter type and length. | |
1783 */ | |
1784 res_sdu_bit_len += 16; | |
1785 } | |
1786 | |
1787 { | |
1788 PALLOC_SDU (ll_xid_res, LL_XID_RES, res_sdu_bit_len); | |
1789 | |
1790 /* | |
1791 * Set sapi in ll_xid_res. | |
1792 */ | |
1793 ll_xid_res->sapi = ll_xid_ind->sapi; | |
1794 /* | |
1795 * Write res_xid_block struct to sdu byte buffer. Implementation dep.. | |
1796 */ | |
1797 mg_set_res_xid_params(&ll_xid_res->sdu, ll_xid_ind->sapi); | |
1798 /* | |
1799 * Mark the affected nsapi and sapi as MG_XID_IDLE. | |
1800 */ | |
1801 sndcp_unset_sapi_state(ll_xid_ind->sapi, MG_XID); | |
1802 sndcp_unset_sapi_state(ll_xid_ind->sapi, MG_EST); | |
1803 | |
1804 /* | |
1805 * Send the XID block to LLC. | |
1806 */ | |
1807 | |
1808 #ifdef SNDCP_RANGE_CHECK | |
1809 | |
1810 if(ll_xid_res EQ NULL) | |
1811 { | |
1812 TRACE_EVENT("ERROR: ll_xid_res is NULL"); | |
1813 } | |
1814 else if(*((ULONG*)ll_xid_res - 7) NEQ 0) | |
1815 { | |
1816 TRACE_EVENT("ERROR in SNDCP: ll_xid_res is not allocated"); | |
1817 } | |
1818 | |
1819 #endif /* SNDCP_RANGE_CHECK */ | |
1820 | |
1821 PSEND(hCommLLC, ll_xid_res); | |
1822 } | |
1823 | |
1824 /* | |
1825 * Reset nsapis or ntts that were assigned, but are not any more. | |
1826 */ | |
1827 mg_clean_xid(ll_xid_ind->sapi); | |
1828 | |
1829 /* | |
1830 * If there was a collision and xid has not been negotiated | |
1831 * sufficiently. | |
1832 */ | |
1833 mg_resend_xid_if_nec(ll_xid_ind->sapi); | |
1834 /* | |
1835 * If activation or deactivation is pending, it will be responded if | |
1836 * no xid_req is pending. | |
1837 */ | |
1838 sndcp_get_sapi_state(ll_xid_ind->sapi, &sapi_state); | |
1839 if ((sapi_state & MG_XID) == 0) { | |
1840 mg_xid_cnf_ok_res(ll_xid_ind->sapi); | |
1841 } | |
1842 | |
1843 | |
1844 } else { | |
1845 /* | |
1846 * not (check_ret == MG_IND_XID_OK) | |
1847 */ | |
1848 /* | |
1849 * Label MG_CHECK_FAIL | |
1850 */ | |
1851 USHORT res_sdu_bit_len = 0; | |
1852 UBYTE ntt = 0; | |
1853 BOOL v42_rej = FALSE; | |
1854 BOOL vj_rej = FALSE; | |
1855 | |
1856 /* | |
1857 * Add the extra space for ntts with nsapis == 0. | |
1858 */ | |
1859 for (ntt = 0; ntt < MG_MAX_ENTITIES; ntt++) { | |
1860 BOOL rej = FALSE; | |
1861 | |
1862 mg_get_sapi_dntt_rej(ll_xid_ind->sapi, ntt, &rej); | |
1863 if (rej) { | |
1864 /* | |
1865 * length of ntt octet and nsapis. | |
1866 */ | |
1867 res_sdu_bit_len += 32; | |
1868 v42_rej = TRUE; | |
1869 } | |
1870 mg_get_sapi_pntt_rej(ll_xid_ind->sapi, ntt, &rej); | |
1871 if (rej) { | |
1872 /* | |
1873 * length of ntt octet and nsapis. | |
1874 */ | |
1875 res_sdu_bit_len += 32; | |
1876 vj_rej = TRUE; | |
1877 } | |
1878 } | |
1879 if (v42_rej) { | |
1880 /* | |
1881 * Add length of parameter type and length. | |
1882 */ | |
1883 res_sdu_bit_len += 16; | |
1884 } | |
1885 if (vj_rej) { | |
1886 /* | |
1887 * Add length of parameter type and length. | |
1888 */ | |
1889 res_sdu_bit_len += 16; | |
1890 } | |
1891 /* | |
1892 * Allocate response and send it. | |
1893 */ | |
1894 { | |
1895 PALLOC_SDU (ll_xid_res, LL_XID_RES, res_sdu_bit_len); | |
1896 | |
1897 /* | |
1898 * Reset res_xid_block, ind_xid_block. | |
1899 */ | |
1900 sndcp_reset_xid_block(&sndcp_data->mg.res_xid_block[sapi_index]); | |
1901 sndcp_reset_xid_block(&sndcp_data->mg.ind_xid_block[sapi_index]); | |
1902 /* | |
1903 * Set sapi in ll_xid_res. | |
1904 */ | |
1905 ll_xid_res->sapi = ll_xid_ind->sapi; | |
1906 /* | |
1907 * Write res_xid_block struct to sdu byte buffer. Implementation dep.. | |
1908 */ | |
1909 mg_set_res_xid_params(&ll_xid_res->sdu, ll_xid_res->sapi); | |
1910 /* | |
1911 * Modify the affected sapi state. | |
1912 */ | |
1913 sndcp_unset_sapi_state(ll_xid_ind->sapi, MG_XID); | |
1914 sndcp_unset_sapi_state(ll_xid_ind->sapi, MG_EST); | |
1915 | |
1916 /* | |
1917 * Send the XID block to LLC. | |
1918 */ | |
1919 | |
1920 #ifdef SNDCP_RANGE_CHECK | |
1921 | |
1922 if(ll_xid_res EQ NULL) | |
1923 { | |
1924 TRACE_EVENT("ERROR: ll_xid_res is NULL"); | |
1925 } | |
1926 else if(*((ULONG*)ll_xid_res - 7) NEQ 0) | |
1927 { | |
1928 TRACE_EVENT("ERROR in SNDCP: ll_xid_res is not allocated"); | |
1929 } | |
1930 | |
1931 #endif /* SNDCP_RANGE_CHECK */ | |
1932 | |
1933 PSEND(hCommLLC, ll_xid_res); | |
1934 } | |
1935 /* | |
1936 * If there was a collision and xid has not been negotiated | |
1937 * sufficiently. | |
1938 */ | |
1939 mg_resend_xid_if_nec(ll_xid_ind->sapi); | |
1940 | |
1941 /* | |
1942 * Reset nsapis or ntts that were assigned before | |
1943 * but are not anymore. | |
1944 */ | |
1945 mg_clean_xid(ll_xid_ind->sapi); | |
1946 /* | |
1947 * Allocate status req and send it (label MG_SEND_STATUS_REQ). | |
1948 */ | |
1949 { | |
1950 #ifdef SNDCP_UPM_INCLUDED | |
1951 PALLOC (snsm_status_req, SN_STATUS_IND); | |
1952 snsm_status_req->sapi = ll_xid_ind->sapi; | |
1953 snsm_status_req->ps_cause.ctrl_value = CAUSE_is_from_sndcp; | |
1954 snsm_status_req->ps_cause.value.sn_cause = CAUSE_SN_INVALID_XID; | |
1955 PSEND(hCommUPM, snsm_status_req); | |
1956 #else | |
1957 PALLOC (snsm_status_req, SNSM_STATUS_REQ); | |
1958 snsm_status_req->sapi = ll_xid_ind->sapi; | |
1959 snsm_status_req->status_cause = SNSM_RELCS_INVALID_XID; | |
1960 PSEND(hCommSM, snsm_status_req); | |
1961 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
1962 | |
1963 } | |
1964 } | |
1965 } else { /* not if (dec_ret == MG_XID_OK) */ | |
1966 /* | |
1967 * Reset nsapis or ntts that were assigned before | |
1968 * but are not anymore. | |
1969 */ | |
1970 sndcp_reset_xid_block(&sndcp_data->mg.cur_xid_block[sapi_index]); | |
1971 mg_clean_xid(ll_xid_ind->sapi); | |
1972 /* | |
1973 * Decoding of LL_XID_IND failed (label MG_SEND_STATUS_REQ). | |
1974 * Allocate status req and send it. | |
1975 */ | |
1976 { | |
1977 #ifdef SNDCP_UPM_INCLUDED | |
1978 PALLOC (snsm_status_req, SN_STATUS_IND); | |
1979 snsm_status_req->sapi = ll_xid_ind->sapi; | |
1980 snsm_status_req->ps_cause.ctrl_value = CAUSE_is_from_sndcp; | |
1981 snsm_status_req->ps_cause.value.sn_cause = CAUSE_SN_INVALID_XID; | |
1982 PSEND(hCommUPM, snsm_status_req); | |
1983 #else | |
1984 PALLOC (snsm_status_req, SNSM_STATUS_REQ); | |
1985 snsm_status_req->sapi = ll_xid_ind->sapi; | |
1986 snsm_status_req->status_cause = SNSM_RELCS_INVALID_XID; | |
1987 PSEND(hCommSM, snsm_status_req); | |
1988 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
1989 | |
1990 } | |
1991 | |
1992 } | |
1993 break; | |
1994 default: | |
1995 TRACE_ERROR( "LL_XID_IND unexpected" ); | |
1996 break; | |
1997 } | |
1998 if (ll_xid_ind != NULL) { | |
1999 sndcp_reset_xid_block(&sndcp_data->mg.ind_xid_block[sapi_index]); | |
2000 PFREE(ll_xid_ind); | |
2001 } | |
2002 } /* mg_ll_xid_ind() */ | |
2003 | |
2004 | |
2005 | |
2006 /* | |
2007 +------------------------------------------------------------------------------ | |
2008 | Function : mg_snsm_activate_ind | |
2009 +------------------------------------------------------------------------------ | |
2010 | Description : Handles the primitive SNSM_ACTIVATE_IND | |
2011 | | |
2012 | Parameters : *snsm_activate_ind - Ptr to primitive payload | |
2013 | | |
2014 +------------------------------------------------------------------------------ | |
2015 */ | |
2016 #ifdef SNDCP_UPM_INCLUDED | |
2017 GLOBAL void mg_snsm_activate_ind ( T_SN_ACTIVATE_REQ *snsm_activate_ind ) | |
2018 #else | |
2019 GLOBAL void mg_snsm_activate_ind ( T_SNSM_ACTIVATE_IND *snsm_activate_ind ) | |
2020 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
2021 { | |
2022 /* | |
2023 * is nsapi already used? | |
2024 */ | |
2025 BOOL used = FALSE; | |
2026 /* | |
2027 * is LLC mode specified (TRUE) or should the subscribed one be used | |
2028 * (FALSE) | |
2029 */ | |
2030 BOOL spec = FALSE; | |
2031 /* | |
2032 * should the context use acknowledged LLC operation mode? | |
2033 */ | |
2034 BOOL b = FALSE; | |
2035 | |
2036 TRACE_FUNCTION( "mg_snsm_activate_ind" ); | |
2037 | |
2038 #ifndef NCONFIG | |
2039 if (sndcp_data->millis > 0) { | |
2040 vsi_t_sleep(VSI_CALLER sndcp_data->millis); | |
2041 } | |
2042 #endif /* NCONFIG */ | |
2043 | |
2044 switch( GET_STATE( MG ) ) | |
2045 { | |
2046 case MG_DEFAULT: | |
2047 sndcp_is_nsapi_used(snsm_activate_ind->nsapi, &used); | |
2048 if (used == FALSE) { | |
2049 | |
2050 USHORT sapi_state = MG_IDLE; | |
2051 | |
2052 sndcp_set_nsapi_state(snsm_activate_ind->nsapi, MG_ACT); | |
2053 sndcp_reset_nd_nsapi_npdu_num(snsm_activate_ind->nsapi); | |
2054 sndcp_set_nsapi_used(snsm_activate_ind->nsapi, TRUE); | |
2055 sndcp_set_nsapi_qos(snsm_activate_ind->nsapi, | |
2056 snsm_activate_ind->snsm_qos); | |
2057 sndcp_set_nsapi_sapi(snsm_activate_ind->nsapi, | |
2058 snsm_activate_ind->sapi); | |
2059 sndcp_set_nsapi_prio(snsm_activate_ind->nsapi, | |
2060 snsm_activate_ind->radio_prio); | |
2061 #ifdef REL99 | |
2062 sndcp_set_nsapi_pktflowid(snsm_activate_ind->nsapi, | |
2063 snsm_activate_ind->pkt_flow_id); | |
2064 #endif /*REL 99*/ | |
2065 | |
2066 #if 0 | |
2067 #ifdef _SNDCP_DTI_2_ | |
2068 #ifndef SNDCP_UPM_INCLUDED | |
2069 if (snsm_activate_ind->dti_direction == DTI_CHANNEL_TO_LOWER_LAYER) { | |
2070 /* new constant instead of SNSM HOME , replaced by DTI_CHANNEL_TO_LOWER_LAYER */ | |
2071 sndcp_set_nsapi_direction(snsm_activate_ind->nsapi, DTI_CHANNEL_TO_LOWER_LAYER); | |
2072 } else { | |
2073 sndcp_set_nsapi_direction(snsm_activate_ind->nsapi, DTI_CHANNEL_TO_HIGHER_LAYER); | |
2074 } | |
2075 | |
2076 sndcp_set_nsapi_linkid(snsm_activate_ind->nsapi, | |
2077 snsm_activate_ind->dti_linkid); | |
2078 | |
2079 sndcp_set_nsapi_neighbor(snsm_activate_ind->nsapi, | |
2080 #ifdef _SIMULATION_ | |
2081 (snsm_activate_ind->dti_neighbor == | |
2082 0xabcdabcd | |
2083 ? | |
2084 "PPP" | |
2085 : | |
2086 "NULL") | |
2087 #else /* _SIMULATION_ */ | |
2088 (U8*)snsm_activate_ind->dti_neighbor | |
2089 #endif /* _SIMULATION_ */ | |
2090 ); | |
2091 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
2092 | |
2093 #else /*_SNDCP_DTI_2_*/ | |
2094 if (snsm_activate_ind->dti_direction == SNSM_HOME) { | |
2095 /* new constant instead of HOME, but the comiler switch! */ | |
2096 sndcp_set_nsapi_direction(snsm_activate_ind->nsapi, HOME); | |
2097 } else { | |
2098 sndcp_set_nsapi_direction(snsm_activate_ind->nsapi, NEIGHBOR); | |
2099 } | |
2100 sndcp_set_nsapi_linkid(snsm_activate_ind->nsapi, | |
2101 snsm_activate_ind->dti_linkid); | |
2102 sndcp_set_nsapi_neighbor(snsm_activate_ind->nsapi, | |
2103 #ifdef _SIMULATION_ | |
2104 (snsm_activate_ind->dti_neighbor == | |
2105 0xabcdabcd | |
2106 ? | |
2107 "PPP" | |
2108 : | |
2109 "NULL") | |
2110 #else | |
2111 (U8*)snsm_activate_ind->dti_neighbor | |
2112 #endif /* _SIMULATION_ */ | |
2113 ); | |
2114 #endif /*_SNDCP_DTI_2_*/ | |
2115 #endif | |
2116 mg_is_ack(snsm_activate_ind->snsm_qos, &spec, &b); | |
2117 if (spec) { | |
2118 if (b) { | |
2119 /* | |
2120 * The NSAPI will use acknowledged LLC operation mode. | |
2121 */ | |
2122 | |
2123 BOOL ack = FALSE; | |
2124 USHORT local_sapi_state = MG_IDLE; | |
2125 BOOL comp_available = FALSE; | |
2126 | |
2127 /* | |
2128 * Is another compressor available? | |
2129 */ | |
2130 #ifdef SNDCP_UPM_INCLUDED | |
2131 mg_is_comp_available(snsm_activate_ind->sapi, | |
2132 TRUE, | |
2133 SNDCP_ACK, | |
2134 snsm_activate_ind->comp_params.msid, | |
2135 &comp_available); | |
2136 #else | |
2137 mg_is_comp_available(snsm_activate_ind->sapi, | |
2138 TRUE, | |
2139 SNDCP_ACK, | |
2140 snsm_activate_ind->msid, | |
2141 &comp_available); | |
2142 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
2143 | |
2144 sndcp_set_nsapi_ack(snsm_activate_ind->nsapi, TRUE); | |
2145 /* | |
2146 * Is the affected SAPI already in ack mode or est_pending?? | |
2147 */ | |
2148 sndcp_get_sapi_ack(snsm_activate_ind->sapi, &ack); | |
2149 sndcp_get_sapi_state(snsm_activate_ind->sapi, &local_sapi_state); | |
2150 | |
2151 if ((((local_sapi_state & MG_EST) > 0) | |
2152 || | |
2153 ((local_sapi_state & MG_XID) > 0)) | |
2154 && | |
2155 comp_available) | |
2156 { | |
2157 sndcp_set_sapi_state(snsm_activate_ind->sapi, MG_XID_NEC); | |
2158 mg_set_new_xid_block(snsm_activate_ind); | |
2159 | |
2160 } else if (ack) { | |
2161 | |
2162 /* check if flow control is received before PDP activation */ | |
2163 mg_check_unset_nsapi_flow_ctrl_flag (snsm_activate_ind->nsapi,SNDCP_ACK); | |
2164 /* | |
2165 * If XID negotiation is not requested, respond | |
2166 * activation to SM, else send LL_XID_REQ. | |
2167 */ | |
2168 #ifdef SNDCP_UPM_INCLUDED | |
2169 if ((snsm_activate_ind->comp_params.dcomp == NAS_DCOMP_OFF && | |
2170 snsm_activate_ind->comp_params.hcomp == NAS_HCOMP_OFF) || | |
2171 ! comp_available) { | |
2172 #else | |
2173 if ((snsm_activate_ind->dcomp == SNSM_COMP_NEITHER_DIRECT && | |
2174 snsm_activate_ind->hcomp == SNSM_COMP_NEITHER_DIRECT) || | |
2175 ! comp_available) { | |
2176 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
2177 | |
2178 /* | |
2179 * If est_pending, the res is sent after est_cnf. | |
2180 */ | |
2181 | |
2182 /* | |
2183 * Reset service nu to acknowledged LLC mode. | |
2184 */ | |
2185 sig_mg_nu_reset_ack(snsm_activate_ind->nsapi, 0, 0, FALSE); | |
2186 /* | |
2187 * Open DTI connection. | |
2188 */ | |
2189 #ifndef SNDCP_UPM_INCLUDED | |
2190 mg_dti_open(snsm_activate_ind->nsapi); | |
2191 #else | |
2192 nu_ready_ind_if_nec(snsm_activate_ind->nsapi); | |
2193 #endif | |
2194 | |
2195 /* | |
2196 * | |
2197 */ | |
2198 sig_mg_sda_getdata(snsm_activate_ind->sapi, snsm_activate_ind->nsapi); | |
2199 /* | |
2200 * Send response | |
2201 */ | |
2202 mg_send_snsm_activate_res(snsm_activate_ind->nsapi); | |
2203 | |
2204 /* | |
2205 * unsetting the ACT-state | |
2206 */ | |
2207 sndcp_unset_nsapi_state(snsm_activate_ind->nsapi, MG_ACT); | |
2208 | |
2209 } else { /* if XID negotiation necessary */ | |
2210 USHORT punct_sapi_state = MG_IDLE; | |
2211 | |
2212 /* | |
2213 * Increment number of requested compressors. | |
2214 */ | |
2215 sndcp_data->vj_count++; | |
2216 /* | |
2217 * Set the N-PDU number in the affected nu instance to 0. | |
2218 */ | |
2219 sig_mg_nu_reset_ack(snsm_activate_ind->nsapi, 0, 0, TRUE); | |
2220 /* | |
2221 * Uplink data transfer on SAPI is completely suspended. | |
2222 */ | |
2223 sig_mg_su_suspend(snsm_activate_ind->sapi); | |
2224 sig_mg_sua_suspend(snsm_activate_ind->sapi); | |
2225 mg_suspend_affected_nus(snsm_activate_ind->sapi); | |
2226 /* | |
2227 * Send prim or store requested compression. | |
2228 */ | |
2229 sndcp_get_sapi_state(snsm_activate_ind->sapi, | |
2230 &punct_sapi_state); | |
2231 mg_send_xid_req(snsm_activate_ind); | |
2232 | |
2233 } /* if XID negotiation necessary */ | |
2234 } else { | |
2235 /* | |
2236 * Is XID negotiation necessary? | |
2237 */ | |
2238 #ifdef SNDCP_UPM_INCLUDED | |
2239 if ((snsm_activate_ind->comp_params.dcomp == NAS_DCOMP_OFF && | |
2240 snsm_activate_ind->comp_params.hcomp == NAS_HCOMP_OFF) || | |
2241 sndcp_data->vj_count == SNDCP_MAX_VJ_COUNT) | |
2242 #else | |
2243 if ((snsm_activate_ind->dcomp == SNSM_COMP_NEITHER_DIRECT && | |
2244 snsm_activate_ind->hcomp == SNSM_COMP_NEITHER_DIRECT) || | |
2245 sndcp_data->vj_count == SNDCP_MAX_VJ_COUNT) | |
2246 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
2247 { | |
2248 /* | |
2249 * Ack mode, sapi not yet established. | |
2250 * No XID requested. | |
2251 */ | |
2252 PALLOC_SDU(ll_establish_req, LL_ESTABLISH_REQ, 0); | |
2253 | |
2254 /* | |
2255 * Reset service nu to acknowledged LLC mode. | |
2256 */ | |
2257 sig_mg_nu_reset_ack(snsm_activate_ind->nsapi, 0, 0, TRUE); | |
2258 | |
2259 ll_establish_req->sapi = snsm_activate_ind->sapi; | |
2260 /* | |
2261 * Set the establishment states of sapi | |
2262 */ | |
2263 sndcp_set_sapi_state(snsm_activate_ind->sapi, MG_EST); | |
2264 /* | |
2265 * Uplink data transfer on SAPI is completely suspended. | |
2266 */ | |
2267 sig_mg_su_suspend(snsm_activate_ind->sapi); | |
2268 sig_mg_sua_suspend(snsm_activate_ind->sapi); | |
2269 mg_suspend_affected_nus(snsm_activate_ind->sapi); | |
2270 | |
2271 /* | |
2272 * Send prim to LLC. | |
2273 */ | |
2274 sndcp_set_nsapi_rec_state(snsm_activate_ind->nsapi, SDA_ESTABLISH_REQUESTED); | |
2275 | |
2276 #ifdef SNDCP_RANGE_CHECK | |
2277 | |
2278 if(ll_establish_req EQ NULL) | |
2279 { | |
2280 TRACE_EVENT("ERROR: ll_establish_req is NULL"); | |
2281 } | |
2282 else if(*((ULONG*)ll_establish_req - 7) NEQ 0) | |
2283 { | |
2284 TRACE_EVENT | |
2285 ("ERROR in SNDCP: ll_establish_req is not allocated"); | |
2286 } | |
2287 | |
2288 #endif /* SNDCP_RANGE_CHECK */ | |
2289 | |
2290 PSEND(hCommLLC, ll_establish_req); | |
2291 } else { | |
2292 | |
2293 UBYTE sapi_index = 0; | |
2294 | |
2295 /* | |
2296 * Ack mode, sapi not yet established. | |
2297 * XID requested. | |
2298 */ | |
2299 PALLOC_SDU(ll_establish_req, | |
2300 LL_ESTABLISH_REQ, | |
2301 SNDCP_XID_BLOCK_BIT_LEN); | |
2302 | |
2303 /* | |
2304 * Increment number of requested compressors. | |
2305 */ | |
2306 sndcp_data->vj_count++; | |
2307 | |
2308 sndcp_get_sapi_index(snsm_activate_ind->sapi, &sapi_index); | |
2309 /* | |
2310 * Reset service nu to acknowledged LLC mode. | |
2311 */ | |
2312 sig_mg_nu_reset_ack(snsm_activate_ind->nsapi, 0, 0, TRUE); | |
2313 | |
2314 ll_establish_req->sapi = snsm_activate_ind->sapi; | |
2315 /* | |
2316 * Write data from snsm_activate_ind to service variable req_xid_block. | |
2317 */ | |
2318 | |
2319 mg_set_req_xid_block(snsm_activate_ind); | |
2320 /* | |
2321 * Fill the XID block. Implementation dependent!!! | |
2322 */ | |
2323 mg_set_xid_params(ll_establish_req->sapi, | |
2324 &ll_establish_req->sdu, | |
2325 sndcp_data->mg.req_xid_block[sapi_index]); | |
2326 | |
2327 /* | |
2328 * Set the establishment states of sapi | |
2329 */ | |
2330 sndcp_set_sapi_state(snsm_activate_ind->sapi, MG_EST); | |
2331 /* | |
2332 * Uplink data transfer on SAPI is completely suspended. | |
2333 */ | |
2334 sig_mg_su_suspend(snsm_activate_ind->sapi); | |
2335 sig_mg_sua_suspend(snsm_activate_ind->sapi); | |
2336 mg_suspend_affected_nus(snsm_activate_ind->sapi); | |
2337 | |
2338 /* | |
2339 * Send prim to LLC. | |
2340 */ | |
2341 sndcp_set_nsapi_rec_state(snsm_activate_ind->nsapi, SDA_ESTABLISH_REQUESTED); | |
2342 | |
2343 #ifdef SNDCP_RANGE_CHECK | |
2344 | |
2345 if(ll_establish_req EQ NULL) | |
2346 { | |
2347 TRACE_EVENT("ERROR: ll_establish_req is NULL"); | |
2348 } | |
2349 else if(*((ULONG*)ll_establish_req - 7) NEQ 0) | |
2350 { | |
2351 TRACE_EVENT | |
2352 ("ERROR in SNDCP: ll_establish_req is not allocated"); | |
2353 } | |
2354 | |
2355 #endif /* SNDCP_RANGE_CHECK */ | |
2356 | |
2357 PSEND(hCommLLC, ll_establish_req); | |
2358 } | |
2359 } | |
2360 } else { | |
2361 /* | |
2362 * The NSAPI will not use acknowledged LLC operation mode. | |
2363 */ | |
2364 | |
2365 /* | |
2366 * Is XID negotiation necessary? | |
2367 */ | |
2368 | |
2369 /* check if flow control is received before PDP activation */ | |
2370 mg_check_unset_nsapi_flow_ctrl_flag (snsm_activate_ind->nsapi,SNDCP_UNACK); | |
2371 | |
2372 | |
2373 #ifdef TI_PS_FF_V42BIS | |
2374 #ifdef SNDCP_UPM_INCLUDED | |
2375 if ((snsm_activate_ind->comp_params.hcomp == NAS_HCOMP_NEITHER_DIRECT | |
2376 || | |
2377 sndcp_data->vj_count >= SNDCP_MAX_VJ_COUNT) | |
2378 && | |
2379 snsm_activate_ind->comp_params.dcomp == NAS_HCOMP_NEITHER_DIRECT) | |
2380 #else | |
2381 if ((snsm_activate_ind->hcomp == SNSM_COMP_NEITHER_DIRECT | |
2382 || | |
2383 sndcp_data->vj_count >= SNDCP_MAX_VJ_COUNT) | |
2384 && | |
2385 snsm_activate_ind->dcomp == SNSM_COMP_NEITHER_DIRECT) | |
2386 | |
2387 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
2388 #else /* !TI_PS_FF_V42BIS */ | |
2389 #ifdef SNDCP_UPM_INCLUDED | |
2390 if (snsm_activate_ind->comp_params.hcomp == NAS_HCOMP_OFF | |
2391 || | |
2392 sndcp_data->vj_count == SNDCP_MAX_VJ_COUNT) | |
2393 #else | |
2394 if (snsm_activate_ind->hcomp == SNSM_COMP_NEITHER_DIRECT | |
2395 || | |
2396 sndcp_data->vj_count == SNDCP_MAX_VJ_COUNT) | |
2397 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
2398 | |
2399 #endif /* TI_PS_FF_V42BIS */ | |
2400 { | |
2401 | |
2402 /* | |
2403 * No XID negotiation necessary. | |
2404 * BUT LLC needs trigger to send LLC XID request to network. | |
2405 * If LL_ESTABLISH_REQ or LL_XID_REQ is pending, no LL_XID_REQ | |
2406 * is needed here. | |
2407 * If LL_RELEASE_REQ is pending, XID must have been negotiated, | |
2408 * so it is not necessary. | |
2409 */ | |
2410 USHORT local_sapi_state = MG_IDLE; | |
2411 sndcp_get_sapi_state(snsm_activate_ind->sapi, | |
2412 &local_sapi_state); | |
2413 | |
2414 if (sndcp_data->always_xid | |
2415 && | |
2416 (local_sapi_state & MG_EST) == 0 | |
2417 && | |
2418 (local_sapi_state & MG_REL) == 0 | |
2419 && | |
2420 (local_sapi_state & MG_XID) == 0 | |
2421 ) { | |
2422 | |
2423 /* | |
2424 * XID negotiation is not necessary, but done for LLC. | |
2425 */ | |
2426 /* | |
2427 * Set the N-PDU number in the affected nu instance to 0. | |
2428 */ | |
2429 sig_mg_nu_reset(snsm_activate_ind->nsapi, TRUE); | |
2430 /* | |
2431 * Uplink data transfer on SAPI is completely suspended. | |
2432 */ | |
2433 sig_mg_su_suspend(snsm_activate_ind->sapi); | |
2434 sig_mg_sua_suspend(snsm_activate_ind->sapi); | |
2435 mg_suspend_affected_nus(snsm_activate_ind->sapi); | |
2436 /* | |
2437 * Send prim. | |
2438 */ | |
2439 mg_send_empty_xid_req(snsm_activate_ind); | |
2440 | |
2441 } else { | |
2442 /* | |
2443 * No XID negotiation necessary. | |
2444 */ | |
2445 | |
2446 /* | |
2447 * LLC may send data now | |
2448 */ | |
2449 sig_mg_sd_getunitdata(snsm_activate_ind->sapi, snsm_activate_ind->nsapi); | |
2450 /* | |
2451 * Open DTI connection. | |
2452 */ | |
2453 #ifndef SNDCP_UPM_INCLUDED | |
2454 mg_dti_open(snsm_activate_ind->nsapi); | |
2455 #else | |
2456 nu_unitready_ind_if_nec(snsm_activate_ind->nsapi); | |
2457 #endif | |
2458 /* | |
2459 * Set the N-PDU number in the affected nu instance to 0. | |
2460 */ | |
2461 sig_mg_nu_reset(snsm_activate_ind->nsapi, FALSE); | |
2462 | |
2463 mg_send_snsm_activate_res(snsm_activate_ind->nsapi); | |
2464 /* | |
2465 * The response is now sent, state flag can be unset. | |
2466 */ | |
2467 sndcp_unset_nsapi_state(snsm_activate_ind->nsapi, MG_ACT); | |
2468 | |
2469 } | |
2470 | |
2471 } else { | |
2472 #ifdef SNDCP_UPM_INCLUDED | |
2473 if (snsm_activate_ind->comp_params.hcomp > NAS_HCOMP_OFF) { | |
2474 #else | |
2475 if (snsm_activate_ind->hcomp > SNSM_COMP_NEITHER_DIRECT) { | |
2476 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
2477 /* | |
2478 * Increment number of requested compressors. | |
2479 */ | |
2480 sndcp_data->vj_count++; | |
2481 } | |
2482 | |
2483 /* | |
2484 * XID negotiation is necessary. | |
2485 */ | |
2486 /* | |
2487 * Set the N-PDU number in the affected nu instance to 0. | |
2488 */ | |
2489 sndcp_get_sapi_state(snsm_activate_ind->sapi, &sapi_state); | |
2490 sig_mg_nu_reset(snsm_activate_ind->nsapi, TRUE); | |
2491 | |
2492 if (((sapi_state & MG_XID) == 0) | |
2493 && | |
2494 ((sapi_state & MG_EST) == 0)) { | |
2495 | |
2496 /* | |
2497 * Uplink data transfer on SAPI is completely suspended. | |
2498 */ | |
2499 sig_mg_su_suspend(snsm_activate_ind->sapi); | |
2500 sig_mg_sua_suspend(snsm_activate_ind->sapi); | |
2501 mg_suspend_affected_nus(snsm_activate_ind->sapi); | |
2502 /* | |
2503 * Send prim. | |
2504 */ | |
2505 mg_send_xid_req(snsm_activate_ind); | |
2506 } else { | |
2507 mg_set_new_xid_block(snsm_activate_ind); | |
2508 sndcp_set_sapi_state(snsm_activate_ind->sapi, MG_XID_NEC); | |
2509 } | |
2510 | |
2511 } /* else from if negotiation necessary */ | |
2512 } /* else from if (b) { */ | |
2513 } /* if (spec) { */ | |
2514 if ( sndcp_data->tcp_flow) | |
2515 { | |
2516 TRACE_EVENT("sndcp_data.tcp_flow --- DATA FLOW PRIMITIVE "); | |
2517 TRACE_EVENT_P1("nsapi value %d", snsm_activate_ind->nsapi); | |
2518 nd_dti_buffer_ready(snsm_activate_ind->nsapi); | |
2519 } | |
2520 } /* if (used == FALSE) { */ | |
2521 break; | |
2522 default: | |
2523 TRACE_ERROR( "SNSM_ACTIVATE_IND unexpected" ); | |
2524 break; | |
2525 } | |
2526 if (snsm_activate_ind != NULL) { | |
2527 PFREE(snsm_activate_ind); | |
2528 } | |
2529 | |
2530 } /* mg_snsm_activate_ind() */ | |
2531 | |
2532 | |
2533 | |
2534 /* | |
2535 +------------------------------------------------------------------------------ | |
2536 | Function : mg_snsm_deactivate_ind | |
2537 +------------------------------------------------------------------------------ | |
2538 | Description : Handles the primitive SNSM_DEACTIVATE_IND | |
2539 | | |
2540 | Parameters : *snsm_deactivate_ind - Ptr to primitive payload | |
2541 | | |
2542 +------------------------------------------------------------------------------ | |
2543 */ | |
2544 #ifdef SNDCP_UPM_INCLUDED | |
2545 GLOBAL void mg_snsm_deactivate_ind ( T_SN_DEACTIVATE_REQ *snsm_deactivate_ind ) | |
2546 #else | |
2547 GLOBAL void mg_snsm_deactivate_ind ( T_SNSM_DEACTIVATE_IND *snsm_deactivate_ind ) | |
2548 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
2549 { | |
2550 UBYTE nsapi = 0; | |
2551 BOOL nec = FALSE; | |
2552 | |
2553 TRACE_FUNCTION( "mg_snsm_deactivate_ind" ); | |
2554 | |
2555 switch( GET_STATE( MG ) ) | |
2556 { | |
2557 case MG_DEFAULT: | |
2558 for (nsapi = 0; nsapi < SNDCP_NUMBER_OF_NSAPIS; nsapi ++) { | |
2559 #ifdef SNDCP_UPM_INCLUDED | |
2560 if (snsm_deactivate_ind->nsapi == nsapi) { | |
2561 #else | |
2562 if (snsm_deactivate_ind->nsapi_set & (0x001 << nsapi)) { | |
2563 #endif | |
2564 USHORT sapi_state = 0; | |
2565 BOOL ack = FALSE; | |
2566 BOOL used = FALSE; | |
2567 UBYTE sapi = 0; | |
2568 | |
2569 /* | |
2570 * Delete information about requested compressors. | |
2571 */ | |
2572 sndcp_reset_xid_block(&sndcp_data->mg.user_xid_block[nsapi]); | |
2573 /* | |
2574 * If nsapi is not used, send response anyway to avoid block. | |
2575 */ | |
2576 sndcp_is_nsapi_used(nsapi, &used); | |
2577 if (!used) { | |
2578 #ifdef SNDCP_UPM_INCLUDED | |
2579 PALLOC(snsm_deactivate_res, SN_DEACTIVATE_CNF); | |
2580 snsm_deactivate_res->nsapi = nsapi; | |
2581 #else | |
2582 PALLOC(snsm_deactivate_res, SNSM_DEACTIVATE_RES); | |
2583 snsm_deactivate_res->nsapi = nsapi; | |
2584 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
2585 /* | |
2586 * Set the "state" of the nsapi. | |
2587 */ | |
2588 sndcp_unset_nsapi_state(nsapi, MG_DEACT); | |
2589 | |
2590 | |
2591 #ifdef SNDCP_UPM_INCLUDED | |
2592 PSEND(hCommUPM, snsm_deactivate_res); | |
2593 #else /*#ifdef SNDCP_UPM_INCLUDED*/ | |
2594 PSEND(hCommSM, snsm_deactivate_res); | |
2595 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
2596 continue; | |
2597 } | |
2598 | |
2599 | |
2600 /* | |
2601 * Close affected DTI connection. | |
2602 */ | |
2603 #ifdef _SNDCP_DTI_2_ | |
2604 /* FIX | |
2605 for entity test TC TC 321 and TC 327 and TC 262a*/ | |
2606 sndcp_data->nu = & sndcp_data->nu_base[nsapi]; | |
2607 /* End FIX */ | |
2608 #endif /* _SNDCP_DTI_2_ */ | |
2609 #ifndef SNDCP_UPM_INCLUDED | |
2610 mg_dti_close(nsapi); | |
2611 #else | |
2612 /* | |
2613 * This part is required for EDGE to get next line out of if | |
2614 * statement. | |
2615 */ | |
2616 {} | |
2617 #endif | |
2618 sndcp_set_nsapi_state(nsapi, MG_DEACT); | |
2619 sndcp_unset_nsapi_state(nsapi, MG_ACT); | |
2620 | |
2621 sndcp_get_nsapi_ack(nsapi, &ack); | |
2622 sndcp_get_nsapi_sapi(nsapi, &sapi); | |
2623 if (ack) { | |
2624 mg_rel_nsapi_nec(nsapi); | |
2625 } | |
2626 sndcp_get_sapi_state(sapi, &sapi_state); | |
2627 mg_delete_npdus(nsapi); | |
2628 sndcp_data->nu_base[nsapi].sn_unitready_ind_pending = FALSE; | |
2629 sndcp_data->nu_base[nsapi].sn_ready_ind_pending = FALSE; | |
2630 /* | |
2631 * is compressor deactivation necessary? | |
2632 */ | |
2633 mg_is_rel_comp_nec(nsapi, &nec); | |
2634 | |
2635 #ifdef SNDCP_UPM_INCLUDED | |
2636 if ((snsm_deactivate_ind->rel_ind == PS_REL_IND_YES) | |
2637 && | |
2638 ((sapi_state & (MG_REL + MG_REL_NEC_LOC + MG_REL_NEC_PEER)) == 0) | |
2639 ) { | |
2640 #else | |
2641 if ((snsm_deactivate_ind->rel_ind == REL_IND_YES) | |
2642 && | |
2643 ((sapi_state & (MG_REL + MG_REL_NEC_LOC + MG_REL_NEC_PEER)) == 0) | |
2644 ) { | |
2645 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
2646 /* | |
2647 * Local deactivation. No LL_XID_REQ will be sent (because rel_ind | |
2648 * is REL_IND_YES). | |
2649 * No release is pending or needed. | |
2650 */ | |
2651 | |
2652 #ifdef SNDCP_UPM_INCLUDED | |
2653 PALLOC(snsm_deactivate_res, SN_DEACTIVATE_CNF); | |
2654 snsm_deactivate_res->nsapi = nsapi; | |
2655 #else | |
2656 PALLOC(snsm_deactivate_res, SNSM_DEACTIVATE_RES); | |
2657 snsm_deactivate_res->nsapi = nsapi; | |
2658 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
2659 /* | |
2660 * Now the NSAPI is not in use anymore: | |
2661 */ | |
2662 sndcp_set_nsapi_used(nsapi, FALSE); | |
2663 sndcp_set_nsapi_ack(nsapi, FALSE); | |
2664 /* | |
2665 * Set the "state" of the nsapi. | |
2666 */ | |
2667 sndcp_unset_nsapi_state(nsapi, MG_DEACT); | |
2668 /* | |
2669 * Reset xid blocks. | |
2670 */ | |
2671 mg_reset_compressors(nsapi); | |
2672 | |
2673 | |
2674 #ifdef SNDCP_UPM_INCLUDED | |
2675 PSEND(hCommUPM, snsm_deactivate_res); | |
2676 #else | |
2677 PSEND(hCommSM, snsm_deactivate_res); | |
2678 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
2679 | |
2680 } else if ((sapi_state & (MG_REL + MG_REL_NEC_LOC + MG_REL_NEC_PEER)) | |
2681 == 0 | |
2682 ) { | |
2683 | |
2684 /* | |
2685 * No release is pending. | |
2686 * If no compressor has to be released: respond to SM. | |
2687 */ | |
2688 if (nec) { | |
2689 /* | |
2690 * If xid req is sent, suspend uplink transfer for affected sapi. | |
2691 */ | |
2692 sig_mg_su_suspend(sapi); | |
2693 sig_mg_sua_suspend(sapi); | |
2694 mg_suspend_affected_nus(sapi); | |
2695 /* | |
2696 * Negotiate possible deactivation of compressors. | |
2697 */ | |
2698 mg_send_xid_req_del(sapi); | |
2699 | |
2700 } else { /* if (nec) */ | |
2701 | |
2702 sndcp_get_sapi_state(sapi, &sapi_state); | |
2703 if ((sapi_state & MG_XID_NEC) == 0) { | |
2704 /* | |
2705 * No compressor negotiated, no release sent. | |
2706 */ | |
2707 | |
2708 #ifdef SNDCP_UPM_INCLUDED | |
2709 PALLOC(snsm_deactivate_res, SN_DEACTIVATE_CNF); | |
2710 snsm_deactivate_res->nsapi = nsapi; | |
2711 #else | |
2712 PALLOC(snsm_deactivate_res, SNSM_DEACTIVATE_RES); | |
2713 snsm_deactivate_res->nsapi = nsapi; | |
2714 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
2715 | |
2716 | |
2717 /* | |
2718 * Now the NSAPI is not in use anymore: | |
2719 */ | |
2720 sndcp_set_nsapi_used(nsapi, FALSE); | |
2721 sndcp_set_nsapi_ack(nsapi, FALSE); | |
2722 /* | |
2723 * Set the "state" of the nsapi. | |
2724 */ | |
2725 sndcp_unset_nsapi_state(nsapi, MG_DEACT); | |
2726 | |
2727 | |
2728 #ifdef SNDCP_UPM_INCLUDED | |
2729 PSEND(hCommUPM, snsm_deactivate_res); | |
2730 #else /*#ifdef SNDCP_UPM_INCLUDED*/ | |
2731 PSEND(hCommSM, snsm_deactivate_res); | |
2732 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
2733 | |
2734 } | |
2735 } /* if (nec) */ | |
2736 } else {/* if ((state & (MG_REL + ....)) == 0) */ | |
2737 /* | |
2738 * LL_RELEASE_REQ is pending. After reception of LL_RELEASE_REQ, | |
2739 * if XID negotiatio is necessary, LL_XID_REQ will be sent. | |
2740 */ | |
2741 if (nec) { | |
2742 sndcp_set_sapi_state(sapi, MG_XID_NEC); | |
2743 } | |
2744 } | |
2745 } | |
2746 } | |
2747 break; | |
2748 default: | |
2749 TRACE_ERROR( "SNSM_DEACTIVATE_IND unexpected" ); | |
2750 break; | |
2751 } | |
2752 if (snsm_deactivate_ind != NULL) { | |
2753 PFREE(snsm_deactivate_ind); | |
2754 } | |
2755 | |
2756 | |
2757 } /* mg_snsm_deactivate_ind() */ | |
2758 | |
2759 | |
2760 | |
2761 /* | |
2762 +------------------------------------------------------------------------------ | |
2763 | Function : mg_snsm_sequence_ind | |
2764 +------------------------------------------------------------------------------ | |
2765 | Description : Handles the primitive SNSM_SEQUENCE_IND | |
2766 | | |
2767 | Parameters : *snsm_sequence_ind - Ptr to primitive payload | |
2768 | | |
2769 +------------------------------------------------------------------------------ | |
2770 */ | |
2771 #ifdef SNDCP_UPM_INCLUDED | |
2772 GLOBAL void mg_snsm_sequence_ind ( T_SN_SEQUENCE_REQ *snsm_sequence_ind ) | |
2773 #else | |
2774 GLOBAL void mg_snsm_sequence_ind ( T_SNSM_SEQUENCE_IND *snsm_sequence_ind ) | |
2775 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
2776 { | |
2777 | |
2778 #ifdef SNDCP_UPM_INCLUDED | |
2779 int i = 0; | |
2780 U8 nsapi,rec_no,npdu_number; | |
2781 #endif | |
2782 | |
2783 TRACE_FUNCTION( "mg_snsm_sequence_ind" ); | |
2784 | |
2785 switch( GET_STATE( MG ) ) | |
2786 { | |
2787 case MG_DEFAULT: | |
2788 { | |
2789 #ifdef SNDCP_UPM_INCLUDED | |
2790 | |
2791 PALLOC(snsm_sequence_res, SN_SEQUENCE_CNF); | |
2792 | |
2793 for (i = 0; | |
2794 i < snsm_sequence_ind->c_receive_no_list; | |
2795 i++) { | |
2796 | |
2797 nsapi = snsm_sequence_ind->receive_no_list[i].nsapi; | |
2798 rec_no = snsm_sequence_ind->receive_no_list[i].receive_no; | |
2799 | |
2800 sndcp_unset_nsapi_state(nsapi, MG_SEQ); | |
2801 sig_mg_nu_delete_to(nsapi, rec_no); | |
2802 npdu_number = sig_mg_nd_get_rec_no(nsapi); | |
2803 snsm_sequence_res->receive_no_list[i].nsapi = nsapi; | |
2804 snsm_sequence_res->receive_no_list[i].receive_no = npdu_number; | |
2805 } | |
2806 snsm_sequence_res->c_receive_no_list = i; | |
2807 PSEND(hCommUPM, snsm_sequence_res); | |
2808 #else | |
2809 TRACE_EVENT_P1( "SEQ_IND rec_no: %d", snsm_sequence_ind->rec_no); | |
2810 sndcp_unset_nsapi_state(snsm_sequence_ind->nsapi, MG_SEQ); | |
2811 sig_mg_nu_delete_to(snsm_sequence_ind->nsapi, | |
2812 snsm_sequence_ind->rec_no); | |
2813 sig_mg_nd_get_rec_no(snsm_sequence_ind->nsapi); | |
2814 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
2815 break; | |
2816 } | |
2817 default: | |
2818 TRACE_ERROR( "SNSM_SEQUENCE_IND unexpected" ); | |
2819 break; | |
2820 } | |
2821 if (snsm_sequence_ind != NULL) { | |
2822 PFREE (snsm_sequence_ind); | |
2823 } | |
2824 | |
2825 } /* mg_snsm_sequence_ind() */ | |
2826 | |
2827 | |
2828 | |
2829 /* | |
2830 +------------------------------------------------------------------------------ | |
2831 | Function : mg_snsm_modify_ind | |
2832 +------------------------------------------------------------------------------ | |
2833 | Description : Handles the primitive SNSM_MODIFY_IND | |
2834 | | |
2835 | Parameters : *snsm_modify_ind - Ptr to primitive payload | |
2836 | | |
2837 +------------------------------------------------------------------------------ | |
2838 */ | |
2839 #ifdef SNDCP_UPM_INCLUDED | |
2840 GLOBAL void mg_snsm_modify_ind ( T_SN_MODIFY_REQ *snsm_modify_ind ) | |
2841 #else | |
2842 GLOBAL void mg_snsm_modify_ind ( T_SNSM_MODIFY_IND *snsm_modify_ind ) | |
2843 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
2844 { | |
2845 /* | |
2846 * LLC mode specified? | |
2847 */ | |
2848 BOOL spec = FALSE; | |
2849 /* | |
2850 * LLC mode acknowledged? | |
2851 */ | |
2852 BOOL b = FALSE; | |
2853 BOOL nsapi_used = FALSE; | |
2854 BOOL old_nsapi_ack = FALSE; | |
2855 UBYTE old_sapi = 0; | |
2856 | |
2857 TRACE_FUNCTION( "mg_snsm_modify_ind" ); | |
2858 | |
2859 switch( GET_STATE( MG ) ) | |
2860 { | |
2861 case MG_DEFAULT: | |
2862 /* | |
2863 * If no release/establish will be done, SNSM_MODIFY_RES is expected now. | |
2864 */ | |
2865 sndcp_data->mg.mod_expects = MG_MOD_X_READY; | |
2866 /* | |
2867 * Is NSAPI already used? | |
2868 */ | |
2869 sndcp_is_nsapi_used(snsm_modify_ind->nsapi, &nsapi_used); | |
2870 if (! nsapi_used) { | |
2871 mg_mod_nsapi_new(snsm_modify_ind); | |
2872 } | |
2873 /* | |
2874 * Is LLC operation mode changing from unack to ack? | |
2875 */ | |
2876 mg_is_ack(snsm_modify_ind->snsm_qos, &spec, &b); | |
2877 sndcp_get_nsapi_ack(snsm_modify_ind->nsapi, &old_nsapi_ack); | |
2878 if (spec && b && ! old_nsapi_ack) { | |
2879 mg_mod_unack_ack(snsm_modify_ind); | |
2880 } | |
2881 /* | |
2882 * Is LLC operation mode changing from ack to unack? | |
2883 */ | |
2884 if (spec && ! b && old_nsapi_ack) { | |
2885 mg_mod_ack_unack(snsm_modify_ind); | |
2886 } | |
2887 /* | |
2888 * Is new sapi different from old one? | |
2889 */ | |
2890 sndcp_get_nsapi_sapi(snsm_modify_ind->nsapi, &old_sapi); | |
2891 if (old_sapi != snsm_modify_ind->sapi) { | |
2892 mg_mod_sapi_diff(snsm_modify_ind); | |
2893 } | |
2894 /* | |
2895 * Add nsapi to waiting_nsapis | |
2896 */ | |
2897 | |
2898 sndcp_data->mg.waiting_nsapis |= (1 << (snsm_modify_ind->nsapi)); | |
2899 | |
2900 /* | |
2901 * The following will be done in any case: | |
2902 */ | |
2903 sndcp_set_nsapi_qos(snsm_modify_ind->nsapi, snsm_modify_ind->snsm_qos); | |
2904 sndcp_set_nsapi_prio(snsm_modify_ind->nsapi, snsm_modify_ind->radio_prio); | |
2905 | |
2906 #ifdef REL99 | |
2907 sndcp_set_nsapi_pktflowid(snsm_modify_ind->nsapi, | |
2908 snsm_modify_ind->pkt_flow_id); | |
2909 #endif /*REL99*/ | |
2910 /* | |
2911 * If no establish/release is expected, send res now. | |
2912 */ | |
2913 mg_mod_res_if_nec(); | |
2914 break; | |
2915 default: | |
2916 TRACE_ERROR( "SNSM_MODIFY_IND unexpected" ); | |
2917 break; | |
2918 } | |
2919 if (snsm_modify_ind != NULL) { | |
2920 PFREE(snsm_modify_ind); | |
2921 } | |
2922 | |
2923 } /* mg_snsm_modify_ind() */ | |
2924 | |
2925 | |
2926 #ifndef SNDCP_UPM_INCLUDED | |
2927 /* | |
2928 +------------------------------------------------------------------------------ | |
2929 | Function : mg_sn_switch_req | |
2930 +------------------------------------------------------------------------------ | |
2931 | Description : Handles the primitive SN_SWITCH_REQ | |
2932 | | |
2933 | Parameters : *snswitch_req - Ptr to primitive payload | |
2934 | | |
2935 +------------------------------------------------------------------------------ | |
2936 */ | |
2937 | |
2938 GLOBAL void mg_sn_switch_req ( T_SN_SWITCH_REQ *sn_switch_req ) | |
2939 { | |
2940 #ifdef _SNDCP_DTI_2_ | |
2941 UBYTE* neighbor = NULL; | |
2942 #endif /* _SNDCP_DTI_2_ */ | |
2943 TRACE_FUNCTION( "mg_sn_switch_req" ); | |
2944 | |
2945 switch( GET_STATE( MG ) ) | |
2946 { | |
2947 case MG_DEFAULT: | |
2948 sndcp_set_nsapi_linkid(sn_switch_req->nsapi, | |
2949 sn_switch_req->dti_linkid); | |
2950 #ifdef _SNDCP_DTI_2_ | |
2951 sndcp_get_nsapi_neighbor(sn_switch_req->nsapi, &neighbor); | |
2952 #endif /* _SNDCP_DTI_2_ */ | |
2953 #ifdef _SIMULATION_ | |
2954 sndcp_set_nsapi_neighbor(sn_switch_req->nsapi, | |
2955 (sn_switch_req->dti_neighbor == | |
2956 0xabcdabcd | |
2957 ? | |
2958 "PPP" | |
2959 : | |
2960 "NULL")); | |
2961 #else /*_SIMULATION_ */ | |
2962 sndcp_set_nsapi_neighbor(sn_switch_req->nsapi, | |
2963 (UBYTE*)sn_switch_req->dti_neighbor); | |
2964 #endif /* _SIMULATION_ */ | |
2965 /* | |
2966 * Map sn constants to dti constants. | |
2967 */ | |
2968 if (sn_switch_req->dti_direction == SN_HOME) { | |
2969 sndcp_set_nsapi_direction(sn_switch_req->nsapi, HOME); | |
2970 } else { | |
2971 sndcp_set_nsapi_direction(sn_switch_req->nsapi, NEIGHBOR); | |
2972 } | |
2973 #ifdef _SIMULATION_ | |
2974 #ifdef _SNDCP_DTI_2_ | |
2975 /* FIX for entity test TC 1205*/ | |
2976 sndcp_data->nu = & sndcp_data->nu_base[sn_switch_req->nsapi]; | |
2977 if ((sndcp_data->nu->connection_is_opened == TRUE) || | |
2978 ((neighbor != NULL) && !(strcmp(neighbor,"NULL")))) | |
2979 /* End FIX */ | |
2980 #endif /* _SNDCP_DTI_2_ */ | |
2981 #endif /* _SIMULATION_ */ | |
2982 #ifndef SNDCP_UPM_INCLUDED | |
2983 mg_dti_close(sn_switch_req->nsapi); | |
2984 #endif | |
2985 sndcp_data->nu->sn_switch_cnf_expected = TRUE; | |
2986 #ifndef SNDCP_UPM_INCLUDED | |
2987 mg_dti_open(sn_switch_req->nsapi); | |
2988 #endif | |
2989 | |
2990 break; | |
2991 default: | |
2992 TRACE_ERROR( "SN_SWITCH_REQ unexpected" ); | |
2993 break; | |
2994 } | |
2995 | |
2996 PFREE(sn_switch_req); | |
2997 | |
2998 } /* mg_sn_switch_req() */ | |
2999 #endif /*SNDCP_UPM_INCLUDED*/ | |
3000 | |
3001 | |
3002 #ifdef SNDCP_UPM_INCLUDED | |
3003 /* | |
3004 +------------------------------------------------------------------------------ | |
3005 | Function : mg_sn_dti_req | |
3006 +------------------------------------------------------------------------------ | |
3007 | Description : Handles the primitive SN_DTI_REQ | |
3008 | | |
3009 | Parameters : *sn_dti_req - Ptr to primitive payload | |
3010 | | |
3011 +------------------------------------------------------------------------------ | |
3012 */ | |
3013 GLOBAL void mg_sn_dti_req ( T_SN_DTI_REQ *sn_dti_req ) | |
3014 { | |
3015 | |
3016 UBYTE* neighbor = NULL; | |
3017 | |
3018 /* | |
3019 * is nsapi already used? | |
3020 */ | |
3021 /* BOOL used = FALSE;*/ | |
3022 BOOL ack = FALSE; | |
3023 | |
3024 TRACE_FUNCTION( "mg_sn_dti_req" ); | |
3025 | |
3026 switch( GET_STATE( MG ) ) | |
3027 { | |
3028 case MG_DEFAULT: | |
3029 sndcp_set_nsapi_linkid(sn_dti_req->nsapi, | |
3030 sn_dti_req->dti_linkid); | |
3031 | |
3032 TRACE_EVENT_P1("sn_dti_req->nsapi: %d", sn_dti_req->nsapi); | |
3033 | |
3034 if (sn_dti_req->dti_conn == NAS_CONNECT_DTI) { | |
3035 | |
3036 sndcp_get_nsapi_neighbor(sn_dti_req->nsapi, &neighbor); | |
3037 sndcp_data->nsapi = sn_dti_req->nsapi; | |
3038 | |
3039 #ifdef SNDCP_2to1 | |
3040 sndcp_set_nsapi_neighbor(sn_dti_req->nsapi, | |
3041 (U8*)sn_dti_req->dti_neighbor.name); | |
3042 #else /*SNDCP_2to1*/ | |
3043 #ifdef _SIMULATION_ | |
3044 sndcp_set_nsapi_neighbor(sn_dti_req->nsapi, | |
3045 (sn_dti_req->dti_neighbor == | |
3046 0xabcdabcd | |
3047 ? | |
3048 "PPP" | |
3049 : | |
3050 "NULL")); | |
3051 #else /*_SIMULATION_ */ | |
3052 sndcp_set_nsapi_neighbor(sn_dti_req->nsapi, | |
3053 (U8*)sn_dti_req->dti_neighbor); | |
3054 #endif /* _SIMULATION_ */ | |
3055 #endif /*SNDCP_2to1*/ | |
3056 | |
3057 /* | |
3058 * Map sn constants to dti constants. | |
3059 * The compiler switch is required because the dti_direction | |
3060 * C-Macros have different values in old and new worlds. | |
3061 */ | |
3062 | |
3063 #ifdef SNDCP_UPM_INCLUDED | |
3064 if (sn_dti_req->dti_direction == NAS_HOME) | |
3065 { | |
3066 sndcp_set_nsapi_direction(sn_dti_req->nsapi, DTI_CHANNEL_TO_LOWER_LAYER); | |
3067 } | |
3068 else | |
3069 { | |
3070 sndcp_set_nsapi_direction(sn_dti_req->nsapi, DTI_CHANNEL_TO_HIGHER_LAYER); | |
3071 } | |
3072 #else /*SNDCP_UPM_INCLUDED*/ | |
3073 if (sn_dti_req->dti_direction == DTI_CHANNEL_TO_LOWER_LAYER) | |
3074 { | |
3075 sndcp_set_nsapi_direction(sn_dti_req->nsapi, DTI_CHANNEL_TO_LOWER_LAYER); | |
3076 } | |
3077 else | |
3078 { | |
3079 sndcp_set_nsapi_direction(sn_dti_req->nsapi, DTI_CHANNEL_TO_HIGHER_LAYER); | |
3080 } | |
3081 #endif | |
3082 sndcp_set_nsapi_linkid(sn_dti_req->nsapi, | |
3083 sn_dti_req->dti_linkid); | |
3084 if (sn_dti_req->dti_neighbor NEQ (ULONG)TCPIP_NAME) | |
3085 { | |
3086 mg_dti_open(sn_dti_req->nsapi); | |
3087 } | |
3088 #ifdef SNDCP_UPM_INCLUDED | |
3089 sndcp_get_nsapi_ack(sn_dti_req->nsapi, &ack); | |
3090 if (ack) { | |
3091 UBYTE sapi = 0; | |
3092 USHORT stat = MG_IDLE; | |
3093 sndcp_get_nsapi_sapi(sn_dti_req->nsapi, &sapi); | |
3094 sndcp_get_sapi_state(sapi, &stat); | |
3095 /* | |
3096 * Do not call nu_ready_ind_if_nec() if establish | |
3097 * is ongoing. | |
3098 */ | |
3099 if ((stat & MG_EST) == 0) { | |
3100 nu_ready_ind_if_nec(sn_dti_req->nsapi); | |
3101 } | |
3102 } else { | |
3103 nu_unitready_ind_if_nec(sn_dti_req->nsapi); | |
3104 } | |
3105 #endif | |
3106 | |
3107 } else { /* if (sn_dti_req->dti_conn == SNDCP_CONNECT_DTI) */ | |
3108 | |
3109 | |
3110 /* check if flow control is received before PDP activation */ | |
3111 mg_check_unset_nsapi_flow_ctrl_flag (sn_dti_req->nsapi,MG_MOD_X_NONE); | |
3112 | |
3113 mg_dti_close(sn_dti_req->nsapi); | |
3114 } /* if (sn_dti_req->dti_conn == SNDCP_CONNECT_DTI) */ | |
3115 | |
3116 break; | |
3117 default: | |
3118 TRACE_ERROR( "SN_DTI_REQ unexpected" ); | |
3119 break; | |
3120 } | |
3121 | |
3122 PFREE(sn_dti_req); | |
3123 | |
3124 } /* mg_sn_dti_req() */ | |
3125 | |
3126 | |
3127 | |
3128 #endif /* SNDCP_UPM_INCLUDED */ | |
3129 | |
3130 #ifdef TI_DUAL_MODE | |
3131 /* | |
3132 +------------------------------------------------------------------------------ | |
3133 | Function : mg_get_pending_pdu_req | |
3134 +------------------------------------------------------------------------------ | |
3135 | Description : Handles the primitive SN_GET_PENDING_PDU_REQ | |
3136 | | |
3137 | Parameters : *sn_get_pending_pdu_req - Ptr to primitive payload | |
3138 | | |
3139 +------------------------------------------------------------------------------ | |
3140 */ | |
3141 GLOBAL void mg_get_pending_pdu_req (T_SN_GET_PENDING_PDU_REQ | |
3142 *sn_get_pending_pdu_req) | |
3143 { | |
3144 U8 nsapi = 0; | |
3145 BOOL ack = FALSE, used = FALSE; | |
3146 | |
3147 TRACE_FUNCTION( "mg_get_pending_pdu_req" ); | |
3148 | |
3149 switch( GET_STATE( MG ) ) | |
3150 { | |
3151 case MG_DEFAULT: | |
3152 { | |
3153 PALLOC(sn_get_pending_pdu_cnf, SN_GET_PENDING_PDU_CNF); | |
3154 #ifdef _SIMULATION_ | |
3155 PALLOC(sn_test_get_pending_pdu_cnf, SN_TEST_GET_PENDING_PDU_CNF); | |
3156 #endif | |
3157 memset(sn_get_pending_pdu_cnf->ul_pdus,0, sizeof(T_SN_ul_pdus)); | |
3158 for (nsapi = 0; nsapi < SN_SIZE_NSAPI; nsapi++) { | |
3159 sn_get_pending_pdu_cnf->ul_pdus[nsapi].c_desc_list2 = 0; | |
3160 sn_get_pending_pdu_cnf->ul_pdus[nsapi].nsapi = 0; | |
3161 sn_get_pending_pdu_cnf->ul_pdus[nsapi].dl_sequence_number = 0; | |
3162 sndcp_is_nsapi_used(nsapi, &used); | |
3163 if (used) { | |
3164 sndcp_get_nsapi_ack(nsapi, &ack); | |
3165 if (ack) {/*acknowledged context*/ | |
3166 sn_get_pending_pdu_cnf = | |
3167 mg_get_unsent_unconfirmed_npdus(nsapi, sn_get_pending_pdu_cnf); | |
3168 mg_clean_ack_npdu_queues_leave_data(nsapi); | |
3169 } else {/*unacknowledged context*/ | |
3170 mg_clean_unack_npdu_queues_including_data(nsapi); | |
3171 } | |
3172 } | |
3173 } | |
3174 sn_get_pending_pdu_cnf->c_ul_pdus=SN_SIZE_NSAPI; | |
3175 #ifdef _SIMULATION_ | |
3176 sm_make_test_pending_pdu_cnf(sn_get_pending_pdu_cnf, | |
3177 sn_test_get_pending_pdu_cnf); | |
3178 PSEND(hCommUPM, sn_test_get_pending_pdu_cnf); | |
3179 #else | |
3180 PSEND(hCommUPM, sn_get_pending_pdu_cnf); | |
3181 #endif | |
3182 break; | |
3183 } | |
3184 default: | |
3185 TRACE_ERROR( "SN_GET_PENDING_PDU_REQ unexpected" ); | |
3186 break; | |
3187 } | |
3188 if (sn_get_pending_pdu_req != NULL) { | |
3189 PFREE (sn_get_pending_pdu_req); | |
3190 } | |
3191 } | |
3192 #endif /*TI_DUAL_MODE*/ |