Commit 6fb3e962 authored by Lionel Gauthier's avatar Lionel Gauthier

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@6063 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent b005d788
......@@ -40,6 +40,24 @@
#include <pthread.h>
#include <stdio.h>
#ifdef ENABLE_USE_NETFILTER_FOR_SGI
#warning "ENABLE_USE_NETFILTER_FOR_SGI"
#define SGI_SOCKET_RAW 1
#define SGI_SOCKET_BIND_TO_IF 1
#undef SGI_MARKING
#undef SGI_PACKET_RX_RING
#undef SGI_SOCKET_UDP
#else
#warning "DISABLE_USE_NETFILTER_FOR_SGI"
//#define SGI_SOCKET_RAW 1
#undef SGI_SOCKET_RAW
#define SGI_SOCKET_DGRAM 1
#define SGI_SOCKET_BIND_TO_IF 1
#undef SGI_PACKET_RX_RING
#undef SGI_MARKING
#undef SGI_SOCKET_UDP
#endif
#ifdef ENABLE_USE_PCAP_FOR_SGI
#include <pcap.h>
#endif
......@@ -167,6 +185,7 @@ typedef struct sgi_addr_mapping_s {
typedef struct sgi_data_s {
int sd[SGI_MAX_EPS_BEARERS_PER_USER];
unsigned int if_index[SGI_MAX_EPS_BEARERS_PER_USER];
int sd6;
char *interface_name;
int interface_name_len;
......@@ -261,6 +280,8 @@ void sgi_send_arp_request(sgi_data_t *sgi_dataP, char* dst_ip_addrP);
//-----------------------------------------------------------------------------
int sgi_create_sockets(sgi_data_t *sgi_data_p);
int sgi_send_data(uint8_t *buffer, uint32_t length, sgi_data_t *sgi_dataP, Teid_t originating_sgw_S1u_teidP);
int sgi_dgram_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP, Teid_t originating_sgw_S1u_teidP);
#ifdef SGI_TEST
unsigned short in_cksum(unsigned short *addr, int len);
void sgi_test_send_ping(sgi_data_t *sgi_dataP, uint32_t markP, uint64_t src_mac_addrP, uint64_t dst_mac_addrP, char* src_ip_addrP, char* dst_ip_addrP);
......@@ -277,4 +298,5 @@ void sgi_forward_ip_packet(sgi_data_t *sgi_dataP, struct ether_header *ehP, int
#ifdef ENABLE_USE_RAW_SOCKET_FOR_SGI
void sgi_process_raw_packet(sgi_data_t *sgi_dataP, unsigned char* dataP, int packet_sizeP);
#endif
void sgi_process_dgram_packet(sgi_data_t *sgi_dataP, unsigned char* dataP, int packet_sizeP);
#endif /* SGI_H_ */
......@@ -350,3 +350,50 @@ void sgi_process_raw_packet(sgi_data_t *sgi_data_pP, unsigned char* data_pP, int
}
#endif
#endif
void sgi_process_dgram_packet(sgi_data_t *sgi_data_pP, unsigned char* data_pP, int packet_sizeP)
{
Gtpv1uTunnelDataReq *gtpv1u_tunnel_data_req_p = NULL;
MessageDef *message_p = NULL;
unsigned char *message_payload_p = NULL ;
struct arphdr *arph_p = NULL;
struct iphdr *iph_p = NULL;
struct ipv6hdr *ip6h_p = NULL;
sgi_addr_mapping_t *addr_mapping_p = NULL;
struct in6_addr dest6_addr;
u_int32_t dest4_addr;
u_int32_t src4_addr;
struct in_addr in_dest_addr;
sgi_print_hex_octets(data_pP, packet_sizeP);
return;
message_p = itti_alloc_new_message(TASK_FW_IP, GTPV1U_TUNNEL_DATA_REQ);
if (message_p == NULL) {
SGI_IF_ERROR("%s OUT OF MEMORY DROP EGRESS PACKET\n", __FUNCTION__);
return;
}
AssertFatal(packet_sizeP > 20, "BAD IP PACKET SIZE");
message_payload_p = itti_malloc(TASK_FW_IP, TASK_GTPV1_U, packet_sizeP + 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 + GTPU_HEADER_OVERHEAD_MAX, data_pP, packet_sizeP);
gtpv1u_tunnel_data_req_p = &message_p->ittiMsg.gtpv1uTunnelDataReq;
gtpv1u_tunnel_data_req_p->S1u_enb_teid = addr_mapping_p->enb_S1U_teid;
//#warning forced S1u_enb_teid to 1 for testing, waiting for MODIFY_BEARER REQUEST
// 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 ;
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__,
gtpv1u_tunnel_data_req_p->S1u_enb_teid,
gtpv1u_tunnel_data_req_p->local_S1u_teid,
gtpv1u_tunnel_data_req_p->length);
itti_send_msg_to_task(TASK_GTPV1_U, INSTANCE_DEFAULT, message_p);
}
This diff is collapsed.
......@@ -92,7 +92,13 @@ static void* sgi_task_thread(void *args_p)
*/
Gtpv1uTunnelDataInd *data_ind_p;
data_ind_p = &received_message_p->ittiMsg.gtpv1uTunnelDataInd;
#ifdef SGI_SOCKET_RAW
sgi_send_data(&data_ind_p->buffer[data_ind_p->offset], data_ind_p->length, sgi_data_p, data_ind_p->local_S1u_teid);
#else
#ifdef SGI_SOCKET_DGRAM
sgi_dgram_send_data(&data_ind_p->buffer[data_ind_p->offset], data_ind_p->length, sgi_data_p, data_ind_p->local_S1u_teid);
#endif
#endif
/* Buffer is no longer needed, free it */
itti_free(ITTI_MSG_ORIGIN_ID(received_message_p), data_ind_p->buffer);
}
......@@ -121,8 +127,10 @@ static void* sgi_task_thread(void *args_p)
{
case ACTIVATE_MESSAGE: {
sgi_data_p->hss_associated = 1;
#if !defined(ENABLE_USE_GTPU_IN_KERNEL)
SGI_IF_DEBUG("HSS ASSOCIATED, CAN START VLANS (bug in freediameter)");
sgi_init_phase2(sgi_data_p);
#endif
} break;
default: {
......
......@@ -64,14 +64,14 @@ void sgi_print_hex_octets(unsigned char* dataP, unsigned long sizeP)
}
gettimeofday(&tv, &tz);
h = tv.tv_sec/3600/24;
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("%s------+-------------------------------------------------|\n",timeofday);
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);
SGI_IF_DEBUG("%s------+-------------------------------------------------+\n",timeofday);
for (octet_index = 0; octet_index < sizeP; octet_index++) {
if ((octet_index % 16) == 0){
if (octet_index != 0) {
......
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