comparison src/g23m-gprs/sndcp/sndcp_nuf.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_nuf.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 | procedures and functions as described in the
19 | SDL-documentation (NU-statemachine)
20 +-----------------------------------------------------------------------------
21 */
22
23 /*---- HISTORY --------------------------------------------------------------*/
24 #define ENTITY_SNDCP
25
26 /*==== INCLUDES =============================================================*/
27
28 #include "typedefs.h" /* to get Condat data types */
29 #include "vsi.h" /* to get a lot of macros */
30 #include "macdef.h"
31 #include "gsm.h" /* to get a lot of macros */
32 #include "prim.h" /* to get the definitions of used SAP and directions */
33
34 #include "dti.h"
35
36 #include "sndcp.h" /* to get the global entity definitions */
37 #include "sndcp_f.h" /* to get the functions to access the global arrays*/
38
39 #ifndef NCONFIG
40 #include "sndcp_nuf.h"
41 #include "sndcp_suas.h"
42 #include "sndcp_sus.h"
43 #endif
44
45 /*==== CONST ================================================================*/
46
47 /*==== LOCAL VARS ===========================================================*/
48
49 /*==== PRIVATE FUNCTIONS ====================================================*/
50
51 LOCAL void nu_delete (T_NPDU_BUFFER* npdu_buffer);
52
53
54 /*
55 +------------------------------------------------------------------------------
56 | Function : nu_delete
57 +------------------------------------------------------------------------------
58 | Description : The function nu_delete() deletes one buffered N-PDU.
59 | It is used to delete one N-PDU in form of an SN_DATA_REQ
60 | pointer.
61 | It will be useful when one N-PDU is deleted in case of
62 | LL_DATA_CNF orwhen every N-PDU for one NSAPI is deleted in case
63 | of SIG_MG_DELETE_NPDUS.
64 | First every descriptor in the SN_DATA_REQ is deleted, then the
65 | primitive is deleted, then the T_NPDU_BUFFER* is deleted. (This
66 | type is only specified in the code.)
67 | Parameter : the one N-PDU to be deleted.
68 |
69 +------------------------------------------------------------------------------
70 */
71 LOCAL void nu_delete (T_NPDU_BUFFER* npdu_buffer)
72 {
73
74 TRACE_FUNCTION( "nu_delete" );
75
76 if (npdu_buffer == NULL) {
77 return;
78 }
79 /*
80 * Free the SN_DATA_REQ.
81 */
82 #ifdef _SNDCP_DTI_2_
83 if (npdu_buffer->sn_data_req != NULL) {
84 MFREE_PRIM(npdu_buffer->sn_data_req);
85 npdu_buffer->sn_data_req = NULL;
86 }
87 #else /*_SNDCP_DTI_2_*/
88 if (npdu_buffer->sn_data_req != NULL) {
89 PFREE_DESC(npdu_buffer->sn_data_req);
90 npdu_buffer->sn_data_req = NULL;
91 }
92 #endif /*_SNDCP_DTI_2_*/
93 /*
94 * If this was the next to send in recovery state, move to next now.
95 */
96 if (npdu_buffer == sndcp_data->nu->next_resend) {
97 sndcp_data->nu->next_resend = npdu_buffer->next;
98 }
99 if (npdu_buffer == sndcp_data->nu->first_buffered_npdu) {
100 sndcp_data->nu->first_buffered_npdu = npdu_buffer->next;
101 }
102 /*
103 * Free the T_NPDU_BUFFER
104 */
105 MFREE(npdu_buffer);
106 npdu_buffer = NULL;
107 } /* nu_delete() */
108
109
110 /*==== PUBLIC FUNCTIONS =====================================================*/
111
112
113
114
115 /*
116 +------------------------------------------------------------------------------
117 | Function : nu_buffer_npdu
118 +------------------------------------------------------------------------------
119 | Description : The function nu_buffer_npdu() buffers the given SN_DATA_REQ
120 | together with the given N-PDU number.
121 |
122 | Parameters : N-PDU number, SN_DATA_REQ primitive.
123 |
124 +------------------------------------------------------------------------------
125 */
126 GLOBAL void nu_buffer_npdu (UBYTE npdu_number, T_SN_DATA_REQ* sn_data_req)
127 {
128 T_NPDU_BUFFER* npdu_buffer = 0;
129
130 TRACE_FUNCTION( "nu_buffer_npdu" );
131
132 /*
133 * Allocate the T_NPDU_BUFFER struct for
134 */
135 MALLOC(npdu_buffer, sizeof(T_NPDU_BUFFER));
136 /*
137 * Insert the given values.
138 */
139 npdu_buffer->npdu_number = npdu_number;
140 npdu_buffer->sn_data_req = sn_data_req;
141 npdu_buffer->next = NULL;
142 if (sndcp_data->nu->first_buffered_npdu == NULL) {
143 sndcp_data->nu->first_buffered_npdu = npdu_buffer;
144 sndcp_data->nu->next_resend = npdu_buffer;
145 } else {
146 T_NPDU_BUFFER* help = sndcp_data->nu->first_buffered_npdu;
147
148 if (help->next == NULL) {
149 help->next = npdu_buffer;
150 } else {
151 while (help->next != NULL) {
152 help = help->next;
153 }
154 help->next = npdu_buffer;
155 }
156
157 }
158
159
160 } /* nu_buffer_npdu() */
161
162 #ifndef NCONFIG
163
164 /*
165 +------------------------------------------------------------------------------
166 | Function : nu_config_discard
167 +------------------------------------------------------------------------------
168 | Description : reaction to config prim
169 |
170 | Parameters : nsapi
171 |
172 +------------------------------------------------------------------------------
173 */
174 GLOBAL void nu_config_discard (UBYTE nsapi)
175 {
176 TRACE_FUNCTION( "nu_config_discard" );
177
178 sndcp_data->nu = &sndcp_data->nu_base[nsapi];
179 sndcp_data->nu->discard = TRUE;
180 }
181
182 /*
183 +------------------------------------------------------------------------------
184 | Function : nu_config_resume
185 +------------------------------------------------------------------------------
186 | Description : reaction to config prim
187 |
188 | Parameters : nsapi
189 |
190 +------------------------------------------------------------------------------
191 */
192 GLOBAL void nu_config_resume (UBYTE nsapi)
193 {
194 TRACE_FUNCTION( "nu_config_resume" );
195
196 sndcp_data->nu = &sndcp_data->nu_base[nsapi];
197 sndcp_data->nu->discard = FALSE;
198 }
199
200 /*
201 +------------------------------------------------------------------------------
202 | Function : nu_config_send
203 +------------------------------------------------------------------------------
204 | Description : reaction to config prim
205 |
206 | Parameters : nsapi, number of octets
207 |
208 +------------------------------------------------------------------------------
209 */
210 GLOBAL void nu_config_send (UBYTE nsapi, U32 octets)
211 {
212 U32 *data_count = NULL;
213
214 TRACE_FUNCTION( "nu_config_send" );
215
216 sndcp_data->nu = &sndcp_data->nu_base[nsapi];
217
218 data_count = &sndcp_data->data_count[nsapi];
219
220 if (*data_count == 0) {
221 *data_count = octets;
222 } else {
223 *data_count += octets;
224 return;
225 }
226
227 switch( GET_STATE( NU ) )
228 {
229 case NU_ACK_SUA_RECEPTIVE:
230 case NU_SEND_ACK_SUA_RECEPTIVE:
231 SET_STATE(NU, NU_SEND_ACK_SUA_NOT_RECEPTIVE);
232 nu_config_send_next(nsapi);
233 sndcp_data->nu->sn_ready_ind_pending = FALSE;
234 break;
235 case NU_ACK_SUA_NOT_RECEPTIVE:
236 SET_STATE(NU, NU_SEND_ACK_SUA_NOT_RECEPTIVE);
237 break;
238 case NU_SEND_ACK_SUA_NOT_RECEPTIVE:
239 SET_STATE(NU, NU_SEND_ACK_SUA_NOT_RECEPTIVE);
240 *data_count += octets;
241 sndcp_data->nu->sn_ready_ind_pending = FALSE;
242 break;
243 case NU_UNACK_SU_NOT_RECEPTIVE:
244 SET_STATE(NU, NU_SEND_UNACK_SU_NOT_RECEPTIVE);
245 break;
246 case NU_SEND_UNACK_SU_NOT_RECEPTIVE:
247 SET_STATE(NU, NU_SEND_UNACK_SU_NOT_RECEPTIVE);
248 *data_count += octets;
249 sndcp_data->nu->sn_unitready_ind_pending = FALSE;
250 break;
251 case NU_UNACK_SU_RECEPTIVE:
252 case NU_SEND_UNACK_SU_RECEPTIVE:
253 SET_STATE(NU, NU_SEND_UNACK_SU_NOT_RECEPTIVE);
254 nu_config_send_next(nsapi);
255 sndcp_data->nu->sn_unitready_ind_pending = FALSE;
256 break;
257 case NU_REC_SUA_NOT_RECEPTIVE:
258 SET_STATE(NU, NU_SEND_REC_SUA_NOT_RECEPTIVE);
259 break;
260 case NU_SEND_REC_SUA_NOT_RECEPTIVE:
261 break;
262 case NU_SUS_SUA_NOT_RECEPTIVE:
263 SET_STATE(NU, NU_SEND_SUS_SUA_NOT_RECEPTIVE);
264 break;
265 case NU_SEND_SUS_SUA_NOT_RECEPTIVE:
266 break;
267 case NU_SUS_SUA_RECEPTIVE:
268 SET_STATE(NU, NU_SEND_SUS_SUA_RECEPTIVE);
269 break;
270 case NU_SEND_SUS_SUA_RECEPTIVE:
271 break;
272
273 default:
274 TRACE_ERROR( "config prim SEND unexpected" );
275 break;
276 }
277
278
279 } /* nu_config_send() */
280
281 /*
282 +------------------------------------------------------------------------------
283 | Function : nu_config_send_next
284 +------------------------------------------------------------------------------
285 | Description : sends data with 'data_count' octets. State is not changed.
286 |
287 | Parameters : nsapi
288 | Pre : data_count > 0
289 |
290 +------------------------------------------------------------------------------
291 */
292 GLOBAL void nu_config_send_next (UBYTE nsapi)
293 {
294 BOOL ack = FALSE;
295 /*
296 * Index and number in pattern.
297 */
298 USHORT i = 0;
299 USHORT r = 0;
300 UBYTE sapi = 0;
301 USHORT k = 0;
302 UBYTE sapi_index = 0;
303 USHORT send_size = 0;
304 U16 ip_size = 0;
305 U32 length;
306 U32* data_count = NULL;
307 #ifdef _SNDCP_DTI_2_
308 T_desc2* desc = NULL,*help;
309 #else /*_SNDCP_DTI_2_*/
310 T_desc* desc = NULL;
311 #endif /*_SNDCP_DTI_2_*/
312
313 T_SN_DATA_REQ* sn_data_req = NULL;
314 T_SN_UNITDATA_REQ* sn_unitdata_req = NULL;
315
316 data_count = &sndcp_data->data_count[nsapi];
317 length = *data_count;
318
319 TRACE_FUNCTION( "nu_config_send_next" );
320
321 if (length == 0) {
322 sndcp_get_nsapi_ack(nsapi, &ack);
323 if (ack) {
324 SET_STATE(NU, NU_SEND_ACK_SUA_RECEPTIVE);
325 } else {
326 SET_STATE(NU, NU_SEND_UNACK_SU_RECEPTIVE);
327 }
328 return;
329 }
330
331 sndcp_get_nsapi_sapi(sndcp_data->nu->nsapi, &sapi);
332 sndcp_get_sapi_index(sapi, &sapi_index);
333
334 sndcp_data->nu = &sndcp_data->nu_base[nsapi];
335 sndcp_get_nsapi_ack(nsapi, &ack);
336
337 if (ack) {
338 send_size =
339 sndcp_data->sua_base[sapi_index].n201_i - SN_DATA_PDP_HDR_LEN_BIG;
340 TRACE_EVENT_P1("send_size: %d", send_size);
341 } else {
342 send_size =
343 sndcp_data->su_base[sapi_index].n201_u - SN_UNITDATA_PDP_HDR_LEN_BIG;
344 TRACE_EVENT_P1("send_size: %d", send_size);
345 }
346
347 /*
348 * The amount of data to be segmented
349 * shall be a multiple of N201_I or N201_U respectively
350 */
351 if(ack)
352 {
353 ip_size = 2 * sndcp_data->sua_base[sapi_index].n201_i + 100;
354 if (length > ip_size)
355 {
356 if ( sndcp_data->sua_base[sapi_index].n201_i < ip_size)
357 {
358 k = (ip_size - (ip_size %
359 sndcp_data->sua_base[sapi_index].n201_i))/
360 sndcp_data->sua_base[sapi_index].n201_i;
361 length = k * (sndcp_data->sua_base[sapi_index].n201_i)
362 -(k-1)- SN_DATA_PDP_HDR_LEN_BIG;
363 }
364 else
365 {
366 length = sndcp_data->sua_base[sapi_index].n201_i -
367 SN_DATA_PDP_HDR_LEN_BIG;
368 }
369 }
370 }
371 else
372 {
373 ip_size = 2 * sndcp_data->su_base[sapi_index].n201_u + 100;
374 if (length > ip_size)
375 {
376 if ( sndcp_data->su_base[sapi_index].n201_u < ip_size)
377 {
378 k = (ip_size - (ip_size %
379 sndcp_data->su_base[sapi_index].n201_u))/
380 sndcp_data->su_base[sapi_index].n201_u;
381 length = k * (sndcp_data->su_base[sapi_index].n201_u)
382 - (k * (SN_UNITDATA_PDP_HDR_LEN_BIG -1) +1);
383 }
384 else
385 {
386 length = sndcp_data->su_base[sapi_index].n201_u -
387 SN_UNITDATA_PDP_HDR_LEN_BIG;
388 }
389 }
390 }
391
392 TRACE_EVENT_P2("data to segment: %d, data to send: %d",
393 length, *data_count);
394
395 *data_count -= length;
396
397 /*
398 * Allocates small segments
399 */
400 k = (U16)(length / 100); /* Number of 'full' 100 byte descriptors*/
401 r = (U16)(length % 100); /* Number of rest bytes */
402
403 if(r > 0){
404 #ifdef _SNDCP_DTI_2_
405 MALLOC (desc, (USHORT)(sizeof(T_desc2) - 1 + r));
406 #else /*_SNDCP_DTI_2_*/
407 MALLOC (desc, (USHORT)(sizeof(T_desc) - 1 + r));
408 #endif /*_SNDCP_DTI_2_*/
409
410 desc->next = (ULONG)NULL;
411 desc->len = r;
412
413 #ifdef _SNDCP_DTI_2_
414 desc->offset = 0;
415 desc->size = r;
416 #endif
417 }
418
419 for ( i=0; i < k; i++){
420 /*
421 * Allocate memory for descriptor
422 */
423 MALLOC (help, (USHORT)(sizeof(T_desc2) - 1 + 100));
424
425
426
427
428 /*
429 * Fill descriptor control information.
430 */
431 help->next = (ULONG)desc;
432 help->len = 100;
433 help->offset = 0;
434 help->size = help->len;
435
436 desc = help;
437 } /* for k */
438
439
440
441 if (ack) {
442 #ifdef _SNDCP_DTI_2_
443 MALLOC(sn_data_req, sizeof(T_SN_DATA_REQ));
444 sn_data_req->desc_list2.first = (ULONG) desc;
445 sn_data_req->desc_list2.list_len = (U16)length;
446 #else /*_SNDCP_DTI_2_*/
447 PALLOC_DESC (sn_data_req, SN_DATA_REQ);
448 sn_data_req->desc_list.first = (ULONG) desc;
449 sn_data_req->desc_list.list_len = (U16)length;
450 #endif /*_SNDCP_DTI_2_*/
451
452
453 sn_data_req->nsapi = nsapi;
454 #ifdef SNDCP_UPM_INCLUDED
455 sn_data_req->p_id = DTI_PID_IP;
456 #else
457 sn_data_req->p_id = PPP_PID_IP;
458 #endif /*SNDCP_UPM_INCLUDED*/
459 /*
460 * Buffer the given N-PDU
461 */
462 nu_buffer_npdu(sndcp_data->nu->send_npdu_number_ack, sn_data_req);
463
464 sndcp_data->nu->send_npdu_number_ack =
465 (U8)((sndcp_data->nu->send_npdu_number_ack + 1) % MAX_NPDU_NUMBER_ACK);
466 sig_nu_sua_data_req(sn_data_req,
467 (U8)((sndcp_data->nu->send_npdu_number_ack - 1
468 + MAX_NPDU_NUMBER_ACK) % MAX_NPDU_NUMBER_ACK),
469 sn_data_req->nsapi,
470 sapi);
471
472
473 } else {
474 #ifdef _SNDCP_DTI_2_
475 MALLOC(sn_unitdata_req, sizeof(T_SN_UNITDATA_REQ));
476 sn_unitdata_req->desc_list2.first = (ULONG) desc;
477 sn_unitdata_req->desc_list2.list_len = (U16)length;
478 #else /*_SNDCP_DTI_2_*/
479 PALLOC_DESC (sn_unitdata_req, SN_UNITDATA_REQ);
480 sn_unitdata_req->desc_list.first = (ULONG) desc;
481 sn_unitdata_req->desc_list.list_len = (U16)length;
482 #endif /*_SNDCP_DTI_2_*/
483 sn_unitdata_req->nsapi = nsapi;
484 #ifdef SNDCP_UPM_INCLUDED
485 sn_unitdata_req->p_id = DTI_PID_IP;
486 #else
487 sn_unitdata_req->p_id = PPP_PID_IP;
488 #endif /*SNDCP_UPM_INCLUDED*/
489
490 sndcp_data->nu->send_npdu_number_unack =
491 (sndcp_data->nu->send_npdu_number_unack + 1) % MAX_NPDU_NUMBER_UNACK;
492 sig_nu_su_unitdata_req(sn_unitdata_req,
493 (U16)((sndcp_data->nu->send_npdu_number_unack - 1
494 + MAX_NPDU_NUMBER_UNACK) % MAX_NPDU_NUMBER_UNACK),
495 sndcp_data->nu->nsapi,
496 sapi);
497
498 }
499
500 } /* nu_config_send_next() */
501
502 #endif
503
504
505
506 /*
507 +------------------------------------------------------------------------------
508 | Function : nu_delete_npdu
509 +------------------------------------------------------------------------------
510 | Description : The function nu_delete_npdu() searches and deletes one
511 | buffered N-PDU.
512 | Parameter : nsapi, npdu_number.
513 | Pre : correct nu instance must be active, NPDU must exist.
514 |
515 +------------------------------------------------------------------------------
516 */
517 GLOBAL void nu_delete_npdu (UBYTE nsapi, UBYTE npdu_number)
518 {
519 T_NPDU_BUFFER* npdu_buffer = NULL;
520 T_NPDU_BUFFER* pre = NULL;
521 BOOL found = FALSE;
522
523 TRACE_FUNCTION( "nu_delete_npdu" );
524
525 /*
526 * Find the npdu.
527 */
528 npdu_buffer = sndcp_data->nu->first_buffered_npdu;
529 while (!found && npdu_buffer != NULL) {
530 if (sndcp_data->nu->nsapi == nsapi &&
531 npdu_buffer->npdu_number == npdu_number)
532 {
533 found = TRUE;
534 if (pre != NULL) {
535 pre->next = npdu_buffer->next;
536 }
537 } else {
538 pre = npdu_buffer;
539 npdu_buffer = npdu_buffer->next;
540 }
541 }
542 /*
543 * Delete it.
544 */
545 if (npdu_buffer != NULL) {
546 nu_delete(npdu_buffer);
547 }
548 } /* nu_delete_npdu() */
549
550
551
552 /*
553 +------------------------------------------------------------------------------
554 | Function : nu_delete_npdus
555 +------------------------------------------------------------------------------
556 | Description : The function nu_delete_npdus() deletes all buffered N-PDUs.
557 |
558 | Pre : The correct nu instance has to be "active".
559 |
560 +------------------------------------------------------------------------------
561 */
562 GLOBAL void nu_delete_npdus (void)
563 {
564 T_NPDU_BUFFER* help = NULL;
565
566 TRACE_FUNCTION( "nu_delete_npdus" );
567
568 while (sndcp_data->nu->first_buffered_npdu != NULL) {
569 help = sndcp_data->nu->first_buffered_npdu->next;
570 /*
571 * Delete the first one.
572 */
573 nu_delete(sndcp_data->nu->first_buffered_npdu);
574 /*
575 * Go to the next.
576 */
577 sndcp_data->nu->first_buffered_npdu = help;
578 }
579 sndcp_data->nu->next_resend = NULL;
580
581 } /* nu_delete_npdus() */
582
583
584 /*
585 +------------------------------------------------------------------------------
586 | Function : nu_init
587 +------------------------------------------------------------------------------
588 | Description : The function nu_init() ....
589 |
590 | Parameters :
591 |
592 +------------------------------------------------------------------------------
593 */
594 GLOBAL void nu_init (void)
595 {
596
597 UBYTE nsapi = 0;
598
599 TRACE_FUNCTION( "nu_init" );
600
601 sndcp_data->nu = & sndcp_data->nu_base[0];
602 INIT_STATE(NU_0, NU_UNACK_SU_RECEPTIVE);
603
604 sndcp_data->nu = & sndcp_data->nu_base[1];
605 INIT_STATE(NU_1, NU_UNACK_SU_RECEPTIVE);
606
607 sndcp_data->nu = & sndcp_data->nu_base[2];
608 INIT_STATE(NU_2, NU_UNACK_SU_RECEPTIVE);
609
610 sndcp_data->nu = & sndcp_data->nu_base[3];
611 INIT_STATE(NU_3, NU_UNACK_SU_RECEPTIVE);
612
613 sndcp_data->nu = & sndcp_data->nu_base[4];
614 INIT_STATE(NU_4, NU_UNACK_SU_RECEPTIVE);
615
616 sndcp_data->nu = & sndcp_data->nu_base[5];
617 INIT_STATE(NU_5, NU_UNACK_SU_RECEPTIVE);
618
619 sndcp_data->nu = & sndcp_data->nu_base[6];
620 INIT_STATE(NU_6, NU_UNACK_SU_RECEPTIVE);
621
622 sndcp_data->nu = & sndcp_data->nu_base[7];
623 INIT_STATE(NU_7, NU_UNACK_SU_RECEPTIVE);
624
625 sndcp_data->nu = & sndcp_data->nu_base[8];
626 INIT_STATE(NU_8, NU_UNACK_SU_RECEPTIVE);
627
628 sndcp_data->nu = & sndcp_data->nu_base[9];
629 INIT_STATE(NU_9, NU_UNACK_SU_RECEPTIVE);
630
631 sndcp_data->nu = & sndcp_data->nu_base[10];
632 INIT_STATE(NU_10, NU_UNACK_SU_RECEPTIVE);
633
634 sndcp_data->nu = & sndcp_data->nu_base[11];
635 INIT_STATE(NU_11, NU_UNACK_SU_RECEPTIVE);
636
637 sndcp_data->nu = & sndcp_data->nu_base[12];
638 INIT_STATE(NU_12, NU_UNACK_SU_RECEPTIVE);
639
640 sndcp_data->nu = & sndcp_data->nu_base[13];
641 INIT_STATE(NU_13, NU_UNACK_SU_RECEPTIVE);
642
643 sndcp_data->nu = & sndcp_data->nu_base[14];
644 INIT_STATE(NU_14, NU_UNACK_SU_RECEPTIVE);
645
646 sndcp_data->nu = & sndcp_data->nu_base[15];
647 INIT_STATE(NU_15, NU_UNACK_SU_RECEPTIVE);
648
649 for (nsapi = 0; nsapi < SNDCP_NUMBER_OF_NSAPIS; nsapi++) {
650 sndcp_data->nu = & sndcp_data->nu_base[nsapi];
651
652 sndcp_data->nu->nsapi = nsapi;
653 sndcp_data->nu->send_npdu_number_unack = 0;
654 sndcp_data->nu->send_npdu_number_ack = 0;
655 sndcp_data->nu->rec_npdu_number_ack = 0;
656 sndcp_data->nu->first_buffered_npdu = NULL;
657 sndcp_data->nu->next_resend = NULL;
658 sndcp_data->nu->sn_ready_ind_pending = FALSE;
659 sndcp_data->nu->sn_unitready_ind_pending = FALSE;
660 sndcp_data->nu->connection_is_opened = FALSE;
661 sndcp_data->nu->discard = FALSE;
662 sndcp_data->nu->discarded_data = 0;
663 sndcp_data->nu->sent_data = 0;
664 }
665 } /* nu_init() */
666
667
668 /*
669 +------------------------------------------------------------------------------
670 | Function : nu_ready_ind_if_nec
671 +------------------------------------------------------------------------------
672 | Description : Sends an SN_READY_IND if none is pending and DTI connection is
673 | opened.
674 |
675 | Parameters : nsapi
676 |
677 +------------------------------------------------------------------------------
678 */
679 GLOBAL void nu_ready_ind_if_nec (UBYTE nsapi)
680 {
681 BOOL used = FALSE;
682 USHORT stat = MG_IDLE;
683 UBYTE sapi = 0;
684
685 TRACE_FUNCTION( "nu_ready_ind_if_nec" );
686 #ifdef SNDCP_TRACE_ALL
687 if (sndcp_data->nu->sn_ready_ind_pending) {
688 TRACE_EVENT("sn_ready_ind_pending TRUE");
689 } else {
690 TRACE_EVENT("sn_ready_ind_pending FALSE");
691 }
692 if (sndcp_data->nu->connection_is_opened) {
693 TRACE_EVENT("connection_is_opened TRUE");
694 } else {
695 TRACE_EVENT("connection_is_opened FALSE");
696 }
697 #endif /* SNDCP_TRACE_ALL */
698
699 /*
700 * set service instance according to nsapi parameter
701 */
702 sndcp_data->nu = & sndcp_data->nu_base[nsapi];
703
704 sndcp_get_nsapi_sapi(nsapi, &sapi);
705 sndcp_get_sapi_state(sapi, &stat);
706 sndcp_is_nsapi_used(nsapi, &used);
707
708 if (! sndcp_data->nu->sn_ready_ind_pending
709 &&
710 sndcp_data->nu->connection_is_opened
711 &&
712 used
713 ) {
714
715 sndcp_data->nu->sn_ready_ind_pending = TRUE;
716
717 #ifdef SNDCP_UPM_INCLUDED
718 dti_start(sndcp_data->hDTI, 0, SNDCP_INTERFACE_UNACK, nsapi);
719 #else
720 dti_start(sndcp_data->hDTI, 0, SNDCP_INTERFACE_ACK, nsapi);
721 #endif
722 }
723
724 } /* nu_ready_ind_if_nec() */
725
726 /*
727 +------------------------------------------------------------------------------
728 | Function : nu_unitready_ind_if_nec
729 +------------------------------------------------------------------------------
730 | Description : Sends an SN_UNITREADY_IND if none is pending and DTI connection
731 | is opened.
732 |
733 | Parameters : nsapi
734 | Pre : The correct nu instance has to be "active".
735 |
736 +------------------------------------------------------------------------------
737 */
738 GLOBAL void nu_unitready_ind_if_nec (UBYTE nsapi)
739 {
740 BOOL used = FALSE;
741 USHORT stat = MG_IDLE;
742 UBYTE sapi = 0;
743
744 TRACE_FUNCTION( "nu_unitready_ind_if_nec" );
745 #ifdef SNDCP_TRACE_ALL
746 if (sndcp_data->nu->sn_unitready_ind_pending) {
747 TRACE_EVENT("sn_unitready_ind_pending TRUE");
748 } else {
749 TRACE_EVENT("sn_unitready_ind_pending FALSE");
750 }
751 if (sndcp_data->nu->connection_is_opened) {
752 TRACE_EVENT("connection_is_opened TRUE");
753 } else {
754 TRACE_EVENT("connection_is_opened FALSE");
755 }
756 #endif
757
758 sndcp_get_nsapi_sapi(nsapi, &sapi);
759 sndcp_get_sapi_state(sapi, &stat);
760 sndcp_is_nsapi_used(nsapi, &used);
761
762 if (! sndcp_data->nu->sn_unitready_ind_pending
763 &&
764 sndcp_data->nu->connection_is_opened
765 &&
766 used
767 ) {
768 #ifdef SNDCP_TRACE_ALL
769 TRACE_EVENT("trying to palloc/send SN_UNITREADY_IND");
770 #endif
771
772
773 sndcp_data->nu->sn_unitready_ind_pending = TRUE;
774
775 dti_start(sndcp_data->hDTI, 0, SNDCP_INTERFACE_UNACK, nsapi);
776
777 }
778 } /* nu_unitready_ind_if_nec() */