Commit d971f434 authored by Lionel Gauthier's avatar Lionel Gauthier

Hashtable rename + config

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5069 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent db9f0bbd
...@@ -187,7 +187,8 @@ typedef struct sgi_read_thread_args_s { ...@@ -187,7 +187,8 @@ typedef struct sgi_read_thread_args_s {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// sgi_task.c // sgi_task.c
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
int sgi_init(const mme_config_t *mme_config); #include "spgw_config.h"
int sgi_init(const pgw_config_t *pgw_config_p);
char* sgi_status_2_str(SGIStatus_t statusP); char* sgi_status_2_str(SGIStatus_t statusP);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
......
...@@ -57,7 +57,7 @@ void sgi_process_raw_packet(sgi_data_t *sgi_data_pP, unsigned char* data_pP, int ...@@ -57,7 +57,7 @@ void sgi_process_raw_packet(sgi_data_t *sgi_data_pP, unsigned char* data_pP, int
//******************* //*******************
iph_p = (struct iphdr *) (data_pP + sizeof(struct ether_header)); iph_p = (struct iphdr *) (data_pP + sizeof(struct ether_header));
dest4_addr = iph_p->daddr; dest4_addr = iph_p->daddr;
if (hashtbl_get(sgi_data_pP->addr_v4_mapping, dest4_addr, (void**)&addr_mapping_p) == HASH_TABLE_OK) { if (hashtable_get(sgi_data_pP->addr_v4_mapping, dest4_addr, (void**)&addr_mapping_p) == HASH_TABLE_OK) {
memcpy(eh_p->ether_dhost, addr_mapping_p->ue_mac_addr, ETH_ALEN); memcpy(eh_p->ether_dhost, addr_mapping_p->ue_mac_addr, ETH_ALEN);
} else { } else {
...@@ -78,7 +78,7 @@ void sgi_process_raw_packet(sgi_data_t *sgi_data_pP, unsigned char* data_pP, int ...@@ -78,7 +78,7 @@ void sgi_process_raw_packet(sgi_data_t *sgi_data_pP, unsigned char* data_pP, int
//******************* //*******************
ip6h_p = (struct ipv6hdr *) (data_pP + sizeof(struct ether_header)); ip6h_p = (struct ipv6hdr *) (data_pP + sizeof(struct ether_header));
memcpy(dest6_addr.__in6_u.__u6_addr8, ip6h_p->daddr.__in6_u.__u6_addr8, 16); memcpy(dest6_addr.__in6_u.__u6_addr8, ip6h_p->daddr.__in6_u.__u6_addr8, 16);
if (obj_hashtbl_get(sgi_data_pP->addr_v6_mapping, (void*)&dest6_addr, sizeof(struct in6_addr), (void**)&addr_mapping_p) == HASH_TABLE_OK) { if (obj_hashtable_get(sgi_data_pP->addr_v6_mapping, (void*)&dest6_addr, sizeof(struct in6_addr), (void**)&addr_mapping_p) == HASH_TABLE_OK) {
memcpy(eh_p->ether_dhost, addr_mapping_p->ue_mac_addr, ETH_ALEN); memcpy(eh_p->ether_dhost, addr_mapping_p->ue_mac_addr, ETH_ALEN);
} else { } else {
SGI_IF_WARNING("%s Dropping incoming egress IPV6 packet, IPV6 dest %X:%X:%X:%X:%X:%X:%X:%X not found \n", __FUNCTION__, NIP6ADDR(&dest6_addr)); SGI_IF_WARNING("%s Dropping incoming egress IPV6 packet, IPV6 dest %X:%X:%X:%X:%X:%X:%X:%X not found \n", __FUNCTION__, NIP6ADDR(&dest6_addr));
...@@ -106,7 +106,7 @@ void sgi_process_raw_packet(sgi_data_t *sgi_data_pP, unsigned char* data_pP, int ...@@ -106,7 +106,7 @@ void sgi_process_raw_packet(sgi_data_t *sgi_data_pP, unsigned char* data_pP, int
// get " unsigned char __ar_tip[4]; /* Target IP address. */" (from /usr/include/net/if_apr.h line 68) // get " unsigned char __ar_tip[4]; /* Target IP address. */" (from /usr/include/net/if_apr.h line 68)
memcpy(&dest4_addr, &((unsigned char*)(&arph_p[1]))[ETH_ALEN*2+4], 4); memcpy(&dest4_addr, &((unsigned char*)(&arph_p[1]))[ETH_ALEN*2+4], 4);
SGI_IF_DEBUG("%s ARP OPCODE %s TARGET IP %d.%d.%d.%d\n", __FUNCTION__, sgi_arpopcode_2_str(ntohl(arph_p->ar_op)), NIPADDR(dest4_addr)); SGI_IF_DEBUG("%s ARP OPCODE %s TARGET IP %d.%d.%d.%d\n", __FUNCTION__, sgi_arpopcode_2_str(ntohl(arph_p->ar_op)), NIPADDR(dest4_addr));
if (hashtbl_get(sgi_data_pP->addr_v4_mapping, dest4_addr, (void**)&addr_mapping_p) == HASH_TABLE_OK) { if (hashtable_get(sgi_data_pP->addr_v4_mapping, dest4_addr, (void**)&addr_mapping_p) == HASH_TABLE_OK) {
memcpy(eh_p->ether_dhost, addr_mapping_p->ue_mac_addr, ETH_ALEN); memcpy(eh_p->ether_dhost, addr_mapping_p->ue_mac_addr, ETH_ALEN);
} else { } else {
if (sgi_data_pP->ipv4_addr == dest4_addr) { if (sgi_data_pP->ipv4_addr == dest4_addr) {
...@@ -196,7 +196,7 @@ void sgi_process_raw_packet(sgi_data_t *sgi_data_pP, unsigned char* data_pP, int ...@@ -196,7 +196,7 @@ void sgi_process_raw_packet(sgi_data_t *sgi_data_pP, unsigned char* data_pP, int
//******************* //*******************
iph_p = (struct iphdr *) (data_pP + sizeof(struct ether_header)); iph_p = (struct iphdr *) (data_pP + sizeof(struct ether_header));
dest4_addr = iph_p->daddr; dest4_addr = iph_p->daddr;
if (hashtbl_get(sgi_data_pP->addr_v4_mapping, dest4_addr, (void**)&addr_mapping_p) != HASH_TABLE_OK) { if (hashtable_get(sgi_data_pP->addr_v4_mapping, dest4_addr, (void**)&addr_mapping_p) != HASH_TABLE_OK) {
if (sgi_data_pP->ipv4_addr == dest4_addr) { if (sgi_data_pP->ipv4_addr == dest4_addr) {
SGI_IF_DEBUG("%s Dropping incoming egress IPV4 packet not UE IP flow\n", __FUNCTION__); SGI_IF_DEBUG("%s Dropping incoming egress IPV4 packet not UE IP flow\n", __FUNCTION__);
return; return;
...@@ -214,7 +214,7 @@ void sgi_process_raw_packet(sgi_data_t *sgi_data_pP, unsigned char* data_pP, int ...@@ -214,7 +214,7 @@ void sgi_process_raw_packet(sgi_data_t *sgi_data_pP, unsigned char* data_pP, int
//******************* //*******************
ip6h_p = (struct ipv6hdr *) (data_pP + sizeof(struct ether_header)); ip6h_p = (struct ipv6hdr *) (data_pP + sizeof(struct ether_header));
memcpy(dest6_addr.__in6_u.__u6_addr8, ip6h_p->daddr.__in6_u.__u6_addr8, 16); memcpy(dest6_addr.__in6_u.__u6_addr8, ip6h_p->daddr.__in6_u.__u6_addr8, 16);
if (obj_hashtbl_get(sgi_data_pP->addr_v6_mapping, (void*)&dest6_addr, sizeof(struct in6_addr), (void**)&addr_mapping_p) != HASH_TABLE_OK) { if (obj_hashtable_get(sgi_data_pP->addr_v6_mapping, (void*)&dest6_addr, sizeof(struct in6_addr), (void**)&addr_mapping_p) != HASH_TABLE_OK) {
SGI_IF_WARNING("%s Dropping incoming egress IPV6 packet, IPV6 dest %X:%X:%X:%X:%X:%X:%X:%X not found \n", __FUNCTION__, NIP6ADDR(&dest6_addr)); SGI_IF_WARNING("%s Dropping incoming egress IPV6 packet, IPV6 dest %X:%X:%X:%X:%X:%X:%X:%X not found \n", __FUNCTION__, NIP6ADDR(&dest6_addr));
return; return;
} }
...@@ -239,7 +239,7 @@ void sgi_process_raw_packet(sgi_data_t *sgi_data_pP, unsigned char* data_pP, int ...@@ -239,7 +239,7 @@ void sgi_process_raw_packet(sgi_data_t *sgi_data_pP, unsigned char* data_pP, int
// get " unsigned char __ar_tip[4]; /* Target IP address. */" (from /usr/include/net/if_apr.h line 68) // get " unsigned char __ar_tip[4]; /* Target IP address. */" (from /usr/include/net/if_apr.h line 68)
memcpy(&dest4_addr, &((unsigned char*)(&arph_p[1]))[ETH_ALEN*2+4], 4); memcpy(&dest4_addr, &((unsigned char*)(&arph_p[1]))[ETH_ALEN*2+4], 4);
SGI_IF_DEBUG("%s ARP OPCODE %s TARGET IP %d.%d.%d.%d\n", __FUNCTION__, sgi_arpopcode_2_str(ntohl(arph_p->ar_op)), NIPADDR(dest4_addr)); SGI_IF_DEBUG("%s ARP OPCODE %s TARGET IP %d.%d.%d.%d\n", __FUNCTION__, sgi_arpopcode_2_str(ntohl(arph_p->ar_op)), NIPADDR(dest4_addr));
if (hashtbl_get(sgi_data_pP->addr_v4_mapping, dest4_addr, (void**)&addr_mapping_p) != HASH_TABLE_OK) { if (hashtable_get(sgi_data_pP->addr_v4_mapping, dest4_addr, (void**)&addr_mapping_p) != HASH_TABLE_OK) {
if (sgi_data_pP->ipv4_addr == dest4_addr) { if (sgi_data_pP->ipv4_addr == dest4_addr) {
SGI_IF_DEBUG("%s Dropping incoming egress IPV4 packet not UE IP flow\n", __FUNCTION__); SGI_IF_DEBUG("%s Dropping incoming egress IPV4 packet not UE IP flow\n", __FUNCTION__);
return; return;
......
...@@ -277,7 +277,7 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP, ...@@ -277,7 +277,7 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP,
struct ipv6hdr *ip6h_p = NULL; struct ipv6hdr *ip6h_p = NULL;
sgi_teid_mapping_t *mapping_p = NULL; sgi_teid_mapping_t *mapping_p = NULL;
sgi_addr_mapping_t *addr_mapping_p = NULL; sgi_addr_mapping_t *addr_mapping_p = NULL;
hashtbl_rc_t hash_rc; hashtable_rc_t hash_rc;
struct in6_addr src6_addr; /* source address */ struct in6_addr src6_addr; /* source address */
struct in6_addr *src6_addr_p; /* source address */ struct in6_addr *src6_addr_p; /* source address */
u_int32_t src4_addr; u_int32_t src4_addr;
...@@ -297,8 +297,8 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP, ...@@ -297,8 +297,8 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP,
// The entry should be here but all signalling tied with RRC procedures not finished so // The entry should be here but all signalling tied with RRC procedures not finished so
// a data packet can arrive before the MODIFY_BEARER REQUEST // a data packet can arrive before the MODIFY_BEARER REQUEST
src4_addr = iph_p->saddr; src4_addr = iph_p->saddr;
if (hashtbl_get(sgi_data_pP->addr_v4_mapping, src4_addr, (void**)&addr_mapping_p) != HASH_TABLE_OK) { if (hashtable_get(sgi_data_pP->addr_v4_mapping, src4_addr, (void**)&addr_mapping_p) != HASH_TABLE_OK) {
hash_rc = hashtbl_get(sgi_data_pP->teid_mapping, originating_sgw_S1u_teidP, (void**)&mapping_p); hash_rc = hashtable_get(sgi_data_pP->teid_mapping, originating_sgw_S1u_teidP, (void**)&mapping_p);
if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) { if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) {
SGI_IF_ERROR("%s Error unknown context SGW teid %d\n", __FUNCTION__, originating_sgw_S1u_teidP); SGI_IF_ERROR("%s Error unknown context SGW teid %d\n", __FUNCTION__, originating_sgw_S1u_teidP);
return -1; return -1;
...@@ -314,7 +314,7 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP, ...@@ -314,7 +314,7 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP,
addr_mapping_p->is_outgoing_packet_seen = 1; addr_mapping_p->is_outgoing_packet_seen = 1;
addr_mapping_p->enb_S1U_teid = mapping_p->enb_S1U_teid; addr_mapping_p->enb_S1U_teid = mapping_p->enb_S1U_teid;
addr_mapping_p->sgw_S1U_teid = originating_sgw_S1u_teidP; addr_mapping_p->sgw_S1U_teid = originating_sgw_S1u_teidP;
hashtbl_insert(sgi_data_pP->addr_v4_mapping, src4_addr, (void*)addr_mapping_p); hashtable_insert(sgi_data_pP->addr_v4_mapping, src4_addr, (void*)addr_mapping_p);
SGI_IF_DEBUG("%s ASSOCIATED %d.%d.%d.%d to MAC %02x:%02x:%02x:%02x:%02x:%02x teid %d\n", SGI_IF_DEBUG("%s ASSOCIATED %d.%d.%d.%d to MAC %02x:%02x:%02x:%02x:%02x:%02x teid %d\n",
__FUNCTION__, NIPADDR(src4_addr), NMACADDR(eh_p->ether_shost), originating_sgw_S1u_teidP); __FUNCTION__, NIPADDR(src4_addr), NMACADDR(eh_p->ether_shost), originating_sgw_S1u_teidP);
} else { } else {
...@@ -324,7 +324,7 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP, ...@@ -324,7 +324,7 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP,
} }
} else { } else {
hash_rc = hashtbl_get(sgi_data_pP->teid_mapping, originating_sgw_S1u_teidP, (void**)&mapping_p); hash_rc = hashtable_get(sgi_data_pP->teid_mapping, originating_sgw_S1u_teidP, (void**)&mapping_p);
} }
break; break;
...@@ -336,8 +336,8 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP, ...@@ -336,8 +336,8 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP,
// a data packet can arrive before the MODIFY_BEARER REQUEST // a data packet can arrive before the MODIFY_BEARER REQUEST
memcpy(&src4_addr, &((unsigned char*)(&arph_p[1]))[ETH_ALEN], 4); memcpy(&src4_addr, &((unsigned char*)(&arph_p[1]))[ETH_ALEN], 4);
SGI_IF_ERROR("%s ARP OPCODE %s TARGET IP %d.%d.%d.%d\n", __FUNCTION__, sgi_arpopcode_2_str(ntohl(arph_p->ar_op)), NIPADDR(src4_addr)); SGI_IF_ERROR("%s ARP OPCODE %s TARGET IP %d.%d.%d.%d\n", __FUNCTION__, sgi_arpopcode_2_str(ntohl(arph_p->ar_op)), NIPADDR(src4_addr));
if (hashtbl_get(sgi_data_pP->addr_v4_mapping, src4_addr, (void**)&addr_mapping_p) != HASH_TABLE_OK) { if (hashtable_get(sgi_data_pP->addr_v4_mapping, src4_addr, (void**)&addr_mapping_p) != HASH_TABLE_OK) {
hash_rc = hashtbl_get(sgi_data_pP->teid_mapping, originating_sgw_S1u_teidP, (void**)&mapping_p); hash_rc = hashtable_get(sgi_data_pP->teid_mapping, originating_sgw_S1u_teidP, (void**)&mapping_p);
if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) { if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) {
SGI_IF_ERROR("%s Error unknown context SGW teid %d\n", __FUNCTION__, originating_sgw_S1u_teidP); SGI_IF_ERROR("%s Error unknown context SGW teid %d\n", __FUNCTION__, originating_sgw_S1u_teidP);
return -1; return -1;
...@@ -353,7 +353,7 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP, ...@@ -353,7 +353,7 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP,
addr_mapping_p->is_outgoing_packet_seen = 1; addr_mapping_p->is_outgoing_packet_seen = 1;
addr_mapping_p->enb_S1U_teid = mapping_p->enb_S1U_teid; addr_mapping_p->enb_S1U_teid = mapping_p->enb_S1U_teid;
addr_mapping_p->sgw_S1U_teid = originating_sgw_S1u_teidP; addr_mapping_p->sgw_S1U_teid = originating_sgw_S1u_teidP;
hashtbl_insert(sgi_data_pP->addr_v4_mapping, src4_addr, (void*)addr_mapping_p); hashtable_insert(sgi_data_pP->addr_v4_mapping, src4_addr, (void*)addr_mapping_p);
SGI_IF_DEBUG("%s ASSOCIATED %d.%d.%d.%d to MAC %02x:%02x:%02x:%02x:%02x:%02x teid %d\n", SGI_IF_DEBUG("%s ASSOCIATED %d.%d.%d.%d to MAC %02x:%02x:%02x:%02x:%02x:%02x teid %d\n",
__FUNCTION__, NIPADDR(src4_addr), NMACADDR(eh_p->ether_shost), originating_sgw_S1u_teidP); __FUNCTION__, NIPADDR(src4_addr), NMACADDR(eh_p->ether_shost), originating_sgw_S1u_teidP);
} else { } else {
...@@ -363,7 +363,7 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP, ...@@ -363,7 +363,7 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP,
} }
} else { } else {
hash_rc = hashtbl_get(sgi_data_pP->teid_mapping, originating_sgw_S1u_teidP, (void**)&mapping_p); hash_rc = hashtable_get(sgi_data_pP->teid_mapping, originating_sgw_S1u_teidP, (void**)&mapping_p);
} }
break; break;
...@@ -372,8 +372,8 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP, ...@@ -372,8 +372,8 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP,
case ETHERTYPE_IPV6: case ETHERTYPE_IPV6:
ip6h_p = (struct ipv6hdr *) (buffer_pP + sizeof(struct ether_header)); ip6h_p = (struct ipv6hdr *) (buffer_pP + sizeof(struct ether_header));
if (obj_hashtbl_get(sgi_data_pP->addr_v6_mapping, &src6_addr, sizeof(struct in6_addr), (void**)&addr_mapping_p) != HASH_TABLE_OK) { if (obj_hashtable_get(sgi_data_pP->addr_v6_mapping, &src6_addr, sizeof(struct in6_addr), (void**)&addr_mapping_p) != HASH_TABLE_OK) {
hash_rc = hashtbl_get(sgi_data_pP->teid_mapping, originating_sgw_S1u_teidP, (void**)&mapping_p); hash_rc = hashtable_get(sgi_data_pP->teid_mapping, originating_sgw_S1u_teidP, (void**)&mapping_p);
if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) { if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) {
SGI_IF_ERROR("%s Error unknown context SGW teid %d\n", __FUNCTION__, originating_sgw_S1u_teidP); SGI_IF_ERROR("%s Error unknown context SGW teid %d\n", __FUNCTION__, originating_sgw_S1u_teidP);
return -1; return -1;
...@@ -397,7 +397,7 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP, ...@@ -397,7 +397,7 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP,
return -1; return -1;
} }
memcpy(src6_addr_p->s6_addr, ip6h_p->saddr.s6_addr, 16); memcpy(src6_addr_p->s6_addr, ip6h_p->saddr.s6_addr, 16);
obj_hashtbl_insert(sgi_data_pP->addr_v6_mapping, src6_addr_p,sizeof(struct in6_addr), (void*)addr_mapping_p); obj_hashtable_insert(sgi_data_pP->addr_v6_mapping, src6_addr_p,sizeof(struct in6_addr), (void*)addr_mapping_p);
} else { } else {
SGI_IF_ERROR("Error TOO MANY IPv6 address already registered for teid %d\n", originating_sgw_S1u_teidP); SGI_IF_ERROR("Error TOO MANY IPv6 address already registered for teid %d\n", originating_sgw_S1u_teidP);
return -1; return -1;
...@@ -405,7 +405,7 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP, ...@@ -405,7 +405,7 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP,
} }
} else { } else {
hash_rc = hashtbl_get(sgi_data_pP->teid_mapping, originating_sgw_S1u_teidP, (void**)&mapping_p); hash_rc = hashtable_get(sgi_data_pP->teid_mapping, originating_sgw_S1u_teidP, (void**)&mapping_p);
} }
break; break;
...@@ -432,7 +432,7 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP, ...@@ -432,7 +432,7 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP,
struct ipv6hdr *ip6h_p = (struct ipv6hdr *) buffer_pP; struct ipv6hdr *ip6h_p = (struct ipv6hdr *) buffer_pP;
sgi_teid_mapping_t *mapping_p = NULL; sgi_teid_mapping_t *mapping_p = NULL;
sgi_addr_mapping_t *addr_mapping_p = NULL; sgi_addr_mapping_t *addr_mapping_p = NULL;
hashtbl_rc_t hash_rc; hashtable_rc_t hash_rc;
struct in6_addr src6_addr; /* source address */ struct in6_addr src6_addr; /* source address */
struct in6_addr *src6_addr_p; /* source address */ struct in6_addr *src6_addr_p; /* source address */
u_int32_t src4_addr; u_int32_t src4_addr;
...@@ -453,8 +453,8 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP, ...@@ -453,8 +453,8 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP,
// a data packet can arrive before the MODIFY_BEARER REQUEST // a data packet can arrive before the MODIFY_BEARER REQUEST
sgi_data_pP->eh.ether_type = htons(ETHERTYPE_IP); sgi_data_pP->eh.ether_type = htons(ETHERTYPE_IP);
src4_addr = iph_p->saddr; src4_addr = iph_p->saddr;
if (hashtbl_get(sgi_data_pP->addr_v4_mapping, src4_addr, (void**)&addr_mapping_p) != HASH_TABLE_OK) { if (hashtable_get(sgi_data_pP->addr_v4_mapping, src4_addr, (void**)&addr_mapping_p) != HASH_TABLE_OK) {
hash_rc = hashtbl_get(sgi_data_pP->teid_mapping, originating_sgw_S1u_teidP, (void**)&mapping_p); hash_rc = hashtable_get(sgi_data_pP->teid_mapping, originating_sgw_S1u_teidP, (void**)&mapping_p);
if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) { if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) {
SGI_IF_ERROR("%s Error unknown context SGW teid %d\n", __FUNCTION__, originating_sgw_S1u_teidP); SGI_IF_ERROR("%s Error unknown context SGW teid %d\n", __FUNCTION__, originating_sgw_S1u_teidP);
return -1; return -1;
...@@ -468,7 +468,7 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP, ...@@ -468,7 +468,7 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP,
addr_mapping_p->is_outgoing_packet_seen = 1; addr_mapping_p->is_outgoing_packet_seen = 1;
addr_mapping_p->enb_S1U_teid = mapping_p->enb_S1U_teid; addr_mapping_p->enb_S1U_teid = mapping_p->enb_S1U_teid;
addr_mapping_p->sgw_S1U_teid = originating_sgw_S1u_teidP; addr_mapping_p->sgw_S1U_teid = originating_sgw_S1u_teidP;
hashtbl_insert(sgi_data_pP->addr_v4_mapping, src4_addr, (void*)addr_mapping_p); hashtable_insert(sgi_data_pP->addr_v4_mapping, src4_addr, (void*)addr_mapping_p);
SGI_IF_DEBUG("%s ASSOCIATED %d.%d.%d.%d to teid %d\n", SGI_IF_DEBUG("%s ASSOCIATED %d.%d.%d.%d to teid %d\n",
__FUNCTION__, NIPADDR(src4_addr), originating_sgw_S1u_teidP); __FUNCTION__, NIPADDR(src4_addr), originating_sgw_S1u_teidP);
} else { } else {
...@@ -478,7 +478,7 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP, ...@@ -478,7 +478,7 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP,
} }
} else { } else {
hash_rc = hashtbl_get(sgi_data_pP->teid_mapping, originating_sgw_S1u_teidP, (void**)&mapping_p); hash_rc = hashtable_get(sgi_data_pP->teid_mapping, originating_sgw_S1u_teidP, (void**)&mapping_p);
} }
break; break;
...@@ -487,8 +487,8 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP, ...@@ -487,8 +487,8 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP,
//******************* //*******************
case 6: case 6:
sgi_data_pP->eh.ether_type = htons(ETHERTYPE_IPV6); sgi_data_pP->eh.ether_type = htons(ETHERTYPE_IPV6);
if (obj_hashtbl_get(sgi_data_pP->addr_v6_mapping, &src6_addr, sizeof(struct in6_addr), (void**)&addr_mapping_p) != HASH_TABLE_OK) { if (obj_hashtable_get(sgi_data_pP->addr_v6_mapping, &src6_addr, sizeof(struct in6_addr), (void**)&addr_mapping_p) != HASH_TABLE_OK) {
hash_rc = hashtbl_get(sgi_data_pP->teid_mapping, originating_sgw_S1u_teidP, (void**)&mapping_p); hash_rc = hashtable_get(sgi_data_pP->teid_mapping, originating_sgw_S1u_teidP, (void**)&mapping_p);
if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) { if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) {
SGI_IF_ERROR("%s Error unknown context SGW teid %d\n", __FUNCTION__, originating_sgw_S1u_teidP); SGI_IF_ERROR("%s Error unknown context SGW teid %d\n", __FUNCTION__, originating_sgw_S1u_teidP);
return -1; return -1;
...@@ -510,7 +510,7 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP, ...@@ -510,7 +510,7 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP,
return -1; return -1;
} }
memcpy(src6_addr_p->s6_addr, ip6h_p->saddr.s6_addr, 16); memcpy(src6_addr_p->s6_addr, ip6h_p->saddr.s6_addr, 16);
obj_hashtbl_insert(sgi_data_pP->addr_v6_mapping, src6_addr_p,sizeof(struct in6_addr), (void*)addr_mapping_p); obj_hashtable_insert(sgi_data_pP->addr_v6_mapping, src6_addr_p,sizeof(struct in6_addr), (void*)addr_mapping_p);
} else { } else {
SGI_IF_ERROR("Error TOO MANY IPv6 address already registered for teid %d\n", originating_sgw_S1u_teidP); SGI_IF_ERROR("Error TOO MANY IPv6 address already registered for teid %d\n", originating_sgw_S1u_teidP);
return -1; return -1;
...@@ -518,7 +518,7 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP, ...@@ -518,7 +518,7 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP,
} }
} else { } else {
hash_rc = hashtbl_get(sgi_data_pP->teid_mapping, originating_sgw_S1u_teidP, (void**)&mapping_p); hash_rc = hashtable_get(sgi_data_pP->teid_mapping, originating_sgw_S1u_teidP, (void**)&mapping_p);
} }
break; break;
......
...@@ -143,7 +143,7 @@ static int sgi_create_endpoint_request(sgi_data_t *sgi_dataP, SGICreateEndpointR ...@@ -143,7 +143,7 @@ static int sgi_create_endpoint_request(sgi_data_t *sgi_dataP, SGICreateEndpointR
sgi_create_endpoint_resp_p->paa = req_p->paa; sgi_create_endpoint_resp_p->paa = req_p->paa;
sgi_create_endpoint_resp_p->status = SGI_STATUS_OK; sgi_create_endpoint_resp_p->status = SGI_STATUS_OK;
if (hashtbl_is_key_exists(sgi_dataP->teid_mapping, req_p->sgw_S1u_teid) == HASH_TABLE_OK) if (hashtable_is_key_exists(sgi_dataP->teid_mapping, req_p->sgw_S1u_teid) == HASH_TABLE_OK)
{ {
SGI_IF_ERROR("SGI_STATUS_ERROR_CONTEXT_ALREADY_EXIST Context: S11 teid %u\n", req_p->context_teid); SGI_IF_ERROR("SGI_STATUS_ERROR_CONTEXT_ALREADY_EXIST Context: S11 teid %u\n", req_p->context_teid);
sgi_create_endpoint_resp_p->status = SGI_STATUS_ERROR_CONTEXT_ALREADY_EXIST; sgi_create_endpoint_resp_p->status = SGI_STATUS_ERROR_CONTEXT_ALREADY_EXIST;
...@@ -156,7 +156,7 @@ static int sgi_create_endpoint_request(sgi_data_t *sgi_dataP, SGICreateEndpointR ...@@ -156,7 +156,7 @@ static int sgi_create_endpoint_request(sgi_data_t *sgi_dataP, SGICreateEndpointR
mapping->eps_bearer_id = req_p->eps_bearer_id; mapping->eps_bearer_id = req_p->eps_bearer_id;
mapping->enb_S1U_teid = -1; mapping->enb_S1U_teid = -1;
if (hashtbl_insert(sgi_dataP->teid_mapping, req_p->sgw_S1u_teid, mapping) != 0) { if (hashtable_insert(sgi_dataP->teid_mapping, req_p->sgw_S1u_teid, mapping) != 0) {
SGI_IF_ERROR("SGI_STATUS_ERROR_SYSTEM_FAILURE Context: S11 teid %u\n", req_p->context_teid); SGI_IF_ERROR("SGI_STATUS_ERROR_SYSTEM_FAILURE Context: S11 teid %u\n", req_p->context_teid);
sgi_create_endpoint_resp_p->status = SGI_STATUS_ERROR_SYSTEM_FAILURE; sgi_create_endpoint_resp_p->status = SGI_STATUS_ERROR_SYSTEM_FAILURE;
free(mapping); free(mapping);
...@@ -191,7 +191,7 @@ static int sgi_update_endpoint_request(sgi_data_t *sgi_dataP, SGIUpdateEndpointR ...@@ -191,7 +191,7 @@ static int sgi_update_endpoint_request(sgi_data_t *sgi_dataP, SGIUpdateEndpointR
sgi_update_endpoint_resp_p->enb_S1u_teid = req_p->enb_S1u_teid; sgi_update_endpoint_resp_p->enb_S1u_teid = req_p->enb_S1u_teid;
sgi_update_endpoint_resp_p->status = SGI_STATUS_OK; sgi_update_endpoint_resp_p->status = SGI_STATUS_OK;
if (hashtbl_get(sgi_dataP->teid_mapping, req_p->sgw_S1u_teid, (void**)&mapping) == HASH_TABLE_OK) if (hashtable_get(sgi_dataP->teid_mapping, req_p->sgw_S1u_teid, (void**)&mapping) == HASH_TABLE_OK)
{ {
mapping->enb_S1U_teid = req_p->enb_S1u_teid; mapping->enb_S1U_teid = req_p->enb_S1u_teid;
} else { } else {
...@@ -202,7 +202,7 @@ static int sgi_update_endpoint_request(sgi_data_t *sgi_dataP, SGIUpdateEndpointR ...@@ -202,7 +202,7 @@ static int sgi_update_endpoint_request(sgi_data_t *sgi_dataP, SGIUpdateEndpointR
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
int sgi_init(const mme_config_t *mme_config_p) int sgi_init(const pgw_config_t *pgw_config_p)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
...@@ -221,30 +221,30 @@ int sgi_init(const mme_config_t *mme_config_p) ...@@ -221,30 +221,30 @@ int sgi_init(const mme_config_t *mme_config_p)
sgi_data_p->thread_started = 0; sgi_data_p->thread_started = 0;
pthread_mutex_init (&sgi_data_p->thread_started_mutex, NULL); pthread_mutex_init (&sgi_data_p->thread_started_mutex, NULL);
sgi_data_p->teid_mapping = hashtbl_create (SGI_MAX_EPS_BEARERS, NULL, NULL); sgi_data_p->teid_mapping = hashtable_create (SGI_MAX_EPS_BEARERS, NULL, NULL);
if (sgi_data_p->teid_mapping == NULL) { if (sgi_data_p->teid_mapping == NULL) {
SGI_IF_ERROR("Failed to create SGI hashtable teid_mapping\n"); SGI_IF_ERROR("Failed to create SGI hashtable teid_mapping\n");
return -1; return -1;
} }
sgi_data_p->addr_v4_mapping = hashtbl_create (SGI_MAX_SERVED_USERS_PER_PGW, NULL, NULL); sgi_data_p->addr_v4_mapping = hashtable_create (SGI_MAX_SERVED_USERS_PER_PGW, NULL, NULL);
if (sgi_data_p->addr_v4_mapping == NULL) { if (sgi_data_p->addr_v4_mapping == NULL) {
SGI_IF_ERROR("Failed to create SGI hashtable addr_v4_mapping\n"); SGI_IF_ERROR("Failed to create SGI hashtable addr_v4_mapping\n");
return -1; return -1;
} }
sgi_data_p->addr_v6_mapping = obj_hashtbl_create (SGI_MAX_SERVED_USERS_PER_PGW, NULL, NULL, NULL); sgi_data_p->addr_v6_mapping = obj_hashtable_create (SGI_MAX_SERVED_USERS_PER_PGW, NULL, NULL, NULL);
if (sgi_data_p->addr_v6_mapping == NULL) { if (sgi_data_p->addr_v6_mapping == NULL) {
SGI_IF_ERROR("Failed to create SGI hashtable addr_v6_mapping\n"); SGI_IF_ERROR("Failed to create SGI hashtable addr_v6_mapping\n");
return -1; return -1;
} }
len = strlen(mme_config_p->ipv4.pgw_interface_name_for_SGI); len = strlen(pgw_config_p->ipv4.pgw_interface_name_for_SGI);
sgi_data_p->interface_name = calloc(len + 1, sizeof(char)); sgi_data_p->interface_name = calloc(len + 1, sizeof(char));
memcpy(sgi_data_p->interface_name, mme_config_p->ipv4.pgw_interface_name_for_SGI, len); memcpy(sgi_data_p->interface_name, pgw_config_p->ipv4.pgw_interface_name_for_SGI, len);
sgi_data_p->interface_name[len] = '\0'; sgi_data_p->interface_name[len] = '\0';
sgi_data_p->ipv4_addr = mme_config_p->ipv4.pgw_ip_addr_for_SGI; sgi_data_p->ipv4_addr = pgw_config_p->ipv4.pgw_ipv4_address_for_SGI;
sgi_data_p->interface_index = if_nametoindex(sgi_data_p->interface_name); sgi_data_p->interface_index = if_nametoindex(sgi_data_p->interface_name);
......
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