Commit 1961fd7f authored by Cedric Roux's avatar Cedric Roux

remove gccxml/castxml

This was used for the ITTI analyzer.

The ITTI analyzer is now to be considered obsolete.
The source code will be removed at some point.
parent 0f94c348
......@@ -262,7 +262,6 @@ if (${ENABLE_ITTI})
# add .h files if depend on (this one is generated)
${ITTI_DIR}/intertask_interface.h
${ITTI_DIR}/intertask_interface.c
${ITTI_DIR}/intertask_interface_dump.c
${ITTI_DIR}/backtrace.c
${ITTI_DIR}/memory_pools.c
${ITTI_DIR}/signals.c
......@@ -1905,7 +1904,6 @@ add_definitions(-DASN1_MINIMUM_VERSION=924)
add_executable(lte-softmodem
${rrc_h}
${s1ap_h}
${OPENAIR_BIN_DIR}/messages_xml.h
${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c
${OPENAIR_TARGETS}/RT/USER/lte-enb.c
${OPENAIR_TARGETS}/RT/USER/lte-ru.c
......@@ -1945,7 +1943,6 @@ target_link_libraries (lte-softmodem ${T_LIB})
add_executable(lte-softmodem-nos1
${rrc_h}
${s1ap_h}
${OPENAIR_BIN_DIR}/messages_xml.h
${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c
${OPENAIR_TARGETS}/RT/USER/lte-enb.c
${OPENAIR_TARGETS}/RT/USER/lte-ru.c
......@@ -1984,7 +1981,6 @@ target_link_libraries (lte-softmodem-nos1 ${T_LIB})
add_executable(lte-uesoftmodem
${rrc_h}
${s1ap_h}
${OPENAIR_BIN_DIR}/messages_xml.h
${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c
${OPENAIR_TARGETS}/RT/USER/lte-ue.c
${OPENAIR_TARGETS}/RT/USER/lte-uesoftmodem.c
......@@ -2023,7 +2019,6 @@ target_link_libraries (lte-uesoftmodem ${T_LIB})
add_executable(lte-uesoftmodem-nos1
${rrc_h}
${s1ap_h}
${OPENAIR_BIN_DIR}/messages_xml.h
${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c
${OPENAIR_TARGETS}/RT/USER/lte-ue.c
${OPENAIR_TARGETS}/RT/USER/lte-uesoftmodem.c
......@@ -2091,7 +2086,6 @@ target_link_libraries (lte-uesoftmodem-nos1 ${T_LIB})
#special case for dlim TM4, which uses its own version of phy_scope code
add_executable(dlsim_tm4
# ${OPENAIR_BIN_DIR}/messages_xml.h
${OPENAIR1_DIR}/SIMULATION/LTE_PHY/dlsim_tm4.c
${OPENAIR1_DIR}/PHY/TOOLS/lte_phy_scope_tm4.c
${T_SOURCE}
......@@ -2104,7 +2098,6 @@ target_link_libraries (dlsim_tm4
foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim prachsim syncsim)
add_executable(${myExe}
# ${OPENAIR_BIN_DIR}/messages_xml.h
${OPENAIR1_DIR}/SIMULATION/LTE_PHY/${myExe}.c
${XFORMS_SOURCE}
${T_SOURCE}
......@@ -2126,7 +2119,6 @@ add_executable(test_epc_generate_scenario
${OPENAIR2_DIR}/COMMON/messages_def.h
${OPENAIR2_DIR}/COMMON/messages_types.h
${OPENAIR3_DIR}/S1AP/s1ap_eNB_defs.h
# ${OPENAIR_BIN_DIR}/messages_xml.h
)
target_link_libraries (test_epc_generate_scenario
-Wl,--start-group RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB GTPV1U LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS ${ITTI_LIB} ${MSC_LIB} L2 -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} ${CONFIG_LIBRARIES}
......@@ -2146,7 +2138,6 @@ add_executable(test_epc_play_scenario
${OPENAIR2_DIR}/COMMON/commonDef.h
${OPENAIR2_DIR}/COMMON/messages_def.h
${OPENAIR2_DIR}/COMMON/messages_types.h
${OPENAIR_BIN_DIR}/messages_xml.h
)
target_include_directories(test_epc_play_scenario PUBLIC /usr/local/share/asn1c)
target_link_libraries (test_epc_play_scenario
......@@ -2202,43 +2193,6 @@ endif (${T_TRACER})
# Generated specific cases is not regular code
###############################################
##################""
# itti symbolic debug print require to generate a specific include file
########################################
# retrieve the compiler options to send it to gccxml
get_directory_property( DirDefs COMPILE_DEFINITIONS )
foreach( d ${DirDefs} )
list(APPEND itti_compiler_options "-D${d}")
endforeach()
get_directory_property( DirDefs INCLUDE_DIRECTORIES )
foreach( d ${DirDefs} )
list(APPEND itti_compiler_options "-I${d}")
endforeach()
# castxml doesn't work with c11 (gcc 5 default)
# force castxml and clang compilation with gnu89 standard
# we can't use cXX standard as pthread_rwlock_t is gnu standard
list(APPEND itti_compiler_options "-std=gnu89;-DASN_DISABLE_OER_SUPPORT;-D'MAKE_VERSION(a,b,c)=((a)*256+(b)*16+c)'")
set (ITTI_H ${ITTI_DIR}/intertask_interface_types.h)
if(EXISTS /usr/bin/gccxml)
set(xml_command gccxml ${itti_compiler_options} -fxml=${OPENAIR_BIN_DIR}/messages.xml ${ITTI_H})
else()
set(xml_command castxml --castxml-gccxml ${itti_compiler_options} ${ITTI_H} -o ${OPENAIR_BIN_DIR}/messages.xml)
endif()
add_custom_command (
OUTPUT ${OPENAIR_BIN_DIR}/messages.xml
COMMAND ${xml_command}
DEPENDS ${S1AP_OAI_generated} ${RRC_FULL_DIR}/asn_constant.h
)
add_custom_command (
OUTPUT ${OPENAIR_BIN_DIR}/messages_xml.h
COMMAND sed -e 's/ *//' -e 's/\"/\\\\\"/g' -e 's/^/\"/' -e 's/$$/\\\\n\"/' ${OPENAIR_BIN_DIR}/messages.xml > ${OPENAIR_BIN_DIR}/messages_xml.h
DEPENDS ${OPENAIR_BIN_DIR}/messages.xml ${RRC_FULL_DIR}/asn_constant.h
)
################
# Kernel modules
###############
......
......@@ -504,24 +504,24 @@ check_install_oai_software() {
$SUDO apt install -y software-properties-common
case "$(get_distribution_release)" in
"ubuntu14.04")
specific_packages="libtasn1-3-dev gccxml libgnutls-dev libatlas-dev iproute libconfig8-dev"
specific_packages="libtasn1-3-dev libgnutls-dev libatlas-dev iproute libconfig8-dev"
# For iperf3
$SUDO add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty-backports universe"
$SUDO apt-get update
;;
"ubuntu16.04")
specific_packages="libtasn1-6-dev gccxml libgnutls-dev libatlas-dev iproute libconfig8-dev"
specific_packages="libtasn1-6-dev libgnutls-dev libatlas-dev iproute libconfig8-dev"
;;
"ubuntu17.04")
specific_packages="libtasn1-6-dev castxml libgnutls28-dev libatlas-dev iproute libconfig8-dev"
specific_packages="libtasn1-6-dev libgnutls28-dev libatlas-dev iproute libconfig8-dev"
;;
"ubuntu17.10")
specific_packages="libtasn1-6-dev castxml libgnutls28-dev iproute libconfig8-dev"
specific_packages="libtasn1-6-dev libgnutls28-dev iproute libconfig8-dev"
LAPACK_LIBNAME="liblapack.so-x86_64-linux-gnu"
LAPACK_TARGET="/usr/lib/x86_64-linux-gnu/atlas/liblapack.so"
;;
"ubuntu18.04")
specific_packages="libtasn1-6-dev castxml libgnutls28-dev iproute2 libconfig-dev"
specific_packages="libtasn1-6-dev libgnutls28-dev iproute2 libconfig-dev"
LAPACK_LIBNAME="liblapack.so-x86_64-linux-gnu"
LAPACK_TARGET="/usr/lib/x86_64-linux-gnu/atlas/liblapack.so"
;;
......@@ -598,11 +598,8 @@ check_install_oai_software() {
$SUDO $INSTALLER install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
fi
$SUDO $INSTALLER install -y python-epdb
$SUDO $INSTALLER install -y gccxml
else
$SUDO $INSTALLER install -y mscgen pydb
# Fedora repos already contain gccxml's successor castxml.
$SUDO $INSTALLER install -y castxml
fi
$SUDO $INSTALLER install -y \
......
......@@ -39,7 +39,6 @@
#include "assertions.h"
#include "intertask_interface.h"
#include "intertask_interface_dump.h"
#if T_TRACER
#include "T.h"
......@@ -770,7 +769,7 @@ void itti_terminate_tasks(task_id_t task_id)
}
int itti_init(task_id_t task_max, thread_id_t thread_max, MessagesIds messages_id_max, const task_info_t *tasks_info,
const message_info_t *messages_info, const char * const messages_definition_xml, const char * const dump_file_name)
const message_info_t *messages_info)
{
task_id_t task_id;
thread_id_t thread_id;
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/** @brief Intertask Interface Signal Dumper
* Allows users to connect their itti_analyzer to this process and dump
* signals exchanged between tasks.
* @author Sebastien Roux <sebastien.roux@eurecom.fr>
*/
#define _GNU_SOURCE // required for pthread_setname_np()
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <error.h>
#include <sched.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <sys/eventfd.h>
#include "assertions.h"
#include "liblfds611.h"
#include "itti_types.h"
#include "intertask_interface.h"
#include "intertask_interface_dump.h"
#if T_TRACER
#include "T.h"
#endif
static const int itti_dump_debug = 0; // 0x8 | 0x4 | 0x2;
# define ITTI_DUMP_DEBUG(m, x, args...) do { if ((m) & itti_dump_debug) fprintf(stdout, "[ITTI_DUMP][D]"x, ##args); } \
while(0)
#define ITTI_DUMP_ERROR(x, args...) do { fprintf(stdout, "[ITTI_DUMP][E]"x, ##args); } \
while(0)
typedef struct itti_dump_queue_item_s {
MessageDef *data;
uint32_t data_size;
uint32_t message_number;
uint32_t message_type;
uint32_t message_size;
} itti_dump_queue_item_t;
typedef struct {
int sd;
uint32_t last_message_number;
} itti_client_desc_t;
typedef struct itti_desc_s {
/* Asynchronous thread that write to file/accept new clients */
pthread_t itti_acceptor_thread;
pthread_attr_t attr;
/* List of messages to dump.
* NOTE: we limit the size of this queue to retain only the last exchanged
* messages. The size can be increased by setting up the ITTI_QUEUE_MAX_ELEMENTS
* in mme_default_values.h or by putting a custom in the configuration file.
*/
struct lfds611_ringbuffer_state *itti_message_queue;
int nb_connected;
/* Event fd used to notify new messages (semaphore) */
int event_fd;
int itti_listen_socket;
itti_client_desc_t itti_clients[ITTI_DUMP_MAX_CON];
} itti_desc_t;
typedef struct {
itti_socket_header_t socket_header;
itti_signal_header_t signal_header;
/* Message payload is added here, this struct is used as an header */
} itti_dump_message_t;
typedef struct {
itti_socket_header_t socket_header;
} itti_statistic_message_t;
static const itti_message_types_t itti_dump_xml_definition_end = ITTI_DUMP_XML_DEFINITION_END;
static const itti_message_types_t itti_dump_message_type_end = ITTI_DUMP_MESSAGE_TYPE_END;
static itti_desc_t itti_dump_queue;
static FILE *dump_file = NULL;
static int itti_dump_running = 1;
static volatile uint32_t pending_messages = 0;
/*------------------------------------------------------------------------------*/
static int itti_dump_send_message(int sd, itti_dump_queue_item_t *message)
{
itti_dump_message_t *new_message;
ssize_t bytes_sent = 0, total_sent = 0;
uint8_t *data_ptr;
/* Allocate memory for message header and payload */
size_t size = sizeof(itti_dump_message_t) + message->data_size + sizeof(itti_message_types_t);
AssertFatal (sd > 0, "Socket descriptor (%d) is invalid!\n", sd);
AssertFatal (message != NULL, "Message is NULL!\n");
new_message = malloc(size);
AssertFatal (new_message != NULL, "New message allocation failed!\n");
/* Preparing the header */
new_message->socket_header.message_size = size;
new_message->socket_header.message_type = ITTI_DUMP_MESSAGE_TYPE;
/* Adds message number in unsigned decimal ASCII format */
snprintf(new_message->signal_header.message_number_char, sizeof(new_message->signal_header.message_number_char),
MESSAGE_NUMBER_CHAR_FORMAT, message->message_number);
new_message->signal_header.message_number_char[sizeof(new_message->signal_header.message_number_char) - 1] = '\n';
/* Appends message payload */
memcpy(&new_message[1], message->data, message->data_size);
memcpy(((void *) &new_message[1]) + message->data_size, &itti_dump_message_type_end, sizeof(itti_message_types_t));
data_ptr = (uint8_t *)&new_message[0];
do {
bytes_sent = send(sd, &data_ptr[total_sent], size - total_sent, 0);
if (bytes_sent < 0) {
ITTI_DUMP_ERROR("[%d] Failed to send %zu bytes to socket (%d:%s)\n",
sd, size, errno, strerror(errno));
free(new_message);
return -1;
}
total_sent += bytes_sent;
} while (total_sent != size);
free(new_message);
return total_sent;
}
static int itti_dump_fwrite_message(itti_dump_queue_item_t *message)
{
itti_dump_message_t new_message_header;
if ((dump_file != NULL) && (message != NULL)) {
new_message_header.socket_header.message_size = message->message_size + sizeof(itti_dump_message_t) + sizeof(itti_message_types_t);
new_message_header.socket_header.message_type = message->message_type;
snprintf(new_message_header.signal_header.message_number_char, sizeof(new_message_header.signal_header.message_number_char),
MESSAGE_NUMBER_CHAR_FORMAT, message->message_number);
new_message_header.signal_header.message_number_char[sizeof(new_message_header.signal_header.message_number_char) - 1] = '\n';
fwrite (&new_message_header, sizeof(itti_dump_message_t), 1, dump_file);
fwrite (message->data, message->data_size, 1, dump_file);
fwrite (&itti_dump_message_type_end, sizeof(itti_message_types_t), 1, dump_file);
fflush (dump_file);
return (1);
}
return (0);
}
static int itti_dump_send_xml_definition(const int sd, const char *message_definition_xml,
const uint32_t message_definition_xml_length)
{
itti_socket_header_t *itti_dump_message;
/* Allocate memory for message header and payload */
size_t itti_dump_message_size;
ssize_t bytes_sent = 0, total_sent = 0;
uint8_t *data_ptr;
AssertFatal (sd > 0, "Socket descriptor (%d) is invalid!\n", sd);
AssertFatal (message_definition_xml != NULL, "Message definition XML is NULL!\n");
itti_dump_message_size = sizeof(itti_socket_header_t) + message_definition_xml_length + sizeof(itti_message_types_t);
itti_dump_message = calloc(1, itti_dump_message_size);
ITTI_DUMP_DEBUG(0x2, "[%d] Sending XML definition message of size %zu to observer peer\n",
sd, itti_dump_message_size);
itti_dump_message->message_size = itti_dump_message_size;
itti_dump_message->message_type = ITTI_DUMP_XML_DEFINITION;
/* Copying message definition */
memcpy (&itti_dump_message[1], message_definition_xml, message_definition_xml_length);
memcpy (((void *) &itti_dump_message[1]) + message_definition_xml_length, &itti_dump_xml_definition_end, sizeof(itti_message_types_t));
data_ptr = (uint8_t *)&itti_dump_message[0];
do {
bytes_sent = send(sd, &data_ptr[total_sent], itti_dump_message_size - total_sent, 0);
if (bytes_sent < 0) {
ITTI_DUMP_ERROR("[%d] Failed to send %zu bytes to socket (%d:%s)\n",
sd, itti_dump_message_size, errno, strerror(errno));
free(itti_dump_message);
return -1;
}
total_sent += bytes_sent;
} while (total_sent != itti_dump_message_size);
free(itti_dump_message);
return 0;
}
static void itti_dump_user_data_delete_function(void *user_data, void *user_state)
{
(void)user_state; // UNUSED
if (user_data != NULL) {
itti_dump_queue_item_t *item;
task_id_t task_id;
int result;
item = (itti_dump_queue_item_t *)user_data;
if (item->data != NULL) {
task_id = ITTI_MSG_ORIGIN_ID(item->data);
result = itti_free(task_id, item->data);
AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
} else {
task_id = TASK_UNKNOWN;
}
result = itti_free(task_id, item);
AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
}
}
static int itti_dump_enqueue_message(itti_dump_queue_item_t *new, uint32_t message_size,
uint32_t message_type)
{
struct lfds611_freelist_element *new_queue_element = NULL;
int overwrite_flag;
AssertFatal (new != NULL, "Message to queue is NULL!\n");
new->message_type = message_type;
new->message_size = message_size;
ITTI_DUMP_DEBUG (0x1, " itti_dump_enqueue_message: lfds611_ringbuffer_get_write_element\n");
new_queue_element = lfds611_ringbuffer_get_write_element (itti_dump_queue.itti_message_queue, &new_queue_element, &overwrite_flag);
if (overwrite_flag != 0) {
// no free element available: overwrite a non read one => data loss!
void *old = NULL;
lfds611_freelist_get_user_data_from_element(new_queue_element, &old);
ITTI_DUMP_DEBUG (0x4, " overwrite_flag set, freeing old data %p %p\n", new_queue_element, old);
itti_dump_user_data_delete_function (old, NULL);
}
lfds611_freelist_set_user_data_in_element(new_queue_element, new);
lfds611_ringbuffer_put_write_element(itti_dump_queue.itti_message_queue, new_queue_element);
if (overwrite_flag == 0) {
{
ssize_t write_ret;
eventfd_t sem_counter = 1;
/* Call to write for an event fd must be of 8 bytes */
write_ret = write(itti_dump_queue.event_fd, &sem_counter, sizeof(sem_counter));
AssertFatal (write_ret == sizeof(sem_counter), "Write to dump event failed (%d/%d)!\n", (int) write_ret, (int) sizeof(sem_counter));
}
// add one to pending_messages, atomically
__sync_fetch_and_add (&pending_messages, 1);
}
ITTI_DUMP_DEBUG (0x2, " Added element to queue %p %p, pending %u, type %u\n", new_queue_element, new, pending_messages, message_type);
return 0;
}
static void itti_dump_socket_exit(void)
{
close(itti_dump_queue.event_fd);
close(itti_dump_queue.itti_listen_socket);
/* Leave the thread as we detected end signal */
pthread_exit(NULL);
}
static int itti_dump_flush_ring_buffer(int flush_all)
{
struct lfds611_freelist_element *element = NULL;
void *user_data;
int j;
int consumer;
/* Check if there is a least one consumer */
consumer = 0;
if (dump_file != NULL) {
consumer = 1;
} else {
for (j = 0; j < ITTI_DUMP_MAX_CON; j++) {
if (itti_dump_queue.itti_clients[j].sd > 0) {
consumer = 1;
break;
}
}
}
if (consumer > 0) {
do {
/* Acquire the ring element */
lfds611_ringbuffer_get_read_element(itti_dump_queue.itti_message_queue, &element);
// subtract one from pending_messages, atomically
__sync_fetch_and_sub (&pending_messages, 1);
if (element == NULL) {
if (flush_all != 0) {
flush_all = 0;
} else {
AssertFatal (0, "Dump event with no data!\n");
}
} else {
/* Retrieve user part of the message */
lfds611_freelist_get_user_data_from_element(element, &user_data);
ITTI_DUMP_DEBUG (0x2, " removed element from queue %p %p, pending %u\n", element, user_data, pending_messages);
if (((itti_dump_queue_item_t *)user_data)->message_type == ITTI_DUMP_EXIT_SIGNAL) {
lfds611_ringbuffer_put_read_element(itti_dump_queue.itti_message_queue, element);
itti_dump_socket_exit();
}
/* Write message to file */
itti_dump_fwrite_message((itti_dump_queue_item_t *)user_data);
/* Send message to remote analyzer */
for (j = 0; j < ITTI_DUMP_MAX_CON; j++) {
if (itti_dump_queue.itti_clients[j].sd > 0) {
itti_dump_send_message(itti_dump_queue.itti_clients[j].sd,
(itti_dump_queue_item_t *)user_data);
}
}
itti_dump_user_data_delete_function (user_data, NULL);
lfds611_freelist_set_user_data_in_element(element, NULL);
/* We have finished with this element, reinsert it in the ring buffer */
lfds611_ringbuffer_put_read_element(itti_dump_queue.itti_message_queue, element);
}
} while(flush_all
);
}
return (consumer);
}
static int itti_dump_handle_new_connection(int sd, const char *xml_definition, uint32_t xml_definition_length)
{
if (itti_dump_queue.nb_connected < ITTI_DUMP_MAX_CON) {
uint8_t i;
for (i = 0; i < ITTI_DUMP_MAX_CON; i++) {
/* Let's find a place to store the new client */
if (itti_dump_queue.itti_clients[i].sd == -1) {
break;
}
}
ITTI_DUMP_DEBUG(0x2, " Found place to store new connection: %d\n", i);
AssertFatal (i < ITTI_DUMP_MAX_CON, "No more connection available (%d/%d) for socked %d!\n", i, ITTI_DUMP_MAX_CON, sd);
ITTI_DUMP_DEBUG(0x2, " Socket %d accepted\n", sd);
/* Send the XML message definition */
if (itti_dump_send_xml_definition(sd, xml_definition, xml_definition_length) < 0) {
AssertError (0, {}, "Failed to send XML definition!\n");
close (sd);
return -1;
}
itti_dump_queue.itti_clients[i].sd = sd;
itti_dump_queue.nb_connected++;
} else {
ITTI_DUMP_DEBUG(0x2, " Socket %d rejected\n", sd);
/* We have reached max number of users connected...
* Reject the connection.
*/
close (sd);
return -1;
}
return 0;
}
static void *itti_dump_socket(void *arg_p)
{
uint32_t message_definition_xml_length;
char *message_definition_xml;
int rc;
int itti_listen_socket, max_sd;
int on = 1;
fd_set read_set, working_set;
struct sockaddr_in servaddr; /* socket address structure */
struct timeval *timeout_p = NULL;
ITTI_DUMP_DEBUG(0x2, " Creating TCP dump socket on port %u\n", ITTI_PORT);
message_definition_xml = (char *)arg_p;
AssertFatal (message_definition_xml != NULL, "Message definition XML is NULL!\n");
message_definition_xml_length = strlen(message_definition_xml) + 1;
if ((itti_listen_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
ITTI_DUMP_ERROR(" ocket creation failed (%d:%s)\n", errno, strerror(errno));
pthread_exit(NULL);
}
/* Allow socket reuse */
rc = setsockopt(itti_listen_socket, SOL_SOCKET, SO_REUSEADDR,
(char *)&on, sizeof(on));
if (rc < 0) {
ITTI_DUMP_ERROR(" setsockopt SO_REUSEADDR failed (%d:%s)\n", errno, strerror(errno));
close(itti_listen_socket);
pthread_exit(NULL);
}
/* Set socket to be non-blocking.
* NOTE: sockets accepted will inherit this option.
*/
rc = ioctl(itti_listen_socket, FIONBIO, (char *)&on);
if (rc < 0) {
ITTI_DUMP_ERROR(" ioctl FIONBIO (non-blocking) failed (%d:%s)\n", errno, strerror(errno));
close(itti_listen_socket);
pthread_exit(NULL);
}
memset(&servaddr, 0, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
servaddr.sin_port = htons(ITTI_PORT);
if (bind(itti_listen_socket, (struct sockaddr *) &servaddr,
sizeof(servaddr)) < 0) {
ITTI_DUMP_ERROR(" Bind failed (%d:%s)\n", errno, strerror(errno));
pthread_exit(NULL);
}
if (listen(itti_listen_socket, 5) < 0) {
ITTI_DUMP_ERROR(" Listen failed (%d:%s)\n", errno, strerror(errno));
pthread_exit(NULL);
}
FD_ZERO(&read_set);
/* Add the listener */
FD_SET(itti_listen_socket, &read_set);
/* Add the event fd */
FD_SET(itti_dump_queue.event_fd, &read_set);
/* Max of both sd */
max_sd = itti_listen_socket > itti_dump_queue.event_fd ? itti_listen_socket : itti_dump_queue.event_fd;
itti_dump_queue.itti_listen_socket = itti_listen_socket;
/* Loop waiting for incoming connects or for incoming data
* on any of the connected sockets.
*/
while (1) {
int desc_ready;
int client_socket = -1;
int i;
memcpy(&working_set, &read_set, sizeof(read_set));
timeout_p = NULL;
/* No timeout: select blocks till a new event has to be handled
* on sd's.
*/
rc = select(max_sd + 1, &working_set, NULL, NULL, timeout_p);
if (rc < 0) {
ITTI_DUMP_ERROR(" select failed (%d:%s)\n", errno, strerror(errno));
pthread_exit(NULL);
} else if (rc == 0) {
/* Timeout */
if (itti_dump_flush_ring_buffer(1) == 0) {
if (itti_dump_running) {
ITTI_DUMP_DEBUG (0x4, " No messages consumers, waiting ...\n");
usleep(100 * 1000);
} else {
itti_dump_socket_exit();
}
}
}
desc_ready = rc;
for (i = 0; i <= max_sd && desc_ready > 0; i++) {
if (FD_ISSET(i, &working_set)) {
desc_ready -= 1;
if (i == itti_dump_queue.event_fd) {
/* Notification of new element to dump from other tasks */
eventfd_t sem_counter;
ssize_t read_ret;
/* Read will always return 1 for kernel versions > 2.6.30 */
read_ret = read (itti_dump_queue.event_fd, &sem_counter, sizeof(sem_counter));
if (read_ret < 0) {
ITTI_DUMP_ERROR(" Failed read for semaphore: %s\n", strerror(errno));
pthread_exit(NULL);
}
AssertFatal (read_ret == sizeof(sem_counter), "Failed to read from dump event FD (%d/%d)!\n", (int) read_ret, (int) sizeof(sem_counter));
if (itti_dump_flush_ring_buffer(0) == 0) {
if (itti_dump_running) {
ITTI_DUMP_DEBUG (0x4, " No messages consumers, waiting ...\n");
usleep(100 * 1000);
{
ssize_t write_ret;
sem_counter = 1;
/* Call to write for an event fd must be of 8 bytes */
write_ret = write(itti_dump_queue.event_fd, &sem_counter, sizeof(sem_counter));
AssertFatal (write_ret == sizeof(sem_counter), "Failed to write to dump event FD (%d/%d)!\n", (int) write_ret, (int) sem_counter);
}
} else {
itti_dump_socket_exit();
}
} else {
ITTI_DUMP_DEBUG(0x1, " Write element to file\n");
}
} else
if (i == itti_listen_socket) {
do {
client_socket = accept(itti_listen_socket, NULL, NULL);
if (client_socket < 0) {
if (errno == EWOULDBLOCK || errno == EAGAIN) {
/* No more new connection */
ITTI_DUMP_DEBUG(0x2, " No more new connection\n");
continue;
} else {
ITTI_DUMP_ERROR(" accept failed (%d:%s)\n", errno, strerror(errno));
pthread_exit(NULL);
}
}
if (itti_dump_handle_new_connection(client_socket, message_definition_xml,
message_definition_xml_length) == 0) {
/* The socket has been accepted.
* We have to update the set to include this new sd.
*/
FD_SET(client_socket, &read_set);
if (client_socket > max_sd)
max_sd = client_socket;
}
} while(client_socket != -1);
} else {
/* For now the MME itti dumper should not receive data
* other than connection oriented (CLOSE).
*/
uint8_t j;
ITTI_DUMP_DEBUG(0x2, " Socket %d disconnected\n", i);
/* Close the socket and update info related to this connection */
close(i);
for (j = 0; j < ITTI_DUMP_MAX_CON; j++) {
if (itti_dump_queue.itti_clients[j].sd == i)
break;
}
/* In case we don't find the matching sd in list of known
* connections -> assert.
*/
AssertFatal (j < ITTI_DUMP_MAX_CON, "Connection index not found (%d/%d) for socked %d!\n", j, ITTI_DUMP_MAX_CON, i);
/* Re-initialize the socket to -1 so we can accept new
* incoming connections.
*/
itti_dump_queue.itti_clients[j].sd = -1;
itti_dump_queue.itti_clients[j].last_message_number = 0;
itti_dump_queue.nb_connected--;
/* Remove the socket from the FD set and update the max sd */
FD_CLR(i, &read_set);
if (i == max_sd) {
if (itti_dump_queue.nb_connected == 0) {
/* No more new connection max_sd = itti_listen_socket */
max_sd = itti_listen_socket;
} else {
while (FD_ISSET(max_sd, &read_set) == 0) {
max_sd -= 1;
}
}
}
}
}
}
}
return NULL;
}
/*------------------------------------------------------------------------------*/
int itti_dump_queue_message(task_id_t sender_task,
message_number_t message_number,
MessageDef *message_p,
const char *message_name,
const uint32_t message_size)
{
if (itti_dump_running) {
itti_dump_queue_item_t *new;
AssertFatal (message_name != NULL, "Message name is NULL!\n");
AssertFatal (message_p != NULL, "Message is NULL!\n");
new = itti_malloc(sender_task, TASK_MAX, sizeof(itti_dump_queue_item_t));
new->data = itti_malloc(sender_task, TASK_MAX, message_size);
memcpy(new->data, message_p, message_size);
new->data_size = message_size;
new->message_number = message_number;
itti_dump_enqueue_message(new, message_size, ITTI_DUMP_MESSAGE_TYPE);
}
return 0;
}
/* This function should be called by each thread that will use the ring buffer */
void itti_dump_thread_use_ring_buffer(void)
{
lfds611_ringbuffer_use(itti_dump_queue.itti_message_queue);
}
int itti_dump_init(const char * const messages_definition_xml, const char * const dump_file_name)
{
int i, ret;
struct sched_param scheduler_param;
scheduler_param.sched_priority = sched_get_priority_min(SCHED_FIFO) + 1;
if (dump_file_name != NULL) {
dump_file = fopen(dump_file_name, "wb");
if (dump_file == NULL) {
ITTI_DUMP_ERROR(" can not open dump file \"%s\" (%d:%s)\n", dump_file_name, errno, strerror(errno));
} else {
/* Output the XML to file */
uint32_t message_size = strlen(messages_definition_xml) + 1;
itti_socket_header_t header;
header.message_size = sizeof(itti_socket_header_t) + message_size + sizeof(itti_message_types_t);
header.message_type = ITTI_DUMP_XML_DEFINITION;
fwrite (&header, sizeof(itti_socket_header_t), 1, dump_file);
fwrite (messages_definition_xml, message_size, 1, dump_file);
fwrite (&itti_dump_xml_definition_end, sizeof(itti_message_types_t), 1, dump_file);
fflush (dump_file);
}
}
memset(&itti_dump_queue, 0, sizeof(itti_desc_t));
ITTI_DUMP_DEBUG(0x2, " Creating new ring buffer for itti dump of %u elements\n",
ITTI_QUEUE_MAX_ELEMENTS);
if (lfds611_ringbuffer_new(&itti_dump_queue.itti_message_queue,
ITTI_QUEUE_MAX_ELEMENTS,
NULL,
NULL) != 1) {
/* Always assert on this condition */
AssertFatal (0, " Failed to create ring buffer!\n");
}
itti_dump_queue.event_fd = eventfd(0, EFD_SEMAPHORE);
if (itti_dump_queue.event_fd == -1) {
/* Always assert on this condition */
AssertFatal (0, "eventfd failed: %s!\n", strerror(errno));
}
itti_dump_queue.nb_connected = 0;
for(i = 0; i < ITTI_DUMP_MAX_CON; i++) {
itti_dump_queue.itti_clients[i].sd = -1;
itti_dump_queue.itti_clients[i].last_message_number = 0;
}
/* initialized with default attributes */
ret = pthread_attr_init(&itti_dump_queue.attr);
if (ret < 0) {
AssertFatal (0, "pthread_attr_init failed (%d:%s)!\n", errno, strerror(errno));
}
ret = pthread_attr_setschedpolicy(&itti_dump_queue.attr, SCHED_FIFO);
if (ret < 0) {
AssertFatal (0, "pthread_attr_setschedpolicy (SCHED_IDLE) failed (%d:%s)!\n", errno, strerror(errno));
}
ret = pthread_attr_setschedparam(&itti_dump_queue.attr, &scheduler_param);
if (ret < 0) {
AssertFatal (0, "pthread_attr_setschedparam failed (%d:%s)!\n", errno, strerror(errno));
}
ret = pthread_create(&itti_dump_queue.itti_acceptor_thread, &itti_dump_queue.attr,
&itti_dump_socket, (void *)messages_definition_xml);
if (ret < 0) {
AssertFatal (0, "pthread_create failed (%d:%s)!\n", errno, strerror(errno));
}
pthread_setname_np( itti_dump_queue.itti_acceptor_thread, "ITTI acceptor" );
return 0;
}
void itti_dump_exit(void)
{
void *arg;
itti_dump_queue_item_t *new;
new = itti_malloc(TASK_UNKNOWN, TASK_UNKNOWN, sizeof(itti_dump_queue_item_t));
memset(new, 0, sizeof(itti_dump_queue_item_t));
/* Set a flag to stop recording message */
itti_dump_running = 0;
/* Send the exit signal to other thread */
itti_dump_enqueue_message(new, 0, ITTI_DUMP_EXIT_SIGNAL);
ITTI_DUMP_DEBUG(0x2, " waiting for dumper thread to finish\n");
/* wait for the thread to terminate */
pthread_join(itti_dump_queue.itti_acceptor_thread, &arg);
ITTI_DUMP_DEBUG(0x2, " dumper thread correctly exited\n");
if (dump_file != NULL) {
/* Synchronise file and then close it */
fclose(dump_file);
dump_file = NULL;
}
if (itti_dump_queue.itti_message_queue) {
lfds611_ringbuffer_delete(itti_dump_queue.itti_message_queue,
itti_dump_user_data_delete_function, NULL);
}
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef INTERTASK_INTERFACE_DUMP_H_
#define INTERTASK_INTERFACE_DUMP_H_
int itti_dump_queue_message(task_id_t sender_task, message_number_t message_number, MessageDef *message_p, const char *message_name,
const uint32_t message_size);
int itti_dump_init(const char * const messages_definition_xml, const char * const dump_file_name);
void itti_dump_exit(void);
void itti_dump_thread_use_ring_buffer(void);
#endif /* INTERTASK_INTERFACE_DUMP_H_ */
......@@ -41,10 +41,6 @@
#ifndef CHECK_PROTOTYPE_ONLY
const char * const messages_definition_xml = {
#include "messages_xml.h"
};
/* Map task id to printable name. */
const task_info_t tasks_info[] = {
{0, TASK_UNKNOWN, 0, 0, "TASK_UNKNOWN"},
......@@ -71,8 +67,7 @@ const message_info_t messages_info[] = {
* \param messages_info Pointer on messages information as created by this include file
**/
int itti_init(task_id_t task_max, thread_id_t thread_max, MessagesIds messages_id_max, const task_info_t *tasks_info,
const message_info_t *messages_info, const char * const messages_definition_xml,
const char * const dump_file_name);
const message_info_t *messages_info);
#endif /* INTERTASK_INTERFACE_INIT_H_ */
/* @} */
......@@ -29,7 +29,7 @@ PLMN: {
PLMN4: {
FULLNAME="OAI LTEBOX";
SHORTNAME="OAIALU";
MNC="93";
MNC="92";
MCC="208";
};
PLMN5: {
......@@ -86,20 +86,20 @@ UE0:
};
SIM: {
MSIN="0100001111";
USIM_API_K="8baf473f2f8fd09487cccbd7097c6862";
OPC="e734f8734007d6c5ce7a0508809e7e9c";
MSIN="0100001100";
USIM_API_K="fec86ba6eb707ed08905757b1bb44b8f";
OPC="C42449363BBAD02B66D16BC975D77CC1";
MSISDN="33611123456";
};
# Home PLMN Selector with Access Technology
HPLMN= "20893";
HPLMN= "20892";
# User controlled PLMN Selector with Access Technology
UCPLMN_LIST = ();
# Operator PLMN List
OPLMN_LIST = ("00101", "20810", "20811", "20813", "20893", "310280", "310028");
OPLMN_LIST = ("00101", "20810", "20811", "20813", "20892", "310280", "310028");
# Operator controlled PLMN Selector with Access Technology
OCPLMN_LIST = ("22210", "21401", "21406", "26202", "26204");
......
......@@ -1206,7 +1206,7 @@ int main( int argc, char **argv )
logInit();
set_glog(LOG_TRACE, LOG_MED);
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, NULL);
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info);
set_comp_log(ENB_APP, LOG_TRACE, LOG_MED, 1);
set_comp_log(S1AP, LOG_TRACE, LOG_MED, 1);
......
......@@ -69,7 +69,7 @@ int main(int argc, char *argv[])
/* Calling each layer init function */
log_init(&mme_config);
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, NULL);
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info);
sctp_init(&mme_config);
udp_init(&mme_config);
s1ap_mme_init(&mme_config);
......
......@@ -57,7 +57,6 @@ static void *eNB_app_task (void *args_p);
void mme_test_s1_start_test(instance_t instance);
//------------------------------------------------------------------------------
static char *conf_config_file_name = NULL;
static char *itti_dump_file = NULL;
const Enb_properties_array_t *enb_properties = NULL;
int16_t glog_level = LOG_INFO;
int16_t glog_verbosity = LOG_MED;
......@@ -77,10 +76,6 @@ static void get_options (int argc, char **argv)
while ((c = getopt_long (argc, argv, "K:g:G:O:",NULL,NULL)) != -1) {
switch (c) {
case 'K':
itti_dump_file = strdup(optarg);
break;
case 'O':
conf_config_file_name = optarg;
break;
......@@ -316,7 +311,7 @@ int main( int argc, char **argv )
/* Read eNB configuration file */
enb_properties = enb_config_init(conf_config_file_name);
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, itti_dump_file);
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info);
itti_wait_ready(1);
......
......@@ -19,7 +19,7 @@ First, you must have all four openair SW directories, openair1, openair2, openai
- libconfig++8-dev
- libgtk-3-dev
- libpgm-5.1 and libpgm-5.1-dev for distributed simulation with reliable multicast transmport
- libxml2 and libxml2-dev and gccxml
- libxml2 and libxml2-dev
- libforms-bin libforms-dev
- nettle-dev nettle-bin openssl libssl-dev
- libatlas-base-dev and libatlas-headers (for Ubuntu 11.04, libatlas-dev instead of libatlas-headers)
......@@ -113,4 +113,3 @@ Please choose the web server that should be automatically configured to run phpM
Web server to reconfigure automatically:
[*] apache2
[ ] lighttpd
\ No newline at end of file
......@@ -149,10 +149,6 @@ char logmem_filename[1024] = {0};
// This is a dummy declaration (dlsch_demodulation.c is no longer compiled for eNodeB)
int16_t dlsch_demod_shift = 0;
#if defined(ENABLE_ITTI)
static char *itti_dump_file = NULL;
#endif
int UE_scan = 1;
int UE_scan_carrier = 0;
runmode_t mode = normal_txrx;
......@@ -976,7 +972,7 @@ int main( int argc, char **argv )
log_set_instance_type (LOG_INSTANCE_ENB);
printf("ITTI init\n");
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, itti_dump_file);
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info);
// initialize mscgen log after ITTI
MSC_INIT(MSC_E_UTRAN, THREAD_MAX+TASK_MAX);
......
......@@ -176,7 +176,6 @@
{"a" , CONFIG_HLP_CHOFF, 0, iptr:&chain_offset, defintval:0, TYPE_INT, 0}, \
{"d" , CONFIG_HLP_SOFTS, PARAMFLAG_BOOL, uptr:(uint32_t *)&do_forms, defintval:0, TYPE_INT8, 0}, \
{"E" , CONFIG_HLP_TQFS, PARAMFLAG_BOOL, i8ptr:&threequarter_fs, defintval:0, TYPE_INT8, 0}, \
{"K" , CONFIG_HLP_ITTIL, PARAMFLAG_NOFREE, strptr:&itti_dump_file, defstrval:"/tmp/itti.dump", TYPE_STRING, 0}, \
{"m" , CONFIG_HLP_DLMCS, 0, uptr:&target_dl_mcs, defintval:0, TYPE_UINT, 0}, \
{"t" , CONFIG_HLP_ULMCS, 0, uptr:&target_ul_mcs, defintval:0, TYPE_UINT, 0}, \
{"W" , CONFIG_HLP_L2MONW, 0, strptr:(char **)&in_ip, defstrval:"127.0.0.1", TYPE_STRING, sizeof(in_ip)}, \
......
......@@ -149,10 +149,6 @@ int32_t uplink_frequency_offset[MAX_NUM_CCs][4];
#if defined(ENABLE_ITTI)
static char *itti_dump_file = NULL;
#endif
int UE_scan = 1;
int UE_scan_carrier = 0;
int simL1flag = 0;
......@@ -859,7 +855,7 @@ int main( int argc, char **argv )
printf("ITTI init\n");
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, itti_dump_file);
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info);
// initialize mscgen log after ITTI
MSC_INIT(MSC_E_UTRAN, THREAD_MAX+TASK_MAX);
......
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