open5gs/src/mme/event.h

122 lines
2.4 KiB
C
Raw Normal View History

2017-02-13 00:58:55 +00:00
#ifndef __EVENT_H__
#define __EVENT_H__
2017-02-13 02:48:25 +00:00
#include "core_msgq.h"
2017-02-13 00:58:55 +00:00
#include "core_time.h"
#include "core_timer.h"
#include "core_fsm.h"
#include "core_pkbuf.h"
2017-02-13 05:01:38 +00:00
#include "core_net.h"
2017-02-13 00:58:55 +00:00
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef enum {
EVT_BASE = FSM_USER_SIG,
2017-03-04 15:57:52 +00:00
EVT_LO_ENB_S1AP_ACCEPT,
EVT_LO_ENB_S1AP_CONNREFUSED,
2017-02-13 00:58:55 +00:00
2017-03-05 08:07:43 +00:00
EVT_MSG_ENB_S1AP,
2017-03-05 08:36:16 +00:00
EVT_MSG_UE_EMM,
2017-03-24 04:19:36 +00:00
EVT_MSG_MME_S11,
2017-02-13 00:58:55 +00:00
EVT_TOP,
} event_e;
typedef struct {
fsm_event_t event;
c_uintptr_t param1;
c_uintptr_t param2;
c_uintptr_t param3;
c_uintptr_t param4;
} event_t;
#define EVENT_SIZE sizeof(event_t)
2017-03-05 08:05:30 +00:00
#define event_set(__ptr_e, __evnt) \
((__ptr_e)->event = (__evnt))
2017-02-13 00:58:55 +00:00
#define event_get(__ptr_e) \
((__ptr_e)->event)
#define event_set_param1(__ptr_e, __param) \
((__ptr_e)->param1 = (c_uintptr_t)(__param))
#define event_set_param2(__ptr_e, __param) \
((__ptr_e)->param2 = (c_uintptr_t)(__param))
#define event_set_param3(__ptr_e, __param) \
((__ptr_e)->param3 = (c_uintptr_t)(__param))
#define event_set_param4(__ptr_e, __param) \
((__ptr_e)->param4 = (c_uintptr_t)(__param))
#define event_get_param1(__ptr_e) \
((__ptr_e)->param1)
#define event_get_param2(__ptr_e) \
((__ptr_e)->param2)
#define event_get_param3(__ptr_e) \
((__ptr_e)->param3)
#define event_get_param4(__ptr_e) \
((__ptr_e)->param4)
/**
2017-02-13 02:48:25 +00:00
* Create event message queue
2017-02-13 00:58:55 +00:00
*
2017-02-13 02:48:25 +00:00
* @return event queue or 0
2017-02-13 00:58:55 +00:00
*/
2017-02-13 02:48:25 +00:00
CORE_DECLARE(msgq_id) event_create(void);
2017-02-13 00:58:55 +00:00
/**
2017-02-13 02:48:25 +00:00
* Delete event message queue
2017-02-13 00:58:55 +00:00
*
* @return CORE_OK or CORE_ERROR
*/
2017-02-13 02:48:25 +00:00
CORE_DECLARE(status_t) event_delete(msgq_id queue_id);
2017-02-13 00:58:55 +00:00
/**
* Send a event to event queue
*
* @return If success, return the size to be sent.
* If else, return -1
*/
2017-02-13 02:48:25 +00:00
CORE_DECLARE(int) event_send(msgq_id queue_id, event_t *e);
2017-02-13 00:58:55 +00:00
/**
* Receive a event from event queue with timeout
*
* @return If success, return the size to be received.
* If timout occurs, return CORE_TIMEUP.
* If else, return -1.
*/
2017-02-13 02:48:25 +00:00
CORE_DECLARE(int) event_timedrecv(
msgq_id queue_id, event_t *e, c_time_t timeout);
2017-02-13 00:58:55 +00:00
/**
* Create a timer
*/
2017-03-24 05:18:30 +00:00
CORE_DECLARE(tm_block_id) event_timer_create(
tm_service_t *tm_service, tm_type_e type, c_uint32_t duration,
c_uintptr_t event, c_uintptr_t param);
2017-02-13 00:58:55 +00:00
/**
* Delete a timer
*/
CORE_DECLARE(status_t) event_timer_delete(tm_block_id id);
char* event_get_name(event_t *e);
#ifdef __cplusplus
}
#endif /* __cplusplus */
2017-03-07 08:10:38 +00:00
#endif /* __EVENT_H__ */