📄 bs_msghandle.c
字号:
/*---------------------------------------------------------------------------------------*/
/******************************************************************************
when UE on BSFS_EAP_START or BSFS_EAP_PENDING state receive EAP_MESSAGE call this procedure
******************************************************************************/
int handleGwEapMsg(St_BsUeCtxt *pUeCtxt,R64_MSG_S * pR64Msg)
{
R64_MSG_S EapMsgRsp;
BS_StopTimer(pUeCtxt->timer) ;
pUeCtxt->transId=pR64Msg->msgHead.transId;
pUeCtxt->state = BSFS_EAP_PENDING;
genEapMsgRsp(pUeCtxt,&(EapMsgRsp) );
bs_r6_msg_send( &(EapMsgRsp));
BS_CreateTimer(&(pUeCtxt->timer), (BS_TMR_FUNC )BS_PostTimer, pUeCtxt);
BS_StartTimer(pUeCtxt->timer,EXPIRES);
pUeCtxt->sendCount = 0;
return SUCCESS;
}
void reSendEapMsgRsp(St_BsUeCtxt *pUeCtxt)
{
R64_MSG_S EapMsgRsp;
if(pUeCtxt->sendCount++>=TXTIME)
{
TRACE3("Didn't receive EAP_MSG or EAP_CTXT_REP after send out EAP_MESSAGE_RESP for a long time\n");
BS_StopTimer(pUeCtxt->timer) ;
handle_bs_err (pUeCtxt);
return ;
}
else
{
genEapMsgRsp(pUeCtxt,&(EapMsgRsp) );
bs_r6_msg_send( &(EapMsgRsp));
BS_RestartTimer(pUeCtxt->timer,EXPIRES);
return ;
}
}
void genEapMsgRsp(St_BsUeCtxt *pUeCtxt,R64_MSG_S* pR64Msg)
{
bzero((char *)pR64Msg,sizeof(R64_MSG_S));
pR64Msg->msgHead.destinationIp=gDestinationIp;
pR64Msg->msgHead.destinationUdpPort=GW_R6_UDP_PORT;
//pR64Msg->msgHead.flags=
//pR64Msg->msgHead.fragmentId=
pR64Msg->msgHead.functionType=R64_FUNCTION_TYPE_AUTH_RELAY ;
pR64Msg->msgHead.ifType=IF_TYPE_R6;
pR64Msg->msgHead.messageType=R64_ID_AUTH_RELAY_EAP_TRANSFER ;
pR64Msg->msgHead.msId=pUeCtxt->msId;
pR64Msg->msgHead.sourceIp=gSourceIp;
pR64Msg->msgHead.sourceUdpPort=BS_R6_UDP_PORT;
pR64Msg->msgHead.transId=pUeCtxt->transId;
//pR64Msg->msgHead.version=
pR64Msg->u.authRelayEapTransfer.present.msInfoPresent=PRESENT;
pR64Msg->u.authRelayEapTransfer.present.eapMessagePresent=PRESENT;
pR64Msg->u.authRelayEapTransfer.msInfo.present.msIdPresent=PRESENT;
pR64Msg->u.authRelayEapTransfer.msInfo.msId=pUeCtxt->msId;
return ;
}
/*****************************************************************************
when UE on BSFS_EAP_PENDING state receive EAP_CTXT_REP MSG call this procedure
*****************************************************************************/
int handleGwEapCtxtRep(St_BsUeCtxt *pUeCtxt,R64_MSG_S * pR64Msg)
{
R64_MSG_S eapCtxtAck;
BS_StopTimer(pUeCtxt->timer) ;
pUeCtxt->transId=pR64Msg->msgHead.transId;
genEapCtxtAck(pUeCtxt,&(eapCtxtAck));
bs_r6_msg_send(&(eapCtxtAck));
pUeCtxt->state = BSFS_EAP_COMPLETE;
initMsReg(pUeCtxt);
return SUCCESS;
}
/*****************************************************************************
Generate EAP_CTXT_REP_ACK
*****************************************************************************/
void genEapCtxtAck(St_BsUeCtxt *pUeCtxt,R64_MSG_S* pR64Msg)
{
bzero((char *)pR64Msg,sizeof(R64_MSG_S));
pR64Msg->msgHead.destinationIp=gDestinationIp;
pR64Msg->msgHead.destinationUdpPort=GW_R6_UDP_PORT;
//pR64Msg->msgHead.flags=
//pR64Msg->msgHead.fragmentId=
pR64Msg->msgHead.functionType=R64_FUNCTION_TYPE_AUTH_RELAY ;
pR64Msg->msgHead.ifType=IF_TYPE_R6;
pR64Msg->msgHead.messageType=R64_ID_AUTH_RELAY_EAP_TRANSFER ;
pR64Msg->msgHead.msId=pUeCtxt->msId;
pR64Msg->msgHead.sourceIp=gSourceIp;
pR64Msg->msgHead.sourceUdpPort=BS_R6_UDP_PORT;
pR64Msg->msgHead.transId=pUeCtxt->transId;
//pR64Msg->msgHead.version=
pR64Msg->u.msContextRepAck.present.msInfoPresent=PRESENT;
pR64Msg->u.msContextRepAck.msInfo.present.msIdPresent=PRESENT;
pR64Msg->u.msContextRepAck.present.purposeIndPresent=PRESENT;
pR64Msg->u.msContextRepAck.purposeInd.indicator=R64_CONTEXT_PURPOSE_EAP_PROCEDURE;
pR64Msg->u.msContextRepAck.msInfo.msId=pUeCtxt->msId;
return;
}
/*--------------------------------------------------------------------------------------*/
/*****************************************************************************
after EAP complete,call this procedure
*****************************************************************************/
int initMsReg(St_BsUeCtxt *pUeCtxt)
{
pUeCtxt->xid++;
BS_CreateTimer(&pUeCtxt->timer, (BS_TMR_FUNC )BS_PostTimer, pUeCtxt);
pUeCtxt->sendCount = 0;
send_reg_entry_state_change_req(pUeCtxt);
return SUCCESS;
}
void gen_reg_entry_state_change_req (St_BsUeCtxt *pUeCtxt, R64_MSG_S * pMsg)
{
pMsg->u.nwEntryMsStateChangeReq.present.purposePresent = PRESENT;
pMsg->u.nwEntryMsStateChangeReq.present.msInfoPresent = PRESENT;
pMsg->u.nwEntryMsStateChangeReq.msInfo.present.msIdPresent = PRESENT;
pMsg->u.nwEntryMsStateChangeReq.present.bsInfoPresent = PRESENT;
pMsg->u.nwEntryMsStateChangeReq.bsInfo.present.bsIdPresent = PRESENT;
pMsg->u.nwEntryMsStateChangeReq.present.csTypePresent = PRESENT;
pMsg->u.nwEntryMsStateChangeReq.present.downlinkCidNumPresent = PRESENT;
pMsg->u.nwEntryMsStateChangeReq.present.uplinkCidNumPresent = PRESENT;
pMsg->u.nwEntryMsStateChangeReq.present.classifierNumPresent = PRESENT;
pMsg->u.nwEntryMsStateChangeReq.purpose.indicator = R64_CONTEXT_PURPOSE_MS_REGISTRATION;
bcopy((char *)&pUeCtxt->msId, (char *)&pMsg->u.nwEntryMsStateChangeReq.msInfo.msId, sizeof(R64_MS_ID_S));
bcopy((char *)&gBsId, (char *)&pMsg->u.nwEntryMsStateChangeReq.bsInfo.bsId, sizeof(R64_BS_ID_S));
pMsg->u.nwEntryMsStateChangeReq.bsInfo.targetServingInd.indicator = R64_SERVING_NODE;
pMsg->u.nwEntryMsStateChangeReq.csType.type = R64_IP_CS;
pMsg->u.nwEntryMsStateChangeReq.downlinkCidNum.number = BS_MAX_NUM_DLINK_CID;
pMsg->u.nwEntryMsStateChangeReq.uplinkCidNum.number = BS_MAX_NUM_ULINK_CID;
pMsg->u.nwEntryMsStateChangeReq.classifierNum.number = BS_MAX_NUM_DLINK_CID + BS_MAX_NUM_ULINK_CID;
pMsg->msgHead.functionType = R64_FUNCTION_TYPE_MS_STATE_CHANGE;
pMsg->msgHead.messageType = R64_ID_NW_ENTRY_MS_STATE_CHANGE_REQUEST;
bcopy((char *)&pUeCtxt->msId, (char *)&pMsg->msgHead.msId, sizeof(R64_MS_ID_S));
pMsg->msgHead.transId = pUeCtxt->xid;
pMsg->msgHead.sourceIp = gSourceIp;
pMsg->msgHead.destinationIp = gDestinationIp;
pMsg->msgHead.sourceUdpPort = BS_R6_UDP_PORT;
pMsg->msgHead.destinationUdpPort = GW_R6_UDP_PORT;
pMsg->msgHead.ifType = IF_TYPE_R6;
return;
}
void send_reg_entry_state_change_req (St_BsUeCtxt * pUeCtxt)
{
R64_MSG_S msg;
bzero((char *)&msg, sizeof(msg));
if(pUeCtxt->sendCount < TXTIME)
{
gen_reg_entry_state_change_req(pUeCtxt, &msg);
bs_r6_msg_send(&msg);
BS_StartTimer(pUeCtxt->timer, EXPIRES);
pUeCtxt->sendCount++;
}
else
{
TRACE3("NO RSP answer for REG_ENTRY_STATE_CHANGE_REQ!\n");
PRNT_MSID(&msg);
handle_bs_err (pUeCtxt);
}
return;
}
/****************************************************************************
**
** Function Name: handle_entry_state_change_resp
**
** Description:
** Handle network entry ms state change response message of ms registration procedure.
**
** Argument Type IO Description
** ------------- -------- -- ---------------------------------
** pUeCtxt St_BsUeCtxt * I pointer of UE context
** pR64Msg R64_MSG_S * I pointer R64 message
**
** Return Value: int SUCCESS/FAILURE value
** 0 SUCCESS
** -1 FAILURE
**
****************************************************************************/
int handle_reg_entry_state_change_resp (St_BsUeCtxt * pUeCtxt, R64_MSG_S * pR64Msg)
{
BS_StopTimer(pUeCtxt->timer);
BS_DestroyTimer(&pUeCtxt->timer);
pUeCtxt->transId= pR64Msg->msgHead.transId;
pUeCtxt->state = BSFS_MS_REG_PENDING;
BS_CreateTimer(&(pUeCtxt->timer), (BS_TMR_FUNC )BS_PostTimer, pUeCtxt);
send_reg_entry_state_change_ack(pUeCtxt);
return SUCCESS;
}
void send_reg_entry_state_change_ack (St_BsUeCtxt * pUeCtxt)
{
R64_MSG_S msg;
bzero((char *)&msg, sizeof(msg));
msg.u.nwEntryMsStateChangeAck.present.purposePresent = PRESENT;
msg.u.nwEntryMsStateChangeAck.present.causeCodePresent = PRESENT;
msg.u.nwEntryMsStateChangeAck.present.msInfoPresent = PRESENT;
msg.u.nwEntryMsStateChangeAck.msInfo.present.msIdPresent = PRESENT;
msg.u.nwEntryMsStateChangeAck.purpose.indicator = R64_CONTEXT_PURPOSE_MS_REGISTRATION;
msg.u.nwEntryMsStateChangeAck.causeCode.code = R64_CAUSE_SUCCESS;
bcopy((char *)&pUeCtxt->msId, (char *)&msg.u.nwEntryMsStateChangeAck.msInfo.msId, sizeof(R64_MS_ID_S));
msg.msgHead.functionType = R64_FUNCTION_TYPE_MS_STATE_CHANGE;
msg.msgHead.messageType = R64_ID_NW_ENTRY_MS_STATE_CHANGE_ACK;
bcopy((char *)&pUeCtxt->msId, (char *)&msg.msgHead.msId, sizeof(R64_MS_ID_S));
msg.msgHead.transId = pUeCtxt->transId;
msg.msgHead.sourceIp = gSourceIp;
msg.msgHead.destinationIp = gDestinationIp;
msg.msgHead.sourceUdpPort = BS_R6_UDP_PORT;
msg.msgHead.destinationUdpPort = GW_R6_UDP_PORT;
msg.msgHead.ifType = IF_TYPE_R6;
bs_r6_msg_send(&msg);
BS_StartTimer(pUeCtxt->timer, EXPIRES);
return;
}
/****************************************************************************
**
** Function Name: handle_dp_reg_req
**
** Description:
** Handle data path request of data path registration procedure.
**
** Argument Type IO Description
** ------------- -------- -- ---------------------------------
** pUeCtxt St_BsUeCtxt * I pointer of UE context
** pR64Msg R64_MSG_S * I pointer R64 message
**
** Return Value: int SUCCESS/FAILURE value
** 0 SUCCESS
** -1 FAILURE
**
****************************************************************************/
int handle_dp_reg_req (St_BsUeCtxt * pUeCtxt, R64_MSG_S * pR64Msg)
{
BS_StopTimer(pUeCtxt->timer);
BS_DestroyTimer(&pUeCtxt->timer);
pUeCtxt->transId= pR64Msg->msgHead.transId;
pUeCtxt->state = BSFS_DP_EST_PENDING;
pUeCtxt->sfNum = pR64Msg->u.dataPathRegReq.msInfo.sfInfoNum;
printf("SFINFO NUM = %d\n", pR64Msg->u.dataPathRegReq.msInfo.sfInfoNum);
pUeCtxt->dpNum = pR64Msg->u.dataPathRegReq.msInfo.dpInfoNum;
printf("DPINFO NUM = %d\n", pR64Msg->u.dataPathRegReq.msInfo.dpInfoNum);
bcopy((char *)pR64Msg->u.dataPathRegReq.msInfo.sfInfo, (char *)pUeCtxt->sfInfo,
pUeCtxt->sfNum*sizeof(R64_SF_INFO_S));
bcopy((char *)pR64Msg->u.dataPathRegReq.msInfo.dpInfo, (char *)pUeCtxt->dpInfo,
pUeCtxt->dpNum*sizeof(R64_DATA_PATH_INFO_S));
BS_CreateTimer(&pUeCtxt->timer, (BS_TMR_FUNC )BS_PostTimer, pUeCtxt);
pUeCtxt->sendCount = 0;
send_dp_reg_resp(pUeCtxt);
return SUCCESS;
}
void gen_dp_reg_resp (St_BsUeCtxt * pUeCtxt, R64_MSG_S * pMsg)
{
int i;
pMsg->u.dataPathRegRsp.present.regTypePresent = PRESENT;
pMsg->u.dataPathRegRsp.present.msInfoPresent = PRESENT;
pMsg->u.dataPathRegRsp.msInfo.present.msIdPresent = PRESENT;
pMsg->u.dataPathRegRsp.msInfo.present.dpInfoPresent = PRESENT;
pMsg->u.dataPathRegRsp.msInfo.present.sfInfoPresent = PRESENT;
pMsg->u.dataPathRegRsp.regType.type = R64_REGISTRATION_INITIAL_NW_ENTRY;
bcopy((char *)&pUeCtxt->msId, (char *)&pMsg->u.dataPathRegRsp.msInfo.msId, sizeof(R64_MS_ID_S));
pMsg->u.dataPathRegRsp.msInfo.dpInfoNum = pUeCtxt->dpNum;
pMsg->u.dataPathRegRsp.msInfo.sfInfoNum = pUeCtxt->sfNum;
bcopy((char *)pUeCtxt->dpInfo, (char *)pMsg->u.dataPathRegRsp.msInfo.dpInfo,
pUeCtxt->dpNum*sizeof(R64_DATA_PATH_INFO_S));
for(i = 0;i < pUeCtxt->sfNum;i++)
{
pMsg->u.dataPathRegRsp.msInfo.sfInfo[i].present.sfIdPresent = PRESENT;
pMsg->u.dataPathRegRsp.msInfo.sfInfo[i].present.directionPresent = PRESENT;
pMsg->u.dataPathRegRsp.msInfo.sfInfo[i].present.reservationResultPresent = PRESENT;
pMsg->u.dataPathRegRsp.msInfo.sfInfo[i].sfId = pUeCtxt->sfInfo[i].sfId;
pMsg->u.dataPathRegRsp.msInfo.sfInfo[i].direction = pUeCtxt->sfInfo[i].direction;
pMsg->u.dataPathRegRsp.msInfo.sfInfo[i].reservationResult.created = TRUE;
pMsg->u.dataPathRegRsp.msInfo.sfInfo[i].reservationResult.admited = TRUE;
pMsg->u.dataPathRegRsp.msInfo.sfInfo[i].reservationResult.activated = TRUE;
}
pMsg->msgHead.functionType = R64_FUNCTION_TYPE_DATA_PATH;
pMsg->msgHead.messageType = R64_ID_DATA_PATH_REGISTRATION_RESPONSE;
bcopy((char *)&pUeCtxt->msId, (char *)&pMsg->msgHead.msId, sizeof(R64_MS_ID_S));
pMsg->msgHead.transId = pUeCtxt->transId;
pMsg->msgHead.sourceIp = gSourceIp;
pMsg->msgHead.destinationIp = gDestinationIp;
pMsg->msgHead.sourceUdpPort = BS_R6_UDP_PORT;
pMsg->msgHead.destinationUdpPort = GW_R6_UDP_PORT;
pMsg->msgHead.ifType = IF_TYPE_R6;
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -