comparison src/g23m-fad/ppp/ppp_ptxs.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 :
4 | Modul :
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 PPP and implements all
18 | functions to handles the incoming process internal signals as
19 | described in the SDL-documentation (PTX-statemachine)
20 +-----------------------------------------------------------------------------
21 */
22
23 #define ENTITY_PPP
24
25 /*
26 * define for ptxs debug traces
27 */
28 /* #define PTXS_DEBUG */
29
30 /*==== INCLUDES =============================================================*/
31
32 #include "typedefs.h" /* to get Condat data types */
33 #include "vsi.h" /* to get a lot of macros */
34 #include "macdef.h" /* to get a lot of macros */
35 #include "custom.h" /* to get a lot of macros */
36 #include "gsm.h" /* to get a lot of macros */
37 /*lint -efile(766,cnf_ppp.h) */
38 #include "cnf_ppp.h" /* to get cnf-definitions */
39 /*lint -efile(766,mon_ppp.h) */
40 #include "mon_ppp.h" /* to get mon-definitions */
41 #include "prim.h" /* to get the definitions of used SAP and directions */
42 #include "dti.h" /* to get the DTILIB definitions */
43 #include "ppp.h" /* to get the global entity definitions */
44
45 #include "ppp_dti.h" /* to get the local DTILIB definitions */
46 #include "ppp_frxs.h" /* to get signal interface from frx */
47 #include "ppp_arbs.h" /* to get signal interface from arb */
48
49 #include "ppp_arbf.h" /* to get arb functions */
50
51 /*==== CONST ================================================================*/
52
53 /*==== LOCAL VARS ===========================================================*/
54
55 /*==== PRIVATE FUNCTIONS ====================================================*/
56
57 /*==== PUBLIC FUNCTIONS =====================================================*/
58
59
60
61 /*
62 +------------------------------------------------------------------------------
63 | Function : sig_arb_ptx_dead_mode_req
64 +------------------------------------------------------------------------------
65 | Description : Handles the internal signal SIG_ARB_PTX_DEAD_MODE_REQ. It sets
66 | the frame-reception-packet-transission direction to DEAD mode.
67 | That means these two services will not receive or send any more
68 | data.
69 |
70 | Parameters : no parameters
71 |
72 +------------------------------------------------------------------------------
73 */
74 GLOBAL void sig_arb_ptx_dead_mode_req ()
75 {
76 TRACE_ISIG( "sig_arb_ptx_dead_mode_req" );
77
78 ppp_data->ptx.ftx_buffer_state = PTX_FTX_BUFFER_FULL;
79 ppp_data->ptx.ptx_buffer_state = PTX_BUFFER_FULL;
80
81 switch( GET_STATE( PPP_SERVICE_PTX ) )
82 {
83 case PTX_READY:
84 case PTX_BLOCKED:
85 SET_STATE( PPP_SERVICE_PTX, PTX_DEAD );
86 sig_ptx_frx_stop_flow_req();
87 break;
88
89 default:
90 TRACE_ERROR( "SIG_ARB_PTX_DEAD_MODE_REQ unexpected" );
91 break;
92 }
93
94 /*
95 * set FRX to dead mode
96 */
97 sig_ptx_frx_dead_mode_req();
98
99 } /* sig_arb_ptx_dead_mode_req() */
100
101
102
103 /*
104 +------------------------------------------------------------------------------
105 | Function : sig_arb_ptx_ready_mode_req
106 +------------------------------------------------------------------------------
107 | Description : Handles the internal signal SIG_ARB_PTX_READY_MODE_REQ. It sets
108 | the frame-reception-packet-transission direction to READY mode.
109 | That means these two services will receive and send data.
110 |
111 | Parameters : no parameters
112 |
113 +------------------------------------------------------------------------------
114 */
115 GLOBAL void sig_arb_ptx_ready_mode_req ()
116 {
117 TRACE_ISIG( "sig_arb_ptx_ready_mode_req" );
118
119 switch( GET_STATE( PPP_SERVICE_PTX ) )
120 {
121 case PTX_BLOCKED:
122 SET_STATE( PPP_SERVICE_PTX, PTX_READY );
123 /*
124 * incoming data flow had not been stopped but redirected to
125 * ARB, so normally don't need to start, but it is possible that the data flow
126 * has been stopped bacause of ftx_buffer_full_ind
127 */
128 if(ppp_data->ptx.ftx_buffer_state EQ PTX_FTX_BUFFER_READY AND
129 ppp_data->ptx.ptx_buffer_state EQ PTX_BUFFER_READY )
130 {
131 sig_ptx_frx_start_flow_req();
132 }
133 #ifdef PTXS_DEBUG
134 else
135 {
136 TRACE_EVENT_P2("WARNING(READY_MODE_REQ): UL data flow wasn't started, %s(%d)", __FILE__, __LINE__);
137 }
138 #endif /* PTXS_DEBUG */
139 /*
140 * data is to be sent directly to the peer, and the dtilib buffer is
141 * full, so stop incoming data flow.
142 */
143 if(ppp_data->ptx.ptx_buffer_state EQ PTX_BUFFER_FULL)
144 {
145 sig_ptx_frx_stop_flow_req();
146 }
147 #ifdef PTXS_DEBUG
148 else
149 {
150 TRACE_EVENT_P2("INFO(READY_MODE_REQ): UL data flow wasn't stopped, %s(%d)", __FILE__, __LINE__);
151 }
152 #endif /* PTXS_DEBUG */
153 break;
154
155 case PTX_DEAD:
156 /*
157 * incoming data is to be redirected to ARB
158 */
159 SET_STATE( PPP_SERVICE_PTX, PTX_READY);
160 sig_ptx_frx_ready_mode_req();
161 if(ppp_data->ptx.ftx_buffer_state EQ PTX_FTX_BUFFER_READY AND
162 ppp_data->ptx.ptx_buffer_state EQ PTX_BUFFER_READY )
163 {
164 sig_ptx_frx_start_flow_req();
165 }
166 #ifdef PTXS_DEBUG
167 else
168 {
169 TRACE_EVENT_P2("WARNING(READY_MODE_REQ): UL data flow wasn't started, %s(%d)", __FILE__, __LINE__);
170 }
171 #endif /* PTXS_DEBUG */
172 break;
173
174 default:
175 TRACE_ERROR( "SIG_ARB_PTX_READY_MODE_REQ unexpected" );
176 break;
177 }
178 } /* sig_arb_ptx_ready_mode_req() */
179
180
181
182 /*
183 +------------------------------------------------------------------------------
184 | Function : sig_arb_ptx_blocked_mode_req
185 +------------------------------------------------------------------------------
186 | Description : Handles the internal signal SIG_ARB_PTX_BLOCKED_MODE_REQ. It
187 | sets the frame-reception-packet-transission direction to
188 | BLOCKED mode. That means PPP receives frames, but it dos not
189 | send packts.
190 |
191 | Parameters : no parameters
192 |
193 +------------------------------------------------------------------------------
194 */
195 GLOBAL void sig_arb_ptx_blocked_mode_req ()
196 {
197 TRACE_ISIG( "sig_arb_ptx_blocked_mode_req" );
198
199 switch( GET_STATE( PPP_SERVICE_PTX ) )
200 {
201 case PTX_DEAD:
202 /*
203 * Start incoming data flow - data will be sent to ARB.
204 */
205 SET_STATE( PPP_SERVICE_PTX, PTX_BLOCKED);
206 sig_ptx_frx_ready_mode_req();
207 if(ppp_data->ptx.ftx_buffer_state EQ PTX_FTX_BUFFER_READY)
208 {
209 sig_ptx_frx_start_flow_req();
210 }
211 #ifdef PTXS_DEBUG
212 else
213 {
214 TRACE_EVENT_P2("WARNING(BLOCKED_MODE_REQ): UL data flow wasn't started, %s(%d)", __FILE__, __LINE__);
215 }
216 #endif /* PTXS_DEBUG */
217 break;
218
219 case PTX_READY:
220 /*
221 * Do not stop incoming data flow, just redirect it to ARB
222 * Restart incoming data flow if it should be now redirected to ARB
223 */
224 SET_STATE( PPP_SERVICE_PTX, PTX_BLOCKED );
225 if(ppp_data->ptx.ftx_buffer_state EQ PTX_FTX_BUFFER_READY AND
226 ppp_data->ptx.ptx_buffer_state EQ PTX_BUFFER_FULL )
227 {
228 sig_ptx_frx_start_flow_req();
229 }
230 #ifdef PTXS_DEBUG
231 else
232 {
233 TRACE_EVENT_P2("WARNING(BLOCKED_MODE_REQ): UL data flow wasn't started, %s(%d)", __FILE__, __LINE__);
234 }
235 #endif /* PTXS_DEBUG */
236 break;
237
238 default:
239 TRACE_ERROR( "SIG_ARB_PTX_BLOCKED_MODE_REQ unexpected" );
240 break;
241 }
242 } /* sig_arb_ptx_blocked_mode_req() */
243
244
245
246 /*
247 +------------------------------------------------------------------------------
248 | Function : sig_arb_ptx_transparent_mode_req
249 +------------------------------------------------------------------------------
250 | Description : Handles the internal signal SIG_ARB_PTX_TRANSPARENT_MODE_REQ.
251 | It sets the frame-reception-packet-transission direction to
252 | TRANSPARENT mode. That means PPP receives frames and sends
253 | these frame transparent to the upper layer.
254 |
255 | Parameters : no parameters
256 |
257 +------------------------------------------------------------------------------
258 */
259 GLOBAL void sig_arb_ptx_transparent_mode_req ()
260 {
261 TRACE_ISIG( "sig_arb_ptx_transparent_mode_req" );
262
263 switch( GET_STATE( PPP_SERVICE_PTX ) )
264 {
265 case PTX_DEAD:
266 /*
267 * Set ptx to transparent mode and enable incoming data flow.
268 * The dti connection has been newly opened so that its buffers
269 * are empty and data can be received
270 */
271 SET_STATE( PPP_SERVICE_PTX, PTX_READY );
272 sig_ptx_frx_transparent_mode_req();
273 if(ppp_data->ptx.ftx_buffer_state EQ PTX_FTX_BUFFER_READY AND
274 ppp_data->ptx.ptx_buffer_state EQ PTX_BUFFER_READY )
275 {
276 sig_ptx_frx_start_flow_req();
277 }
278 #ifdef PTXS_DEBUG
279 else
280 {
281 TRACE_EVENT_P2("WARNING(TRANSP_MODE_REQ): UL data flow wasn't started, %s(%d)", __FILE__, __LINE__);
282 }
283 #endif /* PTXS_DEBUG */
284 break;
285
286 default:
287 TRACE_ERROR( "SIG_ARB_PTX_TRANSPARENT_MODE_REQ unexpected" );
288 break;
289 }
290 } /* sig_arb_ptx_transparent_mode_req() */
291
292 /*
293 +------------------------------------------------------------------------------
294 | Function : sig_frx_ptx_packet_ind
295 +------------------------------------------------------------------------------
296 | Description : Handles the internal signal SIG_FRX_PTX_PACKET_IND. The service
297 | FRX received a complete frame and forwards the encapsulated
298 | packet to PTX.
299 |
300 | Parameters : ptype - type of packet
301 | packet_len - length of packet
302 | packet - pointer to a generic data descriptor
303 |
304 +------------------------------------------------------------------------------
305 */
306 GLOBAL void sig_frx_ptx_packet_ind (USHORT ptype,
307 USHORT packet_len,
308 T_desc2* packet)
309 {
310 TRACE_ISIG( "sig_frx_ptx_packet_ind" );
311
312 switch( GET_STATE( PPP_SERVICE_PTX ) )
313 {
314 case PTX_READY:
315 switch(ptype)
316 {
317 case DTI_PID_CTCP:
318 case DTI_PID_UTCP:
319 /*
320 * if Van Jacobson Header Compression is not negotiated such packets
321 * will not be sent to upper layer
322 */
323 if(ppp_data->n_hc NEQ PPP_HC_VJ)
324 {
325 sig_ptx_arb_packet_ind(ptype, packet);
326 if(ppp_data->ptx.ftx_buffer_state EQ PTX_FTX_BUFFER_FULL)
327 {
328 sig_ptx_frx_stop_flow_req();
329 #ifdef PTXS_DEBUG
330 TRACE_EVENT_P2("INFO(PTX_PACKET_IND): UL data flow was stopped, %s(%d)", __FILE__, __LINE__);
331 #endif /* PTXS_DEBUG */
332 }
333 break;
334 }
335 /* fall through */
336 case DTI_PID_IP:
337 case DTI_PID_UOS:
338 /*
339 * send packet to upper layer
340 */
341 {
342 PALLOC_DESC2 (dti_data_ind, DTI2_DATA_IND);
343
344 dti_data_ind->desc_list2.list_len = packet_len;
345 dti_data_ind->desc_list2.first = (ULONG)packet;
346
347 /*
348 * Send the DTI data primitive
349 */
350
351 sig_any_dti_data_ind(ppp_data->ppphDTI,
352 dti_data_ind,
353 PPP_INSTANCE, PROT_LAYER,
354 PROT_CHANNEL,(UBYTE)ptype);
355 }
356 break;
357
358 default:
359 /*
360 * received packet is nether an IP packet nor
361 * a PPP frame (transparent mode), so we forward it to ARB
362 */
363 sig_ptx_arb_packet_ind(ptype, packet);
364 if(ppp_data->ptx.ftx_buffer_state EQ PTX_FTX_BUFFER_FULL)
365 {
366 sig_ptx_frx_stop_flow_req();
367 #ifdef PTXS_DEBUG
368 TRACE_EVENT_P2("INFO(PTX_PACKET_IND): UL data flow was stopped, %s(%d)", __FILE__, __LINE__);
369 #endif /* PTXS_DEBUG */
370 }
371 break;
372 }
373 break;
374
375 case PTX_BLOCKED:
376 /*
377 * In BLOCKED mode we forward each packet to ARB
378 */
379 sig_ptx_arb_packet_ind(ptype, packet);
380 if(ppp_data->ptx.ftx_buffer_state EQ PTX_FTX_BUFFER_FULL)
381 {
382 sig_ptx_frx_stop_flow_req();
383 #ifdef PTXS_DEBUG
384 TRACE_EVENT_P2("INFO(PTX_PACKET_IND): UL data flow was stopped, %s(%d)", __FILE__, __LINE__);
385 #endif /* PTXS_DEBUG */
386 }
387 break;
388
389 default:
390 TRACE_ERROR( "SIG_FRX_PTX_PACKET_IND unexpected" );
391 arb_discard_packet(packet);
392 break;
393 }
394 } /* sig_frx_ptx_packet_ind() */
395
396 /*
397 +------------------------------------------------------------------------------
398 | Function : sig_dti_ptx_tx_buffer_ready_ind
399 +------------------------------------------------------------------------------
400 | Description : Handles the signal sig_dti_ptx_tx_buffer_ready_ind
401 |
402 | Parameters : no parameter
403 |
404 +------------------------------------------------------------------------------
405 */
406
407 GLOBAL void sig_dti_ptx_tx_buffer_ready_ind ()
408 {
409 TRACE_FUNCTION( "sig_dti_ptx_tx_buffer_ready_ind" );
410
411 ppp_data->ptx.ptx_buffer_state = PTX_BUFFER_READY;
412
413 switch( GET_STATE( PPP_SERVICE_PTX ) )
414 {
415 case PTX_READY:
416 if(ppp_data->ptx.ftx_buffer_state EQ PTX_FTX_BUFFER_READY)
417 {
418 sig_ptx_frx_start_flow_req();
419 }
420 #ifdef PTXS_DEBUG
421 else
422 {
423 TRACE_EVENT_P2("WARNING(BUFFER_READY_IND): UL data flow wasn't started, %s(%d)", __FILE__, __LINE__);
424 }
425 #endif /* PTXS_DEBUG */
426 break;
427
428 case PTX_BLOCKED:
429 case PTX_DEAD:
430 /* wait for sig_arb_ptx_blocked/ready/transparent_mode_req */
431 break;
432
433 default:
434 TRACE_ERROR( "DTI signal unexpected" );
435 break;
436 }
437 } /* sig_dti_ptx_tx_buffer_ready_ind() */
438
439
440
441 /*
442 +------------------------------------------------------------------------------
443 | Function : sig_dti_ptx_tx_buffer_full_ind
444 +------------------------------------------------------------------------------
445 | Description : This function handle the signal sig_dti_ptx_tx_buffer_full_ind
446 |
447 | Parameters : no parameter
448 |
449 +------------------------------------------------------------------------------
450 */
451 GLOBAL void sig_dti_ptx_tx_buffer_full_ind ()
452 {
453 TRACE_FUNCTION ("sig_dti_ptx_tx_buffer_full_ind()");
454
455 ppp_data->ptx.ptx_buffer_state = PTX_BUFFER_FULL;
456
457 switch( GET_STATE( PPP_SERVICE_PTX ) )
458 {
459 case PTX_READY:
460 sig_ptx_frx_stop_flow_req();
461 break;
462
463 case PTX_DEAD:
464 break;
465
466 case PTX_BLOCKED:
467 /*
468 * do not stop incoming data flow here since data is not sent
469 * to the peer but to ARB, not having to be buffered in dtilib
470 */
471 break;
472
473 default:
474 TRACE_ERROR("Wrong state");
475 break;
476 }
477 } /* sig_dti_ptx_tx_buffer_full_ind() */
478
479
480 /*
481 +------------------------------------------------------------------------------
482 | Function : sig_ftx_ptx_tx_buffer_full_ind
483 +------------------------------------------------------------------------------
484 | Description : This function handle the signal sig_ftx_ptx_tx_buffer_full_ind
485 |
486 | Parameters : no parameter
487 |
488 +------------------------------------------------------------------------------
489 */
490 GLOBAL void sig_ftx_ptx_buffer_full_ind ()
491 {
492 TRACE_FUNCTION ("sig_ftx_ptx_tx_buffer_full_ind()");
493
494 ppp_data->ptx.ftx_buffer_state = PTX_FTX_BUFFER_FULL;
495
496 } /* sig_ftx_ptx_tx_buffer_full_ind() */
497
498
499 /*
500 +------------------------------------------------------------------------------
501 | Function : sig_ftx_ptx_tx_buffer_ready_ind
502 +------------------------------------------------------------------------------
503 | Description : This function handle the signal sig_ftx_ptx_tx_buffer_ready_ind
504 |
505 | Parameters : no parameter
506 |
507 +------------------------------------------------------------------------------
508 */
509 GLOBAL void sig_ftx_ptx_buffer_ready_ind ()
510 {
511 TRACE_FUNCTION ("sig_ftx_ptx_tx_buffer_ready_ind()");
512
513 ppp_data->ptx.ftx_buffer_state = PTX_FTX_BUFFER_READY;
514
515 switch( GET_STATE( PPP_SERVICE_PTX ) )
516 {
517 case PTX_READY:
518 if(ppp_data->ptx.ptx_buffer_state EQ PTX_BUFFER_READY)
519 {
520 sig_ptx_frx_start_flow_req();
521 }
522 #ifdef PTXS_DEBUG
523 else
524 {
525 TRACE_EVENT_P2("WARNING(FTX_BUFFER_READY_IND): UL data flow wasn't started, %s(%d)", __FILE__, __LINE__);
526 }
527 #endif /* PTXS_DEBUG */
528 break;
529
530 case PTX_BLOCKED:
531 /*
532 * Start data flow also if PTX buffer is full,
533 * because the data will be redirected to ARB.
534 */
535 sig_ptx_frx_start_flow_req();
536 break;
537
538 case PTX_DEAD:
539 /* wait for sig_arb_ptx_blocked/ready/transparent_mode_req */
540 break;
541
542 default:
543 TRACE_ERROR( "DTI signal unexpected" );
544 break;
545 }
546
547
548 } /* sig_ftx_ptx_tx_buffer_ready_ind() */
549
550