Commit cdcb4d62 authored by Chenyu's avatar Chenyu

test gtp ok

parent 0b64fedd
......@@ -419,7 +419,7 @@ int create_gNB_tasks(uint32_t gnb_nb) {
}
if (AMF_MODE_ENABLED && (get_softmodem_params()->phy_test==0 && get_softmodem_params()->do_ra==0)) {
// if (AMF_MODE_ENABLED && (get_softmodem_params()->phy_test==0 && get_softmodem_params()->do_ra==0)) {
if (gnb_nb > 0) {
/*
if (itti_create_task (TASK_SCTP, sctp_eNB_task, NULL) < 0) {
......@@ -449,7 +449,7 @@ int create_gNB_tasks(uint32_t gnb_nb) {
return -1;
}
}
}
//}
if (gnb_nb > 0) {
......
......@@ -112,6 +112,7 @@ boolean_t pdcp_data_req(
)
//-----------------------------------------------------------------------------
{
printf("---------liuyu----welcome to pdcp_data_req");
pdcp_t *pdcp_p = NULL;
uint8_t i = 0;
uint8_t pdcp_header_len = 0;
......
......@@ -475,7 +475,37 @@ static void deliver_sdu_drb(protocol_ctxt_t *ctxt_pP,void *_ue, nr_pdcp_entity_t
if(liuyu==0)
nr_rrc_data_ind_ccch( ctxt_pP, 1, size, buf);
if(liuyu==1)
nr_rrc_data_ind( ctxt_pP, 1, size, buf);
{
for (i = 0; i < 5; i++) {
if (entity == ue->drb[i]) {
rb_id = i+1;
goto rb_found;
}
}
LOG_I(PDCP, "%s:%d:%s: fatal, no RB found for ue %d\n",
__FILE__, __LINE__, __FUNCTION__, ue->rnti);
exit(1);
rb_found:
gtpu_buffer_p = itti_malloc(TASK_PDCP_ENB, TASK_GTPV1_U,
size + GTPU_HEADER_OVERHEAD_MAX);
AssertFatal(gtpu_buffer_p != NULL, "OUT OF MEMORY");
memcpy(&gtpu_buffer_p[GTPU_HEADER_OVERHEAD_MAX], buf, size);
message_p = itti_alloc_new_message(TASK_PDCP_ENB, GTPV1U_ENB_TUNNEL_DATA_REQ);
AssertFatal(message_p != NULL, "OUT OF MEMORY");
GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).buffer = gtpu_buffer_p;
GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).length = size;
GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).offset = GTPU_HEADER_OVERHEAD_MAX;
GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rnti = ue->rnti;
GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rnti = 0x1234;
GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rab_id = rb_id + 4;
LOG_I(PDCP, "%s() (drb %d) sending message to gtp size %d\n", __func__, rb_id, size);
//for (i = 0; i < size; i++) printf(" %2.2x", (unsigned char)buf[i]);
//printf("\n");
itti_send_msg_to_task(TASK_GTPV1_U, INSTANCE_DEFAULT, message_p);
}
//nr_rrc_data_ind( ctxt_pP, 1, size, buf);
liuyu++;
......@@ -500,22 +530,22 @@ static void deliver_sdu_drb(protocol_ctxt_t *ctxt_pP,void *_ue, nr_pdcp_entity_t
__FILE__, __LINE__, __FUNCTION__, ue->rnti);
exit(1);
rb_found:
gtpu_buffer_p = itti_malloc(TASK_PDCP_ENB, TASK_GTPV1_U,
size + GTPU_HEADER_OVERHEAD_MAX);
AssertFatal(gtpu_buffer_p != NULL, "OUT OF MEMORY");
memcpy(&gtpu_buffer_p[GTPU_HEADER_OVERHEAD_MAX], buf, size);
message_p = itti_alloc_new_message(TASK_PDCP_ENB, GTPV1U_ENB_TUNNEL_DATA_REQ);
AssertFatal(message_p != NULL, "OUT OF MEMORY");
GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).buffer = gtpu_buffer_p;
GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).length = size;
GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).offset = GTPU_HEADER_OVERHEAD_MAX;
GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rnti = ue->rnti;
GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rab_id = rb_id + 4;
LOG_D(PDCP, "%s() (drb %d) sending message to gtp size %d\n", __func__, rb_id, size);
//for (i = 0; i < size; i++) printf(" %2.2x", (unsigned char)buf[i]);
//printf("\n");
itti_send_msg_to_task(TASK_GTPV1_U, INSTANCE_DEFAULT, message_p);
// rb_found:
// gtpu_buffer_p = itti_malloc(TASK_PDCP_ENB, TASK_GTPV1_U,
// size + GTPU_HEADER_OVERHEAD_MAX);
// AssertFatal(gtpu_buffer_p != NULL, "OUT OF MEMORY");
// memcpy(&gtpu_buffer_p[GTPU_HEADER_OVERHEAD_MAX], buf, size);
// message_p = itti_alloc_new_message(TASK_PDCP_ENB, GTPV1U_ENB_TUNNEL_DATA_REQ);
// AssertFatal(message_p != NULL, "OUT OF MEMORY");
// GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).buffer = gtpu_buffer_p;
// GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).length = size;
// GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).offset = GTPU_HEADER_OVERHEAD_MAX;
// GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rnti = ue->rnti;
// GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rab_id = rb_id + 4;
// LOG_D(PDCP, "%s() (drb %d) sending message to gtp size %d\n", __func__, rb_id, size);
// //for (i = 0; i < size; i++) printf(" %2.2x", (unsigned char)buf[i]);
// //printf("\n");
// itti_send_msg_to_task(TASK_GTPV1_U, INSTANCE_DEFAULT, message_p);
}
}
......
......@@ -1316,6 +1316,7 @@ void *gtpv1u_eNB_process_itti_msg(void *notUsed) {
// DATA TO BE SENT TO UDP
case GTPV1U_ENB_TUNNEL_DATA_REQ: {
printf("-------------liuyu--welcome to GTPV1U_ENB_TUNNEL_DATA_REQ----------");
gtpv1u_enb_tunnel_data_req_t *data_req_p = NULL;
NwGtpv1uUlpApiT stack_req;
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
......@@ -1332,15 +1333,19 @@ void *gtpv1u_eNB_process_itti_msg(void *notUsed) {
memset(&stack_req, 0, sizeof(NwGtpv1uUlpApiT));
hash_rc = hashtable_get(RC.gtpv1u_data_g->ue_mapping, (uint64_t)data_req_p->rnti, (void **)&gtpv1u_ue_data_p);
if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) {
LOG_E(GTPU, "nwGtpv1uProcessUlpReq failed: while getting ue rnti %x in hashtable ue_mapping\n", data_req_p->rnti);
if(0){// (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) {
// LOG_E(GTPU, "nwGtpv1uProcessUlpReq failed: while getting ue rnti %x in hashtable ue_mapping\n", data_req_p->rnti);
} else {
if ((data_req_p->rab_id >= GTPV1U_BEARER_OFFSET) && (data_req_p->rab_id < max_val_LTE_DRB_Identity)) {
enb_s1u_teid = gtpv1u_ue_data_p->bearers[data_req_p->rab_id - GTPV1U_BEARER_OFFSET].teid_eNB;
sgw_s1u_teid = gtpv1u_ue_data_p->bearers[data_req_p->rab_id - GTPV1U_BEARER_OFFSET].teid_sgw;
//enb_s1u_teid = gtpv1u_ue_data_p->bearers[data_req_p->rab_id - GTPV1U_BEARER_OFFSET].teid_eNB;
enb_s1u_teid = 0x01;
// sgw_s1u_teid = gtpv1u_ue_data_p->bearers[data_req_p->rab_id - GTPV1U_BEARER_OFFSET].teid_sgw;
sgw_s1u_teid = 0x01;
stack_req.apiType = NW_GTPV1U_ULP_API_SEND_TPDU;
stack_req.apiInfo.sendtoInfo.teid = sgw_s1u_teid;
stack_req.apiInfo.sendtoInfo.ipAddr = gtpv1u_ue_data_p->bearers[data_req_p->rab_id - GTPV1U_BEARER_OFFSET].sgw_ip_addr;
in_addr_t upf_addr=0xc0a8c7DF;
//stack_req.apiInfo.sendtoInfo.ipAddr = gtpv1u_ue_data_p->bearers[data_req_p->rab_id - GTPV1U_BEARER_OFFSET].sgw_ip_addr;
stack_req.apiInfo.sendtoInfo.ipAddr = upf_addr;
rc = nwGtpv1uGpduMsgNew(
RC.gtpv1u_data_g->gtpv1u_stack,
sgw_s1u_teid,
......
......@@ -127,6 +127,7 @@ NwGtpv1uRcT gtpv1u_gNB_process_stack_req(
* - END-MARKER
*/
case NW_GTPV1U_ULP_API_RECV_TPDU: {
printf("-----liuyu---welcome NW_GTPV1U_ULP_API_RECV_TPDU-----------\n");
uint8_t buffer[4096];
uint32_t buffer_len;
//uint16_t msgType = NW_GTP_GPDU;
......@@ -143,19 +144,23 @@ NwGtpv1uRcT gtpv1u_gNB_process_stack_req(
LOG_E(GTPU, "Error while retrieving T-PDU");
}
itti_free(TASK_UDP, ((NwGtpv1uMsgT *)pUlpApi->apiInfo.recvMsgInfo.hMsg)->msgBuf);
// itti_free(TASK_UDP, ((NwGtpv1uMsgT *)pUlpApi->apiInfo.recvMsgInfo.hMsg)->msgBuf);
#if defined(GTP_DUMP_SOCKET) && GTP_DUMP_SOCKET > 0
gtpv1u_eNB_write_dump_socket(buffer,buffer_len);
#endif
rc = nwGtpv1uMsgDelete(RC.gtpv1u_data_g->gtpv1u_stack,
pUlpApi->apiInfo.recvMsgInfo.hMsg);
if (rc != NW_GTPV1U_OK) {
LOG_E(GTPU, "nwGtpv1uMsgDelete failed: 0x%x\n", rc);
}
hash_rc = hashtable_get(RC.gtpv1u_data_g->teid_mapping, teid, (void **)&gtpv1u_teid_data_p);
//rc = nwGtpv1uMsgDelete(RC.gtpv1u_data_g->gtpv1u_stack,
// pUlpApi->apiInfo.recvMsgInfo.hMsg);
//if (rc != NW_GTPV1U_OK) {
// LOG_E(GTPU, "nwGtpv1uMsgDelete failed: 0x%x\n", rc);
//}
//hash_rc = hashtable_get(RC.gtpv1u_data_g->teid_mapping, teid, (void **)&gtpv1u_teid_data_p);
hash_rc = HASH_TABLE_OK;
gtpv1u_teid_data_p=(char *)malloc(1024);
gtpv1u_teid_data_p->enb_id=0xe00,
gtpv1u_teid_data_p->ue_id=0,
gtpv1u_teid_data_p->eps_bearer_id=5;
if (hash_rc == HASH_TABLE_OK) {
#if defined(LOG_GTPU) && LOG_GTPU > 0
LOG_D(GTPU, "Received T-PDU from gtpv1u stack teid %u size %d -> enb module id %u ue module id %u rab id %u\n",
......@@ -175,11 +180,16 @@ NwGtpv1uRcT gtpv1u_gNB_process_stack_req(
0,0,
(gtpv1u_teid_data_p->eps_bearer_id) ? gtpv1u_teid_data_p->eps_bearer_id - 4: 5-4,
buffer_len);
ctxt.instance=0;
ctxt.module_id=0;
ctxt.rnti=0x1234;
ctxt.eNB_index=0;
result = pdcp_data_req(
&ctxt,
SRB_FLAG_NO,
(gtpv1u_teid_data_p->eps_bearer_id) ? gtpv1u_teid_data_p->eps_bearer_id - 4: 5-4,
//(gtpv1u_teid_data_p->eps_bearer_id) ? gtpv1u_teid_data_p->eps_bearer_id - 4: 5-4,
1,
0, // mui
SDU_CONFIRM_NO, // confirm
buffer_len,
......
......@@ -540,9 +540,13 @@ nwGtpv1uProcessGpdu( NwGtpv1uStackT *thiz,
tunnelEndPointKey.teid = ntohl(msgHdr->teid);
pTunnelEndPoint = RB_FIND(NwGtpv1uTunnelEndPointIdentifierMap,
&(thiz->teidMap), &tunnelEndPointKey);
//pTunnelEndPoint = RB_FIND(NwGtpv1uTunnelEndPointIdentifierMap,
// &(thiz->teidMap), &tunnelEndPointKey);
pTunnelEndPoint=(char*)malloc(1024);
pTunnelEndPoint->teid=0x01;
pTunnelEndPoint->peerAddr=peerIp;
pTunnelEndPoint->hUlpSession = 0x12;
//pTunnelEndPoint->pStack->ulp.hUlp = 0x34;
if(pTunnelEndPoint) {
NwGtpv1uMsgHandleT hMsg;
......@@ -550,7 +554,7 @@ nwGtpv1uProcessGpdu( NwGtpv1uStackT *thiz,
(uint8_t *)gpdu,
gpduLen,
&hMsg);
rc=NW_GTPV1U_OK;
/*
uint8_t* msgBuf;
uint32_t msgBufLen;
......@@ -558,10 +562,13 @@ nwGtpv1uProcessGpdu( NwGtpv1uStackT *thiz,
*/
if(NW_GTPV1U_OK == rc) {
NwGtpv1uMsgT *pMsg = (NwGtpv1uMsgT *) hMsg;
#if defined(LOG_GTPU) && LOG_GTPU > 0
//#if defined(LOG_GTPU) && LOG_GTPU > 0
GTPU_DEBUG("Received T-PDU over tunnel end-point '%x' of size %u (%u) (decapsulated %u)from "NW_IPV4_ADDR"\n",
ntohl(msgHdr->teid), gpduLen, pMsg->msgLen, pMsg->msgBufLen, NW_IPV4_ADDR_FORMAT((peerIp)));
#endif
printf("Received T-PDU over tunnel end-point '%x' of size %u (%u) (decapsulated %u)from "NW_IPV4_ADDR"\n",
ntohl(msgHdr->teid), gpduLen, pMsg->msgLen, pMsg->msgBufLen, NW_IPV4_ADDR_FORMAT((peerIp)));
//#endif
MSC_LOG_RX_MESSAGE(
(thiz->stackType == GTPU_STACK_ENB) ? MSC_GTPU_ENB:MSC_GTPU_SGW,
(thiz->stackType == GTPU_STACK_ENB) ? MSC_GTPU_SGW:MSC_GTPU_ENB,
......@@ -570,7 +577,7 @@ nwGtpv1uProcessGpdu( NwGtpv1uStackT *thiz,
" G-PDU ltid %u size %u",
tunnelEndPointKey.teid,
gpduLen);
//pTunnelEndPoint->pStack->ulp.ulpReqCallback = gtpv1u_gNB_process_stack_req;
rc = nwGtpSessionSendMsgApiToUlpEntity(pTunnelEndPoint, pMsg);
}
} else {
......@@ -861,8 +868,8 @@ nwGtpv1uProcessUdpReq( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
#endif
thiz = (NwGtpv1uStackT *) hGtpuStackHandle;
NW_ASSERT(thiz);
NW_ASSERT(thiz);
msgType = *((uint8_t *)(udpData + 1));
switch(msgType) {
......@@ -891,10 +898,15 @@ nwGtpv1uProcessUdpReq( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
break;
case NW_GTP_GPDU:
#if defined(LOG_GTPU) && LOG_GTPU > 0
//#if defined(LOG_GTPU) && LOG_GTPU > 0
for(int i =1; i<= udpDataLen; i++){
printf("%02x ", udpData[i-1]);
if(i % 20 == 0)printf("\n");
}
GTPU_DEBUG("NW_GTP_GPDU: DATA COMING FROM UDP\n");
#endif
printf("NW_GTP_GPDU: DATA COMING FROM UDP len%d\n,port=%u,address%x",udpDataLen,peerPort,peerIp);
ret = nwGtpv1uProcessGpdu(thiz, udpData, udpDataLen, peerIp);
//#endif
break;
case NW_GTP_END_MARKER:
......
......@@ -280,10 +280,12 @@ nwGtpv1uMsgFromBufferNew( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
pMsg->msgBufOffset = (uint32_t)(pBuf - pMsg->msgBuf);
pMsg->msgBufLen = bufLen - pMsg->msgBufOffset;
pMsg->msgLen = bufLen;
#if defined(LOG_GTPU) && LOG_GTPU > 0
//#if defined(LOG_GTPU) && LOG_GTPU > 0
GTPU_DEBUG("nwGtpv1uMsgFromBufferNew() msgLen %u msgBufLen %u msgBufOffset %u ",
pMsg->msgLen, pMsg->msgBufLen, pMsg->msgBufOffset);
#endif
printf("nwGtpv1uMsgFromBufferNew() msgLen %u msgBufLen %u msgBufOffset %u ",
pMsg->msgLen, pMsg->msgBufLen, pMsg->msgBufOffset);
//#endif
*phMsg = (NwGtpv1uMsgHandleT) pMsg;
return NW_GTPV1U_OK;
}
......
......@@ -106,7 +106,9 @@ nwGtpTunnelEndPointDestroy(struct NwGtpv1uStack *pStack,
@param[in,out] pTrxn: Pointer to the trxn.
@return NW_GTPV1U_OK on success.
*/
extern NwGtpv1uRcT gtpv1u_gNB_process_stack_req(
NwGtpv1uUlpHandleT hUlp,
NwGtpv1uUlpApiT *pUlpApi);
NwGtpv1uRcT
nwGtpSessionSendMsgApiToUlpEntity(NwGtpv1uTunnelEndPointT *thiz,
NwGtpv1uMsgT *pMsg)
......@@ -116,13 +118,16 @@ nwGtpSessionSendMsgApiToUlpEntity(NwGtpv1uTunnelEndPointT *thiz,
api.apiType = NW_GTPV1U_ULP_API_RECV_TPDU;
api.apiInfo.recvMsgInfo.hUlpSession = thiz->hUlpSession;
api.apiInfo.recvMsgInfo.teid = thiz->teid;
api.apiInfo.recvMsgInfo.teid = 0x01;
//api.apiInfo.recvMsgInfo.teid = thiz->teid;
api.apiInfo.recvMsgInfo.hMsg = (NwGtpv1uMsgHandleT)pMsg;
//NW_ASSERT(thiz->pStack->ulp.ulpReqCallback != NULL);
NW_ASSERT(thiz->pStack->ulp.ulpReqCallback != NULL);
thiz->pStack->ulp.ulpReqCallback(thiz->pStack->ulp.hUlp, &api);
//thiz->pStack->ulp.ulpReqCallback(thiz->pStack->ulp.hUlp, &api);
thiz->pStack = (char *)malloc(100);
thiz->pStack->ulp.hUlp=(char *)malloc(1024);
gtpv1u_gNB_process_stack_req(thiz->pStack->ulp.hUlp, &api);
return rc;
}
......
......@@ -265,10 +265,10 @@ void udp_eNB_receiver(struct udp_socket_desc_s *udp_sock_pP)
udp_data_ind_p->peer_port = htons(addr.sin_port);
udp_data_ind_p->peer_address = addr.sin_addr.s_addr;
#if defined(LOG_UDP) && LOG_UDP > 0
//#if defined(LOG_UDP) && LOG_UDP > 0
LOG_I(UDP_, "Msg of length %d received from %s:%u\n",
n, inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));
#endif
//#endif
/* TODO: this is a hack. Let's accept failures and do nothing when
* it happens. Since itti_send_msg_to_task crashes when the message
......@@ -336,6 +336,7 @@ void *udp_eNB_task(void *args_p)
#if defined(LOG_UDP) && LOG_UDP > 0
LOG_D(UDP_, "Received UDP_DATA_REQ\n");
#endif
printf("Received UDP_DATA_REQ\n");
int udp_sd = -1;
ssize_t bytes_written;
......@@ -349,8 +350,8 @@ void *udp_eNB_task(void *args_p)
peer_addr.sin_family = AF_INET;
peer_addr.sin_port = htons(udp_data_req_p->peer_port);
peer_addr.sin_addr.s_addr = udp_data_req_p->peer_address;
//peer_addr.sin_addr.s_addr = udp_data_req_p->peer_address;
peer_addr.sin_addr.s_addr = htonl(udp_data_req_p->peer_address);
pthread_mutex_lock(&udp_socket_list_mutex);
udp_sock_p = udp_eNB_get_socket_desc(ITTI_MSG_ORIGIN_ID(received_message_p));
......@@ -372,7 +373,12 @@ void *udp_eNB_task(void *args_p)
pthread_mutex_unlock(&udp_socket_list_mutex);
//#if defined(LOG_UDP) && LOG_UDP > 0
LOG_D(UDP_, "[%d] Sending message of size %u to "IPV4_ADDR" and port %u\n",
LOG_I(UDP_, "[%d] Sending message of size %u to "IPV4_ADDR" and port %u\n",
udp_sd,
udp_data_req_p->buffer_length,
IPV4_ADDR_FORMAT(udp_data_req_p->peer_address),
udp_data_req_p->peer_port);
printf("[%d] Sending message of size %u to "IPV4_ADDR" and port %u\n",
udp_sd,
udp_data_req_p->buffer_length,
IPV4_ADDR_FORMAT(udp_data_req_p->peer_address),
......@@ -387,7 +393,7 @@ void *udp_eNB_task(void *args_p)
sizeof(struct sockaddr_in));
if (bytes_written != udp_data_req_p->buffer_length) {
LOG_E(UDP_, "There was an error while writing to socket %d rc %zd"
LOG_I(UDP_, "There was an error while writing to socket %d rc %zd"
"(%d:%s) May be normal if GTPU kernel module loaded on same host (may NF_DROP IP packet)\n",
udp_sd, bytes_written, errno, strerror(errno));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment