open5gs/lib/gtp/xact.h

102 lines
3.5 KiB
C
Raw Normal View History

2019-04-27 14:54:30 +00:00
/*
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
*
* This file is part of Open5GS.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2019-09-13 12:07:47 +00:00
#if !defined(OGS_GTP_INSIDE) && !defined(OGS_GTP_COMPILATION)
#error "This header cannot be included directly."
#endif
2017-03-26 15:48:33 +00:00
2019-09-13 12:07:47 +00:00
#ifndef OGS_GTP_XACT_H
#define OGS_GTP_XACT_H
2017-03-26 15:48:33 +00:00
#ifdef __cplusplus
extern "C" {
2019-06-11 09:28:25 +00:00
#endif
2017-03-26 15:48:33 +00:00
/**
* Transaction context
*/
2019-09-13 12:07:47 +00:00
typedef struct ogs_gtp_xact_s {
2019-04-27 14:54:30 +00:00
ogs_lnode_t node; /**< A node of list */
ogs_index_t index;
2019-09-13 12:07:47 +00:00
#define OGS_GTP_LOCAL_ORIGINATOR 0
#define OGS_GTP_REMOTE_ORIGINATOR 1
2019-04-27 14:54:30 +00:00
uint8_t org; /**< Transaction' originator.
2017-03-26 15:48:33 +00:00
local or remote */
2017-03-30 00:06:56 +00:00
2019-04-27 14:54:30 +00:00
uint32_t xid; /**< Transaction ID */
2019-09-13 12:07:47 +00:00
ogs_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 {
2019-04-27 14:54:30 +00:00
uint8_t type; /**< Message type history */
ogs_pkbuf_t *pkbuf; /**< Packet history */
2017-08-31 11:48:15 +00:00
} seq[3]; /**< history for the each step */
2017-03-30 00:20:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_timer_t *tm_response; /**< Timer waiting for next message */
uint8_t response_rcount;
ogs_timer_t *tm_holding; /**< Timer waiting for holding message */
uint8_t holding_rcount;
2017-03-26 15:48:33 +00:00
2019-09-13 12:07:47 +00:00
struct ogs_gtp_xact_s *assoc_xact; /**< Associated transaction */
2017-09-01 12:35:45 +00:00
2019-09-13 12:07:47 +00:00
#define OGS_GTP_XACT_STORE_SESSION(xact, session) \
2017-09-01 12:35:45 +00:00
do { \
2019-04-27 14:54:30 +00:00
ogs_assert((xact)); \
ogs_assert((session)); \
2017-09-01 12:35:45 +00:00
((xact)->sess) = (session); \
} while(0)
2019-09-13 12:07:47 +00:00
#define OGS_GTP_XACT_RETRIEVE_SESSION(xact) ((xact) ? ((xact)->sess) : NULL)
2017-09-01 12:35:45 +00:00
void *sess; /**< Session Store */
2019-09-13 12:07:47 +00:00
} ogs_gtp_xact_t;
2017-03-26 15:48:33 +00:00
2019-09-13 12:07:47 +00:00
int ogs_gtp_xact_init(ogs_timer_mgr_t *timer_mgr, int size);
int ogs_gtp_xact_final(void);
2017-03-26 15:48:33 +00:00
2019-09-13 12:07:47 +00:00
ogs_gtp_xact_t *ogs_gtp_xact_local_create(
ogs_gtp_node_t *gnode, ogs_gtp_header_t *hdesc, ogs_pkbuf_t *pkbuf);
ogs_gtp_xact_t *ogs_gtp_xact_remote_create(
ogs_gtp_node_t *gnode, uint32_t sqn);
void ogs_gtp_xact_delete_all(ogs_gtp_node_t *gnode);
2017-03-26 15:48:33 +00:00
2019-09-13 12:07:47 +00:00
int ogs_gtp_xact_update_tx(ogs_gtp_xact_t *xact,
ogs_gtp_header_t *hdesc, ogs_pkbuf_t *pkbuf);
int ogs_gtp_xact_update_rx(ogs_gtp_xact_t *xact, uint8_t type);
2017-08-31 05:03:00 +00:00
2019-09-13 12:07:47 +00:00
int ogs_gtp_xact_commit(ogs_gtp_xact_t *xact);
2017-03-26 15:48:33 +00:00
2019-09-13 12:07:47 +00:00
int ogs_gtp_xact_receive(ogs_gtp_node_t *gnode,
ogs_gtp_header_t *h, ogs_gtp_xact_t **xact);
2017-03-26 15:48:33 +00:00
2019-09-13 12:07:47 +00:00
ogs_gtp_xact_t *ogs_gtp_xact_find(ogs_index_t index);
ogs_gtp_xact_t *ogs_gtp_xact_find_by_xid(
ogs_gtp_node_t *gnode, uint8_t type, uint32_t xid);
void ogs_gtp_xact_associate(ogs_gtp_xact_t *xact1, ogs_gtp_xact_t *xact2);
void ogs_gtp_xact_deassociate(ogs_gtp_xact_t *xact1, ogs_gtp_xact_t *xact2);
2017-03-26 15:48:33 +00:00
#ifdef __cplusplus
}
2019-06-11 09:28:25 +00:00
#endif
2017-03-26 15:48:33 +00:00
2019-09-13 12:07:47 +00:00
#endif /* OGS_GTP_XACT_H */