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 {
//-----------------------------------------------------------------------------
// 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);
//-----------------------------------------------------------------------------
......
......@@ -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));
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);
} else {
......@@ -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));
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);
} 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));
......@@ -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)
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));
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);
} else {
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
//*******************
iph_p = (struct iphdr *) (data_pP + sizeof(struct ether_header));
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) {
SGI_IF_DEBUG("%s Dropping incoming egress IPV4 packet not UE IP flow\n", __FUNCTION__);
return;
......@@ -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));
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));
return;
}
......@@ -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)
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));
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) {
SGI_IF_DEBUG("%s Dropping incoming egress IPV4 packet not UE IP flow\n", __FUNCTION__);
return;
......
This diff is collapsed.
......@@ -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->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_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
mapping->eps_bearer_id = req_p->eps_bearer_id;
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_create_endpoint_resp_p->status = SGI_STATUS_ERROR_SYSTEM_FAILURE;
free(mapping);
......@@ -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->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;
} else {
......@@ -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)
sgi_data_p->thread_started = 0;
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) {
SGI_IF_ERROR("Failed to create SGI hashtable teid_mapping\n");
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) {
SGI_IF_ERROR("Failed to create SGI hashtable addr_v4_mapping\n");
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) {
SGI_IF_ERROR("Failed to create SGI hashtable addr_v6_mapping\n");
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));
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->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);
......
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