Commit 40faab75 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Code cleanup/format for Itti

parent 238c743b
......@@ -3,9 +3,9 @@
* 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
* 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
*
......@@ -33,28 +33,22 @@
class itti_async_shell_cmd : public itti_msg {
public:
itti_async_shell_cmd(const task_id_t origin, const task_id_t destination,
const std::string &system_cmd, bool is_abort_on_error,
const char *src_file, const int src_line)
:
itti_msg(ASYNC_SHELL_CMD, origin, destination),
itti_async_shell_cmd(
const task_id_t origin, const task_id_t destination,
const std::string& system_cmd, bool is_abort_on_error,
const char* src_file, const int src_line)
: itti_msg(ASYNC_SHELL_CMD, origin, destination),
system_command(system_cmd),
is_abort_on_error(is_abort_on_error),
src_file(src_file),
src_line(src_line) {
}
itti_async_shell_cmd(const itti_async_shell_cmd &i)
:
itti_msg(i),
src_line(src_line) {}
itti_async_shell_cmd(const itti_async_shell_cmd& i)
: itti_msg(i),
system_command(i.system_command),
is_abort_on_error(i.is_abort_on_error),
src_file(i.src_file),
src_line(i.src_line) {
}
const char* get_msg_name() {
return typeid(itti_msg_ping).name();
}
;
src_line(i.src_line) {}
const char* get_msg_name() { return typeid(itti_msg_ping).name(); };
std::string system_command;
bool is_abort_on_error;
// debug
......
......@@ -4,8 +4,8 @@
* 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
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
......
This diff is collapsed.
......@@ -3,9 +3,9 @@
* 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
* 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
*
......@@ -36,26 +36,16 @@
class itti_n4_restore : public itti_msg {
public:
itti_n4_restore(const task_id_t origin, const task_id_t destination)
:
itti_msg(RESTORE_N4_SESSIONS, origin, destination),
sessions() {
}
itti_n4_restore(const itti_n4_restore &i)
:
itti_msg(i),
sessions(i.sessions) {
}
itti_n4_restore(const itti_n4_restore &i, const task_id_t orig,
const task_id_t dest)
:
itti_n4_restore(i) {
: itti_msg(RESTORE_N4_SESSIONS, origin, destination), sessions() {}
itti_n4_restore(const itti_n4_restore& i)
: itti_msg(i), sessions(i.sessions) {}
itti_n4_restore(
const itti_n4_restore& i, const task_id_t orig, const task_id_t dest)
: itti_n4_restore(i) {
origin = orig;
destination = dest;
}
const char* get_msg_name() {
return "N4_RESTORE";
}
;
const char* get_msg_name() { return "N4_RESTORE"; };
std::set<pfcp::fseid_t> sessions;
};
......
......@@ -3,9 +3,9 @@
* 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
* 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
*
......@@ -35,54 +35,34 @@
class itti_nx_msg : public itti_msg {
public:
itti_nx_msg(const itti_msg_type_t msg_type, const task_id_t orig,
itti_nx_msg(
const itti_msg_type_t msg_type, const task_id_t orig,
const task_id_t dest)
:
itti_msg(msg_type, orig, dest) {
}
itti_nx_msg(const itti_nx_msg &i)
:
itti_msg(i) {
}
itti_nx_msg(const itti_nx_msg &i, const task_id_t orig, const task_id_t dest)
:
itti_nx_msg(i) {
: itti_msg(msg_type, orig, dest) {}
itti_nx_msg(const itti_nx_msg& i) : itti_msg(i) {}
itti_nx_msg(const itti_nx_msg& i, const task_id_t orig, const task_id_t dest)
: itti_nx_msg(i) {
origin = orig;
destination = dest;
}
};
//-----------------------------------------------------------------------------
class itti_nx_trigger_pdu_session_modification : public itti_nx_msg {
public:
itti_nx_trigger_pdu_session_modification(const task_id_t orig,
const task_id_t dest)
:
itti_nx_msg(NX_TRIGGER_SESSION_MODIFICATION, orig, dest),
itti_nx_trigger_pdu_session_modification(
const task_id_t orig, const task_id_t dest)
: itti_nx_msg(NX_TRIGGER_SESSION_MODIFICATION, orig, dest),
msg(),
http_version() {
}
http_version() {}
itti_nx_trigger_pdu_session_modification(
const itti_nx_trigger_pdu_session_modification &i)
:
itti_nx_msg(i),
msg(i.msg),
http_version(i.http_version) {
}
const itti_nx_trigger_pdu_session_modification& i)
: itti_nx_msg(i), msg(i.msg), http_version(i.http_version) {}
itti_nx_trigger_pdu_session_modification(
const itti_nx_trigger_pdu_session_modification &i, const task_id_t orig,
const itti_nx_trigger_pdu_session_modification& i, const task_id_t orig,
const task_id_t dest)
:
itti_nx_msg(i, orig, dest),
msg(),
http_version(i.http_version) {
}
const char* get_msg_name() {
return "NX_TRIGGER_PDU_SESSION_MODIFICATION";
}
;
: itti_nx_msg(i, orig, dest), msg(), http_version(i.http_version) {}
const char* get_msg_name() { return "NX_TRIGGER_PDU_SESSION_MODIFICATION"; };
smf::pdu_session_modification_network_requested msg;
uint8_t http_version;
};
......
......@@ -3,9 +3,9 @@
* 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
* 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
*
......@@ -33,30 +33,30 @@ typedef enum extended_protocol_discriminator_e {
} extended_protocol_discriminator_t;
// Procedure transaction identity
//8 bits
#define PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED (uint8_t)0
#define PROCEDURE_TRANSACTION_IDENTITY_FIRST (uint8_t)1
#define PROCEDURE_TRANSACTION_IDENTITY_LAST (uint8_t)254
#define PROCEDURE_TRANSACTION_IDENTITY_RESERVED (uint8_t)255
// 8 bits
#define PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED (uint8_t) 0
#define PROCEDURE_TRANSACTION_IDENTITY_FIRST (uint8_t) 1
#define PROCEDURE_TRANSACTION_IDENTITY_LAST (uint8_t) 254
#define PROCEDURE_TRANSACTION_IDENTITY_RESERVED (uint8_t) 255
// PDU Session Identity
typedef uint8_t pdu_session_id_t;
//8 bits
#define PDU_SESSION_IDENTITY_UNASSIGNED (uint8_t)0
#define PDU_SESSION_IDENTITY_FIRST (uint8_t)1
#define PDU_SESSION_IDENTITY_LAST (uint8_t)15
// 8 bits
#define PDU_SESSION_IDENTITY_UNASSIGNED (uint8_t) 0
#define PDU_SESSION_IDENTITY_FIRST (uint8_t) 1
#define PDU_SESSION_IDENTITY_LAST (uint8_t) 15
// QFI
// type: integer, minimum: 0, maximum: 63
#define NO_QOS_FLOW_IDENTIFIER_ASSIGNED (uint8_t)0
#define QOS_FLOW_IDENTIFIER_FIRST (uint8_t)1
#define QOS_FLOW_IDENTIFIER_LAST (uint8_t)63
#define NO_QOS_FLOW_IDENTIFIER_ASSIGNED (uint8_t) 0
#define QOS_FLOW_IDENTIFIER_FIRST (uint8_t) 1
#define QOS_FLOW_IDENTIFIER_LAST (uint8_t) 63
//QoS Rule
#define NO_QOS_RULE_IDENTIFIER_ASSIGNED (uint8_t)0
#define QOS_RULE_IDENTIFIER_FIRST (uint8_t)1
#define QOS_RULE_IDENTIFIER_LAST (uint8_t)255
// QoS Rule
#define NO_QOS_RULE_IDENTIFIER_ASSIGNED (uint8_t) 0
#define QOS_RULE_IDENTIFIER_FIRST (uint8_t) 1
#define QOS_RULE_IDENTIFIER_LAST (uint8_t) 255
// Integrity protection maximum data rate
typedef struct ipmdr_s {
......
......@@ -3,9 +3,9 @@
* 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
* 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
*
......@@ -47,14 +47,17 @@
//------------------------------------------------------------------------------
// 6.1.2 Distribution of authentication data from HSS to serving network
//------------------------------------------------------------------------------
/* NOTE 2: It is recommended that the MME fetch only one EPS authentication vector at a time as the need to perform
* AKA runs has been reduced in EPS through the use of a more elaborate key hierarchy. In particular,
* service requests can be authenticated using a stored K ASME without the need to perform AKA.
* Furthermore, the sequence number management schemes in TS 33.102, Annex C [4], designed to avoid
* re-synchronisation problems caused by interleaving use of batches of authentication vectors, are only
* optional. Re-synchronisation problems in EPS can be avoided, independently of the sequence number
* management scheme, by immediately using an authentication vector retrieved from the HSS in an
* authentication procedure between UE and MME.
/* NOTE 2: It is recommended that the MME fetch only one EPS authentication
* vector at a time as the need to perform AKA runs has been reduced in EPS
* through the use of a more elaborate key hierarchy. In particular, service
* requests can be authenticated using a stored K ASME without the need to
* perform AKA. Furthermore, the sequence number management schemes in
* TS 33.102, Annex C [4], designed to avoid re-synchronisation problems caused
* by interleaving use of batches of authentication vectors, are only optional.
* Re-synchronisation problems in EPS can be avoided, independently of the
* sequence number management scheme, by immediately using an authentication
* vector retrieved from the HSS in an authentication procedure between UE and
* MME.
*/
#define MAX_EPS_AUTH_VECTORS 1
......
......@@ -3,9 +3,9 @@
* 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
* 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
*
......@@ -19,7 +19,6 @@
* contact@openairinterface.org
*/
/*! \file 3gpp_36.401.h
\brief
\author Lionel Gauthier
......@@ -34,14 +33,18 @@
// 6.2 E-UTRAN Identifiers
//------------------------------------------------------------------------------
typedef uint32_t enb_ue_s1ap_id_t; /*!< \brief An eNB UE S1AP ID shall be allocated so as to uniquely identify the UE over the S1 interface within an eNB.
When an MME receives an eNB UE S1AP ID it shall store it for the duration of the UE-associated logical S1-connection for this UE.
Once known to an MME this IE is included in all UE associated S1-AP signalling.
The eNB UE S1AP ID shall be unique within the eNB logical node. */
typedef uint32_t enb_ue_s1ap_id_t; /*!< \brief An eNB UE S1AP ID shall be
allocated so as to uniquely identify the UE over the S1 interface within an
eNB. When an MME receives an eNB UE S1AP ID it shall store it for the duration
of the UE-associated logical S1-connection for this UE. Once known to an MME
this IE is included in all UE associated S1-AP signalling. The eNB UE S1AP ID
shall be unique within the eNB logical node. */
typedef uint32_t mme_ue_s1ap_id_t; /*!< \brief A MME UE S1AP ID shall be allocated so as to uniquely identify the UE over the S1 interface within the MME.
When an eNB receives MME UE S1AP ID it shall store it for the duration of the UE-associated logical S1-connection for this UE.
Once known to an eNB this IE is included in all UE associated S1-AP signalling.
typedef uint32_t mme_ue_s1ap_id_t; /*!< \brief A MME UE S1AP ID shall be
allocated so as to uniquely identify the UE over the S1 interface within the
MME. When an eNB receives MME UE S1AP ID it shall store it for the duration of
the UE-associated logical S1-connection for this UE. Once known to an eNB this
IE is included in all UE associated S1-AP signalling.
The MME UE S1AP ID shall be unique within the MME logical node.*/
#endif /* FILE_3GPP_36_401_SEEN */
......@@ -3,9 +3,9 @@
* 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
* 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
*
......
......@@ -3,9 +3,9 @@
* 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
* 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
*
......@@ -19,7 +19,6 @@
* contact@openairinterface.org
*/
#ifndef FILE_COMMON_TYPES_SEEN
#define FILE_COMMON_TYPES_SEEN
......@@ -31,7 +30,7 @@
typedef uint16_t sctp_stream_id_t;
typedef uint32_t sctp_assoc_id_t;
//UE NGAP IDs
// UE NGAP IDs
#define INVALID_RAN_UE_NGAP_ID_KEY 0xFFFFFFFFFFFFFFFF
#define RAN_UE_NGAP_ID_MASK 0x00FFFFFF
......
......@@ -3,9 +3,9 @@
* 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
* 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
*
......@@ -19,7 +19,6 @@
* contact@openairinterface.org
*/
/*! \file security_types.h
\brief
\author Sebastien ROUX, Lionel Gauthier
......@@ -28,11 +27,11 @@
*/
#if HAVE_CONFIG_H
# include "config.h"
#include "config.h"
#endif
#if !defined(HAVE_UINT128_T)
# include <gmp.h>
#include <gmp.h>
#endif
#include <stdlib.h>
......@@ -43,16 +42,16 @@
#define FILE_SECURITY_TYPES_SEEN
#define RAND_LENGTH_BITS (128)
#define RAND_LENGTH_OCTETS (RAND_LENGTH_BITS/8)
#define RAND_LENGTH_OCTETS (RAND_LENGTH_BITS / 8)
#define AUTH_KEY_LENGTH_BITS (128)
#define AUTH_KEY_LENGTH_OCTETS (AUTH_KEY_LENGTH_BITS/8)
#define AUTH_KEY_LENGTH_OCTETS (AUTH_KEY_LENGTH_BITS / 8)
#define KASME_LENGTH_BITS (256)
#define KASME_LENGTH_OCTETS (KASME_LENGTH_BITS/8)
#define KASME_LENGTH_OCTETS (KASME_LENGTH_BITS / 8)
/* In OCTETS */
#define XRES_LENGTH_MIN (4)
#define XRES_LENGTH_MAX (16)
#define AUTN_LENGTH_BITS (128)
#define AUTN_LENGTH_OCTETS (AUTN_LENGTH_BITS/8)
#define AUTN_LENGTH_OCTETS (AUTN_LENGTH_BITS / 8)
/* Some methods to convert a string to an int64_t */
/*
......@@ -63,29 +62,28 @@
*/
/* Converts a string to 128 bits gmplib integer holder */
# define STRING_TO_XBITS(sTRING, lENGTH, cONTAINER, rET) \
do { \
#define STRING_TO_XBITS(sTRING, lENGTH, cONTAINER, rET) \
do { \
memcpy(cONTAINER, sTRING, lENGTH); \
rET = 0; \
} while(0)
} while (0)
# define STRING_TO_128BITS(sTRING, cONTAINER, rET) \
STRING_TO_XBITS(sTRING, 16, cONTAINER, rET)
#define STRING_TO_128BITS(sTRING, cONTAINER, rET) \
STRING_TO_XBITS(sTRING, 16, cONTAINER, rET)
# define STRING_TO_256BITS(sTRING, cONTAINER, rET) \
STRING_TO_XBITS(sTRING, 32, cONTAINER, rET)
#define STRING_TO_256BITS(sTRING, cONTAINER, rET) \
STRING_TO_XBITS(sTRING, 32, cONTAINER, rET)
# define STRING_TO_RAND STRING_TO_128BITS
# define STRING_TO_AUTH_KEY STRING_TO_128BITS
# define STRING_TO_AUTH_RES STRING_TO_128BITS
# define STRING_TO_AUTN STRING_TO_128BITS
# define STRING_TO_KASME STRING_TO_256BITS
# define STRING_TO_XRES(sTRING, lENGTH, cONTAINER, rET) \
do { \
#define STRING_TO_RAND STRING_TO_128BITS
#define STRING_TO_AUTH_KEY STRING_TO_128BITS
#define STRING_TO_AUTH_RES STRING_TO_128BITS
#define STRING_TO_AUTN STRING_TO_128BITS
#define STRING_TO_KASME STRING_TO_256BITS
#define STRING_TO_XRES(sTRING, lENGTH, cONTAINER, rET) \
do { \
STRING_TO_XBITS(sTRING, lENGTH, (cONTAINER)->data, rET); \
if (rET != -1) \
(cONTAINER)->size = lENGTH; \
} while(0)
if (rET != -1) (cONTAINER)->size = lENGTH; \
} while (0)
/* RES amd XRES can have a variable length of 4-16 octets */
typedef struct {
......@@ -93,18 +91,22 @@ typedef struct {
uint8_t data[XRES_LENGTH_MAX];
} res_t;
#define FORMAT_128BITS "%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x"
#define FORMAT_128BITS \
"%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%" \
"02x,%02x"
#define XRES_FORMAT FORMAT_128BITS
#define RAND_FORMAT FORMAT_128BITS
#define AUTN_FORMAT FORMAT_128BITS
#define KASME_FORMAT FORMAT_128BITS
#define DISPLAY_128BITS(bUFFER) \
bUFFER[0], bUFFER[1], bUFFER[2], bUFFER[3], bUFFER[4], bUFFER[5], bUFFER[6], bUFFER[7], \
bUFFER[8], bUFFER[9], bUFFER[10], bUFFER[11], bUFFER[12], bUFFER[13], bUFFER[14], bUFFER[15]
bUFFER[0], bUFFER[1], bUFFER[2], bUFFER[3], bUFFER[4], bUFFER[5], bUFFER[6], \
bUFFER[7], bUFFER[8], bUFFER[9], bUFFER[10], bUFFER[11], bUFFER[12], \
bUFFER[13], bUFFER[14], bUFFER[15]
#define DISPLAY_128BITS_2(bUFFER) \
bUFFER[16], bUFFER[17], bUFFER[18], bUFFER[19], bUFFER[20], bUFFER[21], bUFFER[22], bUFFER[23], \
bUFFER[24], bUFFER[25], bUFFER[26], bUFFER[27], bUFFER[28], bUFFER[29], bUFFER[30], bUFFER[31]
bUFFER[16], bUFFER[17], bUFFER[18], bUFFER[19], bUFFER[20], bUFFER[21], \
bUFFER[22], bUFFER[23], bUFFER[24], bUFFER[25], bUFFER[26], bUFFER[27], \
bUFFER[28], bUFFER[29], bUFFER[30], bUFFER[31]
#define XRES_DISPLAY(bUFFER) DISPLAY_128BITS(bUFFER)
#define RAND_DISPLAY(bUFFER) DISPLAY_128BITS(bUFFER)
......
This diff is collapsed.
......@@ -3,9 +3,9 @@
* 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
* 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
*
......@@ -27,7 +27,6 @@
#ifndef SRC_OAI_ITTI_ITTI_HPP_INCLUDED_
#define SRC_OAI_ITTI_ITTI_HPP_INCLUDED_
#include <chrono>
#include <condition_variable>
//#include <iomanip>
......@@ -42,25 +41,43 @@
#include "thread_sched.hpp"
typedef volatile enum task_state_s {
TASK_STATE_NOT_CONFIGURED, TASK_STATE_STARTING, TASK_STATE_READY, TASK_STATE_ENDED, TASK_STATE_MAX,
TASK_STATE_NOT_CONFIGURED,
TASK_STATE_STARTING,
TASK_STATE_READY,
TASK_STATE_ENDED,
TASK_STATE_MAX,
} task_state_t;
typedef uint32_t timer_id_t;
#define ITTI_INVALID_TIMER_ID (timer_id_t)0
#define ITTI_INVALID_TIMER_ID (timer_id_t) 0
class itti_timer {
public:
itti_timer(const timer_id_t id, const task_id_t task_id, const uint32_t interval_sec, const uint32_t interval_us, uint64_t arg1_user, uint64_t arg2_user) :
id(id), task_id(task_id), arg1_user(arg1_user), arg2_user(arg2_user) {
time_out = std::chrono::system_clock::now() + std::chrono::seconds(interval_sec) + std::chrono::microseconds(interval_us);
}
itti_timer(const timer_id_t id, const task_id_t task_id, const std::chrono::system_clock::time_point time_out, uint64_t arg1_user, uint64_t arg2_user) :
id(id), task_id(task_id), time_out(time_out), arg1_user(arg1_user), arg2_user(arg2_user) {
public:
itti_timer(
const timer_id_t id, const task_id_t task_id, const uint32_t interval_sec,
const uint32_t interval_us, uint64_t arg1_user, uint64_t arg2_user)
: id(id), task_id(task_id), arg1_user(arg1_user), arg2_user(arg2_user) {
time_out = std::chrono::system_clock::now() +
std::chrono::seconds(interval_sec) +
std::chrono::microseconds(interval_us);
}
itti_timer(const itti_timer &t) : id(t.id), task_id(t.task_id) , time_out(t.time_out), arg1_user(t.arg1_user), arg2_user(t.arg2_user) {}
//itti_timer(itti_timer&& t) noexcept : id(std::move(t.id)), task_id(std::move(t.task_id)) , time_out(std::move(t.time_out)) {}
itti_timer(
const timer_id_t id, const task_id_t task_id,
const std::chrono::system_clock::time_point time_out, uint64_t arg1_user,
uint64_t arg2_user)
: id(id),
task_id(task_id),
time_out(time_out),
arg1_user(arg1_user),
arg2_user(arg2_user) {}
itti_timer(const itti_timer& t)
: id(t.id),
task_id(t.task_id),
time_out(t.time_out),
arg1_user(t.arg1_user),
arg2_user(t.arg2_user) {}
// itti_timer(itti_timer&& t) noexcept : id(std::move(t.id)),
// task_id(std::move(t.task_id)) , time_out(std::move(t.time_out)) {}
bool operator<(const itti_timer& t) const { return time_out < t.time_out; }
~itti_timer() {}
......@@ -73,24 +90,27 @@ public:
//------------------------------------------------------------------------------
struct timer_comparator {
bool operator()(const itti_timer &left, const itti_timer &right) const
{
bool operator()(const itti_timer& left, const itti_timer& right) const {
return (left.time_out < right.time_out);
}
};
class itti_task_ctxt {
public:
explicit itti_task_ctxt(const task_id_t task_id) :
task_id(task_id), m_state(), task_state(TASK_STATE_STARTING), msg_queue() , m_queue(), c_queue() {}
public:
explicit itti_task_ctxt(const task_id_t task_id)
: task_id(task_id),
m_state(),
task_state(TASK_STATE_STARTING),
msg_queue(),
m_queue(),
c_queue() {}
~itti_task_ctxt() {}
const task_id_t task_id;
/*
* pthread associated with the thread
*/
//std::thread::id thread_id;
// std::thread::id thread_id;
std::thread thread;
/*
* State of the thread
......@@ -104,8 +124,8 @@ public:
};
class itti_mw {
private:
itti_task_ctxt *itti_task_ctxts[TASK_MAX];
private:
itti_task_ctxt* itti_task_ctxts[TASK_MAX];
/*
* Current message number. Incremented every call to send_msg_to_task
......@@ -130,7 +150,7 @@ private:
static void timer_manager_task(const util::thread_sched_params& sched_params);
public:
public:
itti_mw();
itti_mw(itti_mw const&) = delete;
void operator=(itti_mw const&) = delete;
......@@ -138,8 +158,8 @@ public:
void start(const util::thread_sched_params& sched_params);
timer_id_t increment_timer_id ();
unsigned int increment_message_number ();
timer_id_t increment_timer_id();
unsigned int increment_message_number();
/** \brief Send a broadcast message to every task
\param message_p Pointer to the message to send
......@@ -158,7 +178,7 @@ public:
\param task_id Task ID of the receiving task
\param received_msg Pointer to the allocated message
**/
std::shared_ptr<itti_msg> receive_msg (task_id_t task_id);
std::shared_ptr<itti_msg> receive_msg(task_id_t task_id);
/** \brief Try to retrieves a message in the queue associated to task_id.
\param task_id Task ID of the receiving task
......@@ -172,9 +192,8 @@ public:
* \param args_p Optional argument to pass to the start routine
* @returns -1 on failure, 0 otherwise
**/
int create_task (const task_id_t task_id,
void (*start_routine) (void *),
void *args_p);
int create_task(
const task_id_t task_id, void (*start_routine)(void*), void* args_p);
/** \brief Notify ITTI of a started thread
* \param task_id of started task
......@@ -184,18 +203,20 @@ public:
**/
int notify_task_ready(const task_id_t task_id);
/** \brief Indicates to ITTI if newly created tasks should wait for all tasks to be ready
* \param wait_tasks non 0 to make new created tasks to wait, 0 to let created tasks to run
/** \brief Indicates to ITTI if newly created tasks should wait for all tasks
*to be ready \param wait_tasks non 0 to make new created tasks to wait, 0 to
*let created tasks to run
**/
//void wait_ready(int wait_tasks);
// void wait_ready(int wait_tasks);
/** \brief Mark the task as in ready state
* \param task_id task to mark as ready
**/
//void mark_task_ready(task_id_t task_id);
// void mark_task_ready(task_id_t task_id);
/** \brief handle signals and wait for all threads to join when the process complete.
* This function should be called from the main thread after having created all ITTI tasks.
/** \brief handle signals and wait for all threads to join when the process
*complete. This function should be called from the main thread after having
*created all ITTI tasks.
**/
void wait_tasks_end(void);
......@@ -211,22 +232,17 @@ public:
* @returns 0 on failure, timer id otherwise
**/
timer_id_t timer_setup(
uint32_t interval_sec,
uint32_t interval_us,
task_id_t task_id,
uint64_t arg1_user = 0,
uint64_t arg2_user = 0);
uint32_t interval_sec, uint32_t interval_us, task_id_t task_id,
uint64_t arg1_user = 0, uint64_t arg2_user = 0);
/** \brief Remove the timer from list
* \param timer_id unique timer id
* \param task_id task id of the task that requested the timer
* @returns -1 on failure, 0 otherwise
**/
int timer_remove (timer_id_t timer_id);
static void signal_handler( int signum );
int timer_remove(timer_id_t timer_id);
static void signal_handler(int signum);
};
#endif /* SRC_OAI_ITTI_ITTI_HPP_INCLUDED_ */
......@@ -3,9 +3,9 @@
* 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
* 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
*
......@@ -28,24 +28,25 @@
#include "itti_msg.hpp"
#include "itti.hpp"
extern itti_mw *itti_inst;
extern itti_mw* itti_inst;
itti_msg::itti_msg() :
msg_type(ITTI_MSG_TYPE_NONE), origin(TASK_NONE), destination(TASK_NONE) {
itti_msg::itti_msg()
: msg_type(ITTI_MSG_TYPE_NONE), origin(TASK_NONE), destination(TASK_NONE) {
msg_num = itti_inst->increment_message_number();
};
itti_msg::itti_msg(const itti_msg_type_t msg_type, task_id_t origin, task_id_t destination) :
msg_type(msg_type), origin(origin), destination(destination) {
itti_msg::itti_msg(
const itti_msg_type_t msg_type, task_id_t origin, task_id_t destination)
: msg_type(msg_type), origin(origin), destination(destination) {
msg_num = itti_inst->increment_message_number();
};
itti_msg::itti_msg(const itti_msg& i) :
msg_type(i.msg_type),msg_num(i.msg_num), origin(i.origin), destination(i.destination) {
};
itti_msg::itti_msg(const itti_msg& i)
: msg_type(i.msg_type),
msg_num(i.msg_num),
origin(i.origin),
destination(i.destination){};
const char* itti_msg::get_msg_name()
{
const char* itti_msg::get_msg_name() {
return "UNINITIALIZED";
}
......@@ -4,8 +4,8 @@
* 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
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
......
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