Commit 10b8f568 authored by Cedric Roux's avatar Cedric Roux

- Generate "unique" eNB_id according to host name

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4345 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent d58853f9
......@@ -32,6 +32,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <crypt.h>
#include "tree.h"
#include "queue.h"
......@@ -117,6 +118,25 @@ inline struct s1ap_eNB_mme_data_s *s1ap_eNB_get_MME(
return NULL;
}
uint32_t s1ap_generate_eNB_id(void)
{
char *out;
char hostname[50];
int ret;
uint32_t eNB_id;
/* Retrieve the host name */
ret = gethostname(hostname, sizeof(hostname));
DevAssert(ret == 0);
out = crypt(hostname, "eurecom");
DevAssert(out != NULL);
eNB_id = ((out[0] << 24) | (out[1] << 16) | (out[2] << 8) | out[3]);
return eNB_id;
}
// int s1ap_run(eNB_mme_desc_t *eNB_desc_p)
// {
// int ret = 0;
......@@ -350,7 +370,7 @@ static int s1ap_eNB_generate_s1_setup_request(
SupportedTAs_Item_t ta;
uint8_t *buffer;
uint32_t len;
int ret;
int ret = 0;
DevAssert(instance_p != NULL);
DevAssert(s1ap_mme_data_p != NULL);
......
......@@ -41,6 +41,8 @@
void *s1ap_eNB_task(void *arg);
uint32_t s1ap_generate_eNB_id(void);
#endif /* S1AP_ENB_H_ */
/**
......
......@@ -198,12 +198,12 @@ void s1ap_dump_eNB(eNB_description_t *eNB_ref) {
indent = 0;
if (eNB_ref == NULL) return;
eNB_LIST_OUT("");
eNB_LIST_OUT("eNB name: %s", eNB_ref->eNB_name == NULL ? "not present" : eNB_ref->eNB_name);
eNB_LIST_OUT("eNB ID: %d", eNB_ref->eNB_id);
eNB_LIST_OUT("SCTP assoc id: %d", eNB_ref->sctp_assoc_id);
eNB_LIST_OUT("SCTP instreams: %d", eNB_ref->instreams);
eNB_LIST_OUT("SCTP outstreams: %d", eNB_ref->outstreams);
eNB_LIST_OUT("UE attache to eNB: %d", eNB_ref->nb_ue_associated);
eNB_LIST_OUT("eNB name: %s", eNB_ref->eNB_name == NULL ? "not present" : eNB_ref->eNB_name);
eNB_LIST_OUT("eNB ID: %07x", eNB_ref->eNB_id);
eNB_LIST_OUT("SCTP assoc id: %d", eNB_ref->sctp_assoc_id);
eNB_LIST_OUT("SCTP instreams: %d", eNB_ref->instreams);
eNB_LIST_OUT("SCTP outstreams: %d", eNB_ref->outstreams);
eNB_LIST_OUT("UE attache to eNB: %d", eNB_ref->nb_ue_associated);
indent++;
for (ue_ref = eNB_ref->ue_list_head; ue_ref; ue_ref = ue_ref->next_ue) {
......
......@@ -253,7 +253,7 @@ int s1ap_mme_handle_s1_setup_request(uint32_t assoc_id, uint32_t stream,
}
eNB_id = (eNB_id_buf[0] << 20) + (eNB_id_buf[1] << 12) +
(eNB_id_buf[2] << 4) + ((eNB_id_buf[3] & 0xf0) >> 4);
S1AP_DEBUG("home eNB id: %u\n", eNB_id);
S1AP_DEBUG("home eNB id: %07x\n", eNB_id);
} else {
// Macro eNB = 20 bits
uint8_t *eNB_id_buf =
......@@ -263,7 +263,7 @@ int s1ap_mme_handle_s1_setup_request(uint32_t assoc_id, uint32_t stream,
}
eNB_id = (eNB_id_buf[0] << 12) + (eNB_id_buf[1] << 4) + ((
eNB_id_buf[2] & 0xf0) >> 4);
S1AP_DEBUG("macro eNB id: %u\n", eNB_id);
S1AP_DEBUG("macro eNB id: %05x\n", eNB_id);
}
config_read_lock(&mme_config);
......
......@@ -395,14 +395,18 @@ void *l2l1_task(void *args_p) {
char *mme_address_v4 = "192.168.12.87";
char *mme_address_v6 = "2001:660:5502:12:30da:829a:2343:b6cf";
s1ap_register_eNB_t *s1ap_register_eNB;
uint32_t hash;
message_p = itti_alloc_new_message(TASK_L2L1, S1AP_REGISTER_ENB);
s1ap_register_eNB = &message_p->msg.s1ap_register_eNB;
hash = s1ap_generate_eNB_id();
/* Some default/random parameters */
s1ap_register_eNB->mod_id = eNB_id;
/* FIXME: generate unique eNB id */
s1ap_register_eNB->eNB_id = 1 + eNB_id;
s1ap_register_eNB->eNB_id = eNB_id + (hash & 0xFFFF8);
s1ap_register_eNB->cell_type = CELL_MACRO_ENB;
s1ap_register_eNB->tac = 8;
s1ap_register_eNB->mcc = 208;
......
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