Before CUPS, move GTP-TLV to core library

TLV library will be shared in GTP and PFCP
This commit is contained in:
Sukchan Lee 2019-12-01 20:46:53 +09:00
parent ed701ce90e
commit ce6d2c5889
17 changed files with 1919 additions and 1918 deletions

View File

@ -248,6 +248,7 @@ libcore_sources = files('''
ogs-poll.h
ogs-notify.h
ogs-tlv.h
ogs-tlv-msg.h
ogs-env.h
ogs-fsm.h
ogs-hash.h
@ -281,6 +282,7 @@ libcore_sources = files('''
ogs-poll.c
ogs-notify.c
ogs-tlv.c
ogs-tlv-msg.c
ogs-env.c
ogs-fsm.c
ogs-hash.c

View File

@ -52,6 +52,7 @@
#include "core/ogs-poll.h"
#include "core/ogs-notify.h"
#include "core/ogs-tlv.h"
#include "core/ogs-tlv-msg.h"
#include "core/ogs-env.h"
#include "core/ogs-fsm.h"
#include "core/ogs-hash.h"

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "ogs-gtp.h"
#include "ogs-core.h"
ogs_tlv_desc_t ogs_tlv_desc_more1 = {
OGS_TLV_MORE, "More", 0, 1, 0, 0, { NULL } };

View File

@ -17,16 +17,16 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#if !defined(OGS_GTP_INSIDE) && !defined(OGS_GTP_COMPILATION)
#if !defined(OGS_CORE_INSIDE) && !defined(OGS_CORE_COMPILATION)
#error "This header cannot be included directly."
#endif
#ifndef OGS_GTP_TLV_H
#define OGS_GTP_TLV_H
#ifndef OGS_TLV_MSG_H
#define OGS_TLV_MSG_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif
#define OGS_TLV_MAX_HEADROOM 16
#define OGS_TLV_VARIABLE_LEN 0

View File

@ -24,6 +24,10 @@
#ifndef OGS_TLV_H
#define OGS_TLV_H
#ifdef __cplusplus
extern "C" {
#endif
#define OGS_TLV_MODE_T1_L1 1
#define OGS_TLV_MODE_T1_L2 2
#define OGS_TLV_MODE_T1_L2_I1 3

View File

@ -20,7 +20,7 @@
#include "ogs-gtp.h"
void ogs_gtp_bearers_in_create_indirect_tunnel_request(
ogs_tlv_bearer_context_t *bearers[][GTP_MAX_NUM_OF_INDIRECT_TUNNEL],
ogs_gtp_tlv_bearer_context_t *bearers[][GTP_MAX_NUM_OF_INDIRECT_TUNNEL],
ogs_gtp_create_indirect_data_forwarding_tunnel_request_t *req)
{
@ -38,7 +38,7 @@ void ogs_gtp_bearers_in_create_indirect_tunnel_request(
}
void ogs_gtp_bearers_in_create_indirect_tunnel_response(
ogs_tlv_bearer_context_t *bearers[][GTP_MAX_NUM_OF_INDIRECT_TUNNEL],
ogs_gtp_tlv_bearer_context_t *bearers[][GTP_MAX_NUM_OF_INDIRECT_TUNNEL],
ogs_gtp_create_indirect_data_forwarding_tunnel_response_t *rsp)
{
(*bearers)[0] = &rsp->bearer_context_0;

View File

@ -32,10 +32,10 @@ extern "C" {
/* Create Indirect Data Forwarding Tunnel Request/Response */
void ogs_gtp_bearers_in_create_indirect_tunnel_request(
ogs_tlv_bearer_context_t *bearers[][GTP_MAX_NUM_OF_INDIRECT_TUNNEL],
ogs_gtp_tlv_bearer_context_t *bearers[][GTP_MAX_NUM_OF_INDIRECT_TUNNEL],
ogs_gtp_create_indirect_data_forwarding_tunnel_request_t *req);
void ogs_gtp_bearers_in_create_indirect_tunnel_response(
ogs_tlv_bearer_context_t *bearers[][GTP_MAX_NUM_OF_INDIRECT_TUNNEL],
ogs_gtp_tlv_bearer_context_t *bearers[][GTP_MAX_NUM_OF_INDIRECT_TUNNEL],
ogs_gtp_create_indirect_data_forwarding_tunnel_response_t *rsp);
int ogs_gtp_f_teid_to_sockaddr(

View File

@ -18,7 +18,6 @@
libgtp_sources = files('''
ogs-gtp.h
tlv.h
message.h
types.h
conv.h
@ -26,7 +25,6 @@ libgtp_sources = files('''
path.h
xact.h
tlv.c
message.c
types.c
conv.c

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -194,7 +194,7 @@ void ogs_gtp_send_error_message(
int rv;
ogs_gtp_message_t errmsg;
ogs_gtp_cause_t cause;
ogs_tlv_cause_t *tlv = NULL;
ogs_gtp_tlv_cause_t *tlv = NULL;
ogs_pkbuf_t *pkbuf = NULL;
memset(&errmsg, 0, sizeof(ogs_gtp_message_t));

View File

@ -379,8 +379,6 @@ f.write("""#if !defined(OGS_GTP_INSIDE) && !defined(OGS_GTP_COMPILATION)
#ifndef OGS_GTP_MESSAGE_H
#define OGS_GTP_MESSAGE_H
#include "gtp/tlv.h"
#ifdef __cplusplus
extern "C" {
#endif
@ -445,7 +443,7 @@ for (k, v) in sorted_type_list:
if k in group_list.keys():
continue
for instance in range(0, int(type_list[k]["max_instance"])+1):
f.write("extern ogs_tlv_desc_t ogs_tlv_desc_" + v_lower(k))
f.write("extern ogs_tlv_desc_t ogs_gtp_tlv_desc_" + v_lower(k))
f.write("_" + str(instance) + ";\n")
f.write("\n")
@ -455,13 +453,13 @@ sorted_group_list = sorted(tmp, key=lambda tup: int(tup[1]))
f.write("/* Group Infomration Element TLV Descriptor */\n")
for (k, v) in sorted_group_list:
for instance in range(0, int(type_list[k]["max_instance"])+1):
f.write("extern ogs_tlv_desc_t ogs_tlv_desc_" + v_lower(k))
f.write("extern ogs_tlv_desc_t ogs_gtp_tlv_desc_" + v_lower(k))
f.write("_" + str(instance) + ";\n")
f.write("\n")
f.write("/* Message Descriptor */\n")
for (k, v) in sorted_msg_list:
f.write("extern ogs_tlv_desc_t ogs_tlv_desc_" + v_lower(k) + ";\n")
f.write("extern ogs_tlv_desc_t ogs_gtp_tlv_desc_" + v_lower(k) + ";\n")
f.write("\n")
f.write("/* Structure for Infomration Element */\n")
@ -470,25 +468,25 @@ for (k, v) in sorted_type_list:
continue
if "size" in type_list[k]:
if type_list[k]["size"] == 1:
f.write("typedef ogs_tlv_uint8_t ogs_tlv_" + v_lower(k) + "_t;\n")
f.write("typedef ogs_tlv_uint8_t ogs_gtp_tlv_" + v_lower(k) + "_t;\n")
elif type_list[k]["size"] == 2:
f.write("typedef ogs_tlv_uint16_t ogs_tlv_" + v_lower(k) + "_t;\n")
f.write("typedef ogs_tlv_uint16_t ogs_gtp_tlv_" + v_lower(k) + "_t;\n")
elif type_list[k]["size"] == 3:
f.write("typedef ogs_tlv_uint24_t ogs_tlv_" + v_lower(k) + "_t;\n")
f.write("typedef ogs_tlv_uint24_t ogs_gtp_tlv_" + v_lower(k) + "_t;\n")
elif type_list[k]["size"] == 4:
f.write("typedef ogs_tlv_uint32_t ogs_tlv_" + v_lower(k) + "_t;\n")
f.write("typedef ogs_tlv_uint32_t ogs_gtp_tlv_" + v_lower(k) + "_t;\n")
else:
assert False, "Unknown size = %d for key = %s" % (type_list[k]["size"], k)
else:
f.write("typedef ogs_tlv_octet_t ogs_tlv_" + v_lower(k) + "_t;\n")
f.write("typedef ogs_tlv_octet_t ogs_gtp_tlv_" + v_lower(k) + "_t;\n")
f.write("\n")
f.write("/* Structure for Group Infomration Element */\n")
for (k, v) in sorted_group_list:
f.write("typedef struct ogs_tlv_" + v_lower(k) + "_s {\n")
f.write("typedef struct ogs_gtp_tlv_" + v_lower(k) + "_s {\n")
f.write(" ogs_tlv_presence_t presence;\n")
for ies in group_list[k]["ies"]:
f.write(" ogs_tlv_" + v_lower(ies["ie_type"]) + "_t " + \
f.write(" ogs_gtp_tlv_" + v_lower(ies["ie_type"]) + "_t " + \
v_lower(ies["ie_value"]))
if ies["ie_type"] == "F-TEID":
if ies["ie_value"] == "S2b-U ePDG F-TEID":
@ -500,7 +498,7 @@ for (k, v) in sorted_group_list:
f.write(" /* Instance : " + ies["instance"] + " */\n")
else:
f.write(";\n")
f.write("} ogs_tlv_" + v_lower(k) + "_t;\n")
f.write("} ogs_gtp_tlv_" + v_lower(k) + "_t;\n")
f.write("\n")
f.write("/* Structure for Message */\n")
@ -508,7 +506,7 @@ for (k, v) in sorted_msg_list:
if "ies" in msg_list[k]:
f.write("typedef struct ogs_gtp_" + v_lower(k) + "_s {\n")
for ies in msg_list[k]["ies"]:
f.write(" ogs_tlv_" + v_lower(ies["ie_type"]) + "_t " + \
f.write(" ogs_gtp_tlv_" + v_lower(ies["ie_type"]) + "_t " + \
v_lower(ies["ie_value"]) + ";\n")
f.write("} ogs_gtp_" + v_lower(k) + "_t;\n")
f.write("\n")
@ -543,7 +541,7 @@ for (k, v) in sorted_type_list:
if k in group_list.keys():
continue
for instance in range(0, int(type_list[k]["max_instance"])+1):
f.write("ogs_tlv_desc_t ogs_tlv_desc_%s_%d =\n" % (v_lower(k), instance))
f.write("ogs_tlv_desc_t ogs_gtp_tlv_desc_%s_%d =\n" % (v_lower(k), instance))
f.write("{\n")
if "size" in type_list[k]:
if type_list[k]["size"] == 1:
@ -565,36 +563,36 @@ for (k, v) in sorted_type_list:
else:
f.write(" 0,\n")
f.write(" %d,\n" % instance)
f.write(" sizeof(ogs_tlv_%s_t),\n" % v_lower(k))
f.write(" sizeof(ogs_gtp_tlv_%s_t),\n" % v_lower(k))
f.write(" { NULL }\n")
f.write("};\n\n")
for (k, v) in sorted_group_list:
for instance in range(0, int(type_list[k]["max_instance"])+1):
f.write("ogs_tlv_desc_t ogs_tlv_desc_%s_%d =\n" % (v_lower(k), instance))
f.write("ogs_tlv_desc_t ogs_gtp_tlv_desc_%s_%d =\n" % (v_lower(k), instance))
f.write("{\n")
f.write(" OGS_TLV_COMPOUND,\n")
f.write(" \"%s\",\n" % k)
f.write(" OGS_TLV_%s_TYPE,\n" % v_upper(k))
f.write(" 0,\n")
f.write(" %d,\n" % instance)
f.write(" sizeof(ogs_tlv_%s_t),\n" % v_lower(k))
f.write(" sizeof(ogs_gtp_tlv_%s_t),\n" % v_lower(k))
f.write(" {\n")
for ies in group_list[k]["ies"]:
f.write(" &ogs_tlv_desc_%s_%s,\n" % (v_lower(ies["ie_type"]), v_lower(ies["instance"])))
f.write(" &ogs_gtp_tlv_desc_%s_%s,\n" % (v_lower(ies["ie_type"]), v_lower(ies["instance"])))
f.write(" NULL,\n")
f.write(" }\n")
f.write("};\n\n")
for (k, v) in sorted_msg_list:
if "ies" in msg_list[k]:
f.write("ogs_tlv_desc_t ogs_tlv_desc_%s =\n" % v_lower(k))
f.write("ogs_tlv_desc_t ogs_gtp_tlv_desc_%s =\n" % v_lower(k))
f.write("{\n")
f.write(" OGS_TLV_MESSAGE,\n")
f.write(" \"%s\",\n" % k)
f.write(" 0, 0, 0, 0, {\n")
for ies in msg_list[k]["ies"]:
f.write(" &ogs_tlv_desc_%s_%s,\n" % (v_lower(ies["ie_type"]), v_lower(ies["instance"])))
f.write(" &ogs_gtp_tlv_desc_%s_%s,\n" % (v_lower(ies["ie_type"]), v_lower(ies["instance"])))
f.write(" NULL,\n")
f.write("}};\n\n")
f.write("\n")
@ -634,7 +632,7 @@ for (k, v) in sorted_msg_list:
if "ies" in msg_list[k]:
f.write(" case OGS_GTP_%s_TYPE:\n" % v_upper(k))
f.write(" rv = ogs_tlv_parse_msg(&gtp_message->%s,\n" % v_lower(k))
f.write(" &ogs_tlv_desc_%s, pkbuf, OGS_TLV_MODE_T1_L2_I1);\n" % v_lower(k))
f.write(" &ogs_gtp_tlv_desc_%s, pkbuf, OGS_TLV_MODE_T1_L2_I1);\n" % v_lower(k))
f.write(" break;\n")
f.write(""" default:
ogs_warn("Not implmeneted(type:%d)", gtp_message->h.type);
@ -656,7 +654,7 @@ f.write("""ogs_pkbuf_t *ogs_gtp_build_msg(ogs_gtp_message_t *gtp_message)
for (k, v) in sorted_msg_list:
if "ies" in msg_list[k]:
f.write(" case OGS_GTP_%s_TYPE:\n" % v_upper(k))
f.write(" pkbuf = ogs_tlv_build_msg(&ogs_tlv_desc_%s,\n" % v_lower(k))
f.write(" pkbuf = ogs_tlv_build_msg(&ogs_gtp_tlv_desc_%s,\n" % v_lower(k))
f.write(" &gtp_message->%s, OGS_TLV_MODE_T1_L2_I1);\n" % v_lower(k))
f.write(" break;\n")
f.write(""" default:

View File

@ -665,7 +665,7 @@ ogs_pkbuf_t *mme_s11_build_create_indirect_data_forwarding_tunnel_request(
ogs_gtp_create_indirect_data_forwarding_tunnel_request_t *req =
&gtp_message.create_indirect_data_forwarding_tunnel_request;
ogs_tlv_bearer_context_t *bearers[GTP_MAX_NUM_OF_INDIRECT_TUNNEL];
ogs_gtp_tlv_bearer_context_t *bearers[GTP_MAX_NUM_OF_INDIRECT_TUNNEL];
ogs_gtp_f_teid_t dl_teid[GTP_MAX_NUM_OF_INDIRECT_TUNNEL];
ogs_gtp_f_teid_t ul_teid[GTP_MAX_NUM_OF_INDIRECT_TUNNEL];
int len;

View File

@ -680,7 +680,7 @@ void mme_s11_handle_create_indirect_data_forwarding_tunnel_response(
enb_ue_t *source_ue = NULL;
int i;
ogs_tlv_bearer_context_t *bearers[GTP_MAX_NUM_OF_INDIRECT_TUNNEL];
ogs_gtp_tlv_bearer_context_t *bearers[GTP_MAX_NUM_OF_INDIRECT_TUNNEL];
ogs_gtp_f_teid_t *teid = NULL;
ogs_assert(xact);

View File

@ -22,7 +22,7 @@
#include "ipfw/ipfw2.h"
static int16_t pgw_pco_build(uint8_t *pco_buf, ogs_tlv_pco_t *tlv_pco);
static int16_t pgw_pco_build(uint8_t *pco_buf, ogs_gtp_tlv_pco_t *tlv_pco);
ogs_pkbuf_t *pgw_s5c_build_create_session_response(
uint8_t type, pgw_sess_t *sess,
@ -455,7 +455,7 @@ ogs_pkbuf_t *pgw_s5c_build_delete_bearer_request(
return ogs_gtp_build_msg(&gtp_message);
}
static int16_t pgw_pco_build(uint8_t *pco_buf, ogs_tlv_pco_t *tlv_pco)
static int16_t pgw_pco_build(uint8_t *pco_buf, ogs_gtp_tlv_pco_t *tlv_pco)
{
int rv;
ogs_pco_t ue, pgw;

View File

@ -974,8 +974,8 @@ void sgw_s11_handle_create_indirect_data_forwarding_tunnel_request(
sgw_tunnel_t *tunnel = NULL;
ogs_gtp_cause_t cause;
ogs_tlv_bearer_context_t *req_bearers[GTP_MAX_NUM_OF_INDIRECT_TUNNEL];
ogs_tlv_bearer_context_t *rsp_bearers[GTP_MAX_NUM_OF_INDIRECT_TUNNEL];
ogs_gtp_tlv_bearer_context_t *req_bearers[GTP_MAX_NUM_OF_INDIRECT_TUNNEL];
ogs_gtp_tlv_bearer_context_t *rsp_bearers[GTP_MAX_NUM_OF_INDIRECT_TUNNEL];
ogs_gtp_f_teid_t *req_teid = NULL;
ogs_gtp_f_teid_t rsp_dl_teid[GTP_MAX_NUM_OF_INDIRECT_TUNNEL];
ogs_gtp_f_teid_t rsp_ul_teid[GTP_MAX_NUM_OF_INDIRECT_TUNNEL];

View File

@ -178,16 +178,16 @@ static void gtp_message_test1(abts_case *tc, void *data)
req.charging_characteristics.data = (uint8_t *)"\x54\x00";
req.charging_characteristics.len = 2;
pkbuf = ogs_tlv_build_msg(&ogs_tlv_desc_create_session_request, &req,
OGS_TLV_MODE_T1_L2_I1);
pkbuf = ogs_tlv_build_msg(&ogs_gtp_tlv_desc_create_session_request,
&req, OGS_TLV_MODE_T1_L2_I1);
ABTS_PTR_NOTNULL(tc, pkbuf);
ABTS_TRUE(tc, memcmp(pkbuf->data,
OGS_HEX(_payload, strlen(_payload), hexbuf), pkbuf->len) == 0);
memset(&req, 0, sizeof(req));
rv = ogs_tlv_parse_msg(&req, &ogs_tlv_desc_create_session_request, pkbuf,
OGS_TLV_MODE_T1_L2_I1);
rv = ogs_tlv_parse_msg(&req, &ogs_gtp_tlv_desc_create_session_request,
pkbuf, OGS_TLV_MODE_T1_L2_I1);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
ogs_pkbuf_free(pkbuf);