annotate src/g23m-fad/ppp/ppp_ftxf.c @ 174:90eb61ecd093

src/g23m-fad: initial import from TCS3.2/LoCosto
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 12 Oct 2016 05:40:46 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
174
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 +-----------------------------------------------------------------------------
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 | Project :
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 | Modul :
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 +-----------------------------------------------------------------------------
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 | Copyright 2002 Texas Instruments Berlin, AG
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 | All rights reserved.
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 |
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 | This file is confidential and a trade secret of Texas
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 | Instruments Berlin, AG
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 | The receipt of or possession of this file does not convey
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 | any rights to reproduce or disclose its contents or to
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 | manufacture, use, or sell anything it may describe, in
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 | whole, or in part, without the specific written consent of
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 | Texas Instruments Berlin, AG.
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 +-----------------------------------------------------------------------------
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 | Purpose : This modul is part of the entity PPP and implements all
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 | procedures and functions as described in the
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 | SDL-documentation (FTX-statemachine)
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 +-----------------------------------------------------------------------------
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 #define ENTITY_PPP
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 /*==== INCLUDES =============================================================*/
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 #include "typedefs.h" /* to get Condat data types */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 #include "vsi.h" /* to get a lot of macros */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 #include "macdef.h" /* to get a lot of macros */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 #include "custom.h" /* to get a lot of macros */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 /*lint -efile(766,gsm.h) */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 #include "gsm.h" /* to get a lot of macros */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 /*lint -efile(766,cnf_ppp.h) */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 #include "cnf_ppp.h" /* to get cnf-definitions */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 /*lint -efile(766,mon_ppp.h) */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 #include "mon_ppp.h" /* to get mon-definitions */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 #include "prim.h" /* to get the definitions of used SAP and directions */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 #include "dti.h" /* to get the DTILIB definitions */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 #include "ppp.h" /* to get the global entity definitions */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 #include "ppp_arbf.h" /* to get function interface from arb */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 /*==== CONST ================================================================*/
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 /*==== LOCAL VARS ===========================================================*/
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 /*==== PRIVATE FUNCTIONS ====================================================*/
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 /*==== PUBLIC FUNCTIONS =====================================================*/
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 #ifndef PPP_INT_RAM
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 /*
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 +------------------------------------------------------------------------------
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 | Function : ftx_init
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 +------------------------------------------------------------------------------
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 | Description : The function ftx_init() initializes Frame Transmit (FTX)
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 |
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 | Parameters : no parameters
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 |
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 +------------------------------------------------------------------------------
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 GLOBAL void ftx_init ()
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 USHORT i;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 TRACE_FUNCTION( "ftx_init" );
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 ppp_data->ftx.acfc = PPP_ACFC_DEFAULT;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 ppp_data->ftx.pfc = PPP_PFC_DEFAULT;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 /*
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 * inititialise ACCMTAB
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 for(i=0;i<=255;i++)
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 if(i<0x20)
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 ppp_data->ftx.accmtab[i] = (PPP_ACCM_DEFAULT & (1UL << i)) ? 0xFF : 0x00;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 else if((i EQ PPP_HDLC_FLAG) ||
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 (i EQ PPP_HDLC_ESCAPE) ||
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 (i EQ PPP_ASCII_DEL))
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 ppp_data->ftx.accmtab[i] = 0xFF;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 else
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 ppp_data->ftx.accmtab[i] = 0x00;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 INIT_STATE( PPP_SERVICE_FTX , FTX_DEAD );
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 } /* ftx_init() */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 #endif /* PPP_INT_RAM */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 #ifndef PPP_FLASH_ROM
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 /*
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 +------------------------------------------------------------------------------
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 | Function : ftx_get_frame
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 +------------------------------------------------------------------------------
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 | Description : The function ftx_get_frame() puts the given packet into a HDLC
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 | frame. A FCS is calculated and put at the the end of the
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 | packet. After that every byte is examined and preceeded with an
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 | escape character when certain condiitions are met.
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 |
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 | This function has been optimized - FCS calculation and escaping
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 | are done in the same loop.
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 |
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 | Parameters : ptype - packet type
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 | packet - pointer to a generic data descriptor
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 | ptr_frame - returns a list of generic data descriptors
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 |
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 +------------------------------------------------------------------------------
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 GLOBAL void ftx_get_frame (USHORT ptype, T_desc2* packet, T_desc_list2* ptr_frame)
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 T_desc2 *temp_desc1, *temp_desc2;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 USHORT calc_fcs;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 USHORT i;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 UBYTE currentByte;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 UBYTE escape;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 TRACE_FUNCTION( "ftx_get_frame" );
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 /*
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 * create a new descriptor for address, control and protocol field and put
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 * it in front of the linked descriptor list
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 /*
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 * 1 octet address field
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 * 1 octet control field
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 * 2 octets protocol field (uncompressed)
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 *----------
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 * 4 octets
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 MALLOC (temp_desc1, (USHORT)(sizeof(T_desc2) - 1 + 4));
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 temp_desc1->next = (ULONG)packet;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 packet = temp_desc1;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 packet->len = 0;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 /*
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 * if no address and control field compression add both
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 * in LCP packets we need always address and control field
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 if((ppp_data->ftx.acfc EQ FALSE) ||
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 (ptype EQ DTI_PID_LCP))
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 packet->buffer[packet->len] = 0xff;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 packet->len++;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 packet->buffer[packet->len] = 0x03;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 packet->len++;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 /*
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 * if no protocol field compression add most significant octet
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 * of the protocol field
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 * in LCP packets we need always uncompressed protocol field
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 if((ppp_data->ftx.pfc EQ FALSE) ||
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 (ptype > 0x00ff) ||
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 (ptype EQ DTI_PID_LCP))
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 packet->buffer[packet->len] = (UBYTE)(ptype >> 8);
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 packet->len++;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 /*
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 * add protocol field least significant octet
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 packet->buffer[packet->len] = (UBYTE)(ptype & 0xff);
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 packet->len++;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 /*
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 * create complete frame
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 * use async-control-character-map and copy the packet into descriptor with
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 * a size of FTX_GET_DESC_SIZE
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 MALLOC (temp_desc1, (USHORT)(sizeof(T_desc2) - 1 + FTX_GET_DESC_SIZE));
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 temp_desc1->next = (ULONG)NULL;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181 ptr_frame->first = (ULONG)temp_desc1;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
184 /*
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185 * reset ptr_frame->list_len, it will be incremented by temp_desc1->len
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186 * when the packet is completely processed, at the end it will contain
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187 * the length of the whole frame in bytes
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
188 */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189 ptr_frame->list_len = 0;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192 /*
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 * insert HDLC-Flag - to mark the start of the frame
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194 */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195 temp_desc1->len = 1;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196 temp_desc1->size = 1;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 temp_desc1->offset = 1;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198 temp_desc1->buffer[0] = PPP_HDLC_FLAG;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 escape=FALSE;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
200
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
201
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
202 /*
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
203 * init FCS
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
204 */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205 calc_fcs = PPP_INITFCS;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208 /*
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209 * ATTENTION: the following two while loops contain equivalent
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210 * code - if you edit the code make sure you edit BOTH loops
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
211 */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
212 if(ptype EQ DTI_PID_LCP)
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
213 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
214 while(packet NEQ NULL)
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
215 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
216 i=0;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
217 while(i < packet->len)
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
218 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
219 currentByte = packet->buffer[i];
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
220
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
221 if(escape EQ TRUE)
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
222 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
223 temp_desc1->buffer[temp_desc1->len] = currentByte ^ 0x20;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
224
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
225 calc_fcs=(calc_fcs >> 8) ^
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
226 ppp_data->fcstab[(calc_fcs ^ currentByte) & 0xff];
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
227
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
228 escape=FALSE;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
229 i++;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
230 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
231
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
232 /*
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
233 * In LCP packets we escape ALL characters below 0x20.
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
234 * In addition to that PPP_HDLC_FLAG, PPP_HDLC_ESCAPE,
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
235 * PPP_ASCII_DEL are escaped too. These characters are marked in
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
236 * in the ACCM table
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
237 */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
238 else if((currentByte < 0x20) || ppp_data->ftx.accmtab[currentByte])
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
239 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
240 temp_desc1->buffer[temp_desc1->len] = PPP_HDLC_ESCAPE;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
241 escape = TRUE;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
242 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
243
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
244 else
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
245 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
246 temp_desc1->buffer[temp_desc1->len] = currentByte;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
247
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
248 calc_fcs=(calc_fcs >> 8) ^
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
249 ppp_data->fcstab[(calc_fcs ^ currentByte) & 0xff];
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
250
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
251 i++;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
252 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
253
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
254 temp_desc1->len++;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
255
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
256 if(temp_desc1->len >= FTX_GET_DESC_SIZE)
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
257 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
258 ptr_frame->list_len +=temp_desc1->len;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
259
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
260 temp_desc2=temp_desc1;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
261 MALLOC (temp_desc1,
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
262 (USHORT)(sizeof(T_desc2) - 1 + FTX_GET_DESC_SIZE));
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
263
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
264 temp_desc1->len=0;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
265 temp_desc1->next = (ULONG)NULL;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
266
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
267 temp_desc2->next=(ULONG)temp_desc1;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
268 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
269 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
270
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
271 temp_desc2=packet;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
272 packet=(T_desc2*)packet->next;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
273 MFREE(temp_desc2);
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
274 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
275 ptr_frame->list_len +=temp_desc1->len;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
276 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
277 else
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
278 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
279 while(packet NEQ NULL)
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
280 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
281 i=0;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
282 while(i < packet->len)
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
283 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
284 currentByte = packet->buffer[i];
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
285
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
286 if(escape EQ TRUE)
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
287 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
288 temp_desc1->buffer[temp_desc1->len] = currentByte ^ 0x20;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
289
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
290 calc_fcs=(calc_fcs >> 8) ^
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
291 ppp_data->fcstab[(calc_fcs ^ currentByte) & 0xff];
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
292
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
293 escape=FALSE;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
294 i++;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
295 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
296
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
297 /*
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
298 * In packets other than LCP we escape only those characters
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
299 * below 0x20 that are marked in the ACCM table.
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
300 * In addition to that PPP_HDLC_FLAG, PPP_HDLC_ESCAPE,
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
301 * PPP_ASCII_DEL are escaped too. These characters are marked in
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
302 * in the same table.
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
303 */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
304 else if(ppp_data->ftx.accmtab[currentByte])
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
305 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
306 temp_desc1->buffer[temp_desc1->len] = PPP_HDLC_ESCAPE;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
307 escape = TRUE;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
308 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
309
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
310 else
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
311 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
312 temp_desc1->buffer[temp_desc1->len] = currentByte;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
313
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
314 calc_fcs=(calc_fcs >> 8) ^
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
315 ppp_data->fcstab[(calc_fcs ^ currentByte) & 0xff];
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
316
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
317 i++;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
318 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
319
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
320 temp_desc1->len++;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
321
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
322 if(temp_desc1->len >= FTX_GET_DESC_SIZE)
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
323 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
324 ptr_frame->list_len +=temp_desc1->len;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
325
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
326 temp_desc2=temp_desc1;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
327 MALLOC (temp_desc1,
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
328 (USHORT)(sizeof(T_desc2) - 1 + FTX_GET_DESC_SIZE));
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
329 temp_desc1->len=0;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
330 temp_desc1->next = (ULONG)NULL;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
331
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
332 temp_desc2->next=(ULONG)temp_desc1;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
333 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
334 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
335
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
336 temp_desc2=packet;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
337 packet=(T_desc2*)packet->next;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
338 MFREE(temp_desc2);
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
339 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
340 ptr_frame->list_len +=temp_desc1->len;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
341 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
342
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
343 /*
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
344 * finish FCS calculation
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
345 */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
346 calc_fcs ^= 0xffff;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
347
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
348
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
349 /*
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
350 * create a new descriptor for FCS and HDLC-Flag
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
351 * put the descriptor at the end of the descriptor list
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
352 *
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
353 * FCS must be escaped too, allocate two bytes more - just in case
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
354 * 2 for FCS, 2 for PPP_HDLC_ESCAPE, 1 for PPP_HDLC_FLAG
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
355 *
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
356 */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
357 if(temp_desc1->len + 5 >= FTX_GET_DESC_SIZE)
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
358 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
359 MALLOC (temp_desc2, (USHORT)(sizeof(T_desc2) - 1 + 5));
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
360 temp_desc2->len = 0;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
361 temp_desc2->size = 0;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
362 temp_desc2->offset = 0;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
363 temp_desc2->next = (ULONG)NULL;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
364
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
365 temp_desc1->next = (ULONG)temp_desc2;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
366 temp_desc1 = temp_desc2;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
367 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
368
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
369 /*
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
370 * insert the FCS, escape when necessary
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
371 */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
372 #ifdef _SIMULATION_
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
373 temp_desc1->buffer[temp_desc1->len]=(UBYTE)(PPP_GOODFCS >> 8);
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
374 temp_desc1->buffer[temp_desc1->len+1]=(UBYTE)(PPP_GOODFCS & 0x00ff);
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
375 temp_desc1->len += 2;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
376 ptr_frame->list_len += 2;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
377 #else /* _SIMULATION_ */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
378 /*
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
379 * least significant octet first
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
380 */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
381 if(ptype EQ DTI_PID_LCP)
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
382 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
383 currentByte = (UBYTE)(calc_fcs & 0x00ff);
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
384 if((currentByte < 0x20) || ppp_data->ftx.accmtab[currentByte])
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
385 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
386 temp_desc1->buffer[temp_desc1->len] = PPP_HDLC_ESCAPE;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
387 temp_desc1->buffer[temp_desc1->len+1] = currentByte ^ 0x20;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
388 temp_desc1->len += 2;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
389 ptr_frame->list_len += 2;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
390 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
391 else
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
392 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
393 temp_desc1->buffer[temp_desc1->len] = currentByte;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
394 temp_desc1->len++;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
395 ptr_frame->list_len++;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
396 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
397
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
398 currentByte = (UBYTE)(calc_fcs >> 8);
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
399 if((currentByte < 0x20) || ppp_data->ftx.accmtab[currentByte])
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
400 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
401 temp_desc1->buffer[temp_desc1->len] = PPP_HDLC_ESCAPE;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
402 temp_desc1->buffer[temp_desc1->len+1] = currentByte ^ 0x20;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
403 temp_desc1->len += 2;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
404 ptr_frame->list_len += 2;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
405 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
406 else
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
407 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
408 temp_desc1->buffer[temp_desc1->len] = currentByte;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
409 temp_desc1->len++;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
410 ptr_frame->list_len++;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
411 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
412 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
413 else
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
414 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
415 currentByte = (UBYTE)(calc_fcs & 0x00ff);
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
416 if(ppp_data->ftx.accmtab[currentByte])
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
417 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
418 temp_desc1->buffer[temp_desc1->len] = PPP_HDLC_ESCAPE;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
419 temp_desc1->buffer[temp_desc1->len+1] = currentByte ^ 0x20;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
420 temp_desc1->len += 2;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
421 ptr_frame->list_len += 2;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
422 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
423 else
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
424 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
425 temp_desc1->buffer[temp_desc1->len] = currentByte;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
426 temp_desc1->len++;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
427 ptr_frame->list_len++;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
428 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
429
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
430 currentByte = (UBYTE)(calc_fcs >> 8);
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
431 if(ppp_data->ftx.accmtab[currentByte])
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
432 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
433 temp_desc1->buffer[temp_desc1->len] = PPP_HDLC_ESCAPE;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
434 temp_desc1->buffer[temp_desc1->len+1] = currentByte ^ 0x20;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
435 temp_desc1->len += 2;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
436 ptr_frame->list_len += 2;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
437 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
438 else
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
439 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
440 temp_desc1->buffer[temp_desc1->len] = currentByte;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
441 temp_desc1->len++;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
442 ptr_frame->list_len++;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
443 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
444 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
445
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
446 #endif /* _SIMULATION_ */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
447
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
448 /*
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
449 * insert HDLC-Flag - to mark the start of the frame
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
450 */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
451 temp_desc1->buffer[temp_desc1->len] = PPP_HDLC_FLAG;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
452 temp_desc1->len++;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
453 temp_desc1->size = temp_desc1->len;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
454 ptr_frame->list_len++;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
455
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
456
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
457 } /* ftx_get_frame() */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
458 #endif /* PPP_FLASH_ROM */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
459
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
460
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
461
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
462 #ifndef PPP_INT_RAM
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
463 /*
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
464 +------------------------------------------------------------------------------
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
465 | Function : ftx_check_frame
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
466 +------------------------------------------------------------------------------
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
467 | Description : The function ftx_check_frame() checks for flag at begin and end
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
468 | of the frame and calculates length of frame.
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
469 |
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
470 | Parameters : ptr_frame - gives just a frame and returns a frame with length
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
471 |
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
472 +------------------------------------------------------------------------------
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
473 */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
474 GLOBAL void ftx_check_frame (T_desc_list2* ptr_frame)
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
475 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
476 T_desc2* frame;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
477 T_desc2* temp_desc;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
478 UBYTE last_byte;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
479
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
480 TRACE_FUNCTION( "ftx_check_frame" );
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
481
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
482 frame = (T_desc2*)ptr_frame->first;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
483
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
484 while((frame) && (frame->len EQ 0))
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
485 frame = (T_desc2*)frame->next;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
486
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
487 if(frame)
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
488 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
489 /*
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
490 * if the first character isnt the HDLC flag then
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
491 * create a new first data descriptor containing just the HDLC flag
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
492 */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
493 if(frame->buffer[0] NEQ PPP_HDLC_FLAG)
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
494 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
495 MALLOC (frame, (USHORT)(sizeof(T_desc2) - 1 + 1));
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
496 frame->next = ptr_frame->first;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
497 frame->len = 1;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
498 frame->buffer[0] = PPP_HDLC_FLAG;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
499 ptr_frame->first = (ULONG)frame;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
500 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
501 /*
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
502 * search for the last character and if it isnt the HDLC flag then
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
503 * create a new last data descriptor containing just the HDLC flag.
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
504 * calculate length of whole data.
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
505 */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
506 ptr_frame->list_len = 0;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
507 for(frame = (T_desc2*)ptr_frame->first;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
508 frame;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
509 frame = (T_desc2*)frame->next)
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
510 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
511 if(frame->len)
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
512 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
513 ptr_frame->list_len+= frame->len;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
514 last_byte = frame->buffer[frame->len - 1];
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
515 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
516 temp_desc = frame;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
517 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
518 if(last_byte NEQ PPP_HDLC_FLAG) /*lint !e644 last_byte may not have been initialized */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
519 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
520 MALLOC (frame, (USHORT)(sizeof(T_desc2) - 1 + 1));
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
521 frame->next = (ULONG)NULL;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
522 frame->len = 1;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
523 frame->buffer[0] = PPP_HDLC_FLAG;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
524 temp_desc->next = (ULONG)frame; /*lint !e771 temp_desc conceivably not initialized */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
525 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
526 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
527 else
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
528 {
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
529 /*
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
530 * free the empty frame
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
531 */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
532 arb_discard_packet((T_desc2*)ptr_frame->first);
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
533 ptr_frame->first = (ULONG)NULL;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
534 ptr_frame->list_len = 0;
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
535 }
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
536 } /* ftx_check_frame() */
90eb61ecd093 src/g23m-fad: initial import from TCS3.2/LoCosto
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
537 #endif /* PPP_INT_RAM */