comparison src/g23m-gprs/llc/llc_uitxf.c @ 183:219afcfc6250

src/g23m-gprs: initial import from TCS3.2/LoCosto
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 13 Oct 2016 04:24:13 +0000
parents
children
comparison
equal deleted inserted replaced
182:f02d0a0e1849 183:219afcfc6250
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 LLC and implements all
18 | procedures and functions as described in the
19 | SDL-documentation (UITX-statemachine)
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef LLC_UITXF_C
24 #define LLC_UITXF_C
25 #endif
26
27 #define ENTITY_LLC
28
29 /*==== INCLUDES =============================================================*/
30
31 #include "typedefs.h" /* to get Condat data types */
32 #include "vsi.h" /* to get a lot of macros */
33 #include "macdef.h"
34 #include "gprs.h"
35 #include "gsm.h" /* to get a lot of macros */
36 #include "cnf_llc.h" /* to get cnf-definitions */
37 #include "mon_llc.h" /* to get mon-definitions */
38 #include "prim.h" /* to get the definitions of used SAP and directions */
39 #include "llc.h" /* to get the global entity definitions */
40
41 /*==== CONST ================================================================*/
42
43 /*==== LOCAL VARS ===========================================================*/
44
45 /*==== PRIVATE FUNCTIONS ====================================================*/
46
47 /*==== PUBLIC FUNCTIONS =====================================================*/
48
49
50
51 /*
52 +------------------------------------------------------------------------------
53 | Function : uitx_init
54 +------------------------------------------------------------------------------
55 | Description : This procedure initialises all necessary variables of
56 | ui_frames_tx for all SAPIs.
57 |
58 | Parameters :
59 |
60 +------------------------------------------------------------------------------
61 */
62 GLOBAL void uitx_init (void)
63 {
64 TRACE_FUNCTION( "uitx_init" );
65
66 /*
67 * Initialise every incarnation of UITX with state TLLI_UNASSIGNED_NOT_READY.
68 */
69 SWITCH_SERVICE (llc, uitx, 0);
70 INIT_STATE (UITX_0, UITX_TLLI_UNASSIGNED_NOT_READY);
71
72 SWITCH_SERVICE (llc, uitx, 1);
73 INIT_STATE (UITX_1, UITX_TLLI_UNASSIGNED_NOT_READY);
74
75 SWITCH_SERVICE (llc, uitx, 2);
76 INIT_STATE (UITX_2, UITX_TLLI_UNASSIGNED_NOT_READY);
77
78 SWITCH_SERVICE (llc, uitx, 3);
79 INIT_STATE (UITX_3, UITX_TLLI_UNASSIGNED_NOT_READY);
80
81 SWITCH_SERVICE (llc, uitx, 4);
82 INIT_STATE (UITX_4, UITX_TLLI_UNASSIGNED_NOT_READY);
83
84 SWITCH_SERVICE (llc, uitx, 5);
85 INIT_STATE (UITX_5, UITX_TLLI_UNASSIGNED_NOT_READY);
86
87 return;
88 } /* uitx_init() */
89
90
91
92 /*
93 +------------------------------------------------------------------------------
94 | Function : uitx_init_sapi
95 +------------------------------------------------------------------------------
96 | Description : This procedure initialises all necessary variables of
97 | ui_frames_tx for the given SAPI.
98 |
99 | Parameters :
100 |
101 +------------------------------------------------------------------------------
102 */
103 GLOBAL void uitx_init_sapi (void)
104 {
105 TRACE_FUNCTION( "uitx_init_sapi" );
106
107 /*
108 * <R.LLC.TLLI_ASS.A.007>, <R.LLC.TLLI_ASS.A.008>
109 */
110 llc_data->uitx->vu = 0;
111
112 return;
113 } /* uitx_init_sapi() */
114
115
116
117 /*
118 +------------------------------------------------------------------------------
119 | Function : uitx_build_ui_header
120 +------------------------------------------------------------------------------
121 | Description : This procedure inserts the address and control field of an UI
122 | frame in the given sdu. sdu already contains the user data.
123 | The variable cipher indicates the setting of the E bit. The
124 | variable relclass contains the information if the frame shall
125 | be transmitted in protected or unprotected mode, which is
126 | needed in this function to set the PM bit properly.
127 |
128 | Parameters : sdu - a valid pointer to a T_sdu variable, must contain enough
129 | spare octets at the beginning for the LLC header fields
130 | (address + control field = 3 octets for UI frames)
131 | cr_bit - C/R bit
132 | sapi - a valid SAPI for unacknowledged operation
133 | nu - N(U)
134 | cipher - ciphering indicator (see LL SAP: LL-UNITDATA-REQ)
135 | relclass - QoS reliability class (see LL SAP), must not be set
136 | to LL_RELCLASS_SUB
137 |
138 +------------------------------------------------------------------------------
139 */
140 GLOBAL void uitx_build_ui_header
141 (
142 #ifdef LL_DESC
143 T_desc_list3* desc_list3,
144 #else
145 T_sdu *sdu,
146 #endif
147 T_BIT cr_bit,
148 UBYTE sapi,
149 T_FRAME_NUM nu,
150 UBYTE cipher,
151 UBYTE relclass
152 )
153
154 {
155
156 #ifdef LL_DESC
157 T_desc3 *desc3 = (T_desc3*)(desc_list3->first);
158 UBYTE *buf = (UBYTE*)(desc3->buffer);
159 #endif
160
161 TRACE_FUNCTION( "uitx_build_ui_header" );
162
163 #ifdef LL_DESC
164 /*
165 * set new offset (3 octets earlier) and new length of desc_list3
166 */
167 desc3->offset -= UI_CTRL_MIN_OCTETS;
168 desc3->len += UI_CTRL_MIN_OCTETS;
169 desc_list3->list_len += UI_CTRL_MIN_OCTETS;
170 /*
171 * insert address field (PD is always 0)
172 */
173 buf[desc3->offset] = ((UBYTE)cr_bit << 6) | sapi;
174
175 /*
176 * insert 1st octet of control field
177 * (UI code + 3 most significant bits of N(U))
178 */
179 buf[desc3->offset+1]= 0xC0 | (UBYTE)(nu >> 6);
180
181 /*
182 * insert 2nd octet of control field
183 * (6 least significant bits of N(U) + E bit + PM bit)
184 */
185 buf[desc3->offset+2]= (((UBYTE)nu & 0x3F) << 2);
186
187 if (cipher == LL_CIPHER_ON)
188 {
189 buf[desc3->offset+2] |= 0x02;
190 }
191
192 /*
193 * all reliability classes except LL_NO_REL request protected data
194 */
195 if (relclass != LL_NO_REL)
196 {
197 buf[desc3->offset+2] |= 0x01;
198 }
199
200 return;
201
202 #else
203
204 /*
205 * set new offset (3 octets earlier) and new length of sdu
206 */
207 sdu->o_buf -= UI_CTRL_MIN_OCTETS * 8;
208 sdu->l_buf += UI_CTRL_MIN_OCTETS * 8;
209
210 /*
211 * insert address field (PD is always 0)
212 */
213 sdu->buf[sdu->o_buf/8] = ((UBYTE)cr_bit << 6) | sapi;
214
215 /*
216 * insert 1st octet of control field
217 * (UI code + 3 most significant bits of N(U))
218 */
219 sdu->buf[(sdu->o_buf/8)+1] = 0xC0 | (UBYTE)(nu >> 6);
220
221 /*
222 * insert 2nd octet of control field
223 * (6 least significant bits of N(U) + E bit + PM bit)
224 */
225 sdu->buf[(sdu->o_buf/8)+2] = (((UBYTE)nu & 0x3F) << 2);
226
227 if (cipher == LL_CIPHER_ON)
228 {
229 sdu->buf[(sdu->o_buf/8)+2] |= 0x02;
230 }
231
232 /*
233 * all reliability classes except LL_NO_REL request protected data
234 */
235 if (relclass != LL_NO_REL)
236 {
237 sdu->buf[(sdu->o_buf/8)+2] |= 0x01;
238 }
239
240 return;
241
242 #endif /* LL_DESC */
243
244 } /* uitx_build_ui_header() */