open5gs/lib/gtp/gtp_xact.h

90 lines
3.0 KiB
C
Raw Normal View History

2017-03-26 15:48:33 +00:00
#ifndef __GTP_XACT_H__
#define __GTP_XACT_H__
#include "core_pkbuf.h"
#include "core_list.h"
#include "core_index.h"
2017-03-26 15:48:33 +00:00
#include "core_timer.h"
2017-08-31 01:48:14 +00:00
#include "gtp_message.h"
2017-03-26 15:48:33 +00:00
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
2017-11-30 11:13:15 +00:00
typedef struct _gtp_node_t gtp_node_t;
2017-03-26 15:48:33 +00:00
/**
* Transaction context
*/
2017-03-29 02:54:18 +00:00
typedef struct _gtp_xact_t {
2017-03-26 15:48:33 +00:00
lnode_t node; /**< A node of list */
index_t index;
2017-03-26 15:48:33 +00:00
#define GTP_LOCAL_ORIGINATOR 0
#define GTP_REMOTE_ORIGINATOR 1
c_uint8_t org; /**< Transaction' originator.
local or remote */
2017-03-30 00:06:56 +00:00
c_uint32_t xid; /**< Transaction ID */
2017-03-27 10:12:45 +00:00
gtp_node_t *gnode; /**< Relevant GTP node context */
2017-03-30 00:20:40 +00:00
2017-08-31 11:48:15 +00:00
int step; /**< Current step in the sequence.
1 : Initial
2 : Triggered
3 : Triggered-Reply */
struct {
c_uint8_t type; /**< Message type history */
pkbuf_t *pkbuf; /**< Packet history */
} seq[3]; /**< history for the each step */
2017-03-30 00:20:40 +00:00
2017-08-31 11:48:15 +00:00
tm_block_id tm_response; /**< Timer waiting for next message */
c_uint8_t response_rcount;
2017-09-04 11:06:54 +00:00
tm_block_id tm_holding; /**< Timer waiting for holding message */
c_uint8_t holding_rcount;
2017-03-26 15:48:33 +00:00
2017-03-30 00:20:40 +00:00
struct _gtp_xact_t *assoc_xact; /**< Associated transaction */
2017-09-01 12:35:45 +00:00
#define GTP_XACT_STORE_SESSION(xact, session) \
do { \
d_assert((xact), break, "Null param"); \
d_assert((session), break, "Null param"); \
((xact)->sess) = (session); \
} while(0)
#define GTP_XACT_RETRIEVE_SESSION(xact) ((xact) ? ((xact)->sess) : NULL)
void *sess; /**< Session Store */
2017-03-29 02:54:18 +00:00
} gtp_xact_t;
2017-03-26 15:48:33 +00:00
2017-08-31 11:48:15 +00:00
CORE_DECLARE(status_t) gtp_xact_init(tm_service_t *tm_service,
2017-09-04 11:06:54 +00:00
c_uintptr_t response_event, c_uintptr_t holding_event);
2017-03-26 15:48:33 +00:00
CORE_DECLARE(status_t) gtp_xact_final(void);
CORE_DECLARE(gtp_xact_t *) gtp_xact_local_create(
2017-09-01 04:51:31 +00:00
gtp_node_t *gnode, gtp_header_t *hdesc, pkbuf_t *pkbuf);
2017-08-31 05:03:00 +00:00
CORE_DECLARE(gtp_xact_t *) gtp_xact_remote_create(
gtp_node_t *gnode, c_uint32_t sqn);
2017-04-11 13:44:57 +00:00
CORE_DECLARE(void) gtp_xact_delete_all(gtp_node_t *gnode);
2017-03-26 15:48:33 +00:00
2017-08-31 05:03:00 +00:00
CORE_DECLARE(status_t) gtp_xact_update_tx(gtp_xact_t *xact,
2017-09-01 04:51:31 +00:00
gtp_header_t *hdesc, pkbuf_t *pkbuf);
2017-08-31 11:48:15 +00:00
CORE_DECLARE(status_t) gtp_xact_update_rx(gtp_xact_t *xact, c_uint8_t type);
2017-08-31 05:03:00 +00:00
CORE_DECLARE(status_t) gtp_xact_commit(gtp_xact_t *xact);
2017-08-31 11:48:15 +00:00
CORE_DECLARE(status_t) gtp_xact_timeout(index_t index, c_uintptr_t event);
2017-03-26 15:48:33 +00:00
2017-08-31 05:03:00 +00:00
CORE_DECLARE(status_t) gtp_xact_receive(
gtp_node_t *gnode, gtp_header_t *h, gtp_xact_t **xact);
2017-03-26 15:48:33 +00:00
CORE_DECLARE(gtp_xact_t *) gtp_xact_find(index_t index);
2017-08-31 05:03:00 +00:00
CORE_DECLARE(gtp_xact_t *)gtp_xact_find_by_xid(
gtp_node_t *gnode, c_uint8_t type, c_uint32_t xid);
2017-08-31 03:06:11 +00:00
CORE_DECLARE(void) gtp_xact_associate(gtp_xact_t *xact1, gtp_xact_t *xact2);
CORE_DECLARE(void) gtp_xact_deassociate(gtp_xact_t *xact1, gtp_xact_t *xact2);
2017-03-26 15:48:33 +00:00
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GTP_XACT_H__ */