From c99489df2c72ed50a1801b30181f0d8bfd79e353 Mon Sep 17 00:00:00 2001 From: Lionel Gauthier Date: Thu, 6 Nov 2014 08:41:51 +0000 Subject: [PATCH] git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5983 818b1a75-f10b-46b9-bf7c-635c3b92a50f --- openair-cn/SGI/sgi_egress.c | 7 +++++-- openair-cn/SGI/sgi_task.c | 4 ++-- openair-cn/SGI/sgi_util.c | 21 +++++++++++++++------ 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/openair-cn/SGI/sgi_egress.c b/openair-cn/SGI/sgi_egress.c index dd719eb945..04a998bc6b 100755 --- a/openair-cn/SGI/sgi_egress.c +++ b/openair-cn/SGI/sgi_egress.c @@ -314,6 +314,8 @@ void sgi_process_raw_packet(sgi_data_t *sgi_data_pP, unsigned char* data_pP, int //SGI_IF_ERROR("%s UNHANDLED ether type %d of incoming egress packet\n", __FUNCTION__, eh_p->ether_type); return; } + SGI_IF_DEBUG("--------------------------------------------------------------\n%s :\n", __FUNCTION__); + sgi_print_hex_octets(data_pP+sizeof(sgi_data_pP->eh), packet_sizeP - sizeof(sgi_data_pP->eh)); message_p = itti_alloc_new_message(TASK_FW_IP, GTPV1U_TUNNEL_DATA_REQ); if (message_p == NULL) { @@ -321,12 +323,12 @@ void sgi_process_raw_packet(sgi_data_t *sgi_data_pP, unsigned char* data_pP, int return; } AssertFatal((packet_sizeP - sizeof(sgi_data_pP->eh)) > 20, "BAD IP PACKET SIZE"); - message_payload_p = itti_malloc(TASK_FW_IP, TASK_GTPV1_U, packet_sizeP - sizeof(sgi_data_pP->eh)); + message_payload_p = itti_malloc(TASK_FW_IP, TASK_GTPV1_U, packet_sizeP - sizeof(sgi_data_pP->eh) + GTPU_HEADER_OVERHEAD_MAX); if (message_payload_p == NULL) { SGI_IF_ERROR("%s OUT OF MEMORY DROP EGRESS PACKET\n", __FUNCTION__); return; } - memcpy(message_payload_p, data_pP+sizeof(sgi_data_pP->eh), packet_sizeP - sizeof(sgi_data_pP->eh)); + memcpy(message_payload_p + GTPU_HEADER_OVERHEAD_MAX, data_pP+sizeof(sgi_data_pP->eh), packet_sizeP - sizeof(sgi_data_pP->eh)); gtpv1u_tunnel_data_req_p = &message_p->ittiMsg.gtpv1uTunnelDataReq; gtpv1u_tunnel_data_req_p->S1u_enb_teid = addr_mapping_p->enb_S1U_teid; @@ -334,6 +336,7 @@ void sgi_process_raw_packet(sgi_data_t *sgi_data_pP, unsigned char* data_pP, int // gtpv1u_tunnel_data_req_p->S1u_enb_teid = 1; gtpv1u_tunnel_data_req_p->local_S1u_teid = addr_mapping_p->sgw_S1U_teid; gtpv1u_tunnel_data_req_p->length = packet_sizeP - sizeof(sgi_data_pP->eh); + gtpv1u_tunnel_data_req_p->offset = GTPU_HEADER_OVERHEAD_MAX; gtpv1u_tunnel_data_req_p->buffer = message_payload_p; SGI_IF_DEBUG("%s send GTPV1U_TUNNEL_DATA_REQ to GTPV1U S1u_enb_teid %u local_S1u_teid %u size %u\n", __FUNCTION__, diff --git a/openair-cn/SGI/sgi_task.c b/openair-cn/SGI/sgi_task.c index 6987fe4b30..d70a8d300c 100644 --- a/openair-cn/SGI/sgi_task.c +++ b/openair-cn/SGI/sgi_task.c @@ -92,9 +92,9 @@ static void* sgi_task_thread(void *args_p) */ Gtpv1uTunnelDataInd *data_ind_p; data_ind_p = &received_message_p->ittiMsg.gtpv1uTunnelDataInd; - sgi_send_data(data_ind_p->buffer, data_ind_p->length, sgi_data_p, data_ind_p->local_S1u_teid); + sgi_send_data(&data_ind_p->buffer[data_ind_p->offset], data_ind_p->length, sgi_data_p, data_ind_p->local_S1u_teid); /* Buffer is no longer needed, free it */ - free(data_ind_p->buffer); + itti_free(ITTI_MSG_ORIGIN_ID(received_message_p), data_ind_p->buffer); } break; case SGI_CREATE_ENDPOINT_REQUEST: { diff --git a/openair-cn/SGI/sgi_util.c b/openair-cn/SGI/sgi_util.c index 74390d42a2..969179f6d8 100755 --- a/openair-cn/SGI/sgi_util.c +++ b/openair-cn/SGI/sgi_util.c @@ -42,6 +42,7 @@ #include #include #include +#include #include "sgi.h" #define FW_2_PRINT_BUFFER_LEN 10000 @@ -50,24 +51,32 @@ static char fw_2_print_buffer[FW_2_PRINT_BUFFER_LEN]; void sgi_print_hex_octets(unsigned char* dataP, unsigned long sizeP) //----------------------------------------------------------------------------- { - return; unsigned long octet_index = 0; unsigned long buffer_marker = 0; unsigned char aindex; + struct timeval tv; + struct timezone tz; + char timeofday[64]; + unsigned int h,m,s; if (dataP == NULL) { return; } + gettimeofday(&tv, &tz); + h = tv.tv_sec/3600/24; + m = (tv.tv_sec / 60) % 60; + s = tv.tv_sec % 60; + snprintf(timeofday, 64, "%02d:%02d:%02d.%06d", h,m,s,tv.tv_usec); - SGI_IF_DEBUG("------+-------------------------------------------------|\n"); - SGI_IF_DEBUG(" | 0 1 2 3 4 5 6 7 8 9 a b c d e f |\n"); - SGI_IF_DEBUG("------+-------------------------------------------------|\n"); + SGI_IF_DEBUG("%s------+-------------------------------------------------|\n",timeofday); + SGI_IF_DEBUG("%s | 0 1 2 3 4 5 6 7 8 9 a b c d e f |\n",timeofday); + SGI_IF_DEBUG("%s------+-------------------------------------------------|\n",timeofday); for (octet_index = 0; octet_index < sizeP; octet_index++) { if ((octet_index % 16) == 0){ if (octet_index != 0) { buffer_marker+=snprintf(&fw_2_print_buffer[buffer_marker], FW_2_PRINT_BUFFER_LEN - buffer_marker, " |\n"); - SGI_IF_DEBUG("%s", fw_2_print_buffer); + SGI_IF_DEBUG("%s%s",timeofday, fw_2_print_buffer); buffer_marker = 0; } buffer_marker+=snprintf(&fw_2_print_buffer[buffer_marker], FW_2_PRINT_BUFFER_LEN - buffer_marker, " %04ld |", octet_index); @@ -88,7 +97,7 @@ void sgi_print_hex_octets(unsigned char* dataP, unsigned long sizeP) buffer_marker+=snprintf(&fw_2_print_buffer[buffer_marker], FW_2_PRINT_BUFFER_LEN - buffer_marker, " "); //SGI_IF_DEBUG(" "); buffer_marker+=snprintf(&fw_2_print_buffer[buffer_marker], FW_2_PRINT_BUFFER_LEN - buffer_marker, " |\n"); - SGI_IF_DEBUG("%s",fw_2_print_buffer); + SGI_IF_DEBUG("%s%s",timeofday,fw_2_print_buffer); } //-----------------------------------------------------------------------------