mirror of
https://github.com/open5gs/open5gs.git
synced 2025-10-23 07:41:57 +00:00
A friend in the community was trying to connect an SMF made by another manufacturer with an SBI interface and found a big problem with Open5GS. All of the code in the part that generates the Resource URI from HTTP.location is invalid. For example, suppose we create a Resource URI with SMContext as below. {apiRoot}/nsmf-pdusession/<apiVersion>/sm-contexts/{smContextRef} In this case, Open5GS extracted the {smContextRef} part of the HTTP.location and appended it to the beginning {apiRoot}/nsmf-pdusession/<apiVersion>/sm-contexts/. This implementation may not work properly if the apiRoot changes. Consider a different port number as shown below. <HTTP.location> 127.0.0.4:9999/nsmf-pdusession/v1/sm-contexts/1 The SMF may send an apiRoot to the AMF with a changed port number, in which case the AMF must honor it. Therefore, instead of extracting only the smContextRef from HTTP.location, we modified it to use the whole thing to create a Resource URI. We modified all NFs that use HTTP.location in the same way, not just SMFs.
135 lines
3.6 KiB
C
135 lines
3.6 KiB
C
/*
|
|
* Copyright (C) 2019-2023 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 AF_CONTEXT_H
|
|
#define AF_CONTEXT_H
|
|
|
|
#include "ogs-sbi.h"
|
|
#include "ogs-app.h"
|
|
|
|
#include "event.h"
|
|
#include "local.h"
|
|
#include "af-sm.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
extern int __af_log_domain;
|
|
|
|
#undef OGS_LOG_DOMAIN
|
|
#define OGS_LOG_DOMAIN __af_log_domain
|
|
|
|
typedef struct af_context_s {
|
|
ogs_hash_t *supi_hash; /* hash table (SUPI) */
|
|
ogs_hash_t *ipv4_hash; /* hash table (IPv4 Address) */
|
|
ogs_hash_t *ipv6_hash; /* hash table (IPv6 Address) */
|
|
ogs_hash_t *pcf_app_session_id_hash; /* hash table (AppSessionId) */
|
|
|
|
ogs_list_t sess_list;
|
|
} af_context_t;
|
|
|
|
typedef struct af_sess_s af_sess_t;
|
|
|
|
typedef struct af_sess_s {
|
|
ogs_sbi_object_t sbi;
|
|
|
|
uint64_t policyauthorization_features;
|
|
|
|
#define PCF_APP_SESSION_ASSOCIATED(__sESS) \
|
|
((__sESS) && ((__sESS)->app_session.pcf_id))
|
|
#define PCF_APP_SESSION_CLEAR(__sESS) \
|
|
do { \
|
|
ogs_assert((__sESS)); \
|
|
if ((__sESS)->app_session.pcf.resource_uri) \
|
|
ogs_free((__sESS)->app_session.pcf.resource_uri); \
|
|
(__sESS)->app_session.pcf.resource_uri = NULL; \
|
|
if ((__sESS)->app_session.pcf.id) \
|
|
ogs_free((__sESS)->app_session.pcf.id); \
|
|
(__sESS)->app_session.pcf.id = NULL; \
|
|
} while(0)
|
|
#define PCF_APP_SESSION_STORE(__sESS, __rESOURCE_URI, __iD) \
|
|
do { \
|
|
ogs_assert((__sESS)); \
|
|
ogs_assert((__rESOURCE_URI)); \
|
|
ogs_assert((__iD)); \
|
|
PCF_APP_SESSION_CLEAR(__sESS); \
|
|
(__sESS)->app_session.pcf.resource_uri = ogs_strdup(__rESOURCE_URI); \
|
|
ogs_assert((__sESS)->app_session.pcf.resource_uri); \
|
|
(__sESS)->app_session.pcf.id = ogs_strdup(__iD); \
|
|
ogs_assert((__sESS)->app_session.pcf.id); \
|
|
} while(0)
|
|
struct {
|
|
struct {
|
|
char *id;
|
|
} af;
|
|
struct {
|
|
char *resource_uri;
|
|
char *id;
|
|
ogs_sbi_client_t *client;
|
|
} pcf;
|
|
} app_session;
|
|
|
|
char *ipv4addr;
|
|
char *ipv6addr;
|
|
char *ipv6prefix;
|
|
|
|
char *supi;
|
|
char *gpsi;
|
|
|
|
ogs_s_nssai_t s_nssai;
|
|
char *dnn;
|
|
|
|
struct {
|
|
char *fqdn;
|
|
|
|
int num_of_ip;
|
|
struct {
|
|
ogs_sockaddr_t *addr;
|
|
ogs_sockaddr_t *addr6;
|
|
bool is_port;
|
|
int port;
|
|
} ip[OGS_SBI_MAX_NUM_OF_IP_ADDRESS];
|
|
|
|
ogs_sbi_client_t *client;
|
|
} pcf;
|
|
|
|
} af_sess_t;
|
|
|
|
void af_context_init(void);
|
|
void af_context_final(void);
|
|
af_context_t *af_self(void);
|
|
|
|
int af_context_parse_config(void);
|
|
|
|
af_sess_t *af_sess_add_by_ue_address(ogs_ip_t *ue_address);
|
|
void af_sess_remove(af_sess_t *sess);
|
|
void af_sess_remove_all(void);
|
|
|
|
af_sess_t *af_sess_find(uint32_t index);
|
|
af_sess_t *af_sess_find_by_af_app_session_id(char *af_app_session_id);
|
|
|
|
void af_sess_associate_pcf_client(af_sess_t *sess);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* AF_CONTEXT_H */
|