yu.dong | c33b307 | 2024-08-21 23:14:49 -0700 | [diff] [blame^] | 1 | /***************************************************************************** |
| 2 | * Copyright Statement: |
| 3 | * -------------------- |
| 4 | * This software is protected by Copyright and the information contained |
| 5 | * herein is confidential. The software may not be copied and the information |
| 6 | * contained herein may not be used or disclosed except with the written |
| 7 | * permission of MediaTek Inc. (C) 2005 |
| 8 | * |
| 9 | * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 10 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 11 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| 12 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 13 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 14 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 15 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 16 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 17 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| 18 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| 19 | * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| 20 | * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| 21 | * |
| 22 | * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| 23 | * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 24 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 25 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| 26 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 27 | * |
| 28 | * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| 29 | * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| 30 | * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| 31 | * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| 32 | * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| 33 | * |
| 34 | *****************************************************************************/ |
| 35 | |
| 36 | /******************************************************************************* |
| 37 | * Filename: |
| 38 | * --------- |
| 39 | * dispatcher_control.c |
| 40 | * |
| 41 | * Project: |
| 42 | * -------- |
| 43 | * VMOLY |
| 44 | * |
| 45 | * Description: |
| 46 | * ------------ |
| 47 | * Dispatcher control information managment. |
| 48 | * |
| 49 | * Author: |
| 50 | * ------- |
| 51 | * ------- |
| 52 | * |
| 53 | *******************************************************************************/ |
| 54 | |
| 55 | #include "dispatcher_struct.h" |
| 56 | #include "dispatcher_msgid.h" |
| 57 | #include "md_sap.h" |
| 58 | #include "dispatcher_debug.h" |
| 59 | #include "dispatcher_data_path_trace_utmd.h" |
| 60 | /** |
| 61 | * dispatcher global conrol context having bearer & context information |
| 62 | */ |
| 63 | static dispatcher_control_cntx g_dispatcher_cntx[MAX_SIM_NUM]; |
| 64 | |
| 65 | /** |
| 66 | * dispatcher current protoidx for recvd ilm |
| 67 | */ |
| 68 | kal_uint8 g_dispatcher_curr_protoidx; |
| 69 | |
| 70 | |
| 71 | void dispatcher_ctrl_set_current_protoidx(kal_uint8 protoidx) |
| 72 | { |
| 73 | g_dispatcher_curr_protoidx = protoidx; |
| 74 | } |
| 75 | |
| 76 | |
| 77 | void dispatcher_init_control_cntx(void) |
| 78 | { |
| 79 | kal_mem_set(g_dispatcher_cntx, 0, sizeof(g_dispatcher_cntx)); |
| 80 | } |
| 81 | |
| 82 | #ifdef ATEST_SYS_DISPATCHER |
| 83 | extern kal_bool dispatcher_ut_assert_flag; |
| 84 | |
| 85 | #ifdef ASSERT |
| 86 | #undef ASSERT |
| 87 | #endif |
| 88 | //#define ASSERT(x) do{ if (x) ut_assert_flag = KAL_TRUE; }while(0) |
| 89 | void ASSERT(int x) { |
| 90 | if (!x) { |
| 91 | dispatcher_ut_assert_flag = KAL_TRUE; |
| 92 | } |
| 93 | } |
| 94 | #endif |
| 95 | |
| 96 | /****************************************************************** |
| 97 | ****************Control path functions**************************** |
| 98 | *****************************************************************/ |
| 99 | |
| 100 | void |
| 101 | n3epc_dispatcher_bearer_act_req(n3epc_dispatcher_bearer_act_req_struct *p_local) |
| 102 | { |
| 103 | kal_uint8 proto_idx = g_dispatcher_curr_protoidx; |
| 104 | dispatcher_control_cntx *p_dispatcher_ctrl_cntx; |
| 105 | dispatcher_bearer_info_struct *p_bearer_info; |
| 106 | dispatcher_cid_info_struct *p_cid_info; |
| 107 | kal_uint8 bearer_id, cid; |
| 108 | |
| 109 | MD_TRC_DISPATCHER_TR_BEARER_ACT_REQ(p_local->bearer_id, p_local->linked_bearer_id, |
| 110 | p_local->context_id, proto_idx); |
| 111 | |
| 112 | bearer_id = p_local->bearer_id; |
| 113 | /*as per WO bearer_id will range from 1~15*/ |
| 114 | if (0 == bearer_id || bearer_id > 15) { |
| 115 | //BEARER_ID_INVALID_VALUE |
| 116 | ASSERT(0); |
| 117 | return; |
| 118 | } |
| 119 | cid = p_local->context_id; |
| 120 | p_dispatcher_ctrl_cntx = &g_dispatcher_cntx[proto_idx]; |
| 121 | p_bearer_info = &p_dispatcher_ctrl_cntx->bearer_info[bearer_id]; |
| 122 | p_cid_info = &p_dispatcher_ctrl_cntx->cid_info[cid]; |
| 123 | |
| 124 | /*if ebi context has already valid values it means bearer is already active*/ |
| 125 | if (p_bearer_info->defult_bearer_id != 0) { |
| 126 | ASSERT(0); |
| 127 | return; |
| 128 | } |
| 129 | p_bearer_info->bearer_id = bearer_id; |
| 130 | p_bearer_info->defult_bearer_id = p_local->linked_bearer_id; |
| 131 | //for R14 this will be always true |
| 132 | if (p_bearer_info->bearer_id == p_local->linked_bearer_id) |
| 133 | { |
| 134 | // the bearer_id of the cid info not to be set at bearer act req |
| 135 | //bearer is already active for this cid |
| 136 | ASSERT(p_cid_info->bearer_id == 0); |
| 137 | p_bearer_info->context_id = cid; |
| 138 | |
| 139 | // save ip_addr and dns for the ipcore bind process |
| 140 | p_cid_info->ip_addr = p_local->ip_addr; |
| 141 | p_cid_info->dns = p_local->dns; |
| 142 | |
| 143 | MD_TRC_DISPATCHER_TR_BEARER_ACT_REQ_BIND_STATE(p_bearer_info->context_id, p_cid_info->bind_state); |
| 144 | |
| 145 | if (DISPATCHER_PDN_ST_UNBIND == p_cid_info->bind_state) |
| 146 | { |
| 147 | //reset old bearer id here |
| 148 | p_cid_info->old_bearer_id = 0; |
| 149 | } |
| 150 | /* not accepatable state to handle bearer activation*/ |
| 151 | if ((DISPATCHER_PDN_ST_BIND == p_cid_info->bind_state) || |
| 152 | (DISPATCHER_PDN_ST_BINDING == p_cid_info->bind_state) || |
| 153 | (DISPATCHER_PDN_ST_BINDING_GOING_TO_UNBIND == p_cid_info->bind_state)) |
| 154 | { |
| 155 | ASSERT(0); |
| 156 | return; |
| 157 | } |
| 158 | p_cid_info->bearer_id = p_bearer_info->defult_bearer_id; |
| 159 | } |
| 160 | /*currently bearer_id & linked bearer_id will be same*/ |
| 161 | else |
| 162 | { |
| 163 | ASSERT(0); |
| 164 | return; |
| 165 | } |
| 166 | |
| 167 | } |
| 168 | |
| 169 | |
| 170 | |
| 171 | void |
| 172 | n3epc_dispatcher_bearer_deact_req(n3epc_dispatcher_bearer_deact_req_struct *p_local) |
| 173 | { |
| 174 | kal_uint8 proto_idx = g_dispatcher_curr_protoidx; |
| 175 | dispatcher_control_cntx *p_dispatcher_ctrl_cntx; |
| 176 | dispatcher_bearer_info_struct *p_bearer_info; |
| 177 | dispatcher_cid_info_struct *p_cid_info; |
| 178 | kal_uint8 bearer_id, cid; |
| 179 | |
| 180 | p_dispatcher_ctrl_cntx = &g_dispatcher_cntx[proto_idx]; |
| 181 | bearer_id = p_local->bearer_id; |
| 182 | cid = p_local->context_id; |
| 183 | |
| 184 | MD_TRC_DISPATCHER_TR_BEARER_DEACT_REQ(bearer_id, cid, proto_idx); |
| 185 | |
| 186 | if (0 == bearer_id || bearer_id > 15) { |
| 187 | //BEARER_ID_INVALID_VALUE |
| 188 | ASSERT(0); |
| 189 | return; |
| 190 | } |
| 191 | |
| 192 | p_bearer_info = &p_dispatcher_ctrl_cntx->bearer_info[bearer_id]; |
| 193 | p_cid_info = &p_dispatcher_ctrl_cntx->cid_info[cid]; |
| 194 | |
| 195 | if (p_bearer_info->defult_bearer_id == bearer_id) |
| 196 | { |
| 197 | /*check this bearer info have same cid*/ |
| 198 | ASSERT(p_bearer_info->context_id == cid); |
| 199 | p_bearer_info->defult_bearer_id = 0; |
| 200 | p_cid_info->bearer_id = 0; |
| 201 | } |
| 202 | |
| 203 | /*bearer can be deactivated before pdn unbind*/ |
| 204 | /*to handle unbind we need bearer_id, to keep bearer_id in old_bearer_id in cid info*/ |
| 205 | if ((DISPATCHER_PDN_ST_BIND == p_cid_info->bind_state) || |
| 206 | (DISPATCHER_PDN_ST_BINDING_GOING_TO_UNBIND == p_cid_info->bind_state) || |
| 207 | (DISPATCHER_PDN_ST_BINDING == p_cid_info->bind_state)) |
| 208 | { |
| 209 | p_cid_info->old_bearer_id = bearer_id; |
| 210 | } |
| 211 | |
| 212 | } |
| 213 | |
| 214 | void n3epc_dispatcher_pdn_bind_req(n3epc_dispatcher_pdn_bind_req_struct *p_local, |
| 215 | kal_uint32 src_mod_id) |
| 216 | { |
| 217 | kal_uint8 proto_idx = g_dispatcher_curr_protoidx; |
| 218 | dispatcher_control_cntx *p_dispatcher_ctrl_cntx; |
| 219 | dispatcher_bearer_info_struct *p_bearer_info; |
| 220 | dispatcher_cid_info_struct *p_cid_info; |
| 221 | kal_uint8 bearer_id; |
| 222 | dispatcher_bind_state_enum bind_state; |
| 223 | #ifndef ATEST_SYS_DISPATCHER |
| 224 | kal_uint8 pdn_id; |
| 225 | ipcore_dispatcher_pdn_bind_ind_struct *p_pdn_bind_ind; |
| 226 | #endif |
| 227 | ps_cause_enum error_result = HIF_IPC_OK; |
| 228 | |
| 229 | MD_TRC_DISPATCHER_TR_PDN_BIND_REQ(p_local->context_id, |
| 230 | p_local->network_interface_id, proto_idx); |
| 231 | |
| 232 | p_dispatcher_ctrl_cntx = &g_dispatcher_cntx[proto_idx]; |
| 233 | p_cid_info = &p_dispatcher_ctrl_cntx->cid_info[p_local->context_id]; |
| 234 | bearer_id = p_cid_info->bearer_id; |
| 235 | |
| 236 | p_bearer_info = &p_dispatcher_ctrl_cntx->bearer_info[bearer_id]; |
| 237 | /*check if bearer is already active or not before bind this is must condition*/ |
| 238 | /*******handling added for assert removal*************/ |
| 239 | if ((p_cid_info->bearer_id == 0) || |
| 240 | (p_bearer_info->defult_bearer_id != bearer_id)) |
| 241 | { |
| 242 | error_result = N3EPC_DISPATCHER_BIND_ERROR_AS_BEARER_NOT_ACTIVATED_BEFORE; |
| 243 | dispatcher_report_bind_unbind_error_cnf(KAL_TRUE, error_result, p_local->context_id, src_mod_id); |
| 244 | return; |
| 245 | } |
| 246 | bind_state = p_cid_info->bind_state; |
| 247 | /*bind req is valid for unbind state only*/ |
| 248 | if (DISPATCHER_PDN_ST_UNBIND == bind_state) |
| 249 | { |
| 250 | /*update pdn bind state*/ |
| 251 | p_cid_info->bind_state = DISPATCHER_PDN_ST_BINDING; |
| 252 | p_cid_info->apn_type_info = p_local->apn_type_info; |
| 253 | |
| 254 | /* forward to IPCORE */ |
| 255 | #ifndef ATEST_SYS_DISPATCHER |
| 256 | p_pdn_bind_ind = construct_local_para(sizeof(ipcore_dispatcher_pdn_bind_ind_struct), 0); |
| 257 | |
| 258 | #if defined(__SENSITIVE_DATA_MOSAIC__) && defined(__MTK_TARGET__) |
| 259 | kal_set_sensitive_buff(p_pdn_bind_ind); |
| 260 | #endif |
| 261 | |
| 262 | p_pdn_bind_ind->network_interface_id = p_local->network_interface_id; |
| 263 | DISPATCHER_CONVERT_BEARERID_TO_PDNID(bearer_id, pdn_id); |
| 264 | p_pdn_bind_ind->pdn_id = pdn_id; |
| 265 | p_pdn_bind_ind->apn_type_info = p_local->apn_type_info; |
| 266 | p_pdn_bind_ind->ip_addr = p_cid_info->ip_addr; |
| 267 | p_pdn_bind_ind->dns = p_cid_info->dns; |
| 268 | |
| 269 | p_pdn_bind_ind->back_info.reply_dest_mod_id = src_mod_id; |
| 270 | p_pdn_bind_ind->back_info.context_id = p_local->context_id; |
| 271 | |
| 272 | msg_send6( |
| 273 | MOD_DISPATCHER + proto_idx, |
| 274 | MOD_IPCORE, |
| 275 | #if defined(__SENSITIVE_DATA_MOSAIC__) && defined(__MTK_TARGET__) |
| 276 | DISPATCHER_USER_SENSITIVE_SAP, |
| 277 | #else |
| 278 | DISPATCHER_SAP, |
| 279 | #endif |
| 280 | MSG_ID_IPCORE_DISPATCHER_PDN_BIND_IND, |
| 281 | (local_para_struct*) p_pdn_bind_ind, |
| 282 | NULL); |
| 283 | #endif |
| 284 | |
| 285 | } else if (DISPATCHER_PDN_ST_BIND == bind_state) { |
| 286 | error_result = N3EPC_DISPATCHER_BIND_ERROR_AS_PDN_ALREADY_BIND; |
| 287 | dispatcher_report_bind_unbind_error_cnf(KAL_TRUE, error_result, p_local->context_id, src_mod_id); |
| 288 | } else if (DISPATCHER_PDN_ST_BINDING == bind_state) { |
| 289 | error_result = N3EPC_DISPATCHER_BIND_ERROR_AS_PREV_BIND_IN_PROGRESS; |
| 290 | dispatcher_report_bind_unbind_error_cnf(KAL_TRUE, error_result, p_local->context_id, src_mod_id); |
| 291 | } else /*if (DISPATCHER_PDN_ST_BINDING_GOING_TO_UNBIND == bind_state)*/ { |
| 292 | error_result = N3EPC_DISPATCHER_BINDING_GOING_TO_UNBIND_ERROR_AS_PREV_BIND_IN_PROGRESS; |
| 293 | dispatcher_report_bind_unbind_error_cnf(KAL_TRUE, error_result, p_local->context_id, src_mod_id); |
| 294 | } |
| 295 | MD_TRC_DISPATCHER_TR_PDN_BIND_REQ_BIND_STATE(p_local->context_id, |
| 296 | bind_state, p_cid_info->bind_state); |
| 297 | } |
| 298 | |
| 299 | |
| 300 | void n3epc_dispatcher_pdn_unbind_req(n3epc_dispatcher_pdn_unbind_req_struct *p_local, |
| 301 | kal_uint32 src_mod_id) |
| 302 | { |
| 303 | |
| 304 | kal_uint8 proto_idx = g_dispatcher_curr_protoidx; |
| 305 | dispatcher_control_cntx *p_dispatcher_ctrl_cntx; |
| 306 | dispatcher_bearer_info_struct *p_bearer_info; |
| 307 | dispatcher_cid_info_struct *p_cid_info; |
| 308 | kal_uint8 bearer_id; |
| 309 | kal_uint8 cid = p_local->context_id; |
| 310 | dispatcher_bind_state_enum bind_state; |
| 311 | ps_cause_enum error_result = HIF_IPC_OK; |
| 312 | |
| 313 | MD_TRC_DISPATCHER_TR_PDN_UNBIND_REQ(p_local->context_id, proto_idx); |
| 314 | |
| 315 | p_dispatcher_ctrl_cntx = &g_dispatcher_cntx[proto_idx]; |
| 316 | p_cid_info = &p_dispatcher_ctrl_cntx->cid_info[cid]; |
| 317 | bind_state = p_cid_info->bind_state; |
| 318 | bearer_id = p_cid_info->bearer_id; |
| 319 | |
| 320 | /* unbind may be after bearer deact |
| 321 | * on bearer deact we will keep the bearer_id to old_bearer_id in cid |
| 322 | */ |
| 323 | if (!bearer_id) { |
| 324 | bearer_id = p_cid_info->old_bearer_id; |
| 325 | } |
| 326 | |
| 327 | p_bearer_info = &p_dispatcher_ctrl_cntx->bearer_info[bearer_id]; |
| 328 | ASSERT(p_bearer_info->context_id == cid); |
| 329 | |
| 330 | if (DISPATCHER_PDN_ST_BIND == bind_state) { |
| 331 | /* wo unbind cnf + ipc unbind ind!! */ |
| 332 | dispatcher_unbind_cnf_optional_ipc_ind(p_bearer_info, KAL_TRUE, src_mod_id, proto_idx); |
| 333 | p_cid_info->bind_state = DISPATCHER_PDN_ST_UNBIND; |
| 334 | } else if (DISPATCHER_PDN_ST_BINDING == bind_state) { |
| 335 | // update bind_state |
| 336 | p_cid_info->bind_state = DISPATCHER_PDN_ST_BINDING_GOING_TO_UNBIND; |
| 337 | } else { |
| 338 | // Not expected state |
| 339 | //ASSERT(0); |
| 340 | error_result = N3EPC_DISPATCHER_UNBIND_ERROR_AS_DUPLICATE_UNBIND_REQ; |
| 341 | dispatcher_report_bind_unbind_error_cnf(KAL_FALSE, error_result, p_local->context_id, src_mod_id); |
| 342 | } |
| 343 | MD_TRC_DISPATCHER_TR_PDN_UNBIND_REQ_BIND_STATE(cid, bind_state, p_cid_info->bind_state); |
| 344 | } |
| 345 | |
| 346 | |
| 347 | void |
| 348 | ipcore_dispatcher_pdn_bind_rsp(ipcore_dispatcher_pdn_bind_rsp_struct *p_local) |
| 349 | { |
| 350 | kal_uint8 proto_idx = g_dispatcher_curr_protoidx; |
| 351 | kal_uint8 bearer_id = 0; |
| 352 | kal_uint8 context_id = p_local->back_info.context_id; |
| 353 | n3epc_dispatcher_pdn_bind_cnf_struct *p_pdn_bind_cnf; |
| 354 | dispatcher_bind_state_enum bind_state; |
| 355 | dispatcher_control_cntx *p_dispatcher_ctrl_cntx; |
| 356 | dispatcher_bearer_info_struct *p_bearer_info; |
| 357 | dispatcher_cid_info_struct *p_cid_info; |
| 358 | |
| 359 | p_dispatcher_ctrl_cntx = &g_dispatcher_cntx[proto_idx]; |
| 360 | DISPATCHER_CONVERT_PDNID_TO_BEARERID(p_local->pdn_id, bearer_id); |
| 361 | p_bearer_info = &p_dispatcher_ctrl_cntx->bearer_info[bearer_id]; |
| 362 | p_cid_info = &p_dispatcher_ctrl_cntx->cid_info[context_id]; |
| 363 | bind_state = p_cid_info->bind_state; |
| 364 | if (DISPATCHER_PDN_ST_BINDING == bind_state) { |
| 365 | /* state is binding(waiting for bind rsp) send cnf to wo!! */ |
| 366 | if (HIF_IPC_OK == p_local->result) { |
| 367 | p_cid_info->bind_state = DISPATCHER_PDN_ST_BIND; |
| 368 | p_cid_info->network_interface_id = p_local->network_interface_id; |
| 369 | } else { |
| 370 | p_cid_info->bind_state = DISPATCHER_PDN_ST_UNBIND; |
| 371 | } |
| 372 | } else if (DISPATCHER_PDN_ST_BINDING_GOING_TO_UNBIND == bind_state) { |
| 373 | /*send bind cnf to WO + unbind to ipc based upon bind result*/ |
| 374 | if (HIF_IPC_OK == p_local->result) { |
| 375 | p_cid_info->pending_req = DISPATCHER_PENDING_REQ_UNBIND_IND_N_CNF ; |
| 376 | } else { |
| 377 | p_cid_info->pending_req = DISPATCHER_PENDING_REQ_UNBIND_CNF; |
| 378 | } |
| 379 | } else { |
| 380 | ASSERT(0); |
| 381 | } |
| 382 | |
| 383 | MD_TRC_DISPATCHER_TR_PDN_IPC_BIND_RSP(p_local->result, context_id, |
| 384 | bind_state, p_cid_info->bind_state, proto_idx); |
| 385 | /*as this is the bind rsp so first send bind cnf to WO !! */ |
| 386 | |
| 387 | p_pdn_bind_cnf = construct_local_para(sizeof(n3epc_dispatcher_pdn_bind_cnf_struct), TD_RESET); |
| 388 | p_pdn_bind_cnf->context_id = p_local->back_info.context_id; |
| 389 | if (DISPATCHER_PDN_ST_BIND == p_cid_info->bind_state) { |
| 390 | p_pdn_bind_cnf->is_successful = p_local->result == HIF_IPC_OK ? KAL_TRUE : KAL_FALSE; |
| 391 | } |
| 392 | p_pdn_bind_cnf->error_result = p_local->result; |
| 393 | |
| 394 | msg_send6( |
| 395 | #ifndef ATEST_SYS_DISPATCHER |
| 396 | MOD_DISPATCHER + proto_idx, |
| 397 | #else |
| 398 | MOD_NIL, |
| 399 | #endif |
| 400 | p_local->back_info.reply_dest_mod_id, |
| 401 | DISPATCHER_SAP, |
| 402 | MSG_ID_N3EPC_DISPATCHER_PDN_BIND_CNF, |
| 403 | (local_para_struct*) p_pdn_bind_cnf, |
| 404 | NULL); |
| 405 | |
| 406 | /*only send unbind cnf to WO*/ |
| 407 | if (DISPATCHER_PENDING_REQ_UNBIND_CNF == p_cid_info->pending_req) { |
| 408 | //KAL_FALSE : as bind rsp failed so no need to send unbind ind to ipcore |
| 409 | dispatcher_unbind_cnf_optional_ipc_ind(p_bearer_info, KAL_FALSE, |
| 410 | p_local->back_info.reply_dest_mod_id, proto_idx); |
| 411 | p_cid_info->bind_state = DISPATCHER_PDN_ST_UNBIND; |
| 412 | p_cid_info->pending_req = DISPATCHER_PENDING_REQ_NONE; |
| 413 | } else if (DISPATCHER_PENDING_REQ_UNBIND_IND_N_CNF == p_cid_info->pending_req) { |
| 414 | //KAL_TRUE: as bind rsp success, so send unbind ind to ipcore |
| 415 | dispatcher_unbind_cnf_optional_ipc_ind(p_bearer_info, KAL_TRUE, |
| 416 | p_local->back_info.reply_dest_mod_id, proto_idx); |
| 417 | p_cid_info->bind_state = DISPATCHER_PDN_ST_UNBIND; |
| 418 | p_cid_info->pending_req = DISPATCHER_PENDING_REQ_NONE; |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | |
| 423 | /****************************************************************** |
| 424 | *helper function to check binding state & bearer activation state* |
| 425 | *****************************************************************/ |
| 426 | |
| 427 | dispatcher_bind_state_enum |
| 428 | dispatcher_get_bind_state_by_bearerid(kal_uint8 bearer_id, kal_uint8 proto_idx) |
| 429 | { |
| 430 | dispatcher_cid_info_struct *p_cid_info; |
| 431 | dispatcher_bearer_info_struct *p_bearer_info; |
| 432 | kal_uint8 cid = 0; |
| 433 | dispatcher_control_cntx *p_dispatcher_ctrl_cntx = &g_dispatcher_cntx[proto_idx]; |
| 434 | p_bearer_info = &p_dispatcher_ctrl_cntx->bearer_info[bearer_id]; |
| 435 | cid = p_bearer_info->context_id; |
| 436 | p_cid_info = &p_dispatcher_ctrl_cntx->cid_info[cid]; |
| 437 | |
| 438 | MD_TRC_DISPATCHER_DATA_TRACE_BINDING_INFO(bearer_id, cid, p_cid_info->bind_state, proto_idx); |
| 439 | return p_cid_info->bind_state; |
| 440 | |
| 441 | } |
| 442 | |
| 443 | |
| 444 | dispatcher_bind_state_enum |
| 445 | dispatcher_get_bind_state_by_pdnid(kal_uint8 pdn_id, kal_uint8 proto_idx) |
| 446 | { |
| 447 | kal_uint8 bearer_id = 0; |
| 448 | DISPATCHER_CONVERT_PDNID_TO_BEARERID(pdn_id, bearer_id); |
| 449 | if (IS_VALID_BEARERID(bearer_id)) { |
| 450 | return dispatcher_get_bind_state_by_bearerid(bearer_id, proto_idx); |
| 451 | } |
| 452 | return 0; |
| 453 | } |
| 454 | |
| 455 | |
| 456 | kal_bool dispatcher_check_is_bearer_active_by_pdnid(kal_uint8 pdn_id, |
| 457 | kal_uint8 proto_idx) |
| 458 | { |
| 459 | kal_uint8 bearer_id = 0; |
| 460 | DISPATCHER_CONVERT_PDNID_TO_BEARERID(pdn_id, bearer_id); |
| 461 | if (IS_VALID_BEARERID(bearer_id)) { |
| 462 | return dispatcher_check_is_bearer_active_by_bearerid(bearer_id, proto_idx); |
| 463 | } |
| 464 | return KAL_FALSE; |
| 465 | } |
| 466 | |
| 467 | |
| 468 | kal_bool dispatcher_check_is_bearer_active_by_bearerid(kal_uint8 bearer_id, |
| 469 | kal_uint8 proto_idx) |
| 470 | { |
| 471 | dispatcher_control_cntx *p_dispatcher_ctrl_cntx = &g_dispatcher_cntx[proto_idx]; |
| 472 | dispatcher_bearer_info_struct *p_bearer_info = &p_dispatcher_ctrl_cntx->bearer_info[bearer_id]; |
| 473 | kal_bool is_active = (0 != p_bearer_info->defult_bearer_id) ? KAL_TRUE : KAL_FALSE; |
| 474 | |
| 475 | MD_TRC_DISPATCHER_DATA_TRACE_BEARER_INFO(bearer_id, is_active, proto_idx); |
| 476 | return is_active; |
| 477 | } |
| 478 | |
| 479 | /** |
| 480 | * dispatcher_report_bind_unbind_error_cnf |
| 481 | * report bind unbind error to WO for pre check |
| 482 | */ |
| 483 | void dispatcher_report_bind_unbind_error_cnf(kal_bool is_bindreq, |
| 484 | ps_cause_enum error_code, |
| 485 | kal_uint8 cid, |
| 486 | kal_uint32 reply_mod_id) |
| 487 | { |
| 488 | kal_bool success = KAL_FALSE; |
| 489 | kal_uint8 proto_idx = g_dispatcher_curr_protoidx; |
| 490 | if (is_bindreq) |
| 491 | { |
| 492 | n3epc_dispatcher_pdn_bind_cnf_struct *p_pdn_bind_cnf; |
| 493 | p_pdn_bind_cnf = construct_local_para(sizeof(n3epc_dispatcher_pdn_bind_cnf_struct), TD_RESET); |
| 494 | p_pdn_bind_cnf->context_id = cid; |
| 495 | p_pdn_bind_cnf->is_successful = success; |
| 496 | p_pdn_bind_cnf->error_result = error_code; |
| 497 | |
| 498 | msg_send6( |
| 499 | #ifndef ATEST_SYS_DISPATCHER |
| 500 | MOD_DISPATCHER + proto_idx, |
| 501 | #else |
| 502 | MOD_NIL, |
| 503 | #endif |
| 504 | reply_mod_id, |
| 505 | DISPATCHER_SAP, |
| 506 | MSG_ID_N3EPC_DISPATCHER_PDN_BIND_CNF, |
| 507 | (local_para_struct*) p_pdn_bind_cnf, |
| 508 | NULL); |
| 509 | |
| 510 | } |
| 511 | else |
| 512 | { |
| 513 | n3epc_dispatcher_pdn_unbind_cnf_struct *p_pdn_unbind_cnf; |
| 514 | p_pdn_unbind_cnf = construct_local_para(sizeof(n3epc_dispatcher_pdn_unbind_cnf_struct), TD_RESET); |
| 515 | p_pdn_unbind_cnf->context_id = cid; |
| 516 | p_pdn_unbind_cnf->is_successful = success; |
| 517 | p_pdn_unbind_cnf->error_result = error_code; |
| 518 | |
| 519 | msg_send6( |
| 520 | #ifndef ATEST_SYS_DISPATCHER |
| 521 | MOD_DISPATCHER + proto_idx, |
| 522 | #else |
| 523 | MOD_NIL, |
| 524 | #endif |
| 525 | reply_mod_id, |
| 526 | DISPATCHER_SAP, |
| 527 | MSG_ID_N3EPC_DISPATCHER_PDN_UNBIND_CNF, |
| 528 | (local_para_struct*) p_pdn_unbind_cnf, |
| 529 | NULL); |
| 530 | } |
| 531 | } |
| 532 | |
| 533 | |
| 534 | /** |
| 535 | * dispatcher_unbind_cnf_optional_ipc_ind |
| 536 | * unbind CNF to WO must + optional IPC unbind ind |
| 537 | */ |
| 538 | void dispatcher_unbind_cnf_optional_ipc_ind( |
| 539 | dispatcher_bearer_info_struct *p_bearer_info, |
| 540 | kal_bool ipc_unbind_required, |
| 541 | kal_uint32 dest_mod_id, |
| 542 | kal_uint8 proto_idx) |
| 543 | { |
| 544 | #ifndef ATEST_SYS_DISPATCHER |
| 545 | ipcore_dispatcher_pdn_unbind_ind_struct *p_pdn_unbind_ind; |
| 546 | #endif |
| 547 | n3epc_dispatcher_pdn_unbind_cnf_struct *p_pdn_unbind_cnf; |
| 548 | |
| 549 | kal_uint8 bearer_id = p_bearer_info->bearer_id; |
| 550 | kal_uint8 cid = p_bearer_info->context_id; |
| 551 | |
| 552 | MD_TRC_DISPATCHER_TR_PDN_UNBIND_CNF_N_IND_OPTIONAL(bearer_id, |
| 553 | p_bearer_info->context_id, ipc_unbind_required, proto_idx); |
| 554 | |
| 555 | /* forward to IPCORE */ |
| 556 | if (ipc_unbind_required) { |
| 557 | #ifndef ATEST_SYS_DISPATCHER |
| 558 | kal_uint8 pdn_id = 0; |
| 559 | p_pdn_unbind_ind = construct_local_para(sizeof(ipcore_dispatcher_pdn_unbind_ind_struct), TD_RESET); |
| 560 | DISPATCHER_CONVERT_BEARERID_TO_PDNID(bearer_id, pdn_id); |
| 561 | p_pdn_unbind_ind->pdn_id = pdn_id; |
| 562 | |
| 563 | msg_send6( |
| 564 | MOD_DISPATCHER + proto_idx, |
| 565 | MOD_IPCORE, |
| 566 | DISPATCHER_SAP, |
| 567 | MSG_ID_IPCORE_DISPATCHER_PDN_UNBIND_IND, |
| 568 | (local_para_struct*) p_pdn_unbind_ind, |
| 569 | NULL); |
| 570 | #endif |
| 571 | } |
| 572 | |
| 573 | /* CNF to WO */ |
| 574 | |
| 575 | p_pdn_unbind_cnf = construct_local_para(sizeof(n3epc_dispatcher_pdn_unbind_cnf_struct), TD_RESET); |
| 576 | p_pdn_unbind_cnf->context_id = cid; |
| 577 | p_pdn_unbind_cnf->is_successful = KAL_TRUE; |
| 578 | p_pdn_unbind_cnf->error_result = HIF_IPC_OK; |
| 579 | msg_send6( |
| 580 | #ifndef ATEST_SYS_DISPATCHER |
| 581 | MOD_DISPATCHER + proto_idx, |
| 582 | #else |
| 583 | MOD_NIL, |
| 584 | #endif |
| 585 | dest_mod_id, |
| 586 | DISPATCHER_SAP, |
| 587 | MSG_ID_N3EPC_DISPATCHER_PDN_UNBIND_CNF, |
| 588 | (local_para_struct*) p_pdn_unbind_cnf, |
| 589 | NULL); |
| 590 | } |
| 591 | |
| 592 | |
| 593 | #if defined(__SENSITIVE_DATA_MOSAIC__) |
| 594 | void dispatcher_clean_private_data(void) |
| 595 | { |
| 596 | //kal_mem_set(g_dispatcher_cntx, 0, sizeof(g_dispatcher_cntx)); |
| 597 | //or just clean the ip_addr from global |
| 598 | kal_uint8 sim_id, cid; |
| 599 | dispatcher_control_cntx *p_dispatcher_ctrl_cntx; |
| 600 | dispatcher_cid_info_struct *p_cid_info; |
| 601 | |
| 602 | for (sim_id = 0; sim_id < MAX_SIM_NUM; sim_id++) { |
| 603 | p_dispatcher_ctrl_cntx = &g_dispatcher_cntx[sim_id]; |
| 604 | for (cid = 0; cid < 200; cid++) { |
| 605 | p_cid_info = &p_dispatcher_ctrl_cntx->cid_info[cid]; |
| 606 | kal_mem_set(&p_cid_info->ip_addr,0, sizeof(ip_addr_struct)); |
| 607 | kal_mem_set(&p_cid_info->dns, 0, sizeof(dns_struct)); |
| 608 | } |
| 609 | } |
| 610 | } |
| 611 | #endif |