open5gs/src/smf/event.h

133 lines
3.3 KiB
C
Raw Normal View History

2020-04-26 19:36:05 +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/>.
*/
#ifndef SMF_EVENT_H
#define SMF_EVENT_H
#include "ogs-core.h"
#include "ogs-gtp.h"
2020-04-26 19:36:05 +00:00
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ogs_gtp_node_s ogs_gtp_node_t;
typedef struct ogs_gtp_xact_s ogs_gtp_xact_t;
typedef struct ogs_pfcp_node_s ogs_pfcp_node_t;
typedef struct ogs_pfcp_xact_s ogs_pfcp_xact_t;
typedef struct ogs_pfcp_message_s ogs_pfcp_message_t;
typedef struct ogs_diam_gx_message_s ogs_diam_gx_message_t;
typedef struct ogs_diam_gy_message_s ogs_diam_gy_message_t;
typedef struct ogs_diam_s6b_message_s ogs_diam_s6b_message_t;
2020-04-26 19:36:05 +00:00
typedef struct smf_sess_s smf_sess_t;
typedef struct smf_upf_s smf_upf_t;
2020-05-18 21:00:37 +00:00
typedef struct ogs_sbi_request_s ogs_sbi_request_t;
typedef struct ogs_sbi_response_s ogs_sbi_response_t;
typedef struct ogs_sbi_message_s ogs_sbi_message_t;
typedef struct ogs_sbi_subscription_s ogs_sbi_subscription_t;
2020-06-17 05:22:28 +00:00
typedef struct ogs_nas_5gs_message_s ogs_nas_5gs_message_t;
typedef struct NGAP_NGAP_PDU ogs_ngap_message_t;
typedef long NGAP_ProcedureCode_t;
2020-04-26 19:36:05 +00:00
typedef enum {
SMF_EVT_BASE = OGS_FSM_USER_SIG,
SMF_EVT_S5C_MESSAGE,
SMF_EVT_S6B_MESSAGE,
Introduce Gn interface (GTPv1C) Support to PGW (#1351) * [CORE] tlv: Store mode in ogs_tlv_t This allows specifying the format of the IE for each individual IE, hence allowing messages containing IEs formatted in different ways. This is needed in order to support parsing GTPv1-C, since messages contain IEs with different structure (TLV vs TV). Hence, this is a preparation patch to add support for parsing TVs in ogs-tlv.c/.h. * [CORE] tlv: Support parsing msg with both TLV and TV in it IEs of type TV are sometimes used in GTPv1-C. Current tlv parser/builder doesn't provide with ways to parse messages which contain TV formatted IEs. This patch adds the relevant types and ways to encode/decode them. Furthermore, the current parser/builder allows parsing/building messages containing the exact same format in all its IEs. A new parser function is added which allows parsing messages of different types (TV, TLV) mixed in the same message. In order to be able to do so, it uses the general msg_mode passed to it in order to know the general TLV format (in essence, the length of the Tag field, and also the length of the Length field if applicable each IE). Looking up the instance in the TLV description is left undone and hadcoded to 0, since the only user so far requiring this API is GTPv1-C, which has no instances. * [CORE] tlv: Support repeated tag+instance parsing TLV message In GTPv2C, repeated IEs (same tag) are easily differentiated by the Instance byte, which provides info to match different decoded structures. In GTPv1C though, there's no Instance byte, and we still encounter repeated IEs (like GSN Address in Create PDP Context Request). Hence, the TLV decoder needs to be updated to track count of IEs found (identified by tag+instance, where instance is always 0 in GTPv1C) and get the proper description index + offset into the decoded structure. * [GTP]: Move GTPv2-C specifics to its own libgtp subdir This will allow adding GTPv1-C code by the side. Most GTPv2 code is left in this patch as "gtp" instead of renaming it to "gtp2" in order to avoid massive changes. It can be done at a later stage if wanted. * [GTP] Support generating GTPv1-C messages * [SMF] Add Gn interface support This patch introduces GTPv1C support to open5gs-smfd. With it, open5gs-becomes a GGSN too, where SGSN can connect to, hence supporting GERAN and UTRAN networks.
2022-02-18 13:23:45 +00:00
SMF_EVT_GN_MESSAGE,
2020-04-26 19:36:05 +00:00
SMF_EVT_GX_MESSAGE,
SMF_EVT_GY_MESSAGE,
2020-04-26 19:36:05 +00:00
SMF_EVT_N4_MESSAGE,
SMF_EVT_N4_TIMER,
SMF_EVT_N4_NO_HEARTBEAT,
2020-05-18 21:00:37 +00:00
SMF_EVT_SBI_SERVER,
SMF_EVT_SBI_CLIENT,
SMF_EVT_SBI_TIMER,
2020-06-17 05:22:28 +00:00
SMF_EVT_NGAP_MESSAGE,
SMF_EVT_NGAP_TIMER,
SMF_EVT_5GSM_MESSAGE,
SMF_EVT_5GSM_TIMER,
2020-04-26 19:36:05 +00:00
SMF_EVT_TOP,
} smf_event_e;
typedef struct smf_event_s {
int id;
ogs_pkbuf_t *pkbuf;
int timer_id;
ogs_gtp_node_t *gnode;
ogs_gtp_xact_t *gtp_xact;
ogs_pfcp_node_t *pfcp_node;
ogs_pfcp_xact_t *pfcp_xact;
ogs_pfcp_message_t *pfcp_message;
union {
ogs_gtp1_message_t *gtp1_message;
ogs_gtp2_message_t *gtp2_message;
};
union {
ogs_diam_gx_message_t *gx_message;
ogs_diam_gy_message_t *gy_message;
ogs_diam_s6b_message_t *s6b_message;
};
2020-05-18 21:00:37 +00:00
struct {
ogs_sbi_request_t *request;
ogs_sbi_response_t *response;
void *data;
2021-01-01 02:07:08 +00:00
int state;
2020-05-18 21:00:37 +00:00
ogs_sbi_message_t *message;
} sbi;
2020-06-17 05:22:28 +00:00
struct {
int type;
ogs_ngap_message_t *message;
} ngap;
struct {
uint8_t type;
ogs_nas_5gs_message_t *message;
} nas;
2020-04-26 19:36:05 +00:00
smf_sess_t *sess;
} smf_event_t;
void smf_event_init(void);
void smf_event_final(void);
smf_event_t *smf_event_new(smf_event_e id);
void smf_event_free(smf_event_t *e);
const char *smf_event_get_name(smf_event_t *e);
#ifdef __cplusplus
}
#endif
#endif /* SMF_EVENT_H */