FreeCalypso > hg > fc-tourmaline
comparison src/g23m-gprs/llc/llc_txl.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 LLC and implements all labels | |
| 18 | in the SDL-documentation (TX-statemachine) that are called from | |
| 19 | more than one diagram/place. | |
| 20 +----------------------------------------------------------------------------- | |
| 21 */ | |
| 22 | |
| 23 #ifndef LLC_TXL_C | |
| 24 #define LLC_TXL_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 #include "llc_uitxs.h" /* to get signal interface to UITX */ | |
| 42 #include "llc_itxs.h" /* to get signal interface to ITX */ | |
| 43 | |
| 44 /*==== CONST ================================================================*/ | |
| 45 | |
| 46 /*==== LOCAL VARS ===========================================================*/ | |
| 47 | |
| 48 /*==== PRIVATE FUNCTIONS ====================================================*/ | |
| 49 #ifdef TRACE_EVE | |
| 50 | |
| 51 LOCAL void tx_trace_outprim_para(UBYTE sapi, T_sdu *frame) | |
| 52 { | |
| 53 int len = BYTELEN(frame->l_buf); | |
| 54 | |
| 55 if( (len >= U_CTRL_MIN_OCTETS) && ((frame->buf[(frame->o_buf/8)+1] & U_FRAME_MASK) EQ U_FRAME_ID) ) | |
| 56 { | |
| 57 switch (frame->buf[(frame->o_buf/8)+1] & 0x0F) | |
| 58 { | |
| 59 case U_FRAME_DM: TRACE_2_OUT_PARA("DM s:%d len:%d", sapi, len); break; | |
| 60 case U_FRAME_DISC: TRACE_2_OUT_PARA("DISC s:%d len:%d", sapi, len); break; | |
| 61 case U_FRAME_UA: TRACE_2_OUT_PARA("UA s:%d len:%d", sapi, len); break; | |
| 62 case U_FRAME_SABM: TRACE_2_OUT_PARA("SABM s:%d len:%d", sapi, len); break; | |
| 63 case U_FRAME_FRMR: TRACE_2_OUT_PARA("FRMR s:%d len:%d", sapi, len); break; | |
| 64 case U_FRAME_XID: TRACE_2_OUT_PARA("XID s:%d len:%d", sapi, len); break; | |
| 65 default: TRACE_2_OUT_PARA("U ??? s:%d len:%d", sapi, len);break; | |
| 66 } | |
| 67 } | |
| 68 else | |
| 69 if( (len >= UI_CTRL_MIN_OCTETS) && ((frame->buf[(frame->o_buf/8)+1] & UI_FRAME_MASK) EQ UI_FRAME_ID) ) | |
| 70 { | |
| 71 T_FRAME_NUM nr; | |
| 72 | |
| 73 USHORT cipher = (USHORT)(frame->buf[(frame->o_buf/8)+2] >> 1) & 0x0001; | |
| 74 | |
| 75 nr = (T_FRAME_NUM)(frame->buf[(frame->o_buf/8)+1] & 0x07) << 6; | |
| 76 nr |= (T_FRAME_NUM)(frame->buf[(frame->o_buf/8)+2] >> 2); | |
| 77 | |
| 78 TRACE_4_OUT_PARA("UI s:%d len:%d nr:%d c:%d", sapi, len, nr, cipher); | |
| 79 } | |
| 80 else | |
| 81 if ((len >= I_CTRL_MIN_OCTETS) && (frame->buf[(frame->o_buf/8)+1] & I_FRAME_MASK) EQ I_FRAME_ID) | |
| 82 { | |
| 83 T_FRAME_NUM ns, nr; | |
| 84 ns = (T_FRAME_NUM)(frame->buf[(frame->o_buf/8)+1] & 0x1F) << 4; | |
| 85 ns |= (T_FRAME_NUM)(frame->buf[(frame->o_buf/8)+2] >> 4); | |
| 86 | |
| 87 nr = (T_FRAME_NUM)(frame->buf[(frame->o_buf/8)+2] & 0x07) << 6; | |
| 88 nr |= (T_FRAME_NUM)(frame->buf[(frame->o_buf/8)+3] >> 2); | |
| 89 | |
| 90 /* | |
| 91 * Determine the command of the I frame (S1 & S2 bits) | |
| 92 */ | |
| 93 switch (frame->buf[(frame->o_buf/8)+3] & 0x03) | |
| 94 { | |
| 95 case I_FRAME_RR: TRACE_4_OUT_PARA("I-RR s:%d len:%d nr:%d ns:%d", sapi, len, nr, ns); break; | |
| 96 case I_FRAME_ACK: TRACE_4_OUT_PARA("I-ACK s:%d len:%d nr:%d ns:%d", sapi, len, nr, ns); break; | |
| 97 case I_FRAME_RNR: TRACE_4_OUT_PARA("I-RNR s:%d len:%d nr:%d ns:%d", sapi, len, nr, ns); break; | |
| 98 case I_FRAME_SACK:TRACE_4_OUT_PARA("I-SACK s:%d len:%d nr:%d ns:%d", sapi, len, nr, ns);break; | |
| 99 default: TRACE_2_OUT_PARA("I ??? s:%d len:%d", sapi, len); break; | |
| 100 } | |
| 101 } | |
| 102 else | |
| 103 if( (len >= S_CTRL_MIN_OCTETS) && (frame->buf[(frame->o_buf/8)+1] & S_FRAME_MASK) EQ S_FRAME_ID) | |
| 104 { | |
| 105 T_FRAME_NUM nr; | |
| 106 | |
| 107 nr = (T_FRAME_NUM)(frame->buf[(frame->o_buf/8)+1] & 0x07) << 6; | |
| 108 nr |= (T_FRAME_NUM)(frame->buf[(frame->o_buf/8)+2] >> 2); | |
| 109 | |
| 110 switch (frame->buf[(frame->o_buf/8)+2] & 0x03) | |
| 111 { | |
| 112 case I_FRAME_RR: TRACE_3_OUT_PARA("S-RR s:%d len:%d nr:%d", sapi, len, nr); break; | |
| 113 case I_FRAME_ACK: TRACE_3_OUT_PARA("S-ACK s:%d len:%d nr:%d", sapi, len, nr); break; | |
| 114 case I_FRAME_RNR: TRACE_3_OUT_PARA("S-RNR s:%d len:%d nr:%d", sapi, len, nr); break; | |
| 115 case I_FRAME_SACK:TRACE_3_OUT_PARA("S-SACK s:%d len:%d nr:%d", sapi, len, nr);break; | |
| 116 default: TRACE_2_OUT_PARA("S ??? s:%d len:%d", sapi, len); break; | |
| 117 } | |
| 118 } | |
| 119 else | |
| 120 { | |
| 121 TRACE_2_OUT_PARA("??? s:%d len:%d", sapi, len); | |
| 122 } | |
| 123 } /* tx_trace_outprim_para() */ | |
| 124 | |
| 125 #endif | |
| 126 /*==== PUBLIC FUNCTIONS =====================================================*/ | |
| 127 | |
| 128 | |
| 129 /* | |
| 130 +------------------------------------------------------------------------------ | |
| 131 | Function : tx_label_s_data | |
| 132 +------------------------------------------------------------------------------ | |
| 133 | Description : Describes label S_DATA | |
| 134 | | |
| 135 | Parameters : rx_service - indicates the service to receive a READY_IND | |
| 136 | signal, or NO_SERVICE | |
| 137 | grlc_data_req - a valid pointer to a GRLC_DATA_REQ primitive | |
| 138 | | |
| 139 +------------------------------------------------------------------------------ | |
| 140 */ | |
| 141 GLOBAL void tx_label_s_data (T_SERVICE rx_service, | |
| 142 T_GRLC_DATA_REQ *grlc_data_req) | |
| 143 { | |
| 144 UBYTE sapi = grlc_data_req->sapi; | |
| 145 | |
| 146 TRACE_FUNCTION( "tx_label_s_data" ); | |
| 147 | |
| 148 #ifdef TRACE_EVE | |
| 149 tx_trace_outprim_para (sapi, &grlc_data_req->sdu); | |
| 150 #endif | |
| 151 | |
| 152 PSEND (hCommGRLC, grlc_data_req); | |
| 153 | |
| 154 SET_STATE (TX, TX_TLLI_ASSIGNED_NOT_READY); | |
| 155 | |
| 156 /* | |
| 157 * Recursion possible. Therefore send ready indication after all! | |
| 158 */ | |
| 159 if (rx_service EQ SERVICE_UITX) | |
| 160 { | |
| 161 SWITCH_LLC (sapi); | |
| 162 sig_tx_uitx_ready_ind(); | |
| 163 } | |
| 164 else if (rx_service EQ SERVICE_ITX) | |
| 165 { | |
| 166 SWITCH_LLC (sapi); | |
| 167 sig_tx_itx_ready_ind(); | |
| 168 } | |
| 169 | |
| 170 return; | |
| 171 } /* tx_label_s_data() */ | |
| 172 | |
| 173 | |
| 174 /* | |
| 175 +------------------------------------------------------------------------------ | |
| 176 | Function : tx_label_s_unitdata | |
| 177 +------------------------------------------------------------------------------ | |
| 178 | Description : Describes label S_UNITDATA | |
| 179 | | |
| 180 | Parameters : rx_service - indicates the service to receive a | |
| 181 | READY_IND signal, or NO_SERVICE | |
| 182 | grlc_unitdata_req - a valid pointer to a GRLC_UNITDATA_REQ | |
| 183 | primitive | |
| 184 | | |
| 185 +------------------------------------------------------------------------------ | |
| 186 */ | |
| 187 GLOBAL void tx_label_s_unitdata (T_SERVICE rx_service, | |
| 188 T_GRLC_UNITDATA_REQ *grlc_unitdata_req) | |
| 189 { | |
| 190 UBYTE sapi = grlc_unitdata_req->sapi; | |
| 191 | |
| 192 TRACE_FUNCTION( "tx_label_s_unitdata" ); | |
| 193 | |
| 194 #ifdef TRACE_EVE | |
| 195 tx_trace_outprim_para (sapi, &grlc_unitdata_req->sdu); | |
| 196 #endif | |
| 197 | |
| 198 PSEND (hCommGRLC, grlc_unitdata_req); | |
| 199 | |
| 200 SET_STATE (TX, TX_TLLI_ASSIGNED_NOT_READY); | |
| 201 | |
| 202 /* | |
| 203 * Handle ready indication at last! Recursion possible! | |
| 204 */ | |
| 205 if (rx_service EQ SERVICE_UITX) | |
| 206 { | |
| 207 SWITCH_LLC (sapi); | |
| 208 sig_tx_uitx_ready_ind(); | |
| 209 } | |
| 210 | |
| 211 return; | |
| 212 } /* tx_label_s_unitdata() */ | |
| 213 | |
| 214 | |
| 215 /* | |
| 216 +------------------------------------------------------------------------------ | |
| 217 | Function : tx_label_s_removed | |
| 218 +------------------------------------------------------------------------------ | |
| 219 | Description : Describes label S_REMOVED | |
| 220 | | |
| 221 | Parameters : rx_service - indicates the service to receive a | |
| 222 | READY_IND signal, or NO_SERVICE | |
| 223 | sapi - sapi of removed entry | |
| 224 | | |
| 225 +------------------------------------------------------------------------------ | |
| 226 */ | |
| 227 GLOBAL void tx_label_s_removed (T_SERVICE rx_service, UBYTE sapi) | |
| 228 { | |
| 229 TRACE_FUNCTION( "tx_label_s_removed" ); | |
| 230 | |
| 231 if (rx_service EQ SERVICE_UITX) | |
| 232 { | |
| 233 SWITCH_LLC (sapi); | |
| 234 sig_tx_uitx_ready_ind(); | |
| 235 } | |
| 236 else if (rx_service EQ SERVICE_ITX) | |
| 237 { | |
| 238 SWITCH_LLC (sapi); | |
| 239 sig_tx_itx_ready_ind(); | |
| 240 } | |
| 241 | |
| 242 return; | |
| 243 } /* tx_label_s_removed() */ |
