Projects
osmocom:nightly
open5gs
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 47
View file
open5gs_2.4.9.14.ec9fe.202208120002.dsc
Deleted
@@ -1,37 +0,0 @@ -Format: 3.0 (native) -Source: open5gs -Binary: open5gs-common, open5gs-mme, open5gs-sgwc, open5gs-smf, open5gs-amf, open5gs-sgwu, open5gs-upf, open5gs-hss, open5gs-pcrf, open5gs-nrf, open5gs-ausf, open5gs-udm, open5gs-pcf, open5gs-nssf, open5gs-bsf, open5gs-udr, open5gs, open5gs-dbg -Architecture: any -Version: 2.4.9.14.ec9fe.202208120002 -Maintainer: Harald Welte <laforge@gnumonks.org> -Uploaders: Sukchan Lee <acetcom@gmail.com> -Homepage: https://open5gs.org -Standards-Version: 4.3.0 -Vcs-Browser: https://github.com/open5gs/open5gs -Vcs-Git: git://github.com/open5gs/open5gs -Build-Depends: debhelper (>= 11), git, pkg-config, meson (>= 0.43.0), flex, bison, libgnutls28-dev, libgcrypt-dev, libssl-dev, libidn11-dev, libmongoc-dev, libbson-dev, libsctp-dev, libyaml-dev, libmicrohttpd-dev, libcurl4-gnutls-dev, libnghttp2-dev, libtins-dev, libtalloc-dev -Package-List: - open5gs deb net optional arch=any - open5gs-amf deb net optional arch=any - open5gs-ausf deb net optional arch=any - open5gs-bsf deb net optional arch=any - open5gs-common deb net optional arch=any - open5gs-dbg deb net optional arch=any - open5gs-hss deb net optional arch=any - open5gs-mme deb net optional arch=any - open5gs-nrf deb net optional arch=any - open5gs-nssf deb net optional arch=any - open5gs-pcf deb net optional arch=any - open5gs-pcrf deb net optional arch=any - open5gs-sgwc deb net optional arch=any - open5gs-sgwu deb net optional arch=any - open5gs-smf deb net optional arch=any - open5gs-udm deb net optional arch=any - open5gs-udr deb net optional arch=any - open5gs-upf deb net optional arch=any -Checksums-Sha1: - ae264f05ad536316baeea8d1aac5c0071e760708 11460128 open5gs_2.4.9.14.ec9fe.202208120002.tar.xz -Checksums-Sha256: - 459d8fb11d0d29108b0ca448ab5bf0c9c9f6f112a4dae895564966fea7faf2aa 11460128 open5gs_2.4.9.14.ec9fe.202208120002.tar.xz -Files: - ec5eceee7ff503b1186c0528efca26fd 11460128 open5gs_2.4.9.14.ec9fe.202208120002.tar.xz
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/core/ogs-3gpp-types.c
Deleted
@@ -1,1012 +0,0 @@ -/* - * 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/>. - */ - -#include "ogs-core.h" - -#define PLMN_ID_DIGIT1(x) (((x) / 100) % 10) -#define PLMN_ID_DIGIT2(x) (((x) / 10) % 10) -#define PLMN_ID_DIGIT3(x) ((x) % 10) - -uint32_t ogs_plmn_id_hexdump(void *plmn_id) -{ - uint32_t hex; - ogs_assert(plmn_id); - memcpy(&hex, plmn_id, sizeof(ogs_plmn_id_t)); - hex = be32toh(hex) >> 8; - return hex; -} - -uint16_t ogs_plmn_id_mcc(ogs_plmn_id_t *plmn_id) -{ - return plmn_id->mcc1 * 100 + plmn_id->mcc2 * 10 + plmn_id->mcc3; -} -uint16_t ogs_plmn_id_mnc(ogs_plmn_id_t *plmn_id) -{ - return plmn_id->mnc1 == 0xf ? plmn_id->mnc2 * 10 + plmn_id->mnc3 : - plmn_id->mnc1 * 100 + plmn_id->mnc2 * 10 + plmn_id->mnc3; -} -uint16_t ogs_plmn_id_mnc_len(ogs_plmn_id_t *plmn_id) -{ - return plmn_id->mnc1 == 0xf ? 2 : 3; -} - -void *ogs_plmn_id_build(ogs_plmn_id_t *plmn_id, - uint16_t mcc, uint16_t mnc, uint16_t mnc_len) -{ - plmn_id->mcc1 = PLMN_ID_DIGIT1(mcc); - plmn_id->mcc2 = PLMN_ID_DIGIT2(mcc); - plmn_id->mcc3 = PLMN_ID_DIGIT3(mcc); - - if (mnc_len == 2) - plmn_id->mnc1 = 0xf; - else - plmn_id->mnc1 = PLMN_ID_DIGIT1(mnc); - - plmn_id->mnc2 = PLMN_ID_DIGIT2(mnc); - plmn_id->mnc3 = PLMN_ID_DIGIT3(mnc); - - return plmn_id; -} - -void *ogs_nas_from_plmn_id( - ogs_nas_plmn_id_t *ogs_nas_plmn_id, ogs_plmn_id_t *plmn_id) -{ - memcpy(ogs_nas_plmn_id, plmn_id, OGS_PLMN_ID_LEN); - if (plmn_id->mnc1 != 0xf) { - ogs_nas_plmn_id->mnc1 = plmn_id->mnc1; - ogs_nas_plmn_id->mnc2 = plmn_id->mnc2; - ogs_nas_plmn_id->mnc3 = plmn_id->mnc3; - } - return ogs_nas_plmn_id; -} -void *ogs_nas_to_plmn_id( - ogs_plmn_id_t *plmn_id, ogs_nas_plmn_id_t *ogs_nas_plmn_id) -{ - memcpy(plmn_id, ogs_nas_plmn_id, OGS_PLMN_ID_LEN); - if (plmn_id->mnc1 != 0xf) { - plmn_id->mnc1 = ogs_nas_plmn_id->mnc1; - plmn_id->mnc2 = ogs_nas_plmn_id->mnc2; - plmn_id->mnc3 = ogs_nas_plmn_id->mnc3; - } - return plmn_id; -} - -char *ogs_serving_network_name_from_plmn_id(ogs_plmn_id_t *plmn_id) -{ - ogs_assert(plmn_id); - return ogs_msprintf("5G:mnc%03d.mcc%03d.3gppnetwork.org", - ogs_plmn_id_mnc(plmn_id), ogs_plmn_id_mcc(plmn_id)); -} - -char *ogs_plmn_id_mcc_string(ogs_plmn_id_t *plmn_id) -{ - ogs_assert(plmn_id); - return ogs_msprintf("%03d", ogs_plmn_id_mcc(plmn_id)); -} - -char *ogs_plmn_id_mnc_string(ogs_plmn_id_t *plmn_id) -{ - ogs_assert(plmn_id); - if (ogs_plmn_id_mnc_len(plmn_id) == 2) - return ogs_msprintf("%02d", ogs_plmn_id_mnc(plmn_id)); - else - return ogs_msprintf("%03d", ogs_plmn_id_mnc(plmn_id)); -} - -char *ogs_plmn_id_to_string(ogs_plmn_id_t *plmn_id, char *buf) -{ - ogs_assert(plmn_id); - ogs_assert(buf); - - if (ogs_plmn_id_mnc_len(plmn_id) == 2) - ogs_snprintf(buf, OGS_PLMNIDSTRLEN, "%03d%02d", - ogs_plmn_id_mcc(plmn_id), ogs_plmn_id_mnc(plmn_id)); - else - ogs_snprintf(buf, OGS_PLMNIDSTRLEN, "%03d%03d", - ogs_plmn_id_mcc(plmn_id), ogs_plmn_id_mnc(plmn_id)); - - return buf; -} - -uint32_t ogs_amf_id_hexdump(ogs_amf_id_t *amf_id) -{ - uint32_t hex; - - ogs_assert(amf_id); - - memcpy(&hex, amf_id, sizeof(ogs_amf_id_t)); - hex = be32toh(hex) >> 8; - - return hex; -} - -ogs_amf_id_t *ogs_amf_id_from_string(ogs_amf_id_t *amf_id, const char *hex) -{ - char hexbufsizeof(ogs_amf_id_t); - - ogs_assert(amf_id); - ogs_assert(hex); - - OGS_HEX(hex, strlen(hex), hexbuf); - - amf_id->region = hexbuf0; - amf_id->set1 = hexbuf1; - amf_id->set2 = (hexbuf2 & 0xc0) >> 6; - amf_id->pointer = hexbuf2 & 0x3f; - - return amf_id; -} - -#define OGS_AMFIDSTRLEN (sizeof(ogs_amf_id_t)*2+1) -char *ogs_amf_id_to_string(ogs_amf_id_t *amf_id) -{ - char *str = NULL; - ogs_assert(amf_id); - - str = ogs_calloc(1, OGS_AMFIDSTRLEN); - ogs_expect_or_return_val(str, NULL); - - ogs_hex_to_ascii(amf_id, sizeof(ogs_amf_id_t), str, OGS_AMFIDSTRLEN); - - return str; -} - -uint8_t ogs_amf_region_id(ogs_amf_id_t *amf_id) -{ - ogs_assert(amf_id); - return amf_id->region; -} -uint16_t ogs_amf_set_id(ogs_amf_id_t *amf_id) -{ - ogs_assert(amf_id); - return (amf_id->set1 << 2) + amf_id->set2; -} -uint8_t ogs_amf_pointer(ogs_amf_id_t *amf_id) -{ - ogs_assert(amf_id); - return amf_id->pointer; -} - -ogs_amf_id_t *ogs_amf_id_build(ogs_amf_id_t *amf_id, - uint8_t region, uint16_t set, uint8_t pointer) -{ - amf_id->region = region; - amf_id->set1 = set >> 2; - amf_id->set2 = set & 0x3; - amf_id->pointer = pointer; - - return amf_id; -} - -char *ogs_supi_from_suci(char *suci) -{ -#define MAX_SUCI_TOKEN 16 - char *arrayMAX_SUCI_TOKEN; - char *p, *tmp; - int i; - char *supi = NULL; - - ogs_assert(suci); - tmp = ogs_strdup(suci); - ogs_expect_or_return_val(tmp, NULL); - - p = tmp; - i = 0; - while((arrayi++ = strsep(&p, "-"))) { - /* Empty Body */ - } - - SWITCH(array0) - CASE("suci") - SWITCH(array1) - CASE("0") /* SUPI format : IMSI */ - if (array2 && array3 && array7) - supi = ogs_msprintf("imsi-%s%s%s", - array2, array3, array7); - - break; - DEFAULT - ogs_error("Not implemented %s", array1); - break; - END - break; - DEFAULT - ogs_error("Not implemented %s", array0); - break; - END - - ogs_free(tmp); - return supi; -} - -char *ogs_id_get_type(char *str) -{ - char *token, *p, *tmp; - char *type = NULL; - - ogs_assert(str); - tmp = ogs_strdup(str); - ogs_expect_or_return_val(tmp, NULL); - - p = tmp; - token = strsep(&p, "-"); - ogs_assert(token); - type = ogs_strdup(token); - ogs_expect_or_return_val(type, NULL); - - ogs_free(tmp); - return type; -} - -char *ogs_id_get_value(char *str) -{ - char *token, *p, *tmp; - char *ueid = NULL; - - ogs_assert(str); - tmp = ogs_strdup(str); - ogs_expect_or_return_val(tmp, NULL); - - p = tmp; - token = strsep(&p, "-"); - ogs_assert(token); - token = strsep(&p, "-"); - ogs_assert(token); - ueid = ogs_strdup(token); - ogs_expect_or_return_val(ueid, NULL); - - ogs_free(tmp); - return ueid; -} - -char *ogs_s_nssai_sd_to_string(ogs_uint24_t sd) -{ - char *string = NULL; - - if (sd.v == OGS_S_NSSAI_NO_SD_VALUE) - return NULL; - - string = ogs_uint24_to_0string(sd); - ogs_expect(string); - - return string; -} - -ogs_uint24_t ogs_s_nssai_sd_from_string(const char *hex) -{ - ogs_uint24_t sd; - - sd.v = OGS_S_NSSAI_NO_SD_VALUE; - if (hex == NULL) - return sd; - - return ogs_uint24_from_string((char *)hex); -} - -int ogs_fqdn_build(char *dst, char *src, int length) -{ - int i = 0, j = 0; - - for (i = 0, j = 0; i < length; i++, j++) { - if (srci == '.') { - dsti-j = j; - j = -1; - } else { - dsti+1 = srci; - } - } - dsti-j = j; - - return length+1; -} - -int ogs_fqdn_parse(char *dst, char *src, int length) -{ - int i = 0, j = 0; - uint8_t len = 0; - - while (i+1 < length) { - len = srci++; - if ((j + len + 1) > length) { - ogs_error("Invalid FQDN encodinglen:%d + 1 > length%d", - len, length); - ogs_log_hexdump(OGS_LOG_ERROR, (unsigned char *)src, length); - return 0; - } - memcpy(&dstj, &srci, len); - - i += len; - j += len; - - if (i+1 < length) - dstj++ = '.'; - else - dstj = 0; - } - - return j; -} - -/* 8.13 Protocol Configuration Options (PCO) - * 10.5.6.3 Protocol configuration options in 3GPP TS 24.008 */ -int ogs_pco_parse(ogs_pco_t *pco, unsigned char *data, int data_len) -{ - ogs_pco_t *source = (ogs_pco_t *)data; - int size = 0; - int i = 0; - - ogs_assert(pco); - ogs_assert(data); - ogs_assert(data_len); - - memset(pco, 0, sizeof(ogs_pco_t)); - - pco->ext = source->ext; - pco->configuration_protocol = source->configuration_protocol; - size++; - - while(size < data_len && i < OGS_MAX_NUM_OF_PROTOCOL_OR_CONTAINER_ID) { - ogs_pco_id_t *id = &pco->idsi; - ogs_assert(size + sizeof(id->id) <= data_len); - memcpy(&id->id, data + size, sizeof(id->id)); - id->id = be16toh(id->id); - size += sizeof(id->id); - - ogs_assert(size + sizeof(id->len) <= data_len); - memcpy(&id->len, data + size, sizeof(id->len)); - size += sizeof(id->len); - - id->data = data + size; - size += id->len; - - i++; - } - pco->num_of_id = i; - ogs_assert(size == data_len); - - return size; -} -int ogs_pco_build(unsigned char *data, int data_len, ogs_pco_t *pco) -{ - ogs_pco_t target; - int size = 0; - int i = 0; - - ogs_assert(pco); - ogs_assert(data); - ogs_assert(data_len); - - memcpy(&target, pco, sizeof(ogs_pco_t)); - - ogs_assert(size + 1 <= data_len); - memcpy(data + size, &target, 1); - size += 1; - - ogs_assert(target.num_of_id <= OGS_MAX_NUM_OF_PROTOCOL_OR_CONTAINER_ID); - for (i = 0; i < target.num_of_id; i++) { - ogs_pco_id_t *id = &target.idsi; - - ogs_assert(size + sizeof(id->id) <= data_len); - id->id = htobe16(id->id); - memcpy(data + size, &id->id, sizeof(id->id)); - size += sizeof(id->id); - - ogs_assert(size + sizeof(id->len) <= data_len); - memcpy(data + size, &id->len, sizeof(id->len)); - size += sizeof(id->len); - - ogs_assert(size + id->len <= data_len); - memcpy(data + size, id->data, id->len); - size += id->len; - } - - return size; -} - -int ogs_ip_to_sockaddr(ogs_ip_t *ip, uint16_t port, ogs_sockaddr_t **list) -{ - ogs_sockaddr_t *addr = NULL, *addr6 = NULL; - - ogs_assert(ip); - ogs_assert(list); - - addr = ogs_calloc(1, sizeof(ogs_sockaddr_t)); - if (!addr) { - ogs_error("ogs_calloc() failed"); - return OGS_ERROR; - } - addr->ogs_sa_family = AF_INET; - addr->ogs_sin_port = htobe16(port); - - addr6 = ogs_calloc(1, sizeof(ogs_sockaddr_t)); - if (!addr6) { - ogs_error("ogs_calloc() failed"); - ogs_free(addr); - return OGS_ERROR; - } - addr6->ogs_sa_family = AF_INET6; - addr6->ogs_sin_port = htobe16(port); - - if (ip->ipv4 && ip->ipv6) { - addr->next = addr6; - - addr->sin.sin_addr.s_addr = ip->addr; - memcpy(addr6->sin6.sin6_addr.s6_addr, ip->addr6, OGS_IPV6_LEN); - - *list = addr; - } else if (ip->ipv4) { - addr->sin.sin_addr.s_addr = ip->addr; - ogs_free(addr6); - - *list = addr; - } else if (ip->ipv6) { - memcpy(addr6->sin6.sin6_addr.s6_addr, ip->addr6, OGS_IPV6_LEN); - ogs_free(addr); - - *list = addr6; - } else { - ogs_error("No IPv4 and IPv6"); - ogs_free(addr); - ogs_free(addr6); - return OGS_ERROR; - } - - return OGS_OK; -} - -int ogs_sockaddr_to_ip( - ogs_sockaddr_t *addr, ogs_sockaddr_t *addr6, ogs_ip_t *ip) -{ - ogs_expect_or_return_val(ip, OGS_ERROR); - ogs_expect_or_return_val(addr || addr6, OGS_ERROR); - - memset(ip, 0, sizeof(ogs_ip_t)); - - if (addr && addr6) { - ip->ipv4 = 1; - ip->ipv6 = 1; - ip->len = OGS_IPV4V6_LEN; - ip->addr = addr->sin.sin_addr.s_addr; - memcpy(ip->addr6, addr6->sin6.sin6_addr.s6_addr, OGS_IPV6_LEN); - } else if (addr) { - ip->ipv4 = 1; - ip->len = OGS_IPV4_LEN; - ip->addr = addr->sin.sin_addr.s_addr; - } else if (addr6) { - ip->ipv6 = 1; - ip->len = OGS_IPV6_LEN; - memcpy(ip->addr6, addr6->sin6.sin6_addr.s6_addr, OGS_IPV6_LEN); - } else - ogs_assert_if_reached(); - - return OGS_OK; -} - -char *ogs_ipv4_to_string(uint32_t addr) -{ - char *buf = NULL; - - buf = ogs_calloc(1, OGS_ADDRSTRLEN); - ogs_expect_or_return_val(buf, NULL); - - return (char*)OGS_INET_NTOP(&addr, buf); -} - -char *ogs_ipv6addr_to_string(uint8_t *addr6) -{ - char *buf = NULL; - ogs_assert(addr6); - - buf = ogs_calloc(1, OGS_ADDRSTRLEN); - ogs_expect_or_return_val(buf, NULL); - - return (char *)OGS_INET6_NTOP(addr6, buf); -} - -char *ogs_ipv6prefix_to_string(uint8_t *addr6, uint8_t prefixlen) -{ - char *buf = NULL; - uint8_t tmpOGS_IPV6_LEN; - ogs_assert(addr6); - - memset(tmp, 0, OGS_IPV6_LEN); - memcpy(tmp, addr6, prefixlen >> 3); - - buf = ogs_calloc(1, OGS_ADDRSTRLEN); - ogs_expect_or_return_val(buf, NULL); - - if (OGS_INET6_NTOP(tmp, buf) == NULL) { - ogs_fatal("Invalid IPv6 address"); - ogs_log_hexdump(OGS_LOG_FATAL, addr6, OGS_IPV6_LEN); - ogs_assert_if_reached(); - } - return ogs_mstrcatf(buf, "/%d", prefixlen); -} - -int ogs_ipv4_from_string(uint32_t *addr, char *string) -{ - int rv; - ogs_sockaddr_t tmp; - - ogs_assert(addr); - ogs_assert(string); - - rv = ogs_inet_pton(AF_INET, string, &tmp); - if (rv != OGS_OK) { - ogs_error("Invalid IPv4 string = %s", string); - return OGS_ERROR; - } - - *addr = tmp.sin.sin_addr.s_addr; - - return OGS_OK; -} - -int ogs_ipv6addr_from_string(uint8_t *addr6, char *string) -{ - int rv; - ogs_sockaddr_t tmp; - - ogs_assert(addr6); - ogs_assert(string); - - rv = ogs_inet_pton(AF_INET6, string, &tmp); - if (rv != OGS_OK) { - ogs_error("Invalid IPv6 string = %s", string); - return OGS_ERROR; - } - - memcpy(addr6, tmp.sin6.sin6_addr.s6_addr, OGS_IPV6_LEN); - - return OGS_OK; -} - -int ogs_ipv6prefix_from_string(uint8_t *addr6, uint8_t *prefixlen, char *string) -{ - int rv; - ogs_sockaddr_t tmp; - char *v = NULL, *pv = NULL, *ipstr = NULL, *mask_or_numbits = NULL; - - ogs_assert(addr6); - ogs_assert(prefixlen); - ogs_assert(string); - pv = v = ogs_strdup(string); - ogs_expect_or_return_val(v, OGS_ERROR); - - ipstr = strsep(&v, "/"); - if (ipstr) - mask_or_numbits = v; - - if (!ipstr || !mask_or_numbits) { - ogs_error("Invalid IPv6 Prefix string = %s", v); - ogs_free(v); - return OGS_ERROR; - } - - rv = ogs_inet_pton(AF_INET6, ipstr, &tmp); - ogs_expect_or_return_val(rv == OGS_OK, rv); - - memcpy(addr6, tmp.sin6.sin6_addr.s6_addr, OGS_IPV6_LEN); - *prefixlen = atoi(mask_or_numbits); - - ogs_free(pv); - return OGS_OK; -} - -int ogs_sockaddr_to_user_plane_ip_resource_info( - ogs_sockaddr_t *addr, ogs_sockaddr_t *addr6, - ogs_user_plane_ip_resource_info_t *info) -{ - ogs_assert(addr || addr6); - ogs_assert(info); - - if (addr) { - info->v4 = 1; - info->addr = addr->sin.sin_addr.s_addr; - } - if (addr6) { - info->v6 = 1; - memcpy(info->addr6, addr6->sin6.sin6_addr.s6_addr, OGS_IPV6_LEN); - } - - return OGS_OK; -} - -int ogs_user_plane_ip_resource_info_to_sockaddr( - ogs_user_plane_ip_resource_info_t *info, - ogs_sockaddr_t **addr, ogs_sockaddr_t **addr6) -{ - ogs_assert(addr && addr6); - ogs_assert(info); - - *addr = NULL; - *addr6 = NULL; - - if (info->v4) { - *addr = ogs_calloc(1, sizeof(**addr)); - ogs_assert(*addr); - (*addr)->sin.sin_addr.s_addr = info->addr; - (*addr)->ogs_sa_family = AF_INET; - } - - if (info->v6) { - *addr6 = ogs_calloc(1, sizeof(**addr6)); - ogs_assert(*addr6); - memcpy((*addr6)->sin6.sin6_addr.s6_addr, info->addr6, OGS_IPV6_LEN); - (*addr6)->ogs_sa_family = AF_INET6; - } - - return OGS_OK; -} - -ogs_slice_data_t *ogs_slice_find_by_s_nssai( - ogs_slice_data_t *slice_data, int num_of_slice_data, - ogs_s_nssai_t *s_nssai) -{ - int i; - - ogs_assert(slice_data); - ogs_assert(num_of_slice_data); - ogs_assert(s_nssai); - - /* Compare S-NSSAI */ - for (i = 0; i < num_of_slice_data; i++) { - if (s_nssai->sst == slice_datai.s_nssai.sst && - s_nssai->sd.v == slice_datai.s_nssai.sd.v) { - return slice_data + i; - } - } - - return NULL; -} - -void ogs_subscription_data_free(ogs_subscription_data_t *subscription_data) -{ - int i, j; - - ogs_assert(subscription_data); - - for (i = 0; i < subscription_data->num_of_slice; i++) { - ogs_slice_data_t *slice_data = &subscription_data->slicei; - - for (j = 0; j < slice_data->num_of_session; j++) { - if (slice_data->sessionj.name) - ogs_free(slice_data->sessionj.name); - } - - slice_data->num_of_session = 0; - } - - subscription_data->num_of_slice = 0; - - subscription_data->num_of_msisdn = 0; -} - -void ogs_session_data_free(ogs_session_data_t *session_data) -{ - int i; - - ogs_assert(session_data); - - if (session_data->session.name) - ogs_free(session_data->session.name); - - for (i = 0; i < session_data->num_of_pcc_rule; i++) - OGS_PCC_RULE_FREE(&session_data->pcc_rulei); -} - -void ogs_ims_data_free(ogs_ims_data_t *ims_data) -{ - int i, j, k; - - ogs_assert(ims_data); - - for (i = 0; i < ims_data->num_of_media_component; i++) { - ogs_media_component_t *media_component = &ims_data->media_componenti; - - for (j = 0; j < media_component->num_of_sub; j++) { - ogs_media_sub_component_t *sub = &media_component->subj; - - for (k = 0; k < sub->num_of_flow; k++) { - ogs_flow_t *flow = &sub->flowk; - - if (flow->description) { - ogs_free(flow->description); - } else - ogs_assert_if_reached(); - } - } - } -} - -static int flow_rx_to_gx(ogs_flow_t *rx_flow, ogs_flow_t *gx_flow) -{ - int len; - char *from_str, *to_str; - - ogs_assert(rx_flow); - ogs_assert(gx_flow); - - if (!strncmp(rx_flow->description, - "permit out", strlen("permit out"))) { - gx_flow->direction = OGS_FLOW_DOWNLINK_ONLY; - gx_flow->description = ogs_strdup(rx_flow->description); - ogs_assert(gx_flow->description); - - } else if (!strncmp(rx_flow->description, - "permit in", strlen("permit in"))) { - gx_flow->direction = OGS_FLOW_UPLINK_ONLY; - - /* 'permit in' should be changed - * 'permit out' in Gx Diameter */ - len = strlen(rx_flow->description)+2; - gx_flow->description = ogs_calloc(1, len); - ogs_assert(gx_flow->description); - strcpy(gx_flow->description, "permit out"); - from_str = strstr(&rx_flow->descriptionstrlen("permit in"), "from"); - ogs_assert(from_str); - to_str = strstr(&rx_flow->descriptionstrlen("permit in"), "to"); - ogs_assert(to_str); - strncat(gx_flow->description, - &rx_flow->descriptionstrlen("permit in"), - strlen(rx_flow->description) - - strlen("permit in") - strlen(from_str)); - strcat(gx_flow->description, "from"); - strcat(gx_flow->description, &to_strstrlen("to")); - strcat(gx_flow->description, " to"); - strncat(gx_flow->description, &from_strstrlen("from"), - strlen(from_str) - strlen(to_str) - strlen("from") - 1); - ogs_assert(len == strlen(gx_flow->description)+1); - } else { - ogs_error("Invalid Flow Descripton : %s", rx_flow->description); - return OGS_ERROR; - } - - return OGS_OK; -} - -int ogs_pcc_rule_num_of_flow_equal_to_media( - ogs_pcc_rule_t *pcc_rule, ogs_media_component_t *media_component) -{ - int rv; - int i, j, k; - int matched = 0; - int new = 0; - - ogs_assert(pcc_rule); - ogs_assert(media_component); - - for (i = 0; i < media_component->num_of_sub; i++) { - ogs_media_sub_component_t *sub = &media_component->subi; - - for (j = 0; j < sub->num_of_flow; j++) { - new++; - } - } - - if (new == 0) { - /* No new flow in Media-Component */ - return pcc_rule->num_of_flow; - } - - for (i = 0; i < media_component->num_of_sub; i++) { - ogs_media_sub_component_t *sub = &media_component->subi; - - for (j = 0; j < sub->num_of_flow && - j < OGS_MAX_NUM_OF_FLOW_IN_MEDIA_SUB_COMPONENT; j++) { - ogs_flow_t gx_flow; - ogs_flow_t *rx_flow = &sub->flowj; - - rv = flow_rx_to_gx(rx_flow, &gx_flow); - if (rv != OGS_OK) { - ogs_error("flow reformatting error"); - return OGS_ERROR; - } - - for (k = 0; k < pcc_rule->num_of_flow; k++) { - if (gx_flow.direction == pcc_rule->flowk.direction && - !strcmp(gx_flow.description, - pcc_rule->flowk.description)) { - matched++; - break; - } - } - - OGS_FLOW_FREE(&gx_flow); - } - } - - return matched; -} - -int ogs_pcc_rule_install_flow_from_media( - ogs_pcc_rule_t *pcc_rule, ogs_media_component_t *media_component) -{ - int rv; - int i, j; - - ogs_assert(pcc_rule); - ogs_assert(media_component); - - /* Remove Flow from PCC Rule */ - for (i = 0; i < pcc_rule->num_of_flow; i++) { - OGS_FLOW_FREE(&pcc_rule->flowi); - } - pcc_rule->num_of_flow = 0; - - for (i = 0; i < media_component->num_of_sub; i++) { - ogs_media_sub_component_t *sub = &media_component->subi; - - /* Copy Flow to PCC Rule */ - for (j = 0; j < sub->num_of_flow && - j < OGS_MAX_NUM_OF_FLOW_IN_MEDIA_SUB_COMPONENT; j++) { - ogs_flow_t *rx_flow = NULL; - ogs_flow_t *gx_flow = NULL; - - if (pcc_rule->num_of_flow < OGS_MAX_NUM_OF_FLOW_IN_PCC_RULE) { - rx_flow = &sub->flowj; - gx_flow = &pcc_rule->flowpcc_rule->num_of_flow; - - rv = flow_rx_to_gx(rx_flow, gx_flow); - if (rv != OGS_OK) { - ogs_error("flow reformatting error"); - return OGS_ERROR; - } - - pcc_rule->num_of_flow++; - } else { - ogs_error("Overflow: Number of Flow"); - return OGS_ERROR; - } - } - } - - return OGS_OK; -} - -int ogs_pcc_rule_update_qos_from_media( - ogs_pcc_rule_t *pcc_rule, ogs_media_component_t *media_component) -{ - int rv; - int i, j; - - ogs_assert(pcc_rule); - ogs_assert(media_component); - - pcc_rule->qos.mbr.downlink = 0; - pcc_rule->qos.mbr.uplink = 0; - pcc_rule->qos.gbr.downlink = 0; - pcc_rule->qos.gbr.uplink = 0; - - for (i = 0; i < media_component->num_of_sub; i++) { - ogs_media_sub_component_t *sub = &media_component->subi; - - for (j = 0; j < sub->num_of_flow && - j < OGS_MAX_NUM_OF_FLOW_IN_MEDIA_SUB_COMPONENT; j++) { - ogs_flow_t gx_flow; - ogs_flow_t *rx_flow = &sub->flowj; - - rv = flow_rx_to_gx(rx_flow, &gx_flow); - if (rv != OGS_OK) { - ogs_error("flow reformatting error"); - return OGS_ERROR; - } - - if (gx_flow.direction == OGS_FLOW_DOWNLINK_ONLY) { - if (sub->flow_usage == OGS_FLOW_USAGE_RTCP) { - if (media_component->rr_bandwidth && - media_component->rs_bandwidth) { - pcc_rule->qos.mbr.downlink += - (media_component->rr_bandwidth + - media_component->rs_bandwidth); - } else if (media_component->max_requested_bandwidth_dl) { - if (media_component->rr_bandwidth && - !media_component->rs_bandwidth) { - pcc_rule->qos.mbr.downlink += - ogs_max(0.05 * - media_component->max_requested_bandwidth_dl, - media_component->rr_bandwidth); - } - if (!media_component->rr_bandwidth && - media_component->rs_bandwidth) { - pcc_rule->qos.mbr.downlink += - ogs_max(0.05 * - media_component->max_requested_bandwidth_dl, - media_component->rs_bandwidth); - } - if (!media_component->rr_bandwidth && - !media_component->rs_bandwidth) { - pcc_rule->qos.mbr.downlink += - 0.05 * - media_component->max_requested_bandwidth_dl; - } - } - } else { - if (gx_flow.description) { - pcc_rule->qos.mbr.downlink += - media_component->max_requested_bandwidth_dl; - pcc_rule->qos.gbr.downlink += - media_component->min_requested_bandwidth_dl; - } - } - } else if (gx_flow.direction == OGS_FLOW_UPLINK_ONLY) { - if (sub->flow_usage == OGS_FLOW_USAGE_RTCP) { - if (media_component->rr_bandwidth && - media_component->rs_bandwidth) { - pcc_rule->qos.mbr.uplink += - (media_component->rr_bandwidth + - media_component->rs_bandwidth); - } else if (media_component->max_requested_bandwidth_ul) { - if (media_component->rr_bandwidth && - !media_component->rs_bandwidth) { - pcc_rule->qos.mbr.uplink += - ogs_max(0.05 * - media_component->max_requested_bandwidth_ul, - media_component->rr_bandwidth); - } - if (!media_component->rr_bandwidth && - media_component->rs_bandwidth) { - pcc_rule->qos.mbr.uplink += - ogs_max(0.05 * - media_component->max_requested_bandwidth_ul, - media_component->rs_bandwidth); - } - if (!media_component->rr_bandwidth && - !media_component->rs_bandwidth) { - pcc_rule->qos.mbr.uplink += - 0.05 * - media_component->max_requested_bandwidth_ul; - } - } - } else { - if (gx_flow.description) { - pcc_rule->qos.mbr.uplink += - media_component->max_requested_bandwidth_ul; - pcc_rule->qos.gbr.uplink += - media_component->min_requested_bandwidth_ul; - } - } - } else - ogs_assert_if_reached(); - - OGS_FLOW_FREE(&gx_flow); - } - } - - if (pcc_rule->qos.mbr.downlink == 0) { - pcc_rule->qos.mbr.downlink += - media_component->max_requested_bandwidth_dl; - pcc_rule->qos.mbr.downlink += - (media_component->rr_bandwidth + media_component->rs_bandwidth); - } - - if (pcc_rule->qos.mbr.uplink == 0) { - pcc_rule->qos.mbr.uplink += - media_component->max_requested_bandwidth_ul; - pcc_rule->qos.mbr.uplink += - (media_component->rr_bandwidth + media_component->rs_bandwidth); - } - - if (pcc_rule->qos.gbr.downlink == 0) - pcc_rule->qos.gbr.downlink = pcc_rule->qos.mbr.downlink; - if (pcc_rule->qos.gbr.uplink == 0) - pcc_rule->qos.gbr.uplink = pcc_rule->qos.mbr.uplink; - - return OGS_OK; -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/core/ogs-3gpp-types.h
Deleted
@@ -1,781 +0,0 @@ -/* - * 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/>. - */ - -#if !defined(OGS_CORE_INSIDE) && !defined(OGS_CORE_COMPILATION) -#error "This header cannot be included directly." -#endif - -#ifndef OGS_3GPP_TYPES_H -#define OGS_3GPP_TYPES_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define OGS_MAX_NUM_OF_SESS 4 /* Num of APN(Session) per UE */ -#define OGS_MAX_NUM_OF_BEARER 4 /* Num of Bearer per Session */ -#define OGS_BEARER_PER_UE 8 /* Num of Bearer per UE */ -#define OGS_MAX_NUM_OF_PACKET_BUFFER 64 /* Num of PacketBuffer per UE */ - -/* Num of NF Service per NF Instance */ -#define OGS_MAX_NUM_OF_NF_SERVICE 16 - -/* - * The array of TLV messages is limited to 8. - * So, Flow(PDI.SDF_Filter) in PDR is limited to 8. - * - * However, the number of flow in bearer context seems to need more than 16. - * - * Therefore, the maximum number of flows of messages is defined as 8, - * and the maximum number of flows stored by the context is 16. - */ -#define OGS_MAX_NUM_OF_FLOW_IN_PDR 8 -#define OGS_MAX_NUM_OF_FLOW_IN_GTP OGS_MAX_NUM_OF_FLOW_IN_PDR -#define OGS_MAX_NUM_OF_FLOW_IN_NAS OGS_MAX_NUM_OF_FLOW_IN_PDR -#define OGS_MAX_NUM_OF_FLOW_IN_PCC_RULE OGS_MAX_NUM_OF_FLOW_IN_PDR -#define OGS_MAX_NUM_OF_FLOW_IN_MEDIA_SUB_COMPONENT OGS_MAX_NUM_OF_FLOW_IN_PDR -#define OGS_MAX_NUM_OF_FLOW_IN_BEARER 16 - -#define OGS_MAX_NUM_OF_GTPU_RESOURCE 4 - -#define OGS_MAX_SDU_LEN 8192 -#define OGS_MAX_PKT_LEN 2048 -#define OGS_PLMN_ID_LEN 3 -#define OGS_MAX_PLMN_ID_BCD_LEN 6 - -#define OGS_CHRGCHARS_LEN 2 - -#define OGS_BCD_TO_BUFFER_LEN(x) (((x)+1)/2) -#define OGS_MAX_IMSI_BCD_LEN 15 -#define OGS_MAX_IMSI_LEN \ - OGS_BCD_TO_BUFFER_LEN(OGS_MAX_IMSI_BCD_LEN) - -#define OGS_MAX_IMEISV_BCD_LEN 16 -#define OGS_MAX_IMEISV_LEN \ - OGS_BCD_TO_BUFFER_LEN(OGS_MAX_IMEISV_BCD_LEN) - -#define OGS_MAX_MSISDN_BCD_LEN 15 -#define OGS_MAX_MSISDN_LEN \ - OGS_BCD_TO_BUFFER_LEN(OGS_MAX_MSISDN_BCD_LEN) - -#define OGS_MAX_NUM_OF_CELL_ID 16 -#define OGS_MAX_NUM_OF_ENB_ID 16 -#define OGS_MAX_NUM_OF_DNN 16 -#define OGS_MAX_NUM_OF_APN OGS_MAX_NUM_OF_DNN -#define OGS_MAX_NUM_OF_HOSTNAME 16 -#define OGS_MAX_DNN_LEN 100 -#define OGS_MAX_APN_LEN OGS_MAX_DNN_LEN -#define OGS_MAX_PCO_LEN 251 -#define OGS_MAX_FQDN_LEN 256 - -#define OGS_MAX_NUM_OF_SERVED_TAI 16 -#define OGS_MAX_NUM_OF_ALGORITHM 8 - -#define OGS_MAX_NUM_OF_BPLMN 6 - -#define OGS_NEXT_ID(__id, __min, __max) \ - ((__id) = ((__id) == (__max) ? (__min) : ((__id) + 1))) -#define OGS_COMPARE_ID(__id1, __id2, __max) \ - ((__id2) > (__id1) ? ((__id2) - (__id1) < ((__max)-1) ? -1 : 1) : \ - (__id1) > (__id2) ? ((__id1) - (__id2) < ((__max)-1) ? 1 : -1) : 0) - -#define OGS_TIME_TO_BCD(x) \ - (((((x) % 10) << 4) & 0xf0) | (((x) / 10) & 0x0f)) - -#define OGS_NAS_PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED 0 -#define OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED 0 - -#define OGS_ACCESS_TYPE_3GPP 1 -#define OGS_ACCESS_TYPE_NON_3GPP 2 -#define OGS_ACCESS_TYPE_BOTH_3GPP_AND_NON_3GPP 3 - -#define OGS_MAX_QOS_FLOW_ID 63 - -#define OGS_DEFAULT_SCTP_MAX_NUM_OF_OSTREAMS 30 - -/************************************ - * PLMN_ID Structure */ -#define OGS_MAX_NUM_OF_PLMN 6 -typedef struct ogs_plmn_id_s { -ED2(uint8_t mcc2:4;, - uint8_t mcc1:4;) -ED2(uint8_t mnc1:4;, - uint8_t mcc3:4;) -ED2(uint8_t mnc3:4;, - uint8_t mnc2:4;) -} __attribute__ ((packed)) ogs_plmn_id_t; - -uint32_t ogs_plmn_id_hexdump(void *plmn_id); - -uint16_t ogs_plmn_id_mcc(ogs_plmn_id_t *plmn_id); -uint16_t ogs_plmn_id_mnc(ogs_plmn_id_t *plmn_id); -uint16_t ogs_plmn_id_mnc_len(ogs_plmn_id_t *plmn_id); - -void *ogs_plmn_id_build(ogs_plmn_id_t *plmn_id, - uint16_t mcc, uint16_t mnc, uint16_t mnc_len); - -char *ogs_serving_network_name_from_plmn_id(ogs_plmn_id_t *plmn_id); -char *ogs_plmn_id_mcc_string(ogs_plmn_id_t *plmn_id); -char *ogs_plmn_id_mnc_string(ogs_plmn_id_t *plmn_id); - -#define OGS_PLMNIDSTRLEN (sizeof(ogs_plmn_id_t)*2+1) -char *ogs_plmn_id_to_string(ogs_plmn_id_t *plmn_id, char *buf); - -/************************* - * NAS PLMN_ID Structure */ -typedef struct ogs_nas_plmn_id_s { -ED2(uint8_t mcc2:4;, - uint8_t mcc1:4;) -ED2(uint8_t mnc3:4;, - uint8_t mcc3:4;) -ED2(uint8_t mnc2:4;, - uint8_t mnc1:4;) -} __attribute__ ((packed)) ogs_nas_plmn_id_t; - -void *ogs_nas_from_plmn_id( - ogs_nas_plmn_id_t *ogs_nas_plmn_id, ogs_plmn_id_t *plmn_id); -void *ogs_nas_to_plmn_id( - ogs_plmn_id_t *plmn_id, ogs_nas_plmn_id_t *ogs_nas_plmn_id); - -/************************************ - * AMF_ID Structure */ -typedef struct ogs_amf_id_s { - uint8_t region; - uint8_t set1; -ED2(uint8_t set2:2;, - uint8_t pointer:6;) -} __attribute__ ((packed)) ogs_amf_id_t; - -typedef struct ogs_guami_s { - ogs_plmn_id_t plmn_id; - ogs_amf_id_t amf_id; -} ogs_guami_t; - -uint32_t ogs_amf_id_hexdump(ogs_amf_id_t *amf_id); - -ogs_amf_id_t *ogs_amf_id_from_string(ogs_amf_id_t *amf_id, const char *hex); -char *ogs_amf_id_to_string(ogs_amf_id_t *amf_id); - -uint8_t ogs_amf_region_id(ogs_amf_id_t *amf_id); -uint16_t ogs_amf_set_id(ogs_amf_id_t *amf_id); -uint8_t ogs_amf_pointer(ogs_amf_id_t *amf_id); - -ogs_amf_id_t *ogs_amf_id_build(ogs_amf_id_t *amf_id, - uint8_t region, uint16_t set, uint8_t pointer); - -/************************************ - * SUPI/SUCI */ -char *ogs_supi_from_suci(char *suci); - -/************************************ - * SUPI/GPSI */ -#define OGS_ID_SUPI_TYPE_IMSI "imsi" -#define OGS_ID_GPSI_TYPE_MSISDN "msisdn" -char *ogs_id_get_type(char *str); -char *ogs_id_get_value(char *str); - -/************************************ - * TAI Structure */ -#define OGS_MAX_NUM_OF_TAI 16 -typedef struct ogs_eps_tai_s { - ogs_plmn_id_t plmn_id; - uint16_t tac; -} __attribute__ ((packed)) ogs_eps_tai_t; - -typedef struct ogs_5gs_tai_s { - ogs_plmn_id_t plmn_id; - ogs_uint24_t tac; -} __attribute__ ((packed)) ogs_5gs_tai_t; - -typedef struct ogs_e_cgi_s { - ogs_plmn_id_t plmn_id; - uint32_t cell_id; /* 28 bit */ -} __attribute__ ((packed)) ogs_e_cgi_t; - -typedef struct ogs_nr_cgi_s { - ogs_plmn_id_t plmn_id; - uint64_t cell_id; /* 36 bit */ -} __attribute__ ((packed)) ogs_nr_cgi_t; - -/************************************ - * S-NSSAI Structure */ -#define OGS_MAX_NUM_OF_SLICE 8 -#define OGS_S_NSSAI_NO_SD_VALUE 0xffffff -typedef struct ogs_s_nssai_s { - uint8_t sst; - ogs_uint24_t sd; -} __attribute__ ((packed)) ogs_s_nssai_t; - -char *ogs_s_nssai_sd_to_string(ogs_uint24_t sd); -ogs_uint24_t ogs_s_nssai_sd_from_string(const char *hex); - -/************************************************** - * Common Structure - * S1AP : 9.2.2.1 Transport Layer Address, See 36.414 - * GTP : 8.22 Fully Qualified TEID (F-TEID) */ -#define OGS_IPV4_LEN 4 -#define OGS_IPV6_LEN 16 -#define OGS_IPV6_DEFAULT_PREFIX_LEN 64 -#define OGS_IPV6_128_PREFIX_LEN 128 -#define OGS_IPV4V6_LEN 20 -typedef struct ogs_ip_s { - uint32_t addr; - uint8_t addr6OGS_IPV6_LEN; - uint32_t len; -ED3(uint8_t ipv4:1;, - uint8_t ipv6:1;, - uint8_t reserved:6;) -} ogs_ip_t; - -int ogs_ip_to_sockaddr(ogs_ip_t *ip, uint16_t port, ogs_sockaddr_t **list); -int ogs_sockaddr_to_ip( - ogs_sockaddr_t *addr, ogs_sockaddr_t *addr6, ogs_ip_t *ip); - -char *ogs_ipv4_to_string(uint32_t addr); -char *ogs_ipv6addr_to_string(uint8_t *addr6); -char *ogs_ipv6prefix_to_string(uint8_t *addr6, uint8_t prefixlen); -int ogs_ipv4_from_string(uint32_t *addr, char *string); -int ogs_ipv6addr_from_string(uint8_t *addr6, char *string); -int ogs_ipv6prefix_from_string( - uint8_t *addr6, uint8_t *prefixlen, char *string); - -/************************************************** - * GTPv1-C: TS 29.060 7.7.27 End User Address (EUA) */ -#define OGS_PDP_EUA_ORG_ETSI 0 -#define OGS_PDP_EUA_ORG_IETF 1 -#define OGS_PDP_EUA_ETSI_PPP 1 -#define OGS_PDP_EUA_IETF_IPV4 0x21 -#define OGS_PDP_EUA_IETF_IPV6 0x57 -#define OGS_PDP_EUA_IETF_IPV4V6 0x8D -typedef struct ogs_eua_s { -ED2(uint8_t spare:4;, - uint8_t organization:4;) - uint8_t type; - union { - /* PDU_SESSION_TYPE_IPV4 */ - uint32_t addr; - - /* PDU_SESSION_TYPE_IPV6 */ - uint8_t addr6OGS_IPV6_LEN; - - /* PDU_SESSION_TYPE_IPV4V6 */ - struct { - uint32_t addr; - uint8_t addr6OGS_IPV6_LEN; - } __attribute__ ((packed)) both; - }; -} __attribute__ ((packed)) ogs_eua_t; - -/************************************************** - * GTPv2-C: TS 29.274 8.14 PDN Address Allocation (PAA) */ -#define OGS_PAA_IPV4_LEN 5 -#define OGS_PAA_IPV6_LEN 18 -#define OGS_PAA_IPV4V6_LEN 22 -typedef struct ogs_paa_s { -ED2(uint8_t spare:5;, -/* 8.34 PDN Type */ -#define OGS_PDU_SESSION_TYPE_IS_VALID(x) \ - ((x) == OGS_PDU_SESSION_TYPE_IPV4 || \ - (x) == OGS_PDU_SESSION_TYPE_IPV6 || \ - (x) == OGS_PDU_SESSION_TYPE_IPV4V6) \ - - uint8_t session_type:3;) - union { - /* PDU_SESSION_TYPE_IPV4 */ - uint32_t addr; - - /* PDU_SESSION_TYPE_IPV6 */ - struct { - /* the IPv6 Prefix Length */ - uint8_t len; - /* IPv6 Prefix and Interface Identifier */ - uint8_t addr6OGS_IPV6_LEN; - }; - - /* PDU_SESSION_TYPE_IPV4V6 */ - struct { - struct { - /* the IPv6 Prefix Length */ - uint8_t len; - /* IPv6 Prefix and Interface Identifier */ - uint8_t addr6OGS_IPV6_LEN; - }; - uint32_t addr; - } __attribute__ ((packed)) both; - }; -} __attribute__ ((packed)) ogs_paa_t; - -#define MAX_BIT_RATE 10000000000UL - -typedef struct ogs_bitrate_s { - uint64_t downlink; /* bits per seconds */ - uint64_t uplink; /* bits per seconds */ -} ogs_bitrate_t; - -/********************************** - * QoS Structure */ -typedef struct ogs_qos_s { -#define OGS_QOS_INDEX_1 1 -#define OGS_QOS_INDEX_2 2 -#define OGS_QOS_INDEX_5 5 - uint8_t index; - - struct { - /* Values 1 to 8 should only be assigned for services that are - * authorized to receive prioritized treatment within an operator domain. - * Values 9 to 15 may be assigned to resources that are authorized - * by the home network and thus applicable when a UE is roaming. */ - uint8_t priority_level; -/* - * Ch 7.3.40 Allocation-Retenion-Proirty in TS 29.272 V15.9.0 - * - * If the Pre-emption-Capability AVP is not present in the - * Allocation-Retention-Priority AVP, the default value shall be - * PRE-EMPTION_CAPABILITY_DISABLED (1). - * - * If the Pre-emption-Vulnerability AVP is not present in the - * Allocation-Retention-Priority AVP, the default value shall be - * PRE-EMPTION_VULNERABILITY_ENABLED (0). - * - * However, to easily set up VoLTE service, - * enable Pre-emption Capability/Vulnerablility - * in Default Bearer - */ -#define OGS_EPC_PRE_EMPTION_DISABLED 1 -#define OGS_EPC_PRE_EMPTION_ENABLED 0 - -#define OGS_5GC_PRE_EMPTION_DISABLED 1 -#define OGS_5GC_PRE_EMPTION_ENABLED 2 - uint8_t pre_emption_capability; - uint8_t pre_emption_vulnerability; - } arp; - - ogs_bitrate_t mbr; /* Maxmimum Bit Rate (MBR) */ - ogs_bitrate_t gbr; /* Guaranteed Bit Rate (GBR) */ -} ogs_qos_t; - -/********************************** - * Flow Structure */ -#define OGS_FLOW_DOWNLINK_ONLY 1 -#define OGS_FLOW_UPLINK_ONLY 2 -typedef struct ogs_flow_s { - uint8_t direction; - char *description; -} ogs_flow_t; - -#define OGS_FLOW_FREE(__fLOW) \ - do { \ - if ((__fLOW)->description) { \ - ogs_free((__fLOW)->description); \ - } \ - else \ - ogs_assert_if_reached(); \ - } while(0) - -/********************************** - * PCC Rule Structure */ -typedef struct ogs_pcc_rule_s { -#define OGS_PCC_RULE_TYPE_INSTALL 1 -#define OGS_PCC_RULE_TYPE_REMOVE 2 - uint8_t type; - - char *id; /* 5GC */ - char *name; /* EPC */ - - ogs_flow_t flowOGS_MAX_NUM_OF_FLOW_IN_PCC_RULE; - int num_of_flow; - - int flow_status; - uint32_t precedence; - - ogs_qos_t qos; -} ogs_pcc_rule_t; - -#define OGS_STORE_PCC_RULE(__dST, __sRC) \ - do { \ - int __iNDEX; \ - ogs_assert((__sRC)); \ - ogs_assert((__dST)); \ - OGS_PCC_RULE_FREE(__dST); \ - (__dST)->type = (__sRC)->type; \ - if ((__sRC)->name) { \ - (__dST)->name = ogs_strdup((__sRC)->name); \ - ogs_assert((__dST)->name); \ - } \ - if ((__sRC)->id) { \ - (__dST)->id = ogs_strdup((__sRC)->id); \ - ogs_assert((__dST)->id); \ - } \ - for (__iNDEX = 0; __iNDEX < (__sRC)->num_of_flow; __iNDEX++) { \ - (__dST)->flow__iNDEX.direction = \ - (__sRC)->flow__iNDEX.direction; \ - (__dST)->flow__iNDEX.description = \ - ogs_strdup((__sRC)->flow__iNDEX.description); \ - ogs_assert((__dST)->flow__iNDEX.description); \ - } \ - (__dST)->num_of_flow = (__sRC)->num_of_flow; \ - (__dST)->flow_status = (__sRC)->flow_status; \ - (__dST)->precedence = (__sRC)->precedence; \ - memcpy(&(__dST)->qos, &(__sRC)->qos, sizeof(ogs_qos_t)); \ - } while(0) - -#define OGS_PCC_RULE_FREE(__pCCrULE) \ - do { \ - int __pCCrULE_iNDEX; \ - ogs_assert((__pCCrULE)); \ - if ((__pCCrULE)->id) \ - ogs_free((__pCCrULE)->id); \ - if ((__pCCrULE)->name) \ - ogs_free((__pCCrULE)->name); \ - for (__pCCrULE_iNDEX = 0; \ - __pCCrULE_iNDEX < (__pCCrULE)->num_of_flow; __pCCrULE_iNDEX++) { \ - OGS_FLOW_FREE(&((__pCCrULE)->flow__pCCrULE_iNDEX)); \ - } \ - (__pCCrULE)->num_of_flow = 0; \ - } while(0) - -/********************************** - * PDN Structure */ -typedef struct ogs_session_s { - char *name; - - uint32_t context_identifier; /* EPC */ - bool default_dnn_indicator; /* 5GC */ - - uint8_t charging_characteristicsOGS_CHRGCHARS_LEN; - bool charging_characteristics_presence; - -#define OGS_PDU_SESSION_TYPE_IPV4 1 -#define OGS_PDU_SESSION_TYPE_IPV6 2 -#define OGS_PDU_SESSION_TYPE_IPV4V6 3 -#define OGS_PDU_SESSION_TYPE_UNSTRUCTURED 4 -#define OGS_PDU_SESSION_TYPE_ETHERNET 5 - -#define OGS_PDU_SESSION_TYPE_TO_DIAMETER(x) ((x)-1) -#define OGS_PDU_SESSION_TYPE_FROM_DIAMETER(x) ((x)+1) - uint8_t session_type; - -#define OGS_SSC_MODE_1 1 -#define OGS_SSC_MODE_2 2 -#define OGS_SSC_MODE_3 3 - uint8_t ssc_mode; - - ogs_qos_t qos; - ogs_bitrate_t ambr; /* APN-AMBR */ - - ogs_paa_t paa; - ogs_ip_t ue_ip; - ogs_ip_t smf_ip; -} ogs_session_t; - -int ogs_fqdn_build(char *dst, char *src, int len); -int ogs_fqdn_parse(char *dst, char *src, int len); - -/************************************************** - * Protocol Configuration Options Structure - * 8.13 Protocol Configuration Options (PCO) - * 10.5.6.3 Protocol configuration options in 3GPP TS 24.008 - * RFC 3232 103 - * RFC 1661 102 */ -#define OGS_PCO_PPP_FOR_USE_WITH_IP_PDP_TYPE_OR_IP_PDN_TYPE 0 - -#define OGS_PCO_ID_INTERNET_PROTOCOL_CONTROL_PROTOCOL 0x8021 -#define OGS_PCO_ID_PASSWORD_AUTHENTICATION_PROTOCOL 0xc023 -#define OGS_PCO_ID_CHALLENGE_HANDSHAKE_AUTHENTICATION_PROTOCOL 0xc223 -#define OGS_PCO_ID_P_CSCF_IPV6_ADDRESS_REQUEST 0x0001 -#define OGS_PCO_ID_DNS_SERVER_IPV6_ADDRESS_REQUEST 0x0003 -#define OGS_PCO_ID_MS_SUPPORTS_BCM 0x0005 -#define OGS_PCO_ID_IP_ADDRESS_ALLOCATION_VIA_NAS_SIGNALLING 0x000a -#define OGS_PCO_ID_P_CSCF_IPV4_ADDRESS_REQUEST 0x000c -#define OGS_PCO_ID_DNS_SERVER_IPV4_ADDRESS_REQUEST 0x000d -#define OGS_PCO_ID_IPV4_LINK_MTU_REQUEST 0x0010 -#define OGS_PCO_ID_MS_SUPPORT_LOCAL_ADDR_TFT_INDICATOR 0x0011 -#define OGS_PCO_ID_P_CSCF_RE_SELECTION_SUPPORT 0x0012 - -enum ogs_pco_ipcp_options { - OGS_IPCP_OPT_IPADDR = 3, - OGS_IPCP_OPT_PRIMARY_DNS = 129, - OGS_IPCP_OPT_SECONDARY_DNS = 131, -}; - -typedef struct ogs_pco_ipcp_options_s { - uint8_t type; - uint8_t len; - uint32_t addr; -} __attribute__ ((packed)) ogs_pco_ipcp_options_t; - -#define OGS_PCO_MAX_NUM_OF_IPCP_OPTIONS 4 -typedef struct ogs_pco_ipcp_s { - uint8_t code; - uint8_t identifier; - uint16_t len; - ogs_pco_ipcp_options_t optionsOGS_PCO_MAX_NUM_OF_IPCP_OPTIONS; -} __attribute__ ((packed)) ogs_pco_ipcp_t; - -typedef struct ogs_pco_pap_s { - uint8_t code; - uint8_t identifier; - uint16_t len; - uint8_t welcome_len; - char welcome255; -} __attribute__ ((packed)) ogs_pco_pap_t; - -typedef struct ogs_pco_chap_s { - uint8_t code; - uint8_t identifier; - uint16_t len; -} __attribute__ ((packed)) ogs_pco_chap_t; - -typedef struct ogs_pco_id_s { - uint16_t id; - uint8_t len; - void *data; -} ogs_pco_id_t; - -#define OGS_MAX_NUM_OF_PROTOCOL_OR_CONTAINER_ID 16 -typedef struct ogs_pco_s { -ED3(uint8_t ext:1;, - uint8_t spare:4;, - uint8_t configuration_protocol:3;) - uint8_t num_of_id; - ogs_pco_id_t idsOGS_MAX_NUM_OF_PROTOCOL_OR_CONTAINER_ID; -} ogs_pco_t; - -int ogs_pco_parse(ogs_pco_t *pco, unsigned char *data, int data_len); -int ogs_pco_build(unsigned char *data, int data_len, ogs_pco_t *pco); - -/* - * PFCP Specification - * - * TS29.244, Ch 8.2.82 User Plane IP Resource Information - * - * The following flags are coded within Octet 5: - * - Bit 1 – V4: If this bit is set to "1", then the IPv4 address field - * shall be present, otherwise the IPv4 address field shall not be present. - * - Bit 2 – V6: If this bit is set to "1", then the IPv6 address field - * shall be present, otherwise the IPv6 address field shall not be present. - * - Bit 3-5 – TEID Range Indication (TEIDRI): the value of this field - * indicates the number of bits in the most significant octet of a TEID - * that are used to partition the TEID range, - * e.g. if this field is set to "4", then the first 4 bits in the TEID - * are used to partition the TEID range. - * - Bit 6 – Associated Network Instance (ASSONI): if this bit is set to "1", - * then the Network Instance field shall be present, otherwise the Network - * Instance field shall not be present. - * - Bit 7 – Associated Source Interface (ASSOSI): if this bit is set to "1", - * then the Source Interface field shall be present, - * otherwise the Source Interface field shall not be present. - * - Bit 8: Spare, for future use and set to 0. - * - * At least one of the V4 and V6 flags shall be set to "1", - * and both may be set to "1". - * - * If both the ASSONI and ASSOSI flags are set to "0", this shall indicate - * that the User Plane IP Resource Information provided can be used - * by CP function for any Network Instance and any Source Interface - * of GTP-U user plane in the UP function. Octet 6 (TEID Range) shall be - * present if the TEID Range Indication is not set to zero and - * shall contain a value of the bits which are used to partition the TEID range. - * E.g. if the TEID Range Indication is set to "4", then Octet 6 shall be - * one of values between 0 and 15. When TEID Range Indication is set to zero, - * the Octet 6 shall not be present, the TEID is not partitioned, - * i.e. all TEID values are available for use by the CP function. - * - * Octets "m to (m+3)" and/or "p to (p+15)" (IPv4 address / IPv6 address fields) - * , if present, shall contain the respective IP address values. - * - * Octets "k to l", if present, shall contain a Network Instance value - * as encoded in octet "5 to n+4" of the Figure 8.2.4-1 in clause 8.2.4, - * identifying a Network Instance with which the IP address or TEID Range - * is associated. - * - * Octet r, if present, shall contain a Source Interface value as encoded - * in octet 5 of the Figure 8.2.2-1 in clause 8.2.2, - * identifying the Source Interface with which the IP address or TEID Range - * is associated. - */ - -/* Flags(1) + TEID Range(1) + IPV4(4) + IPV6(16) + Source Interface(1) = 23 */ -#define OGS_MAX_USER_PLANE_IP_RESOURCE_INFO_LEN \ - (23 + (OGS_MAX_APN_LEN+1)) -typedef struct ogs_user_plane_ip_resource_info_s { - union { - struct { -ED6(uint8_t spare:1;, - uint8_t assosi:1;, - uint8_t assoni:1;, - uint8_t teidri:3;, - uint8_t v6:1;, - uint8_t v4:1;) - }; - uint8_t flags; - }; - - /* - * OGS_PFCP-GTPU-TEID = INDEX | TEID_RANGE - * INDEX = OGS_PFCP-GTPU-TEID & ~TEID_RANGE - */ -#define OGS_PFCP_GTPU_TEID_TO_INDEX(__tEID, __iND, __rANGE) \ - (__tEID & ~(__rANGE << (32 - __iND))) -#define OGS_PFCP_GTPU_INDEX_TO_TEID(__iNDEX, __iND, __rANGE) \ - (__iNDEX | (__rANGE << (32 - __iND))) - uint8_t teid_range; - uint32_t addr; - uint8_t addr6OGS_IPV6_LEN; - char network_instanceOGS_MAX_APN_LEN+1; - uint8_t source_interface; -} __attribute__ ((packed)) ogs_user_plane_ip_resource_info_t; - -int ogs_sockaddr_to_user_plane_ip_resource_info( - ogs_sockaddr_t *addr, ogs_sockaddr_t *addr6, - ogs_user_plane_ip_resource_info_t *info); -int ogs_user_plane_ip_resource_info_to_sockaddr( - ogs_user_plane_ip_resource_info_t *info, - ogs_sockaddr_t **addr, ogs_sockaddr_t **addr6); - -typedef struct ogs_slice_data_s { - ogs_s_nssai_t s_nssai; - bool default_indicator; - - uint32_t context_identifier; /* EPC for checking default APN */ - - int num_of_session; - ogs_session_t sessionOGS_MAX_NUM_OF_SESS; -} ogs_slice_data_t; - -ogs_slice_data_t *ogs_slice_find_by_s_nssai( - ogs_slice_data_t *slice_data, int num_of_slice_data, - ogs_s_nssai_t *s_nssai); - -typedef struct ogs_subscription_data_s { -#define OGS_ACCESS_RESTRICTION_UTRAN_NOT_ALLOWED (1) -#define OGS_ACCESS_RESTRICTION_GERAN_NOT_ALLOWED (1<<1) -#define OGS_ACCESS_RESTRICTION_GAN_NOT_ALLOWED (1<<2) -#define OGS_ACCESS_RESTRICTION_I_HSPA_EVOLUTION_NOT_ALLOWED (1<<3) -#define OGS_ACCESS_RESTRICTION_WB_E_UTRAN_NOT_ALLOWED (1<<4) -#define OGS_ACCESS_RESTRICTION_HO_TO_NON_3GPP_ACCESS_NOT_ALLOWED (1<<5) -#define OGS_ACCESS_RESTRICTION_NB_IOT_NOT_ALLOWED (1<<6) - uint32_t access_restriction_data; -#define OGS_SUBSCRIBER_STATUS_SERVICE_GRANTED 0 -#define OGS_SUBSCRIBER_STATUS_OPERATOR_DETERMINED_BARRING 1 - uint32_t subscriber_status; -#define OGS_NETWORK_ACCESS_MODE_PACKET_AND_CIRCUIT 0 -#define OGS_NETWORK_ACCESS_MODE_RESERVED 1 -#define OGS_NETWORK_ACCESS_MODE_ONLY_PACKET 2 - uint32_t network_access_mode; - - ogs_bitrate_t ambr; /* UE-AMBR */ - -#define OGS_RAU_TAU_DEFAULT_TIME (12*60) /* 12 min */ - uint32_t subscribed_rau_tau_timer; /* unit : seconds */ - - int num_of_slice; - ogs_slice_data_t sliceOGS_MAX_NUM_OF_SLICE; - -#define OGS_MAX_NUM_OF_MSISDN 2 - int num_of_msisdn; - struct { - uint8_t bufOGS_MAX_MSISDN_LEN; - int len; - char bcdOGS_MAX_MSISDN_BCD_LEN+1; - } msisdnOGS_MAX_NUM_OF_MSISDN; -} ogs_subscription_data_t; - -void ogs_subscription_data_free(ogs_subscription_data_t *subscription_data); - -typedef struct ogs_session_data_s { - ogs_session_t session; -#define OGS_MAX_NUM_OF_PCC_RULE 8 /* Num of PCC Rule */ - ogs_pcc_rule_t pcc_ruleOGS_MAX_NUM_OF_PCC_RULE; - int num_of_pcc_rule; -} ogs_session_data_t; - -void ogs_session_data_free(ogs_session_data_t *session_data); - -typedef struct ogs_media_sub_component_s { - uint32_t flow_number; -/* - * TS29.214 - * 5.3.12 Flow-Usage AVP - * NO_INFORMATION(0) - * RTCP(1) - * AF_SIGNALLING(2) - * - * TS29.514 - * 5.6.3.14 Enumeration: FlowUsage - * NO_INFO : 1 - * RTCP : 2 - * AF_SIGNALLING : 3 - * - * EPC and 5GC have different values for FlowUsage - * At this point, we will use the 5GC value. - */ -#define OGS_FLOW_USAGE_NO_INFO 1 -#define OGS_FLOW_USAGE_RTCP 2 -#define OGS_FLOW_USAGE_AF_SIGNALLING 3 - uint32_t flow_usage; - ogs_flow_t flowOGS_MAX_NUM_OF_FLOW_IN_MEDIA_SUB_COMPONENT; - int num_of_flow; -} ogs_media_sub_component_t; - -typedef struct ogs_media_component_s { - uint32_t media_component_number; - uint32_t media_type; - - uint64_t max_requested_bandwidth_dl; - uint64_t max_requested_bandwidth_ul; - uint64_t min_requested_bandwidth_dl; - uint64_t min_requested_bandwidth_ul; - uint64_t rr_bandwidth; - uint64_t rs_bandwidth; - - int flow_status; - -#define OGS_MAX_NUM_OF_MEDIA_SUB_COMPONENT 8 - ogs_media_sub_component_t subOGS_MAX_NUM_OF_MEDIA_SUB_COMPONENT; - int num_of_sub; -} ogs_media_component_t; - -typedef struct ogs_ims_data_s { - int num_of_msisdn; - struct { - uint8_t bufOGS_MAX_MSISDN_LEN; - int len; - char bcdOGS_MAX_MSISDN_BCD_LEN+1; - } msisdnOGS_MAX_NUM_OF_MSISDN; - -#define OGS_MAX_NUM_OF_MEDIA_COMPONENT 16 - ogs_media_component_t media_componentOGS_MAX_NUM_OF_MEDIA_COMPONENT; - int num_of_media_component; -} ogs_ims_data_t; - -void ogs_ims_data_free(ogs_ims_data_t *ims_data); - -int ogs_pcc_rule_num_of_flow_equal_to_media( - ogs_pcc_rule_t *pcc_rule, ogs_media_component_t *media_component); -int ogs_pcc_rule_install_flow_from_media( - ogs_pcc_rule_t *pcc_rule, ogs_media_component_t *media_component); -int ogs_pcc_rule_update_qos_from_media( - ogs_pcc_rule_t *pcc_rule, ogs_media_component_t *media_component); - -#ifdef __cplusplus -} -#endif - -#endif /* OGS_3GPP_TYPES_H */
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/amf/nf-sm.c
Deleted
@@ -1,467 +0,0 @@ -/* - * Copyright (C) 2019,2020 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/>. - */ - -#include "context.h" - -#include "sbi-path.h" -#include "nnrf-handler.h" - -void amf_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance) -{ - amf_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_create(&nf_instance->sm, - amf_nf_state_initial, amf_nf_state_final); - ogs_fsm_init(&nf_instance->sm, &e); -} - -void amf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance) -{ - amf_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_fini(&nf_instance->sm, &e); - ogs_fsm_delete(&nf_instance->sm); -} - -void amf_nf_state_initial(ogs_fsm_t *s, amf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - amf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - nf_instance->t_registration_interval = ogs_timer_add(ogs_app()->timer_mgr, - amf_timer_nf_instance_registration_interval, nf_instance); - ogs_assert(nf_instance->t_registration_interval); - nf_instance->t_heartbeat_interval = ogs_timer_add(ogs_app()->timer_mgr, - amf_timer_nf_instance_heartbeat_interval, nf_instance); - ogs_assert(nf_instance->t_heartbeat_interval); - nf_instance->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr, - amf_timer_nf_instance_no_heartbeat, nf_instance); - ogs_assert(nf_instance->t_no_heartbeat); - nf_instance->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - amf_timer_nf_instance_validity, nf_instance); - ogs_assert(nf_instance->t_validity); - - if (NF_INSTANCE_IS_NRF(nf_instance)) { - OGS_FSM_TRAN(s, &amf_nf_state_will_register); - } else { - ogs_assert(nf_instance->id); - OGS_FSM_TRAN(s, &amf_nf_state_registered); - } -} - -void amf_nf_state_final(ogs_fsm_t *s, amf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - amf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - ogs_timer_delete(nf_instance->t_registration_interval); - ogs_timer_delete(nf_instance->t_heartbeat_interval); - ogs_timer_delete(nf_instance->t_no_heartbeat); - ogs_timer_delete(nf_instance->t_validity); -} - -void amf_nf_state_will_register(ogs_fsm_t *s, amf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_sockaddr_t *addr = NULL; - - ogs_assert(s); - ogs_assert(e); - - amf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - ogs_assert(NF_INSTANCE_IS_NRF(nf_instance)); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, amf_nnrf_nfm_build_register)); - break; - - case OGS_FSM_EXIT_SIG: - ogs_timer_stop(nf_instance->t_registration_interval); - break; - - case AMF_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_OK || - message->res_status == OGS_SBI_HTTP_STATUS_CREATED) { - amf_nnrf_handle_nf_register(nf_instance, message); - OGS_FSM_TRAN(s, &amf_nf_state_registered); - } else { - ogs_error("%s HTTP Response Status Code %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &amf_nf_state_exception); - } - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case AMF_EVT_SBI_TIMER: - switch(e->timer_id) { - case AMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - client = nf_instance->client; - ogs_assert(client); - addr = client->node.addr; - ogs_assert(addr); - - ogs_warn("%s Retry to registration with NRF", - ogs_sbi_self()->nf_instance->id); - - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, amf_nnrf_nfm_build_register)); - break; - - default: - ogs_error("%s Unknown timer%s:%d", - ogs_sbi_self()->nf_instance->id, - amf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("Unknown event %s", amf_event_get_name(e)); - break; - } -} - -void amf_nf_state_registered(ogs_fsm_t *s, amf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_assert(s); - ogs_assert(e); - - amf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF registered Heartbeat:%ds", - ogs_sbi_self()->nf_instance->id, - nf_instance->time.heartbeat_interval); - - client = nf_instance->client; - ogs_assert(client); - - if (nf_instance->time.heartbeat_interval) { - ogs_timer_start(nf_instance->t_heartbeat_interval, - ogs_time_from_sec(nf_instance->time.heartbeat_interval)); - ogs_timer_start(nf_instance->t_no_heartbeat, - ogs_time_from_sec( - nf_instance->time.heartbeat_interval + - ogs_app()->time.nf_instance.no_heartbeat_margin)); - } - - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_AUSF)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_UDM)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_PCF)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_SMF)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_NSSF)); - } - - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - - if (nf_instance->time.heartbeat_interval) { - ogs_timer_stop(nf_instance->t_heartbeat_interval); - ogs_timer_stop(nf_instance->t_no_heartbeat); - } - - if (!OGS_FSM_CHECK(&nf_instance->sm, amf_nf_state_exception)) { - ogs_assert(true == - ogs_nnrf_nfm_send_nf_de_register(nf_instance)); - } - } - break; - - case AMF_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_NO_CONTENT || - message->res_status == OGS_SBI_HTTP_STATUS_OK) { - if (nf_instance->time.heartbeat_interval) - ogs_timer_start(nf_instance->t_no_heartbeat, - ogs_time_from_sec( - nf_instance->time.heartbeat_interval + - ogs_app()->time.nf_instance. - no_heartbeat_margin)); - } else { - ogs_warn("%s HTTP response error %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &amf_nf_state_exception); - } - - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case AMF_EVT_SBI_TIMER: - switch(e->timer_id) { - case AMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - if (nf_instance->time.heartbeat_interval) - ogs_timer_start(nf_instance->t_heartbeat_interval, - ogs_time_from_sec(nf_instance->time.heartbeat_interval)); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_update(nf_instance)); - break; - - case AMF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - ogs_error("%s No heartbeat", ogs_sbi_self()->nf_instance->id); - OGS_FSM_TRAN(s, &amf_nf_state_will_register); - break; - - case AMF_TIMER_NF_INSTANCE_VALIDITY: - ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance)); - ogs_assert(nf_instance->id); - - ogs_info("%s NF expired", nf_instance->id); - OGS_FSM_TRAN(s, &amf_nf_state_de_registered); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - amf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - amf_event_get_name(e)); - break; - } -} - -void amf_nf_state_de_registered(ogs_fsm_t *s, amf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_assert(s); - ogs_assert(e); - - amf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - } - break; - - case OGS_FSM_EXIT_SIG: - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - amf_event_get_name(e)); - break; - } -} - -void amf_nf_state_exception(ogs_fsm_t *s, amf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_sockaddr_t *addr = NULL; - ogs_assert(s); - ogs_assert(e); - - amf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi. - nf_register_interval_in_exception); - } - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_timer_stop(nf_instance->t_registration_interval); - } - break; - - case AMF_EVT_SBI_TIMER: - switch(e->timer_id) { - case AMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - client = nf_instance->client; - ogs_assert(client); - addr = client->node.addr; - ogs_assert(addr); - - ogs_warn("%s Retry to registration with NRF", - ogs_sbi_self()->nf_instance->id); - - OGS_FSM_TRAN(s, &amf_nf_state_will_register); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - amf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - case AMF_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - break; - DEFAULT - ogs_error("Invalid resource name %s", - message->h.resource.component0); - END - break; - DEFAULT - ogs_error("Invalid API name %s", message->h.service.name); - END - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - amf_event_get_name(e)); - break; - } -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/ausf/nf-sm.c
Deleted
@@ -1,447 +0,0 @@ -/* - * Copyright (C) 2019,2020 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/>. - */ - -#include "context.h" - -#include "sbi-path.h" -#include "nnrf-handler.h" - -void ausf_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance) -{ - ausf_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_create(&nf_instance->sm, - ausf_nf_state_initial, ausf_nf_state_final); - ogs_fsm_init(&nf_instance->sm, &e); -} - -void ausf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance) -{ - ausf_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_fini(&nf_instance->sm, &e); - ogs_fsm_delete(&nf_instance->sm); -} - -void ausf_nf_state_initial(ogs_fsm_t *s, ausf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - ausf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - nf_instance->t_registration_interval = ogs_timer_add(ogs_app()->timer_mgr, - ausf_timer_nf_instance_registration_interval, nf_instance); - ogs_assert(nf_instance->t_registration_interval); - nf_instance->t_heartbeat_interval = ogs_timer_add(ogs_app()->timer_mgr, - ausf_timer_nf_instance_heartbeat_interval, nf_instance); - ogs_assert(nf_instance->t_heartbeat_interval); - nf_instance->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr, - ausf_timer_nf_instance_no_heartbeat, nf_instance); - ogs_assert(nf_instance->t_no_heartbeat); - nf_instance->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - ausf_timer_nf_instance_validity, nf_instance); - ogs_assert(nf_instance->t_validity); - - if (NF_INSTANCE_IS_NRF(nf_instance)) { - OGS_FSM_TRAN(s, &ausf_nf_state_will_register); - } else { - ogs_assert(nf_instance->id); - OGS_FSM_TRAN(s, &ausf_nf_state_registered); - } -} - -void ausf_nf_state_final(ogs_fsm_t *s, ausf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - ausf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - ogs_timer_delete(nf_instance->t_registration_interval); - ogs_timer_delete(nf_instance->t_heartbeat_interval); - ogs_timer_delete(nf_instance->t_no_heartbeat); - ogs_timer_delete(nf_instance->t_validity); -} - -void ausf_nf_state_will_register(ogs_fsm_t *s, ausf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_sockaddr_t *addr = NULL; - - ogs_assert(s); - ogs_assert(e); - - ausf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - ogs_assert(NF_INSTANCE_IS_NRF(nf_instance)); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, ausf_nnrf_nfm_build_register)); - break; - - case OGS_FSM_EXIT_SIG: - ogs_timer_stop(nf_instance->t_registration_interval); - break; - - case AUSF_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_OK || - message->res_status == OGS_SBI_HTTP_STATUS_CREATED) { - ausf_nnrf_handle_nf_register(nf_instance, message); - OGS_FSM_TRAN(s, &ausf_nf_state_registered); - } else { - ogs_error("%s HTTP response error %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &ausf_nf_state_exception); - } - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case AUSF_EVT_SBI_TIMER: - switch(e->timer_id) { - case AUSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - client = nf_instance->client; - ogs_assert(client); - addr = client->node.addr; - ogs_assert(addr); - - ogs_warn("%s Retry to registration with NRF", - ogs_sbi_self()->nf_instance->id); - - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, ausf_nnrf_nfm_build_register)); - break; - - default: - ogs_error("%s Unknown timer%s:%d", - ogs_sbi_self()->nf_instance->id, - ausf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("Unknown event %s", ausf_event_get_name(e)); - break; - } -} - -void ausf_nf_state_registered(ogs_fsm_t *s, ausf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_assert(s); - ogs_assert(e); - - ausf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF registered Heartbeat:%ds", - ogs_sbi_self()->nf_instance->id, - nf_instance->time.heartbeat_interval); - - client = nf_instance->client; - ogs_assert(client); - - if (nf_instance->time.heartbeat_interval) { - ogs_timer_start(nf_instance->t_heartbeat_interval, - ogs_time_from_sec(nf_instance->time.heartbeat_interval)); - ogs_timer_start(nf_instance->t_no_heartbeat, - ogs_time_from_sec( - nf_instance->time.heartbeat_interval + - ogs_app()->time.nf_instance.no_heartbeat_margin)); - } - - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_UDM)); - } - - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - - if (nf_instance->time.heartbeat_interval) { - ogs_timer_stop(nf_instance->t_heartbeat_interval); - ogs_timer_stop(nf_instance->t_no_heartbeat); - } - - if (!OGS_FSM_CHECK(&nf_instance->sm, ausf_nf_state_exception)) { - ogs_assert(true == - ogs_nnrf_nfm_send_nf_de_register(nf_instance)); - } - } - break; - - case AUSF_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_NO_CONTENT || - message->res_status == OGS_SBI_HTTP_STATUS_OK) { - if (nf_instance->time.heartbeat_interval) - ogs_timer_start(nf_instance->t_no_heartbeat, - ogs_time_from_sec( - nf_instance->time.heartbeat_interval + - ogs_app()->time.nf_instance. - no_heartbeat_margin)); - } else { - ogs_warn("%s HTTP response error %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &ausf_nf_state_exception); - } - - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case AUSF_EVT_SBI_TIMER: - switch(e->timer_id) { - case AUSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - if (nf_instance->time.heartbeat_interval) - ogs_timer_start(nf_instance->t_heartbeat_interval, - ogs_time_from_sec(nf_instance->time.heartbeat_interval)); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_update(nf_instance)); - break; - - case AUSF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - ogs_error("%s No heartbeat", ogs_sbi_self()->nf_instance->id); - OGS_FSM_TRAN(s, &ausf_nf_state_will_register); - break; - - case AUSF_TIMER_NF_INSTANCE_VALIDITY: - ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance)); - ogs_assert(nf_instance->id); - - ogs_info("%s NF expired", nf_instance->id); - OGS_FSM_TRAN(s, &ausf_nf_state_de_registered); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - ausf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - ausf_event_get_name(e)); - break; - } -} - -void ausf_nf_state_de_registered(ogs_fsm_t *s, ausf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_assert(s); - ogs_assert(e); - - ausf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - } - break; - - case OGS_FSM_EXIT_SIG: - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - ausf_event_get_name(e)); - break; - } -} - -void ausf_nf_state_exception(ogs_fsm_t *s, ausf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_sockaddr_t *addr = NULL; - ogs_assert(s); - ogs_assert(e); - - ausf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi. - nf_register_interval_in_exception); - } - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_timer_stop(nf_instance->t_registration_interval); - } - break; - - case AUSF_EVT_SBI_TIMER: - switch(e->timer_id) { - case AUSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - client = nf_instance->client; - ogs_assert(client); - addr = client->node.addr; - ogs_assert(addr); - - ogs_warn("%s Retry to registration with NRF", - ogs_sbi_self()->nf_instance->id); - - OGS_FSM_TRAN(s, &ausf_nf_state_will_register); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - ausf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - case AUSF_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - break; - DEFAULT - ogs_error("Invalid resource name %s", - message->h.resource.component0); - END - break; - DEFAULT - ogs_error("Invalid API name %s", message->h.service.name); - END - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - ausf_event_get_name(e)); - break; - } -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/ausf/nnrf-build.c
Deleted
@@ -1,55 +0,0 @@ -/* - * Copyright (C) 2019,2020 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/>. - */ - -#include "nnrf-build.h" - -ogs_sbi_request_t *ausf_nnrf_nfm_build_register(void) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_request_t *request = NULL; - - OpenAPI_nf_profile_t *NFProfile = NULL; - - nf_instance = ogs_sbi_self()->nf_instance; - ogs_assert(nf_instance); - ogs_assert(nf_instance->id); - - memset(&message, 0, sizeof(message)); - message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT; - message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; - message.h.api.version = (char *)OGS_SBI_API_V1; - message.h.resource.component0 = - (char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES; - message.h.resource.component1 = nf_instance->id; - - message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding; - - NFProfile = ogs_nnrf_nfm_build_nf_profile(); - ogs_expect_or_return_val(NFProfile, NULL); - - message.NFProfile = NFProfile; - - request = ogs_sbi_build_request(&message); - - ogs_sbi_nnrf_free_nf_profile(NFProfile); - - return request; -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/ausf/nnrf-build.h
Deleted
@@ -1,35 +0,0 @@ -/* - * Copyright (C) 2019,2020 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 AUSF_NNRF_BUILD_H -#define AUSF_NNRF_BUILD_H - -#include "context.h" - -#ifdef __cplusplus -extern "C" { -#endif - -ogs_sbi_request_t *ausf_nnrf_nfm_build_register(void); - -#ifdef __cplusplus -} -#endif - -#endif /* AUSF_NNRF_BUILD_H */
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/ausf/timer.c
Deleted
@@ -1,116 +0,0 @@ -/* - * Copyright (C) 2019,2020 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/>. - */ - -#include "context.h" - -const char *ausf_timer_get_name(ausf_timer_e id) -{ - switch (id) { - case AUSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - return "AUSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL"; - case AUSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - return "AUSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL"; - case AUSF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - return "AUSF_TIMER_NF_INSTANCE_NO_HEARTBEAT"; - case AUSF_TIMER_NF_INSTANCE_VALIDITY: - return "AUSF_TIMER_NF_INSTANCE_VALIDITY"; - case AUSF_TIMER_SUBSCRIPTION_VALIDITY: - return "AUSF_TIMER_SUBSCRIPTION_VALIDITY"; - case AUSF_TIMER_SBI_CLIENT_WAIT: - return "AUSF_TIMER_SBI_CLIENT_WAIT"; - default: - break; - } - - return "UNKNOWN_TIMER"; -} - -static void sbi_timer_send_event(int timer_id, void *data) -{ - int rv; - ausf_event_t *e = NULL; - ogs_assert(data); - - switch (timer_id) { - case AUSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case AUSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case AUSF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case AUSF_TIMER_NF_INSTANCE_VALIDITY: - case AUSF_TIMER_SUBSCRIPTION_VALIDITY: - e = ausf_event_new(AUSF_EVT_SBI_TIMER); - ogs_assert(e); - e->timer_id = timer_id; - e->sbi.data = data; - break; - case AUSF_TIMER_SBI_CLIENT_WAIT: - e = ausf_event_new(AUSF_EVT_SBI_TIMER); - if (!e) { - ogs_sbi_xact_t *sbi_xact = data; - ogs_assert(sbi_xact); - - ogs_error("sbi_timer_send_event() failed"); - ogs_sbi_xact_remove(sbi_xact); - return; - } - e->timer_id = timer_id; - e->sbi.data = data; - break; - default: - ogs_fatal("Unknown timer id%d", timer_id); - ogs_assert_if_reached(); - break; - } - - rv = ogs_queue_push(ogs_app()->queue, e); - if (rv != OGS_OK) { - ogs_error("ogs_queue_push() failed %d in %s", - (int)rv, ausf_timer_get_name(e->timer_id)); - ausf_event_free(e); - } -} - -void ausf_timer_nf_instance_registration_interval(void *data) -{ - sbi_timer_send_event(AUSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, data); -} - -void ausf_timer_nf_instance_heartbeat_interval(void *data) -{ - sbi_timer_send_event(AUSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, data); -} - -void ausf_timer_nf_instance_no_heartbeat(void *data) -{ - sbi_timer_send_event(AUSF_TIMER_NF_INSTANCE_NO_HEARTBEAT, data); -} - -void ausf_timer_nf_instance_validity(void *data) -{ - sbi_timer_send_event(AUSF_TIMER_NF_INSTANCE_VALIDITY, data); -} - -void ausf_timer_subscription_validity(void *data) -{ - sbi_timer_send_event(AUSF_TIMER_SUBSCRIPTION_VALIDITY, data); -} - -void ausf_timer_sbi_client_wait_expire(void *data) -{ - sbi_timer_send_event(AUSF_TIMER_SBI_CLIENT_WAIT, data); -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/ausf/timer.h
Deleted
@@ -1,57 +0,0 @@ -/* - * 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 AUSF_TIMER_H -#define AUSF_TIMER_H - -#include "ogs-core.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* forward declaration */ -typedef enum { - AUSF_TIMER_BASE = 0, - - AUSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, - AUSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, - AUSF_TIMER_NF_INSTANCE_NO_HEARTBEAT, - AUSF_TIMER_NF_INSTANCE_VALIDITY, - AUSF_TIMER_SUBSCRIPTION_VALIDITY, - AUSF_TIMER_SBI_CLIENT_WAIT, - - MAX_NUM_OF_AUSF_TIMER, - -} ausf_timer_e; - -const char *ausf_timer_get_name(ausf_timer_e id); - -void ausf_timer_nf_instance_registration_interval(void *data); -void ausf_timer_nf_instance_heartbeat_interval(void *data); -void ausf_timer_nf_instance_no_heartbeat(void *data); -void ausf_timer_nf_instance_validity(void *data); -void ausf_timer_subscription_validity(void *data); -void ausf_timer_sbi_client_wait_expire(void *data); - -#ifdef __cplusplus -} -#endif - -#endif /* AUSF_TIMER_H */
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/bsf/nf-sm.c
Deleted
@@ -1,442 +0,0 @@ -/* - * 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/>. - */ - -#include "context.h" - -#include "sbi-path.h" -#include "nnrf-handler.h" - -void bsf_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance) -{ - bsf_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_create(&nf_instance->sm, - bsf_nf_state_initial, bsf_nf_state_final); - ogs_fsm_init(&nf_instance->sm, &e); -} - -void bsf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance) -{ - bsf_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_fini(&nf_instance->sm, &e); - ogs_fsm_delete(&nf_instance->sm); -} - -void bsf_nf_state_initial(ogs_fsm_t *s, bsf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - bsf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - nf_instance->t_registration_interval = ogs_timer_add(ogs_app()->timer_mgr, - bsf_timer_nf_instance_registration_interval, nf_instance); - ogs_assert(nf_instance->t_registration_interval); - nf_instance->t_heartbeat_interval = ogs_timer_add(ogs_app()->timer_mgr, - bsf_timer_nf_instance_heartbeat_interval, nf_instance); - ogs_assert(nf_instance->t_heartbeat_interval); - nf_instance->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr, - bsf_timer_nf_instance_no_heartbeat, nf_instance); - ogs_assert(nf_instance->t_no_heartbeat); - nf_instance->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - bsf_timer_nf_instance_validity, nf_instance); - ogs_assert(nf_instance->t_validity); - - if (NF_INSTANCE_IS_NRF(nf_instance)) { - OGS_FSM_TRAN(s, &bsf_nf_state_will_register); - } else { - ogs_assert(nf_instance->id); - OGS_FSM_TRAN(s, &bsf_nf_state_registered); - } -} - -void bsf_nf_state_final(ogs_fsm_t *s, bsf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - bsf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - ogs_timer_delete(nf_instance->t_registration_interval); - ogs_timer_delete(nf_instance->t_heartbeat_interval); - ogs_timer_delete(nf_instance->t_no_heartbeat); - ogs_timer_delete(nf_instance->t_validity); -} - -void bsf_nf_state_will_register(ogs_fsm_t *s, bsf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_sockaddr_t *addr = NULL; - - ogs_assert(s); - ogs_assert(e); - - bsf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - ogs_assert(NF_INSTANCE_IS_NRF(nf_instance)); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, bsf_nnrf_nfm_build_register)); - break; - - case OGS_FSM_EXIT_SIG: - ogs_timer_stop(nf_instance->t_registration_interval); - break; - - case BSF_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_OK || - message->res_status == OGS_SBI_HTTP_STATUS_CREATED) { - bsf_nnrf_handle_nf_register(nf_instance, message); - OGS_FSM_TRAN(s, &bsf_nf_state_registered); - } else { - ogs_error("%s HTTP Response Status Code %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &bsf_nf_state_exception); - } - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case BSF_EVT_SBI_TIMER: - switch(e->timer_id) { - case BSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - client = nf_instance->client; - ogs_assert(client); - addr = client->node.addr; - ogs_assert(addr); - - ogs_warn("%s Retry to registration with NRF", - ogs_sbi_self()->nf_instance->id); - - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, bsf_nnrf_nfm_build_register)); - break; - - default: - ogs_error("%s Unknown timer%s:%d", - ogs_sbi_self()->nf_instance->id, - bsf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s Unknown event %s", - ogs_sbi_self()->nf_instance->id, bsf_event_get_name(e)); - break; - } -} - -void bsf_nf_state_registered(ogs_fsm_t *s, bsf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_assert(s); - ogs_assert(e); - - bsf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF registered Heartbeat:%ds", - ogs_sbi_self()->nf_instance->id, - nf_instance->time.heartbeat_interval); - - client = nf_instance->client; - ogs_assert(client); - - if (nf_instance->time.heartbeat_interval) { - ogs_timer_start(nf_instance->t_heartbeat_interval, - ogs_time_from_sec(nf_instance->time.heartbeat_interval)); - ogs_timer_start(nf_instance->t_no_heartbeat, - ogs_time_from_sec( - nf_instance->time.heartbeat_interval + - ogs_app()->time.nf_instance.no_heartbeat_margin)); - } - } - - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - - if (nf_instance->time.heartbeat_interval) { - ogs_timer_stop(nf_instance->t_heartbeat_interval); - ogs_timer_stop(nf_instance->t_no_heartbeat); - } - - if (!OGS_FSM_CHECK(&nf_instance->sm, bsf_nf_state_exception)) { - ogs_assert(true == - ogs_nnrf_nfm_send_nf_de_register(nf_instance)); - } - } - break; - - case BSF_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_NO_CONTENT || - message->res_status == OGS_SBI_HTTP_STATUS_OK) { - if (nf_instance->time.heartbeat_interval) - ogs_timer_start(nf_instance->t_no_heartbeat, - ogs_time_from_sec( - nf_instance->time.heartbeat_interval + - ogs_app()->time.nf_instance. - no_heartbeat_margin)); - } else { - ogs_warn("%s HTTP response error %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &bsf_nf_state_exception); - } - - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case BSF_EVT_SBI_TIMER: - switch(e->timer_id) { - case BSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - if (nf_instance->time.heartbeat_interval) - ogs_timer_start(nf_instance->t_heartbeat_interval, - ogs_time_from_sec(nf_instance->time.heartbeat_interval)); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_update(nf_instance)); - break; - - case BSF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - ogs_error("%s No heartbeat", ogs_sbi_self()->nf_instance->id); - OGS_FSM_TRAN(s, &bsf_nf_state_will_register); - break; - - case BSF_TIMER_NF_INSTANCE_VALIDITY: - ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance)); - ogs_assert(nf_instance->id); - - ogs_info("%s NF expired", nf_instance->id); - OGS_FSM_TRAN(s, &bsf_nf_state_de_registered); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - bsf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - bsf_event_get_name(e)); - break; - } -} - -void bsf_nf_state_de_registered(ogs_fsm_t *s, bsf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_assert(s); - ogs_assert(e); - - bsf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - } - break; - - case OGS_FSM_EXIT_SIG: - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - bsf_event_get_name(e)); - break; - } -} - -void bsf_nf_state_exception(ogs_fsm_t *s, bsf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_sockaddr_t *addr = NULL; - ogs_assert(s); - ogs_assert(e); - - bsf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi. - nf_register_interval_in_exception); - } - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_timer_stop(nf_instance->t_registration_interval); - } - break; - - case BSF_EVT_SBI_TIMER: - switch(e->timer_id) { - case BSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - client = nf_instance->client; - ogs_assert(client); - addr = client->node.addr; - ogs_assert(addr); - - ogs_warn("%s Retry to registration with NRF", - ogs_sbi_self()->nf_instance->id); - - OGS_FSM_TRAN(s, &bsf_nf_state_will_register); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - bsf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - case BSF_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - break; - DEFAULT - ogs_error("Invalid resource name %s", - message->h.resource.component0); - END - break; - DEFAULT - ogs_error("Invalid API name %s", message->h.service.name); - END - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - bsf_event_get_name(e)); - break; - } -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/bsf/nnrf-build.c
Deleted
@@ -1,55 +0,0 @@ -/* - * Copyright (C) 2019,2020 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/>. - */ - -#include "nnrf-build.h" - -ogs_sbi_request_t *bsf_nnrf_nfm_build_register(void) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_request_t *request = NULL; - - OpenAPI_nf_profile_t *NFProfile = NULL; - - nf_instance = ogs_sbi_self()->nf_instance; - ogs_assert(nf_instance); - ogs_assert(nf_instance->id); - - memset(&message, 0, sizeof(message)); - message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT; - message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; - message.h.api.version = (char *)OGS_SBI_API_V1; - message.h.resource.component0 = - (char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES; - message.h.resource.component1 = nf_instance->id; - - message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding; - - NFProfile = ogs_nnrf_nfm_build_nf_profile(); - ogs_expect_or_return_val(NFProfile, NULL); - - message.NFProfile = NFProfile; - - request = ogs_sbi_build_request(&message); - - ogs_sbi_nnrf_free_nf_profile(NFProfile); - - return request; -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/bsf/nnrf-build.h
Deleted
@@ -1,35 +0,0 @@ -/* - * Copyright (C) 2019,2020 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 BSF_NNRF_BUILD_H -#define BSF_NNRF_BUILD_H - -#include "context.h" - -#ifdef __cplusplus -extern "C" { -#endif - -ogs_sbi_request_t *bsf_nnrf_nfm_build_register(void); - -#ifdef __cplusplus -} -#endif - -#endif /* BSF_NNRF_BUILD_H */
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/bsf/timer.c
Deleted
@@ -1,118 +0,0 @@ -/* - * 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/>. - */ - -#include "timer.h" -#include "event.h" -#include "context.h" - -const char *bsf_timer_get_name(bsf_timer_e id) -{ - switch (id) { - case BSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - return "BSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL"; - case BSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - return "BSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL"; - case BSF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - return "BSF_TIMER_NF_INSTANCE_NO_HEARTBEAT"; - case BSF_TIMER_NF_INSTANCE_VALIDITY: - return "BSF_TIMER_NF_INSTANCE_VALIDITY"; - case BSF_TIMER_SUBSCRIPTION_VALIDITY: - return "BSF_TIMER_SUBSCRIPTION_VALIDITY"; - case BSF_TIMER_SBI_CLIENT_WAIT: - return "BSF_TIMER_SBI_CLIENT_WAIT"; - default: - break; - } - - return "UNKNOWN_TIMER"; -} - -static void timer_send_event(int timer_id, void *data) -{ - int rv; - bsf_event_t *e = NULL; - ogs_assert(data); - - switch (timer_id) { - case BSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case BSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case BSF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case BSF_TIMER_NF_INSTANCE_VALIDITY: - case BSF_TIMER_SUBSCRIPTION_VALIDITY: - e = bsf_event_new(BSF_EVT_SBI_TIMER); - ogs_assert(e); - e->timer_id = timer_id; - e->sbi.data = data; - break; - case BSF_TIMER_SBI_CLIENT_WAIT: - e = bsf_event_new(BSF_EVT_SBI_TIMER); - if (!e) { - ogs_sbi_xact_t *sbi_xact = data; - ogs_assert(sbi_xact); - - ogs_error("timer_send_event() failed"); - ogs_sbi_xact_remove(sbi_xact); - return; - } - e->timer_id = timer_id; - e->sbi.data = data; - break; - default: - ogs_fatal("Unknown timer id%d", timer_id); - ogs_assert_if_reached(); - break; - } - - rv = ogs_queue_push(ogs_app()->queue, e); - if (rv != OGS_OK) { - ogs_error("ogs_queue_push() failed %d in %s", - (int)rv, bsf_timer_get_name(e->timer_id)); - bsf_event_free(e); - } -} - -void bsf_timer_nf_instance_registration_interval(void *data) -{ - timer_send_event(BSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, data); -} - -void bsf_timer_nf_instance_heartbeat_interval(void *data) -{ - timer_send_event(BSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, data); -} - -void bsf_timer_nf_instance_no_heartbeat(void *data) -{ - timer_send_event(BSF_TIMER_NF_INSTANCE_NO_HEARTBEAT, data); -} - -void bsf_timer_nf_instance_validity(void *data) -{ - timer_send_event(BSF_TIMER_NF_INSTANCE_VALIDITY, data); -} - -void bsf_timer_subscription_validity(void *data) -{ - timer_send_event(BSF_TIMER_SUBSCRIPTION_VALIDITY, data); -} - -void bsf_timer_sbi_client_wait_expire(void *data) -{ - timer_send_event(BSF_TIMER_SBI_CLIENT_WAIT, data); -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/bsf/timer.h
Deleted
@@ -1,57 +0,0 @@ -/* - * 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 BSF_TIMER_H -#define BSF_TIMER_H - -#include "ogs-core.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* forward declaration */ -typedef enum { - BSF_TIMER_BASE = 0, - - BSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, - BSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, - BSF_TIMER_NF_INSTANCE_NO_HEARTBEAT, - BSF_TIMER_NF_INSTANCE_VALIDITY, - BSF_TIMER_SUBSCRIPTION_VALIDITY, - BSF_TIMER_SBI_CLIENT_WAIT, - - MAX_NUM_OF_BSF_TIMER, - -} bsf_timer_e; - -const char *bsf_timer_get_name(bsf_timer_e id); - -void bsf_timer_nf_instance_registration_interval(void *data); -void bsf_timer_nf_instance_heartbeat_interval(void *data); -void bsf_timer_nf_instance_no_heartbeat(void *data); -void bsf_timer_nf_instance_validity(void *data); -void bsf_timer_subscription_validity(void *data); -void bsf_timer_sbi_client_wait_expire(void *data); - -#ifdef __cplusplus -} -#endif - -#endif /* BSF_TIMER_H */
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/nssf/nf-sm.c
Deleted
@@ -1,441 +0,0 @@ -/* - * Copyright (C) 2019,2020 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/>. - */ - -#include "context.h" - -#include "sbi-path.h" -#include "nnrf-handler.h" - -void nssf_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance) -{ - nssf_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_create(&nf_instance->sm, - nssf_nf_state_initial, nssf_nf_state_final); - ogs_fsm_init(&nf_instance->sm, &e); -} - -void nssf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance) -{ - nssf_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_fini(&nf_instance->sm, &e); - ogs_fsm_delete(&nf_instance->sm); -} - -void nssf_nf_state_initial(ogs_fsm_t *s, nssf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - nssf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - nf_instance->t_registration_interval = ogs_timer_add(ogs_app()->timer_mgr, - nssf_timer_nf_instance_registration_interval, nf_instance); - ogs_assert(nf_instance->t_registration_interval); - nf_instance->t_heartbeat_interval = ogs_timer_add(ogs_app()->timer_mgr, - nssf_timer_nf_instance_heartbeat_interval, nf_instance); - ogs_assert(nf_instance->t_heartbeat_interval); - nf_instance->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr, - nssf_timer_nf_instance_no_heartbeat, nf_instance); - ogs_assert(nf_instance->t_no_heartbeat); - nf_instance->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - nssf_timer_nf_instance_validity, nf_instance); - ogs_assert(nf_instance->t_validity); - - if (NF_INSTANCE_IS_NRF(nf_instance)) { - OGS_FSM_TRAN(s, &nssf_nf_state_will_register); - } else { - ogs_assert(nf_instance->id); - OGS_FSM_TRAN(s, &nssf_nf_state_registered); - } -} - -void nssf_nf_state_final(ogs_fsm_t *s, nssf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - nssf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - ogs_timer_delete(nf_instance->t_registration_interval); - ogs_timer_delete(nf_instance->t_heartbeat_interval); - ogs_timer_delete(nf_instance->t_no_heartbeat); - ogs_timer_delete(nf_instance->t_validity); -} - -void nssf_nf_state_will_register(ogs_fsm_t *s, nssf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_sockaddr_t *addr = NULL; - - ogs_assert(s); - ogs_assert(e); - - nssf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - ogs_assert(NF_INSTANCE_IS_NRF(nf_instance)); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, nssf_nnrf_nfm_build_register)); - break; - - case OGS_FSM_EXIT_SIG: - ogs_timer_stop(nf_instance->t_registration_interval); - break; - - case NSSF_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_OK || - message->res_status == OGS_SBI_HTTP_STATUS_CREATED) { - nssf_nnrf_handle_nf_register(nf_instance, message); - OGS_FSM_TRAN(s, &nssf_nf_state_registered); - } else { - ogs_error("%s HTTP response error %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &nssf_nf_state_exception); - } - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case NSSF_EVT_SBI_TIMER: - switch(e->timer_id) { - case NSSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - client = nf_instance->client; - ogs_assert(client); - addr = client->node.addr; - ogs_assert(addr); - - ogs_warn("%s Retry to registration with NRF", - ogs_sbi_self()->nf_instance->id); - - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, nssf_nnrf_nfm_build_register)); - break; - - default: - ogs_error("%s Unknown timer%s:%d", - ogs_sbi_self()->nf_instance->id, - nssf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("Unknown event %s", nssf_event_get_name(e)); - break; - } -} - -void nssf_nf_state_registered(ogs_fsm_t *s, nssf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_assert(s); - ogs_assert(e); - - nssf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF registered Heartbeat:%ds", - ogs_sbi_self()->nf_instance->id, - nf_instance->time.heartbeat_interval); - - client = nf_instance->client; - ogs_assert(client); - - if (nf_instance->time.heartbeat_interval) { - ogs_timer_start(nf_instance->t_heartbeat_interval, - ogs_time_from_sec(nf_instance->time.heartbeat_interval)); - ogs_timer_start(nf_instance->t_no_heartbeat, - ogs_time_from_sec( - nf_instance->time.heartbeat_interval + - ogs_app()->time.nf_instance.no_heartbeat_margin)); - } - } - - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - - if (nf_instance->time.heartbeat_interval) { - ogs_timer_stop(nf_instance->t_heartbeat_interval); - ogs_timer_stop(nf_instance->t_no_heartbeat); - } - - if (!OGS_FSM_CHECK(&nf_instance->sm, nssf_nf_state_exception)) { - ogs_assert(true == - ogs_nnrf_nfm_send_nf_de_register(nf_instance)); - } - } - break; - - case NSSF_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_NO_CONTENT || - message->res_status == OGS_SBI_HTTP_STATUS_OK) { - if (nf_instance->time.heartbeat_interval) - ogs_timer_start(nf_instance->t_no_heartbeat, - ogs_time_from_sec( - nf_instance->time.heartbeat_interval + - ogs_app()->time.nf_instance. - no_heartbeat_margin)); - } else { - ogs_warn("%s HTTP response error %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &nssf_nf_state_exception); - } - - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case NSSF_EVT_SBI_TIMER: - switch(e->timer_id) { - case NSSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - if (nf_instance->time.heartbeat_interval) - ogs_timer_start(nf_instance->t_heartbeat_interval, - ogs_time_from_sec(nf_instance->time.heartbeat_interval)); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_update(nf_instance)); - break; - - case NSSF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - ogs_error("%s No heartbeat", ogs_sbi_self()->nf_instance->id); - OGS_FSM_TRAN(s, &nssf_nf_state_will_register); - break; - - case NSSF_TIMER_NF_INSTANCE_VALIDITY: - ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance)); - ogs_assert(nf_instance->id); - - ogs_info("%s NF expired", nf_instance->id); - OGS_FSM_TRAN(s, &nssf_nf_state_de_registered); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - nssf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - nssf_event_get_name(e)); - break; - } -} - -void nssf_nf_state_de_registered(ogs_fsm_t *s, nssf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_assert(s); - ogs_assert(e); - - nssf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - } - break; - - case OGS_FSM_EXIT_SIG: - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - nssf_event_get_name(e)); - break; - } -} - -void nssf_nf_state_exception(ogs_fsm_t *s, nssf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_sockaddr_t *addr = NULL; - ogs_assert(s); - ogs_assert(e); - - nssf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi. - nf_register_interval_in_exception); - } - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_timer_stop(nf_instance->t_registration_interval); - } - break; - - case NSSF_EVT_SBI_TIMER: - switch(e->timer_id) { - case NSSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - client = nf_instance->client; - ogs_assert(client); - addr = client->node.addr; - ogs_assert(addr); - - ogs_warn("%s Retry to registration with NRF", - ogs_sbi_self()->nf_instance->id); - - OGS_FSM_TRAN(s, &nssf_nf_state_will_register); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - nssf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - case NSSF_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - break; - DEFAULT - ogs_error("Invalid resource name %s", - message->h.resource.component0); - END - break; - DEFAULT - ogs_error("Invalid API name %s", message->h.service.name); - END - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - nssf_event_get_name(e)); - break; - } -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/nssf/nnrf-build.c
Deleted
@@ -1,55 +0,0 @@ -/* - * Copyright (C) 2019,2020 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/>. - */ - -#include "nnrf-build.h" - -ogs_sbi_request_t *nssf_nnrf_nfm_build_register(void) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_request_t *request = NULL; - - OpenAPI_nf_profile_t *NFProfile = NULL; - - nf_instance = ogs_sbi_self()->nf_instance; - ogs_assert(nf_instance); - ogs_assert(nf_instance->id); - - memset(&message, 0, sizeof(message)); - message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT; - message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; - message.h.api.version = (char *)OGS_SBI_API_V1; - message.h.resource.component0 = - (char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES; - message.h.resource.component1 = nf_instance->id; - - message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding; - - NFProfile = ogs_nnrf_nfm_build_nf_profile(); - ogs_expect_or_return_val(NFProfile, NULL); - - message.NFProfile = NFProfile; - - request = ogs_sbi_build_request(&message); - - ogs_sbi_nnrf_free_nf_profile(NFProfile); - - return request; -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/nssf/nnrf-build.h
Deleted
@@ -1,35 +0,0 @@ -/* - * Copyright (C) 2019,2020 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 NSSF_NNRF_BUILD_H -#define NSSF_NNRF_BUILD_H - -#include "context.h" - -#ifdef __cplusplus -extern "C" { -#endif - -ogs_sbi_request_t *nssf_nnrf_nfm_build_register(void); - -#ifdef __cplusplus -} -#endif - -#endif /* NSSF_NNRF_BUILD_H */
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/nssf/nnrf-handler.c
Deleted
@@ -1,247 +0,0 @@ -/* - * Copyright (C) 2019,2020 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/>. - */ - -#include "sbi-path.h" -#include "nnrf-handler.h" - -void nssf_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_nf_profile_t *NFProfile = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(nf_instance); - client = nf_instance->client; - ogs_assert(client); - - NFProfile = recvmsg->NFProfile; - if (!NFProfile) { - ogs_error("No NFProfile"); - return; - } - - /* TIME : Update heartbeat from NRF */ - if (NFProfile->is_heart_beat_timer == true) - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; -} - -void nssf_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_subscription_data_t *SubscriptionData = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(subscription); - client = subscription->client; - ogs_assert(client); - - SubscriptionData = recvmsg->SubscriptionData; - if (!SubscriptionData) { - ogs_error("No SubscriptionData"); - return; - } - - if (!SubscriptionData->subscription_id) { - ogs_error("No SubscriptionId"); - return; - } - ogs_sbi_subscription_set_id( - subscription, SubscriptionData->subscription_id); - - if (SubscriptionData->validity_time) { -#define VALIDITY_MINIMUM (10LL * OGS_USEC_PER_SEC) /* 10 seconds */ - ogs_time_t time, duration; - if (ogs_sbi_time_from_string( - &time, SubscriptionData->validity_time) == true) { - duration = time - ogs_time_now(); - if (duration < VALIDITY_MINIMUM) { - duration = VALIDITY_MINIMUM; - ogs_warn("%s Forced to %lld seconds", subscription->id, - (long long)ogs_time_sec(VALIDITY_MINIMUM)); - } - subscription->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - nssf_timer_subscription_validity, subscription); - ogs_assert(subscription->t_validity); - ogs_timer_start(subscription->t_validity, duration); - } else { - ogs_error("Cannot parse validitiyTime %s", - SubscriptionData->validity_time); - } - } -} - -bool nssf_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) -{ - int rv; - bool handled; - - ogs_sbi_response_t *response = NULL; - OpenAPI_notification_data_t *NotificationData = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_header_t header; - - ogs_assert(stream); - ogs_assert(recvmsg); - - NotificationData = recvmsg->NotificationData; - if (!NotificationData) { - ogs_error("No NotificationData"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NotificationData", NULL)); - return false; - } - - if (!NotificationData->nf_instance_uri) { - ogs_error("No nfInstanceUri"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No nfInstanceUri", NULL)); - return false; - } - - memset(&header, 0, sizeof(header)); - header.uri = NotificationData->nf_instance_uri; - - rv = ogs_sbi_parse_header(&message, &header); - if (rv != OGS_OK) { - ogs_error("Cannot parse nfInstanceUri %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - return false; - } - - if (!message.h.resource.component1) { - ogs_error("No nfInstanceId %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - ogs_sbi_header_free(&header); - return false; - } - - if (NF_INSTANCE_IS_SELF(message.h.resource.component1)) { - ogs_warn("%s The notification is not allowed", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_FORBIDDEN, - recvmsg, "The notification is not allowed", - message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - - if (NotificationData->event == - OpenAPI_notification_event_type_NF_REGISTERED) { - - OpenAPI_nf_profile_t *NFProfile = NULL; - - NFProfile = NotificationData->nf_profile; - if (!NFProfile) { - ogs_error("No NFProfile"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NFProfile", NULL)); - ogs_sbi_header_free(&header); - return false; - } - - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, - message.h.resource.component1); - - nssf_nf_fsm_init(nf_instance); - - ogs_info("%s (NRF-notify) NF registered", nf_instance->id); - - } else { - OGS_FSM_TRAN(&nf_instance->sm, nssf_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NRF-notify) NF has already been added", - message.h.resource.component1); - - } - - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, stream, recvmsg); - if (!handled) { - NSSF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - ogs_info("%s (NRF-notify) NF Profile updated", nf_instance->id); - - handled = ogs_sbi_client_associate(nf_instance); - if (!handled) { - ogs_error("%s Cannot associate NF EndPoint", nf_instance->id); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot find NF EndPoint", nf_instance->id)); - NSSF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - } else if (NotificationData->event == - OpenAPI_notification_event_type_NF_DEREGISTERED) { - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (nf_instance) { - NSSF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - } else { - ogs_warn("%s (NRF-notify) Not found", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_NOT_FOUND, - recvmsg, "Not found", message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - } else { - char *eventstr = OpenAPI_notification_event_type_ToString( - NotificationData->event); - ogs_error("Not supported event %d:%s", - NotificationData->event, eventstr ? eventstr : "Unknown"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Not supported event", - eventstr ? eventstr : "Unknown")); - ogs_sbi_header_free(&header); - return false; - } - - response = ogs_sbi_build_response(recvmsg, OGS_SBI_HTTP_STATUS_NO_CONTENT); - ogs_assert(response); - ogs_assert(true == ogs_sbi_server_send_response(stream, response)); - - ogs_sbi_header_free(&header); - return true; -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/nssf/nnrf-handler.h
Deleted
@@ -1,41 +0,0 @@ -/* - * Copyright (C) 2019,2020 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 NSSF_NNRF_HANDLER_H -#define NSSF_NNRF_HANDLER_H - -#include "context.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void nssf_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg); -void nssf_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg); - -bool nssf_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); - -#ifdef __cplusplus -} -#endif - -#endif /* NSSF_NNRF_HANDLER_H */
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/nssf/timer.c
Deleted
@@ -1,101 +0,0 @@ -/* - * Copyright (C) 2019,2020 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/>. - */ - -#include "context.h" - -const char *nssf_timer_get_name(nssf_timer_e id) -{ - switch (id) { - case NSSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - return "NSSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL"; - case NSSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - return "NSSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL"; - case NSSF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - return "NSSF_TIMER_NF_INSTANCE_NO_HEARTBEAT"; - case NSSF_TIMER_NF_INSTANCE_VALIDITY: - return "NSSF_TIMER_NF_INSTANCE_VALIDITY"; - case NSSF_TIMER_SUBSCRIPTION_VALIDITY: - return "NSSF_TIMER_SUBSCRIPTION_VALIDITY"; - default: - break; - } - - return "UNKNOWN_TIMER"; -} - -static void sbi_timer_send_event(int timer_id, void *data) -{ - int rv; - nssf_event_t *e = NULL; - ogs_assert(data); - - switch (timer_id) { - case NSSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case NSSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case NSSF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case NSSF_TIMER_NF_INSTANCE_VALIDITY: - case NSSF_TIMER_SUBSCRIPTION_VALIDITY: - e = nssf_event_new(NSSF_EVT_SBI_TIMER); - ogs_assert(e); - e->timer_id = timer_id; - e->sbi.data = data; - break; - default: - ogs_fatal("Unknown timer id%d", timer_id); - ogs_assert_if_reached(); - break; - } - - rv = ogs_queue_push(ogs_app()->queue, e); - if (rv != OGS_OK) { - ogs_error("ogs_queue_push() failed %d in %s", - (int)rv, nssf_timer_get_name(e->timer_id)); - nssf_event_free(e); - } -} - -void nssf_timer_nf_instance_registration_interval(void *data) -{ - sbi_timer_send_event(NSSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, data); -} - -void nssf_timer_nf_instance_heartbeat_interval(void *data) -{ - sbi_timer_send_event(NSSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, data); -} - -void nssf_timer_nf_instance_no_heartbeat(void *data) -{ - sbi_timer_send_event(NSSF_TIMER_NF_INSTANCE_NO_HEARTBEAT, data); -} - -void nssf_timer_nf_instance_validity(void *data) -{ - sbi_timer_send_event(NSSF_TIMER_NF_INSTANCE_VALIDITY, data); -} - -void nssf_timer_subscription_validity(void *data) -{ - sbi_timer_send_event(NSSF_TIMER_SUBSCRIPTION_VALIDITY, data); -} - -void nssf_timer_sbi_client_wait_expire(void *data) -{ - sbi_timer_send_event(NSSF_TIMER_SBI_CLIENT_WAIT, data); -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/nssf/timer.h
Deleted
@@ -1,57 +0,0 @@ -/* - * 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 NSSF_TIMER_H -#define NSSF_TIMER_H - -#include "ogs-core.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* forward declaration */ -typedef enum { - NSSF_TIMER_BASE = 0, - - NSSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, - NSSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, - NSSF_TIMER_NF_INSTANCE_NO_HEARTBEAT, - NSSF_TIMER_NF_INSTANCE_VALIDITY, - NSSF_TIMER_SUBSCRIPTION_VALIDITY, - NSSF_TIMER_SBI_CLIENT_WAIT, - - MAX_NUM_OF_NSSF_TIMER, - -} nssf_timer_e; - -const char *nssf_timer_get_name(nssf_timer_e id); - -void nssf_timer_nf_instance_registration_interval(void *data); -void nssf_timer_nf_instance_heartbeat_interval(void *data); -void nssf_timer_nf_instance_no_heartbeat(void *data); -void nssf_timer_nf_instance_validity(void *data); -void nssf_timer_subscription_validity(void *data); -void nssf_timer_sbi_client_wait_expire(void *data); - -#ifdef __cplusplus -} -#endif - -#endif /* NSSF_TIMER_H */
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/pcf/nf-sm.c
Deleted
@@ -1,453 +0,0 @@ -/* - * Copyright (C) 2019,2020 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/>. - */ - -#include "context.h" - -#include "sbi-path.h" -#include "nnrf-handler.h" - -void pcf_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance) -{ - pcf_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_create(&nf_instance->sm, - pcf_nf_state_initial, pcf_nf_state_final); - ogs_fsm_init(&nf_instance->sm, &e); -} - -void pcf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance) -{ - pcf_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_fini(&nf_instance->sm, &e); - ogs_fsm_delete(&nf_instance->sm); -} - -void pcf_nf_state_initial(ogs_fsm_t *s, pcf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - pcf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - nf_instance->t_registration_interval = ogs_timer_add(ogs_app()->timer_mgr, - pcf_timer_nf_instance_registration_interval, nf_instance); - ogs_assert(nf_instance->t_registration_interval); - nf_instance->t_heartbeat_interval = ogs_timer_add(ogs_app()->timer_mgr, - pcf_timer_nf_instance_heartbeat_interval, nf_instance); - ogs_assert(nf_instance->t_heartbeat_interval); - nf_instance->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr, - pcf_timer_nf_instance_no_heartbeat, nf_instance); - ogs_assert(nf_instance->t_no_heartbeat); - nf_instance->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - pcf_timer_nf_instance_validity, nf_instance); - ogs_assert(nf_instance->t_validity); - - if (NF_INSTANCE_IS_NRF(nf_instance)) { - OGS_FSM_TRAN(s, &pcf_nf_state_will_register); - } else { - ogs_assert(nf_instance->id); - OGS_FSM_TRAN(s, &pcf_nf_state_registered); - } -} - -void pcf_nf_state_final(ogs_fsm_t *s, pcf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - pcf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - ogs_timer_delete(nf_instance->t_registration_interval); - ogs_timer_delete(nf_instance->t_heartbeat_interval); - ogs_timer_delete(nf_instance->t_no_heartbeat); - ogs_timer_delete(nf_instance->t_validity); -} - -void pcf_nf_state_will_register(ogs_fsm_t *s, pcf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_sockaddr_t *addr = NULL; - - ogs_assert(s); - ogs_assert(e); - - pcf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - ogs_assert(NF_INSTANCE_IS_NRF(nf_instance)); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, pcf_nnrf_nfm_build_register)); - break; - - case OGS_FSM_EXIT_SIG: - ogs_timer_stop(nf_instance->t_registration_interval); - break; - - case PCF_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_OK || - message->res_status == OGS_SBI_HTTP_STATUS_CREATED) { - pcf_nnrf_handle_nf_register(nf_instance, message); - OGS_FSM_TRAN(s, &pcf_nf_state_registered); - } else { - ogs_error("%s HTTP response error %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &pcf_nf_state_exception); - } - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, - message->h.service.name); - END - break; - - case PCF_EVT_SBI_TIMER: - switch(e->timer_id) { - case PCF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - client = nf_instance->client; - ogs_assert(client); - addr = client->node.addr; - ogs_assert(addr); - - ogs_warn("%s Retry to registration with NRF", - ogs_sbi_self()->nf_instance->id); - - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, pcf_nnrf_nfm_build_register)); - break; - - default: - ogs_error("%s Unknown timer%s:%d", - ogs_sbi_self()->nf_instance->id, - pcf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("Unknown event %s", pcf_event_get_name(e)); - break; - } -} - -void pcf_nf_state_registered(ogs_fsm_t *s, pcf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_assert(s); - ogs_assert(e); - - pcf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF registered Heartbeat:%ds", - ogs_sbi_self()->nf_instance->id, - nf_instance->time.heartbeat_interval); - - client = nf_instance->client; - ogs_assert(client); - - if (nf_instance->time.heartbeat_interval) { - ogs_timer_start(nf_instance->t_heartbeat_interval, - ogs_time_from_sec(nf_instance->time.heartbeat_interval)); - ogs_timer_start(nf_instance->t_no_heartbeat, - ogs_time_from_sec( - nf_instance->time.heartbeat_interval + - ogs_app()->time.nf_instance.no_heartbeat_margin)); - } - - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_BSF)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_UDR)); - } - - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - - if (nf_instance->time.heartbeat_interval) { - ogs_timer_stop(nf_instance->t_heartbeat_interval); - ogs_timer_stop(nf_instance->t_no_heartbeat); - } - - if (!OGS_FSM_CHECK(&nf_instance->sm, pcf_nf_state_exception)) { - ogs_assert(true == - ogs_nnrf_nfm_send_nf_de_register(nf_instance)); - } - } - break; - - case PCF_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_NO_CONTENT || - message->res_status == OGS_SBI_HTTP_STATUS_OK) { - if (nf_instance->time.heartbeat_interval) - ogs_timer_start(nf_instance->t_no_heartbeat, - ogs_time_from_sec( - nf_instance->time.heartbeat_interval + - ogs_app()->time.nf_instance. - no_heartbeat_margin)); - } else { - ogs_warn("%s HTTP response error %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &pcf_nf_state_exception); - } - - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case PCF_EVT_SBI_TIMER: - switch(e->timer_id) { - case PCF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - if (nf_instance->time.heartbeat_interval) - ogs_timer_start(nf_instance->t_heartbeat_interval, - ogs_time_from_sec(nf_instance->time.heartbeat_interval)); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_update(nf_instance)); - break; - - case PCF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - ogs_error("%s No heartbeat", ogs_sbi_self()->nf_instance->id); - OGS_FSM_TRAN(s, &pcf_nf_state_will_register); - break; - - case PCF_TIMER_NF_INSTANCE_VALIDITY: - ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance)); - ogs_assert(nf_instance->id); - - ogs_info("%s NF expired", nf_instance->id); - OGS_FSM_TRAN(s, &pcf_nf_state_de_registered); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - pcf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - pcf_event_get_name(e)); - break; - } -} - -void pcf_nf_state_de_registered(ogs_fsm_t *s, pcf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_assert(s); - ogs_assert(e); - - pcf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - } - break; - - case OGS_FSM_EXIT_SIG: - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - pcf_event_get_name(e)); - break; - } -} - -void pcf_nf_state_exception(ogs_fsm_t *s, pcf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_sockaddr_t *addr = NULL; - ogs_assert(s); - ogs_assert(e); - - pcf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi. - nf_register_interval_in_exception); - } - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_timer_stop(nf_instance->t_registration_interval); - } - break; - - case PCF_EVT_SBI_TIMER: - switch(e->timer_id) { - case PCF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - client = nf_instance->client; - ogs_assert(client); - addr = client->node.addr; - ogs_assert(addr); - - ogs_warn("%s Retry to registration with NRF", - ogs_sbi_self()->nf_instance->id); - - OGS_FSM_TRAN(s, &pcf_nf_state_will_register); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - pcf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - case PCF_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - break; - DEFAULT - ogs_error("Invalid resource name %s", - message->h.resource.component0); - END - break; - DEFAULT - ogs_error("Invalid API name %s", message->h.service.name); - END - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - pcf_event_get_name(e)); - break; - } -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/pcf/nnrf-build.c
Deleted
@@ -1,55 +0,0 @@ -/* - * Copyright (C) 2019,2020 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/>. - */ - -#include "nnrf-build.h" - -ogs_sbi_request_t *pcf_nnrf_nfm_build_register(void) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_request_t *request = NULL; - - OpenAPI_nf_profile_t *NFProfile = NULL; - - nf_instance = ogs_sbi_self()->nf_instance; - ogs_assert(nf_instance); - ogs_assert(nf_instance->id); - - memset(&message, 0, sizeof(message)); - message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT; - message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; - message.h.api.version = (char *)OGS_SBI_API_V1; - message.h.resource.component0 = - (char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES; - message.h.resource.component1 = nf_instance->id; - - message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding; - - NFProfile = ogs_nnrf_nfm_build_nf_profile(); - ogs_expect_or_return_val(NFProfile, NULL); - - message.NFProfile = NFProfile; - - request = ogs_sbi_build_request(&message); - - ogs_sbi_nnrf_free_nf_profile(NFProfile); - - return request; -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/pcf/nnrf-build.h
Deleted
@@ -1,35 +0,0 @@ -/* - * Copyright (C) 2019,2020 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 PCF_NNRF_BUILD_H -#define PCF_NNRF_BUILD_H - -#include "context.h" - -#ifdef __cplusplus -extern "C" { -#endif - -ogs_sbi_request_t *pcf_nnrf_nfm_build_register(void); - -#ifdef __cplusplus -} -#endif - -#endif /* PCF_NNRF_BUILD_H */
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/pcf/timer.c
Deleted
@@ -1,116 +0,0 @@ -/* - * Copyright (C) 2019,2020 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/>. - */ - -#include "context.h" - -const char *pcf_timer_get_name(pcf_timer_e id) -{ - switch (id) { - case PCF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - return "PCF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL"; - case PCF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - return "PCF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL"; - case PCF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - return "PCF_TIMER_NF_INSTANCE_NO_HEARTBEAT"; - case PCF_TIMER_NF_INSTANCE_VALIDITY: - return "PCF_TIMER_NF_INSTANCE_VALIDITY"; - case PCF_TIMER_SUBSCRIPTION_VALIDITY: - return "PCF_TIMER_SUBSCRIPTION_VALIDITY"; - case PCF_TIMER_SBI_CLIENT_WAIT: - return "PCF_TIMER_SBI_CLIENT_WAIT"; - default: - break; - } - - return "UNKNOWN_TIMER"; -} - -static void sbi_timer_send_event(int timer_id, void *data) -{ - int rv; - pcf_event_t *e = NULL; - ogs_assert(data); - - switch (timer_id) { - case PCF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case PCF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case PCF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case PCF_TIMER_NF_INSTANCE_VALIDITY: - case PCF_TIMER_SUBSCRIPTION_VALIDITY: - e = pcf_event_new(PCF_EVT_SBI_TIMER); - ogs_assert(e); - e->timer_id = timer_id; - e->sbi.data = data; - break; - case PCF_TIMER_SBI_CLIENT_WAIT: - e = pcf_event_new(PCF_EVT_SBI_TIMER); - if (!e) { - ogs_sbi_xact_t *sbi_xact = data; - ogs_assert(sbi_xact); - - ogs_error("sbi_timer_send_event() failed"); - ogs_sbi_xact_remove(sbi_xact); - return; - } - e->timer_id = timer_id; - e->sbi.data = data; - break; - default: - ogs_fatal("Unknown timer id%d", timer_id); - ogs_assert_if_reached(); - break; - } - - rv = ogs_queue_push(ogs_app()->queue, e); - if (rv != OGS_OK) { - ogs_error("ogs_queue_push() failed %d in %s", - (int)rv, pcf_timer_get_name(e->timer_id)); - pcf_event_free(e); - } -} - -void pcf_timer_nf_instance_registration_interval(void *data) -{ - sbi_timer_send_event(PCF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, data); -} - -void pcf_timer_nf_instance_heartbeat_interval(void *data) -{ - sbi_timer_send_event(PCF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, data); -} - -void pcf_timer_nf_instance_no_heartbeat(void *data) -{ - sbi_timer_send_event(PCF_TIMER_NF_INSTANCE_NO_HEARTBEAT, data); -} - -void pcf_timer_nf_instance_validity(void *data) -{ - sbi_timer_send_event(PCF_TIMER_NF_INSTANCE_VALIDITY, data); -} - -void pcf_timer_subscription_validity(void *data) -{ - sbi_timer_send_event(PCF_TIMER_SUBSCRIPTION_VALIDITY, data); -} - -void pcf_timer_sbi_client_wait_expire(void *data) -{ - sbi_timer_send_event(PCF_TIMER_SBI_CLIENT_WAIT, data); -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/pcf/timer.h
Deleted
@@ -1,57 +0,0 @@ -/* - * 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 PCF_TIMER_H -#define PCF_TIMER_H - -#include "ogs-core.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* forward declaration */ -typedef enum { - PCF_TIMER_BASE = 0, - - PCF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, - PCF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, - PCF_TIMER_NF_INSTANCE_NO_HEARTBEAT, - PCF_TIMER_NF_INSTANCE_VALIDITY, - PCF_TIMER_SUBSCRIPTION_VALIDITY, - PCF_TIMER_SBI_CLIENT_WAIT, - - MAX_NUM_OF_PCF_TIMER, - -} pcf_timer_e; - -const char *pcf_timer_get_name(pcf_timer_e id); - -void pcf_timer_nf_instance_registration_interval(void *data); -void pcf_timer_nf_instance_heartbeat_interval(void *data); -void pcf_timer_nf_instance_no_heartbeat(void *data); -void pcf_timer_nf_instance_validity(void *data); -void pcf_timer_subscription_validity(void *data); -void pcf_timer_sbi_client_wait_expire(void *data); - -#ifdef __cplusplus -} -#endif - -#endif /* PCF_TIMER_H */
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/scp/nf-sm.c
Deleted
@@ -1,483 +0,0 @@ -/* - * Copyright (C) 2019-2022 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/>. - */ - -#include "context.h" - -#include "sbi-path.h" -#include "nnrf-handler.h" - -void scp_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance) -{ - scp_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_create(&nf_instance->sm, - scp_nf_state_initial, scp_nf_state_final); - ogs_fsm_init(&nf_instance->sm, &e); -} - -void scp_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance) -{ - scp_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_fini(&nf_instance->sm, &e); - ogs_fsm_delete(&nf_instance->sm); -} - -void scp_nf_state_initial(ogs_fsm_t *s, scp_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - scp_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - nf_instance->t_registration_interval = ogs_timer_add(ogs_app()->timer_mgr, - scp_timer_nf_instance_registration_interval, nf_instance); - ogs_assert(nf_instance->t_registration_interval); - nf_instance->t_heartbeat_interval = ogs_timer_add(ogs_app()->timer_mgr, - scp_timer_nf_instance_heartbeat_interval, nf_instance); - ogs_assert(nf_instance->t_heartbeat_interval); - nf_instance->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr, - scp_timer_nf_instance_no_heartbeat, nf_instance); - ogs_assert(nf_instance->t_no_heartbeat); - nf_instance->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - scp_timer_nf_instance_validity, nf_instance); - ogs_assert(nf_instance->t_validity); - - if (NF_INSTANCE_IS_NRF(nf_instance)) { - OGS_FSM_TRAN(s, &scp_nf_state_will_register); - } else { - ogs_assert(nf_instance->id); - OGS_FSM_TRAN(s, &scp_nf_state_registered); - } -} - -void scp_nf_state_final(ogs_fsm_t *s, scp_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - scp_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - ogs_timer_delete(nf_instance->t_registration_interval); - ogs_timer_delete(nf_instance->t_heartbeat_interval); - ogs_timer_delete(nf_instance->t_no_heartbeat); - ogs_timer_delete(nf_instance->t_validity); -} - -void scp_nf_state_will_register(ogs_fsm_t *s, scp_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_sockaddr_t *addr = NULL; - - ogs_assert(s); - ogs_assert(e); - - scp_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - ogs_assert(NF_INSTANCE_IS_NRF(nf_instance)); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, scp_nnrf_nfm_build_register)); - break; - - case OGS_FSM_EXIT_SIG: - ogs_timer_stop(nf_instance->t_registration_interval); - break; - - case SCP_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_OK || - message->res_status == OGS_SBI_HTTP_STATUS_CREATED) { - scp_nnrf_handle_nf_register(nf_instance, message); - OGS_FSM_TRAN(s, &scp_nf_state_registered); - } else { - ogs_error("%s HTTP Response Status Code %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &scp_nf_state_exception); - } - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case SCP_EVT_SBI_TIMER: - switch(e->timer_id) { - case SCP_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - client = nf_instance->client; - ogs_assert(client); - addr = client->node.addr; - ogs_assert(addr); - - ogs_warn("%s Retry to registration with NRF", - ogs_sbi_self()->nf_instance->id); - - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, scp_nnrf_nfm_build_register)); - break; - - default: - ogs_error("%s Unknown timer%s:%d", - ogs_sbi_self()->nf_instance->id, - scp_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s Unknown event %s", - ogs_sbi_self()->nf_instance->id, scp_event_get_name(e)); - break; - } -} - -void scp_nf_state_registered(ogs_fsm_t *s, scp_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_assert(s); - ogs_assert(e); - - scp_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF registered Heartbeat:%ds", - ogs_sbi_self()->nf_instance->id, - nf_instance->time.heartbeat_interval); - - client = nf_instance->client; - ogs_assert(client); - - if (nf_instance->time.heartbeat_interval) { - ogs_timer_start(nf_instance->t_heartbeat_interval, - ogs_time_from_sec(nf_instance->time.heartbeat_interval)); - ogs_timer_start(nf_instance->t_no_heartbeat, - ogs_time_from_sec( - nf_instance->time.heartbeat_interval + - ogs_app()->time.nf_instance.no_heartbeat_margin)); - } - - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_AMF)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_AUSF)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_BSF)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_NSSF)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_PCF)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_SMF)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_UDM)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_UDR)); - } - - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - - if (nf_instance->time.heartbeat_interval) { - ogs_timer_stop(nf_instance->t_heartbeat_interval); - ogs_timer_stop(nf_instance->t_no_heartbeat); - } - - if (!OGS_FSM_CHECK(&nf_instance->sm, scp_nf_state_exception)) { - ogs_assert(true == - ogs_nnrf_nfm_send_nf_de_register(nf_instance)); - } - } - break; - - case SCP_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_NO_CONTENT || - message->res_status == OGS_SBI_HTTP_STATUS_OK) { - if (nf_instance->time.heartbeat_interval) - ogs_timer_start(nf_instance->t_no_heartbeat, - ogs_time_from_sec( - nf_instance->time.heartbeat_interval + - ogs_app()->time.nf_instance. - no_heartbeat_margin)); - } else { - ogs_warn("%s HTTP response error %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &scp_nf_state_exception); - } - - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case SCP_EVT_SBI_TIMER: - switch(e->timer_id) { - case SCP_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - if (nf_instance->time.heartbeat_interval) - ogs_timer_start(nf_instance->t_heartbeat_interval, - ogs_time_from_sec(nf_instance->time.heartbeat_interval)); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_update(nf_instance)); - break; - - case SCP_TIMER_NF_INSTANCE_NO_HEARTBEAT: - ogs_error("%s No heartbeat", ogs_sbi_self()->nf_instance->id); - OGS_FSM_TRAN(s, &scp_nf_state_will_register); - break; - - case SCP_TIMER_NF_INSTANCE_VALIDITY: - ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance)); - ogs_assert(nf_instance->id); - - ogs_info("%s NF expired", nf_instance->id); - OGS_FSM_TRAN(s, &scp_nf_state_de_registered); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - scp_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - scp_event_get_name(e)); - break; - } -} - -void scp_nf_state_de_registered(ogs_fsm_t *s, scp_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_assert(s); - ogs_assert(e); - - scp_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - } - break; - - case OGS_FSM_EXIT_SIG: - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - scp_event_get_name(e)); - break; - } -} - -void scp_nf_state_exception(ogs_fsm_t *s, scp_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_sockaddr_t *addr = NULL; - ogs_assert(s); - ogs_assert(e); - - scp_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi. - nf_register_interval_in_exception); - } - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_timer_stop(nf_instance->t_registration_interval); - } - break; - - case SCP_EVT_SBI_TIMER: - switch(e->timer_id) { - case SCP_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - client = nf_instance->client; - ogs_assert(client); - addr = client->node.addr; - ogs_assert(addr); - - ogs_warn("%s Retry to registration with NRF", - ogs_sbi_self()->nf_instance->id); - - OGS_FSM_TRAN(s, &scp_nf_state_will_register); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - scp_timer_get_name(e->timer_id), e->timer_id); - } - break; - - case SCP_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - break; - DEFAULT - ogs_error("Invalid resource name %s", - message->h.resource.component0); - END - break; - DEFAULT - ogs_error("Invalid API name %s", message->h.service.name); - END - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - scp_event_get_name(e)); - break; - } -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/scp/nnrf-build.c
Deleted
@@ -1,55 +0,0 @@ -/* - * Copyright (C) 2019-2022 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/>. - */ - -#include "nnrf-build.h" - -ogs_sbi_request_t *scp_nnrf_nfm_build_register(void) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_request_t *request = NULL; - - OpenAPI_nf_profile_t *NFProfile = NULL; - - nf_instance = ogs_sbi_self()->nf_instance; - ogs_assert(nf_instance); - ogs_assert(nf_instance->id); - - memset(&message, 0, sizeof(message)); - message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT; - message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; - message.h.api.version = (char *)OGS_SBI_API_V1; - message.h.resource.component0 = - (char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES; - message.h.resource.component1 = nf_instance->id; - - message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding; - - NFProfile = ogs_nnrf_nfm_build_nf_profile(); - ogs_expect_or_return_val(NFProfile, NULL); - - message.NFProfile = NFProfile; - - request = ogs_sbi_build_request(&message); - - ogs_sbi_nnrf_free_nf_profile(NFProfile); - - return request; -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/scp/nnrf-build.h
Deleted
@@ -1,35 +0,0 @@ -/* - * Copyright (C) 2019-2022 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 SCP_NNRF_BUILD_H -#define SCP_NNRF_BUILD_H - -#include "context.h" - -#ifdef __cplusplus -extern "C" { -#endif - -ogs_sbi_request_t *scp_nnrf_nfm_build_register(void); - -#ifdef __cplusplus -} -#endif - -#endif /* SCP_NNRF_BUILD_H */
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/scp/timer.c
Deleted
@@ -1,118 +0,0 @@ -/* - * Copyright (C) 2019-2022 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/>. - */ - -#include "timer.h" -#include "event.h" -#include "context.h" - -const char *scp_timer_get_name(scp_timer_e id) -{ - switch (id) { - case SCP_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - return "SCP_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL"; - case SCP_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - return "SCP_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL"; - case SCP_TIMER_NF_INSTANCE_NO_HEARTBEAT: - return "SCP_TIMER_NF_INSTANCE_NO_HEARTBEAT"; - case SCP_TIMER_NF_INSTANCE_VALIDITY: - return "SCP_TIMER_NF_INSTANCE_VALIDITY"; - case SCP_TIMER_SUBSCRIPTION_VALIDITY: - return "SCP_TIMER_SUBSCRIPTION_VALIDITY"; - case SCP_TIMER_SBI_CLIENT_WAIT: - return "SCP_TIMER_SBI_CLIENT_WAIT"; - default: - break; - } - - return "UNKNOWN_TIMER"; -} - -static void timer_send_event(int timer_id, void *data) -{ - int rv; - scp_event_t *e = NULL; - ogs_assert(data); - - switch (timer_id) { - case SCP_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case SCP_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case SCP_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case SCP_TIMER_NF_INSTANCE_VALIDITY: - case SCP_TIMER_SUBSCRIPTION_VALIDITY: - e = scp_event_new(SCP_EVT_SBI_TIMER); - ogs_assert(e); - e->timer_id = timer_id; - e->sbi.data = data; - break; - case SCP_TIMER_SBI_CLIENT_WAIT: - e = scp_event_new(SCP_EVT_SBI_TIMER); - if (!e) { - ogs_sbi_xact_t *sbi_xact = data; - ogs_assert(sbi_xact); - - ogs_error("timer_send_event() failed"); - ogs_sbi_xact_remove(sbi_xact); - return; - } - e->timer_id = timer_id; - e->sbi.data = data; - break; - default: - ogs_fatal("Unknown timer id%d", timer_id); - ogs_assert_if_reached(); - break; - } - - rv = ogs_queue_push(ogs_app()->queue, e); - if (rv != OGS_OK) { - ogs_warn("ogs_queue_push() failed %d in %s", - (int)rv, scp_timer_get_name(e->timer_id)); - scp_event_free(e); - } -} - -void scp_timer_nf_instance_registration_interval(void *data) -{ - timer_send_event(SCP_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, data); -} - -void scp_timer_nf_instance_heartbeat_interval(void *data) -{ - timer_send_event(SCP_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, data); -} - -void scp_timer_nf_instance_no_heartbeat(void *data) -{ - timer_send_event(SCP_TIMER_NF_INSTANCE_NO_HEARTBEAT, data); -} - -void scp_timer_nf_instance_validity(void *data) -{ - timer_send_event(SCP_TIMER_NF_INSTANCE_VALIDITY, data); -} - -void scp_timer_subscription_validity(void *data) -{ - timer_send_event(SCP_TIMER_SUBSCRIPTION_VALIDITY, data); -} - -void scp_timer_sbi_client_wait_expire(void *data) -{ - timer_send_event(SCP_TIMER_SBI_CLIENT_WAIT, data); -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/scp/timer.h
Deleted
@@ -1,57 +0,0 @@ -/* - * Copyright (C) 2019-2022 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 SCP_TIMER_H -#define SCP_TIMER_H - -#include "ogs-core.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* forward declaration */ -typedef enum { - SCP_TIMER_BASE = 0, - - SCP_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, - SCP_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, - SCP_TIMER_NF_INSTANCE_NO_HEARTBEAT, - SCP_TIMER_NF_INSTANCE_VALIDITY, - SCP_TIMER_SUBSCRIPTION_VALIDITY, - SCP_TIMER_SBI_CLIENT_WAIT, - - MAX_NUM_OF_SCP_TIMER, - -} scp_timer_e; - -const char *scp_timer_get_name(scp_timer_e id); - -void scp_timer_nf_instance_registration_interval(void *data); -void scp_timer_nf_instance_heartbeat_interval(void *data); -void scp_timer_nf_instance_no_heartbeat(void *data); -void scp_timer_nf_instance_validity(void *data); -void scp_timer_subscription_validity(void *data); -void scp_timer_sbi_client_wait_expire(void *data); - -#ifdef __cplusplus -} -#endif - -#endif /* SCP_TIMER_H */
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/nf-sm.c
Deleted
@@ -1,462 +0,0 @@ -/* - * 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/>. - */ - -#include "context.h" - -#include "sbi-path.h" -#include "nnrf-handler.h" - -void smf_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance) -{ - smf_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_create(&nf_instance->sm, - smf_nf_state_initial, smf_nf_state_final); - ogs_fsm_init(&nf_instance->sm, &e); -} - -void smf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance) -{ - smf_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_fini(&nf_instance->sm, &e); - ogs_fsm_delete(&nf_instance->sm); -} - -void smf_nf_state_initial(ogs_fsm_t *s, smf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - smf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - nf_instance->t_registration_interval = ogs_timer_add(ogs_app()->timer_mgr, - smf_timer_nf_instance_registration_interval, nf_instance); - ogs_assert(nf_instance->t_registration_interval); - nf_instance->t_heartbeat_interval = ogs_timer_add(ogs_app()->timer_mgr, - smf_timer_nf_instance_heartbeat_interval, nf_instance); - ogs_assert(nf_instance->t_heartbeat_interval); - nf_instance->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr, - smf_timer_nf_instance_no_heartbeat, nf_instance); - ogs_assert(nf_instance->t_no_heartbeat); - nf_instance->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - smf_timer_nf_instance_validity, nf_instance); - ogs_assert(nf_instance->t_validity); - - if (NF_INSTANCE_IS_NRF(nf_instance)) { - OGS_FSM_TRAN(s, &smf_nf_state_will_register); - } else { - ogs_assert(nf_instance->id); - OGS_FSM_TRAN(s, &smf_nf_state_registered); - } -} - -void smf_nf_state_final(ogs_fsm_t *s, smf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - smf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - ogs_timer_delete(nf_instance->t_registration_interval); - ogs_timer_delete(nf_instance->t_heartbeat_interval); - ogs_timer_delete(nf_instance->t_no_heartbeat); - ogs_timer_delete(nf_instance->t_validity); -} - -void smf_nf_state_will_register(ogs_fsm_t *s, smf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_sockaddr_t *addr = NULL; - - ogs_assert(s); - ogs_assert(e); - - smf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - ogs_assert(NF_INSTANCE_IS_NRF(nf_instance)); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, smf_nnrf_nfm_build_register)); - break; - - case OGS_FSM_EXIT_SIG: - ogs_timer_stop(nf_instance->t_registration_interval); - break; - - case SMF_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_OK || - message->res_status == OGS_SBI_HTTP_STATUS_CREATED) { - smf_nnrf_handle_nf_register(nf_instance, message); - OGS_FSM_TRAN(s, &smf_nf_state_registered); - } else { - ogs_error("%s HTTP Response Status Code %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &smf_nf_state_exception); - } - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case SMF_EVT_SBI_TIMER: - switch(e->timer_id) { - case SMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - client = nf_instance->client; - ogs_assert(client); - addr = client->node.addr; - ogs_assert(addr); - - ogs_warn("%s Retry to registration with NRF", - ogs_sbi_self()->nf_instance->id); - - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, smf_nnrf_nfm_build_register)); - break; - - default: - ogs_error("%s Unknown timer%s:%d", - ogs_sbi_self()->nf_instance->id, - smf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s Unknown event %s", - ogs_sbi_self()->nf_instance->id, smf_event_get_name(e)); - break; - } -} - -void smf_nf_state_registered(ogs_fsm_t *s, smf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_assert(s); - ogs_assert(e); - - smf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF registered Heartbeat:%ds", - ogs_sbi_self()->nf_instance->id, - nf_instance->time.heartbeat_interval); - - client = nf_instance->client; - ogs_assert(client); - - if (nf_instance->time.heartbeat_interval) { - ogs_timer_start(nf_instance->t_heartbeat_interval, - ogs_time_from_sec(nf_instance->time.heartbeat_interval)); - ogs_timer_start(nf_instance->t_no_heartbeat, - ogs_time_from_sec( - nf_instance->time.heartbeat_interval + - ogs_app()->time.nf_instance.no_heartbeat_margin)); - } - - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_AMF)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_UDM)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_PCF)); - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_UPF)); - } - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - - if (nf_instance->time.heartbeat_interval) { - ogs_timer_stop(nf_instance->t_heartbeat_interval); - ogs_timer_stop(nf_instance->t_no_heartbeat); - } - - if (!OGS_FSM_CHECK(&nf_instance->sm, smf_nf_state_exception)) { - ogs_assert(true == - ogs_nnrf_nfm_send_nf_de_register(nf_instance)); - } - } - break; - - case SMF_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_NO_CONTENT || - message->res_status == OGS_SBI_HTTP_STATUS_OK) { - if (nf_instance->time.heartbeat_interval) - ogs_timer_start(nf_instance->t_no_heartbeat, - ogs_time_from_sec( - nf_instance->time.heartbeat_interval + - ogs_app()->time.nf_instance. - no_heartbeat_margin)); - } else { - ogs_warn("%s HTTP response error %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &smf_nf_state_exception); - } - - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case SMF_EVT_SBI_TIMER: - switch(e->timer_id) { - case SMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - if (nf_instance->time.heartbeat_interval) - ogs_timer_start(nf_instance->t_heartbeat_interval, - ogs_time_from_sec(nf_instance->time.heartbeat_interval)); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_update(nf_instance)); - break; - - case SMF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - ogs_error("%s No heartbeat", ogs_sbi_self()->nf_instance->id); - OGS_FSM_TRAN(s, &smf_nf_state_will_register); - break; - - case SMF_TIMER_NF_INSTANCE_VALIDITY: - ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance)); - ogs_assert(nf_instance->id); - - ogs_info("%s NF expired", nf_instance->id); - OGS_FSM_TRAN(s, &smf_nf_state_de_registered); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - smf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - smf_event_get_name(e)); - break; - } -} - -void smf_nf_state_de_registered(ogs_fsm_t *s, smf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_assert(s); - ogs_assert(e); - - smf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - } - break; - - case OGS_FSM_EXIT_SIG: - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - smf_event_get_name(e)); - break; - } -} - -void smf_nf_state_exception(ogs_fsm_t *s, smf_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_sockaddr_t *addr = NULL; - ogs_assert(s); - ogs_assert(e); - - smf_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi. - nf_register_interval_in_exception); - } - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_timer_stop(nf_instance->t_registration_interval); - } - break; - - case SMF_EVT_SBI_TIMER: - switch(e->timer_id) { - case SMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - client = nf_instance->client; - ogs_assert(client); - addr = client->node.addr; - ogs_assert(addr); - - ogs_warn("%s Retry to registration with NRF", - ogs_sbi_self()->nf_instance->id); - - OGS_FSM_TRAN(s, &smf_nf_state_will_register); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - smf_timer_get_name(e->timer_id), e->timer_id); - } - break; - - case SMF_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - break; - DEFAULT - ogs_error("Invalid resource name %s", - message->h.resource.component0); - END - break; - DEFAULT - ogs_error("Invalid API name %s", message->h.service.name); - END - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - smf_event_get_name(e)); - break; - } -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/nnrf-build.c
Deleted
@@ -1,293 +0,0 @@ -/* - * Copyright (C) 2019,2020 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/>. - */ - -#include "nnrf-build.h" - -ogs_sbi_request_t *smf_nnrf_nfm_build_register(void) -{ - int i, j; - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_nf_info_t *nf_info = NULL; - - ogs_sbi_message_t message; - ogs_sbi_request_t *request = NULL; - - OpenAPI_nf_profile_t *NFProfile = NULL; - - OpenAPI_list_t *SmfInfoList = NULL; - OpenAPI_map_t *SmfInfoMap = NULL; - OpenAPI_smf_info_t *SmfInfo = NULL; - int SmfInfoMapKey; - - OpenAPI_list_t *sNssaiSmfInfoList = NULL; - OpenAPI_snssai_smf_info_item_t *sNssaiSmfInfoItem = NULL; - OpenAPI_snssai_t *sNssai = NULL; - OpenAPI_list_t *DnnSmfInfoList = NULL; - OpenAPI_dnn_smf_info_item_t *DnnSmfInfoItem = NULL; - - OpenAPI_list_t *TaiList = NULL; - OpenAPI_tai_t *TaiItem = NULL; - OpenAPI_list_t *TaiRangeList = NULL; - OpenAPI_tai_range_t *TaiRangeItem = NULL; - OpenAPI_list_t *TacRangeList = NULL; - OpenAPI_tac_range_t *TacRangeItem = NULL; - - OpenAPI_lnode_t *node = NULL, *node2 = NULL, *node3 = NULL; - - nf_instance = ogs_sbi_self()->nf_instance; - ogs_assert(nf_instance); - ogs_assert(nf_instance->id); - - memset(&message, 0, sizeof(message)); - message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT; - message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; - message.h.api.version = (char *)OGS_SBI_API_V1; - message.h.resource.component0 = - (char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES; - message.h.resource.component1 = nf_instance->id; - - message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding; - - SmfInfoList = OpenAPI_list_create(); - ogs_assert(SmfInfoList); - - SmfInfoMapKey = 0; - - ogs_list_for_each(&nf_instance->nf_info_list, nf_info) { - if (nf_info->nf_type != OpenAPI_nf_type_SMF) { - ogs_fatal("Not implemented NF-type%s", - OpenAPI_nf_type_ToString(nf_info->nf_type)); - ogs_assert_if_reached(); - } - - if (nf_info->smf.num_of_slice == 0) { - ogs_fatal("CHECK CONFIGURATION: No S-NSSAI"); - ogs_assert_if_reached(); - } - - SmfInfo = ogs_calloc(1, sizeof(*SmfInfo)); - ogs_expect_or_return_val(SmfInfo, NULL); - - sNssaiSmfInfoList = OpenAPI_list_create(); - ogs_assert(sNssaiSmfInfoList); - - for (i = 0; i < nf_info->smf.num_of_slice; i++) { - DnnSmfInfoList = OpenAPI_list_create(); - ogs_assert(DnnSmfInfoList); - - for (j = 0; j < nf_info->smf.slicei.num_of_dnn; j++) { - DnnSmfInfoItem = ogs_calloc(1, sizeof(*DnnSmfInfoItem)); - ogs_expect_or_return_val(DnnSmfInfoItem, NULL); - DnnSmfInfoItem->dnn = nf_info->smf.slicei.dnnj; - - OpenAPI_list_add(DnnSmfInfoList, DnnSmfInfoItem); - } - - if (!DnnSmfInfoList->count) { - OpenAPI_list_free(DnnSmfInfoList); - - ogs_error("CHECK CONFIGURATION: No DNN"); - ogs_expect_or_return_val(0, NULL); - } - - sNssaiSmfInfoItem = ogs_calloc(1, sizeof(*sNssaiSmfInfoItem)); - ogs_expect_or_return_val(sNssaiSmfInfoItem, NULL); - - sNssaiSmfInfoItem->dnn_smf_info_list = DnnSmfInfoList; - - sNssaiSmfInfoItem->s_nssai = sNssai = - ogs_calloc(1, sizeof(*sNssai)); - ogs_expect_or_return_val(sNssai, NULL); - sNssai->sst = nf_info->smf.slicei.s_nssai.sst; - sNssai->sd = - ogs_s_nssai_sd_to_string(nf_info->smf.slicei.s_nssai.sd); - - OpenAPI_list_add(sNssaiSmfInfoList, sNssaiSmfInfoItem); - } - - if (sNssaiSmfInfoList->count) - SmfInfo->s_nssai_smf_info_list = sNssaiSmfInfoList; - else - OpenAPI_list_free(sNssaiSmfInfoList); - - TaiList = OpenAPI_list_create(); - ogs_assert(TaiList); - - for (i = 0; i < nf_info->smf.num_of_nr_tai; i++) { - TaiItem = ogs_calloc(1, sizeof(*TaiItem)); - ogs_expect_or_return_val(TaiItem, NULL); - TaiItem->plmn_id = ogs_sbi_build_plmn_id( - &nf_info->smf.nr_taii.plmn_id); - ogs_expect_or_return_val(TaiItem->plmn_id, NULL); - TaiItem->tac = ogs_uint24_to_0string(nf_info->smf.nr_taii.tac); - ogs_expect_or_return_val(TaiItem->tac, NULL); - - OpenAPI_list_add(TaiList, TaiItem); - } - - if (TaiList->count) - SmfInfo->tai_list = TaiList; - else - OpenAPI_list_free(TaiList); - - TaiRangeList = OpenAPI_list_create(); - ogs_assert(TaiRangeList); - - for (i = 0; i < nf_info->smf.num_of_nr_tai_range; i++) { - TacRangeList = OpenAPI_list_create(); - ogs_assert(TacRangeList); - - for (j = 0; - j < nf_info->smf.nr_tai_rangei.num_of_tac_range; j++) { - TacRangeItem = ogs_calloc(1, sizeof(*TacRangeItem)); - ogs_expect_or_return_val(TacRangeItem, NULL); - - TacRangeItem->start = ogs_uint24_to_0string( - nf_info->smf.nr_tai_rangei.startj); - ogs_expect_or_return_val(TacRangeItem->start, NULL); - TacRangeItem->end = - ogs_uint24_to_0string(nf_info->smf.nr_tai_rangei.endj); - ogs_expect_or_return_val(TacRangeItem->end, NULL); - - OpenAPI_list_add(TacRangeList, TacRangeItem); - } - - if (!TacRangeList->count) { - OpenAPI_list_free(TacRangeList); - - ogs_error("CHECK CONFIGURATION: No Start/End in TacRange"); - ogs_expect_or_return_val(0, NULL); - } - - TaiRangeItem = ogs_calloc(1, sizeof(*TaiRangeItem)); - ogs_expect_or_return_val(TaiRangeItem, NULL); - - TaiRangeItem->plmn_id = ogs_sbi_build_plmn_id( - &nf_info->smf.nr_tai_rangei.plmn_id); - ogs_expect_or_return_val(TaiRangeItem->plmn_id, NULL); - - TaiRangeItem->tac_range_list = TacRangeList; - - OpenAPI_list_add(TaiRangeList, TaiRangeItem); - } - - if (TaiRangeList->count) - SmfInfo->tai_range_list = TaiRangeList; - else - OpenAPI_list_free(TaiRangeList); - - SmfInfoMap = OpenAPI_map_create( - ogs_msprintf("%d", ++SmfInfoMapKey), SmfInfo); - ogs_assert(SmfInfoMap); - - OpenAPI_list_add(SmfInfoList, SmfInfoMap); - } - - NFProfile = ogs_nnrf_nfm_build_nf_profile(); - ogs_expect_or_return_val(NFProfile, NULL); - - if (SmfInfoList->count == 1) { - NFProfile->smf_info = SmfInfo; - } else if (SmfInfoList->count > 1) { - NFProfile->smf_info_list = SmfInfoList; - } - - message.NFProfile = NFProfile; - - request = ogs_sbi_build_request(&message); - - ogs_sbi_nnrf_free_nf_profile(NFProfile); - - OpenAPI_list_for_each(SmfInfoList, node) { - SmfInfoMap = node->data; - if (SmfInfoMap) { - SmfInfo = SmfInfoMap->value; - if (SmfInfo) { - sNssaiSmfInfoList = SmfInfo->s_nssai_smf_info_list; - OpenAPI_list_for_each(sNssaiSmfInfoList, node2) { - sNssaiSmfInfoItem = node2->data; - ogs_assert(sNssaiSmfInfoItem); - - DnnSmfInfoList = sNssaiSmfInfoItem->dnn_smf_info_list; - OpenAPI_list_for_each(DnnSmfInfoList, node3) { - DnnSmfInfoItem = node3->data; - ogs_assert(DnnSmfInfoItem); - ogs_free(DnnSmfInfoItem); - } - OpenAPI_list_free(DnnSmfInfoList); - - sNssai = sNssaiSmfInfoItem->s_nssai; - if (sNssai) { - if (sNssai->sd) - ogs_free(sNssai->sd); - ogs_free(sNssai); - } - - ogs_free(sNssaiSmfInfoItem); - } - OpenAPI_list_free(sNssaiSmfInfoList); - - TaiList = SmfInfo->tai_list; - OpenAPI_list_for_each(TaiList, node2) { - TaiItem = node2->data; - ogs_assert(TaiItem); - if (TaiItem->plmn_id) - ogs_sbi_free_plmn_id(TaiItem->plmn_id); - if (TaiItem->tac) - ogs_free(TaiItem->tac); - ogs_free(TaiItem); - } - OpenAPI_list_free(TaiList); - - TaiRangeList = SmfInfo->tai_range_list; - OpenAPI_list_for_each(TaiRangeList, node2) { - TaiRangeItem = node2->data; - ogs_assert(TaiRangeItem); - - if (TaiRangeItem->plmn_id) - ogs_sbi_free_plmn_id(TaiRangeItem->plmn_id); - - TacRangeList = TaiRangeItem->tac_range_list; - OpenAPI_list_for_each(TacRangeList, node3) { - TacRangeItem = node3->data; - ogs_assert(TacRangeItem); - if (TacRangeItem->start) - ogs_free(TacRangeItem->start); - if (TacRangeItem->end) - ogs_free(TacRangeItem->end); - - ogs_free(TacRangeItem); - } - OpenAPI_list_free(TacRangeList); - - ogs_free(TaiRangeItem); - } - OpenAPI_list_free(TaiRangeList); - - ogs_free(SmfInfo); - } - if (SmfInfoMap->key) - ogs_free(SmfInfoMap->key); - ogs_free(SmfInfoMap); - } - } - OpenAPI_list_free(SmfInfoList); - - return request; -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/nnrf-build.h
Deleted
@@ -1,35 +0,0 @@ -/* - * Copyright (C) 2019,2020 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_NNRF_BUILD_H -#define SMF_NNRF_BUILD_H - -#include "context.h" - -#ifdef __cplusplus -extern "C" { -#endif - -ogs_sbi_request_t *smf_nnrf_nfm_build_register(void); - -#ifdef __cplusplus -} -#endif - -#endif /* SMF_NNRF_BUILD_H */
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udm/nf-sm.c
Deleted
@@ -1,447 +0,0 @@ -/* - * Copyright (C) 2019,2020 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/>. - */ - -#include "context.h" - -#include "sbi-path.h" -#include "nnrf-handler.h" - -void udm_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance) -{ - udm_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_create(&nf_instance->sm, - udm_nf_state_initial, udm_nf_state_final); - ogs_fsm_init(&nf_instance->sm, &e); -} - -void udm_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance) -{ - udm_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_fini(&nf_instance->sm, &e); - ogs_fsm_delete(&nf_instance->sm); -} - -void udm_nf_state_initial(ogs_fsm_t *s, udm_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - udm_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - nf_instance->t_registration_interval = ogs_timer_add(ogs_app()->timer_mgr, - udm_timer_nf_instance_registration_interval, nf_instance); - ogs_assert(nf_instance->t_registration_interval); - nf_instance->t_heartbeat_interval = ogs_timer_add(ogs_app()->timer_mgr, - udm_timer_nf_instance_heartbeat_interval, nf_instance); - ogs_assert(nf_instance->t_heartbeat_interval); - nf_instance->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr, - udm_timer_nf_instance_no_heartbeat, nf_instance); - ogs_assert(nf_instance->t_no_heartbeat); - nf_instance->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - udm_timer_nf_instance_validity, nf_instance); - ogs_assert(nf_instance->t_validity); - - if (NF_INSTANCE_IS_NRF(nf_instance)) { - OGS_FSM_TRAN(s, &udm_nf_state_will_register); - } else { - ogs_assert(nf_instance->id); - OGS_FSM_TRAN(s, &udm_nf_state_registered); - } -} - -void udm_nf_state_final(ogs_fsm_t *s, udm_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - udm_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - ogs_timer_delete(nf_instance->t_registration_interval); - ogs_timer_delete(nf_instance->t_heartbeat_interval); - ogs_timer_delete(nf_instance->t_no_heartbeat); - ogs_timer_delete(nf_instance->t_validity); -} - -void udm_nf_state_will_register(ogs_fsm_t *s, udm_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_sockaddr_t *addr = NULL; - - ogs_assert(s); - ogs_assert(e); - - udm_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - ogs_assert(NF_INSTANCE_IS_NRF(nf_instance)); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, udm_nnrf_nfm_build_register)); - break; - - case OGS_FSM_EXIT_SIG: - ogs_timer_stop(nf_instance->t_registration_interval); - break; - - case UDM_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_OK || - message->res_status == OGS_SBI_HTTP_STATUS_CREATED) { - udm_nnrf_handle_nf_register(nf_instance, message); - OGS_FSM_TRAN(s, &udm_nf_state_registered); - } else { - ogs_error("%s HTTP response error %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &udm_nf_state_exception); - } - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case UDM_EVT_SBI_TIMER: - switch(e->timer_id) { - case UDM_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - client = nf_instance->client; - ogs_assert(client); - addr = client->node.addr; - ogs_assert(addr); - - ogs_warn("%s Retry to registration with NRF", - ogs_sbi_self()->nf_instance->id); - - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, udm_nnrf_nfm_build_register)); - break; - - default: - ogs_error("%s Unknown timer%s:%d", - ogs_sbi_self()->nf_instance->id, - udm_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("Unknown event %s", udm_event_get_name(e)); - break; - } -} - -void udm_nf_state_registered(ogs_fsm_t *s, udm_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_assert(s); - ogs_assert(e); - - udm_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF registered Heartbeat:%ds", - ogs_sbi_self()->nf_instance->id, - nf_instance->time.heartbeat_interval); - - client = nf_instance->client; - ogs_assert(client); - - if (nf_instance->time.heartbeat_interval) { - ogs_timer_start(nf_instance->t_heartbeat_interval, - ogs_time_from_sec(nf_instance->time.heartbeat_interval)); - ogs_timer_start(nf_instance->t_no_heartbeat, - ogs_time_from_sec( - nf_instance->time.heartbeat_interval + - ogs_app()->time.nf_instance.no_heartbeat_margin)); - } - - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_UDR)); - } - - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - - if (nf_instance->time.heartbeat_interval) { - ogs_timer_stop(nf_instance->t_heartbeat_interval); - ogs_timer_stop(nf_instance->t_no_heartbeat); - } - - if (!OGS_FSM_CHECK(&nf_instance->sm, udm_nf_state_exception)) { - ogs_assert(true == - ogs_nnrf_nfm_send_nf_de_register(nf_instance)); - } - } - break; - - case UDM_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_NO_CONTENT || - message->res_status == OGS_SBI_HTTP_STATUS_OK) { - if (nf_instance->time.heartbeat_interval) - ogs_timer_start(nf_instance->t_no_heartbeat, - ogs_time_from_sec( - nf_instance->time.heartbeat_interval + - ogs_app()->time.nf_instance. - no_heartbeat_margin)); - } else { - ogs_warn("%s HTTP response error %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &udm_nf_state_exception); - } - - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case UDM_EVT_SBI_TIMER: - switch(e->timer_id) { - case UDM_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - if (nf_instance->time.heartbeat_interval) - ogs_timer_start(nf_instance->t_heartbeat_interval, - ogs_time_from_sec(nf_instance->time.heartbeat_interval)); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_update(nf_instance)); - break; - - case UDM_TIMER_NF_INSTANCE_NO_HEARTBEAT: - ogs_error("%s No heartbeat", ogs_sbi_self()->nf_instance->id); - OGS_FSM_TRAN(s, &udm_nf_state_will_register); - break; - - case UDM_TIMER_NF_INSTANCE_VALIDITY: - ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance)); - ogs_assert(nf_instance->id); - - ogs_info("%s NF expired", nf_instance->id); - OGS_FSM_TRAN(s, &udm_nf_state_de_registered); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - udm_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - udm_event_get_name(e)); - break; - } -} - -void udm_nf_state_de_registered(ogs_fsm_t *s, udm_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_assert(s); - ogs_assert(e); - - udm_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - } - break; - - case OGS_FSM_EXIT_SIG: - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - udm_event_get_name(e)); - break; - } -} - -void udm_nf_state_exception(ogs_fsm_t *s, udm_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_sockaddr_t *addr = NULL; - ogs_assert(s); - ogs_assert(e); - - udm_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi. - nf_register_interval_in_exception); - } - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_timer_stop(nf_instance->t_registration_interval); - } - break; - - case UDM_EVT_SBI_TIMER: - switch(e->timer_id) { - case UDM_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - client = nf_instance->client; - ogs_assert(client); - addr = client->node.addr; - ogs_assert(addr); - - ogs_warn("%s Retry to registration with NRF", - ogs_sbi_self()->nf_instance->id); - - OGS_FSM_TRAN(s, &udm_nf_state_will_register); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - udm_timer_get_name(e->timer_id), e->timer_id); - } - break; - - case UDM_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - break; - DEFAULT - ogs_error("Invalid resource name %s", - message->h.resource.component0); - END - break; - DEFAULT - ogs_error("Invalid API name %s", message->h.service.name); - END - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - udm_event_get_name(e)); - break; - } -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udm/nnrf-build.c
Deleted
@@ -1,55 +0,0 @@ -/* - * Copyright (C) 2019,2020 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/>. - */ - -#include "nnrf-build.h" - -ogs_sbi_request_t *udm_nnrf_nfm_build_register(void) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_request_t *request = NULL; - - OpenAPI_nf_profile_t *NFProfile = NULL; - - nf_instance = ogs_sbi_self()->nf_instance; - ogs_assert(nf_instance); - ogs_assert(nf_instance->id); - - memset(&message, 0, sizeof(message)); - message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT; - message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; - message.h.api.version = (char *)OGS_SBI_API_V1; - message.h.resource.component0 = - (char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES; - message.h.resource.component1 = nf_instance->id; - - message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding; - - NFProfile = ogs_nnrf_nfm_build_nf_profile(); - ogs_expect_or_return_val(NFProfile, NULL); - - message.NFProfile = NFProfile; - - request = ogs_sbi_build_request(&message); - - ogs_sbi_nnrf_free_nf_profile(NFProfile); - - return request; -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udm/nnrf-build.h
Deleted
@@ -1,35 +0,0 @@ -/* - * Copyright (C) 2019,2020 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 UDM_NNRF_BUILD_H -#define UDM_NNRF_BUILD_H - -#include "context.h" - -#ifdef __cplusplus -extern "C" { -#endif - -ogs_sbi_request_t *udm_nnrf_nfm_build_register(void); - -#ifdef __cplusplus -} -#endif - -#endif /* UDM_NNRF_BUILD_H */
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udm/timer.c
Deleted
@@ -1,116 +0,0 @@ -/* - * Copyright (C) 2019,2020 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/>. - */ - -#include "context.h" - -const char *udm_timer_get_name(udm_timer_e id) -{ - switch (id) { - case UDM_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - return "UDM_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL"; - case UDM_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - return "UDM_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL"; - case UDM_TIMER_NF_INSTANCE_NO_HEARTBEAT: - return "UDM_TIMER_NF_INSTANCE_NO_HEARTBEAT"; - case UDM_TIMER_NF_INSTANCE_VALIDITY: - return "UDM_TIMER_NF_INSTANCE_VALIDITY"; - case UDM_TIMER_SUBSCRIPTION_VALIDITY: - return "UDM_TIMER_SUBSCRIPTION_VALIDITY"; - case UDM_TIMER_SBI_CLIENT_WAIT: - return "UDM_TIMER_SBI_CLIENT_WAIT"; - default: - break; - } - - return "UNKNOWN_TIMER"; -} - -static void sbi_timer_send_event(int timer_id, void *data) -{ - int rv; - udm_event_t *e = NULL; - ogs_assert(data); - - switch (timer_id) { - case UDM_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case UDM_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case UDM_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case UDM_TIMER_NF_INSTANCE_VALIDITY: - case UDM_TIMER_SUBSCRIPTION_VALIDITY: - e = udm_event_new(UDM_EVT_SBI_TIMER); - ogs_assert(e); - e->timer_id = timer_id; - e->sbi.data = data; - break; - case UDM_TIMER_SBI_CLIENT_WAIT: - e = udm_event_new(UDM_EVT_SBI_TIMER); - if (!e) { - ogs_sbi_xact_t *sbi_xact = data; - ogs_assert(sbi_xact); - - ogs_error("sbi_timer_send_event() failed"); - ogs_sbi_xact_remove(sbi_xact); - return; - } - e->timer_id = timer_id; - e->sbi.data = data; - break; - default: - ogs_fatal("Unknown timer id%d", timer_id); - ogs_assert_if_reached(); - break; - } - - rv = ogs_queue_push(ogs_app()->queue, e); - if (rv != OGS_OK) { - ogs_error("ogs_queue_push() failed %d in %s", - (int)rv, udm_timer_get_name(e->timer_id)); - udm_event_free(e); - } -} - -void udm_timer_nf_instance_registration_interval(void *data) -{ - sbi_timer_send_event(UDM_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, data); -} - -void udm_timer_nf_instance_heartbeat_interval(void *data) -{ - sbi_timer_send_event(UDM_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, data); -} - -void udm_timer_nf_instance_no_heartbeat(void *data) -{ - sbi_timer_send_event(UDM_TIMER_NF_INSTANCE_NO_HEARTBEAT, data); -} - -void udm_timer_nf_instance_validity(void *data) -{ - sbi_timer_send_event(UDM_TIMER_NF_INSTANCE_VALIDITY, data); -} - -void udm_timer_subscription_validity(void *data) -{ - sbi_timer_send_event(UDM_TIMER_SUBSCRIPTION_VALIDITY, data); -} - -void udm_timer_sbi_client_wait_expire(void *data) -{ - sbi_timer_send_event(UDM_TIMER_SBI_CLIENT_WAIT, data); -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udm/timer.h
Deleted
@@ -1,57 +0,0 @@ -/* - * 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 UDM_TIMER_H -#define UDM_TIMER_H - -#include "ogs-core.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* forward declaration */ -typedef enum { - UDM_TIMER_BASE = 0, - - UDM_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, - UDM_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, - UDM_TIMER_NF_INSTANCE_NO_HEARTBEAT, - UDM_TIMER_NF_INSTANCE_VALIDITY, - UDM_TIMER_SUBSCRIPTION_VALIDITY, - UDM_TIMER_SBI_CLIENT_WAIT, - - MAX_NUM_OF_UDM_TIMER, - -} udm_timer_e; - -const char *udm_timer_get_name(udm_timer_e id); - -void udm_timer_nf_instance_registration_interval(void *data); -void udm_timer_nf_instance_heartbeat_interval(void *data); -void udm_timer_nf_instance_no_heartbeat(void *data); -void udm_timer_nf_instance_validity(void *data); -void udm_timer_subscription_validity(void *data); -void udm_timer_sbi_client_wait_expire(void *data); - -#ifdef __cplusplus -} -#endif - -#endif /* UDM_TIMER_H */
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udr/nf-sm.c
Deleted
@@ -1,441 +0,0 @@ -/* - * Copyright (C) 2019,2020 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/>. - */ - -#include "context.h" - -#include "sbi-path.h" -#include "nnrf-handler.h" - -void udr_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance) -{ - udr_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_create(&nf_instance->sm, - udr_nf_state_initial, udr_nf_state_final); - ogs_fsm_init(&nf_instance->sm, &e); -} - -void udr_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance) -{ - udr_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_fini(&nf_instance->sm, &e); - ogs_fsm_delete(&nf_instance->sm); -} - -void udr_nf_state_initial(ogs_fsm_t *s, udr_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - udr_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - nf_instance->t_registration_interval = ogs_timer_add(ogs_app()->timer_mgr, - udr_timer_nf_instance_registration_interval, nf_instance); - ogs_assert(nf_instance->t_registration_interval); - nf_instance->t_heartbeat_interval = ogs_timer_add(ogs_app()->timer_mgr, - udr_timer_nf_instance_heartbeat_interval, nf_instance); - ogs_assert(nf_instance->t_heartbeat_interval); - nf_instance->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr, - udr_timer_nf_instance_no_heartbeat, nf_instance); - ogs_assert(nf_instance->t_no_heartbeat); - nf_instance->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - udr_timer_nf_instance_validity, nf_instance); - ogs_assert(nf_instance->t_validity); - - if (NF_INSTANCE_IS_NRF(nf_instance)) { - OGS_FSM_TRAN(s, &udr_nf_state_will_register); - } else { - ogs_assert(nf_instance->id); - OGS_FSM_TRAN(s, &udr_nf_state_registered); - } -} - -void udr_nf_state_final(ogs_fsm_t *s, udr_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - udr_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - ogs_timer_delete(nf_instance->t_registration_interval); - ogs_timer_delete(nf_instance->t_heartbeat_interval); - ogs_timer_delete(nf_instance->t_no_heartbeat); - ogs_timer_delete(nf_instance->t_validity); -} - -void udr_nf_state_will_register(ogs_fsm_t *s, udr_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_sockaddr_t *addr = NULL; - - ogs_assert(s); - ogs_assert(e); - - udr_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - ogs_assert(NF_INSTANCE_IS_NRF(nf_instance)); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, udr_nnrf_nfm_build_register)); - break; - - case OGS_FSM_EXIT_SIG: - ogs_timer_stop(nf_instance->t_registration_interval); - break; - - case UDR_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_OK || - message->res_status == OGS_SBI_HTTP_STATUS_CREATED) { - udr_nnrf_handle_nf_register(nf_instance, message); - OGS_FSM_TRAN(s, &udr_nf_state_registered); - } else { - ogs_error("%s HTTP response error %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &udr_nf_state_exception); - } - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case UDR_EVT_SBI_TIMER: - switch(e->timer_id) { - case UDR_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - client = nf_instance->client; - ogs_assert(client); - addr = client->node.addr; - ogs_assert(addr); - - ogs_warn("%s Retry to registration with NRF", - ogs_sbi_self()->nf_instance->id); - - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_register( - nf_instance, udr_nnrf_nfm_build_register)); - break; - - default: - ogs_error("%s Unknown timer%s:%d", - ogs_sbi_self()->nf_instance->id, - udr_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("Unknown event %s", udr_event_get_name(e)); - break; - } -} - -void udr_nf_state_registered(ogs_fsm_t *s, udr_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_assert(s); - ogs_assert(e); - - udr_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF registered Heartbeat:%ds", - ogs_sbi_self()->nf_instance->id, - nf_instance->time.heartbeat_interval); - - client = nf_instance->client; - ogs_assert(client); - - if (nf_instance->time.heartbeat_interval) { - ogs_timer_start(nf_instance->t_heartbeat_interval, - ogs_time_from_sec(nf_instance->time.heartbeat_interval)); - ogs_timer_start(nf_instance->t_no_heartbeat, - ogs_time_from_sec( - nf_instance->time.heartbeat_interval + - ogs_app()->time.nf_instance.no_heartbeat_margin)); - } - } - - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - - if (nf_instance->time.heartbeat_interval) { - ogs_timer_stop(nf_instance->t_heartbeat_interval); - ogs_timer_stop(nf_instance->t_no_heartbeat); - } - - if (!OGS_FSM_CHECK(&nf_instance->sm, udr_nf_state_exception)) { - ogs_assert(true == - ogs_nnrf_nfm_send_nf_de_register(nf_instance)); - } - } - break; - - case UDR_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_NO_CONTENT || - message->res_status == OGS_SBI_HTTP_STATUS_OK) { - if (nf_instance->time.heartbeat_interval) - ogs_timer_start(nf_instance->t_no_heartbeat, - ogs_time_from_sec( - nf_instance->time.heartbeat_interval + - ogs_app()->time.nf_instance. - no_heartbeat_margin)); - } else { - ogs_warn("%s HTTP response error %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &udr_nf_state_exception); - } - - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case UDR_EVT_SBI_TIMER: - switch(e->timer_id) { - case UDR_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - if (nf_instance->time.heartbeat_interval) - ogs_timer_start(nf_instance->t_heartbeat_interval, - ogs_time_from_sec(nf_instance->time.heartbeat_interval)); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_update(nf_instance)); - break; - - case UDR_TIMER_NF_INSTANCE_NO_HEARTBEAT: - ogs_error("%s No heartbeat", ogs_sbi_self()->nf_instance->id); - OGS_FSM_TRAN(s, &udr_nf_state_will_register); - break; - - case UDR_TIMER_NF_INSTANCE_VALIDITY: - ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance)); - ogs_assert(nf_instance->id); - - ogs_info("%s NF expired", nf_instance->id); - OGS_FSM_TRAN(s, &udr_nf_state_de_registered); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - udr_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - udr_event_get_name(e)); - break; - } -} - -void udr_nf_state_de_registered(ogs_fsm_t *s, udr_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_assert(s); - ogs_assert(e); - - udr_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - } - break; - - case OGS_FSM_EXIT_SIG: - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - udr_event_get_name(e)); - break; - } -} - -void udr_nf_state_exception(ogs_fsm_t *s, udr_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_sockaddr_t *addr = NULL; - ogs_assert(s); - ogs_assert(e); - - udr_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi. - nf_register_interval_in_exception); - } - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_timer_stop(nf_instance->t_registration_interval); - } - break; - - case UDR_EVT_SBI_TIMER: - switch(e->timer_id) { - case UDR_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - client = nf_instance->client; - ogs_assert(client); - addr = client->node.addr; - ogs_assert(addr); - - ogs_warn("%s Retry to registration with NRF", - ogs_sbi_self()->nf_instance->id); - - OGS_FSM_TRAN(s, &udr_nf_state_will_register); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - udr_timer_get_name(e->timer_id), e->timer_id); - } - break; - - case UDR_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - break; - DEFAULT - ogs_error("Invalid resource name %s", - message->h.resource.component0); - END - break; - DEFAULT - ogs_error("Invalid API name %s", message->h.service.name); - END - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - udr_event_get_name(e)); - break; - } -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udr/nnrf-build.c
Deleted
@@ -1,55 +0,0 @@ -/* - * Copyright (C) 2019,2020 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/>. - */ - -#include "nnrf-build.h" - -ogs_sbi_request_t *udr_nnrf_nfm_build_register(void) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_request_t *request = NULL; - - OpenAPI_nf_profile_t *NFProfile = NULL; - - nf_instance = ogs_sbi_self()->nf_instance; - ogs_assert(nf_instance); - ogs_assert(nf_instance->id); - - memset(&message, 0, sizeof(message)); - message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT; - message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; - message.h.api.version = (char *)OGS_SBI_API_V1; - message.h.resource.component0 = - (char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES; - message.h.resource.component1 = nf_instance->id; - - message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding; - - NFProfile = ogs_nnrf_nfm_build_nf_profile(); - ogs_expect_or_return_val(NFProfile, NULL); - - message.NFProfile = NFProfile; - - request = ogs_sbi_build_request(&message); - - ogs_sbi_nnrf_free_nf_profile(NFProfile); - - return request; -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udr/nnrf-build.h
Deleted
@@ -1,35 +0,0 @@ -/* - * Copyright (C) 2019,2020 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 UDR_NNRF_BUILD_H -#define UDR_NNRF_BUILD_H - -#include "context.h" - -#ifdef __cplusplus -extern "C" { -#endif - -ogs_sbi_request_t *udr_nnrf_nfm_build_register(void); - -#ifdef __cplusplus -} -#endif - -#endif /* UDR_NNRF_BUILD_H */
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udr/nnrf-handler.c
Deleted
@@ -1,248 +0,0 @@ -/* - * Copyright (C) 2019,2020 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/>. - */ - -#include "sbi-path.h" -#include "nnrf-handler.h" - -void udr_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_nf_profile_t *NFProfile = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(nf_instance); - client = nf_instance->client; - ogs_assert(client); - - NFProfile = recvmsg->NFProfile; - if (!NFProfile) { - ogs_error("No NFProfile"); - return; - } - - /* TIME : Update heartbeat from NRF */ - if (NFProfile->is_heart_beat_timer == true) - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; -} - -void udr_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_subscription_data_t *SubscriptionData = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(subscription); - client = subscription->client; - ogs_assert(client); - - SubscriptionData = recvmsg->SubscriptionData; - if (!SubscriptionData) { - ogs_error("No SubscriptionData"); - return; - } - - if (!SubscriptionData->subscription_id) { - ogs_error("No SubscriptionId"); - return; - } - ogs_sbi_subscription_set_id( - subscription, SubscriptionData->subscription_id); - - if (SubscriptionData->validity_time) { -#define VALIDITY_MINIMUM (10LL * OGS_USEC_PER_SEC) /* 10 seconds */ - ogs_time_t time, duration; - if (ogs_sbi_time_from_string( - &time, SubscriptionData->validity_time) == true) { - duration = time - ogs_time_now(); - if (duration < VALIDITY_MINIMUM) { - duration = VALIDITY_MINIMUM; - ogs_warn("%s Forced to %lld seconds", subscription->id, - (long long)ogs_time_sec(VALIDITY_MINIMUM)); - } - subscription->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - udr_timer_subscription_validity, subscription); - ogs_assert(subscription->t_validity); - ogs_timer_start(subscription->t_validity, duration); - } else { - ogs_error("Cannot parse validitiyTime %s", - SubscriptionData->validity_time); - } - } -} - -bool udr_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) -{ - int rv; - bool handled; - - ogs_sbi_response_t *response = NULL; - OpenAPI_notification_data_t *NotificationData = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_header_t header; - - ogs_assert(stream); - ogs_assert(recvmsg); - - NotificationData = recvmsg->NotificationData; - if (!NotificationData) { - ogs_error("No NotificationData"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NotificationData", NULL)); - return false; - } - - if (!NotificationData->nf_instance_uri) { - ogs_error("No nfInstanceUri"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No nfInstanceUri", NULL)); - return false; - } - - memset(&header, 0, sizeof(header)); - header.uri = NotificationData->nf_instance_uri; - - rv = ogs_sbi_parse_header(&message, &header); - if (rv != OGS_OK) { - ogs_error("Cannot parse nfInstanceUri %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - return false; - } - - if (!message.h.resource.component1) { - ogs_error("No nfInstanceId %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - ogs_sbi_header_free(&header); - return false; - } - - if (NF_INSTANCE_IS_SELF(message.h.resource.component1)) { - ogs_warn("%s The notification is not allowed", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_FORBIDDEN, - recvmsg, "The notification is not allowed", - message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - - if (NotificationData->event == - OpenAPI_notification_event_type_NF_REGISTERED) { - - OpenAPI_nf_profile_t *NFProfile = NULL; - - NFProfile = NotificationData->nf_profile; - if (!NFProfile) { - ogs_error("No NFProfile"); - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NFProfile", NULL)); - ogs_sbi_header_free(&header); - return false; - } - - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, - message.h.resource.component1); - - udr_nf_fsm_init(nf_instance); - - ogs_info("%s (NRF-notify) NF registered", nf_instance->id); - - } else { - OGS_FSM_TRAN(&nf_instance->sm, udr_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NRF-notify) NF has already been added", - message.h.resource.component1); - - } - - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, stream, recvmsg); - if (!handled) { - UDR_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - ogs_info("%s (NRF-notify) NF Profile updated", nf_instance->id); - - handled = ogs_sbi_client_associate(nf_instance); - if (!handled) { - ogs_error("%s Cannot associate NF EndPoint", nf_instance->id); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot find NF EndPoint", nf_instance->id)); - UDR_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - } else if (NotificationData->event == - OpenAPI_notification_event_type_NF_DEREGISTERED) { - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (nf_instance) { - UDR_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - } else { - ogs_warn("%s (NRF-notify) Not found", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_NOT_FOUND, - recvmsg, "Not found", message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - } else { - char *eventstr = OpenAPI_notification_event_type_ToString( - NotificationData->event); - ogs_error("Not supported event %d:%s", - NotificationData->event, eventstr ? eventstr : "Unknown"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Not supported event", - eventstr ? eventstr : "Unknown")); - ogs_sbi_header_free(&header); - return false; - } - - response = ogs_sbi_build_response(recvmsg, OGS_SBI_HTTP_STATUS_NO_CONTENT); - ogs_assert(response); - ogs_assert(true == ogs_sbi_server_send_response(stream, response)); - - ogs_sbi_header_free(&header); - return true; -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udr/nnrf-handler.h
Deleted
@@ -1,41 +0,0 @@ -/* - * Copyright (C) 2019,2020 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 UDR_NNRF_HANDLER_H -#define UDR_NNRF_HANDLER_H - -#include "context.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void udr_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg); -void udr_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg); - -bool udr_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); - -#ifdef __cplusplus -} -#endif - -#endif /* UDR_NNRF_HANDLER_H */
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udr/timer.c
Deleted
@@ -1,101 +0,0 @@ -/* - * Copyright (C) 2019,2020 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/>. - */ - -#include "context.h" - -const char *udr_timer_get_name(udr_timer_e id) -{ - switch (id) { - case UDR_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - return "UDR_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL"; - case UDR_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - return "UDR_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL"; - case UDR_TIMER_NF_INSTANCE_NO_HEARTBEAT: - return "UDR_TIMER_NF_INSTANCE_NO_HEARTBEAT"; - case UDR_TIMER_NF_INSTANCE_VALIDITY: - return "UDR_TIMER_NF_INSTANCE_VALIDITY"; - case UDR_TIMER_SUBSCRIPTION_VALIDITY: - return "UDR_TIMER_SUBSCRIPTION_VALIDITY"; - default: - break; - } - - return "UNKNOWN_TIMER"; -} - -static void sbi_timer_send_event(int timer_id, void *data) -{ - int rv; - udr_event_t *e = NULL; - ogs_assert(data); - - switch (timer_id) { - case UDR_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case UDR_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case UDR_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case UDR_TIMER_NF_INSTANCE_VALIDITY: - case UDR_TIMER_SUBSCRIPTION_VALIDITY: - e = udr_event_new(UDR_EVT_SBI_TIMER); - ogs_assert(e); - e->timer_id = timer_id; - e->sbi.data = data; - break; - default: - ogs_fatal("Unknown timer id%d", timer_id); - ogs_assert_if_reached(); - break; - } - - rv = ogs_queue_push(ogs_app()->queue, e); - if (rv != OGS_OK) { - ogs_error("ogs_queue_push() failed %d in %s", - (int)rv, udr_timer_get_name(e->timer_id)); - udr_event_free(e); - } -} - -void udr_timer_nf_instance_registration_interval(void *data) -{ - sbi_timer_send_event(UDR_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, data); -} - -void udr_timer_nf_instance_heartbeat_interval(void *data) -{ - sbi_timer_send_event(UDR_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, data); -} - -void udr_timer_nf_instance_no_heartbeat(void *data) -{ - sbi_timer_send_event(UDR_TIMER_NF_INSTANCE_NO_HEARTBEAT, data); -} - -void udr_timer_nf_instance_validity(void *data) -{ - sbi_timer_send_event(UDR_TIMER_NF_INSTANCE_VALIDITY, data); -} - -void udr_timer_subscription_validity(void *data) -{ - sbi_timer_send_event(UDR_TIMER_SUBSCRIPTION_VALIDITY, data); -} - -void udr_timer_sbi_client_wait_expire(void *data) -{ - sbi_timer_send_event(UDR_TIMER_SBI_CLIENT_WAIT, data); -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udr/timer.h
Deleted
@@ -1,57 +0,0 @@ -/* - * 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 UDR_TIMER_H -#define UDR_TIMER_H - -#include "ogs-core.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* forward declaration */ -typedef enum { - UDR_TIMER_BASE = 0, - - UDR_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, - UDR_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, - UDR_TIMER_NF_INSTANCE_NO_HEARTBEAT, - UDR_TIMER_NF_INSTANCE_VALIDITY, - UDR_TIMER_SUBSCRIPTION_VALIDITY, - UDR_TIMER_SBI_CLIENT_WAIT, - - MAX_NUM_OF_UDR_TIMER, - -} udr_timer_e; - -const char *udr_timer_get_name(udr_timer_e id); - -void udr_timer_nf_instance_registration_interval(void *data); -void udr_timer_nf_instance_heartbeat_interval(void *data); -void udr_timer_nf_instance_no_heartbeat(void *data); -void udr_timer_nf_instance_validity(void *data); -void udr_timer_subscription_validity(void *data); -void udr_timer_sbi_client_wait_expire(void *data); - -#ifdef __cplusplus -} -#endif - -#endif /* UDR_TIMER_H */
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/tests/af/nf-sm.c
Deleted
@@ -1,448 +0,0 @@ -/* - * 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/>. - */ - -#include "context.h" - -#include "sbi-path.h" -#include "nnrf-handler.h" - -void af_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance) -{ - af_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_create(&nf_instance->sm, - af_nf_state_initial, af_nf_state_final); - ogs_fsm_init(&nf_instance->sm, &e); -} - -void af_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance) -{ - af_event_t e; - - ogs_assert(nf_instance); - - memset(&e, 0, sizeof(e)); - e.sbi.data = nf_instance; - - ogs_fsm_fini(&nf_instance->sm, &e); - ogs_fsm_delete(&nf_instance->sm); -} - -void af_nf_state_initial(ogs_fsm_t *s, af_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - af_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - nf_instance->t_registration_interval = ogs_timer_add(ogs_app()->timer_mgr, - af_timer_nf_instance_registration_interval, nf_instance); - ogs_assert(nf_instance->t_registration_interval); - nf_instance->t_heartbeat_interval = ogs_timer_add(ogs_app()->timer_mgr, - af_timer_nf_instance_heartbeat_interval, nf_instance); - ogs_assert(nf_instance->t_heartbeat_interval); - nf_instance->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr, - af_timer_nf_instance_no_heartbeat, nf_instance); - ogs_assert(nf_instance->t_no_heartbeat); - nf_instance->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - af_timer_nf_instance_validity, nf_instance); - ogs_assert(nf_instance->t_validity); - - if (NF_INSTANCE_IS_NRF(nf_instance)) { - OGS_FSM_TRAN(s, &af_nf_state_will_register); - } else { - ogs_assert(nf_instance->id); - OGS_FSM_TRAN(s, &af_nf_state_registered); - } -} - -void af_nf_state_final(ogs_fsm_t *s, af_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(s); - ogs_assert(e); - - af_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - - ogs_timer_delete(nf_instance->t_registration_interval); - ogs_timer_delete(nf_instance->t_heartbeat_interval); - ogs_timer_delete(nf_instance->t_no_heartbeat); - ogs_timer_delete(nf_instance->t_validity); -} - -void af_nf_state_will_register(ogs_fsm_t *s, af_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_sockaddr_t *addr = NULL; - - ogs_assert(s); - ogs_assert(e); - - af_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - ogs_assert(NF_INSTANCE_IS_NRF(nf_instance)); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == af_nnrf_nfm_send_nf_register(nf_instance)); - break; - - case OGS_FSM_EXIT_SIG: - ogs_timer_stop(nf_instance->t_registration_interval); - break; - - case AF_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_OK || - message->res_status == OGS_SBI_HTTP_STATUS_CREATED) { - af_nnrf_handle_nf_register(nf_instance, message); - OGS_FSM_TRAN(s, &af_nf_state_registered); - } else { - ogs_error("%s HTTP Response Status Code %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &af_nf_state_exception); - } - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case AF_EVT_SBI_TIMER: - switch(e->timer_id) { - case AF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - client = nf_instance->client; - ogs_assert(client); - addr = client->node.addr; - ogs_assert(addr); - - ogs_warn("%s Retry to registration with NRF", - ogs_sbi_self()->nf_instance->id); - - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi.nf_register_interval); - - ogs_assert(true == af_nnrf_nfm_send_nf_register(nf_instance)); - break; - - default: - ogs_error("%s Unknown timer%s:%d", - ogs_sbi_self()->nf_instance->id, - af_timer_get_name(e->timer_id), e->timer_id); - } - break; - - default: - ogs_error("%s Unknown event %s", - ogs_sbi_self()->nf_instance->id, af_event_get_name(e)); - break; - } -} - -void af_nf_state_registered(ogs_fsm_t *s, af_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_assert(s); - ogs_assert(e); - - af_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF registered Heartbeat:%ds", - ogs_sbi_self()->nf_instance->id, - nf_instance->time.heartbeat_interval); - - client = nf_instance->client; - ogs_assert(client); - - if (nf_instance->time.heartbeat_interval) { - ogs_timer_start(nf_instance->t_heartbeat_interval, - ogs_time_from_sec(nf_instance->time.heartbeat_interval)); - ogs_timer_start(nf_instance->t_no_heartbeat, - ogs_time_from_sec( - nf_instance->time.heartbeat_interval + - ogs_app()->time.nf_instance.no_heartbeat_margin)); - } - - ogs_assert(true == - ogs_nnrf_nfm_send_nf_status_subscribe(client, - ogs_sbi_self()->nf_instance->nf_type, - ogs_sbi_self()->nf_instance->id, - OpenAPI_nf_type_BSF)); - } - - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - - if (nf_instance->time.heartbeat_interval) { - ogs_timer_stop(nf_instance->t_heartbeat_interval); - ogs_timer_stop(nf_instance->t_no_heartbeat); - } - - if (!OGS_FSM_CHECK(&nf_instance->sm, af_nf_state_exception)) { - ogs_assert(true == - ogs_nnrf_nfm_send_nf_de_register(nf_instance)); - } - } - break; - - case AF_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - - if (message->res_status == OGS_SBI_HTTP_STATUS_NO_CONTENT || - message->res_status == OGS_SBI_HTTP_STATUS_OK) { - if (nf_instance->time.heartbeat_interval) - ogs_timer_start(nf_instance->t_no_heartbeat, - ogs_time_from_sec( - nf_instance->time.heartbeat_interval + - ogs_app()->time.nf_instance. - no_heartbeat_margin)); - } else { - ogs_warn("%s HTTP response error %d", - ogs_sbi_self()->nf_instance->id, - message->res_status); - OGS_FSM_TRAN(s, &af_nf_state_exception); - } - - break; - - DEFAULT - ogs_error("%s Invalid resource name %s", - ogs_sbi_self()->nf_instance->id, - message->h.resource.component0); - END - break; - - DEFAULT - ogs_error("%s Invalid API name %s", - ogs_sbi_self()->nf_instance->id, message->h.service.name); - END - break; - - case AF_EVT_SBI_TIMER: - switch(e->timer_id) { - case AF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - if (nf_instance->time.heartbeat_interval) - ogs_timer_start(nf_instance->t_heartbeat_interval, - ogs_time_from_sec(nf_instance->time.heartbeat_interval)); - - ogs_assert(true == ogs_nnrf_nfm_send_nf_update(nf_instance)); - break; - - case AF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - ogs_error("%s No heartbeat", ogs_sbi_self()->nf_instance->id); - OGS_FSM_TRAN(s, &af_nf_state_will_register); - break; - - case AF_TIMER_NF_INSTANCE_VALIDITY: - ogs_assert(!NF_INSTANCE_IS_NRF(nf_instance)); - ogs_assert(nf_instance->id); - - ogs_info("%s NF expired", nf_instance->id); - OGS_FSM_TRAN(s, &af_nf_state_de_registered); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - af_timer_get_name(e->timer_id), e->timer_id); - break; - } - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - af_event_get_name(e)); - break; - } -} - -void af_nf_state_de_registered(ogs_fsm_t *s, af_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_assert(s); - ogs_assert(e); - - af_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); - } - break; - - case OGS_FSM_EXIT_SIG: - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - af_event_get_name(e)); - break; - } -} - -void af_nf_state_exception(ogs_fsm_t *s, af_event_t *e) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_sbi_client_t *client = NULL; - ogs_sbi_message_t *message = NULL; - ogs_sockaddr_t *addr = NULL; - ogs_assert(s); - ogs_assert(e); - - af_sm_debug(e); - - nf_instance = e->sbi.data; - ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_instance); - - switch (e->id) { - case OGS_FSM_ENTRY_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_timer_start(nf_instance->t_registration_interval, - ogs_app()->time.message.sbi. - nf_register_interval_in_exception); - } - break; - - case OGS_FSM_EXIT_SIG: - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_timer_stop(nf_instance->t_registration_interval); - } - break; - - case AF_EVT_SBI_TIMER: - switch(e->timer_id) { - case AF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - client = nf_instance->client; - ogs_assert(client); - addr = client->node.addr; - ogs_assert(addr); - - ogs_warn("%s Retry to registration with NRF", - ogs_sbi_self()->nf_instance->id); - - OGS_FSM_TRAN(s, &af_nf_state_will_register); - break; - - default: - ogs_error("%s:%s Unknown timer%s:%d", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - af_timer_get_name(e->timer_id), e->timer_id); - break; - } - break; - - case AF_EVT_SBI_CLIENT: - message = e->sbi.message; - ogs_assert(message); - - SWITCH(message->h.service.name) - CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) - - SWITCH(message->h.resource.component0) - CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - break; - DEFAULT - ogs_error("Invalid resource name %s", - message->h.resource.component0); - END - break; - DEFAULT - ogs_error("Invalid API name %s", message->h.service.name); - END - break; - - default: - ogs_error("%s:%s Unknown event %s", - OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id ? nf_instance->id : "Undefined", - af_event_get_name(e)); - break; - } -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/tests/af/nnrf-build.c
Deleted
@@ -1,55 +0,0 @@ -/* - * Copyright (C) 2019,2020 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/>. - */ - -#include "nnrf-build.h" - -ogs_sbi_request_t *af_nnrf_nfm_build_register(void) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_request_t *request = NULL; - - OpenAPI_nf_profile_t *NFProfile = NULL; - - nf_instance = ogs_sbi_self()->nf_instance; - ogs_assert(nf_instance); - ogs_assert(nf_instance->id); - - memset(&message, 0, sizeof(message)); - message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT; - message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; - message.h.api.version = (char *)OGS_SBI_API_V1; - message.h.resource.component0 = - (char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES; - message.h.resource.component1 = nf_instance->id; - - message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding; - - NFProfile = ogs_nnrf_nfm_build_nf_profile(); - ogs_expect_or_return_val(NFProfile, NULL); - - message.NFProfile = NFProfile; - - request = ogs_sbi_build_request(&message); - - ogs_sbi_nnrf_free_nf_profile(NFProfile); - - return request; -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/tests/af/nnrf-build.h
Deleted
@@ -1,35 +0,0 @@ -/* - * Copyright (C) 2019,2020 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_NNRF_BUILD_H -#define AF_NNRF_BUILD_H - -#include "context.h" - -#ifdef __cplusplus -extern "C" { -#endif - -ogs_sbi_request_t *af_nnrf_nfm_build_register(void); - -#ifdef __cplusplus -} -#endif - -#endif /* AF_NNRF_BUILD_H */
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/tests/af/timer.c
Deleted
@@ -1,116 +0,0 @@ -/* - * 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/>. - */ - -#include "context.h" - -const char *af_timer_get_name(af_timer_e id) -{ - switch (id) { - case AF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - return "AF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL"; - case AF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - return "AF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL"; - case AF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - return "AF_TIMER_NF_INSTANCE_NO_HEARTBEAT"; - case AF_TIMER_NF_INSTANCE_VALIDITY: - return "AF_TIMER_NF_INSTANCE_VALIDITY"; - case AF_TIMER_SUBSCRIPTION_VALIDITY: - return "AF_TIMER_SUBSCRIPTION_VALIDITY"; - case AF_TIMER_SBI_CLIENT_WAIT: - return "AF_TIMER_SBI_CLIENT_WAIT"; - default: - break; - } - - return "UNKNOWN_TIMER"; -} - -static void timer_send_event(int timer_id, void *data) -{ - int rv; - af_event_t *e = NULL; - ogs_assert(data); - - switch (timer_id) { - case AF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case AF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case AF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case AF_TIMER_NF_INSTANCE_VALIDITY: - case AF_TIMER_SUBSCRIPTION_VALIDITY: - e = af_event_new(AF_EVT_SBI_TIMER); - ogs_assert(e); - e->timer_id = timer_id; - e->sbi.data = data; - break; - case AF_TIMER_SBI_CLIENT_WAIT: - e = af_event_new(AF_EVT_SBI_TIMER); - if (!e) { - ogs_sbi_xact_t *sbi_xact = data; - ogs_assert(sbi_xact); - - ogs_error("timer_send_event() failed"); - ogs_sbi_xact_remove(sbi_xact); - return; - } - e->timer_id = timer_id; - e->sbi.data = data; - break; - default: - ogs_fatal("Unknown timer id%d", timer_id); - ogs_assert_if_reached(); - break; - } - - rv = ogs_queue_push(ogs_app()->queue, e); - if (rv != OGS_OK) { - ogs_error("ogs_queue_push() failed %d in %s", - (int)rv, af_timer_get_name(e->timer_id)); - af_event_free(e); - } -} - -void af_timer_nf_instance_registration_interval(void *data) -{ - timer_send_event(AF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, data); -} - -void af_timer_nf_instance_heartbeat_interval(void *data) -{ - timer_send_event(AF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, data); -} - -void af_timer_nf_instance_no_heartbeat(void *data) -{ - timer_send_event(AF_TIMER_NF_INSTANCE_NO_HEARTBEAT, data); -} - -void af_timer_nf_instance_validity(void *data) -{ - timer_send_event(AF_TIMER_NF_INSTANCE_VALIDITY, data); -} - -void af_timer_subscription_validity(void *data) -{ - timer_send_event(AF_TIMER_SUBSCRIPTION_VALIDITY, data); -} - -void af_timer_sbi_client_wait_expire(void *data) -{ - timer_send_event(AF_TIMER_SBI_CLIENT_WAIT, data); -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/tests/af/timer.h
Deleted
@@ -1,57 +0,0 @@ -/* - * 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 AF_TIMER_H -#define AF_TIMER_H - -#include "ogs-core.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* forward declaration */ -typedef enum { - AF_TIMER_BASE = 0, - - AF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, - AF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, - AF_TIMER_NF_INSTANCE_NO_HEARTBEAT, - AF_TIMER_NF_INSTANCE_VALIDITY, - AF_TIMER_SUBSCRIPTION_VALIDITY, - AF_TIMER_SBI_CLIENT_WAIT, - - MAX_NUM_OF_AF_TIMER, - -} af_timer_e; - -const char *af_timer_get_name(af_timer_e id); - -void af_timer_nf_instance_registration_interval(void *data); -void af_timer_nf_instance_heartbeat_interval(void *data); -void af_timer_nf_instance_no_heartbeat(void *data); -void af_timer_nf_instance_validity(void *data); -void af_timer_subscription_validity(void *data); -void af_timer_sbi_client_wait_expire(void *data); - -#ifdef __cplusplus -} -#endif - -#endif /* AF_TIMER_H */
View file
open5gs_2.4.9.17.603a74.202208130002.dsc
Added
@@ -0,0 +1,37 @@ +Format: 3.0 (native) +Source: open5gs +Binary: open5gs-common, open5gs-mme, open5gs-sgwc, open5gs-smf, open5gs-amf, open5gs-sgwu, open5gs-upf, open5gs-hss, open5gs-pcrf, open5gs-nrf, open5gs-ausf, open5gs-udm, open5gs-pcf, open5gs-nssf, open5gs-bsf, open5gs-udr, open5gs, open5gs-dbg +Architecture: any +Version: 2.4.9.17.603a74.202208130002 +Maintainer: Harald Welte <laforge@gnumonks.org> +Uploaders: Sukchan Lee <acetcom@gmail.com> +Homepage: https://open5gs.org +Standards-Version: 4.3.0 +Vcs-Browser: https://github.com/open5gs/open5gs +Vcs-Git: git://github.com/open5gs/open5gs +Build-Depends: debhelper (>= 11), git, pkg-config, meson (>= 0.43.0), flex, bison, libgnutls28-dev, libgcrypt-dev, libssl-dev, libidn11-dev, libmongoc-dev, libbson-dev, libsctp-dev, libyaml-dev, libmicrohttpd-dev, libcurl4-gnutls-dev, libnghttp2-dev, libtins-dev, libtalloc-dev +Package-List: + open5gs deb net optional arch=any + open5gs-amf deb net optional arch=any + open5gs-ausf deb net optional arch=any + open5gs-bsf deb net optional arch=any + open5gs-common deb net optional arch=any + open5gs-dbg deb net optional arch=any + open5gs-hss deb net optional arch=any + open5gs-mme deb net optional arch=any + open5gs-nrf deb net optional arch=any + open5gs-nssf deb net optional arch=any + open5gs-pcf deb net optional arch=any + open5gs-pcrf deb net optional arch=any + open5gs-sgwc deb net optional arch=any + open5gs-sgwu deb net optional arch=any + open5gs-smf deb net optional arch=any + open5gs-udm deb net optional arch=any + open5gs-udr deb net optional arch=any + open5gs-upf deb net optional arch=any +Checksums-Sha1: + e203a793b184481f4118b650788901f8c3ab4795 11453272 open5gs_2.4.9.17.603a74.202208130002.tar.xz +Checksums-Sha256: + 0e75ffd8f354655a844fab388da684486a9d963712aac4e42a50b8018fce4f40 11453272 open5gs_2.4.9.17.603a74.202208130002.tar.xz +Files: + 34082e17e1cc6e33ae701cb7bda61dd1 11453272 open5gs_2.4.9.17.603a74.202208130002.tar.xz
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/.tarball-version -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/.tarball-version
Changed
@@ -1 +1 @@ -2.4.9.14-ec9fe.202208120002 +2.4.9.17-603a74.202208130002
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/debian/changelog -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/debian/changelog
Changed
@@ -1,8 +1,8 @@ -open5gs (2.4.9.14.ec9fe.202208120002) unstable; urgency=medium +open5gs (2.4.9.17.603a74.202208130002) unstable; urgency=medium * Automatically generated changelog entry for building the Osmocom nightly feed - -- Osmocom OBS scripts <info@osmocom.org> Fri, 12 Aug 2022 00:04:33 +0000 + -- Osmocom OBS scripts <info@osmocom.org> Sat, 13 Aug 2022 00:04:25 +0000 open5gs (2.4.9) unstable; urgency=medium
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/app/meson.build -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/app/meson.build
Changed
@@ -38,11 +38,11 @@ version : libogslib_version, c_args : '-DOGS_APP_COMPILATION', include_directories : libapp_inc, libinc, - dependencies : libcore_dep, yaml_dep, + dependencies : libproto_dep, yaml_dep, install : true) libapp_dep = declare_dependency( link_with : libapp, include_directories : libapp_inc, libinc, - dependencies : libcore_dep, yaml_dep, + dependencies : libproto_dep, yaml_dep, )
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/app/ogs-app.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/app/ogs-app.h
Changed
@@ -20,7 +20,7 @@ #ifndef OGS_APP_H #define OGS_APP_H -#include "ogs-core.h" +#include "ogs-proto.h" #define OGS_APP_INSIDE
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/app/ogs-context.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/app/ogs-context.c
Changed
@@ -170,16 +170,6 @@ #define USRSCTP_LOCAL_UDP_PORT 9899 self.usrsctp.udp_port = USRSCTP_LOCAL_UDP_PORT; - self.sctp.heartbit_interval = 5000; /* 5 seconds */ - self.sctp.sack_delay = 200; /* 200 ms */ - self.sctp.rto_initial = 3000; /* 3 seconds */ - self.sctp.rto_min = 1000; /* 1 seconds */ - self.sctp.rto_max = 5000; /* 5 seconds */ - self.sctp.max_num_of_ostreams = OGS_DEFAULT_SCTP_MAX_NUM_OF_OSTREAMS; - self.sctp.max_num_of_istreams = 65535; - self.sctp.max_attempts = 4; - self.sctp.max_initial_timeout = 8000; /* 8 seconds */ - self.sockopt.no_delay = true; #define MAX_NUM_OF_UE 1024 /* Num of UEs */ @@ -379,48 +369,6 @@ } else ogs_warn("unknown key `%s`", sockopt_key); } - } else if (!strcmp(root_key, "sctp")) { - ogs_yaml_iter_t sctp_iter; - ogs_yaml_iter_recurse(&root_iter, &sctp_iter); - while (ogs_yaml_iter_next(&sctp_iter)) { - const char *sctp_key = ogs_yaml_iter_key(&sctp_iter); - ogs_assert(sctp_key); - if (!strcmp(sctp_key, "heartbit_interval")) { - const char *v = ogs_yaml_iter_value(&sctp_iter); - if (v) self.sctp.heartbit_interval = atoi(v); - } else if (!strcmp(sctp_key, "sack_delay")) { - const char *v = ogs_yaml_iter_value(&sctp_iter); - if (v) self.sctp.sack_delay = atoi(v); - } else if (!strcmp(sctp_key, "rto_initial")) { - const char *v = ogs_yaml_iter_value(&sctp_iter); - if (v) self.sctp.rto_initial = atoi(v); - } else if (!strcmp(sctp_key, "rto_min")) { - const char *v = ogs_yaml_iter_value(&sctp_iter); - if (v) self.sctp.rto_min = atoi(v); - } else if (!strcmp(sctp_key, "rto_max")) { - const char *v = ogs_yaml_iter_value(&sctp_iter); - if (v) self.sctp.rto_max = atoi(v); - } else if (!strcmp(sctp_key, "max_num_of_ostreams")) { - const char *v = ogs_yaml_iter_value(&sctp_iter); - if (v) - self.sctp.max_num_of_ostreams = atoi(v); - } else if (!strcmp(sctp_key, "max_num_of_istreams")) { - const char *v = ogs_yaml_iter_value(&sctp_iter); - if (v) - self.sctp.max_num_of_istreams = atoi(v); - } else if (!strcmp(sctp_key, "max_attempts")) { - const char *v = ogs_yaml_iter_value(&sctp_iter); - if (v) self.sctp.max_attempts = atoi(v); - } else if (!strcmp(sctp_key, "max_initial_timeout")) { - const char *v = ogs_yaml_iter_value(&sctp_iter); - if (v) - self.sctp.max_initial_timeout = atoi(v); - } else if (!strcmp(sctp_key, "usrsctp_udp_port")) { - const char *v = ogs_yaml_iter_value(&sctp_iter); - if (v) self.usrsctp.udp_port = atoi(v); - } else - ogs_warn("unknown key `%s`", sctp_key); - } } else if (!strcmp(root_key, "max")) { ogs_yaml_iter_t max_iter; ogs_yaml_iter_recurse(&root_iter, &max_iter);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/app/ogs-context.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/app/ogs-context.h
Changed
@@ -86,18 +86,6 @@ } sockopt; struct { - int heartbit_interval; - int sack_delay; - int rto_initial; - int rto_min; - int rto_max; - int max_num_of_ostreams; - int max_num_of_istreams; - int max_attempts; - int max_initial_timeout; - } sctp; - - struct { int udp_port; } usrsctp;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/asn1c/common/asn_internal.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/asn1c/common/asn_internal.h
Changed
@@ -40,7 +40,7 @@ #define REALLOC(oldptr, size) realloc(oldptr, size) #define FREEMEM(ptr) free(ptr) #else -#include "ogs-core.h" +#include "ogs-proto.h" static ogs_inline void *ogs_asn_malloc(size_t size, const char *file_line) {
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/asn1c/common/meson.build -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/asn1c/common/meson.build
Changed
@@ -171,10 +171,10 @@ version : libogslib_version, c_args : libasn1c_common_cc_flags, include_directories : libasn1c_common_inc, - dependencies : libcore_dep, + dependencies : libproto_dep, install : true) libasn1c_common_dep = declare_dependency( link_with : libasn1c_common, include_directories : libasn1c_common_inc, - dependencies : libcore_dep) + dependencies : libproto_dep)
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/core/meson.build -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/core/meson.build
Changed
@@ -256,7 +256,6 @@ ogs-hash.h ogs-misc.h ogs-getopt.h - ogs-3gpp-types.h abts.h ogs-abort.c @@ -292,7 +291,6 @@ ogs-hash.c ogs-misc.c ogs-getopt.c - ogs-3gpp-types.c ogs-core.c abts.c '''.split())
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/core/ogs-conv.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/core/ogs-conv.c
Changed
@@ -232,25 +232,3 @@ return x; } - -void ogs_extract_digit_from_string(char *digit, char *string) -{ - bool extracting = false; - int i = 0; - - ogs_assert(string); - ogs_assert(digit); - - while (*string && i < OGS_MAX_IMSI_BCD_LEN) { - if (*string >= '0' && *string <= '9') { - *digit++ = *string; - extracting = true; - } else if (extracting == true) { - break; - } - string++; - i++; - } - - *digit = 0; -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/core/ogs-conv.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/core/ogs-conv.h
Changed
@@ -49,8 +49,6 @@ ogs_uint24_t ogs_uint24_from_string(char *str); uint64_t ogs_uint64_from_string(char *str); -void ogs_extract_digit_from_string(char *digit, char *string); - #ifdef __cplusplus } #endif
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/core/ogs-core.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/core/ogs-core.h
Changed
@@ -62,7 +62,6 @@ #include "core/ogs-hash.h" #include "core/ogs-misc.h" #include "core/ogs-getopt.h" -#include "core/ogs-3gpp-types.h" #undef OGS_CORE_INSIDE
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/core/ogs-fsm.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/core/ogs-fsm.c
Changed
@@ -34,69 +34,116 @@ const char *OGS_FSM_NAME_ENTRY_SIG = "ENTRY"; const char *OGS_FSM_NAME_EXIT_SIG = "EXIT"; -void ogs_fsm_init(void *sm, void *event) +static void fsm_entry(ogs_fsm_t *sm, ogs_fsm_handler_t state, fsm_event_t *e) { - ogs_fsm_t *s = sm; + ogs_assert(sm); + ogs_assert(state); + + if (e) { + e->id = OGS_FSM_ENTRY_SIG; + (*state)(sm, e); + } else { + (*state)(sm, &entry_event); + } +} + +static void fsm_exit(ogs_fsm_t *sm, ogs_fsm_handler_t state, fsm_event_t *e) +{ + ogs_assert(sm); + ogs_assert(state); + + if (e) { + e->id = OGS_FSM_EXIT_SIG; + (*state)(sm, e); + } else { + (*state)(sm, &exit_event); + } +} + +static void fsm_change( + ogs_fsm_t *sm, + ogs_fsm_handler_t oldstate, + ogs_fsm_handler_t newstate, + fsm_event_t *e) +{ + ogs_assert(sm); + ogs_assert(oldstate); + ogs_assert(newstate); + + fsm_exit(sm, oldstate, e); + fsm_entry(sm, newstate, e); +} + +void ogs_fsm_init(void *fsm, void *init, void *fini, void *event) +{ + ogs_fsm_t *sm = fsm; fsm_event_t *e = event; - ogs_assert(s); - if (s->init != NULL) { - (*s->init)(s, e); - if (s->init != s->state) { - if (e) { - e->id = OGS_FSM_ENTRY_SIG; - (*s->state)(s, e); - } else { - (*s->state)(s, &entry_event); - } + ogs_assert(sm); + + sm->init = sm->state = init; + sm->fini = fini; + + if (sm->init) { + (*sm->init)(sm, e); + + if (sm->init != sm->state) { + ogs_assert(sm->state); + fsm_entry(sm, sm->state, e); } } } -void ogs_fsm_dispatch(void *sm, void *event) +void ogs_fsm_tran(void *fsm, void *state, void *event) { - ogs_fsm_t *s = sm; + ogs_fsm_t *sm = fsm; fsm_event_t *e = event; - ogs_assert(s); - ogs_fsm_handler_t tmp = s->state; + ogs_fsm_handler_t tmp = NULL; + + ogs_assert(sm); + + tmp = sm->state; + ogs_assert(tmp); + + sm->state = state; + ogs_assert(sm->state); + + if (sm->state != tmp) + fsm_change(fsm, tmp, sm->state, e); +} + +void ogs_fsm_dispatch(void *fsm, void *event) +{ + ogs_fsm_t *sm = fsm; + fsm_event_t *e = event; + ogs_fsm_handler_t tmp = NULL; + + ogs_assert(sm); + + tmp = sm->state; + ogs_assert(tmp); if (e) - (*tmp)(s, e); + (*tmp)(sm, e); - if (s->state != tmp) { - if (e) { - e->id = OGS_FSM_EXIT_SIG; - (*tmp)(s, e); - } else { - (*tmp)(s, &exit_event); - } - if (e) { - e->id = OGS_FSM_ENTRY_SIG; - (*s->state)(s, e); - } else { - (*s->state)(s, &entry_event); - } - } + if (sm->state != tmp) + fsm_change(fsm, tmp, sm->state, e); } -void ogs_fsm_fini(void *sm, void *event) +void ogs_fsm_fini(void *fsm, void *event) { - ogs_fsm_t *s = sm; + ogs_fsm_t *sm = fsm; fsm_event_t *e = event; - ogs_assert(s); - if (s->fini != s->state) { - if (e) { - e->id = OGS_FSM_EXIT_SIG; - (*s->state)(s, e); - } else { - (*s->state)(s, &exit_event); - } - } + ogs_assert(sm); + + if (sm->fini != sm->state) { + ogs_assert(sm->state); + fsm_exit(sm, sm->state, e); - if (s->fini != NULL) { - (*s->fini)(s, e); + if (sm->fini) + (*sm->fini)(sm, e); } - s->state = s->init; + sm->init = sm->state = sm->fini = NULL; }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/core/ogs-fsm.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/core/ogs-fsm.h
Changed
@@ -46,16 +46,10 @@ ogs_fsm_handler_t state; } ogs_fsm_t; -#define ogs_fsm_create(__s, __i, __f) \ - (((__s)->init = (__s)->state = (ogs_fsm_handler_t)(__i)), \ - (__s)->fini = (ogs_fsm_handler_t)(__f)) - -#define ogs_fsm_delete(__s) \ - ((__s)->init = (__s)->state = (__s)->fini = NULL) - -void ogs_fsm_init(void *sm, void *event); -void ogs_fsm_dispatch(void *sm, void *event); -void ogs_fsm_fini(void *sm, void *event); +void ogs_fsm_init(void *fsm, void *init, void *fini, void *event); +void ogs_fsm_tran(void *fsm, void *state, void *event); +void ogs_fsm_dispatch(void *fsm, void *event); +void ogs_fsm_fini(void *fsm, void *event); #define OGS_FSM_TRAN(__s, __target) \ ((ogs_fsm_t *)__s)->state = (ogs_fsm_handler_t)(__target)
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/core/ogs-macros.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/core/ogs-macros.h
Changed
@@ -210,6 +210,14 @@ #define ogs_uint64_to_uint32(x) ((x >= 0xffffffffUL) ? 0xffffffffU : x) +#define OGS_OBJECT_REF(__oBJ) \ + ((__oBJ)->reference_count)++, \ + ogs_debug("REF %d", ((__oBJ)->reference_count)) +#define OGS_OBJECT_UNREF(__oBJ) \ + ogs_debug("UNREF %d", ((__oBJ)->reference_count)), \ + ((__oBJ)->reference_count)-- +#define OGS_OBJECT_IS_REF(__oBJ) ((__oBJ)->reference_count > 1) + #ifdef __cplusplus } #endif
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/core/ogs-pkbuf.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/core/ogs-pkbuf.c
Changed
@@ -245,7 +245,7 @@ } memset(pkbuf, 0, sizeof(*pkbuf)); - cluster->ref++; + OGS_OBJECT_REF(cluster); pkbuf->cluster = cluster; @@ -283,8 +283,9 @@ cluster = pkbuf->cluster; ogs_assert(cluster); - cluster->ref--; - if (cluster->ref == 0) + if (OGS_OBJECT_IS_REF(cluster)) + OGS_OBJECT_UNREF(cluster); + else cluster_free(pool, pkbuf->cluster); ogs_pool_free(&pool->pkbuf, pkbuf); @@ -337,7 +338,7 @@ ogs_assert(newbuf); memcpy(newbuf, pkbuf, sizeof *pkbuf); - newbuf->cluster->ref++; + OGS_OBJECT_REF(newbuf->cluster); ogs_thread_mutex_unlock(&pool->mutex); #endif
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/core/ogs-pkbuf.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/core/ogs-pkbuf.h
Changed
@@ -32,7 +32,7 @@ unsigned char *buffer; unsigned int size; - unsigned int ref; + unsigned int reference_count; } ogs_cluster_t; #if OGS_USE_TALLOC
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/core/ogs-sockopt.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/core/ogs-sockopt.h
Changed
@@ -35,6 +35,7 @@ uint32_t srto_initial; uint32_t srto_min; uint32_t srto_max; +#define OGS_DEFAULT_SCTP_MAX_NUM_OF_OSTREAMS 30 uint16_t sinit_num_ostreams; uint16_t sinit_max_instreams; uint16_t sinit_max_attempts;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/crypt/meson.build -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/crypt/meson.build
Changed
@@ -52,10 +52,10 @@ version : libogslib_version, c_args : '-DOGS_CRYPT_COMPILATION', include_directories : libcrypt_inc, libinc, - dependencies : libcore_dep, + dependencies : libproto_dep, install : true) libcrypt_dep = declare_dependency( link_with : libcrypt, include_directories : libcrypt_inc, libinc, - dependencies : libcore_dep) + dependencies : libproto_dep)
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/crypt/ogs-crypt.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/crypt/ogs-crypt.h
Changed
@@ -20,7 +20,7 @@ #ifndef OGS_CRYPT_H #define OGS_CRYPT_H -#include "ogs-core.h" +#include "ogs-proto.h" #define OGS_CRYPT_INSIDE
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/diameter/common/meson.build -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/diameter/common/meson.build
Changed
@@ -51,10 +51,10 @@ version : libogslib_version, c_args : libdiameter_common_cc_flags, include_directories : libdiameter_common_inc, libinc, - dependencies : libcore_dep, libfdcore_dep, + dependencies : libproto_dep, libfdcore_dep, install : true) libdiameter_common_dep = declare_dependency( link_with : libdiameter_common, include_directories : libdiameter_common_inc, libinc, - dependencies : libcore_dep, libfdcore_dep) + dependencies : libproto_dep, libfdcore_dep)
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/diameter/common/ogs-diameter-common.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/diameter/common/ogs-diameter-common.h
Changed
@@ -37,7 +37,7 @@ #pragma GCC diagnostic pop #endif -#include "ogs-core.h" +#include "ogs-proto.h" #define OGS_DIAMETER_INSIDE
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/gtp/xact.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/gtp/xact.c
Changed
@@ -191,7 +191,8 @@ xact->gtp_version = gtp_version; xact->org = OGS_GTP_REMOTE_ORIGINATOR; - xact->xid = (gtp_version == 1) ? OGS_GTP1_SQN_TO_XID(sqn) : OGS_GTP2_SQN_TO_XID(sqn); + xact->xid = (gtp_version == 1) ? + OGS_GTP1_SQN_TO_XID(sqn) : OGS_GTP2_SQN_TO_XID(sqn); xact->gnode = gnode; xact->tm_response = ogs_timer_add(
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/ipfw/meson.build -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/ipfw/meson.build
Changed
@@ -80,10 +80,10 @@ version : libogslib_version, c_args : '-include', 'glue.h', ipfw_cc_flags, include_directories : libipfw_inc, - dependencies : libcore_dep, + dependencies : libproto_dep, install : true) libipfw_dep = declare_dependency( link_with : libipfw, include_directories : libinc, - dependencies : libcore_dep) + dependencies : libproto_dep)
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/ipfw/ogs-ipfw.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/ipfw/ogs-ipfw.h
Changed
@@ -24,7 +24,7 @@ extern "C" { #endif -#include "ogs-core.h" +#include "ogs-proto.h" typedef struct ogs_ipfw_rule_s { uint8_t proto;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/meson.build -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/meson.build
Changed
@@ -18,8 +18,9 @@ libinc = include_directories('.') subdir('core') -subdir('ipfw') +subdir('proto') subdir('crypt') +subdir('ipfw') subdir('app') subdir('metrics') subdir('sctp')
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/pfcp/handler.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/pfcp/handler.c
Changed
@@ -76,7 +76,8 @@ if (req->up_function_features.data && req->up_function_features.len) { node->up_function_features_len = req->up_function_features.len; memcpy(&node->up_function_features, req->up_function_features.data, - node->up_function_features_len); + ogs_min(sizeof(node->up_function_features), + node->up_function_features_len)); } } @@ -122,7 +123,8 @@ if (rsp->up_function_features.data && rsp->up_function_features.len) { node->up_function_features_len = rsp->up_function_features.len; memcpy(&node->up_function_features, rsp->up_function_features.data, - node->up_function_features_len); + ogs_min(sizeof(node->up_function_features), + node->up_function_features_len)); } } @@ -250,11 +252,13 @@ if (len == OGS_IPV4_LEN) { report->error_indication.remote_f_teid.ipv4 = 1; memcpy(&report->error_indication.remote_f_teid.addr, - far->hash.f_teid.key.addr, len); + far->hash.f_teid.key.addr, + ogs_min(sizeof(report->error_indication.remote_f_teid.addr), len)); } else if (len == OGS_IPV6_LEN) { report->error_indication.remote_f_teid.ipv6 = 1; memcpy(report->error_indication.remote_f_teid.addr6, - far->hash.f_teid.key.addr, len); + far->hash.f_teid.key.addr, + ogs_min(sizeof(report->error_indication.remote_f_teid.addr6), len)); } else { ogs_error("Invalid Length %d", len); return false; @@ -315,7 +319,7 @@ ogs_pfcp_f_teid_t f_teid; memcpy(&f_teid, message->pdi.local_f_teid.data, - message->pdi.local_f_teid.len); + ogs_min(sizeof(f_teid), message->pdi.local_f_teid.len)); if (f_teid.ipv4 == 0 && f_teid.ipv6 == 0) { ogs_error("One of the IPv4 and IPv6 flags should be 1 " "in the local F-TEID"); @@ -365,8 +369,8 @@ if (oppsite_direction_rule) { /* Copy oppsite direction rule and Swap */ - memcpy(&rule->ipfw, - &oppsite_direction_rule->ipfw, sizeof(rule->ipfw)); + memcpy(&rule->ipfw, &oppsite_direction_rule->ipfw, + sizeof(rule->ipfw)); ogs_ipfw_rule_swap(&rule->ipfw); } @@ -450,7 +454,8 @@ if (message->pdi.local_f_teid.presence) { pdr->f_teid_len = message->pdi.local_f_teid.len; - memcpy(&pdr->f_teid, message->pdi.local_f_teid.data, pdr->f_teid_len); + memcpy(&pdr->f_teid, message->pdi.local_f_teid.data, + ogs_min(sizeof(pdr->f_teid), pdr->f_teid_len)); ogs_assert(pdr->f_teid.ipv4 || pdr->f_teid.ipv6); pdr->f_teid.teid = be32toh(pdr->f_teid.teid); } @@ -466,8 +471,8 @@ if (message->pdi.ue_ip_address.presence) { pdr->ue_ip_addr_len = message->pdi.ue_ip_address.len; - memcpy(&pdr->ue_ip_addr, - message->pdi.ue_ip_address.data, pdr->ue_ip_addr_len); + memcpy(&pdr->ue_ip_addr, message->pdi.ue_ip_address.data, + ogs_min(sizeof(pdr->ue_ip_addr), pdr->ue_ip_addr_len)); } memset(&pdr->outer_header_removal, 0, sizeof(pdr->outer_header_removal)); @@ -476,7 +481,8 @@ if (message->outer_header_removal.presence) { pdr->outer_header_removal_len = message->outer_header_removal.len; memcpy(&pdr->outer_header_removal, message->outer_header_removal.data, - pdr->outer_header_removal_len); + ogs_min(sizeof(pdr->outer_header_removal), + pdr->outer_header_removal_len)); } pdr->far = NULL; @@ -539,7 +545,8 @@ if (message->local_f_teid.presence) { ogs_pfcp_f_teid_t f_teid; - memcpy(&f_teid, message->local_f_teid.data, message->local_f_teid.len); + memcpy(&f_teid, message->local_f_teid.data, + ogs_min(sizeof(f_teid), message->local_f_teid.len)); if (f_teid.ipv4 == 0 && f_teid.ipv6 == 0) { ogs_error("One of the IPv4 and IPv6 flags should be 1 " "in the local F-TEID"); @@ -550,7 +557,8 @@ } pdr->f_teid_len = message->local_f_teid.len; - memcpy(&pdr->f_teid, message->local_f_teid.data, pdr->f_teid_len); + memcpy(&pdr->f_teid, message->local_f_teid.data, + ogs_min(sizeof(pdr->f_teid), pdr->f_teid_len)); ogs_assert(pdr->f_teid.ipv4 || pdr->f_teid.ipv6); pdr->f_teid.teid = be32toh(pdr->f_teid.teid); } @@ -599,7 +607,7 @@ ogs_pfcp_f_teid_t f_teid; memcpy(&f_teid, message->pdi.local_f_teid.data, - message->pdi.local_f_teid.len); + ogs_min(sizeof(f_teid), message->pdi.local_f_teid.len)); if (f_teid.ipv4 == 0 && f_teid.ipv6 == 0) { ogs_error("One of the IPv4 and IPv6 flags should be 1 " "in the local F-TEID"); @@ -649,8 +657,8 @@ if (oppsite_direction_rule) { /* Copy oppsite direction rule and Swap */ - memcpy(&rule->ipfw, - &oppsite_direction_rule->ipfw, sizeof(rule->ipfw)); + memcpy(&rule->ipfw, &oppsite_direction_rule->ipfw, + sizeof(rule->ipfw)); ogs_ipfw_rule_swap(&rule->ipfw); } @@ -725,8 +733,8 @@ if (message->pdi.local_f_teid.presence) { pdr->f_teid_len = message->pdi.local_f_teid.len; - memcpy(&pdr->f_teid, - message->pdi.local_f_teid.data, pdr->f_teid_len); + memcpy(&pdr->f_teid, message->pdi.local_f_teid.data, + ogs_min(sizeof(pdr->f_teid), pdr->f_teid_len)); pdr->f_teid.teid = be32toh(pdr->f_teid.teid); } @@ -838,8 +846,9 @@ ogs_assert(outer_header_creation->data); ogs_assert(outer_header_creation->len); - memcpy(&far->outer_header_creation, - outer_header_creation->data, outer_header_creation->len); + memcpy(&far->outer_header_creation, outer_header_creation->data, + ogs_min(sizeof(far->outer_header_creation), + outer_header_creation->len)); far->outer_header_creation.teid = be32toh(far->outer_header_creation.teid); } @@ -945,8 +954,9 @@ ogs_assert(outer_header_creation->data); ogs_assert(outer_header_creation->len); - memcpy(&far->outer_header_creation, - outer_header_creation->data, outer_header_creation->len); + memcpy(&far->outer_header_creation, outer_header_creation->data, + ogs_min(sizeof(far->outer_header_creation), + outer_header_creation->len)); far->outer_header_creation.teid = be32toh(far->outer_header_creation.teid); }
View file
open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/proto
Added
+(directory)
View file
open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/proto/conv.c
Added
@@ -0,0 +1,42 @@ +/* + * Copyright (C) 2019-2022 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/>. + */ + +#include "ogs-proto.h" + +void ogs_extract_digit_from_string(char *digit, char *string) +{ + bool extracting = false; + int i = 0; + + ogs_assert(string); + ogs_assert(digit); + + while (*string && i < OGS_MAX_IMSI_BCD_LEN) { + if (*string >= '0' && *string <= '9') { + *digit++ = *string; + extracting = true; + } else if (extracting == true) { + break; + } + string++; + i++; + } + + *digit = 0; +}
View file
open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/proto/conv.h
Added
@@ -0,0 +1,37 @@ +/* + * Copyright (C) 2019-2022 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/>. + */ + +#if !defined(OGS_PROTO_INSIDE) && !defined(OGS_PROTO_COMPILATION) +#error "This header cannot be included directly." +#endif + +#ifndef OGS_PROTO_CONV_H +#define OGS_PROTO_CONV_H + +#ifdef __cplusplus +extern "C" { +#endif + +void ogs_extract_digit_from_string(char *digit, char *string); + +#ifdef __cplusplus +} +#endif + +#endif /* OGS_PROTO_CONV_H */
View file
open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/proto/event.c
Added
@@ -0,0 +1,74 @@ +/* + * Copyright (C) 2019-2022 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/>. + */ + +#include "ogs-proto.h" + +const char *OGS_EVENT_NAME_SBI_SERVER = "OGS_EVENT_NAME_SBI_SERVER"; +const char *OGS_EVENT_NAME_SBI_CLIENT = "OGS_EVENT_NAME_SBI_CLIENT"; +const char *OGS_EVENT_NAME_SBI_TIMER = "OGS_EVENT_NAME_SBI_TIMER"; + +void *ogs_event_size(int id, size_t size) +{ + ogs_event_t *e = NULL; + + e = ogs_calloc(1, size); + ogs_assert(e); + + e->id = id; + + return e; +} + +ogs_event_t *ogs_event_new(int id) +{ + return ogs_event_size(id, sizeof(ogs_event_t)); +} + +void ogs_event_free(void *e) +{ + ogs_assert(e); + ogs_free(e); +} + +const char *ogs_event_get_name(ogs_event_t *e) +{ + if (e == NULL) { + return OGS_FSM_NAME_INIT_SIG; + } + + switch (e->id) { + case OGS_FSM_ENTRY_SIG: + return OGS_FSM_NAME_ENTRY_SIG; + case OGS_FSM_EXIT_SIG: + return OGS_FSM_NAME_EXIT_SIG; + + case OGS_EVENT_SBI_SERVER: + return OGS_EVENT_NAME_SBI_SERVER; + case OGS_EVENT_SBI_CLIENT: + return OGS_EVENT_NAME_SBI_CLIENT; + case OGS_EVENT_SBI_TIMER: + return OGS_EVENT_NAME_SBI_TIMER; + + default: + break; + } + + ogs_error("Unknown Event%d", e->id); + return "UNKNOWN_EVENT"; +}
View file
open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/proto/event.h
Added
@@ -0,0 +1,74 @@ +/* + * Copyright (C) 2019-2022 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/>. + */ + +#if !defined(OGS_PROTO_INSIDE) && !defined(OGS_PROTO_COMPILATION) +#error "This header cannot be included directly." +#endif + +#ifndef OGS_PROTO_EVENT_H +#define OGS_PROTO_EVENT_H + +#ifdef __cplusplus +extern "C" { +#endif + +extern const char *OGS_EVENT_NAME_SBI_SERVER; +extern const char *OGS_EVENT_NAME_SBI_CLIENT; +extern const char *OGS_EVENT_NAME_SBI_TIMER; + +typedef enum { + OGS_EVENT_BASE = OGS_FSM_USER_SIG, + + OGS_EVENT_SBI_SERVER, + OGS_EVENT_SBI_CLIENT, + OGS_EVENT_SBI_TIMER, + + OGS_MAX_NUM_OF_PROTO_EVENT, + +} ogs_event_e; + +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_event_s { + int id; + int timer_id; + + struct { + ogs_sbi_request_t *request; + ogs_sbi_response_t *response; + void *data; + int state; + + ogs_sbi_message_t *message; + } sbi; +} ogs_event_t; + +void *ogs_event_size(int id, size_t size); +ogs_event_t *ogs_event_new(int id); +void ogs_event_free(void *e); + +const char *ogs_event_get_name(ogs_event_t *e); + +#ifdef __cplusplus +} +#endif + +#endif /* OGS_PROTO_EVENT_H */
View file
open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/proto/meson.build
Added
@@ -0,0 +1,45 @@ +# Copyright (C) 2019-2022 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/>. + +libproto_sources = files(''' + ogs-proto.h + + types.h + conv.h + event.h + timer.h + + types.c + conv.c + event.c + timer.c +'''.split()) + +libproto_inc = include_directories('.') + +libproto = library('ogsproto', + sources : libproto_sources, + version : libogslib_version, + c_args : '-DOGS_PROTO_COMPILATION', + include_directories : libproto_inc, libinc, + dependencies : libcore_dep, + install : true) + +libproto_dep = declare_dependency( + link_with : libproto, + include_directories : libproto_inc, libinc, + dependencies : libcore_dep)
View file
open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/proto/ogs-proto.h
Added
@@ -0,0 +1,42 @@ +/* + * Copyright (C) 2019-2022 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 OGS_PROTO_H +#define OGS_PROTO_H + +#include "ogs-core.h" + +#define OGS_PROTO_INSIDE + +#include "proto/types.h" +#include "proto/conv.h" +#include "proto/event.h" +#include "proto/timer.h" + +#undef OGS_PROTO_INSIDE + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* OGS_PROTO_H */
View file
open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/proto/timer.c
Added
@@ -0,0 +1,56 @@ +/* + * Copyright (C) 2019-2022 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/>. + */ + +#include "ogs-proto.h" + +const char *OGS_TIMER_NAME_NF_INSTANCE_REGISTRATION_INTERVAL = + "OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL"; +const char *OGS_TIMER_NAME_NF_INSTANCE_HEARTBEAT_INTERVAL = + "OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL"; +const char *OGS_TIMER_NAME_NF_INSTANCE_NO_HEARTBEAT = + "OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT"; +const char *OGS_TIMER_NAME_NF_INSTANCE_VALIDITY = + "OGS_TIMER_NF_INSTANCE_VALIDITY"; +const char *OGS_TIMER_NAME_SUBSCRIPTION_VALIDITY = + "OGS_TIMER_SUBSCRIPTION_VALIDITY"; +const char *OGS_TIMER_NAME_SBI_CLIENT_WAIT = + "OGS_TIMER_SBI_CLIENT_WAIT"; + +const char *ogs_timer_get_name(int timer_id) +{ + switch (timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + return OGS_TIMER_NAME_NF_INSTANCE_REGISTRATION_INTERVAL; + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + return OGS_TIMER_NAME_NF_INSTANCE_HEARTBEAT_INTERVAL; + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + return OGS_TIMER_NAME_NF_INSTANCE_NO_HEARTBEAT; + case OGS_TIMER_NF_INSTANCE_VALIDITY: + return OGS_TIMER_NAME_NF_INSTANCE_VALIDITY; + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + return OGS_TIMER_NAME_SUBSCRIPTION_VALIDITY; + case OGS_TIMER_SBI_CLIENT_WAIT: + return OGS_TIMER_NAME_SBI_CLIENT_WAIT; + default: + break; + } + + ogs_error("Unknown Timer%d", timer_id); + return "UNKNOWN_TIMER"; +}
View file
open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/proto/timer.h
Added
@@ -0,0 +1,59 @@ +/* + * Copyright (C) 2019-2022 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/>. + */ + +#if !defined(OGS_PROTO_INSIDE) && !defined(OGS_PROTO_COMPILATION) +#error "This header cannot be included directly." +#endif + +#ifndef OGS_PROTO_TIMER_H +#define OGS_PROTO_TIMER_H + +#ifdef __cplusplus +extern "C" { +#endif + +extern const char *OGS_TIMER_NAME_NF_INSTANCE_REGISTRATION_INTERVAL; +extern const char *OGS_TIMER_NAME_NF_INSTANCE_HEARTBEAT_INTERVAL; +extern const char *OGS_TIMER_NAME_NF_INSTANCE_NO_HEARTBEAT; +extern const char *OGS_TIMER_NAME_NF_INSTANCE_VALIDITY; +extern const char *OGS_TIMER_NAME_SUBSCRIPTION_VALIDITY; +extern const char *OGS_TIMER_NAME_SBI_CLIENT_WAIT; + +/* forward declaration */ +typedef enum { + OGS_TIMER_BASE = 0, + + OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, + OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, + OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT, + OGS_TIMER_NF_INSTANCE_VALIDITY, + OGS_TIMER_SUBSCRIPTION_VALIDITY, + OGS_TIMER_SBI_CLIENT_WAIT, + + OGS_MAX_NUM_OF_PROTO_TIMER, + +} ogs_timer_e; + +const char *ogs_timer_get_name(int timer_id); + +#ifdef __cplusplus +} +#endif + +#endif /* OGS_PROTO_TIMER_H */
View file
open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/proto/types.c
Added
@@ -0,0 +1,1012 @@ +/* + * Copyright (C) 2019-2022 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/>. + */ + +#include "ogs-proto.h" + +#define PLMN_ID_DIGIT1(x) (((x) / 100) % 10) +#define PLMN_ID_DIGIT2(x) (((x) / 10) % 10) +#define PLMN_ID_DIGIT3(x) ((x) % 10) + +uint32_t ogs_plmn_id_hexdump(void *plmn_id) +{ + uint32_t hex; + ogs_assert(plmn_id); + memcpy(&hex, plmn_id, sizeof(ogs_plmn_id_t)); + hex = be32toh(hex) >> 8; + return hex; +} + +uint16_t ogs_plmn_id_mcc(ogs_plmn_id_t *plmn_id) +{ + return plmn_id->mcc1 * 100 + plmn_id->mcc2 * 10 + plmn_id->mcc3; +} +uint16_t ogs_plmn_id_mnc(ogs_plmn_id_t *plmn_id) +{ + return plmn_id->mnc1 == 0xf ? plmn_id->mnc2 * 10 + plmn_id->mnc3 : + plmn_id->mnc1 * 100 + plmn_id->mnc2 * 10 + plmn_id->mnc3; +} +uint16_t ogs_plmn_id_mnc_len(ogs_plmn_id_t *plmn_id) +{ + return plmn_id->mnc1 == 0xf ? 2 : 3; +} + +void *ogs_plmn_id_build(ogs_plmn_id_t *plmn_id, + uint16_t mcc, uint16_t mnc, uint16_t mnc_len) +{ + plmn_id->mcc1 = PLMN_ID_DIGIT1(mcc); + plmn_id->mcc2 = PLMN_ID_DIGIT2(mcc); + plmn_id->mcc3 = PLMN_ID_DIGIT3(mcc); + + if (mnc_len == 2) + plmn_id->mnc1 = 0xf; + else + plmn_id->mnc1 = PLMN_ID_DIGIT1(mnc); + + plmn_id->mnc2 = PLMN_ID_DIGIT2(mnc); + plmn_id->mnc3 = PLMN_ID_DIGIT3(mnc); + + return plmn_id; +} + +void *ogs_nas_from_plmn_id( + ogs_nas_plmn_id_t *ogs_nas_plmn_id, ogs_plmn_id_t *plmn_id) +{ + memcpy(ogs_nas_plmn_id, plmn_id, OGS_PLMN_ID_LEN); + if (plmn_id->mnc1 != 0xf) { + ogs_nas_plmn_id->mnc1 = plmn_id->mnc1; + ogs_nas_plmn_id->mnc2 = plmn_id->mnc2; + ogs_nas_plmn_id->mnc3 = plmn_id->mnc3; + } + return ogs_nas_plmn_id; +} +void *ogs_nas_to_plmn_id( + ogs_plmn_id_t *plmn_id, ogs_nas_plmn_id_t *ogs_nas_plmn_id) +{ + memcpy(plmn_id, ogs_nas_plmn_id, OGS_PLMN_ID_LEN); + if (plmn_id->mnc1 != 0xf) { + plmn_id->mnc1 = ogs_nas_plmn_id->mnc1; + plmn_id->mnc2 = ogs_nas_plmn_id->mnc2; + plmn_id->mnc3 = ogs_nas_plmn_id->mnc3; + } + return plmn_id; +} + +char *ogs_serving_network_name_from_plmn_id(ogs_plmn_id_t *plmn_id) +{ + ogs_assert(plmn_id); + return ogs_msprintf("5G:mnc%03d.mcc%03d.3gppnetwork.org", + ogs_plmn_id_mnc(plmn_id), ogs_plmn_id_mcc(plmn_id)); +} + +char *ogs_plmn_id_mcc_string(ogs_plmn_id_t *plmn_id) +{ + ogs_assert(plmn_id); + return ogs_msprintf("%03d", ogs_plmn_id_mcc(plmn_id)); +} + +char *ogs_plmn_id_mnc_string(ogs_plmn_id_t *plmn_id) +{ + ogs_assert(plmn_id); + if (ogs_plmn_id_mnc_len(plmn_id) == 2) + return ogs_msprintf("%02d", ogs_plmn_id_mnc(plmn_id)); + else + return ogs_msprintf("%03d", ogs_plmn_id_mnc(plmn_id)); +} + +char *ogs_plmn_id_to_string(ogs_plmn_id_t *plmn_id, char *buf) +{ + ogs_assert(plmn_id); + ogs_assert(buf); + + if (ogs_plmn_id_mnc_len(plmn_id) == 2) + ogs_snprintf(buf, OGS_PLMNIDSTRLEN, "%03d%02d", + ogs_plmn_id_mcc(plmn_id), ogs_plmn_id_mnc(plmn_id)); + else + ogs_snprintf(buf, OGS_PLMNIDSTRLEN, "%03d%03d", + ogs_plmn_id_mcc(plmn_id), ogs_plmn_id_mnc(plmn_id)); + + return buf; +} + +uint32_t ogs_amf_id_hexdump(ogs_amf_id_t *amf_id) +{ + uint32_t hex; + + ogs_assert(amf_id); + + memcpy(&hex, amf_id, sizeof(ogs_amf_id_t)); + hex = be32toh(hex) >> 8; + + return hex; +} + +ogs_amf_id_t *ogs_amf_id_from_string(ogs_amf_id_t *amf_id, const char *hex) +{ + char hexbufsizeof(ogs_amf_id_t); + + ogs_assert(amf_id); + ogs_assert(hex); + + OGS_HEX(hex, strlen(hex), hexbuf); + + amf_id->region = hexbuf0; + amf_id->set1 = hexbuf1; + amf_id->set2 = (hexbuf2 & 0xc0) >> 6; + amf_id->pointer = hexbuf2 & 0x3f; + + return amf_id; +} + +#define OGS_AMFIDSTRLEN (sizeof(ogs_amf_id_t)*2+1) +char *ogs_amf_id_to_string(ogs_amf_id_t *amf_id) +{ + char *str = NULL; + ogs_assert(amf_id); + + str = ogs_calloc(1, OGS_AMFIDSTRLEN); + ogs_expect_or_return_val(str, NULL); + + ogs_hex_to_ascii(amf_id, sizeof(ogs_amf_id_t), str, OGS_AMFIDSTRLEN); + + return str; +} + +uint8_t ogs_amf_region_id(ogs_amf_id_t *amf_id) +{ + ogs_assert(amf_id); + return amf_id->region; +} +uint16_t ogs_amf_set_id(ogs_amf_id_t *amf_id) +{ + ogs_assert(amf_id); + return (amf_id->set1 << 2) + amf_id->set2; +} +uint8_t ogs_amf_pointer(ogs_amf_id_t *amf_id) +{ + ogs_assert(amf_id); + return amf_id->pointer; +} + +ogs_amf_id_t *ogs_amf_id_build(ogs_amf_id_t *amf_id, + uint8_t region, uint16_t set, uint8_t pointer) +{ + amf_id->region = region; + amf_id->set1 = set >> 2; + amf_id->set2 = set & 0x3; + amf_id->pointer = pointer; + + return amf_id; +} + +char *ogs_supi_from_suci(char *suci) +{ +#define MAX_SUCI_TOKEN 16 + char *arrayMAX_SUCI_TOKEN; + char *p, *tmp; + int i; + char *supi = NULL; + + ogs_assert(suci); + tmp = ogs_strdup(suci); + ogs_expect_or_return_val(tmp, NULL); + + p = tmp; + i = 0; + while((arrayi++ = strsep(&p, "-"))) { + /* Empty Body */ + } + + SWITCH(array0) + CASE("suci") + SWITCH(array1) + CASE("0") /* SUPI format : IMSI */ + if (array2 && array3 && array7) + supi = ogs_msprintf("imsi-%s%s%s", + array2, array3, array7); + + break; + DEFAULT + ogs_error("Not implemented %s", array1); + break; + END + break; + DEFAULT + ogs_error("Not implemented %s", array0); + break; + END + + ogs_free(tmp); + return supi; +} + +char *ogs_id_get_type(char *str) +{ + char *token, *p, *tmp; + char *type = NULL; + + ogs_assert(str); + tmp = ogs_strdup(str); + ogs_expect_or_return_val(tmp, NULL); + + p = tmp; + token = strsep(&p, "-"); + ogs_assert(token); + type = ogs_strdup(token); + ogs_expect_or_return_val(type, NULL); + + ogs_free(tmp); + return type; +} + +char *ogs_id_get_value(char *str) +{ + char *token, *p, *tmp; + char *ueid = NULL; + + ogs_assert(str); + tmp = ogs_strdup(str); + ogs_expect_or_return_val(tmp, NULL); + + p = tmp; + token = strsep(&p, "-"); + ogs_assert(token); + token = strsep(&p, "-"); + ogs_assert(token); + ueid = ogs_strdup(token); + ogs_expect_or_return_val(ueid, NULL); + + ogs_free(tmp); + return ueid; +} + +char *ogs_s_nssai_sd_to_string(ogs_uint24_t sd) +{ + char *string = NULL; + + if (sd.v == OGS_S_NSSAI_NO_SD_VALUE) + return NULL; + + string = ogs_uint24_to_0string(sd); + ogs_expect(string); + + return string; +} + +ogs_uint24_t ogs_s_nssai_sd_from_string(const char *hex) +{ + ogs_uint24_t sd; + + sd.v = OGS_S_NSSAI_NO_SD_VALUE; + if (hex == NULL) + return sd; + + return ogs_uint24_from_string((char *)hex); +} + +int ogs_fqdn_build(char *dst, char *src, int length) +{ + int i = 0, j = 0; + + for (i = 0, j = 0; i < length; i++, j++) { + if (srci == '.') { + dsti-j = j; + j = -1; + } else { + dsti+1 = srci; + } + } + dsti-j = j; + + return length+1; +} + +int ogs_fqdn_parse(char *dst, char *src, int length) +{ + int i = 0, j = 0; + uint8_t len = 0; + + while (i+1 < length) { + len = srci++; + if ((j + len + 1) > length) { + ogs_error("Invalid FQDN encodinglen:%d + 1 > length%d", + len, length); + ogs_log_hexdump(OGS_LOG_ERROR, (unsigned char *)src, length); + return 0; + } + memcpy(&dstj, &srci, len); + + i += len; + j += len; + + if (i+1 < length) + dstj++ = '.'; + else + dstj = 0; + } + + return j; +} + +/* 8.13 Protocol Configuration Options (PCO) + * 10.5.6.3 Protocol configuration options in 3GPP TS 24.008 */ +int ogs_pco_parse(ogs_pco_t *pco, unsigned char *data, int data_len) +{ + ogs_pco_t *source = (ogs_pco_t *)data; + int size = 0; + int i = 0; + + ogs_assert(pco); + ogs_assert(data); + ogs_assert(data_len); + + memset(pco, 0, sizeof(ogs_pco_t)); + + pco->ext = source->ext; + pco->configuration_protocol = source->configuration_protocol; + size++; + + while(size < data_len && i < OGS_MAX_NUM_OF_PROTOCOL_OR_CONTAINER_ID) { + ogs_pco_id_t *id = &pco->idsi; + ogs_assert(size + sizeof(id->id) <= data_len); + memcpy(&id->id, data + size, sizeof(id->id)); + id->id = be16toh(id->id); + size += sizeof(id->id); + + ogs_assert(size + sizeof(id->len) <= data_len); + memcpy(&id->len, data + size, sizeof(id->len)); + size += sizeof(id->len); + + id->data = data + size; + size += id->len; + + i++; + } + pco->num_of_id = i; + ogs_assert(size == data_len); + + return size; +} +int ogs_pco_build(unsigned char *data, int data_len, ogs_pco_t *pco) +{ + ogs_pco_t target; + int size = 0; + int i = 0; + + ogs_assert(pco); + ogs_assert(data); + ogs_assert(data_len); + + memcpy(&target, pco, sizeof(ogs_pco_t)); + + ogs_assert(size + 1 <= data_len); + memcpy(data + size, &target, 1); + size += 1; + + ogs_assert(target.num_of_id <= OGS_MAX_NUM_OF_PROTOCOL_OR_CONTAINER_ID); + for (i = 0; i < target.num_of_id; i++) { + ogs_pco_id_t *id = &target.idsi; + + ogs_assert(size + sizeof(id->id) <= data_len); + id->id = htobe16(id->id); + memcpy(data + size, &id->id, sizeof(id->id)); + size += sizeof(id->id); + + ogs_assert(size + sizeof(id->len) <= data_len); + memcpy(data + size, &id->len, sizeof(id->len)); + size += sizeof(id->len); + + ogs_assert(size + id->len <= data_len); + memcpy(data + size, id->data, id->len); + size += id->len; + } + + return size; +} + +int ogs_ip_to_sockaddr(ogs_ip_t *ip, uint16_t port, ogs_sockaddr_t **list) +{ + ogs_sockaddr_t *addr = NULL, *addr6 = NULL; + + ogs_assert(ip); + ogs_assert(list); + + addr = ogs_calloc(1, sizeof(ogs_sockaddr_t)); + if (!addr) { + ogs_error("ogs_calloc() failed"); + return OGS_ERROR; + } + addr->ogs_sa_family = AF_INET; + addr->ogs_sin_port = htobe16(port); + + addr6 = ogs_calloc(1, sizeof(ogs_sockaddr_t)); + if (!addr6) { + ogs_error("ogs_calloc() failed"); + ogs_free(addr); + return OGS_ERROR; + } + addr6->ogs_sa_family = AF_INET6; + addr6->ogs_sin_port = htobe16(port); + + if (ip->ipv4 && ip->ipv6) { + addr->next = addr6; + + addr->sin.sin_addr.s_addr = ip->addr; + memcpy(addr6->sin6.sin6_addr.s6_addr, ip->addr6, OGS_IPV6_LEN); + + *list = addr; + } else if (ip->ipv4) { + addr->sin.sin_addr.s_addr = ip->addr; + ogs_free(addr6); + + *list = addr; + } else if (ip->ipv6) { + memcpy(addr6->sin6.sin6_addr.s6_addr, ip->addr6, OGS_IPV6_LEN); + ogs_free(addr); + + *list = addr6; + } else { + ogs_error("No IPv4 and IPv6"); + ogs_free(addr); + ogs_free(addr6); + return OGS_ERROR; + } + + return OGS_OK; +} + +int ogs_sockaddr_to_ip( + ogs_sockaddr_t *addr, ogs_sockaddr_t *addr6, ogs_ip_t *ip) +{ + ogs_expect_or_return_val(ip, OGS_ERROR); + ogs_expect_or_return_val(addr || addr6, OGS_ERROR); + + memset(ip, 0, sizeof(ogs_ip_t)); + + if (addr && addr6) { + ip->ipv4 = 1; + ip->ipv6 = 1; + ip->len = OGS_IPV4V6_LEN; + ip->addr = addr->sin.sin_addr.s_addr; + memcpy(ip->addr6, addr6->sin6.sin6_addr.s6_addr, OGS_IPV6_LEN); + } else if (addr) { + ip->ipv4 = 1; + ip->len = OGS_IPV4_LEN; + ip->addr = addr->sin.sin_addr.s_addr; + } else if (addr6) { + ip->ipv6 = 1; + ip->len = OGS_IPV6_LEN; + memcpy(ip->addr6, addr6->sin6.sin6_addr.s6_addr, OGS_IPV6_LEN); + } else + ogs_assert_if_reached(); + + return OGS_OK; +} + +char *ogs_ipv4_to_string(uint32_t addr) +{ + char *buf = NULL; + + buf = ogs_calloc(1, OGS_ADDRSTRLEN); + ogs_expect_or_return_val(buf, NULL); + + return (char*)OGS_INET_NTOP(&addr, buf); +} + +char *ogs_ipv6addr_to_string(uint8_t *addr6) +{ + char *buf = NULL; + ogs_assert(addr6); + + buf = ogs_calloc(1, OGS_ADDRSTRLEN); + ogs_expect_or_return_val(buf, NULL); + + return (char *)OGS_INET6_NTOP(addr6, buf); +} + +char *ogs_ipv6prefix_to_string(uint8_t *addr6, uint8_t prefixlen) +{ + char *buf = NULL; + uint8_t tmpOGS_IPV6_LEN; + ogs_assert(addr6); + + memset(tmp, 0, OGS_IPV6_LEN); + memcpy(tmp, addr6, prefixlen >> 3); + + buf = ogs_calloc(1, OGS_ADDRSTRLEN); + ogs_expect_or_return_val(buf, NULL); + + if (OGS_INET6_NTOP(tmp, buf) == NULL) { + ogs_fatal("Invalid IPv6 address"); + ogs_log_hexdump(OGS_LOG_FATAL, addr6, OGS_IPV6_LEN); + ogs_assert_if_reached(); + } + return ogs_mstrcatf(buf, "/%d", prefixlen); +} + +int ogs_ipv4_from_string(uint32_t *addr, char *string) +{ + int rv; + ogs_sockaddr_t tmp; + + ogs_assert(addr); + ogs_assert(string); + + rv = ogs_inet_pton(AF_INET, string, &tmp); + if (rv != OGS_OK) { + ogs_error("Invalid IPv4 string = %s", string); + return OGS_ERROR; + } + + *addr = tmp.sin.sin_addr.s_addr; + + return OGS_OK; +} + +int ogs_ipv6addr_from_string(uint8_t *addr6, char *string) +{ + int rv; + ogs_sockaddr_t tmp; + + ogs_assert(addr6); + ogs_assert(string); + + rv = ogs_inet_pton(AF_INET6, string, &tmp); + if (rv != OGS_OK) { + ogs_error("Invalid IPv6 string = %s", string); + return OGS_ERROR; + } + + memcpy(addr6, tmp.sin6.sin6_addr.s6_addr, OGS_IPV6_LEN); + + return OGS_OK; +} + +int ogs_ipv6prefix_from_string(uint8_t *addr6, uint8_t *prefixlen, char *string) +{ + int rv; + ogs_sockaddr_t tmp; + char *v = NULL, *pv = NULL, *ipstr = NULL, *mask_or_numbits = NULL; + + ogs_assert(addr6); + ogs_assert(prefixlen); + ogs_assert(string); + pv = v = ogs_strdup(string); + ogs_expect_or_return_val(v, OGS_ERROR); + + ipstr = strsep(&v, "/"); + if (ipstr) + mask_or_numbits = v; + + if (!ipstr || !mask_or_numbits) { + ogs_error("Invalid IPv6 Prefix string = %s", v); + ogs_free(v); + return OGS_ERROR; + } + + rv = ogs_inet_pton(AF_INET6, ipstr, &tmp); + ogs_expect_or_return_val(rv == OGS_OK, rv); + + memcpy(addr6, tmp.sin6.sin6_addr.s6_addr, OGS_IPV6_LEN); + *prefixlen = atoi(mask_or_numbits); + + ogs_free(pv); + return OGS_OK; +} + +int ogs_sockaddr_to_user_plane_ip_resource_info( + ogs_sockaddr_t *addr, ogs_sockaddr_t *addr6, + ogs_user_plane_ip_resource_info_t *info) +{ + ogs_assert(addr || addr6); + ogs_assert(info); + + if (addr) { + info->v4 = 1; + info->addr = addr->sin.sin_addr.s_addr; + } + if (addr6) { + info->v6 = 1; + memcpy(info->addr6, addr6->sin6.sin6_addr.s6_addr, OGS_IPV6_LEN); + } + + return OGS_OK; +} + +int ogs_user_plane_ip_resource_info_to_sockaddr( + ogs_user_plane_ip_resource_info_t *info, + ogs_sockaddr_t **addr, ogs_sockaddr_t **addr6) +{ + ogs_assert(addr && addr6); + ogs_assert(info); + + *addr = NULL; + *addr6 = NULL; + + if (info->v4) { + *addr = ogs_calloc(1, sizeof(**addr)); + ogs_assert(*addr); + (*addr)->sin.sin_addr.s_addr = info->addr; + (*addr)->ogs_sa_family = AF_INET; + } + + if (info->v6) { + *addr6 = ogs_calloc(1, sizeof(**addr6)); + ogs_assert(*addr6); + memcpy((*addr6)->sin6.sin6_addr.s6_addr, info->addr6, OGS_IPV6_LEN); + (*addr6)->ogs_sa_family = AF_INET6; + } + + return OGS_OK; +} + +ogs_slice_data_t *ogs_slice_find_by_s_nssai( + ogs_slice_data_t *slice_data, int num_of_slice_data, + ogs_s_nssai_t *s_nssai) +{ + int i; + + ogs_assert(slice_data); + ogs_assert(num_of_slice_data); + ogs_assert(s_nssai); + + /* Compare S-NSSAI */ + for (i = 0; i < num_of_slice_data; i++) { + if (s_nssai->sst == slice_datai.s_nssai.sst && + s_nssai->sd.v == slice_datai.s_nssai.sd.v) { + return slice_data + i; + } + } + + return NULL; +} + +void ogs_subscription_data_free(ogs_subscription_data_t *subscription_data) +{ + int i, j; + + ogs_assert(subscription_data); + + for (i = 0; i < subscription_data->num_of_slice; i++) { + ogs_slice_data_t *slice_data = &subscription_data->slicei; + + for (j = 0; j < slice_data->num_of_session; j++) { + if (slice_data->sessionj.name) + ogs_free(slice_data->sessionj.name); + } + + slice_data->num_of_session = 0; + } + + subscription_data->num_of_slice = 0; + + subscription_data->num_of_msisdn = 0; +} + +void ogs_session_data_free(ogs_session_data_t *session_data) +{ + int i; + + ogs_assert(session_data); + + if (session_data->session.name) + ogs_free(session_data->session.name); + + for (i = 0; i < session_data->num_of_pcc_rule; i++) + OGS_PCC_RULE_FREE(&session_data->pcc_rulei); +} + +void ogs_ims_data_free(ogs_ims_data_t *ims_data) +{ + int i, j, k; + + ogs_assert(ims_data); + + for (i = 0; i < ims_data->num_of_media_component; i++) { + ogs_media_component_t *media_component = &ims_data->media_componenti; + + for (j = 0; j < media_component->num_of_sub; j++) { + ogs_media_sub_component_t *sub = &media_component->subj; + + for (k = 0; k < sub->num_of_flow; k++) { + ogs_flow_t *flow = &sub->flowk; + + if (flow->description) { + ogs_free(flow->description); + } else + ogs_assert_if_reached(); + } + } + } +} + +static int flow_rx_to_gx(ogs_flow_t *rx_flow, ogs_flow_t *gx_flow) +{ + int len; + char *from_str, *to_str; + + ogs_assert(rx_flow); + ogs_assert(gx_flow); + + if (!strncmp(rx_flow->description, + "permit out", strlen("permit out"))) { + gx_flow->direction = OGS_FLOW_DOWNLINK_ONLY; + gx_flow->description = ogs_strdup(rx_flow->description); + ogs_assert(gx_flow->description); + + } else if (!strncmp(rx_flow->description, + "permit in", strlen("permit in"))) { + gx_flow->direction = OGS_FLOW_UPLINK_ONLY; + + /* 'permit in' should be changed + * 'permit out' in Gx Diameter */ + len = strlen(rx_flow->description)+2; + gx_flow->description = ogs_calloc(1, len); + ogs_assert(gx_flow->description); + strcpy(gx_flow->description, "permit out"); + from_str = strstr(&rx_flow->descriptionstrlen("permit in"), "from"); + ogs_assert(from_str); + to_str = strstr(&rx_flow->descriptionstrlen("permit in"), "to"); + ogs_assert(to_str); + strncat(gx_flow->description, + &rx_flow->descriptionstrlen("permit in"), + strlen(rx_flow->description) - + strlen("permit in") - strlen(from_str)); + strcat(gx_flow->description, "from"); + strcat(gx_flow->description, &to_strstrlen("to")); + strcat(gx_flow->description, " to"); + strncat(gx_flow->description, &from_strstrlen("from"), + strlen(from_str) - strlen(to_str) - strlen("from") - 1); + ogs_assert(len == strlen(gx_flow->description)+1); + } else { + ogs_error("Invalid Flow Descripton : %s", rx_flow->description); + return OGS_ERROR; + } + + return OGS_OK; +} + +int ogs_pcc_rule_num_of_flow_equal_to_media( + ogs_pcc_rule_t *pcc_rule, ogs_media_component_t *media_component) +{ + int rv; + int i, j, k; + int matched = 0; + int new = 0; + + ogs_assert(pcc_rule); + ogs_assert(media_component); + + for (i = 0; i < media_component->num_of_sub; i++) { + ogs_media_sub_component_t *sub = &media_component->subi; + + for (j = 0; j < sub->num_of_flow; j++) { + new++; + } + } + + if (new == 0) { + /* No new flow in Media-Component */ + return pcc_rule->num_of_flow; + } + + for (i = 0; i < media_component->num_of_sub; i++) { + ogs_media_sub_component_t *sub = &media_component->subi; + + for (j = 0; j < sub->num_of_flow && + j < OGS_MAX_NUM_OF_FLOW_IN_MEDIA_SUB_COMPONENT; j++) { + ogs_flow_t gx_flow; + ogs_flow_t *rx_flow = &sub->flowj; + + rv = flow_rx_to_gx(rx_flow, &gx_flow); + if (rv != OGS_OK) { + ogs_error("flow reformatting error"); + return OGS_ERROR; + } + + for (k = 0; k < pcc_rule->num_of_flow; k++) { + if (gx_flow.direction == pcc_rule->flowk.direction && + !strcmp(gx_flow.description, + pcc_rule->flowk.description)) { + matched++; + break; + } + } + + OGS_FLOW_FREE(&gx_flow); + } + } + + return matched; +} + +int ogs_pcc_rule_install_flow_from_media( + ogs_pcc_rule_t *pcc_rule, ogs_media_component_t *media_component) +{ + int rv; + int i, j; + + ogs_assert(pcc_rule); + ogs_assert(media_component); + + /* Remove Flow from PCC Rule */ + for (i = 0; i < pcc_rule->num_of_flow; i++) { + OGS_FLOW_FREE(&pcc_rule->flowi); + } + pcc_rule->num_of_flow = 0; + + for (i = 0; i < media_component->num_of_sub; i++) { + ogs_media_sub_component_t *sub = &media_component->subi; + + /* Copy Flow to PCC Rule */ + for (j = 0; j < sub->num_of_flow && + j < OGS_MAX_NUM_OF_FLOW_IN_MEDIA_SUB_COMPONENT; j++) { + ogs_flow_t *rx_flow = NULL; + ogs_flow_t *gx_flow = NULL; + + if (pcc_rule->num_of_flow < OGS_MAX_NUM_OF_FLOW_IN_PCC_RULE) { + rx_flow = &sub->flowj; + gx_flow = &pcc_rule->flowpcc_rule->num_of_flow; + + rv = flow_rx_to_gx(rx_flow, gx_flow); + if (rv != OGS_OK) { + ogs_error("flow reformatting error"); + return OGS_ERROR; + } + + pcc_rule->num_of_flow++; + } else { + ogs_error("Overflow: Number of Flow"); + return OGS_ERROR; + } + } + } + + return OGS_OK; +} + +int ogs_pcc_rule_update_qos_from_media( + ogs_pcc_rule_t *pcc_rule, ogs_media_component_t *media_component) +{ + int rv; + int i, j; + + ogs_assert(pcc_rule); + ogs_assert(media_component); + + pcc_rule->qos.mbr.downlink = 0; + pcc_rule->qos.mbr.uplink = 0; + pcc_rule->qos.gbr.downlink = 0; + pcc_rule->qos.gbr.uplink = 0; + + for (i = 0; i < media_component->num_of_sub; i++) { + ogs_media_sub_component_t *sub = &media_component->subi; + + for (j = 0; j < sub->num_of_flow && + j < OGS_MAX_NUM_OF_FLOW_IN_MEDIA_SUB_COMPONENT; j++) { + ogs_flow_t gx_flow; + ogs_flow_t *rx_flow = &sub->flowj; + + rv = flow_rx_to_gx(rx_flow, &gx_flow); + if (rv != OGS_OK) { + ogs_error("flow reformatting error"); + return OGS_ERROR; + } + + if (gx_flow.direction == OGS_FLOW_DOWNLINK_ONLY) { + if (sub->flow_usage == OGS_FLOW_USAGE_RTCP) { + if (media_component->rr_bandwidth && + media_component->rs_bandwidth) { + pcc_rule->qos.mbr.downlink += + (media_component->rr_bandwidth + + media_component->rs_bandwidth); + } else if (media_component->max_requested_bandwidth_dl) { + if (media_component->rr_bandwidth && + !media_component->rs_bandwidth) { + pcc_rule->qos.mbr.downlink += + ogs_max(0.05 * + media_component->max_requested_bandwidth_dl, + media_component->rr_bandwidth); + } + if (!media_component->rr_bandwidth && + media_component->rs_bandwidth) { + pcc_rule->qos.mbr.downlink += + ogs_max(0.05 * + media_component->max_requested_bandwidth_dl, + media_component->rs_bandwidth); + } + if (!media_component->rr_bandwidth && + !media_component->rs_bandwidth) { + pcc_rule->qos.mbr.downlink += + 0.05 * + media_component->max_requested_bandwidth_dl; + } + } + } else { + if (gx_flow.description) { + pcc_rule->qos.mbr.downlink += + media_component->max_requested_bandwidth_dl; + pcc_rule->qos.gbr.downlink += + media_component->min_requested_bandwidth_dl; + } + } + } else if (gx_flow.direction == OGS_FLOW_UPLINK_ONLY) { + if (sub->flow_usage == OGS_FLOW_USAGE_RTCP) { + if (media_component->rr_bandwidth && + media_component->rs_bandwidth) { + pcc_rule->qos.mbr.uplink += + (media_component->rr_bandwidth + + media_component->rs_bandwidth); + } else if (media_component->max_requested_bandwidth_ul) { + if (media_component->rr_bandwidth && + !media_component->rs_bandwidth) { + pcc_rule->qos.mbr.uplink += + ogs_max(0.05 * + media_component->max_requested_bandwidth_ul, + media_component->rr_bandwidth); + } + if (!media_component->rr_bandwidth && + media_component->rs_bandwidth) { + pcc_rule->qos.mbr.uplink += + ogs_max(0.05 * + media_component->max_requested_bandwidth_ul, + media_component->rs_bandwidth); + } + if (!media_component->rr_bandwidth && + !media_component->rs_bandwidth) { + pcc_rule->qos.mbr.uplink += + 0.05 * + media_component->max_requested_bandwidth_ul; + } + } + } else { + if (gx_flow.description) { + pcc_rule->qos.mbr.uplink += + media_component->max_requested_bandwidth_ul; + pcc_rule->qos.gbr.uplink += + media_component->min_requested_bandwidth_ul; + } + } + } else + ogs_assert_if_reached(); + + OGS_FLOW_FREE(&gx_flow); + } + } + + if (pcc_rule->qos.mbr.downlink == 0) { + pcc_rule->qos.mbr.downlink += + media_component->max_requested_bandwidth_dl; + pcc_rule->qos.mbr.downlink += + (media_component->rr_bandwidth + media_component->rs_bandwidth); + } + + if (pcc_rule->qos.mbr.uplink == 0) { + pcc_rule->qos.mbr.uplink += + media_component->max_requested_bandwidth_ul; + pcc_rule->qos.mbr.uplink += + (media_component->rr_bandwidth + media_component->rs_bandwidth); + } + + if (pcc_rule->qos.gbr.downlink == 0) + pcc_rule->qos.gbr.downlink = pcc_rule->qos.mbr.downlink; + if (pcc_rule->qos.gbr.uplink == 0) + pcc_rule->qos.gbr.uplink = pcc_rule->qos.mbr.uplink; + + return OGS_OK; +}
View file
open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/proto/types.h
Added
@@ -0,0 +1,779 @@ +/* + * Copyright (C) 2019-2022 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/>. + */ + +#if !defined(OGS_PROTO_INSIDE) && !defined(OGS_PROTO_COMPILATION) +#error "This header cannot be included directly." +#endif + +#ifndef OGS_PROTO_TYPES_H +#define OGS_PROTO_TYPES_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define OGS_MAX_NUM_OF_SESS 4 /* Num of APN(Session) per UE */ +#define OGS_MAX_NUM_OF_BEARER 4 /* Num of Bearer per Session */ +#define OGS_BEARER_PER_UE 8 /* Num of Bearer per UE */ +#define OGS_MAX_NUM_OF_PACKET_BUFFER 64 /* Num of PacketBuffer per UE */ + +/* Num of NF Service per NF Instance */ +#define OGS_MAX_NUM_OF_NF_SERVICE 16 + +/* + * The array of TLV messages is limited to 8. + * So, Flow(PDI.SDF_Filter) in PDR is limited to 8. + * + * However, the number of flow in bearer context seems to need more than 16. + * + * Therefore, the maximum number of flows of messages is defined as 8, + * and the maximum number of flows stored by the context is 16. + */ +#define OGS_MAX_NUM_OF_FLOW_IN_PDR 8 +#define OGS_MAX_NUM_OF_FLOW_IN_GTP OGS_MAX_NUM_OF_FLOW_IN_PDR +#define OGS_MAX_NUM_OF_FLOW_IN_NAS OGS_MAX_NUM_OF_FLOW_IN_PDR +#define OGS_MAX_NUM_OF_FLOW_IN_PCC_RULE OGS_MAX_NUM_OF_FLOW_IN_PDR +#define OGS_MAX_NUM_OF_FLOW_IN_MEDIA_SUB_COMPONENT OGS_MAX_NUM_OF_FLOW_IN_PDR +#define OGS_MAX_NUM_OF_FLOW_IN_BEARER 16 + +#define OGS_MAX_NUM_OF_GTPU_RESOURCE 4 + +#define OGS_MAX_SDU_LEN 8192 +#define OGS_MAX_PKT_LEN 2048 +#define OGS_PLMN_ID_LEN 3 +#define OGS_MAX_PLMN_ID_BCD_LEN 6 + +#define OGS_CHRGCHARS_LEN 2 + +#define OGS_BCD_TO_BUFFER_LEN(x) (((x)+1)/2) +#define OGS_MAX_IMSI_BCD_LEN 15 +#define OGS_MAX_IMSI_LEN \ + OGS_BCD_TO_BUFFER_LEN(OGS_MAX_IMSI_BCD_LEN) + +#define OGS_MAX_IMEISV_BCD_LEN 16 +#define OGS_MAX_IMEISV_LEN \ + OGS_BCD_TO_BUFFER_LEN(OGS_MAX_IMEISV_BCD_LEN) + +#define OGS_MAX_MSISDN_BCD_LEN 15 +#define OGS_MAX_MSISDN_LEN \ + OGS_BCD_TO_BUFFER_LEN(OGS_MAX_MSISDN_BCD_LEN) + +#define OGS_MAX_NUM_OF_CELL_ID 16 +#define OGS_MAX_NUM_OF_ENB_ID 16 +#define OGS_MAX_NUM_OF_DNN 16 +#define OGS_MAX_NUM_OF_APN OGS_MAX_NUM_OF_DNN +#define OGS_MAX_NUM_OF_HOSTNAME 16 +#define OGS_MAX_DNN_LEN 100 +#define OGS_MAX_APN_LEN OGS_MAX_DNN_LEN +#define OGS_MAX_PCO_LEN 251 +#define OGS_MAX_FQDN_LEN 256 + +#define OGS_MAX_NUM_OF_SERVED_TAI 16 +#define OGS_MAX_NUM_OF_ALGORITHM 8 + +#define OGS_MAX_NUM_OF_BPLMN 6 + +#define OGS_NEXT_ID(__id, __min, __max) \ + ((__id) = ((__id) == (__max) ? (__min) : ((__id) + 1))) +#define OGS_COMPARE_ID(__id1, __id2, __max) \ + ((__id2) > (__id1) ? ((__id2) - (__id1) < ((__max)-1) ? -1 : 1) : \ + (__id1) > (__id2) ? ((__id1) - (__id2) < ((__max)-1) ? 1 : -1) : 0) + +#define OGS_TIME_TO_BCD(x) \ + (((((x) % 10) << 4) & 0xf0) | (((x) / 10) & 0x0f)) + +#define OGS_NAS_PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED 0 +#define OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED 0 + +#define OGS_ACCESS_TYPE_3GPP 1 +#define OGS_ACCESS_TYPE_NON_3GPP 2 +#define OGS_ACCESS_TYPE_BOTH_3GPP_AND_NON_3GPP 3 + +#define OGS_MAX_QOS_FLOW_ID 63 + +/************************************ + * PLMN_ID Structure */ +#define OGS_MAX_NUM_OF_PLMN 6 +typedef struct ogs_plmn_id_s { +ED2(uint8_t mcc2:4;, + uint8_t mcc1:4;) +ED2(uint8_t mnc1:4;, + uint8_t mcc3:4;) +ED2(uint8_t mnc3:4;, + uint8_t mnc2:4;) +} __attribute__ ((packed)) ogs_plmn_id_t; + +uint32_t ogs_plmn_id_hexdump(void *plmn_id); + +uint16_t ogs_plmn_id_mcc(ogs_plmn_id_t *plmn_id); +uint16_t ogs_plmn_id_mnc(ogs_plmn_id_t *plmn_id); +uint16_t ogs_plmn_id_mnc_len(ogs_plmn_id_t *plmn_id); + +void *ogs_plmn_id_build(ogs_plmn_id_t *plmn_id, + uint16_t mcc, uint16_t mnc, uint16_t mnc_len); + +char *ogs_serving_network_name_from_plmn_id(ogs_plmn_id_t *plmn_id); +char *ogs_plmn_id_mcc_string(ogs_plmn_id_t *plmn_id); +char *ogs_plmn_id_mnc_string(ogs_plmn_id_t *plmn_id); + +#define OGS_PLMNIDSTRLEN (sizeof(ogs_plmn_id_t)*2+1) +char *ogs_plmn_id_to_string(ogs_plmn_id_t *plmn_id, char *buf); + +/************************* + * NAS PLMN_ID Structure */ +typedef struct ogs_nas_plmn_id_s { +ED2(uint8_t mcc2:4;, + uint8_t mcc1:4;) +ED2(uint8_t mnc3:4;, + uint8_t mcc3:4;) +ED2(uint8_t mnc2:4;, + uint8_t mnc1:4;) +} __attribute__ ((packed)) ogs_nas_plmn_id_t; + +void *ogs_nas_from_plmn_id( + ogs_nas_plmn_id_t *ogs_nas_plmn_id, ogs_plmn_id_t *plmn_id); +void *ogs_nas_to_plmn_id( + ogs_plmn_id_t *plmn_id, ogs_nas_plmn_id_t *ogs_nas_plmn_id); + +/************************************ + * AMF_ID Structure */ +typedef struct ogs_amf_id_s { + uint8_t region; + uint8_t set1; +ED2(uint8_t set2:2;, + uint8_t pointer:6;) +} __attribute__ ((packed)) ogs_amf_id_t; + +typedef struct ogs_guami_s { + ogs_plmn_id_t plmn_id; + ogs_amf_id_t amf_id; +} ogs_guami_t; + +uint32_t ogs_amf_id_hexdump(ogs_amf_id_t *amf_id); + +ogs_amf_id_t *ogs_amf_id_from_string(ogs_amf_id_t *amf_id, const char *hex); +char *ogs_amf_id_to_string(ogs_amf_id_t *amf_id); + +uint8_t ogs_amf_region_id(ogs_amf_id_t *amf_id); +uint16_t ogs_amf_set_id(ogs_amf_id_t *amf_id); +uint8_t ogs_amf_pointer(ogs_amf_id_t *amf_id); + +ogs_amf_id_t *ogs_amf_id_build(ogs_amf_id_t *amf_id, + uint8_t region, uint16_t set, uint8_t pointer); + +/************************************ + * SUPI/SUCI */ +char *ogs_supi_from_suci(char *suci); + +/************************************ + * SUPI/GPSI */ +#define OGS_ID_SUPI_TYPE_IMSI "imsi" +#define OGS_ID_GPSI_TYPE_MSISDN "msisdn" +char *ogs_id_get_type(char *str); +char *ogs_id_get_value(char *str); + +/************************************ + * TAI Structure */ +#define OGS_MAX_NUM_OF_TAI 16 +typedef struct ogs_eps_tai_s { + ogs_plmn_id_t plmn_id; + uint16_t tac; +} __attribute__ ((packed)) ogs_eps_tai_t; + +typedef struct ogs_5gs_tai_s { + ogs_plmn_id_t plmn_id; + ogs_uint24_t tac; +} __attribute__ ((packed)) ogs_5gs_tai_t; + +typedef struct ogs_e_cgi_s { + ogs_plmn_id_t plmn_id; + uint32_t cell_id; /* 28 bit */ +} __attribute__ ((packed)) ogs_e_cgi_t; + +typedef struct ogs_nr_cgi_s { + ogs_plmn_id_t plmn_id; + uint64_t cell_id; /* 36 bit */ +} __attribute__ ((packed)) ogs_nr_cgi_t; + +/************************************ + * S-NSSAI Structure */ +#define OGS_MAX_NUM_OF_SLICE 8 +#define OGS_S_NSSAI_NO_SD_VALUE 0xffffff +typedef struct ogs_s_nssai_s { + uint8_t sst; + ogs_uint24_t sd; +} __attribute__ ((packed)) ogs_s_nssai_t; + +char *ogs_s_nssai_sd_to_string(ogs_uint24_t sd); +ogs_uint24_t ogs_s_nssai_sd_from_string(const char *hex); + +/************************************************** + * Common Structure + * S1AP : 9.2.2.1 Transport Layer Address, See 36.414 + * GTP : 8.22 Fully Qualified TEID (F-TEID) */ +#define OGS_IPV4_LEN 4 +#define OGS_IPV6_LEN 16 +#define OGS_IPV6_DEFAULT_PREFIX_LEN 64 +#define OGS_IPV6_128_PREFIX_LEN 128 +#define OGS_IPV4V6_LEN 20 +typedef struct ogs_ip_s { + uint32_t addr; + uint8_t addr6OGS_IPV6_LEN; + uint32_t len; +ED3(uint8_t ipv4:1;, + uint8_t ipv6:1;, + uint8_t reserved:6;) +} ogs_ip_t; + +int ogs_ip_to_sockaddr(ogs_ip_t *ip, uint16_t port, ogs_sockaddr_t **list); +int ogs_sockaddr_to_ip( + ogs_sockaddr_t *addr, ogs_sockaddr_t *addr6, ogs_ip_t *ip); + +char *ogs_ipv4_to_string(uint32_t addr); +char *ogs_ipv6addr_to_string(uint8_t *addr6); +char *ogs_ipv6prefix_to_string(uint8_t *addr6, uint8_t prefixlen); +int ogs_ipv4_from_string(uint32_t *addr, char *string); +int ogs_ipv6addr_from_string(uint8_t *addr6, char *string); +int ogs_ipv6prefix_from_string( + uint8_t *addr6, uint8_t *prefixlen, char *string); + +/************************************************** + * GTPv1-C: TS 29.060 7.7.27 End User Address (EUA) */ +#define OGS_PDP_EUA_ORG_ETSI 0 +#define OGS_PDP_EUA_ORG_IETF 1 +#define OGS_PDP_EUA_ETSI_PPP 1 +#define OGS_PDP_EUA_IETF_IPV4 0x21 +#define OGS_PDP_EUA_IETF_IPV6 0x57 +#define OGS_PDP_EUA_IETF_IPV4V6 0x8D +typedef struct ogs_eua_s { +ED2(uint8_t spare:4;, + uint8_t organization:4;) + uint8_t type; + union { + /* PDU_SESSION_TYPE_IPV4 */ + uint32_t addr; + + /* PDU_SESSION_TYPE_IPV6 */ + uint8_t addr6OGS_IPV6_LEN; + + /* PDU_SESSION_TYPE_IPV4V6 */ + struct { + uint32_t addr; + uint8_t addr6OGS_IPV6_LEN; + } __attribute__ ((packed)) both; + }; +} __attribute__ ((packed)) ogs_eua_t; + +/************************************************** + * GTPv2-C: TS 29.274 8.14 PDN Address Allocation (PAA) */ +#define OGS_PAA_IPV4_LEN 5 +#define OGS_PAA_IPV6_LEN 18 +#define OGS_PAA_IPV4V6_LEN 22 +typedef struct ogs_paa_s { +ED2(uint8_t spare:5;, +/* 8.34 PDN Type */ +#define OGS_PDU_SESSION_TYPE_IS_VALID(x) \ + ((x) == OGS_PDU_SESSION_TYPE_IPV4 || \ + (x) == OGS_PDU_SESSION_TYPE_IPV6 || \ + (x) == OGS_PDU_SESSION_TYPE_IPV4V6) \ + + uint8_t session_type:3;) + union { + /* PDU_SESSION_TYPE_IPV4 */ + uint32_t addr; + + /* PDU_SESSION_TYPE_IPV6 */ + struct { + /* the IPv6 Prefix Length */ + uint8_t len; + /* IPv6 Prefix and Interface Identifier */ + uint8_t addr6OGS_IPV6_LEN; + }; + + /* PDU_SESSION_TYPE_IPV4V6 */ + struct { + struct { + /* the IPv6 Prefix Length */ + uint8_t len; + /* IPv6 Prefix and Interface Identifier */ + uint8_t addr6OGS_IPV6_LEN; + }; + uint32_t addr; + } __attribute__ ((packed)) both; + }; +} __attribute__ ((packed)) ogs_paa_t; + +#define MAX_BIT_RATE 10000000000UL + +typedef struct ogs_bitrate_s { + uint64_t downlink; /* bits per seconds */ + uint64_t uplink; /* bits per seconds */ +} ogs_bitrate_t; + +/********************************** + * QoS Structure */ +typedef struct ogs_qos_s { +#define OGS_QOS_INDEX_1 1 +#define OGS_QOS_INDEX_2 2 +#define OGS_QOS_INDEX_5 5 + uint8_t index; + + struct { + /* Values 1 to 8 should only be assigned for services that are + * authorized to receive prioritized treatment within an operator domain. + * Values 9 to 15 may be assigned to resources that are authorized + * by the home network and thus applicable when a UE is roaming. */ + uint8_t priority_level; +/* + * Ch 7.3.40 Allocation-Retenion-Proirty in TS 29.272 V15.9.0 + * + * If the Pre-emption-Capability AVP is not present in the + * Allocation-Retention-Priority AVP, the default value shall be + * PRE-EMPTION_CAPABILITY_DISABLED (1). + * + * If the Pre-emption-Vulnerability AVP is not present in the + * Allocation-Retention-Priority AVP, the default value shall be + * PRE-EMPTION_VULNERABILITY_ENABLED (0). + * + * However, to easily set up VoLTE service, + * enable Pre-emption Capability/Vulnerablility + * in Default Bearer + */ +#define OGS_EPC_PRE_EMPTION_DISABLED 1 +#define OGS_EPC_PRE_EMPTION_ENABLED 0 + +#define OGS_5GC_PRE_EMPTION_DISABLED 1 +#define OGS_5GC_PRE_EMPTION_ENABLED 2 + uint8_t pre_emption_capability; + uint8_t pre_emption_vulnerability; + } arp; + + ogs_bitrate_t mbr; /* Maxmimum Bit Rate (MBR) */ + ogs_bitrate_t gbr; /* Guaranteed Bit Rate (GBR) */ +} ogs_qos_t; + +/********************************** + * Flow Structure */ +#define OGS_FLOW_DOWNLINK_ONLY 1 +#define OGS_FLOW_UPLINK_ONLY 2 +typedef struct ogs_flow_s { + uint8_t direction; + char *description; +} ogs_flow_t; + +#define OGS_FLOW_FREE(__fLOW) \ + do { \ + if ((__fLOW)->description) { \ + ogs_free((__fLOW)->description); \ + } \ + else \ + ogs_assert_if_reached(); \ + } while(0) + +/********************************** + * PCC Rule Structure */ +typedef struct ogs_pcc_rule_s { +#define OGS_PCC_RULE_TYPE_INSTALL 1 +#define OGS_PCC_RULE_TYPE_REMOVE 2 + uint8_t type; + + char *id; /* 5GC */ + char *name; /* EPC */ + + ogs_flow_t flowOGS_MAX_NUM_OF_FLOW_IN_PCC_RULE; + int num_of_flow; + + int flow_status; + uint32_t precedence; + + ogs_qos_t qos; +} ogs_pcc_rule_t; + +#define OGS_STORE_PCC_RULE(__dST, __sRC) \ + do { \ + int __iNDEX; \ + ogs_assert((__sRC)); \ + ogs_assert((__dST)); \ + OGS_PCC_RULE_FREE(__dST); \ + (__dST)->type = (__sRC)->type; \ + if ((__sRC)->name) { \ + (__dST)->name = ogs_strdup((__sRC)->name); \ + ogs_assert((__dST)->name); \ + } \ + if ((__sRC)->id) { \ + (__dST)->id = ogs_strdup((__sRC)->id); \ + ogs_assert((__dST)->id); \ + } \ + for (__iNDEX = 0; __iNDEX < (__sRC)->num_of_flow; __iNDEX++) { \ + (__dST)->flow__iNDEX.direction = \ + (__sRC)->flow__iNDEX.direction; \ + (__dST)->flow__iNDEX.description = \ + ogs_strdup((__sRC)->flow__iNDEX.description); \ + ogs_assert((__dST)->flow__iNDEX.description); \ + } \ + (__dST)->num_of_flow = (__sRC)->num_of_flow; \ + (__dST)->flow_status = (__sRC)->flow_status; \ + (__dST)->precedence = (__sRC)->precedence; \ + memcpy(&(__dST)->qos, &(__sRC)->qos, sizeof(ogs_qos_t)); \ + } while(0) + +#define OGS_PCC_RULE_FREE(__pCCrULE) \ + do { \ + int __pCCrULE_iNDEX; \ + ogs_assert((__pCCrULE)); \ + if ((__pCCrULE)->id) \ + ogs_free((__pCCrULE)->id); \ + if ((__pCCrULE)->name) \ + ogs_free((__pCCrULE)->name); \ + for (__pCCrULE_iNDEX = 0; \ + __pCCrULE_iNDEX < (__pCCrULE)->num_of_flow; __pCCrULE_iNDEX++) { \ + OGS_FLOW_FREE(&((__pCCrULE)->flow__pCCrULE_iNDEX)); \ + } \ + (__pCCrULE)->num_of_flow = 0; \ + } while(0) + +/********************************** + * PDN Structure */ +typedef struct ogs_session_s { + char *name; + + uint32_t context_identifier; /* EPC */ + bool default_dnn_indicator; /* 5GC */ + + uint8_t charging_characteristicsOGS_CHRGCHARS_LEN; + bool charging_characteristics_presence; + +#define OGS_PDU_SESSION_TYPE_IPV4 1 +#define OGS_PDU_SESSION_TYPE_IPV6 2 +#define OGS_PDU_SESSION_TYPE_IPV4V6 3 +#define OGS_PDU_SESSION_TYPE_UNSTRUCTURED 4 +#define OGS_PDU_SESSION_TYPE_ETHERNET 5 + +#define OGS_PDU_SESSION_TYPE_TO_DIAMETER(x) ((x)-1) +#define OGS_PDU_SESSION_TYPE_FROM_DIAMETER(x) ((x)+1) + uint8_t session_type; + +#define OGS_SSC_MODE_1 1 +#define OGS_SSC_MODE_2 2 +#define OGS_SSC_MODE_3 3 + uint8_t ssc_mode; + + ogs_qos_t qos; + ogs_bitrate_t ambr; /* APN-AMBR */ + + ogs_paa_t paa; + ogs_ip_t ue_ip; + ogs_ip_t smf_ip; +} ogs_session_t; + +int ogs_fqdn_build(char *dst, char *src, int len); +int ogs_fqdn_parse(char *dst, char *src, int len); + +/************************************************** + * Protocol Configuration Options Structure + * 8.13 Protocol Configuration Options (PCO) + * 10.5.6.3 Protocol configuration options in 3GPP TS 24.008 + * RFC 3232 103 + * RFC 1661 102 */ +#define OGS_PCO_PPP_FOR_USE_WITH_IP_PDP_TYPE_OR_IP_PDN_TYPE 0 + +#define OGS_PCO_ID_INTERNET_PROTOCOL_CONTROL_PROTOCOL 0x8021 +#define OGS_PCO_ID_PASSWORD_AUTHENTICATION_PROTOCOL 0xc023 +#define OGS_PCO_ID_CHALLENGE_HANDSHAKE_AUTHENTICATION_PROTOCOL 0xc223 +#define OGS_PCO_ID_P_CSCF_IPV6_ADDRESS_REQUEST 0x0001 +#define OGS_PCO_ID_DNS_SERVER_IPV6_ADDRESS_REQUEST 0x0003 +#define OGS_PCO_ID_MS_SUPPORTS_BCM 0x0005 +#define OGS_PCO_ID_IP_ADDRESS_ALLOCATION_VIA_NAS_SIGNALLING 0x000a +#define OGS_PCO_ID_P_CSCF_IPV4_ADDRESS_REQUEST 0x000c +#define OGS_PCO_ID_DNS_SERVER_IPV4_ADDRESS_REQUEST 0x000d +#define OGS_PCO_ID_IPV4_LINK_MTU_REQUEST 0x0010 +#define OGS_PCO_ID_MS_SUPPORT_LOCAL_ADDR_TFT_INDICATOR 0x0011 +#define OGS_PCO_ID_P_CSCF_RE_SELECTION_SUPPORT 0x0012 + +enum ogs_pco_ipcp_options { + OGS_IPCP_OPT_IPADDR = 3, + OGS_IPCP_OPT_PRIMARY_DNS = 129, + OGS_IPCP_OPT_SECONDARY_DNS = 131, +}; + +typedef struct ogs_pco_ipcp_options_s { + uint8_t type; + uint8_t len; + uint32_t addr; +} __attribute__ ((packed)) ogs_pco_ipcp_options_t; + +#define OGS_PCO_MAX_NUM_OF_IPCP_OPTIONS 4 +typedef struct ogs_pco_ipcp_s { + uint8_t code; + uint8_t identifier; + uint16_t len; + ogs_pco_ipcp_options_t optionsOGS_PCO_MAX_NUM_OF_IPCP_OPTIONS; +} __attribute__ ((packed)) ogs_pco_ipcp_t; + +typedef struct ogs_pco_pap_s { + uint8_t code; + uint8_t identifier; + uint16_t len; + uint8_t welcome_len; + char welcome255; +} __attribute__ ((packed)) ogs_pco_pap_t; + +typedef struct ogs_pco_chap_s { + uint8_t code; + uint8_t identifier; + uint16_t len; +} __attribute__ ((packed)) ogs_pco_chap_t; + +typedef struct ogs_pco_id_s { + uint16_t id; + uint8_t len; + void *data; +} ogs_pco_id_t; + +#define OGS_MAX_NUM_OF_PROTOCOL_OR_CONTAINER_ID 16 +typedef struct ogs_pco_s { +ED3(uint8_t ext:1;, + uint8_t spare:4;, + uint8_t configuration_protocol:3;) + uint8_t num_of_id; + ogs_pco_id_t idsOGS_MAX_NUM_OF_PROTOCOL_OR_CONTAINER_ID; +} ogs_pco_t; + +int ogs_pco_parse(ogs_pco_t *pco, unsigned char *data, int data_len); +int ogs_pco_build(unsigned char *data, int data_len, ogs_pco_t *pco); + +/* + * PFCP Specification + * + * TS29.244, Ch 8.2.82 User Plane IP Resource Information + * + * The following flags are coded within Octet 5: + * - Bit 1 – V4: If this bit is set to "1", then the IPv4 address field + * shall be present, otherwise the IPv4 address field shall not be present. + * - Bit 2 – V6: If this bit is set to "1", then the IPv6 address field + * shall be present, otherwise the IPv6 address field shall not be present. + * - Bit 3-5 – TEID Range Indication (TEIDRI): the value of this field + * indicates the number of bits in the most significant octet of a TEID + * that are used to partition the TEID range, + * e.g. if this field is set to "4", then the first 4 bits in the TEID + * are used to partition the TEID range. + * - Bit 6 – Associated Network Instance (ASSONI): if this bit is set to "1", + * then the Network Instance field shall be present, otherwise the Network + * Instance field shall not be present. + * - Bit 7 – Associated Source Interface (ASSOSI): if this bit is set to "1", + * then the Source Interface field shall be present, + * otherwise the Source Interface field shall not be present. + * - Bit 8: Spare, for future use and set to 0. + * + * At least one of the V4 and V6 flags shall be set to "1", + * and both may be set to "1". + * + * If both the ASSONI and ASSOSI flags are set to "0", this shall indicate + * that the User Plane IP Resource Information provided can be used + * by CP function for any Network Instance and any Source Interface + * of GTP-U user plane in the UP function. Octet 6 (TEID Range) shall be + * present if the TEID Range Indication is not set to zero and + * shall contain a value of the bits which are used to partition the TEID range. + * E.g. if the TEID Range Indication is set to "4", then Octet 6 shall be + * one of values between 0 and 15. When TEID Range Indication is set to zero, + * the Octet 6 shall not be present, the TEID is not partitioned, + * i.e. all TEID values are available for use by the CP function. + * + * Octets "m to (m+3)" and/or "p to (p+15)" (IPv4 address / IPv6 address fields) + * , if present, shall contain the respective IP address values. + * + * Octets "k to l", if present, shall contain a Network Instance value + * as encoded in octet "5 to n+4" of the Figure 8.2.4-1 in clause 8.2.4, + * identifying a Network Instance with which the IP address or TEID Range + * is associated. + * + * Octet r, if present, shall contain a Source Interface value as encoded + * in octet 5 of the Figure 8.2.2-1 in clause 8.2.2, + * identifying the Source Interface with which the IP address or TEID Range + * is associated. + */ + +/* Flags(1) + TEID Range(1) + IPV4(4) + IPV6(16) + Source Interface(1) = 23 */ +#define OGS_MAX_USER_PLANE_IP_RESOURCE_INFO_LEN \ + (23 + (OGS_MAX_APN_LEN+1)) +typedef struct ogs_user_plane_ip_resource_info_s { + union { + struct { +ED6(uint8_t spare:1;, + uint8_t assosi:1;, + uint8_t assoni:1;, + uint8_t teidri:3;, + uint8_t v6:1;, + uint8_t v4:1;) + }; + uint8_t flags; + }; + + /* + * OGS_PFCP-GTPU-TEID = INDEX | TEID_RANGE + * INDEX = OGS_PFCP-GTPU-TEID & ~TEID_RANGE + */ +#define OGS_PFCP_GTPU_TEID_TO_INDEX(__tEID, __iND, __rANGE) \ + (__tEID & ~(__rANGE << (32 - __iND))) +#define OGS_PFCP_GTPU_INDEX_TO_TEID(__iNDEX, __iND, __rANGE) \ + (__iNDEX | (__rANGE << (32 - __iND))) + uint8_t teid_range; + uint32_t addr; + uint8_t addr6OGS_IPV6_LEN; + char network_instanceOGS_MAX_APN_LEN+1; + uint8_t source_interface; +} __attribute__ ((packed)) ogs_user_plane_ip_resource_info_t; + +int ogs_sockaddr_to_user_plane_ip_resource_info( + ogs_sockaddr_t *addr, ogs_sockaddr_t *addr6, + ogs_user_plane_ip_resource_info_t *info); +int ogs_user_plane_ip_resource_info_to_sockaddr( + ogs_user_plane_ip_resource_info_t *info, + ogs_sockaddr_t **addr, ogs_sockaddr_t **addr6); + +typedef struct ogs_slice_data_s { + ogs_s_nssai_t s_nssai; + bool default_indicator; + + uint32_t context_identifier; /* EPC for checking default APN */ + + int num_of_session; + ogs_session_t sessionOGS_MAX_NUM_OF_SESS; +} ogs_slice_data_t; + +ogs_slice_data_t *ogs_slice_find_by_s_nssai( + ogs_slice_data_t *slice_data, int num_of_slice_data, + ogs_s_nssai_t *s_nssai); + +typedef struct ogs_subscription_data_s { +#define OGS_ACCESS_RESTRICTION_UTRAN_NOT_ALLOWED (1) +#define OGS_ACCESS_RESTRICTION_GERAN_NOT_ALLOWED (1<<1) +#define OGS_ACCESS_RESTRICTION_GAN_NOT_ALLOWED (1<<2) +#define OGS_ACCESS_RESTRICTION_I_HSPA_EVOLUTION_NOT_ALLOWED (1<<3) +#define OGS_ACCESS_RESTRICTION_WB_E_UTRAN_NOT_ALLOWED (1<<4) +#define OGS_ACCESS_RESTRICTION_HO_TO_NON_3GPP_ACCESS_NOT_ALLOWED (1<<5) +#define OGS_ACCESS_RESTRICTION_NB_IOT_NOT_ALLOWED (1<<6) + uint32_t access_restriction_data; +#define OGS_SUBSCRIBER_STATUS_SERVICE_GRANTED 0 +#define OGS_SUBSCRIBER_STATUS_OPERATOR_DETERMINED_BARRING 1 + uint32_t subscriber_status; +#define OGS_NETWORK_ACCESS_MODE_PACKET_AND_CIRCUIT 0 +#define OGS_NETWORK_ACCESS_MODE_RESERVED 1 +#define OGS_NETWORK_ACCESS_MODE_ONLY_PACKET 2 + uint32_t network_access_mode; + + ogs_bitrate_t ambr; /* UE-AMBR */ + +#define OGS_RAU_TAU_DEFAULT_TIME (12*60) /* 12 min */ + uint32_t subscribed_rau_tau_timer; /* unit : seconds */ + + int num_of_slice; + ogs_slice_data_t sliceOGS_MAX_NUM_OF_SLICE; + +#define OGS_MAX_NUM_OF_MSISDN 2 + int num_of_msisdn; + struct { + uint8_t bufOGS_MAX_MSISDN_LEN; + int len; + char bcdOGS_MAX_MSISDN_BCD_LEN+1; + } msisdnOGS_MAX_NUM_OF_MSISDN; +} ogs_subscription_data_t; + +void ogs_subscription_data_free(ogs_subscription_data_t *subscription_data); + +typedef struct ogs_session_data_s { + ogs_session_t session; +#define OGS_MAX_NUM_OF_PCC_RULE 8 /* Num of PCC Rule */ + ogs_pcc_rule_t pcc_ruleOGS_MAX_NUM_OF_PCC_RULE; + int num_of_pcc_rule; +} ogs_session_data_t; + +void ogs_session_data_free(ogs_session_data_t *session_data); + +typedef struct ogs_media_sub_component_s { + uint32_t flow_number; +/* + * TS29.214 + * 5.3.12 Flow-Usage AVP + * NO_INFORMATION(0) + * RTCP(1) + * AF_SIGNALLING(2) + * + * TS29.514 + * 5.6.3.14 Enumeration: FlowUsage + * NO_INFO : 1 + * RTCP : 2 + * AF_SIGNALLING : 3 + * + * EPC and 5GC have different values for FlowUsage + * At this point, we will use the 5GC value. + */ +#define OGS_FLOW_USAGE_NO_INFO 1 +#define OGS_FLOW_USAGE_RTCP 2 +#define OGS_FLOW_USAGE_AF_SIGNALLING 3 + uint32_t flow_usage; + ogs_flow_t flowOGS_MAX_NUM_OF_FLOW_IN_MEDIA_SUB_COMPONENT; + int num_of_flow; +} ogs_media_sub_component_t; + +typedef struct ogs_media_component_s { + uint32_t media_component_number; + uint32_t media_type; + + uint64_t max_requested_bandwidth_dl; + uint64_t max_requested_bandwidth_ul; + uint64_t min_requested_bandwidth_dl; + uint64_t min_requested_bandwidth_ul; + uint64_t rr_bandwidth; + uint64_t rs_bandwidth; + + int flow_status; + +#define OGS_MAX_NUM_OF_MEDIA_SUB_COMPONENT 8 + ogs_media_sub_component_t subOGS_MAX_NUM_OF_MEDIA_SUB_COMPONENT; + int num_of_sub; +} ogs_media_component_t; + +typedef struct ogs_ims_data_s { + int num_of_msisdn; + struct { + uint8_t bufOGS_MAX_MSISDN_LEN; + int len; + char bcdOGS_MAX_MSISDN_BCD_LEN+1; + } msisdnOGS_MAX_NUM_OF_MSISDN; + +#define OGS_MAX_NUM_OF_MEDIA_COMPONENT 16 + ogs_media_component_t media_componentOGS_MAX_NUM_OF_MEDIA_COMPONENT; + int num_of_media_component; +} ogs_ims_data_t; + +void ogs_ims_data_free(ogs_ims_data_t *ims_data); + +int ogs_pcc_rule_num_of_flow_equal_to_media( + ogs_pcc_rule_t *pcc_rule, ogs_media_component_t *media_component); +int ogs_pcc_rule_install_flow_from_media( + ogs_pcc_rule_t *pcc_rule, ogs_media_component_t *media_component); +int ogs_pcc_rule_update_qos_from_media( + ogs_pcc_rule_t *pcc_rule, ogs_media_component_t *media_component); + +#ifdef __cplusplus +} +#endif + +#endif /* OGS_PROTO_TYPES_H */
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/sbi/client.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/sbi/client.c
Changed
@@ -102,8 +102,8 @@ ogs_assert(client); memset(client, 0, sizeof(ogs_sbi_client_t)); - client->reference_count++; - ogs_trace("ogs_sbi_client_add()"); + ogs_debug("ogs_sbi_client_add()"); + OGS_OBJECT_REF(client); ogs_assert(OGS_OK == ogs_copyaddrinfo(&client->node.addr, addr)); @@ -118,8 +118,10 @@ curl_multi_setopt(multi, CURLMOPT_SOCKETDATA, client); curl_multi_setopt(multi, CURLMOPT_TIMERFUNCTION, multi_timer_cb); curl_multi_setopt(multi, CURLMOPT_TIMERDATA, client); +#ifdef CURLMOPT_MAX_CONCURRENT_STREAMS curl_multi_setopt(multi, CURLMOPT_MAX_CONCURRENT_STREAMS, ogs_app()->pool.stream); +#endif ogs_list_add(&ogs_sbi_self()->client_list, client); @@ -128,17 +130,22 @@ void ogs_sbi_client_remove(ogs_sbi_client_t *client) { + ogs_sockaddr_t *addr = NULL; + char bufOGS_ADDRSTRLEN; + ogs_assert(client); - /* ogs_sbi_client_t is always created with reference context */ - ogs_assert(client->reference_count > 0); + addr = client->node.addr; + ogs_assert(addr); + ogs_debug("ogs_sbi_client_remove() %s:%d", + OGS_ADDR(addr, buf), OGS_PORT(addr)); - ogs_trace("client->reference_count = %d", client->reference_count); - client->reference_count--; - if (client->reference_count > 0) + /* ogs_sbi_client_t is always created with reference context */ + if (OGS_OBJECT_IS_REF(client)) { + OGS_OBJECT_UNREF(client); return; + } - ogs_trace("ogs_sbi_client_remove()"); ogs_list_remove(&ogs_sbi_self()->client_list, client); connection_remove_all(client);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/sbi/client.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/sbi/client.h
Changed
@@ -47,10 +47,8 @@ ogs_sbi_client_remove(client); \ } \ \ - (__pClient)->reference_count++; \ + OGS_OBJECT_REF(__pClient); \ ((__cTX)->client) = (__pClient); \ - ogs_trace("client->reference_count = %d", \ - (__pClient)->reference_count); \ } while(0) typedef int (*ogs_sbi_client_cb_f)(
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/sbi/context.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/sbi/context.c
Changed
@@ -17,7 +17,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -#include "app/ogs-app.h" +#include "ogs-app.h" #include "ogs-sbi.h" int __ogs_sbi_domain; @@ -727,6 +727,16 @@ return OGS_OK; } +void ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_e nf_type) +{ + ogs_assert(nf_type); + + if (self.num_of_to_be_notified_nf_type < OGS_SBI_MAX_NUM_OF_NF_TYPE) { + self.to_be_notified_nf_typeself.num_of_to_be_notified_nf_type = nf_type; + self.num_of_to_be_notified_nf_type++; + } +} + bool ogs_sbi_nf_service_is_available(const char *name) { int i; @@ -753,8 +763,9 @@ ogs_assert(nf_instance); memset(nf_instance, 0, sizeof(ogs_sbi_nf_instance_t)); - nf_instance->reference_count++; - ogs_trace("ogs_sbi_nf_instance_add()"); + ogs_debug("ogs_sbi_nf_instance_add()"); + + OGS_OBJECT_REF(nf_instance); nf_instance->time.heartbeat_interval = ogs_app()->time.nf_instance.heartbeat_interval; @@ -802,7 +813,7 @@ ogs_assert(allowed_nf_type); if (nf_instance->num_of_allowed_nf_type < OGS_SBI_MAX_NUM_OF_NF_TYPE) { - nf_instance->allowed_nf_typesnf_instance->num_of_allowed_nf_type = + nf_instance->allowed_nf_typenf_instance->num_of_allowed_nf_type = allowed_nf_type; nf_instance->num_of_allowed_nf_type++; } @@ -836,13 +847,13 @@ { ogs_assert(nf_instance); - ogs_trace("nf_instance->reference_count = %d", - nf_instance->reference_count); - nf_instance->reference_count--; - if (nf_instance->reference_count > 0) + ogs_debug("ogs_sbi_nf_instance_remove()"); + + if (OGS_OBJECT_IS_REF(nf_instance)) { + OGS_OBJECT_UNREF(nf_instance); return; + } - ogs_trace("ogs_sbi_nf_instance_remove()"); ogs_list_remove(&ogs_sbi_self()->nf_instance_list, nf_instance); ogs_sbi_nf_info_remove_all(&nf_instance->nf_info_list); @@ -935,17 +946,17 @@ ogs_assert(full); if (nf_service->num_of_version < OGS_SBI_MAX_NUM_OF_SERVICE_VERSION) { - nf_service->versionsnf_service->num_of_version.in_uri = + nf_service->versionnf_service->num_of_version.in_uri = ogs_strdup(in_uri); - ogs_assert(nf_service->versionsnf_service->num_of_version.in_uri); - nf_service->versionsnf_service->num_of_version.full = + ogs_assert(nf_service->versionnf_service->num_of_version.in_uri); + nf_service->versionnf_service->num_of_version.full = ogs_strdup(full); - ogs_assert(nf_service->versionsnf_service->num_of_version.full); + ogs_assert(nf_service->versionnf_service->num_of_version.full); if (expiry) { - nf_service->versionsnf_service->num_of_version.expiry = + nf_service->versionnf_service->num_of_version.expiry = ogs_strdup(expiry); ogs_assert( - nf_service->versionsnf_service->num_of_version.expiry); + nf_service->versionnf_service->num_of_version.expiry); } nf_service->num_of_version++; @@ -978,12 +989,12 @@ ogs_free(nf_service->fqdn); for (i = 0; i < nf_service->num_of_version; i++) { - if (nf_service->versionsi.in_uri) - ogs_free(nf_service->versionsi.in_uri); - if (nf_service->versionsi.full) - ogs_free(nf_service->versionsi.full); - if (nf_service->versionsi.expiry) - ogs_free(nf_service->versionsi.expiry); + if (nf_service->versioni.in_uri) + ogs_free(nf_service->versioni.in_uri); + if (nf_service->versioni.full) + ogs_free(nf_service->versioni.full); + if (nf_service->versioni.expiry) + ogs_free(nf_service->versioni.expiry); } nf_service->num_of_version = 0; @@ -1368,13 +1379,13 @@ ogs_sbi_discovery_option_t *discovery_option) { ogs_assert(nf_instance); - ogs_assert(ogs_sbi_self()->nf_state_registered); ogs_assert(target_nf_type); - if (!OGS_FSM_CHECK(&nf_instance->sm, - ogs_sbi_self()->nf_state_registered)) return false; + if (!OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_registered)) + return false; - if (nf_instance->nf_type != target_nf_type) return false; + if (nf_instance->nf_type != target_nf_type) + return false; if (discovery_option) { if (discovery_option->target_nf_instance_id && @@ -1393,7 +1404,6 @@ { ogs_sbi_nf_instance_t *nf_instance = NULL; - ogs_assert(ogs_sbi_self()->nf_state_registered); ogs_assert(sbi_object); ogs_assert(target_nf_type); @@ -1407,20 +1417,18 @@ } } -bool ogs_sbi_client_associate(ogs_sbi_nf_instance_t *nf_instance) +void ogs_sbi_client_associate(ogs_sbi_nf_instance_t *nf_instance) { ogs_sbi_client_t *client = NULL; ogs_assert(nf_instance); client = nf_instance_find_client(nf_instance); - if (!client) return false; + ogs_assert(client); OGS_SBI_SETUP_CLIENT(nf_instance, client); nf_service_associate_client_all(nf_instance); - - return true; } OpenAPI_uri_scheme_e ogs_sbi_default_uri_scheme(void) @@ -1442,7 +1450,7 @@ ogs_assert(nf_service->name); if (strcmp(nf_service->name, name) == 0) { for (i = 0; i < nf_service->num_of_version; i++) { - if (strcmp(nf_service->versionsi.in_uri, version) == 0) { + if (strcmp(nf_service->versioni.in_uri, version) == 0) { return nf_service->client; } } @@ -1476,7 +1484,6 @@ { ogs_sbi_xact_t *xact = NULL; - ogs_assert(ogs_sbi_self()->client_wait_expire); ogs_assert(sbi_object); ogs_pool_alloc(&xact_pool, &xact); @@ -1496,7 +1503,7 @@ } xact->t_response = ogs_timer_add( - ogs_app()->timer_mgr, ogs_sbi_self()->client_wait_expire, xact); + ogs_app()->timer_mgr, ogs_timer_sbi_client_wait_expire, xact); if (!xact->t_response) { ogs_error("ogs_timer_add() failed"); ogs_sbi_request_free(xact->request);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/sbi/context.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/sbi/context.h
Changed
@@ -65,11 +65,12 @@ const char *content_encoding; - void (*client_wait_expire)(void *data); - ogs_fsm_handler_t nf_state_registered; - int num_of_service_name; const char *service_nameOGS_MAX_NUM_OF_NF_SERVICE; + +#define OGS_SBI_MAX_NUM_OF_NF_TYPE 16 + int num_of_to_be_notified_nf_type; + OpenAPI_nf_type_e to_be_notified_nf_typeOGS_SBI_MAX_NUM_OF_NF_TYPE; } ogs_sbi_context_t; typedef struct ogs_sbi_nf_instance_s { @@ -87,14 +88,14 @@ ogs_timer_t *t_no_heartbeat; /* check heartbeat */ ogs_timer_t *t_validity; /* check validation */ -#define NF_INSTANCE_IS_SELF(_iD) \ +#define NF_INSTANCE_ID_IS_SELF(_iD) \ (_iD) && ogs_sbi_self()->nf_instance && \ strcmp((_iD), ogs_sbi_self()->nf_instance->id) == 0 -#define NF_INSTANCE_IS_OTHERS(_iD) \ +#define NF_INSTANCE_ID_IS_OTHERS(_iD) \ (_iD) && ogs_sbi_self()->nf_instance && \ strcmp((_iD), ogs_sbi_self()->nf_instance->id) != 0 -#define NF_INSTANCE_IS_NRF(__nFInstance) \ +#define NF_INSTANCE_TYPE_IS_NRF(__nFInstance) \ ((__nFInstance->nf_type) == OpenAPI_nf_type_NRF) char *id; /* NFInstanceId */ @@ -110,9 +111,8 @@ int num_of_ipv6; ogs_sockaddr_t *ipv6OGS_SBI_MAX_NUM_OF_IP_ADDRESS; -#define OGS_SBI_MAX_NUM_OF_NF_TYPE 16 int num_of_allowed_nf_type; - OpenAPI_nf_type_e allowed_nf_typesOGS_SBI_MAX_NUM_OF_NF_TYPE; + OpenAPI_nf_type_e allowed_nf_typeOGS_SBI_MAX_NUM_OF_NF_TYPE; #define OGS_SBI_DEFAULT_PRIORITY 0 #define OGS_SBI_DEFAULT_CAPACITY 100 @@ -188,7 +188,7 @@ char *in_uri; char *full; char *expiry; - } versionsOGS_SBI_MAX_NUM_OF_SERVICE_VERSION; + } versionOGS_SBI_MAX_NUM_OF_SERVICE_VERSION; char *fqdn; int num_of_addr; @@ -273,6 +273,8 @@ int ogs_sbi_context_parse_config( const char *local, const char *nrf, const char *scp); +void ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_e nf_type); + bool ogs_sbi_nf_service_is_available(const char *name); ogs_sbi_nf_instance_t *ogs_sbi_scp_instance(void); @@ -320,7 +322,7 @@ ogs_sbi_client_t *ogs_sbi_client_find_by_service_name( ogs_sbi_nf_instance_t *nf_instance, char *name, char *version); -bool ogs_sbi_client_associate(ogs_sbi_nf_instance_t *nf_instance); +void ogs_sbi_client_associate(ogs_sbi_nf_instance_t *nf_instance); OpenAPI_uri_scheme_e ogs_sbi_default_uri_scheme(void); @@ -341,10 +343,8 @@ OGS_SBI_NF_INSTANCE((__sBIObject), (__nFType))); \ } \ \ - (__nFInstance)->reference_count++; \ + OGS_OBJECT_REF(__nFInstance); \ OGS_SBI_NF_INSTANCE((__sBIObject), (__nFType)) = (__nFInstance); \ - ogs_trace("nf_instance->reference_count = %d", \ - (__nFInstance)->reference_count); \ } while(0) bool ogs_sbi_discovery_param_is_matched(
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/sbi/meson.build -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/sbi/meson.build
Changed
@@ -28,6 +28,7 @@ yuarel.c conv.c + timer.c message.c mhd-server.c @@ -39,8 +40,9 @@ nnrf-build.c nnrf-handler.c - + path.c + nf-sm.c '''.split()) libsbi_inc = include_directories('.') @@ -57,8 +59,7 @@ version : libogslib_version, c_args : sbi_cc_flags, include_directories : libsbi_inc, libinc, - dependencies : libcore_dep, - libcrypt_dep, + dependencies : libcrypt_dep, libapp_dep, libsbi_openapi_dep, libgnutls_dep, @@ -71,8 +72,7 @@ libsbi_dep = declare_dependency( link_with : libsbi, include_directories : libsbi_inc, libinc, - dependencies : libcore_dep, - libcrypt_dep, + dependencies : libcrypt_dep, libapp_dep, libsbi_openapi_dep, libgnutls_dep,
View file
open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/sbi/nf-sm.c
Added
@@ -0,0 +1,464 @@ +/* + * Copyright (C) 2019-2022 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/>. + */ + +#include "ogs-app.h" +#include "ogs-sbi.h" + +void ogs_sbi_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance) +{ + ogs_event_t e; + + ogs_assert(nf_instance); + + if (NF_INSTANCE_TYPE_IS_NRF(nf_instance)) { + } else if (NF_INSTANCE_ID_IS_OTHERS(nf_instance->id)) { + } else { + ogs_fatal("FSM is available in NRF or OTHERS"); + ogs_assert_if_reached(); + } + + memset(&e, 0, sizeof(e)); + e.sbi.data = nf_instance; + + ogs_fsm_init(&nf_instance->sm, + ogs_sbi_nf_state_initial, ogs_sbi_nf_state_final, &e); +} + +void ogs_sbi_nf_fsm_tran(ogs_sbi_nf_instance_t *nf_instance, void *state) +{ + ogs_event_t e; + + ogs_assert(nf_instance); + + memset(&e, 0, sizeof(e)); + e.sbi.data = nf_instance; + + ogs_fsm_tran(&nf_instance->sm, state, &e); +} + +void ogs_sbi_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance) +{ + ogs_event_t e; + + ogs_assert(nf_instance); + + memset(&e, 0, sizeof(e)); + e.sbi.data = nf_instance; + + ogs_fsm_fini(&nf_instance->sm, &e); +} + +void ogs_sbi_nf_state_initial(ogs_fsm_t *s, ogs_event_t *e) +{ + ogs_sbi_nf_instance_t *nf_instance = NULL; + + ogs_assert(s); + ogs_assert(e); + + ogs_sbi_sm_debug(e); + + nf_instance = e->sbi.data; + ogs_assert(nf_instance); + + nf_instance->t_registration_interval = ogs_timer_add(ogs_app()->timer_mgr, + ogs_timer_nf_instance_registration_interval, nf_instance); + ogs_assert(nf_instance->t_registration_interval); + nf_instance->t_heartbeat_interval = ogs_timer_add(ogs_app()->timer_mgr, + ogs_timer_nf_instance_heartbeat_interval, nf_instance); + ogs_assert(nf_instance->t_heartbeat_interval); + nf_instance->t_no_heartbeat = ogs_timer_add(ogs_app()->timer_mgr, + ogs_timer_nf_instance_no_heartbeat, nf_instance); + ogs_assert(nf_instance->t_no_heartbeat); + nf_instance->t_validity = ogs_timer_add(ogs_app()->timer_mgr, + ogs_timer_nf_instance_validity, nf_instance); + ogs_assert(nf_instance->t_validity); + + if (NF_INSTANCE_TYPE_IS_NRF(nf_instance)) { + OGS_FSM_TRAN(s, &ogs_sbi_nf_state_will_register); + } else { + ogs_assert(nf_instance->id); + OGS_FSM_TRAN(s, &ogs_sbi_nf_state_registered); + } +} + +void ogs_sbi_nf_state_final(ogs_fsm_t *s, ogs_event_t *e) +{ + ogs_sbi_nf_instance_t *nf_instance = NULL; + + ogs_assert(s); + ogs_assert(e); + + ogs_sbi_sm_debug(e); + + nf_instance = e->sbi.data; + ogs_assert(nf_instance); + + ogs_timer_delete(nf_instance->t_registration_interval); + ogs_timer_delete(nf_instance->t_heartbeat_interval); + ogs_timer_delete(nf_instance->t_no_heartbeat); + ogs_timer_delete(nf_instance->t_validity); +} + +void ogs_sbi_nf_state_will_register(ogs_fsm_t *s, ogs_event_t *e) +{ + ogs_sbi_nf_instance_t *nf_instance = NULL; + ogs_sbi_client_t *client = NULL; + ogs_sbi_message_t *message = NULL; + ogs_sockaddr_t *addr = NULL; + + ogs_assert(s); + ogs_assert(e); + + ogs_sbi_sm_debug(e); + + nf_instance = e->sbi.data; + ogs_assert(nf_instance); + ogs_assert(ogs_sbi_self()->nf_instance); + ogs_assert(NF_INSTANCE_TYPE_IS_NRF(nf_instance)); + + switch (e->id) { + case OGS_FSM_ENTRY_SIG: + ogs_timer_start(nf_instance->t_registration_interval, + ogs_app()->time.message.sbi.nf_register_interval); + + ogs_assert(true == ogs_nnrf_nfm_send_nf_register(nf_instance)); + break; + + case OGS_FSM_EXIT_SIG: + ogs_timer_stop(nf_instance->t_registration_interval); + break; + + case OGS_EVENT_SBI_CLIENT: + message = e->sbi.message; + ogs_assert(message); + + SWITCH(message->h.service.name) + CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) + + SWITCH(message->h.resource.component0) + CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) + + if (message->res_status == OGS_SBI_HTTP_STATUS_OK || + message->res_status == OGS_SBI_HTTP_STATUS_CREATED) { + ogs_sbi_nnrf_handle_nf_register(nf_instance, message); + OGS_FSM_TRAN(s, &ogs_sbi_nf_state_registered); + } else { + ogs_error("%s HTTP Response Status Code %d", + ogs_sbi_self()->nf_instance->id, + message->res_status); + OGS_FSM_TRAN(s, &ogs_sbi_nf_state_exception); + } + break; + + DEFAULT + ogs_error("%s Invalid resource name %s", + ogs_sbi_self()->nf_instance->id, + message->h.resource.component0); + END + break; + + DEFAULT + ogs_error("%s Invalid API name %s", + ogs_sbi_self()->nf_instance->id, message->h.service.name); + END + break; + + case OGS_EVENT_SBI_TIMER: + switch(e->timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + client = nf_instance->client; + ogs_assert(client); + addr = client->node.addr; + ogs_assert(addr); + + ogs_warn("%s Retry to registration with NRF", + ogs_sbi_self()->nf_instance->id); + + ogs_timer_start(nf_instance->t_registration_interval, + ogs_app()->time.message.sbi.nf_register_interval); + + ogs_assert(true == ogs_nnrf_nfm_send_nf_register(nf_instance)); + break; + + default: + ogs_error("%s Unknown timer%s:%d", + ogs_sbi_self()->nf_instance->id, + ogs_timer_get_name(e->timer_id), e->timer_id); + } + break; + + default: + ogs_error("Unknown event %s", ogs_event_get_name(e)); + break; + } +} + +void ogs_sbi_nf_state_registered(ogs_fsm_t *s, ogs_event_t *e) +{ + ogs_sbi_nf_instance_t *nf_instance = NULL; + ogs_sbi_client_t *client = NULL; + ogs_sbi_message_t *message = NULL; + ogs_assert(s); + ogs_assert(e); + + ogs_sbi_sm_debug(e); + + nf_instance = e->sbi.data; + ogs_assert(nf_instance); + ogs_assert(ogs_sbi_self()->nf_instance); + + switch (e->id) { + case OGS_FSM_ENTRY_SIG: + if (NF_INSTANCE_TYPE_IS_NRF(nf_instance)) { + int i; + + ogs_info("%s NF registered Heartbeat:%ds", + ogs_sbi_self()->nf_instance->id, + nf_instance->time.heartbeat_interval); + + client = nf_instance->client; + ogs_assert(client); + + if (nf_instance->time.heartbeat_interval) { + ogs_timer_start(nf_instance->t_heartbeat_interval, + ogs_time_from_sec(nf_instance->time.heartbeat_interval)); + ogs_timer_start(nf_instance->t_no_heartbeat, + ogs_time_from_sec( + nf_instance->time.heartbeat_interval + + ogs_app()->time.nf_instance.no_heartbeat_margin)); + } + + for (i = 0; + i < ogs_sbi_self()->num_of_to_be_notified_nf_type; i++) { + ogs_assert(true == + ogs_nnrf_nfm_send_nf_status_subscribe(client, + ogs_sbi_self()->nf_instance->nf_type, + ogs_sbi_self()->nf_instance->id, + ogs_sbi_self()->to_be_notified_nf_typei)); + } + } + break; + + case OGS_FSM_EXIT_SIG: + if (NF_INSTANCE_TYPE_IS_NRF(nf_instance)) { + ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); + + if (nf_instance->time.heartbeat_interval) { + ogs_timer_stop(nf_instance->t_heartbeat_interval); + ogs_timer_stop(nf_instance->t_no_heartbeat); + } + + if (!OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_exception)) { + ogs_assert(true == + ogs_nnrf_nfm_send_nf_de_register(nf_instance)); + } + } + break; + + case OGS_EVENT_SBI_CLIENT: + message = e->sbi.message; + ogs_assert(message); + + SWITCH(message->h.service.name) + CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) + + SWITCH(message->h.resource.component0) + CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) + + if (message->res_status == OGS_SBI_HTTP_STATUS_NO_CONTENT || + message->res_status == OGS_SBI_HTTP_STATUS_OK) { + if (nf_instance->time.heartbeat_interval) + ogs_timer_start(nf_instance->t_no_heartbeat, + ogs_time_from_sec( + nf_instance->time.heartbeat_interval + + ogs_app()->time.nf_instance. + no_heartbeat_margin)); + } else { + ogs_warn("%s HTTP response error %d", + ogs_sbi_self()->nf_instance->id, + message->res_status); + OGS_FSM_TRAN(s, &ogs_sbi_nf_state_exception); + } + + break; + + DEFAULT + ogs_error("%s Invalid resource name %s", + ogs_sbi_self()->nf_instance->id, + message->h.resource.component0); + END + break; + + DEFAULT + ogs_error("%s Invalid API name %s", + ogs_sbi_self()->nf_instance->id, message->h.service.name); + END + break; + + case OGS_EVENT_SBI_TIMER: + switch(e->timer_id) { + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + if (nf_instance->time.heartbeat_interval) + ogs_timer_start(nf_instance->t_heartbeat_interval, + ogs_time_from_sec(nf_instance->time.heartbeat_interval)); + + ogs_assert(true == ogs_nnrf_nfm_send_nf_update(nf_instance)); + break; + + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + ogs_error("%s No heartbeat", ogs_sbi_self()->nf_instance->id); + OGS_FSM_TRAN(s, &ogs_sbi_nf_state_will_register); + break; + + case OGS_TIMER_NF_INSTANCE_VALIDITY: + ogs_assert(!NF_INSTANCE_TYPE_IS_NRF(nf_instance)); + ogs_assert(nf_instance->id); + + ogs_info("%s NF expired", nf_instance->id); + OGS_FSM_TRAN(s, &ogs_sbi_nf_state_de_registered); + break; + + default: + ogs_error("%s:%s Unknown timer%s:%d", + OpenAPI_nf_type_ToString(nf_instance->nf_type), + nf_instance->id ? nf_instance->id : "Undefined", + ogs_timer_get_name(e->timer_id), e->timer_id); + } + break; + + default: + ogs_error("%s:%s Unknown event %s", + OpenAPI_nf_type_ToString(nf_instance->nf_type), + nf_instance->id ? nf_instance->id : "Undefined", + ogs_event_get_name(e)); + break; + } +} + +void ogs_sbi_nf_state_de_registered(ogs_fsm_t *s, ogs_event_t *e) +{ + ogs_sbi_nf_instance_t *nf_instance = NULL; + ogs_assert(s); + ogs_assert(e); + + ogs_sbi_sm_debug(e); + + nf_instance = e->sbi.data; + ogs_assert(nf_instance); + ogs_assert(ogs_sbi_self()->nf_instance); + + switch (e->id) { + case OGS_FSM_ENTRY_SIG: + if (NF_INSTANCE_TYPE_IS_NRF(nf_instance)) { + ogs_info("%s NF de-registered", ogs_sbi_self()->nf_instance->id); + } + break; + + case OGS_FSM_EXIT_SIG: + break; + + default: + ogs_error("%s:%s Unknown event %s", + OpenAPI_nf_type_ToString(nf_instance->nf_type), + nf_instance->id ? nf_instance->id : "Undefined", + ogs_event_get_name(e)); + break; + } +} + +void ogs_sbi_nf_state_exception(ogs_fsm_t *s, ogs_event_t *e) +{ + ogs_sbi_nf_instance_t *nf_instance = NULL; + ogs_sbi_client_t *client = NULL; + ogs_sbi_message_t *message = NULL; + ogs_sockaddr_t *addr = NULL; + ogs_assert(s); + ogs_assert(e); + + ogs_sbi_sm_debug(e); + + nf_instance = e->sbi.data; + ogs_assert(nf_instance); + ogs_assert(ogs_sbi_self()->nf_instance); + + switch (e->id) { + case OGS_FSM_ENTRY_SIG: + if (NF_INSTANCE_TYPE_IS_NRF(nf_instance)) { + ogs_timer_start(nf_instance->t_registration_interval, + ogs_app()->time.message.sbi. + nf_register_interval_in_exception); + } + break; + + case OGS_FSM_EXIT_SIG: + if (NF_INSTANCE_TYPE_IS_NRF(nf_instance)) { + ogs_timer_stop(nf_instance->t_registration_interval); + } + break; + + case OGS_EVENT_SBI_TIMER: + switch(e->timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + client = nf_instance->client; + ogs_assert(client); + addr = client->node.addr; + ogs_assert(addr); + + ogs_warn("%s Retry to registration with NRF", + ogs_sbi_self()->nf_instance->id); + + OGS_FSM_TRAN(s, &ogs_sbi_nf_state_will_register); + break; + + default: + ogs_error("%s:%s Unknown timer%s:%d", + OpenAPI_nf_type_ToString(nf_instance->nf_type), + nf_instance->id ? nf_instance->id : "Undefined", + ogs_timer_get_name(e->timer_id), e->timer_id); + } + break; + + case OGS_EVENT_SBI_CLIENT: + message = e->sbi.message; + ogs_assert(message); + + SWITCH(message->h.service.name) + CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM) + + SWITCH(message->h.resource.component0) + CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) + break; + DEFAULT + ogs_error("Invalid resource name %s", + message->h.resource.component0); + END + break; + DEFAULT + ogs_error("Invalid API name %s", message->h.service.name); + END + break; + + default: + ogs_error("%s:%s Unknown event %s", + OpenAPI_nf_type_ToString(nf_instance->nf_type), + nf_instance->id ? nf_instance->id : "Undefined", + ogs_event_get_name(e)); + break; + } +}
View file
open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/sbi/nf-sm.h
Added
@@ -0,0 +1,49 @@ +/* + * Copyright (C) 2019,2020 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/>. + */ + +#if !defined(OGS_SBI_INSIDE) && !defined(OGS_SBI_COMPILATION) +#error "This header cannot be included directly." +#endif + +#ifndef OGS_SBI_NF_SM_H +#define OGS_SBI_NF_SM_H + +#ifdef __cplusplus +extern "C" { +#endif + +void ogs_sbi_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance); +void ogs_sbi_nf_fsm_tran(ogs_sbi_nf_instance_t *nf_instance, void *state); +void ogs_sbi_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance); + +void ogs_sbi_nf_state_initial(ogs_fsm_t *s, ogs_event_t *e); +void ogs_sbi_nf_state_final(ogs_fsm_t *s, ogs_event_t *e); +void ogs_sbi_nf_state_will_register(ogs_fsm_t *s, ogs_event_t *e); +void ogs_sbi_nf_state_registered(ogs_fsm_t *s, ogs_event_t *e); +void ogs_sbi_nf_state_de_registered(ogs_fsm_t *s, ogs_event_t *e); +void ogs_sbi_nf_state_exception(ogs_fsm_t *s, ogs_event_t *e); + +#define ogs_sbi_sm_debug(__e) \ + ogs_debug("%s(): %s", __func__, ogs_event_get_name(__e)) + +#ifdef __cplusplus +} +#endif + +#endif /* OGS_SBI_NF_SM_H */
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/sbi/nnrf-build.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/sbi/nnrf-build.c
Changed
@@ -32,11 +32,6 @@ OpenAPI_list_t *NFServiceList = NULL; int i = 0; -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - int fqdn_len; - char fqdnOGS_MAX_FQDN_LEN; -#endif - char *ipstr = NULL; nf_instance = ogs_sbi_self()->nf_instance; @@ -64,22 +59,8 @@ NFProfile->is_nf_profile_changes_support_ind = true; NFProfile->nf_profile_changes_support_ind = true; - if (nf_instance->fqdn) { -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - memset(fqdn, 0, sizeof(fqdn)); - fqdn_len = ogs_fqdn_build(fqdn, - nf_instance->fqdn, strlen(nf_instance->fqdn)); - NFProfile->fqdn = ogs_memdup(fqdn, fqdn_len+1); - ogs_expect_or_return_val(NFProfile->fqdn, NULL); - NFProfile->fqdnfqdn_len = 0; - - ogs_debug("NFInstance-FQDN%s", nf_instance->fqdn); - ogs_log_hexdump(OGS_LOG_DEBUG, - (unsigned char *)NFProfile->fqdn, fqdn_len); -#else + if (nf_instance->fqdn) NFProfile->fqdn = ogs_strdup(nf_instance->fqdn); -#endif - } NFProfile->is_priority = true; NFProfile->priority = nf_instance->priority; @@ -131,7 +112,7 @@ for (i = 0; i < nf_instance->num_of_allowed_nf_type; i++) { OpenAPI_list_add(AllowedNfTypeList, - (void *)(uintptr_t)nf_instance->allowed_nf_typesi); + (void *)(uintptr_t)nf_instance->allowed_nf_typei); } if (AllowedNfTypeList->count) @@ -163,21 +144,21 @@ NFServiceVersion = ogs_calloc(1, sizeof(*NFServiceVersion)); ogs_expect_or_return_val(NFServiceVersion, NULL); - if (nf_service->versionsi.in_uri) { + if (nf_service->versioni.in_uri) { NFServiceVersion->api_version_in_uri = - ogs_strdup(nf_service->versionsi.in_uri); + ogs_strdup(nf_service->versioni.in_uri); ogs_expect_or_return_val( NFServiceVersion->api_version_in_uri, NULL); } - if (nf_service->versionsi.full) { + if (nf_service->versioni.full) { NFServiceVersion->api_full_version = - ogs_strdup(nf_service->versionsi.full); + ogs_strdup(nf_service->versioni.full); ogs_expect_or_return_val( NFServiceVersion->api_full_version, NULL); } - if (nf_service->versionsi.expiry) { + if (nf_service->versioni.expiry) { NFServiceVersion->expiry = - ogs_strdup(nf_service->versionsi.expiry); + ogs_strdup(nf_service->versioni.expiry); ogs_expect_or_return_val( NFServiceVersion->expiry, NULL); } @@ -191,22 +172,8 @@ NFService->scheme = nf_service->scheme; NFService->nf_service_status = nf_service->status; - if (nf_service->fqdn) { -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - memset(fqdn, 0, sizeof(fqdn)); - fqdn_len = ogs_fqdn_build(fqdn, - nf_service->fqdn, strlen(nf_service->fqdn)); - NFService->fqdn = ogs_memdup(fqdn, fqdn_len+1); - ogs_expect_or_return_val(NFService->fqdn, NULL); - NFService->fqdnfqdn_len = 0; - - ogs_debug("NFService-FQDN%s", nf_service->fqdn); - ogs_log_hexdump(OGS_LOG_DEBUG, - (unsigned char *)NFService->fqdn, fqdn_len); -#else + if (nf_service->fqdn) NFService->fqdn = ogs_strdup(nf_service->fqdn); -#endif - } IpEndPointList = OpenAPI_list_create(); ogs_assert(IpEndPointList); @@ -333,6 +300,284 @@ ogs_free(NFProfile); } +ogs_sbi_request_t *ogs_nnrf_nfm_build_register(void) +{ + int i, j; + ogs_sbi_nf_instance_t *nf_instance = NULL; + ogs_sbi_nf_info_t *nf_info = NULL; + + ogs_sbi_message_t message; + ogs_sbi_request_t *request = NULL; + + OpenAPI_nf_profile_t *NFProfile = NULL; + + OpenAPI_list_t *SmfInfoList = NULL; + OpenAPI_map_t *SmfInfoMap = NULL; + OpenAPI_smf_info_t *SmfInfo = NULL; + int SmfInfoMapKey; + + OpenAPI_list_t *sNssaiSmfInfoList = NULL; + OpenAPI_snssai_smf_info_item_t *sNssaiSmfInfoItem = NULL; + OpenAPI_snssai_t *sNssai = NULL; + OpenAPI_list_t *DnnSmfInfoList = NULL; + OpenAPI_dnn_smf_info_item_t *DnnSmfInfoItem = NULL; + + OpenAPI_list_t *TaiList = NULL; + OpenAPI_tai_t *TaiItem = NULL; + OpenAPI_list_t *TaiRangeList = NULL; + OpenAPI_tai_range_t *TaiRangeItem = NULL; + OpenAPI_list_t *TacRangeList = NULL; + OpenAPI_tac_range_t *TacRangeItem = NULL; + + OpenAPI_lnode_t *node = NULL, *node2 = NULL, *node3 = NULL; + + nf_instance = ogs_sbi_self()->nf_instance; + ogs_assert(nf_instance); + ogs_assert(nf_instance->id); + + memset(&message, 0, sizeof(message)); + message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT; + message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; + message.h.api.version = (char *)OGS_SBI_API_V1; + message.h.resource.component0 = + (char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES; + message.h.resource.component1 = nf_instance->id; + + message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding; + + SmfInfoList = OpenAPI_list_create(); + ogs_assert(SmfInfoList); + + SmfInfoMapKey = 0; + + ogs_list_for_each(&nf_instance->nf_info_list, nf_info) { + if (nf_info->nf_type == OpenAPI_nf_type_SMF) { + + if (nf_info->smf.num_of_slice == 0) { + ogs_fatal("CHECK CONFIGURATION: No S-NSSAI"); + ogs_assert_if_reached(); + } + + SmfInfo = ogs_calloc(1, sizeof(*SmfInfo)); + ogs_expect_or_return_val(SmfInfo, NULL); + + sNssaiSmfInfoList = OpenAPI_list_create(); + ogs_assert(sNssaiSmfInfoList); + + for (i = 0; i < nf_info->smf.num_of_slice; i++) { + DnnSmfInfoList = OpenAPI_list_create(); + ogs_assert(DnnSmfInfoList); + + for (j = 0; j < nf_info->smf.slicei.num_of_dnn; j++) { + DnnSmfInfoItem = ogs_calloc(1, sizeof(*DnnSmfInfoItem)); + ogs_expect_or_return_val(DnnSmfInfoItem, NULL); + DnnSmfInfoItem->dnn = nf_info->smf.slicei.dnnj; + + OpenAPI_list_add(DnnSmfInfoList, DnnSmfInfoItem); + } + + if (!DnnSmfInfoList->count) { + OpenAPI_list_free(DnnSmfInfoList); + + ogs_error("CHECK CONFIGURATION: No DNN"); + ogs_expect_or_return_val(0, NULL); + } + + sNssaiSmfInfoItem = ogs_calloc(1, sizeof(*sNssaiSmfInfoItem)); + ogs_expect_or_return_val(sNssaiSmfInfoItem, NULL); + + sNssaiSmfInfoItem->dnn_smf_info_list = DnnSmfInfoList; + + sNssaiSmfInfoItem->s_nssai = sNssai = + ogs_calloc(1, sizeof(*sNssai)); + ogs_expect_or_return_val(sNssai, NULL); + sNssai->sst = nf_info->smf.slicei.s_nssai.sst; + sNssai->sd = + ogs_s_nssai_sd_to_string(nf_info->smf.slicei.s_nssai.sd); + + OpenAPI_list_add(sNssaiSmfInfoList, sNssaiSmfInfoItem); + } + + if (sNssaiSmfInfoList->count) + SmfInfo->s_nssai_smf_info_list = sNssaiSmfInfoList; + else + OpenAPI_list_free(sNssaiSmfInfoList); + + TaiList = OpenAPI_list_create(); + ogs_assert(TaiList); + + for (i = 0; i < nf_info->smf.num_of_nr_tai; i++) { + TaiItem = ogs_calloc(1, sizeof(*TaiItem)); + ogs_expect_or_return_val(TaiItem, NULL); + TaiItem->plmn_id = ogs_sbi_build_plmn_id( + &nf_info->smf.nr_taii.plmn_id); + ogs_expect_or_return_val(TaiItem->plmn_id, NULL); + TaiItem->tac = + ogs_uint24_to_0string(nf_info->smf.nr_taii.tac); + ogs_expect_or_return_val(TaiItem->tac, NULL); + + OpenAPI_list_add(TaiList, TaiItem); + } + + if (TaiList->count) + SmfInfo->tai_list = TaiList; + else + OpenAPI_list_free(TaiList); + + TaiRangeList = OpenAPI_list_create(); + ogs_assert(TaiRangeList); + + for (i = 0; i < nf_info->smf.num_of_nr_tai_range; i++) { + TacRangeList = OpenAPI_list_create(); + ogs_assert(TacRangeList); + + for (j = 0; + j < nf_info->smf.nr_tai_rangei.num_of_tac_range; + j++) { + TacRangeItem = ogs_calloc(1, sizeof(*TacRangeItem)); + ogs_expect_or_return_val(TacRangeItem, NULL); + + TacRangeItem->start = ogs_uint24_to_0string( + nf_info->smf.nr_tai_rangei.startj); + ogs_expect_or_return_val(TacRangeItem->start, NULL); + TacRangeItem->end = + ogs_uint24_to_0string( + nf_info->smf.nr_tai_rangei.endj); + ogs_expect_or_return_val(TacRangeItem->end, NULL); + + OpenAPI_list_add(TacRangeList, TacRangeItem); + } + + if (!TacRangeList->count) { + OpenAPI_list_free(TacRangeList); + + ogs_error("CHECK CONFIGURATION: No Start/End in TacRange"); + ogs_expect_or_return_val(0, NULL); + } + + TaiRangeItem = ogs_calloc(1, sizeof(*TaiRangeItem)); + ogs_expect_or_return_val(TaiRangeItem, NULL); + + TaiRangeItem->plmn_id = ogs_sbi_build_plmn_id( + &nf_info->smf.nr_tai_rangei.plmn_id); + ogs_expect_or_return_val(TaiRangeItem->plmn_id, NULL); + + TaiRangeItem->tac_range_list = TacRangeList; + + OpenAPI_list_add(TaiRangeList, TaiRangeItem); + } + + if (TaiRangeList->count) + SmfInfo->tai_range_list = TaiRangeList; + else + OpenAPI_list_free(TaiRangeList); + + SmfInfoMap = OpenAPI_map_create( + ogs_msprintf("%d", ++SmfInfoMapKey), SmfInfo); + ogs_assert(SmfInfoMap); + + OpenAPI_list_add(SmfInfoList, SmfInfoMap); + + } else { + ogs_fatal("Not implemented NF-type%s", + OpenAPI_nf_type_ToString(nf_info->nf_type)); + ogs_assert_if_reached(); + } + } + + NFProfile = ogs_nnrf_nfm_build_nf_profile(); + ogs_expect_or_return_val(NFProfile, NULL); + + if (SmfInfoList->count == 1) { + NFProfile->smf_info = SmfInfo; + } else if (SmfInfoList->count > 1) { + NFProfile->smf_info_list = SmfInfoList; + } + + message.NFProfile = NFProfile; + + request = ogs_sbi_build_request(&message); + + ogs_sbi_nnrf_free_nf_profile(NFProfile); + + OpenAPI_list_for_each(SmfInfoList, node) { + SmfInfoMap = node->data; + if (SmfInfoMap) { + SmfInfo = SmfInfoMap->value; + if (SmfInfo) { + sNssaiSmfInfoList = SmfInfo->s_nssai_smf_info_list; + OpenAPI_list_for_each(sNssaiSmfInfoList, node2) { + sNssaiSmfInfoItem = node2->data; + ogs_assert(sNssaiSmfInfoItem); + + DnnSmfInfoList = sNssaiSmfInfoItem->dnn_smf_info_list; + OpenAPI_list_for_each(DnnSmfInfoList, node3) { + DnnSmfInfoItem = node3->data; + ogs_assert(DnnSmfInfoItem); + ogs_free(DnnSmfInfoItem); + } + OpenAPI_list_free(DnnSmfInfoList); + + sNssai = sNssaiSmfInfoItem->s_nssai; + if (sNssai) { + if (sNssai->sd) + ogs_free(sNssai->sd); + ogs_free(sNssai); + } + + ogs_free(sNssaiSmfInfoItem); + } + OpenAPI_list_free(sNssaiSmfInfoList); + + TaiList = SmfInfo->tai_list; + OpenAPI_list_for_each(TaiList, node2) { + TaiItem = node2->data; + ogs_assert(TaiItem); + if (TaiItem->plmn_id) + ogs_sbi_free_plmn_id(TaiItem->plmn_id); + if (TaiItem->tac) + ogs_free(TaiItem->tac); + ogs_free(TaiItem); + } + OpenAPI_list_free(TaiList); + + TaiRangeList = SmfInfo->tai_range_list; + OpenAPI_list_for_each(TaiRangeList, node2) { + TaiRangeItem = node2->data; + ogs_assert(TaiRangeItem); + + if (TaiRangeItem->plmn_id) + ogs_sbi_free_plmn_id(TaiRangeItem->plmn_id); + + TacRangeList = TaiRangeItem->tac_range_list; + OpenAPI_list_for_each(TacRangeList, node3) { + TacRangeItem = node3->data; + ogs_assert(TacRangeItem); + if (TacRangeItem->start) + ogs_free(TacRangeItem->start); + if (TacRangeItem->end) + ogs_free(TacRangeItem->end); + + ogs_free(TacRangeItem); + } + OpenAPI_list_free(TacRangeList); + + ogs_free(TaiRangeItem); + } + OpenAPI_list_free(TaiRangeList); + + ogs_free(SmfInfo); + } + if (SmfInfoMap->key) + ogs_free(SmfInfoMap->key); + ogs_free(SmfInfoMap); + } + } + OpenAPI_list_free(SmfInfoList); + + return request; +} + ogs_sbi_request_t *ogs_nnrf_nfm_build_update(void) { ogs_sbi_nf_instance_t *nf_instance = NULL;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/sbi/nnrf-build.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/sbi/nnrf-build.h
Changed
@@ -27,6 +27,7 @@ OpenAPI_nf_profile_t *ogs_nnrf_nfm_build_nf_profile(void); void ogs_sbi_nnrf_free_nf_profile(OpenAPI_nf_profile_t *NFProfile); +ogs_sbi_request_t *ogs_nnrf_nfm_build_register(void); ogs_sbi_request_t *ogs_nnrf_nfm_build_update(void); ogs_sbi_request_t *ogs_nnrf_nfm_build_de_register(void);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/sbi/nnrf-handler.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/sbi/nnrf-handler.c
Changed
@@ -21,139 +21,31 @@ #include "ogs-app.h" static void handle_smf_info( - ogs_sbi_nf_instance_t *nf_instance, OpenAPI_smf_info_t *SmfInfo) -{ - ogs_sbi_nf_info_t *nf_info = NULL; - - OpenAPI_list_t *sNssaiSmfInfoList = NULL; - OpenAPI_snssai_smf_info_item_t *sNssaiSmfInfoItem = NULL; - OpenAPI_snssai_t *sNssai = NULL; - OpenAPI_list_t *DnnSmfInfoList = NULL; - OpenAPI_dnn_smf_info_item_t *DnnSmfInfoItem = NULL; - - OpenAPI_list_t *TaiList = NULL; - OpenAPI_tai_t *TaiItem = NULL; - OpenAPI_list_t *TaiRangeList = NULL; - OpenAPI_tai_range_t *TaiRangeItem = NULL; - OpenAPI_list_t *TacRangeList = NULL; - OpenAPI_tac_range_t *TacRangeItem = NULL; + ogs_sbi_nf_instance_t *nf_instance, OpenAPI_smf_info_t *SmfInfo); - OpenAPI_lnode_t *node = NULL, *node2 = NULL; +void ogs_sbi_nnrf_handle_nf_register( + ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg) +{ + OpenAPI_nf_profile_t *NFProfile = NULL; + ogs_sbi_client_t *client = NULL; + ogs_assert(recvmsg); ogs_assert(nf_instance); - ogs_assert(SmfInfo); - - nf_info = ogs_sbi_nf_info_add( - &nf_instance->nf_info_list, OpenAPI_nf_type_SMF); - ogs_assert(nf_info); - - sNssaiSmfInfoList = SmfInfo->s_nssai_smf_info_list; - OpenAPI_list_for_each(sNssaiSmfInfoList, node) { - sNssaiSmfInfoItem = node->data; - if (sNssaiSmfInfoItem) { - ogs_assert(nf_info->smf.num_of_slice < OGS_MAX_NUM_OF_SLICE); - - DnnSmfInfoList = sNssaiSmfInfoItem->dnn_smf_info_list; - OpenAPI_list_for_each(DnnSmfInfoList, node2) { - DnnSmfInfoItem = node2->data; - if (DnnSmfInfoItem && DnnSmfInfoItem->dnn) { - int dnn_index = nf_info->smf.slice - nf_info->smf.num_of_slice.num_of_dnn; - - ogs_assert(dnn_index < OGS_MAX_NUM_OF_DNN); - nf_info->smf.slicenf_info->smf.num_of_slice. - dnndnn_index = ogs_strdup(DnnSmfInfoItem->dnn); - ogs_assert( - nf_info->smf.slicenf_info->smf.num_of_slice. - dnndnn_index); - nf_info->smf.slicenf_info->smf.num_of_slice. - num_of_dnn++; - } - } - - if (!nf_info->smf.slicenf_info->smf.num_of_slice.num_of_dnn) { - ogs_error("No DNN"); - continue; - } + client = nf_instance->client; + ogs_assert(client); - sNssai = sNssaiSmfInfoItem->s_nssai; - if (sNssai) { - ogs_s_nssai_t *s_nssai = NULL; - - s_nssai = &nf_info->smf. - slicenf_info->smf.num_of_slice.s_nssai; - s_nssai->sst = sNssai->sst; - s_nssai->sd = ogs_s_nssai_sd_from_string(sNssai->sd); - nf_info->smf.num_of_slice++; - } - } - } - - if (nf_info->smf.num_of_slice == 0) { - ogs_error("No S-NSSAI(DNN) in smfInfo"); - ogs_sbi_nf_info_remove(&nf_instance->nf_info_list, nf_info); + NFProfile = recvmsg->NFProfile; + if (!NFProfile) { + ogs_error("No NFProfile"); return; } - TaiList = SmfInfo->tai_list; - OpenAPI_list_for_each(TaiList, node) { - TaiItem = node->data; - if (TaiItem && TaiItem->plmn_id && TaiItem->tac) { - ogs_5gs_tai_t *nr_tai = NULL; - ogs_assert(nf_info->smf.num_of_nr_tai < OGS_MAX_NUM_OF_TAI); - - nr_tai = &nf_info->smf.nr_tainf_info->smf.num_of_nr_tai; - ogs_assert(nr_tai); - ogs_sbi_parse_plmn_id(&nr_tai->plmn_id, TaiItem->plmn_id); - nr_tai->tac = ogs_uint24_from_string(TaiItem->tac); - - nf_info->smf.num_of_nr_tai++; - } - } - - TaiRangeList = SmfInfo->tai_range_list; - OpenAPI_list_for_each(TaiRangeList, node) { - TaiRangeItem = node->data; - if (TaiRangeItem && TaiRangeItem->plmn_id && - TaiRangeItem->tac_range_list) { - ogs_assert(nf_info->smf.num_of_nr_tai_range < - OGS_MAX_NUM_OF_TAI); - - ogs_sbi_parse_plmn_id( - &nf_info->smf.nr_tai_range - nf_info->smf.num_of_nr_tai_range.plmn_id, - TaiRangeItem->plmn_id); - - TacRangeList = TaiRangeItem->tac_range_list; - OpenAPI_list_for_each(TacRangeList, node2) { - TacRangeItem = node2->data; - if (TacRangeItem && - TacRangeItem->start && TacRangeItem->end) { - int tac_index = nf_info->smf.nr_tai_range - nf_info->smf.num_of_nr_tai_range.num_of_tac_range; - ogs_assert(tac_index < OGS_MAX_NUM_OF_TAI); - - nf_info->smf.nr_tai_range - nf_info->smf.num_of_nr_tai_range. - starttac_index = - ogs_uint24_from_string(TacRangeItem->start); - nf_info->smf.nr_tai_range - nf_info->smf.num_of_nr_tai_range. - endtac_index = - ogs_uint24_from_string(TacRangeItem->end); - - nf_info->smf.nr_tai_range - nf_info->smf.num_of_nr_tai_range. - num_of_tac_range++; - } - } - - nf_info->smf.num_of_nr_tai_range++; - } - } + /* TIME : Update heartbeat from NRF */ + if (NFProfile->is_heart_beat_timer == true) + nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; } -bool ogs_sbi_nnrf_handle_nf_profile(ogs_sbi_nf_instance_t *nf_instance, +void ogs_sbi_nnrf_handle_nf_profile(ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_profile_t *NFProfile, ogs_sbi_stream_t *stream, ogs_sbi_message_t *message) { @@ -161,52 +53,12 @@ OpenAPI_lnode_t *node; ogs_sbi_nf_service_t *nf_service = NULL, *next_nf_service = NULL; -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - char fqdnOGS_MAX_FQDN_LEN+1; -#endif ogs_assert(nf_instance); ogs_assert(NFProfile); - - if (!NFProfile) { - ogs_error("No NFProfile"); - if (stream) - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - message, "No NFProfile", NULL)); - return false; - } - - if (!NFProfile->nf_instance_id) { - ogs_error("No NFProfile.NFInstanceId"); - if (stream) - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - message, "NFProfile", "No NFInstanceId")); - return false; - } - - if (!NFProfile->nf_type) { - ogs_error("No NFProfile.NFType"); - if (stream) - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - message, "NFProfile", "No NFType")); - return false; - } - - if (!NFProfile->nf_status) { - ogs_error("No NFProfile.NFStatus"); - if (stream) - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - message, "NFProfile", "No NFStatus")); - return false; - } + ogs_assert(NFProfile->nf_instance_id); + ogs_assert(NFProfile->nf_type); + ogs_assert(NFProfile->nf_status); ogs_list_for_each_safe(&nf_instance->nf_service_list, next_nf_service, nf_service) { @@ -250,24 +102,8 @@ if (NFProfile->is_heart_beat_timer == true) nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; - if (NFProfile->fqdn) { -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - if (ogs_fqdn_parse( - fqdn, NFProfile->fqdn, - ogs_min(strlen(NFProfile->fqdn), OGS_MAX_FQDN_LEN)) > 0) { - - /* Nothing : succeeded to parse FQDN */ - nf_instance->fqdn = ogs_strdup(fqdn); - ogs_assert(nf_instance); - - } else { - ogs_error("ogs_fqdn_parse() failed%s", NFProfile->fqdn); - return false; - } -#else + if (NFProfile->fqdn) nf_instance->fqdn = ogs_strdup(NFProfile->fqdn); -#endif - } if (NFProfile->is_priority == true) nf_instance->priority = NFProfile->priority; @@ -345,25 +181,8 @@ NFServiceVersion->expiry); } - if (NFService->fqdn) { -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - if (ogs_fqdn_parse( - fqdn, NFService->fqdn, - ogs_min(strlen(NFService->fqdn), OGS_MAX_FQDN_LEN)) > 0) { - - /* Nothing : succeeded to parse FQDN */ - nf_service->fqdn = ogs_strdup(fqdn); - ogs_assert(nf_service); - - } else { - ogs_error("ogs_fqdn_parse() failed%s", NFService->fqdn); - return false; - } -#else + if (NFService->fqdn) nf_service->fqdn = ogs_strdup(NFService->fqdn); - ogs_assert(nf_service); -#endif - } OpenAPI_list_for_each(IpEndPointList, node2) { OpenAPI_ip_end_point_t *IpEndPoint = node2->data; @@ -438,6 +257,441 @@ if (SmfInfoMap && SmfInfoMap->value) handle_smf_info(nf_instance, SmfInfoMap->value); } +} + +static void handle_smf_info( + ogs_sbi_nf_instance_t *nf_instance, OpenAPI_smf_info_t *SmfInfo) +{ + ogs_sbi_nf_info_t *nf_info = NULL; + + OpenAPI_list_t *sNssaiSmfInfoList = NULL; + OpenAPI_snssai_smf_info_item_t *sNssaiSmfInfoItem = NULL; + OpenAPI_snssai_t *sNssai = NULL; + OpenAPI_list_t *DnnSmfInfoList = NULL; + OpenAPI_dnn_smf_info_item_t *DnnSmfInfoItem = NULL; + + OpenAPI_list_t *TaiList = NULL; + OpenAPI_tai_t *TaiItem = NULL; + OpenAPI_list_t *TaiRangeList = NULL; + OpenAPI_tai_range_t *TaiRangeItem = NULL; + OpenAPI_list_t *TacRangeList = NULL; + OpenAPI_tac_range_t *TacRangeItem = NULL; + + OpenAPI_lnode_t *node = NULL, *node2 = NULL; + + ogs_assert(nf_instance); + ogs_assert(SmfInfo); + + nf_info = ogs_sbi_nf_info_add( + &nf_instance->nf_info_list, OpenAPI_nf_type_SMF); + ogs_assert(nf_info); + + sNssaiSmfInfoList = SmfInfo->s_nssai_smf_info_list; + OpenAPI_list_for_each(sNssaiSmfInfoList, node) { + sNssaiSmfInfoItem = node->data; + if (sNssaiSmfInfoItem) { + ogs_assert(nf_info->smf.num_of_slice < OGS_MAX_NUM_OF_SLICE); + + DnnSmfInfoList = sNssaiSmfInfoItem->dnn_smf_info_list; + OpenAPI_list_for_each(DnnSmfInfoList, node2) { + DnnSmfInfoItem = node2->data; + if (DnnSmfInfoItem && DnnSmfInfoItem->dnn) { + int dnn_index = nf_info->smf.slice + nf_info->smf.num_of_slice.num_of_dnn; + + ogs_assert(dnn_index < OGS_MAX_NUM_OF_DNN); + nf_info->smf.slicenf_info->smf.num_of_slice. + dnndnn_index = ogs_strdup(DnnSmfInfoItem->dnn); + ogs_assert( + nf_info->smf.slicenf_info->smf.num_of_slice. + dnndnn_index); + nf_info->smf.slicenf_info->smf.num_of_slice. + num_of_dnn++; + } + } + + if (!nf_info->smf.slicenf_info->smf.num_of_slice.num_of_dnn) { + ogs_error("No DNN"); + continue; + } + + sNssai = sNssaiSmfInfoItem->s_nssai; + if (sNssai) { + ogs_s_nssai_t *s_nssai = NULL; + + s_nssai = &nf_info->smf. + slicenf_info->smf.num_of_slice.s_nssai; + s_nssai->sst = sNssai->sst; + s_nssai->sd = ogs_s_nssai_sd_from_string(sNssai->sd); + nf_info->smf.num_of_slice++; + } + } + } + + if (nf_info->smf.num_of_slice == 0) { + ogs_error("No S-NSSAI(DNN) in smfInfo"); + ogs_sbi_nf_info_remove(&nf_instance->nf_info_list, nf_info); + return; + } + + TaiList = SmfInfo->tai_list; + OpenAPI_list_for_each(TaiList, node) { + TaiItem = node->data; + if (TaiItem && TaiItem->plmn_id && TaiItem->tac) { + ogs_5gs_tai_t *nr_tai = NULL; + ogs_assert(nf_info->smf.num_of_nr_tai < OGS_MAX_NUM_OF_TAI); + + nr_tai = &nf_info->smf.nr_tainf_info->smf.num_of_nr_tai; + ogs_assert(nr_tai); + ogs_sbi_parse_plmn_id(&nr_tai->plmn_id, TaiItem->plmn_id); + nr_tai->tac = ogs_uint24_from_string(TaiItem->tac); + + nf_info->smf.num_of_nr_tai++; + } + } + + TaiRangeList = SmfInfo->tai_range_list; + OpenAPI_list_for_each(TaiRangeList, node) { + TaiRangeItem = node->data; + if (TaiRangeItem && TaiRangeItem->plmn_id && + TaiRangeItem->tac_range_list) { + ogs_assert(nf_info->smf.num_of_nr_tai_range < + OGS_MAX_NUM_OF_TAI); + + ogs_sbi_parse_plmn_id( + &nf_info->smf.nr_tai_range + nf_info->smf.num_of_nr_tai_range.plmn_id, + TaiRangeItem->plmn_id); + + TacRangeList = TaiRangeItem->tac_range_list; + OpenAPI_list_for_each(TacRangeList, node2) { + TacRangeItem = node2->data; + if (TacRangeItem && + TacRangeItem->start && TacRangeItem->end) { + int tac_index = nf_info->smf.nr_tai_range + nf_info->smf.num_of_nr_tai_range.num_of_tac_range; + ogs_assert(tac_index < OGS_MAX_NUM_OF_TAI); + + nf_info->smf.nr_tai_range + nf_info->smf.num_of_nr_tai_range. + starttac_index = + ogs_uint24_from_string(TacRangeItem->start); + nf_info->smf.nr_tai_range + nf_info->smf.num_of_nr_tai_range. + endtac_index = + ogs_uint24_from_string(TacRangeItem->end); + + nf_info->smf.nr_tai_range + nf_info->smf.num_of_nr_tai_range. + num_of_tac_range++; + } + } + + nf_info->smf.num_of_nr_tai_range++; + } + } +} + +void ogs_nnrf_handle_nf_status_subscribe( + ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg) +{ + OpenAPI_subscription_data_t *SubscriptionData = NULL; + ogs_sbi_client_t *client = NULL; + + ogs_assert(recvmsg); + ogs_assert(subscription); + client = subscription->client; + ogs_assert(client); + + SubscriptionData = recvmsg->SubscriptionData; + if (!SubscriptionData) { + ogs_error("No SubscriptionData"); + return; + } + + if (!SubscriptionData->subscription_id) { + ogs_error("No SubscriptionId"); + return; + } + ogs_sbi_subscription_set_id( + subscription, SubscriptionData->subscription_id); + if (SubscriptionData->validity_time) { +#define VALIDITY_MINIMUM (10LL * OGS_USEC_PER_SEC) /* 10 seconds */ + ogs_time_t time, duration; + if (ogs_sbi_time_from_string( + &time, SubscriptionData->validity_time) == true) { + duration = time - ogs_time_now(); + if (duration < VALIDITY_MINIMUM) { + duration = VALIDITY_MINIMUM; + ogs_warn("%s Forced to %lld seconds", subscription->id, + (long long)ogs_time_sec(VALIDITY_MINIMUM)); + } + subscription->t_validity = ogs_timer_add(ogs_app()->timer_mgr, + ogs_timer_subscription_validity, subscription); + ogs_assert(subscription->t_validity); + ogs_timer_start(subscription->t_validity, duration); + } else { + ogs_error("Cannot parse validitiyTime %s", + SubscriptionData->validity_time); + } + } +} + +bool ogs_nnrf_handle_nf_status_notify( + ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) +{ + int rv; + + ogs_sbi_response_t *response = NULL; + OpenAPI_notification_data_t *NotificationData = NULL; + ogs_sbi_nf_instance_t *nf_instance = NULL; + + ogs_sbi_message_t message; + ogs_sbi_header_t header; + + ogs_assert(stream); + ogs_assert(recvmsg); + + NotificationData = recvmsg->NotificationData; + if (!NotificationData) { + ogs_error("No NotificationData"); + ogs_assert(true == + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No NotificationData", NULL)); + return false; + } + + if (!NotificationData->nf_instance_uri) { + ogs_error("No nfInstanceUri"); + ogs_assert(true == + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No nfInstanceUri", NULL)); + return false; + } + + memset(&header, 0, sizeof(header)); + header.uri = NotificationData->nf_instance_uri; + + rv = ogs_sbi_parse_header(&message, &header); + if (rv != OGS_OK) { + ogs_error("Cannot parse nfInstanceUri %s", header.uri); + ogs_assert(true == + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "Cannot parse nfInstanceUri", header.uri)); + return false; + } + + if (!message.h.resource.component1) { + ogs_error("No nfInstanceId %s", header.uri); + ogs_assert(true == + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "Cannot parse nfInstanceUri", header.uri)); + ogs_sbi_header_free(&header); + return false; + } + + if (NF_INSTANCE_ID_IS_SELF(message.h.resource.component1)) { + ogs_warn("%s The notification is not allowed", + message.h.resource.component1); + ogs_assert(true == + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_FORBIDDEN, + recvmsg, "The notification is not allowed", + message.h.resource.component1)); + ogs_sbi_header_free(&header); + return false; + } + + if (NotificationData->event == + OpenAPI_notification_event_type_NF_REGISTERED) { + + OpenAPI_nf_profile_t *NFProfile = NULL; + + NFProfile = NotificationData->nf_profile; + if (!NFProfile) { + ogs_error("No NFProfile"); + ogs_assert(true == + ogs_sbi_server_send_error( + stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No NFProfile", NULL)); + ogs_sbi_header_free(&header); + return false; + } + + if (!NFProfile->nf_instance_id) { + ogs_error("No NFProfile.NFInstanceId"); + ogs_assert(true == + ogs_sbi_server_send_error( + stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No NFProfile.NFInstanceId", NULL)); + ogs_sbi_header_free(&header); + return false; + } + + if (!NFProfile->nf_type) { + ogs_error("No NFProfile.NFType"); + ogs_assert(true == + ogs_sbi_server_send_error( + stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No NFProfile.NFType", NULL)); + ogs_sbi_header_free(&header); + return false; + } + + if (!NFProfile->nf_status) { + ogs_error("No NFProfile.NFStatus"); + ogs_assert(true == + ogs_sbi_server_send_error( + stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "No NFProfile.NFStatus", NULL)); + ogs_sbi_header_free(&header); + return false; + } + + nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); + if (!nf_instance) { + nf_instance = ogs_sbi_nf_instance_add(); + ogs_assert(nf_instance); + + ogs_sbi_nf_instance_set_id( + nf_instance, message.h.resource.component1); + ogs_sbi_nf_fsm_init(nf_instance); + + ogs_info("%s (NRF-notify) NF registered", nf_instance->id); + } else { + ogs_sbi_nf_fsm_tran(nf_instance, ogs_sbi_nf_state_registered); + + ogs_warn("%s (NRF-notify) NF has already been added", + message.h.resource.component1); + } + + ogs_sbi_nnrf_handle_nf_profile(nf_instance, NFProfile, stream, recvmsg); + + ogs_info("%s (NRF-notify) NF Profile updated", nf_instance->id); + + ogs_sbi_client_associate(nf_instance); + + } else if (NotificationData->event == + OpenAPI_notification_event_type_NF_DEREGISTERED) { + nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); + if (nf_instance) { + if (OGS_OBJECT_IS_REF(nf_instance)) { + /* There are references to other contexts. */ + ogs_warn("%s:%d NF was referenced in other contexts", + nf_instance->id, nf_instance->reference_count); + ogs_sbi_nf_fsm_tran( + nf_instance, ogs_sbi_nf_state_de_registered); + } else { + ogs_info("%s NF removed", nf_instance->id); + ogs_sbi_nf_fsm_fini((nf_instance)); + ogs_sbi_nf_instance_remove(nf_instance); + } + } else { + ogs_warn("%s (NRF-notify) Not found", + message.h.resource.component1); + ogs_assert(true == + ogs_sbi_server_send_error(stream, + OGS_SBI_HTTP_STATUS_NOT_FOUND, + recvmsg, "Not found", message.h.resource.component1)); + ogs_sbi_header_free(&header); + return false; + } + } else { + char *eventstr = OpenAPI_notification_event_type_ToString( + NotificationData->event); + ogs_error("Not supported event %d:%s", + NotificationData->event, eventstr ? eventstr : "Unknown"); + ogs_assert(true == + ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, + recvmsg, "Not supported event", + eventstr ? eventstr : "Unknown")); + ogs_sbi_header_free(&header); + return false; + } + + response = ogs_sbi_build_response(recvmsg, OGS_SBI_HTTP_STATUS_NO_CONTENT); + ogs_assert(response); + ogs_assert(true == ogs_sbi_server_send_response(stream, response)); + + ogs_sbi_header_free(&header); return true; } + +void ogs_nnrf_handle_nf_discover_search_result( + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + OpenAPI_search_result_t *SearchResult) +{ + OpenAPI_lnode_t *node = NULL; + ogs_sbi_nf_instance_t *nf_instance = NULL; + + ogs_assert(sbi_object); + ogs_assert(SearchResult); + + OpenAPI_list_for_each(SearchResult->nf_instances, node) { + OpenAPI_nf_profile_t *NFProfile = NULL; + + if (!node->data) continue; + + NFProfile = node->data; + + if (!NFProfile) { + ogs_error("No NFProfile"); + continue; + } + + if (!NFProfile->nf_instance_id) { + ogs_error("No NFProfile.NFInstanceId"); + continue; + } + + if (!NFProfile->nf_type) { + ogs_error("No NFProfile.NFType"); + continue; + } + + if (!NFProfile->nf_status) { + ogs_error("No NFProfile.NFStatus"); + continue; + } + + nf_instance = ogs_sbi_nf_instance_find(NFProfile->nf_instance_id); + if (!nf_instance) { + nf_instance = ogs_sbi_nf_instance_add(); + ogs_assert(nf_instance); + + ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id); + ogs_sbi_nf_fsm_init(nf_instance); + + ogs_info("%s (NF-discover) NF registered", nf_instance->id); + } else { + ogs_sbi_nf_fsm_tran(nf_instance, ogs_sbi_nf_state_registered); + + ogs_warn("%s (NF-discover) NF has already been added", + NFProfile->nf_instance_id); + } + + if (NF_INSTANCE_ID_IS_OTHERS(nf_instance->id)) { + ogs_sbi_nnrf_handle_nf_profile(nf_instance, NFProfile, NULL, NULL); + + ogs_sbi_client_associate(nf_instance); + + /* TIME : Update validity from NRF */ + if (SearchResult->is_validity_period && + SearchResult->validity_period) { + nf_instance->time.validity_duration = + SearchResult->validity_period; + + ogs_assert(nf_instance->t_validity); + ogs_timer_start(nf_instance->t_validity, + ogs_time_from_sec(nf_instance->time.validity_duration)); + + } else + ogs_warn("%s NF Instance validity-time should not 0", + nf_instance->id); + + ogs_info("%s (NF-discover) NF Profile updated", nf_instance->id); + } + } +}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/sbi/nnrf-handler.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/sbi/nnrf-handler.h
Changed
@@ -24,10 +24,23 @@ extern "C" { #endif -bool ogs_sbi_nnrf_handle_nf_profile(ogs_sbi_nf_instance_t *nf_instance, +void ogs_sbi_nnrf_handle_nf_register( + ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg); +void ogs_sbi_nnrf_handle_nf_profile(ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_profile_t *NFProfile, ogs_sbi_stream_t *stream, ogs_sbi_message_t *message); +void ogs_nnrf_handle_nf_status_subscribe( + ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg); +bool ogs_nnrf_handle_nf_status_notify( + ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); + +void ogs_nnrf_handle_nf_discover_search_result( + ogs_sbi_object_t *sbi_object, + OpenAPI_nf_type_e target_nf_type, + ogs_sbi_discovery_option_t *discovery_option, + OpenAPI_search_result_t *SearchResult); + #ifdef __cplusplus } #endif
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/sbi/ogs-sbi.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/sbi/ogs-sbi.h
Changed
@@ -20,7 +20,7 @@ #ifndef OGS_SBI_H #define OGS_SBI_H -#include "ogs-core.h" +#include "ogs-proto.h" #if defined(__GNUC__) #pragma GCC diagnostic push @@ -86,12 +86,15 @@ #define OGS_SBI_INSIDE #include "sbi/conv.h" +#include "sbi/timer.h" #include "sbi/message.h" #include "sbi/server.h" #include "sbi/client.h" #include "sbi/context.h" +#include "sbi/nf-sm.h" + #include "sbi/nnrf-build.h" #include "sbi/nnrf-handler.h"
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/sbi/path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/sbi/path.c
Changed
@@ -124,8 +124,7 @@ return false; } -bool ogs_nnrf_nfm_send_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_request_t *(*build)(void)) +bool ogs_nnrf_nfm_send_nf_register(ogs_sbi_nf_instance_t *nf_instance) { ogs_sbi_request_t *request = NULL; ogs_sbi_client_t *client = NULL; @@ -133,9 +132,8 @@ ogs_assert(nf_instance); client = nf_instance->client; ogs_assert(client); - ogs_assert(build); - request = (*build)(); + request = ogs_nnrf_nfm_build_register(); ogs_expect_or_return_val(request, false); return ogs_sbi_scp_send_request(client, client->cb, request, nf_instance);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/sbi/path.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/sbi/path.h
Changed
@@ -35,8 +35,7 @@ ogs_sbi_discovery_option_t *discovery_option, ogs_sbi_client_cb_f client_cb, void *data); -bool ogs_nnrf_nfm_send_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_request_t *(*build)(void)); +bool ogs_nnrf_nfm_send_nf_register(ogs_sbi_nf_instance_t *nf_instance); bool ogs_nnrf_nfm_send_nf_update(ogs_sbi_nf_instance_t *nf_instance); bool ogs_nnrf_nfm_send_nf_de_register(ogs_sbi_nf_instance_t *nf_instance); bool ogs_nnrf_nfm_send_nf_profile_retrieve(ogs_sbi_nf_instance_t *nf_instance,
View file
open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/sbi/timer.c
Added
@@ -0,0 +1,83 @@ +/* + * Copyright (C) 2019-2022 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/>. + */ + +#include "ogs-sbi.h" +#include "ogs-app.h" + +static void timer_send_event(int timer_id, void *data) +{ + int rv; + ogs_event_t *e = NULL; + ogs_assert(data); + + switch (timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + case OGS_TIMER_NF_INSTANCE_VALIDITY: + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + case OGS_TIMER_SBI_CLIENT_WAIT: + e = ogs_event_new(OGS_EVENT_SBI_TIMER); + ogs_assert(e); + e->timer_id = timer_id; + e->sbi.data = data; + break; + default: + ogs_fatal("Unknown timer id%d", timer_id); + ogs_assert_if_reached(); + break; + } + + rv = ogs_queue_push(ogs_app()->queue, e); + if (rv != OGS_OK) { + ogs_error("ogs_queue_push() failed %d in %s", + (int)rv, ogs_timer_get_name(e->timer_id)); + ogs_event_free(e); + } +} + +void ogs_timer_nf_instance_registration_interval(void *data) +{ + timer_send_event(OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, data); +} + +void ogs_timer_nf_instance_heartbeat_interval(void *data) +{ + timer_send_event(OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, data); +} + +void ogs_timer_nf_instance_no_heartbeat(void *data) +{ + timer_send_event(OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT, data); +} + +void ogs_timer_nf_instance_validity(void *data) +{ + timer_send_event(OGS_TIMER_NF_INSTANCE_VALIDITY, data); +} + +void ogs_timer_subscription_validity(void *data) +{ + timer_send_event(OGS_TIMER_SUBSCRIPTION_VALIDITY, data); +} + +void ogs_timer_sbi_client_wait_expire(void *data) +{ + timer_send_event(OGS_TIMER_SBI_CLIENT_WAIT, data); +}
View file
open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/sbi/timer.h
Added
@@ -0,0 +1,42 @@ +/* + * Copyright (C) 2019-2022 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/>. + */ + +#if !defined(OGS_SBI_INSIDE) && !defined(OGS_SBI_COMPILATION) +#error "This header cannot be included directly." +#endif + +#ifndef OGS_SBI_TIMER_H +#define OGS_SBI_TIMER_H + +#ifdef __cplusplus +extern "C" { +#endif + +void ogs_timer_nf_instance_registration_interval(void *data); +void ogs_timer_nf_instance_heartbeat_interval(void *data); +void ogs_timer_nf_instance_no_heartbeat(void *data); +void ogs_timer_nf_instance_validity(void *data); +void ogs_timer_subscription_validity(void *data); +void ogs_timer_sbi_client_wait_expire(void *data); + +#ifdef __cplusplus +} +#endif + +#endif /* OGS_SBI_TIMER_H */
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/tun/meson.build -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/tun/meson.build
Changed
@@ -36,10 +36,10 @@ version : libogslib_version, c_args : '-DOGS_TUN_COMPILATION', include_directories : libtun_inc, libinc, - dependencies : libcore_dep, libipfw_dep, + dependencies : libipfw_dep, install : true) libtun_dep = declare_dependency( link_with : libtun, include_directories : libtun_inc, libinc, - dependencies : libcore_dep, libipfw_dep) + dependencies : libipfw_dep)
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/lib/tun/ogs-tun.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/lib/tun/ogs-tun.h
Changed
@@ -20,7 +20,7 @@ #ifndef OGS_TUN_H #define OGS_TUN_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" {
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/amf/amf-sm.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/amf/amf-sm.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -79,17 +79,17 @@ ogs_assert(s); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case AMF_EVT_SBI_SERVER: - sbi_request = e->sbi.request; + case OGS_EVENT_SBI_SERVER: + sbi_request = e->h.sbi.request; ogs_assert(sbi_request); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); rv = ogs_sbi_parse_request(&sbi_message, sbi_request); @@ -129,7 +129,7 @@ CASE(OGS_SBI_RESOURCE_NAME_NF_STATUS_NOTIFY) SWITCH(sbi_message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) - amf_nnrf_handle_nf_status_notify(stream, &sbi_message); + ogs_nnrf_handle_nf_status_notify(stream, &sbi_message); break; DEFAULT @@ -240,10 +240,10 @@ ogs_sbi_message_free(&sbi_message); break; - case AMF_EVT_SBI_CLIENT: + case OGS_EVENT_SBI_CLIENT: ogs_assert(e); - sbi_response = e->sbi.response; + sbi_response = e->h.sbi.response; ogs_assert(sbi_response); rv = ogs_sbi_parse_response(&sbi_message, sbi_response); if (rv != OGS_OK) { @@ -275,23 +275,23 @@ SWITCH(sbi_message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - nf_instance = e->sbi.data; + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); - e->sbi.message = &sbi_message; + e->h.sbi.message = &sbi_message; ogs_fsm_dispatch(&nf_instance->sm, e); break; CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS) - subscription = e->sbi.data; + subscription = e->h.sbi.data; ogs_assert(subscription); SWITCH(sbi_message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) if (sbi_message.res_status == OGS_SBI_HTTP_STATUS_CREATED || sbi_message.res_status == OGS_SBI_HTTP_STATUS_OK) { - amf_nnrf_handle_nf_status_subscribe( + ogs_nnrf_handle_nf_status_subscribe( subscription, &sbi_message); } else { ogs_error("%s HTTP response error %d", @@ -325,7 +325,7 @@ CASE(OGS_SBI_SERVICE_NAME_NNRF_DISC) SWITCH(sbi_message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); SWITCH(sbi_message.h.method) @@ -354,7 +354,7 @@ CASE(OGS_SBI_SERVICE_NAME_NUDM_UECM) CASE(OGS_SBI_SERVICE_NAME_NUDM_SDM) CASE(OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); sbi_xact = ogs_sbi_xact_cycle(sbi_xact); @@ -376,7 +376,7 @@ ogs_assert(OGS_FSM_STATE(&amf_ue->sm)); e->amf_ue = amf_ue; - e->sbi.message = &sbi_message;; + e->h.sbi.message = &sbi_message;; ogs_fsm_dispatch(&amf_ue->sm, e); } else { @@ -385,7 +385,7 @@ break; CASE(OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); sbi_xact = ogs_sbi_xact_cycle(sbi_xact); @@ -449,7 +449,7 @@ e->amf_ue = amf_ue; e->sess = sess; - e->sbi.message = &sbi_message;; + e->h.sbi.message = &sbi_message;; SWITCH(sbi_message.h.resource.component2) CASE(OGS_SBI_RESOURCE_NAME_MODIFY) @@ -502,7 +502,7 @@ break; CASE(OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); sbi_xact = ogs_sbi_xact_cycle(sbi_xact); @@ -535,7 +535,7 @@ e->amf_ue = amf_ue; e->sess = sess; - e->sbi.message = &sbi_message;; + e->h.sbi.message = &sbi_message;; amf_nnssf_nsselection_handle_get(sess, &sbi_message); break; @@ -549,27 +549,27 @@ ogs_sbi_response_free(sbi_response); break; - case AMF_EVT_SBI_TIMER: + case OGS_EVENT_SBI_TIMER: ogs_assert(e); - switch(e->timer_id) { - case AMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case AMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case AMF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case AMF_TIMER_NF_INSTANCE_VALIDITY: - nf_instance = e->sbi.data; + switch(e->h.timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + case OGS_TIMER_NF_INSTANCE_VALIDITY: + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); ogs_fsm_dispatch(&nf_instance->sm, e); - if (OGS_FSM_CHECK(&nf_instance->sm, amf_nf_state_exception)) + if (OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_exception)) ogs_error("%s:%s State machine exception %d", OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id, e->timer_id); + nf_instance->id, e->h.timer_id); break; - case AMF_TIMER_SUBSCRIPTION_VALIDITY: - subscription = e->sbi.data; + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + subscription = e->h.sbi.data; ogs_assert(subscription); ogs_assert(ogs_sbi_self()->nf_instance); @@ -583,8 +583,8 @@ ogs_sbi_subscription_remove(subscription); break; - case AMF_TIMER_SBI_CLIENT_WAIT: - sbi_xact = e->sbi.data; + case OGS_TIMER_SBI_CLIENT_WAIT: + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); sbi_object = sbi_xact->sbi_object; @@ -647,11 +647,11 @@ default: ogs_error("Unknown timer%s:%d", - amf_timer_get_name(e->timer_id), e->timer_id); + ogs_timer_get_name(e->h.timer_id), e->h.timer_id); } break; - case AMF_EVT_NGAP_LO_ACCEPT: + case AMF_EVENT_NGAP_LO_ACCEPT: sock = e->ngap.sock; ogs_assert(sock); addr = e->ngap.addr; @@ -674,7 +674,7 @@ break; - case AMF_EVT_NGAP_LO_SCTP_COMM_UP: + case AMF_EVENT_NGAP_LO_SCTP_COMM_UP: sock = e->ngap.sock; ogs_assert(sock); addr = e->ngap.addr; @@ -701,7 +701,7 @@ break; - case AMF_EVT_NGAP_LO_CONNREFUSED: + case AMF_EVENT_NGAP_LO_CONNREFUSED: sock = e->ngap.sock; ogs_assert(sock); addr = e->ngap.addr; @@ -720,7 +720,7 @@ ogs_free(addr); break; - case AMF_EVT_NGAP_MESSAGE: + case AMF_EVENT_NGAP_MESSAGE: sock = e->ngap.sock; ogs_assert(sock); addr = e->ngap.addr; @@ -751,11 +751,11 @@ ogs_pkbuf_free(pkbuf); break; - case AMF_EVT_NGAP_TIMER: + case AMF_EVENT_NGAP_TIMER: ran_ue = e->ran_ue; ogs_assert(ran_ue); - switch (e->timer_id) { + switch (e->h.timer_id) { case AMF_TIMER_NG_DELAYED_SEND: gnb = e->gnb; ogs_assert(gnb); @@ -774,12 +774,12 @@ break; default: ogs_error("Unknown timer%s:%d", - amf_timer_get_name(e->timer_id), e->timer_id); + amf_timer_get_name(e->h.timer_id), e->h.timer_id); break; } break; - case AMF_EVT_5GMM_MESSAGE: + case AMF_EVENT_5GMM_MESSAGE: ran_ue = e->ran_ue; ogs_assert(ran_ue); pkbuf = e->pkbuf; @@ -867,7 +867,7 @@ ogs_pkbuf_free(pkbuf); break; - case AMF_EVT_5GMM_TIMER: + case AMF_EVENT_5GMM_TIMER: amf_ue = e->amf_ue; ogs_assert(amf_ue); ogs_assert(OGS_FSM_STATE(&amf_ue->sm));
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/amf/amf-sm.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/amf/amf-sm.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -30,16 +30,6 @@ void amf_state_final(ogs_fsm_t *s, amf_event_t *e); void amf_state_operational(ogs_fsm_t *s, amf_event_t *e); -void amf_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance); -void amf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance); - -void amf_nf_state_initial(ogs_fsm_t *s, amf_event_t *e); -void amf_nf_state_final(ogs_fsm_t *s, amf_event_t *e); -void amf_nf_state_will_register(ogs_fsm_t *s, amf_event_t *e); -void amf_nf_state_registered(ogs_fsm_t *s, amf_event_t *e); -void amf_nf_state_de_registered(ogs_fsm_t *s, amf_event_t *e); -void amf_nf_state_exception(ogs_fsm_t *s, amf_event_t *e); - void ngap_state_initial(ogs_fsm_t *s, amf_event_t *e); void ngap_state_final(ogs_fsm_t *s, amf_event_t *e); void ngap_state_operational(ogs_fsm_t *s, amf_event_t *e);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/amf/context.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/amf/context.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -870,8 +870,7 @@ memset(&e, 0, sizeof(e)); e.gnb = gnb; - ogs_fsm_create(&gnb->sm, ngap_state_initial, ngap_state_final); - ogs_fsm_init(&gnb->sm, &e); + ogs_fsm_init(&gnb->sm, ngap_state_initial, ngap_state_final, &e); ogs_list_add(&self.gnb_list, gnb); amf_metrics_inst_global_inc(AMF_METR_GLOB_GAUGE_GNB); @@ -894,7 +893,6 @@ memset(&e, 0, sizeof(e)); e.gnb = gnb; ogs_fsm_fini(&gnb->sm, &e); - ogs_fsm_delete(&gnb->sm); ogs_hash_set(self.gnb_addr_hash, gnb->sctp.addr, sizeof(ogs_sockaddr_t), NULL); @@ -1311,8 +1309,7 @@ memset(&e, 0, sizeof(e)); e.amf_ue = amf_ue; - ogs_fsm_create(&amf_ue->sm, gmm_state_initial, gmm_state_final); - ogs_fsm_init(&amf_ue->sm, &e); + ogs_fsm_init(&amf_ue->sm, gmm_state_initial, gmm_state_final, &e); } void amf_ue_fsm_fini(amf_ue_t *amf_ue) @@ -1324,7 +1321,6 @@ memset(&e, 0, sizeof(e)); e.amf_ue = amf_ue; ogs_fsm_fini(&amf_ue->sm, &e); - ogs_fsm_delete(&amf_ue->sm); } amf_ue_t *amf_ue_find_by_guti(ogs_nas_5gs_guti_t *guti) @@ -1792,7 +1788,6 @@ ogs_sbi_nf_instance_t *nf_instance = NULL; amf_sess_t *sess = NULL; - ogs_assert(ogs_sbi_self()->nf_state_registered); ogs_assert(sbi_object); ogs_assert(target_nf_type);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/amf/context.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/amf/context.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -197,22 +197,6 @@ amf_ue_t *amf_ue; }; -#define AMF_NF_INSTANCE_CLEAR(_cAUSE, _nFInstance) \ - do { \ - ogs_assert(_nFInstance); \ - if ((_nFInstance)->reference_count == 1) { \ - ogs_info("%s (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ - amf_nf_fsm_fini((_nFInstance)); \ - ogs_sbi_nf_instance_remove(_nFInstance); \ - } else { \ - /* There is an assocation with other context */ \ - ogs_info("%s:%d (%s) NF suspended", \ - _nFInstance->id, _nFInstance->reference_count, (_cAUSE)); \ - OGS_FSM_TRAN(&_nFInstance->sm, amf_nf_state_de_registered); \ - ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ - } \ - } while(0) - struct amf_ue_s { ogs_sbi_object_t sbi; ogs_fsm_t sm;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/amf/event.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/amf/event.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,90 +20,66 @@ #include "event.h" #include "context.h" -static OGS_POOL(pool, amf_event_t); -static ogs_thread_mutex_t amf_event_alloc_mutex; - -void amf_event_init(void) -{ - ogs_pool_init(&pool, ogs_app()->pool.event); - ogs_thread_mutex_init(&amf_event_alloc_mutex); -} - -void amf_event_final(void) -{ - ogs_pool_final(&pool); - ogs_thread_mutex_destroy(&amf_event_alloc_mutex); -} - -amf_event_t *amf_event_new(amf_event_e id) +amf_event_t *amf_event_new(int id) { amf_event_t *e = NULL; - ogs_thread_mutex_lock(&amf_event_alloc_mutex); - ogs_pool_alloc(&pool, &e); - ogs_thread_mutex_unlock(&amf_event_alloc_mutex); + e = ogs_event_size(id, sizeof(amf_event_t)); ogs_assert(e); - memset(e, 0, sizeof(*e)); - e->id = id; + e->h.id = id; return e; } -void amf_event_free(amf_event_t *e) -{ - ogs_assert(e); - ogs_thread_mutex_lock(&amf_event_alloc_mutex); - ogs_pool_free(&pool, e); - ogs_thread_mutex_unlock(&amf_event_alloc_mutex); -} - const char *amf_event_get_name(amf_event_t *e) { - if (e == NULL) + if (e == NULL) { return OGS_FSM_NAME_INIT_SIG; + } - switch (e->id) { - case OGS_FSM_ENTRY_SIG: + switch (e->h.id) { + case OGS_FSM_ENTRY_SIG: return OGS_FSM_NAME_ENTRY_SIG; - case OGS_FSM_EXIT_SIG: + case OGS_FSM_EXIT_SIG: return OGS_FSM_NAME_EXIT_SIG; - case AMF_EVT_SBI_SERVER: - return "AMF_EVT_SBI_SERVER"; - case AMF_EVT_SBI_CLIENT: - return "AMF_EVT_SBI_CLIENT"; - case AMF_EVT_SBI_TIMER: - return "AMF_EVT_SBI_TIMER"; - - case AMF_EVT_NGAP_MESSAGE: - return "AMF_EVT_NGAP_MESSAGE"; - case AMF_EVT_NGAP_TIMER: - return "AMF_EVT_NGAP_TIMER"; - case AMF_EVT_NGAP_LO_ACCEPT: - return "AMF_EVT_NGAP_LO_ACCEPT"; - case AMF_EVT_NGAP_LO_SCTP_COMM_UP: - return "AMF_EVT_NGAP_LO_SCTP_COMM_UP"; - case AMF_EVT_NGAP_LO_CONNREFUSED: - return "AMF_EVT_NGAP_LO_CONNREFUSED"; - - case AMF_EVT_5GMM_MESSAGE: - return "AMF_EVT_5GMM_MESSAGE"; - case AMF_EVT_5GMM_TIMER: - return "AMF_EVT_5GMM_TIMER"; - case AMF_EVT_5GSM_MESSAGE: - return "AMF_EVT_5GSM_MESSAGE"; - case AMF_EVT_5GSM_TIMER: - return "AMF_EVT_5GSM_TIMER"; + case OGS_EVENT_SBI_SERVER: + return OGS_EVENT_NAME_SBI_SERVER; + case OGS_EVENT_SBI_CLIENT: + return OGS_EVENT_NAME_SBI_CLIENT; + case OGS_EVENT_SBI_TIMER: + return OGS_EVENT_NAME_SBI_TIMER; + + case AMF_EVENT_NGAP_MESSAGE: + return "AMF_EVENT_NGAP_MESSAGE"; + case AMF_EVENT_NGAP_TIMER: + return "AMF_EVENT_NGAP_TIMER"; + case AMF_EVENT_NGAP_LO_ACCEPT: + return "AMF_EVENT_NGAP_LO_ACCEPT"; + case AMF_EVENT_NGAP_LO_SCTP_COMM_UP: + return "AMF_EVENT_NGAP_LO_SCTP_COMM_UP"; + case AMF_EVENT_NGAP_LO_CONNREFUSED: + return "AMF_EVENT_NGAP_LO_CONNREFUSED"; + + case AMF_EVENT_5GMM_MESSAGE: + return "AMF_EVENT_5GMM_MESSAGE"; + case AMF_EVENT_5GMM_TIMER: + return "AMF_EVENT_5GMM_TIMER"; + case AMF_EVENT_5GSM_MESSAGE: + return "AMF_EVENT_5GSM_MESSAGE"; + case AMF_EVENT_5GSM_TIMER: + return "AMF_EVENT_5GSM_TIMER"; - default: - break; + default: + break; } + ogs_error("Unknown Event%d", e->h.id); return "UNKNOWN_EVENT"; } -void amf_sctp_event_push(amf_event_e id, +void amf_sctp_event_push(int id, void *sock, ogs_sockaddr_t *addr, ogs_pkbuf_t *pkbuf, uint16_t max_num_of_istreams, uint16_t max_num_of_ostreams) { @@ -130,7 +106,7 @@ ogs_free(e->ngap.addr); if (e->pkbuf) ogs_pkbuf_free(e->pkbuf); - amf_event_free(e); + ogs_event_free(e); } #if HAVE_USRSCTP else {
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/amf/event.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/amf/event.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,18 +20,12 @@ #ifndef AMF_EVENT_H #define AMF_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { #endif -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_nf_instance_s ogs_sbi_nf_instance_t; -typedef struct ogs_sbi_subscription_s ogs_sbi_subscription_t; - 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; @@ -43,39 +37,27 @@ typedef struct amf_bearer_s amf_bearer_t; typedef enum { - AMF_EVT_BASE = OGS_FSM_USER_SIG, + AMF_EVENT_BASE = OGS_MAX_NUM_OF_PROTO_EVENT, - AMF_EVT_SBI_SERVER, - AMF_EVT_SBI_CLIENT, - AMF_EVT_SBI_TIMER, - - AMF_EVT_NGAP_MESSAGE, - AMF_EVT_NGAP_TIMER, - AMF_EVT_NGAP_LO_ACCEPT, - AMF_EVT_NGAP_LO_SCTP_COMM_UP, - AMF_EVT_NGAP_LO_CONNREFUSED, - - AMF_EVT_5GMM_MESSAGE, - AMF_EVT_5GMM_TIMER, - AMF_EVT_5GSM_MESSAGE, - AMF_EVT_5GSM_TIMER, + AMF_EVENT_NGAP_MESSAGE, + AMF_EVENT_NGAP_TIMER, + AMF_EVENT_NGAP_LO_ACCEPT, + AMF_EVENT_NGAP_LO_SCTP_COMM_UP, + AMF_EVENT_NGAP_LO_CONNREFUSED, + + AMF_EVENT_5GMM_MESSAGE, + AMF_EVENT_5GMM_TIMER, + AMF_EVENT_5GSM_MESSAGE, + AMF_EVENT_5GSM_TIMER, - AMF_EVT_TOP, + MAX_NUM_OF_AMF_EVENT, } amf_event_e; typedef struct amf_event_s { - int id; - ogs_pkbuf_t *pkbuf; - int timer_id; - - struct { - ogs_sbi_request_t *request; - ogs_sbi_response_t *response; - void *data; + ogs_event_t h; - ogs_sbi_message_t *message; - } sbi; + ogs_pkbuf_t *pkbuf; struct { ogs_sock_t *sock; @@ -101,15 +83,11 @@ ogs_timer_t *timer; } amf_event_t; -void amf_event_init(void); -void amf_event_final(void); - -amf_event_t *amf_event_new(amf_event_e id); -void amf_event_free(amf_event_t *e); +amf_event_t *amf_event_new(int id); const char *amf_event_get_name(amf_event_t *e); -void amf_sctp_event_push(amf_event_e id, +void amf_sctp_event_push(int id, void *sock, ogs_sockaddr_t *addr, ogs_pkbuf_t *pkbuf, uint16_t max_num_of_istreams, uint16_t max_num_of_ostreams);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/amf/gmm-sm.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/amf/gmm-sm.c
Changed
@@ -62,7 +62,7 @@ amf_ue = e->amf_ue; ogs_assert(amf_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: AMF_UE_CLEAR_PAGING_INFO(amf_ue); AMF_UE_CLEAR_N2_TRANSFER(amf_ue, pdu_session_resource_setup_request); @@ -113,13 +113,13 @@ ogs_assert(amf_ue); } - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case AMF_EVT_5GMM_MESSAGE: + case AMF_EVENT_5GMM_MESSAGE: nas_message = e->nas.message; ogs_assert(nas_message); @@ -367,8 +367,8 @@ } break; - case AMF_EVT_5GMM_TIMER: - switch (e->timer_id) { + case AMF_EVENT_5GMM_TIMER: + switch (e->h.timer_id) { case AMF_TIMER_T3513: if (amf_ue->t3513.retry_count >= amf_timer_cfg(AMF_TIMER_T3513)->max_count) { @@ -457,14 +457,14 @@ default: ogs_error("Unknown timer%s:%d", - amf_timer_get_name(e->timer_id), e->timer_id); + amf_timer_get_name(e->h.timer_id), e->h.timer_id); } break; - case AMF_EVT_SBI_CLIENT: - sbi_response = e->sbi.response; + case OGS_EVENT_SBI_CLIENT: + sbi_response = e->h.sbi.response; ogs_assert(sbi_response); - sbi_message = e->sbi.message; + sbi_message = e->h.sbi.message; ogs_assert(sbi_message); SWITCH(sbi_message->h.service.name) @@ -536,12 +536,12 @@ ogs_assert(amf_ue); } - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case AMF_EVT_5GMM_MESSAGE: + case AMF_EVENT_5GMM_MESSAGE: nas_message = e->nas.message; ogs_assert(nas_message); @@ -651,8 +651,8 @@ break; } break; - case AMF_EVT_5GMM_TIMER: - switch (e->timer_id) { + case AMF_EVENT_5GMM_TIMER: + switch (e->h.timer_id) { case AMF_TIMER_T3560: if (amf_ue->t3560.retry_count >= amf_timer_cfg(AMF_TIMER_T3560)->max_count) { @@ -673,14 +673,14 @@ break; default: ogs_error("%s Unknown timer%s:%d", amf_ue->suci, - amf_timer_get_name(e->timer_id), e->timer_id); + amf_timer_get_name(e->h.timer_id), e->h.timer_id); break; } break; - case AMF_EVT_SBI_CLIENT: - sbi_response = e->sbi.response; + case OGS_EVENT_SBI_CLIENT: + sbi_response = e->h.sbi.response; ogs_assert(sbi_response); - sbi_message = e->sbi.message; + sbi_message = e->h.sbi.message; ogs_assert(sbi_message); SWITCH(sbi_message->h.service.name) @@ -772,7 +772,7 @@ amf_ue = e->amf_ue; ogs_assert(amf_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: CLEAR_AMF_UE_TIMER(amf_ue->t3560); ogs_assert(OGS_OK == @@ -780,7 +780,7 @@ break; case OGS_FSM_EXIT_SIG: break; - case AMF_EVT_5GMM_MESSAGE: + case AMF_EVENT_5GMM_MESSAGE: nas_message = e->nas.message; ogs_assert(nas_message); @@ -901,8 +901,8 @@ break; } break; - case AMF_EVT_5GMM_TIMER: - switch (e->timer_id) { + case AMF_EVENT_5GMM_TIMER: + switch (e->h.timer_id) { case AMF_TIMER_T3560: if (amf_ue->t3560.retry_count >= amf_timer_cfg(AMF_TIMER_T3560)->max_count) { @@ -923,7 +923,7 @@ break; default: ogs_error("Unknown timer%s:%d", - amf_timer_get_name(e->timer_id), e->timer_id); + amf_timer_get_name(e->h.timer_id), e->h.timer_id); break; } break; @@ -962,16 +962,16 @@ ogs_assert(amf_ue); } - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case AMF_EVT_SBI_CLIENT: - sbi_response = e->sbi.response; + case OGS_EVENT_SBI_CLIENT: + sbi_response = e->h.sbi.response; ogs_assert(sbi_response); - sbi_message = e->sbi.message; + sbi_message = e->h.sbi.message; ogs_assert(sbi_message); SWITCH(sbi_message->h.service.name) @@ -1105,7 +1105,7 @@ END break; - case AMF_EVT_5GMM_MESSAGE: + case AMF_EVENT_5GMM_MESSAGE: nas_message = e->nas.message; ogs_assert(nas_message); @@ -1228,8 +1228,8 @@ break; } break; - case AMF_EVT_5GMM_TIMER: - switch (e->timer_id) { + case AMF_EVENT_5GMM_TIMER: + switch (e->h.timer_id) { case AMF_TIMER_T3550: if (amf_ue->t3550.retry_count >= amf_timer_cfg(AMF_TIMER_T3550)->max_count) { @@ -1248,7 +1248,7 @@ break; default: ogs_error("%s Unknown timer%s:%d", amf_ue->suci, - amf_timer_get_name(e->timer_id), e->timer_id); + amf_timer_get_name(e->h.timer_id), e->h.timer_id); break; } break; @@ -1281,7 +1281,7 @@ ogs_assert(amf_ue); } - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: AMF_UE_CLEAR_PAGING_INFO(amf_ue); AMF_UE_CLEAR_N2_TRANSFER(amf_ue, pdu_session_resource_setup_request); @@ -1300,7 +1300,7 @@ case OGS_FSM_EXIT_SIG: break; - case AMF_EVT_5GMM_MESSAGE: + case AMF_EVENT_5GMM_MESSAGE: nas_message = e->nas.message; ogs_assert(nas_message);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/amf/init.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/amf/init.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -33,7 +33,6 @@ ogs_sbi_context_init(); amf_context_init(); - amf_event_init(); rv = ogs_sbi_context_parse_config("amf", "nrf", "scp"); if (rv != OGS_OK) return rv; @@ -76,7 +75,7 @@ /* Sending NF Instance De-registeration to NRF */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) - amf_nf_fsm_fini(nf_instance); + ogs_sbi_nf_fsm_fini(nf_instance); /* Starting holding timer */ t_termination_holding = ogs_timer_add(ogs_app()->timer_mgr, NULL, NULL); @@ -105,8 +104,6 @@ amf_context_final(); ogs_sbi_context_final(); ogs_metrics_context_final(); - - amf_event_final(); /* Destroy event */ } static void amf_main(void *data) @@ -114,8 +111,7 @@ ogs_fsm_t amf_sm; int rv; - ogs_fsm_create(&amf_sm, amf_state_initial, amf_state_final); - ogs_fsm_init(&amf_sm, 0); + ogs_fsm_init(&amf_sm, amf_state_initial, amf_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -148,11 +144,10 @@ ogs_assert(e); ogs_fsm_dispatch(&amf_sm, e); - amf_event_free(e); + ogs_event_free(e); } } done: ogs_fsm_fini(&amf_sm, 0); - ogs_fsm_delete(&amf_sm); }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/amf/meson.build -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/amf/meson.build
Changed
@@ -1,4 +1,4 @@ -# Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> +# Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> # This file is part of Open5GS. @@ -43,8 +43,6 @@ namf-handler.c sbi-path.c - nf-sm.c - ngap-sctp.c ngap-build.c ngap-handler.c
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/amf/ngap-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/amf/ngap-path.c
Changed
@@ -104,7 +104,7 @@ if (duration) { amf_event_t *e = NULL; - e = amf_event_new(AMF_EVT_NGAP_TIMER); + e = amf_event_new(AMF_EVENT_NGAP_TIMER); ogs_assert(e); e->timer = ogs_timer_add( ogs_app()->timer_mgr, amf_timer_ng_delayed_send, e); @@ -132,7 +132,7 @@ ogs_assert(amf_ue); ogs_assert(esmbuf); - e = amf_event_new(AMF_EVT_5GSM_MESSAGE); + e = amf_event_new(AMF_EVENT_5GSM_MESSAGE); ogs_assert(e); e->amf_ue = amf_ue; e->pkbuf = esmbuf; @@ -140,7 +140,7 @@ if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_pkbuf_free(e->pkbuf); - amf_event_free(e); + ogs_event_free(e); } return rv; @@ -212,7 +212,7 @@ if (h->extended_protocol_discriminator == OGS_NAS_EXTENDED_PROTOCOL_DISCRIMINATOR_5GMM) { int rv; - e = amf_event_new(AMF_EVT_5GMM_MESSAGE); + e = amf_event_new(AMF_EVENT_5GMM_MESSAGE); if (!e) { ogs_error("ngap_send_to_nas() failed"); ogs_pkbuf_free(nasbuf); @@ -226,7 +226,7 @@ if (rv != OGS_OK) { ogs_error("ngap_send_to_nas() failed:%d", (int)rv); ogs_pkbuf_free(e->pkbuf); - amf_event_free(e); + ogs_event_free(e); } return rv; } else if (h->extended_protocol_discriminator ==
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/amf/ngap-sctp.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/amf/ngap-sctp.c
Changed
@@ -113,7 +113,7 @@ ogs_info("gNB-N2 accepted%s:%d in ng-path module", OGS_ADDR(addr, buf), OGS_PORT(addr)); - ngap_event_push(AMF_EVT_NGAP_LO_ACCEPT, + ngap_event_push(AMF_EVENT_NGAP_LO_ACCEPT, new, addr, NULL, 0, 0); } else { ogs_log_message(OGS_LOG_ERROR, ogs_socket_errno, "accept() failed"); @@ -164,7 +164,7 @@ ogs_assert(addr); memcpy(addr, &from, sizeof(ogs_sockaddr_t)); - ngap_event_push(AMF_EVT_NGAP_LO_SCTP_COMM_UP, + ngap_event_push(AMF_EVENT_NGAP_LO_SCTP_COMM_UP, sock, addr, NULL, not->sn_assoc_change.sac_inbound_streams, not->sn_assoc_change.sac_outbound_streams); @@ -180,7 +180,7 @@ ogs_assert(addr); memcpy(addr, &from, sizeof(ogs_sockaddr_t)); - ngap_event_push(AMF_EVT_NGAP_LO_CONNREFUSED, + ngap_event_push(AMF_EVENT_NGAP_LO_CONNREFUSED, sock, addr, NULL, 0, 0); } break; @@ -193,7 +193,7 @@ ogs_assert(addr); memcpy(addr, &from, sizeof(ogs_sockaddr_t)); - ngap_event_push(AMF_EVT_NGAP_LO_CONNREFUSED, + ngap_event_push(AMF_EVENT_NGAP_LO_CONNREFUSED, sock, addr, NULL, 0, 0); break; @@ -235,7 +235,7 @@ ogs_assert(addr); memcpy(addr, &from, sizeof(ogs_sockaddr_t)); - ngap_event_push(AMF_EVT_NGAP_MESSAGE, sock, addr, pkbuf, 0, 0); + ngap_event_push(AMF_EVENT_NGAP_MESSAGE, sock, addr, pkbuf, 0, 0); return; } else { if (ogs_socket_errno != OGS_EAGAIN) {
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/amf/ngap-sm.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/amf/ngap-sm.c
Changed
@@ -55,12 +55,12 @@ gnb = e->gnb; ogs_assert(gnb); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case AMF_EVT_NGAP_MESSAGE: + case AMF_EVENT_NGAP_MESSAGE: pdu = e->ngap.message; ogs_assert(pdu); @@ -190,8 +190,8 @@ } break; - case AMF_EVT_NGAP_TIMER: - switch (e->timer_id) { + case AMF_EVENT_NGAP_TIMER: + switch (e->h.timer_id) { case AMF_TIMER_NG_DELAYED_SEND: ogs_assert(e->ran_ue); ogs_assert(e->pkbuf); @@ -201,7 +201,7 @@ break; default: ogs_error("Unknown timer%s:%d", - amf_timer_get_name(e->timer_id), e->timer_id); + amf_timer_get_name(e->h.timer_id), e->h.timer_id); break; } break; @@ -218,7 +218,7 @@ amf_sm_debug(e); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG:
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/amf/nnrf-build.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/amf/nnrf-build.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -19,41 +19,6 @@ #include "nnrf-build.h" -ogs_sbi_request_t *amf_nnrf_nfm_build_register(void) -{ - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_request_t *request = NULL; - - OpenAPI_nf_profile_t *NFProfile = NULL; - - nf_instance = ogs_sbi_self()->nf_instance; - ogs_assert(nf_instance); - ogs_assert(nf_instance->id); - - memset(&message, 0, sizeof(message)); - message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT; - message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM; - message.h.api.version = (char *)OGS_SBI_API_V1; - message.h.resource.component0 = - (char *)OGS_SBI_RESOURCE_NAME_NF_INSTANCES; - message.h.resource.component1 = nf_instance->id; - - message.http.content_encoding = (char*)ogs_sbi_self()->content_encoding; - - NFProfile = ogs_nnrf_nfm_build_nf_profile(); - ogs_expect_or_return_val(NFProfile, NULL); - - message.NFProfile = NFProfile; - - request = ogs_sbi_build_request(&message); - - ogs_sbi_nnrf_free_nf_profile(NFProfile); - - return request; -} - ogs_sbi_request_t *amf_nnrf_disc_build_discover( char *nrf_id, OpenAPI_nf_type_e target_nf_type, OpenAPI_nf_type_e requester_nf_type)
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/amf/nnrf-build.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/amf/nnrf-build.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -26,8 +26,6 @@ extern "C" { #endif -ogs_sbi_request_t *amf_nnrf_nfm_build_register(void); - ogs_sbi_request_t *amf_nnrf_disc_build_discover( char *nrf_id, OpenAPI_nf_type_e target_nf_type, OpenAPI_nf_type_e requester_nf_type);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/amf/nnrf-handler.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/amf/nnrf-handler.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -22,233 +22,6 @@ #include "ngap-path.h" #include "nnrf-handler.h" -void amf_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_nf_profile_t *NFProfile = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(nf_instance); - client = nf_instance->client; - ogs_assert(client); - - NFProfile = recvmsg->NFProfile; - if (!NFProfile) { - ogs_error("No NFProfile"); - return; - } - - /* TIME : Update heartbeat from NRF */ - if (NFProfile->is_heart_beat_timer == true) - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; -} - -void amf_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_subscription_data_t *SubscriptionData = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(subscription); - client = subscription->client; - ogs_assert(client); - - SubscriptionData = recvmsg->SubscriptionData; - if (!SubscriptionData) { - ogs_error("No SubscriptionData"); - return; - } - - if (!SubscriptionData->subscription_id) { - ogs_error("No SubscriptionId"); - return; - } - ogs_sbi_subscription_set_id( - subscription, SubscriptionData->subscription_id); - - if (SubscriptionData->validity_time) { -#define VALIDITY_MINIMUM (10LL * OGS_USEC_PER_SEC) /* 10 seconds */ - ogs_time_t time, duration; - if (ogs_sbi_time_from_string( - &time, SubscriptionData->validity_time) == true) { - duration = time - ogs_time_now(); - if (duration < VALIDITY_MINIMUM) { - duration = VALIDITY_MINIMUM; - ogs_warn("%s Forced to %lld seconds", subscription->id, - (long long)ogs_time_sec(VALIDITY_MINIMUM)); - } - subscription->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - amf_timer_subscription_validity, subscription); - ogs_assert(subscription->t_validity); - ogs_timer_start(subscription->t_validity, duration); - } else { - ogs_error("Cannot parse validitiyTime %s", - SubscriptionData->validity_time); - } - } -} - -bool amf_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) -{ - int rv; - bool handled; - - ogs_sbi_response_t *response = NULL; - OpenAPI_notification_data_t *NotificationData = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_header_t header; - - ogs_assert(stream); - ogs_assert(recvmsg); - - NotificationData = recvmsg->NotificationData; - if (!NotificationData) { - ogs_error("No NotificationData"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NotificationData", NULL)); - return false; - } - - if (!NotificationData->nf_instance_uri) { - ogs_error("No nfInstanceUri"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No nfInstanceUri", NULL)); - return false; - } - - memset(&header, 0, sizeof(header)); - header.uri = NotificationData->nf_instance_uri; - - rv = ogs_sbi_parse_header(&message, &header); - if (rv != OGS_OK) { - ogs_error("Cannot parse nfInstanceUri %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - return false; - } - - if (!message.h.resource.component1) { - ogs_error("No nfInstanceId %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - ogs_sbi_header_free(&header); - return false; - } - - if (NF_INSTANCE_IS_SELF(message.h.resource.component1)) { - ogs_warn("%s The notification is not allowed", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_FORBIDDEN, - recvmsg, "The notification is not allowed", - message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - - if (NotificationData->event == - OpenAPI_notification_event_type_NF_REGISTERED) { - - OpenAPI_nf_profile_t *NFProfile = NULL; - - NFProfile = NotificationData->nf_profile; - if (!NFProfile) { - ogs_error("No NFProfile"); - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NFProfile", NULL)); - ogs_sbi_header_free(&header); - return false; - } - - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, - message.h.resource.component1); - - amf_nf_fsm_init(nf_instance); - - ogs_info("%s (NRF-notify) NF registered", nf_instance->id); - - } else { - OGS_FSM_TRAN(&nf_instance->sm, amf_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NRF-notify) NF has already been added", - message.h.resource.component1); - - } - - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, stream, recvmsg); - if (!handled) { - AMF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - ogs_info("%s (NRF-notify) NF Profile updated", nf_instance->id); - - handled = ogs_sbi_client_associate(nf_instance); - if (!handled) { - ogs_error("%s Cannot associate NF EndPoint", nf_instance->id); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot find NF EndPoint", nf_instance->id)); - AMF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - } else if (NotificationData->event == - OpenAPI_notification_event_type_NF_DEREGISTERED) { - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (nf_instance) { - AMF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - } else { - ogs_warn("%s (NRF-notify) Not found", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_NOT_FOUND, - recvmsg, "Not found", message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - } else { - char *eventstr = OpenAPI_notification_event_type_ToString( - NotificationData->event); - ogs_error("Not supported event %d:%s", - NotificationData->event, eventstr ? eventstr : "Unknown"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Not supported event", - eventstr ? eventstr : "Unknown")); - ogs_sbi_header_free(&header); - return false; - } - - response = ogs_sbi_build_response(recvmsg, OGS_SBI_HTTP_STATUS_NO_CONTENT); - ogs_assert(response); - ogs_assert(true == ogs_sbi_server_send_response(stream, response)); - - ogs_sbi_header_free(&header); - return true; -} - void amf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { @@ -273,84 +46,10 @@ return; } - amf_nnrf_handle_nf_discover_search_result( + ogs_nnrf_handle_nf_discover_search_result( sbi_object, target_nf_type, discovery_option, SearchResult); amf_sbi_select_nf(sbi_object, target_nf_type, discovery_option); ogs_expect(true == amf_sbi_send_request(sbi_object, target_nf_type, xact)); } - -void amf_nnrf_handle_nf_discover_search_result( - ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, - ogs_sbi_discovery_option_t *discovery_option, - OpenAPI_search_result_t *SearchResult) -{ - bool handled; - - OpenAPI_lnode_t *node = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_assert(sbi_object); - ogs_assert(SearchResult); - - OpenAPI_list_for_each(SearchResult->nf_instances, node) { - OpenAPI_nf_profile_t *NFProfile = NULL; - - if (!node->data) continue; - - NFProfile = node->data; - - nf_instance = ogs_sbi_nf_instance_find(NFProfile->nf_instance_id); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id); - - amf_nf_fsm_init(nf_instance); - - ogs_info("%s (NF-discover) NF registered", nf_instance->id); - } else { - OGS_FSM_TRAN(&nf_instance->sm, amf_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NF-discover) NF has already been added", - NFProfile->nf_instance_id); - } - - if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) { - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, NULL, NULL); - if (!handled) { - ogs_error("ogs_sbi_nnrf_handle_nf_profile() failed %s", - nf_instance->id); - AMF_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); - continue; - } - - handled = ogs_sbi_client_associate(nf_instance); - if (!handled) { - ogs_error("%s Cannot assciate NF EndPoint", nf_instance->id); - AMF_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); - continue; - } - - /* TIME : Update validity from NRF */ - if (SearchResult->is_validity_period && - SearchResult->validity_period) { - nf_instance->time.validity_duration = - SearchResult->validity_period; - - ogs_assert(nf_instance->t_validity); - ogs_timer_start(nf_instance->t_validity, - ogs_time_from_sec(nf_instance->time.validity_duration)); - - } else - ogs_warn("%s NF Instance validity-time should not 0", - nf_instance->id); - - ogs_info("%s (NF-discover) NF Profile updated", nf_instance->id); - } - } -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/amf/nnrf-handler.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/amf/nnrf-handler.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -26,21 +26,8 @@ extern "C" { #endif -void amf_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg); -void amf_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg); - -bool amf_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); - void amf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg); -void amf_nnrf_handle_nf_discover_search_result( - ogs_sbi_object_t *sbi_object, - OpenAPI_nf_type_e target_nf_type, - ogs_sbi_discovery_option_t *discovery_option, - OpenAPI_search_result_t *SearchResult); #ifdef __cplusplus }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/amf/nsmf-handler.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/amf/nsmf-handler.c
Changed
@@ -174,6 +174,8 @@ amf_sess_t *sess, int state, ogs_sbi_message_t *recvmsg) { amf_ue_t *amf_ue = NULL; + ran_ue_t *ran_ue = NULL; + ogs_assert(sess); amf_ue = sess->amf_ue; ogs_assert(amf_ue); @@ -356,7 +358,7 @@ if (!n2smbuf) { ogs_error("%s:%d No N2 SM Content", amf_ue->supi, sess->psi); - ogs_assert(OGS_OK == + ogs_expect(OGS_OK == ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); @@ -380,7 +382,7 @@ if (!n2smbuf) { ogs_error("%s:%d No N2 SM Content", amf_ue->supi, sess->psi); - ogs_assert(OGS_OK == + ogs_expect(OGS_OK == ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); @@ -402,7 +404,7 @@ default: ogs_error("Not implemented %d", SmContextUpdatedData->n2_sm_info_type); - ogs_assert(OGS_OK == + ogs_expect(OGS_OK == ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); @@ -605,7 +607,7 @@ } else if (state == AMF_REMOVE_S1_CONTEXT_BY_LO_CONNREFUSED) { if (AMF_SESSION_SYNC_DONE(amf_ue, state)) { - ran_ue_t *ran_ue = ran_ue_cycle(amf_ue->ran_ue); + ran_ue = ran_ue_cycle(amf_ue->ran_ue); amf_ue_deassociate(amf_ue); @@ -644,7 +646,7 @@ } else if (state == AMF_REMOVE_S1_CONTEXT_BY_RESET_PARTIAL) { if (AMF_SESSION_SYNC_DONE(amf_ue, state)) { ran_ue_t *iter = NULL; - ran_ue_t *ran_ue = ran_ue_cycle(amf_ue->ran_ue); + ran_ue = ran_ue_cycle(amf_ue->ran_ue); amf_ue_deassociate(amf_ue); @@ -701,8 +703,6 @@ } } } else { - amf_ue_t *amf_ue = NULL; - OpenAPI_sm_context_update_error_t *SmContextUpdateError = NULL; OpenAPI_ref_to_binary_data_t *n1SmMsg = NULL; ogs_pkbuf_t *n1smbuf = NULL; @@ -719,7 +719,7 @@ if (!SmContextUpdateError) { ogs_error("%d:%d No SmContextUpdateError %d", sess->psi, sess->pti, recvmsg->res_status); - ogs_assert(OGS_OK == + ogs_expect(OGS_OK == ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); @@ -728,7 +728,7 @@ if (!SmContextUpdateError->error) { ogs_error("%d:%d No Error %d", sess->psi, sess->pti, recvmsg->res_status); - ogs_assert(OGS_OK == + ogs_expect(OGS_OK == ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); @@ -761,7 +761,7 @@ n2SmInfo = SmContextUpdateError->n2_sm_info; if (!n2SmInfo || !n2SmInfo->content_id) { ogs_error("%d:%d No N2 SM Message", sess->psi, sess->pti); - ogs_assert(OGS_OK == + ogs_expect(OGS_OK == ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); @@ -773,7 +773,7 @@ if (!n2smbuf) { ogs_error("%d:%d No N2 SM Content %s", sess->psi, sess->pti, n2SmInfo->content_id); - ogs_assert(OGS_OK == + ogs_expect(OGS_OK == ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error)); @@ -783,7 +783,7 @@ ogs_error("%d:%d Error Indication", sess->psi, sess->pti); - ogs_assert(OGS_OK == + ogs_expect(OGS_OK == ngap_send_error_indication2(amf_ue, NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error));
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/amf/sbi-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/amf/sbi-path.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -30,17 +30,17 @@ ogs_assert(request); ogs_assert(data); - e = amf_event_new(AMF_EVT_SBI_SERVER); + e = amf_event_new(OGS_EVENT_SBI_SERVER); ogs_assert(e); - e->sbi.request = request; - e->sbi.data = data; + e->h.sbi.request = request; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_request_free(request); - amf_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -61,16 +61,16 @@ ogs_assert(response); - e = amf_event_new(AMF_EVT_SBI_CLIENT); + e = amf_event_new(OGS_EVENT_SBI_CLIENT); ogs_assert(e); - e->sbi.response = response; - e->sbi.data = data; + e->h.sbi.response = response; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_response_free(response); - amf_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -82,6 +82,14 @@ ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_nf_service_t *service = NULL; + /* To be notified when NF Instances registered/deregistered in NRF + * or when their profile is modified */ + ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_AUSF); + ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_UDM); + ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_PCF); + ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_SMF); + ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_NSSF); + /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); @@ -123,16 +131,9 @@ /* NFRegister is sent and the response is received * by the above client callback. */ - amf_nf_fsm_init(nf_instance); + ogs_sbi_nf_fsm_init(nf_instance); } - /* Timer expiration handler of client wait timer */ - ogs_sbi_self()->client_wait_expire = amf_timer_sbi_client_wait_expire; - - /* NF register state in NF state machine */ - ogs_sbi_self()->nf_state_registered = - (ogs_fsm_handler_t)amf_nf_state_registered; - if (ogs_sbi_server_start_all(server_cb) != OGS_OK) return OGS_ERROR; @@ -332,7 +333,7 @@ goto cleanup; } - amf_nnrf_handle_nf_discover_search_result( + ogs_nnrf_handle_nf_discover_search_result( &sess->sbi, OpenAPI_nf_type_SMF, NULL, message.SearchResult); amf_sbi_select_nf(&sess->sbi, OpenAPI_nf_type_SMF, NULL);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/amf/sbi-path.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/amf/sbi-path.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. *
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/amf/timer.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/amf/timer.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,36 +20,33 @@ #include "context.h" static amf_timer_cfg_t g_amf_timer_cfgMAX_NUM_OF_AMF_TIMER = { - AMF_TIMER_SBI_CLIENT_WAIT = - { .duration = ogs_time_from_msec(500) }, - /* Paging procedure for EPS services initiated */ AMF_TIMER_T3513 = - { .max_count = 2, .duration = ogs_time_from_sec(2) }, + { .have = true, .max_count = 2, .duration = ogs_time_from_sec(2) }, /* DEREGISTRATION REQUEST sent */ AMF_TIMER_T3522 = - { .max_count = 4, .duration = ogs_time_from_sec(3) }, + { .have = true, .max_count = 4, .duration = ogs_time_from_sec(3) }, /* REGISTRATION ACCEPT sent */ AMF_TIMER_T3550 = - { .max_count = 4, .duration = ogs_time_from_sec(6) }, + { .have = true, .max_count = 4, .duration = ogs_time_from_sec(6) }, /* CONFIGURATION UPDATE COMMAND sent */ AMF_TIMER_T3555 = - { .max_count = 4, .duration = ogs_time_from_sec(6) }, + { .have = true, .max_count = 4, .duration = ogs_time_from_sec(6) }, /* AUTHENTICATION REQUEST sent * SECURITY MODE COMMAND sent */ AMF_TIMER_T3560 = - { .max_count = 4, .duration = ogs_time_from_sec(6) }, + { .have = true, .max_count = 4, .duration = ogs_time_from_sec(6) }, /* IDENTITY REQUEST sent */ AMF_TIMER_T3570 = - { .max_count = 4, .duration = ogs_time_from_sec(3) }, + { .have = true, .max_count = 4, .duration = ogs_time_from_sec(3) }, AMF_TIMER_NG_HOLDING = - { .duration = ogs_time_from_sec(30) }, + { .have = true, .duration = ogs_time_from_sec(30) }, }; static void gmm_timer_event_send( @@ -58,24 +55,28 @@ amf_timer_cfg_t *amf_timer_cfg(amf_timer_e id) { ogs_assert(id < MAX_NUM_OF_AMF_TIMER); + if (g_amf_timer_cfgid.have != true) { + ogs_fatal("No timer%d configuration", id); + ogs_assert_if_reached(); + } return &g_amf_timer_cfgid; } -const char *amf_timer_get_name(amf_timer_e id) +const char *amf_timer_get_name(int timer_id) { - switch (id) { - case AMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - return "AMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL"; - case AMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - return "AMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL"; - case AMF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - return "AMF_TIMER_NF_INSTANCE_NO_HEARTBEAT"; - case AMF_TIMER_NF_INSTANCE_VALIDITY: - return "AMF_TIMER_NF_INSTANCE_VALIDITY"; - case AMF_TIMER_SUBSCRIPTION_VALIDITY: - return "AMF_TIMER_SUBSCRIPTION_VALIDITY"; - case AMF_TIMER_SBI_CLIENT_WAIT: - return "AMF_TIMER_SBI_CLIENT_WAIT"; + switch (timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + return OGS_TIMER_NAME_NF_INSTANCE_REGISTRATION_INTERVAL; + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + return OGS_TIMER_NAME_NF_INSTANCE_HEARTBEAT_INTERVAL; + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + return OGS_TIMER_NAME_NF_INSTANCE_NO_HEARTBEAT; + case OGS_TIMER_NF_INSTANCE_VALIDITY: + return OGS_TIMER_NAME_NF_INSTANCE_VALIDITY; + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + return OGS_TIMER_NAME_SUBSCRIPTION_VALIDITY; + case OGS_TIMER_SBI_CLIENT_WAIT: + return OGS_TIMER_NAME_SBI_CLIENT_WAIT; case AMF_TIMER_NG_DELAYED_SEND: return "AMF_TIMER_NG_DELAYED_SEND"; case AMF_TIMER_T3513: @@ -93,9 +94,10 @@ case AMF_TIMER_NG_HOLDING: return "AMF_TIMER_NG_HOLDING"; default: - break; + break; } + ogs_error("Unknown Timer%d", timer_id); return "UNKNOWN_TIMER"; } @@ -105,90 +107,16 @@ amf_event_t *e = data; ogs_assert(e); - e->timer_id = AMF_TIMER_NG_DELAYED_SEND; + e->h.timer_id = AMF_TIMER_NG_DELAYED_SEND; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_timer_delete(e->timer); - amf_event_free(e); + ogs_event_free(e); } } -static void sbi_timer_send_event(int timer_id, void *data) -{ - int rv; - amf_event_t *e = NULL; - ogs_assert(data); - - switch (timer_id) { - case AMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case AMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case AMF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case AMF_TIMER_NF_INSTANCE_VALIDITY: - case AMF_TIMER_SUBSCRIPTION_VALIDITY: - e = amf_event_new(AMF_EVT_SBI_TIMER); - ogs_assert(e); - e->timer_id = timer_id; - e->sbi.data = data; - break; - case AMF_TIMER_SBI_CLIENT_WAIT: - e = amf_event_new(AMF_EVT_SBI_TIMER); - if (!e) { - ogs_sbi_xact_t *sbi_xact = data; - ogs_assert(sbi_xact); - - ogs_error("sbi_timer_send_event() failed"); - ogs_sbi_xact_remove(sbi_xact); - return; - } - e->timer_id = timer_id; - e->sbi.data = data; - break; - default: - ogs_fatal("Unknown timer id%d", timer_id); - ogs_assert_if_reached(); - break; - } - - rv = ogs_queue_push(ogs_app()->queue, e); - if (rv != OGS_OK) { - ogs_error("ogs_queue_push() failed %d in %s", - (int)rv, amf_timer_get_name(e->timer_id)); - amf_event_free(e); - } -} - -void amf_timer_nf_instance_registration_interval(void *data) -{ - sbi_timer_send_event(AMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, data); -} - -void amf_timer_nf_instance_heartbeat_interval(void *data) -{ - sbi_timer_send_event(AMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, data); -} - -void amf_timer_nf_instance_no_heartbeat(void *data) -{ - sbi_timer_send_event(AMF_TIMER_NF_INSTANCE_NO_HEARTBEAT, data); -} - -void amf_timer_nf_instance_validity(void *data) -{ - sbi_timer_send_event(AMF_TIMER_NF_INSTANCE_VALIDITY, data); -} - -void amf_timer_subscription_validity(void *data) -{ - sbi_timer_send_event(AMF_TIMER_SUBSCRIPTION_VALIDITY, data); -} - -void amf_timer_sbi_client_wait_expire(void *data) -{ - sbi_timer_send_event(AMF_TIMER_SBI_CLIENT_WAIT, data); -} - static void gmm_timer_event_send( amf_timer_e timer_id, amf_ue_t *amf_ue) { @@ -196,15 +124,16 @@ amf_event_t *e = NULL; ogs_assert(amf_ue); - e = amf_event_new(AMF_EVT_5GMM_TIMER); + e = amf_event_new(AMF_EVENT_5GMM_TIMER); ogs_assert(e); - e->timer_id = timer_id; + e->h.timer_id = timer_id; e->amf_ue = amf_ue; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { - ogs_error("ogs_queue_push() failed:%d", (int)rv); - amf_event_free(e); + ogs_error("ogs_queue_push() failed:%d in %s", + (int)rv, amf_timer_get_name(timer_id)); + ogs_event_free(e); } } @@ -242,15 +171,15 @@ ogs_assert(data); ran_ue = data; - e = amf_event_new(AMF_EVT_NGAP_TIMER); + e = amf_event_new(AMF_EVENT_NGAP_TIMER); ogs_assert(e); - e->timer_id = AMF_TIMER_NG_HOLDING; + e->h.timer_id = AMF_TIMER_NG_HOLDING; e->ran_ue = ran_ue; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); - amf_event_free(e); + ogs_event_free(e); } }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/amf/timer.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/amf/timer.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,7 +20,7 @@ #ifndef AMF_TIMER_H #define AMF_TIMER_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { @@ -28,14 +28,7 @@ /* forward declaration */ typedef enum { - AMF_TIMER_BASE = 0, - - AMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, - AMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, - AMF_TIMER_NF_INSTANCE_NO_HEARTBEAT, - AMF_TIMER_NF_INSTANCE_VALIDITY, - AMF_TIMER_SUBSCRIPTION_VALIDITY, - AMF_TIMER_SBI_CLIENT_WAIT, + AMF_TIMER_BASE = OGS_MAX_NUM_OF_PROTO_TIMER, AMF_TIMER_NG_DELAYED_SEND, AMF_TIMER_NG_HOLDING, @@ -52,20 +45,14 @@ } amf_timer_e; typedef struct amf_timer_cfg_s { + bool have; int max_count; ogs_time_t duration; } amf_timer_cfg_t; amf_timer_cfg_t *amf_timer_cfg(amf_timer_e id); -const char *amf_timer_get_name(amf_timer_e id); - -void amf_timer_nf_instance_registration_interval(void *data); -void amf_timer_nf_instance_heartbeat_interval(void *data); -void amf_timer_nf_instance_no_heartbeat(void *data); -void amf_timer_nf_instance_validity(void *data); -void amf_timer_subscription_validity(void *data); -void amf_timer_sbi_client_wait_expire(void *data); +const char *amf_timer_get_name(int timer_id); void amf_timer_ng_delayed_send(void *data);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/ausf/ausf-sm.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/ausf/ausf-sm.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -53,17 +53,17 @@ ogs_assert(s); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case AUSF_EVT_SBI_SERVER: - request = e->sbi.request; + case OGS_EVENT_SBI_SERVER: + request = e->h.sbi.request; ogs_assert(request); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); rv = ogs_sbi_parse_request(&message, request); @@ -94,7 +94,7 @@ CASE(OGS_SBI_RESOURCE_NAME_NF_STATUS_NOTIFY) SWITCH(message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) - ausf_nnrf_handle_nf_status_notify(stream, &message); + ogs_nnrf_handle_nf_status_notify(stream, &message); break; DEFAULT @@ -154,7 +154,7 @@ ogs_assert(OGS_FSM_STATE(&ausf_ue->sm)); e->ausf_ue = ausf_ue; - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&ausf_ue->sm, e); if (OGS_FSM_CHECK(&ausf_ue->sm, ausf_ue_state_exception)) { ogs_error("%s State machine exception", ausf_ue->suci); @@ -174,10 +174,10 @@ ogs_sbi_message_free(&message); break; - case AUSF_EVT_SBI_CLIENT: + case OGS_EVENT_SBI_CLIENT: ogs_assert(e); - response = e->sbi.response; + response = e->h.sbi.response; ogs_assert(response); rv = ogs_sbi_parse_response(&message, response); if (rv != OGS_OK) { @@ -199,23 +199,23 @@ SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - nf_instance = e->sbi.data; + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&nf_instance->sm, e); break; CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS) - subscription = e->sbi.data; + subscription = e->h.sbi.data; ogs_assert(subscription); SWITCH(message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) if (message.res_status == OGS_SBI_HTTP_STATUS_CREATED || message.res_status == OGS_SBI_HTTP_STATUS_OK) { - ausf_nnrf_handle_nf_status_subscribe( + ogs_nnrf_handle_nf_status_subscribe( subscription, &message); } else { ogs_error("%s HTTP response error %d", @@ -250,7 +250,7 @@ CASE(OGS_SBI_SERVICE_NAME_NNRF_DISC) SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); SWITCH(message.h.method) @@ -276,7 +276,7 @@ break; CASE(OGS_SBI_SERVICE_NAME_NUDM_UEAU) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); sbi_xact = ogs_sbi_xact_cycle(sbi_xact); @@ -290,7 +290,7 @@ ausf_ue = (ausf_ue_t *)sbi_xact->sbi_object; ogs_assert(ausf_ue); - e->sbi.data = sbi_xact->assoc_stream; + e->h.sbi.data = sbi_xact->assoc_stream; ogs_sbi_xact_remove(sbi_xact); @@ -301,7 +301,7 @@ } e->ausf_ue = ausf_ue; - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&ausf_ue->sm, e); if (OGS_FSM_CHECK(&ausf_ue->sm, ausf_ue_state_exception)) { @@ -319,27 +319,27 @@ ogs_sbi_response_free(response); break; - case AUSF_EVT_SBI_TIMER: + case OGS_EVENT_SBI_TIMER: ogs_assert(e); - switch(e->timer_id) { - case AUSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case AUSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case AUSF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case AUSF_TIMER_NF_INSTANCE_VALIDITY: - nf_instance = e->sbi.data; + switch(e->h.timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + case OGS_TIMER_NF_INSTANCE_VALIDITY: + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); ogs_fsm_dispatch(&nf_instance->sm, e); - if (OGS_FSM_CHECK(&nf_instance->sm, ausf_nf_state_exception)) + if (OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_exception)) ogs_error("%s:%s State machine exception %d", OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id, e->timer_id); + nf_instance->id, e->h.timer_id); break; - case AUSF_TIMER_SUBSCRIPTION_VALIDITY: - subscription = e->sbi.data; + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + subscription = e->h.sbi.data; ogs_assert(subscription); ogs_assert(ogs_sbi_self()->nf_instance); @@ -353,8 +353,8 @@ ogs_sbi_subscription_remove(subscription); break; - case AUSF_TIMER_SBI_CLIENT_WAIT: - sbi_xact = e->sbi.data; + case OGS_TIMER_SBI_CLIENT_WAIT: + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); stream = sbi_xact->assoc_stream; @@ -370,7 +370,7 @@ break; default: ogs_error("Unknown timer%s:%d", - ausf_timer_get_name(e->timer_id), e->timer_id); + ogs_timer_get_name(e->h.timer_id), e->h.timer_id); } break;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/ausf/ausf-sm.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/ausf/ausf-sm.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -30,16 +30,6 @@ void ausf_state_final(ogs_fsm_t *s, ausf_event_t *e); void ausf_state_operational(ogs_fsm_t *s, ausf_event_t *e); -void ausf_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance); -void ausf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance); - -void ausf_nf_state_initial(ogs_fsm_t *s, ausf_event_t *e); -void ausf_nf_state_final(ogs_fsm_t *s, ausf_event_t *e); -void ausf_nf_state_will_register(ogs_fsm_t *s, ausf_event_t *e); -void ausf_nf_state_registered(ogs_fsm_t *s, ausf_event_t *e); -void ausf_nf_state_de_registered(ogs_fsm_t *s, ausf_event_t *e); -void ausf_nf_state_exception(ogs_fsm_t *s, ausf_event_t *e); - void ausf_ue_state_initial(ogs_fsm_t *s, ausf_event_t *e); void ausf_ue_state_final(ogs_fsm_t *s, ausf_event_t *e); void ausf_ue_state_operational(ogs_fsm_t *s, ausf_event_t *e);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/ausf/context.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/ausf/context.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -141,8 +141,7 @@ memset(&e, 0, sizeof(e)); e.ausf_ue = ausf_ue; - ogs_fsm_create(&ausf_ue->sm, ausf_ue_state_initial, ausf_ue_state_final); - ogs_fsm_init(&ausf_ue->sm, &e); + ogs_fsm_init(&ausf_ue->sm, ausf_ue_state_initial, ausf_ue_state_final, &e); ogs_list_add(&self.ausf_ue_list, ausf_ue); @@ -160,7 +159,6 @@ memset(&e, 0, sizeof(e)); e.ausf_ue = ausf_ue; ogs_fsm_fini(&ausf_ue->sm, &e); - ogs_fsm_delete(&ausf_ue->sm); /* Free SBI object memory */ ogs_sbi_object_free(&ausf_ue->sbi);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/ausf/context.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/ausf/context.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -25,7 +25,6 @@ #include "ogs-sbi.h" #include "ausf-sm.h" -#include "timer.h" #ifdef __cplusplus extern "C" { @@ -63,22 +62,6 @@ uint8_t hxres_starOGS_MAX_RES_LEN; uint8_t kausfOGS_SHA256_DIGEST_SIZE; uint8_t kseafOGS_SHA256_DIGEST_SIZE; - -#define AUSF_NF_INSTANCE_CLEAR(_cAUSE, _nFInstance) \ - do { \ - ogs_assert(_nFInstance); \ - if ((_nFInstance)->reference_count == 1) { \ - ogs_info("%s (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ - ausf_nf_fsm_fini((_nFInstance)); \ - ogs_sbi_nf_instance_remove(_nFInstance); \ - } else { \ - /* There is an assocation with other context */ \ - ogs_info("%s:%d (%s) NF suspended", \ - _nFInstance->id, _nFInstance->reference_count, (_cAUSE)); \ - OGS_FSM_TRAN(&_nFInstance->sm, ausf_nf_state_de_registered); \ - ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ - } \ - } while(0) }; void ausf_context_init(void);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/ausf/event.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/ausf/event.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -18,60 +18,42 @@ */ #include "event.h" -#include "context.h" -static OGS_POOL(pool, ausf_event_t); - -void ausf_event_init(void) -{ - ogs_pool_init(&pool, ogs_app()->pool.event); -} - -void ausf_event_final(void) -{ - ogs_pool_final(&pool); -} - -ausf_event_t *ausf_event_new(ausf_event_e id) +ausf_event_t *ausf_event_new(int id) { ausf_event_t *e = NULL; - ogs_pool_alloc(&pool, &e); + e = ogs_event_size(id, sizeof(ausf_event_t)); ogs_assert(e); - memset(e, 0, sizeof(*e)); - e->id = id; + e->h.id = id; return e; } -void ausf_event_free(ausf_event_t *e) -{ - ogs_assert(e); - ogs_pool_free(&pool, e); -} - const char *ausf_event_get_name(ausf_event_t *e) { - if (e == NULL) + if (e == NULL) { return OGS_FSM_NAME_INIT_SIG; + } - switch (e->id) { - case OGS_FSM_ENTRY_SIG: + switch (e->h.id) { + case OGS_FSM_ENTRY_SIG: return OGS_FSM_NAME_ENTRY_SIG; - case OGS_FSM_EXIT_SIG: + case OGS_FSM_EXIT_SIG: return OGS_FSM_NAME_EXIT_SIG; - case AUSF_EVT_SBI_SERVER: - return "AUSF_EVT_SBI_SERVER"; - case AUSF_EVT_SBI_CLIENT: - return "AUSF_EVT_SBI_CLIENT"; - case AUSF_EVT_SBI_TIMER: - return "AUSF_EVT_SBI_TIMER"; + case OGS_EVENT_SBI_SERVER: + return OGS_EVENT_NAME_SBI_SERVER; + case OGS_EVENT_SBI_CLIENT: + return OGS_EVENT_NAME_SBI_CLIENT; + case OGS_EVENT_SBI_TIMER: + return OGS_EVENT_NAME_SBI_TIMER; - default: - break; + default: + break; } + ogs_error("Unknown Event%d", e->h.id); return "UNKNOWN_EVENT"; }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/ausf/event.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/ausf/event.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,53 +20,21 @@ #ifndef AUSF_EVENT_H #define AUSF_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { #endif -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_nf_instance_s ogs_sbi_nf_instance_t; -typedef struct ogs_sbi_subscription_s ogs_sbi_subscription_t; - typedef struct ausf_ue_s ausf_ue_t; -typedef enum { - AUSF_EVT_BASE = OGS_FSM_USER_SIG, - - AUSF_EVT_SBI_SERVER, - AUSF_EVT_SBI_CLIENT, - AUSF_EVT_SBI_TIMER, - - AUSF_EVT_TOP, - -} ausf_event_e; - typedef struct ausf_event_s { - int id; - int timer_id; - - struct { - ogs_sbi_request_t *request; - ogs_sbi_response_t *response; - void *data; - - ogs_sbi_message_t *message; - } sbi; + ogs_event_t h; ausf_ue_t *ausf_ue; - - ogs_timer_t *timer; } ausf_event_t; -void ausf_event_init(void); -void ausf_event_final(void); - -ausf_event_t *ausf_event_new(ausf_event_e id); -void ausf_event_free(ausf_event_t *e); +ausf_event_t *ausf_event_new(int id); const char *ausf_event_get_name(ausf_event_t *e);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/ausf/init.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/ausf/init.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -30,7 +30,6 @@ ogs_sbi_context_init(); ausf_context_init(); - ausf_event_init(); rv = ogs_sbi_context_parse_config("ausf", "nrf", "scp"); if (rv != OGS_OK) return rv; @@ -61,7 +60,7 @@ /* Sending NF Instance De-registeration to NRF */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) - ausf_nf_fsm_fini(nf_instance); + ogs_sbi_nf_fsm_fini(nf_instance); /* Starting holding timer */ t_termination_holding = ogs_timer_add(ogs_app()->timer_mgr, NULL, NULL); @@ -87,8 +86,6 @@ ausf_context_final(); ogs_sbi_context_final(); - - ausf_event_final(); /* Destroy event */ } static void ausf_main(void *data) @@ -96,8 +93,7 @@ ogs_fsm_t ausf_sm; int rv; - ogs_fsm_create(&ausf_sm, ausf_state_initial, ausf_state_final); - ogs_fsm_init(&ausf_sm, 0); + ogs_fsm_init(&ausf_sm, ausf_state_initial, ausf_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -130,11 +126,10 @@ ogs_assert(e); ogs_fsm_dispatch(&ausf_sm, e); - ausf_event_free(e); + ogs_event_free(e); } } done: ogs_fsm_fini(&ausf_sm, 0); - ogs_fsm_delete(&ausf_sm); }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/ausf/meson.build -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/ausf/meson.build
Changed
@@ -1,4 +1,4 @@ -# Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> +# Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> # This file is part of Open5GS. @@ -18,12 +18,8 @@ libausf_sources = files(''' context.c event.c - timer.c - nnrf-build.c nnrf-handler.c - nf-sm.c - nausf-handler.c nudm-build.c
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/ausf/nnrf-handler.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/ausf/nnrf-handler.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,243 +20,14 @@ #include "sbi-path.h" #include "nnrf-handler.h" -void ausf_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_nf_profile_t *NFProfile = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(nf_instance); - client = nf_instance->client; - ogs_assert(client); - - NFProfile = recvmsg->NFProfile; - if (!NFProfile) { - ogs_error("No NFProfile"); - return; - } - - /* TIME : Update heartbeat from NRF */ - if (NFProfile->is_heart_beat_timer == true) - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; -} - -void ausf_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_subscription_data_t *SubscriptionData = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(subscription); - client = subscription->client; - ogs_assert(client); - - SubscriptionData = recvmsg->SubscriptionData; - if (!SubscriptionData) { - ogs_error("No SubscriptionData"); - return; - } - - if (!SubscriptionData->subscription_id) { - ogs_error("No SubscriptionId"); - return; - } - ogs_sbi_subscription_set_id( - subscription, SubscriptionData->subscription_id); - - if (SubscriptionData->validity_time) { -#define VALIDITY_MINIMUM (10LL * OGS_USEC_PER_SEC) /* 10 seconds */ - ogs_time_t time, duration; - if (ogs_sbi_time_from_string( - &time, SubscriptionData->validity_time) == true) { - duration = time - ogs_time_now(); - if (duration < VALIDITY_MINIMUM) { - duration = VALIDITY_MINIMUM; - ogs_warn("%s Forced to %lld seconds", subscription->id, - (long long)ogs_time_sec(VALIDITY_MINIMUM)); - } - subscription->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - ausf_timer_subscription_validity, subscription); - ogs_assert(subscription->t_validity); - ogs_timer_start(subscription->t_validity, duration); - } else { - ogs_error("Cannot parse validitiyTime %s", - SubscriptionData->validity_time); - } - } -} - -bool ausf_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) -{ - int rv; - bool handled; - - ogs_sbi_response_t *response = NULL; - OpenAPI_notification_data_t *NotificationData = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_header_t header; - - ogs_assert(stream); - ogs_assert(recvmsg); - - NotificationData = recvmsg->NotificationData; - if (!NotificationData) { - ogs_error("No NotificationData"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NotificationData", NULL)); - return false; - } - - if (!NotificationData->nf_instance_uri) { - ogs_error("No nfInstanceUri"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No nfInstanceUri", NULL)); - return false; - } - - memset(&header, 0, sizeof(header)); - header.uri = NotificationData->nf_instance_uri; - - rv = ogs_sbi_parse_header(&message, &header); - if (rv != OGS_OK) { - ogs_error("Cannot parse nfInstanceUri %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - return false; - } - - if (!message.h.resource.component1) { - ogs_error("No nfInstanceId %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - ogs_sbi_header_free(&header); - return false; - } - - if (NF_INSTANCE_IS_SELF(message.h.resource.component1)) { - ogs_warn("%s The notification is not allowed", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_FORBIDDEN, - recvmsg, "The notification is not allowed", - message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - - if (NotificationData->event == - OpenAPI_notification_event_type_NF_REGISTERED) { - - OpenAPI_nf_profile_t *NFProfile = NULL; - - NFProfile = NotificationData->nf_profile; - if (!NFProfile) { - ogs_error("No NFProfile"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NFProfile", NULL)); - ogs_sbi_header_free(&header); - return false; - } - - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, - message.h.resource.component1); - - ausf_nf_fsm_init(nf_instance); - - ogs_info("%s (NRF-notify) NF registered", nf_instance->id); - - } else { - OGS_FSM_TRAN(&nf_instance->sm, ausf_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NRF-notify) NF has already been added", - message.h.resource.component1); - - } - - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, stream, recvmsg); - if (!handled) { - AUSF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - ogs_info("%s (NRF-notify) NF Profile updated", nf_instance->id); - - handled = ogs_sbi_client_associate(nf_instance); - if (!handled) { - ogs_error("%s Cannot associate NF EndPoint", nf_instance->id); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot find NF EndPoint", nf_instance->id)); - AUSF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - } else if (NotificationData->event == - OpenAPI_notification_event_type_NF_DEREGISTERED) { - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (nf_instance) { - AUSF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - } else { - ogs_warn("%s (NRF-notify) Not found", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_NOT_FOUND, - recvmsg, "Not found", message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - } else { - char *eventstr = OpenAPI_notification_event_type_ToString( - NotificationData->event); - ogs_error("Not supported event %d:%s", - NotificationData->event, eventstr ? eventstr : "Unknown"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Not supported event", - eventstr ? eventstr : "Unknown")); - ogs_sbi_header_free(&header); - return false; - } - - response = ogs_sbi_build_response(recvmsg, OGS_SBI_HTTP_STATUS_NO_CONTENT); - ogs_assert(response); - ogs_assert(true == ogs_sbi_server_send_response(stream, response)); - - ogs_sbi_header_free(&header); - return true; -} - void ausf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { ogs_sbi_object_t *sbi_object = NULL; OpenAPI_nf_type_e target_nf_type = 0; ogs_sbi_discovery_option_t *discovery_option = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; OpenAPI_search_result_t *SearchResult = NULL; - OpenAPI_lnode_t *node = NULL; - bool handled; ogs_assert(recvmsg); ogs_assert(xact); @@ -273,64 +44,8 @@ return; } - OpenAPI_list_for_each(SearchResult->nf_instances, node) { - OpenAPI_nf_profile_t *NFProfile = NULL; - - if (!node->data) continue; - - NFProfile = node->data; - - nf_instance = ogs_sbi_nf_instance_find(NFProfile->nf_instance_id); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id); - - ausf_nf_fsm_init(nf_instance); - - ogs_info("%s (NF-discover) NF registered", nf_instance->id); - } else { - OGS_FSM_TRAN(&nf_instance->sm, ausf_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NF-discover) NF has already been added", - NFProfile->nf_instance_id); - } - - if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) { - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, NULL, NULL); - if (!handled) { - ogs_error("%s ogs_sbi_nnrf_handle_nf_profile() failed", - nf_instance->id); - AUSF_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); - continue; - } - - handled = ogs_sbi_client_associate(nf_instance); - if (!handled) { - ogs_error("%s Cannot assciate NF EndPoint", nf_instance->id); - AUSF_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); - continue; - } - - /* TIME : Update validity from NRF */ - if (SearchResult->is_validity_period && - SearchResult->validity_period) { - nf_instance->time.validity_duration = - SearchResult->validity_period; - - ogs_assert(nf_instance->t_validity); - ogs_timer_start(nf_instance->t_validity, - ogs_time_from_sec(nf_instance->time.validity_duration)); - - } else - ogs_warn("%s NF Instance validity-time should not 0", - nf_instance->id); - - ogs_info("%s (NF-discover) NF Profile updated", nf_instance->id); - } - } + ogs_nnrf_handle_nf_discover_search_result( + sbi_object, target_nf_type, discovery_option, SearchResult); ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/ausf/nnrf-handler.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/ausf/nnrf-handler.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -26,14 +26,6 @@ extern "C" { #endif -void ausf_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg); -void ausf_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg); - -bool ausf_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); - void ausf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/ausf/sbi-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/ausf/sbi-path.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -27,17 +27,17 @@ ogs_assert(request); ogs_assert(data); - e = ausf_event_new(AUSF_EVT_SBI_SERVER); + e = ausf_event_new(OGS_EVENT_SBI_SERVER); ogs_assert(e); - e->sbi.request = request; - e->sbi.data = data; + e->h.sbi.request = request; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_request_free(request); - ausf_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -58,16 +58,16 @@ ogs_assert(response); - e = ausf_event_new(AUSF_EVT_SBI_CLIENT); + e = ausf_event_new(OGS_EVENT_SBI_CLIENT); ogs_assert(e); - e->sbi.response = response; - e->sbi.data = data; + e->h.sbi.response = response; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_response_free(response); - ausf_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -79,6 +79,10 @@ ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_nf_service_t *service = NULL; + /* To be notified when NF Instances registered/deregistered in NRF + * or when their profile is modified */ + ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_UDM); + /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); @@ -98,28 +102,20 @@ } /* Initialize NRF NF Instance */ - ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_sbi_client_t *client = NULL; - - /* Client callback is only used when NF sends to NRF */ - client = nf_instance->client; - ogs_assert(client); - client->cb = client_cb; - - /* NFRegister is sent and the response is received - * by the above client callback. */ - ausf_nf_fsm_init(nf_instance); - } + nf_instance = ogs_sbi_self()->nrf_instance; + if (nf_instance) { + ogs_sbi_client_t *client = NULL; + + /* Client callback is only used when NF sends to NRF */ + client = nf_instance->client; + ogs_assert(client); + client->cb = client_cb; + + /* NFRegister is sent and the response is received + * by the above client callback. */ + ogs_sbi_nf_fsm_init(nf_instance); } - /* Timer expiration handler of client wait timer */ - ogs_sbi_self()->client_wait_expire = ausf_timer_sbi_client_wait_expire; - - /* NF register state in NF state machine */ - ogs_sbi_self()->nf_state_registered = - (ogs_fsm_handler_t)ausf_nf_state_registered; - if (ogs_sbi_server_start_all(server_cb) != OGS_OK) return OGS_ERROR;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/ausf/sbi-path.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/ausf/sbi-path.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,7 +20,6 @@ #ifndef AUSF_SBI_PATH_H #define AUSF_SBI_PATH_H -#include "nnrf-build.h" #include "nudm-build.h" #ifdef __cplusplus
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/ausf/ue-sm.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/ausf/ue-sm.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -66,17 +66,17 @@ ausf_ue = e->ausf_ue; ogs_assert(ausf_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case AUSF_EVT_SBI_SERVER: - message = e->sbi.message; + case OGS_EVENT_SBI_SERVER: + message = e->h.sbi.message; ogs_assert(message); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); SWITCH(message->h.method) @@ -109,13 +109,13 @@ break; - case AUSF_EVT_SBI_CLIENT: - message = e->sbi.message; + case OGS_EVENT_SBI_CLIENT: + message = e->h.sbi.message; ogs_assert(message); ausf_ue = e->ausf_ue; ogs_assert(ausf_ue); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); SWITCH(message->h.service.name) @@ -178,7 +178,7 @@ ausf_ue = e->ausf_ue; ogs_assert(ausf_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/bsf/bsf-sm.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/bsf/bsf-sm.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -56,17 +56,17 @@ ogs_assert(s); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case BSF_EVT_SBI_SERVER: - request = e->sbi.request; + case OGS_EVENT_SBI_SERVER: + request = e->h.sbi.request; ogs_assert(request); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); rv = ogs_sbi_parse_request(&message, request); @@ -97,7 +97,7 @@ CASE(OGS_SBI_RESOURCE_NAME_NF_STATUS_NOTIFY) SWITCH(message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) - bsf_nnrf_handle_nf_status_notify(stream, &message); + ogs_nnrf_handle_nf_status_notify(stream, &message); break; DEFAULT @@ -195,10 +195,10 @@ ogs_sbi_message_free(&message); break; - case BSF_EVT_SBI_CLIENT: + case OGS_EVENT_SBI_CLIENT: ogs_assert(e); - response = e->sbi.response; + response = e->h.sbi.response; ogs_assert(response); rv = ogs_sbi_parse_response(&message, response); if (rv != OGS_OK) { @@ -220,23 +220,23 @@ SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - nf_instance = e->sbi.data; + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&nf_instance->sm, e); break; CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS) - subscription = e->sbi.data; + subscription = e->h.sbi.data; ogs_assert(subscription); SWITCH(message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) if (message.res_status == OGS_SBI_HTTP_STATUS_CREATED || message.res_status == OGS_SBI_HTTP_STATUS_OK) { - bsf_nnrf_handle_nf_status_subscribe( + ogs_nnrf_handle_nf_status_subscribe( subscription, &message); } else { ogs_error("HTTP response error : %d", @@ -269,7 +269,7 @@ CASE(OGS_SBI_SERVICE_NAME_NNRF_DISC) SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); SWITCH(message.h.method) @@ -303,27 +303,27 @@ ogs_sbi_response_free(response); break; - case BSF_EVT_SBI_TIMER: + case OGS_EVENT_SBI_TIMER: ogs_assert(e); - switch(e->timer_id) { - case BSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case BSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case BSF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case BSF_TIMER_NF_INSTANCE_VALIDITY: - nf_instance = e->sbi.data; + switch(e->h.timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + case OGS_TIMER_NF_INSTANCE_VALIDITY: + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); ogs_fsm_dispatch(&nf_instance->sm, e); - if (OGS_FSM_CHECK(&nf_instance->sm, bsf_nf_state_exception)) + if (OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_exception)) ogs_error("%s:%s State machine exception %d", OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id, e->timer_id); + nf_instance->id, e->h.timer_id); break; - case BSF_TIMER_SUBSCRIPTION_VALIDITY: - subscription = e->sbi.data; + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + subscription = e->h.sbi.data; ogs_assert(subscription); ogs_assert(ogs_sbi_self()->nf_instance); @@ -337,8 +337,8 @@ ogs_sbi_subscription_remove(subscription); break; - case BSF_TIMER_SBI_CLIENT_WAIT: - sbi_xact = e->sbi.data; + case OGS_TIMER_SBI_CLIENT_WAIT: + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); stream = sbi_xact->assoc_stream; @@ -358,7 +358,7 @@ default: ogs_error("Unknown timer%s:%d", - bsf_timer_get_name(e->timer_id), e->timer_id); + ogs_timer_get_name(e->h.timer_id), e->h.timer_id); } break;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/bsf/bsf-sm.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/bsf/bsf-sm.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -31,16 +31,6 @@ void bsf_state_operational(ogs_fsm_t *s, bsf_event_t *e); void bsf_state_exception(ogs_fsm_t *s, bsf_event_t *e); -void bsf_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance); -void bsf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance); - -void bsf_nf_state_initial(ogs_fsm_t *s, bsf_event_t *e); -void bsf_nf_state_final(ogs_fsm_t *s, bsf_event_t *e); -void bsf_nf_state_will_register(ogs_fsm_t *s, bsf_event_t *e); -void bsf_nf_state_registered(ogs_fsm_t *s, bsf_event_t *e); -void bsf_nf_state_de_registered(ogs_fsm_t *s, bsf_event_t *e); -void bsf_nf_state_exception(ogs_fsm_t *s, bsf_event_t *e); - #define bsf_sm_debug(__pe) \ ogs_debug("%s(): %s", __func__, bsf_event_get_name(__pe))
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/bsf/context.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/bsf/context.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. *
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/bsf/context.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/bsf/context.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -23,7 +23,6 @@ #include "ogs-sbi.h" #include "ogs-app.h" -#include "timer.h" #include "bsf-sm.h" #ifdef __cplusplus @@ -42,22 +41,6 @@ ogs_list_t sess_list; } bsf_context_t; -#define BSF_NF_INSTANCE_CLEAR(_cAUSE, _nFInstance) \ - do { \ - ogs_assert(_nFInstance); \ - if ((_nFInstance)->reference_count == 1) { \ - ogs_info("%s (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ - bsf_nf_fsm_fini((_nFInstance)); \ - ogs_sbi_nf_instance_remove(_nFInstance); \ - } else { \ - /* There is an assocation with other context */ \ - ogs_info("%s:%d (%s) NF suspended", \ - _nFInstance->id, _nFInstance->reference_count, (_cAUSE)); \ - OGS_FSM_TRAN(&_nFInstance->sm, bsf_nf_state_de_registered); \ - ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ - } \ - } while(0) - typedef struct bsf_sess_s bsf_sess_t; typedef struct bsf_sess_s {
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/bsf/event.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/bsf/event.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -18,60 +18,42 @@ */ #include "event.h" -#include "context.h" -static OGS_POOL(pool, bsf_event_t); - -void bsf_event_init(void) -{ - ogs_pool_init(&pool, ogs_app()->pool.event); -} - -void bsf_event_final(void) -{ - ogs_pool_final(&pool); -} - -bsf_event_t *bsf_event_new(bsf_event_e id) +bsf_event_t *bsf_event_new(int id) { bsf_event_t *e = NULL; - ogs_pool_alloc(&pool, &e); + e = ogs_event_size(id, sizeof(bsf_event_t)); ogs_assert(e); - memset(e, 0, sizeof(*e)); - e->id = id; + e->h.id = id; return e; } -void bsf_event_free(bsf_event_t *e) -{ - ogs_assert(e); - ogs_pool_free(&pool, e); -} - const char *bsf_event_get_name(bsf_event_t *e) { - if (e == NULL) + if (e == NULL) { return OGS_FSM_NAME_INIT_SIG; + } - switch (e->id) { - case OGS_FSM_ENTRY_SIG: + switch (e->h.id) { + case OGS_FSM_ENTRY_SIG: return OGS_FSM_NAME_ENTRY_SIG; - case OGS_FSM_EXIT_SIG: + case OGS_FSM_EXIT_SIG: return OGS_FSM_NAME_EXIT_SIG; - case BSF_EVT_SBI_SERVER: - return "BSF_EVT_SBI_SERVER"; - case BSF_EVT_SBI_CLIENT: - return "BSF_EVT_SBI_CLIENT"; - case BSF_EVT_SBI_TIMER: - return "BSF_EVT_SBI_TIMER"; + case OGS_EVENT_SBI_SERVER: + return OGS_EVENT_NAME_SBI_SERVER; + case OGS_EVENT_SBI_CLIENT: + return OGS_EVENT_NAME_SBI_CLIENT; + case OGS_EVENT_SBI_TIMER: + return OGS_EVENT_NAME_SBI_TIMER; - default: - break; + default: + break; } + ogs_error("Unknown Event%d", e->h.id); return "UNKNOWN_EVENT"; }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/bsf/event.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/bsf/event.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,51 +20,20 @@ #ifndef BSF_EVENT_H #define BSF_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { #endif typedef struct bsf_sess_s bsf_sess_t; -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; - -typedef enum { - BSF_EVT_BASE = OGS_FSM_USER_SIG, - - BSF_EVT_SBI_SERVER, - BSF_EVT_SBI_CLIENT, - BSF_EVT_SBI_TIMER, - - BSF_EVT_TOP, - -} bsf_event_e; typedef struct bsf_event_s { - int id; - ogs_pkbuf_t *pkbuf; - int timer_id; - - struct { - ogs_sbi_request_t *request; - ogs_sbi_response_t *response; - void *data; - int state; - - ogs_sbi_message_t *message; - } sbi; - + ogs_event_t h; bsf_sess_t *sess; } bsf_event_t; -void bsf_event_init(void); -void bsf_event_final(void); - -bsf_event_t *bsf_event_new(bsf_event_e id); -void bsf_event_free(bsf_event_t *e); +bsf_event_t *bsf_event_new(int id); const char *bsf_event_get_name(bsf_event_t *e);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/bsf/init.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/bsf/init.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -32,7 +32,6 @@ ogs_sbi_context_init(); bsf_context_init(); - bsf_event_init(); rv = ogs_sbi_context_parse_config("bsf", "nrf", "scp"); if (rv != OGS_OK) return rv; @@ -63,7 +62,7 @@ /* Sending NF Instance De-registeration to NRF */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) - bsf_nf_fsm_fini(nf_instance); + ogs_sbi_nf_fsm_fini(nf_instance); /* Starting holding timer */ t_termination_holding = ogs_timer_add(ogs_app()->timer_mgr, NULL, NULL); @@ -90,8 +89,6 @@ bsf_context_final(); ogs_sbi_context_final(); - - bsf_event_final(); /* Destroy event */ } static void bsf_main(void *data) @@ -99,8 +96,7 @@ ogs_fsm_t bsf_sm; int rv; - ogs_fsm_create(&bsf_sm, bsf_state_initial, bsf_state_final); - ogs_fsm_init(&bsf_sm, 0); + ogs_fsm_init(&bsf_sm, bsf_state_initial, bsf_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -133,11 +129,10 @@ ogs_assert(e); ogs_fsm_dispatch(&bsf_sm, e); - bsf_event_free(e); + ogs_event_free(e); } } done: ogs_fsm_fini(&bsf_sm, 0); - ogs_fsm_delete(&bsf_sm); }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/bsf/meson.build -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/bsf/meson.build
Changed
@@ -1,4 +1,4 @@ -# Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> +# Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> # This file is part of Open5GS. @@ -18,12 +18,8 @@ libbsf_sources = files(''' context.c event.c - timer.c - nnrf-build.c nnrf-handler.c - nf-sm.c - nbsf-handler.c sbi-path.c
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/bsf/nbsf-handler.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/bsf/nbsf-handler.c
Changed
@@ -34,10 +34,6 @@ OpenAPI_pcf_binding_t *RecvPcfBinding = NULL; OpenAPI_pcf_binding_t SendPcfBinding; OpenAPI_snssai_t Snssai; -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - char fqdnOGS_MAX_FQDN_LEN+1; - int fqdn_len; -#endif ogs_assert(stream); ogs_assert(recvmsg); @@ -103,22 +99,10 @@ bsf_sess_set_ipv6prefix(sess, RecvPcfBinding->ipv6_prefix); if (RecvPcfBinding->pcf_fqdn) { -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - ogs_assert(0 < ogs_fqdn_parse( - fqdn, RecvPcfBinding->pcf_fqdn, - ogs_min(strlen(RecvPcfBinding->pcf_fqdn), - OGS_MAX_FQDN_LEN))); - - if (sess->pcf_fqdn) - ogs_free(sess->pcf_fqdn); - sess->pcf_fqdn = ogs_strdup(fqdn); - ogs_assert(sess->pcf_fqdn); -#else if (sess->pcf_fqdn) ogs_free(sess->pcf_fqdn); sess->pcf_fqdn = ogs_strdup(RecvPcfBinding->pcf_fqdn); ogs_assert(sess->pcf_fqdn); -#endif } PcfIpEndPointList = RecvPcfBinding->pcf_ip_end_points; @@ -232,18 +216,8 @@ PcfIpEndPointList = OpenAPI_list_create(); ogs_assert(PcfIpEndPointList); - if (sess->pcf_fqdn && strlen(sess->pcf_fqdn)) { -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - memset(fqdn, 0, sizeof(fqdn)); - fqdn_len = ogs_fqdn_build(fqdn, - sess->pcf_fqdn, strlen(sess->pcf_fqdn)); - SendPcfBinding.pcf_fqdn = ogs_memdup(fqdn, fqdn_len+1); - ogs_assert(SendPcfBinding.pcf_fqdn); - SendPcfBinding.pcf_fqdnfqdn_len = 0; -#else + if (sess->pcf_fqdn && strlen(sess->pcf_fqdn)) SendPcfBinding.pcf_fqdn = ogs_strdup(sess->pcf_fqdn); -#endif - } for (i = 0; i < sess->num_of_pcf_ip; i++) { OpenAPI_ip_end_point_t *PcfIpEndPoint = NULL;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/bsf/nnrf-handler.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/bsf/nnrf-handler.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,244 +20,14 @@ #include "sbi-path.h" #include "nnrf-handler.h" -void bsf_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_nf_profile_t *NFProfile = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(nf_instance); - client = nf_instance->client; - ogs_assert(client); - - NFProfile = recvmsg->NFProfile; - if (!NFProfile) { - ogs_error("No NFProfile"); - return; - } - - /* TIME : Update heartbeat from NRF */ - if (NFProfile->is_heart_beat_timer == true) - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; -} - -void bsf_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_subscription_data_t *SubscriptionData = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(subscription); - client = subscription->client; - ogs_assert(client); - - SubscriptionData = recvmsg->SubscriptionData; - if (!SubscriptionData) { - ogs_error("No SubscriptionData"); - return; - } - - if (!SubscriptionData->subscription_id) { - ogs_error("No SubscriptionId"); - return; - } - ogs_sbi_subscription_set_id( - subscription, SubscriptionData->subscription_id); - - if (SubscriptionData->validity_time) { -#define VALIDITY_MINIMUM (10LL * OGS_USEC_PER_SEC) /* 10 seconds */ - ogs_time_t time, duration; - if (ogs_sbi_time_from_string( - &time, SubscriptionData->validity_time) == true) { - duration = time - ogs_time_now(); - if (duration < VALIDITY_MINIMUM) { - duration = VALIDITY_MINIMUM; - ogs_warn("%s Forced to %lld seconds", subscription->id, - (long long)ogs_time_sec(VALIDITY_MINIMUM)); - } - subscription->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - bsf_timer_subscription_validity, subscription); - ogs_assert(subscription->t_validity); - ogs_timer_start(subscription->t_validity, duration); - } else { - ogs_error("Cannot parse validitiyTime %s", - SubscriptionData->validity_time); - } - } -} - -bool bsf_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) -{ - int rv; - bool handled; - - ogs_sbi_response_t *response = NULL; - OpenAPI_notification_data_t *NotificationData = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_header_t header; - - ogs_assert(stream); - ogs_assert(recvmsg); - - NotificationData = recvmsg->NotificationData; - if (!NotificationData) { - ogs_error("No NotificationData"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NotificationData", NULL)); - return false; - } - - if (!NotificationData->nf_instance_uri) { - ogs_error("No nfInstanceUri"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No nfInstanceUri", NULL)); - return false; - } - - memset(&header, 0, sizeof(header)); - header.uri = NotificationData->nf_instance_uri; - - rv = ogs_sbi_parse_header(&message, &header); - if (rv != OGS_OK) { - ogs_error("Cannot parse nfInstanceUri %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - return false; - } - - if (!message.h.resource.component1) { - ogs_error("No nfInstanceId %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - ogs_sbi_header_free(&header); - return false; - } - - if (NF_INSTANCE_IS_SELF(message.h.resource.component1)) { - ogs_warn("%s The notification is not allowed", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_FORBIDDEN, - recvmsg, "The notification is not allowed", - message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - - if (NotificationData->event == - OpenAPI_notification_event_type_NF_REGISTERED) { - - OpenAPI_nf_profile_t *NFProfile = NULL; - - NFProfile = NotificationData->nf_profile; - if (!NFProfile) { - ogs_error("No NFProfile"); - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NFProfile", NULL)); - ogs_sbi_header_free(&header); - return false; - } - - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, - message.h.resource.component1); - - bsf_nf_fsm_init(nf_instance); - - ogs_info("%s (NRF-notify) NF registered", nf_instance->id); - - } else { - OGS_FSM_TRAN(&nf_instance->sm, bsf_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NRF-notify) NF has already been added", - message.h.resource.component1); - - } - - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, stream, recvmsg); - if (!handled) { - BSF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - ogs_info("%s (NRF-notify) NF Profile updated", nf_instance->id); - - handled = ogs_sbi_client_associate(nf_instance); - if (!handled) { - ogs_error("%s Cannot associate NF EndPoint", nf_instance->id); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot find NF EndPoint", nf_instance->id)); - BSF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - } else if (NotificationData->event == - OpenAPI_notification_event_type_NF_DEREGISTERED) { - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (nf_instance) { - BSF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - } else { - ogs_warn("%s (NRF-notify) Not found", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_NOT_FOUND, - recvmsg, "Not found", message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - } else { - char *eventstr = OpenAPI_notification_event_type_ToString( - NotificationData->event); - ogs_error("Not supported event %d:%s", - NotificationData->event, eventstr ? eventstr : "Unknown"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Not supported event", - eventstr ? eventstr : "Unknown")); - ogs_sbi_header_free(&header); - return false; - } - - response = ogs_sbi_build_response(recvmsg, OGS_SBI_HTTP_STATUS_NO_CONTENT); - ogs_assert(response); - ogs_assert(true == ogs_sbi_server_send_response(stream, response)); - - ogs_sbi_header_free(&header); - return true; -} - void bsf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { ogs_sbi_object_t *sbi_object = NULL; OpenAPI_nf_type_e target_nf_type = 0; ogs_sbi_discovery_option_t *discovery_option = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; OpenAPI_search_result_t *SearchResult = NULL; - OpenAPI_lnode_t *node = NULL; - bool handled; ogs_assert(recvmsg); ogs_assert(xact); @@ -274,64 +44,8 @@ return; } - OpenAPI_list_for_each(SearchResult->nf_instances, node) { - OpenAPI_nf_profile_t *NFProfile = NULL; - - if (!node->data) continue; - - NFProfile = node->data; - - nf_instance = ogs_sbi_nf_instance_find(NFProfile->nf_instance_id); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id); - - bsf_nf_fsm_init(nf_instance); - - ogs_info("%s (NF-discover) NF registered", nf_instance->id); - } else { - OGS_FSM_TRAN(&nf_instance->sm, bsf_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NF-discover) NF has already been added", - NFProfile->nf_instance_id); - } - - if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) { - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, NULL, NULL); - if (!handled) { - ogs_error("ogs_sbi_nnrf_handle_nf_profile() failed %s", - nf_instance->id); - BSF_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); - continue; - } - - handled = ogs_sbi_client_associate(nf_instance); - if (!handled) { - ogs_error("%s Cannot assciate NF EndPoint", nf_instance->id); - BSF_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); - continue; - } - - /* TIME : Update validity from NRF */ - if (SearchResult->is_validity_period && - SearchResult->validity_period) { - nf_instance->time.validity_duration = - SearchResult->validity_period; - - ogs_assert(nf_instance->t_validity); - ogs_timer_start(nf_instance->t_validity, - ogs_time_from_sec(nf_instance->time.validity_duration)); - - } else - ogs_warn("%s NF Instance validity-time should not 0", - nf_instance->id); - - ogs_info("%s (NF-discover) NF Profile updated", nf_instance->id); - } - } + ogs_nnrf_handle_nf_discover_search_result( + sbi_object, target_nf_type, discovery_option, SearchResult); ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/bsf/nnrf-handler.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/bsf/nnrf-handler.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -26,14 +26,6 @@ extern "C" { #endif -void bsf_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg); -void bsf_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg); - -bool bsf_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); - void bsf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/bsf/sbi-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/bsf/sbi-path.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -27,17 +27,17 @@ ogs_assert(request); ogs_assert(data); - e = bsf_event_new(BSF_EVT_SBI_SERVER); + e = bsf_event_new(OGS_EVENT_SBI_SERVER); ogs_assert(e); - e->sbi.request = request; - e->sbi.data = data; + e->h.sbi.request = request; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_request_free(request); - bsf_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -58,16 +58,16 @@ ogs_assert(response); - e = bsf_event_new(BSF_EVT_SBI_CLIENT); + e = bsf_event_new(OGS_EVENT_SBI_CLIENT); ogs_assert(e); - e->sbi.response = response; - e->sbi.data = data; + e->h.sbi.response = response; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_response_free(response); - bsf_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -79,6 +79,10 @@ ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_nf_service_t *service = NULL; + /* To be notified when NF Instances registered/deregistered in NRF + * or when their profile is modified */ + ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_UDM); + /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); @@ -98,28 +102,20 @@ } /* Initialize NRF NF Instance */ - ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_sbi_client_t *client = NULL; - - /* Client callback is only used when NF sends to NRF */ - client = nf_instance->client; - ogs_assert(client); - client->cb = client_cb; - - /* NFRegister is sent and the response is received - * by the above client callback. */ - bsf_nf_fsm_init(nf_instance); - } + nf_instance = ogs_sbi_self()->nrf_instance; + if (nf_instance) { + ogs_sbi_client_t *client = NULL; + + /* Client callback is only used when NF sends to NRF */ + client = nf_instance->client; + ogs_assert(client); + client->cb = client_cb; + + /* NFRegister is sent and the response is received + * by the above client callback. */ + ogs_sbi_nf_fsm_init(nf_instance); } - /* Timer expiration handler of client wait timer */ - ogs_sbi_self()->client_wait_expire = bsf_timer_sbi_client_wait_expire; - - /* NF register state in NF state machine */ - ogs_sbi_self()->nf_state_registered = - (ogs_fsm_handler_t)bsf_nf_state_registered; - if (ogs_sbi_server_start_all(server_cb) != OGS_OK) return OGS_ERROR;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/bsf/sbi-path.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/bsf/sbi-path.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,7 +20,7 @@ #ifndef BSF_SBI_PATH_H #define BSF_SBI_PATH_H -#include "nnrf-build.h" +#include "context.h" #ifdef __cplusplus extern "C" {
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/mme/emm-sm.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/mme/emm-sm.c
Changed
@@ -109,7 +109,7 @@ case OGS_FSM_EXIT_SIG: break; - case MME_EVT_EMM_MESSAGE: + case MME_EVENT_EMM_MESSAGE: message = e->nas_message; ogs_assert(message); @@ -590,7 +590,7 @@ } break; - case MME_EVT_EMM_TIMER: + case MME_EVENT_EMM_TIMER: switch (e->timer_id) { case MME_TIMER_T3413: if (mme_ue->t3413.retry_count >= @@ -679,7 +679,7 @@ break; case OGS_FSM_EXIT_SIG: break; - case MME_EVT_EMM_MESSAGE: + case MME_EVENT_EMM_MESSAGE: message = e->nas_message; ogs_assert(message); @@ -794,7 +794,7 @@ break; } break; - case MME_EVT_EMM_TIMER: + case MME_EVENT_EMM_TIMER: switch (e->timer_id) { case MME_TIMER_T3460: if (mme_ue->t3460.retry_count >= @@ -850,7 +850,7 @@ break; case OGS_FSM_EXIT_SIG: break; - case MME_EVT_EMM_MESSAGE: + case MME_EVENT_EMM_MESSAGE: message = e->nas_message; ogs_assert(message); @@ -966,7 +966,7 @@ break; } break; - case MME_EVT_EMM_TIMER: + case MME_EVENT_EMM_TIMER: switch (e->timer_id) { case MME_TIMER_T3460: if (mme_ue->t3460.retry_count >= @@ -1021,7 +1021,7 @@ break; case OGS_FSM_EXIT_SIG: break; - case MME_EVT_EMM_MESSAGE: + case MME_EVENT_EMM_MESSAGE: message = e->nas_message; ogs_assert(message); @@ -1159,7 +1159,7 @@ break; } break; - case MME_EVT_EMM_TIMER: + case MME_EVENT_EMM_TIMER: switch (e->timer_id) { case MME_TIMER_T3450: if (mme_ue->t3450.retry_count >= @@ -1224,7 +1224,7 @@ case OGS_FSM_EXIT_SIG: break; - case MME_EVT_EMM_MESSAGE: + case MME_EVENT_EMM_MESSAGE: message = e->nas_message; ogs_assert(message);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/mme/esm-sm.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/mme/esm-sm.c
Changed
@@ -96,7 +96,7 @@ break; case OGS_FSM_EXIT_SIG: break; - case MME_EVT_ESM_MESSAGE: + case MME_EVENT_ESM_MESSAGE: message = e->nas_message; ogs_assert(message); @@ -221,7 +221,7 @@ break; } break; - case MME_EVT_ESM_TIMER: + case MME_EVENT_ESM_TIMER: switch (e->timer_id) { case MME_TIMER_T3489: if (bearer->t3489.retry_count >= @@ -281,7 +281,7 @@ break; case OGS_FSM_EXIT_SIG: break; - case MME_EVT_ESM_MESSAGE: + case MME_EVENT_ESM_MESSAGE: message = e->nas_message; ogs_assert(message); @@ -382,7 +382,7 @@ break; case OGS_FSM_EXIT_SIG: break; - case MME_EVT_ESM_MESSAGE: + case MME_EVENT_ESM_MESSAGE: message = e->nas_message; ogs_assert(message);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/mme/mme-context.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/mme/mme-context.c
Changed
@@ -1831,8 +1831,7 @@ memset(&e, 0, sizeof(e)); e.enb = enb; - ogs_fsm_create(&enb->sm, s1ap_state_initial, s1ap_state_final); - ogs_fsm_init(&enb->sm, &e); + ogs_fsm_init(&enb->sm, s1ap_state_initial, s1ap_state_final, &e); ogs_list_add(&self.enb_list, enb); mme_metrics_inst_global_inc(MME_METR_GLOB_GAUGE_ENB); @@ -1855,7 +1854,6 @@ memset(&e, 0, sizeof(e)); e.enb = enb; ogs_fsm_fini(&enb->sm, &e); - ogs_fsm_delete(&enb->sm); ogs_hash_set(self.enb_addr_hash, enb->sctp.addr, sizeof(ogs_sockaddr_t), NULL); @@ -2399,8 +2397,7 @@ memset(&e, 0, sizeof(e)); e.mme_ue = mme_ue; - ogs_fsm_create(&mme_ue->sm, emm_state_initial, emm_state_final); - ogs_fsm_init(&mme_ue->sm, &e); + ogs_fsm_init(&mme_ue->sm, emm_state_initial, emm_state_final, &e); } void mme_ue_fsm_fini(mme_ue_t *mme_ue) @@ -2412,7 +2409,6 @@ memset(&e, 0, sizeof(e)); e.mme_ue = mme_ue; ogs_fsm_fini(&mme_ue->sm, &e); - ogs_fsm_delete(&mme_ue->sm); } mme_ue_t *mme_ue_find_by_imsi_bcd(char *imsi_bcd) @@ -3004,8 +3000,7 @@ memset(&e, 0, sizeof(e)); e.bearer = bearer; - ogs_fsm_create(&bearer->sm, esm_state_initial, esm_state_final); - ogs_fsm_init(&bearer->sm, &e); + ogs_fsm_init(&bearer->sm, esm_state_initial, esm_state_final, &e); return bearer; } @@ -3021,7 +3016,6 @@ memset(&e, 0, sizeof(e)); e.bearer = bearer; ogs_fsm_fini(&bearer->sm, &e); - ogs_fsm_delete(&bearer->sm); CLEAR_BEARER_ALL_TIMERS(bearer); ogs_timer_delete(bearer->t3489.timer);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/mme/mme-event.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/mme/mme-event.c
Changed
@@ -60,42 +60,42 @@ case OGS_FSM_EXIT_SIG: return OGS_FSM_NAME_EXIT_SIG; - case MME_EVT_S1AP_MESSAGE: - return "MME_EVT_S1AP_MESSAGE"; - case MME_EVT_S1AP_TIMER: - return "MME_EVT_S1AP_TIMER"; - case MME_EVT_S1AP_LO_ACCEPT: - return "MME_EVT_S1AP_LO_ACCEPT"; - case MME_EVT_S1AP_LO_SCTP_COMM_UP: - return "MME_EVT_S1AP_LO_SCTP_COMM_UP"; - case MME_EVT_S1AP_LO_CONNREFUSED: - return "MME_EVT_S1AP_LO_CONNREFUSED"; + case MME_EVENT_S1AP_MESSAGE: + return "MME_EVENT_S1AP_MESSAGE"; + case MME_EVENT_S1AP_TIMER: + return "MME_EVENT_S1AP_TIMER"; + case MME_EVENT_S1AP_LO_ACCEPT: + return "MME_EVENT_S1AP_LO_ACCEPT"; + case MME_EVENT_S1AP_LO_SCTP_COMM_UP: + return "MME_EVENT_S1AP_LO_SCTP_COMM_UP"; + case MME_EVENT_S1AP_LO_CONNREFUSED: + return "MME_EVENT_S1AP_LO_CONNREFUSED"; - case MME_EVT_EMM_MESSAGE: - return "MME_EVT_EMM_MESSAGE"; - case MME_EVT_EMM_TIMER: - return "MME_EVT_EMM_TIMER"; - case MME_EVT_ESM_MESSAGE: - return "MME_EVT_ESM_MESSAGE"; - case MME_EVT_ESM_TIMER: - return "MME_EVT_ESM_TIMER"; - case MME_EVT_S11_MESSAGE: - return "MME_EVT_S11_MESSAGE"; - case MME_EVT_S11_TIMER: - return "MME_EVT_S11_TIMER"; - case MME_EVT_S6A_MESSAGE: - return "MME_EVT_S6A_MESSAGE"; - case MME_EVT_S6A_TIMER: - return "MME_EVT_S6A_TIMER"; + case MME_EVENT_EMM_MESSAGE: + return "MME_EVENT_EMM_MESSAGE"; + case MME_EVENT_EMM_TIMER: + return "MME_EVENT_EMM_TIMER"; + case MME_EVENT_ESM_MESSAGE: + return "MME_EVENT_ESM_MESSAGE"; + case MME_EVENT_ESM_TIMER: + return "MME_EVENT_ESM_TIMER"; + case MME_EVENT_S11_MESSAGE: + return "MME_EVENT_S11_MESSAGE"; + case MME_EVENT_S11_TIMER: + return "MME_EVENT_S11_TIMER"; + case MME_EVENT_S6A_MESSAGE: + return "MME_EVENT_S6A_MESSAGE"; + case MME_EVENT_S6A_TIMER: + return "MME_EVENT_S6A_TIMER"; - case MME_EVT_SGSAP_MESSAGE: - return "MME_EVT_SGSAP_MESSAGE"; - case MME_EVT_SGSAP_TIMER: - return "MME_EVT_SGSAP_TIMER"; - case MME_EVT_SGSAP_LO_SCTP_COMM_UP: - return "MME_EVT_SGSAP_LO_SCTP_COMM_UP"; - case MME_EVT_SGSAP_LO_CONNREFUSED: - return "MME_EVT_SGSAP_LO_CONNREFUSED"; + case MME_EVENT_SGSAP_MESSAGE: + return "MME_EVENT_SGSAP_MESSAGE"; + case MME_EVENT_SGSAP_TIMER: + return "MME_EVENT_SGSAP_TIMER"; + case MME_EVENT_SGSAP_LO_SCTP_COMM_UP: + return "MME_EVENT_SGSAP_LO_SCTP_COMM_UP"; + case MME_EVENT_SGSAP_LO_CONNREFUSED: + return "MME_EVENT_SGSAP_LO_CONNREFUSED"; default: break;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/mme/mme-event.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/mme/mme-event.h
Changed
@@ -20,7 +20,7 @@ #ifndef MME_EVENT_H #define MME_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { @@ -28,29 +28,29 @@ /* forward declaration */ typedef enum { - MME_EVT_BASE = OGS_FSM_USER_SIG, + MME_EVENT_BASE = OGS_MAX_NUM_OF_PROTO_EVENT, - MME_EVT_S1AP_MESSAGE, - MME_EVT_S1AP_TIMER, - MME_EVT_S1AP_LO_ACCEPT, - MME_EVT_S1AP_LO_SCTP_COMM_UP, - MME_EVT_S1AP_LO_CONNREFUSED, - - MME_EVT_EMM_MESSAGE, - MME_EVT_EMM_TIMER, - MME_EVT_ESM_MESSAGE, - MME_EVT_ESM_TIMER, - MME_EVT_S11_MESSAGE, - MME_EVT_S11_TIMER, - MME_EVT_S6A_MESSAGE, - MME_EVT_S6A_TIMER, - - MME_EVT_SGSAP_MESSAGE, - MME_EVT_SGSAP_TIMER, - MME_EVT_SGSAP_LO_SCTP_COMM_UP, - MME_EVT_SGSAP_LO_CONNREFUSED, + MME_EVENT_S1AP_MESSAGE, + MME_EVENT_S1AP_TIMER, + MME_EVENT_S1AP_LO_ACCEPT, + MME_EVENT_S1AP_LO_SCTP_COMM_UP, + MME_EVENT_S1AP_LO_CONNREFUSED, + + MME_EVENT_EMM_MESSAGE, + MME_EVENT_EMM_TIMER, + MME_EVENT_ESM_MESSAGE, + MME_EVENT_ESM_TIMER, + MME_EVENT_S11_MESSAGE, + MME_EVENT_S11_TIMER, + MME_EVENT_S6A_MESSAGE, + MME_EVENT_S6A_TIMER, + + MME_EVENT_SGSAP_MESSAGE, + MME_EVENT_SGSAP_TIMER, + MME_EVENT_SGSAP_LO_SCTP_COMM_UP, + MME_EVENT_SGSAP_LO_CONNREFUSED, - MME_EVT_TOP, + MAX_NUM_OF_MME_EVENT, } mme_event_e; @@ -69,9 +69,10 @@ typedef struct mme_event_s { int id; - ogs_pkbuf_t *pkbuf; int timer_id; + ogs_pkbuf_t *pkbuf; + ogs_sock_t *sock; ogs_sockaddr_t *addr;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/mme/mme-fd-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/mme/mme-fd-path.c
Changed
@@ -376,7 +376,7 @@ out: if (!error) { int rv; - e = mme_event_new(MME_EVT_S6A_MESSAGE); + e = mme_event_new(MME_EVENT_S6A_MESSAGE); ogs_assert(e); e->mme_ue = mme_ue; e->s6a_message = s6a_message; @@ -1344,7 +1344,7 @@ if (!error) { int rv; - e = mme_event_new(MME_EVT_S6A_MESSAGE); + e = mme_event_new(MME_EVENT_S6A_MESSAGE); ogs_assert(e); e->mme_ue = mme_ue; e->s6a_message = s6a_message; @@ -1501,7 +1501,7 @@ ogs_diam_logger_self()->stats.nb_echoed++; ogs_assert( pthread_mutex_unlock(&ogs_diam_logger_self()->stats_lock) == 0); - e = mme_event_new(MME_EVT_S6A_MESSAGE); + e = mme_event_new(MME_EVENT_S6A_MESSAGE); ogs_assert(e); e->mme_ue = mme_ue; e->s6a_message = s6a_message;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/mme/mme-gtp-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/mme/mme-gtp-path.c
Changed
@@ -61,7 +61,7 @@ } ogs_assert(sgw); - e = mme_event_new(MME_EVT_S11_MESSAGE); + e = mme_event_new(MME_EVENT_S11_MESSAGE); ogs_assert(e); e->gnode = (ogs_gtp_node_t *)sgw; e->pkbuf = pkbuf;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/mme/mme-init.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/mme/mme-init.c
Changed
@@ -114,8 +114,7 @@ ogs_fsm_t mme_sm; int rv; - ogs_fsm_create(&mme_sm, mme_state_initial, mme_state_final); - ogs_fsm_init(&mme_sm, 0); + ogs_fsm_init(&mme_sm, mme_state_initial, mme_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -154,5 +153,4 @@ done: ogs_fsm_fini(&mme_sm, 0); - ogs_fsm_delete(&mme_sm); }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/mme/mme-sm.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/mme/mme-sm.c
Changed
@@ -94,7 +94,7 @@ case OGS_FSM_EXIT_SIG: break; - case MME_EVT_S1AP_LO_ACCEPT: + case MME_EVENT_S1AP_LO_ACCEPT: sock = e->sock; ogs_assert(sock); addr = e->addr; @@ -120,7 +120,7 @@ break; - case MME_EVT_S1AP_LO_SCTP_COMM_UP: + case MME_EVENT_S1AP_LO_SCTP_COMM_UP: sock = e->sock; ogs_assert(sock); addr = e->addr; @@ -150,7 +150,7 @@ break; - case MME_EVT_S1AP_LO_CONNREFUSED: + case MME_EVENT_S1AP_LO_CONNREFUSED: sock = e->sock; ogs_assert(sock); addr = e->addr; @@ -172,7 +172,7 @@ ogs_free(addr); break; - case MME_EVT_S1AP_MESSAGE: + case MME_EVENT_S1AP_MESSAGE: sock = e->sock; ogs_assert(sock); addr = e->addr; @@ -206,7 +206,7 @@ ogs_pkbuf_free(pkbuf); break; - case MME_EVT_S1AP_TIMER: + case MME_EVENT_S1AP_TIMER: enb_ue = e->enb_ue; ogs_assert(enb_ue); @@ -233,7 +233,7 @@ } break; - case MME_EVT_EMM_MESSAGE: + case MME_EVENT_EMM_MESSAGE: enb_ue = e->enb_ue; ogs_assert(enb_ue); pkbuf = e->pkbuf; @@ -309,7 +309,7 @@ ogs_pkbuf_free(pkbuf); break; - case MME_EVT_EMM_TIMER: + case MME_EVENT_EMM_TIMER: mme_ue = e->mme_ue; ogs_assert(mme_ue); ogs_assert(OGS_FSM_STATE(&mme_ue->sm)); @@ -317,7 +317,7 @@ ogs_fsm_dispatch(&mme_ue->sm, e); break; - case MME_EVT_ESM_MESSAGE: + case MME_EVENT_ESM_MESSAGE: mme_ue = e->mme_ue; ogs_assert(mme_ue); @@ -376,7 +376,7 @@ ogs_pkbuf_free(pkbuf); break; - case MME_EVT_ESM_TIMER: + case MME_EVENT_ESM_TIMER: bearer = e->bearer; ogs_assert(bearer); ogs_assert(OGS_FSM_STATE(&bearer->sm)); @@ -384,7 +384,7 @@ ogs_fsm_dispatch(&bearer->sm, e); break; - case MME_EVT_S6A_MESSAGE: + case MME_EVENT_S6A_MESSAGE: mme_ue = e->mme_ue; ogs_assert(mme_ue); s6a_message = e->s6a_message; @@ -442,7 +442,7 @@ ogs_free(s6a_message); break; - case MME_EVT_S11_MESSAGE: + case MME_EVENT_S11_MESSAGE: pkbuf = e->pkbuf; ogs_assert(pkbuf); @@ -570,7 +570,7 @@ ogs_pkbuf_free(pkbuf); break; - case MME_EVT_S11_TIMER: + case MME_EVENT_S11_TIMER: sgw_ue = e->sgw_ue; ogs_assert(sgw_ue); mme_ue = sgw_ue->mme_ue; @@ -601,7 +601,7 @@ break; - case MME_EVT_SGSAP_LO_SCTP_COMM_UP: + case MME_EVENT_SGSAP_LO_SCTP_COMM_UP: sock = e->sock; ogs_assert(sock); addr = e->addr; @@ -628,7 +628,7 @@ ogs_fsm_dispatch(&vlr->sm, e); break; - case MME_EVT_SGSAP_LO_CONNREFUSED: + case MME_EVENT_SGSAP_LO_CONNREFUSED: sock = e->sock; ogs_assert(sock); addr = e->addr; @@ -656,7 +656,7 @@ } break; - case MME_EVT_SGSAP_MESSAGE: + case MME_EVENT_SGSAP_MESSAGE: sock = e->sock; ogs_assert(sock); addr = e->addr; @@ -679,7 +679,7 @@ ogs_pkbuf_free(pkbuf); break; - case MME_EVT_SGSAP_TIMER: + case MME_EVENT_SGSAP_TIMER: vlr = e->vlr; ogs_assert(vlr); ogs_assert(OGS_FSM_STATE(&vlr->sm));
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/mme/mme-timer.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/mme/mme-timer.c
Changed
@@ -24,40 +24,40 @@ static mme_timer_cfg_t g_mme_timer_cfgMAX_NUM_OF_MME_TIMER = { /* Paging procedure for EPS services initiated */ MME_TIMER_T3413 = - { .max_count = 2, .duration = ogs_time_from_sec(2) }, + { .have = true, .max_count = 2, .duration = ogs_time_from_sec(2) }, /* DETACH REQUEST sent */ MME_TIMER_T3422 = - { .max_count = 4, .duration = ogs_time_from_sec(3) }, + { .have = true, .max_count = 4, .duration = ogs_time_from_sec(3) }, /* ATTACH ACCEPT sent * TRACKING AREA UPDATE ACCEPT sent with GUTI * TRACKING AREA UPDATE ACCEPT sent with TMSI * GUTI REALLOCATION COMMAND sent */ MME_TIMER_T3450 = - { .max_count = 4, .duration = ogs_time_from_sec(6) }, + { .have = true, .max_count = 4, .duration = ogs_time_from_sec(6) }, /* AUTHENTICATION REQUEST sent * SECURITY MODE COMMAND sent */ MME_TIMER_T3460 = - { .max_count = 4, .duration = ogs_time_from_sec(3) }, + { .have = true, .max_count = 4, .duration = ogs_time_from_sec(3) }, /* IDENTITY REQUEST sent */ MME_TIMER_T3470 = - { .max_count = 4, .duration = ogs_time_from_sec(3) }, + { .have = true, .max_count = 4, .duration = ogs_time_from_sec(3) }, /* ESM INFORMATION REQUEST sent */ MME_TIMER_T3489 = - { .max_count = 2, .duration = ogs_time_from_sec(4) }, + { .have = true, .max_count = 2, .duration = ogs_time_from_sec(4) }, MME_TIMER_SGS_CLI_CONN_TO_SRV = - { .duration = ogs_time_from_sec(3) }, + { .have = true, .duration = ogs_time_from_sec(3) }, MME_TIMER_S1_HOLDING = - { .duration = ogs_time_from_sec(30) }, + { .have = true, .duration = ogs_time_from_sec(30) }, MME_TIMER_S11_HOLDING = - { .duration = ogs_time_from_msec(300) }, + { .have = true, .duration = ogs_time_from_msec(300) }, }; static void emm_timer_event_send( @@ -68,6 +68,10 @@ mme_timer_cfg_t *mme_timer_cfg(mme_timer_e id) { ogs_assert(id < MAX_NUM_OF_MME_TIMER); + if (g_mme_timer_cfgid.have != true) { + ogs_fatal("No timer%d configuration", id); + ogs_assert_if_reached(); + } return &g_mme_timer_cfgid; } @@ -125,7 +129,7 @@ mme_event_t *e = NULL; ogs_assert(mme_ue); - e = mme_event_new(MME_EVT_EMM_TIMER); + e = mme_event_new(MME_EVENT_EMM_TIMER); e->timer_id = timer_id; e->mme_ue = mme_ue; @@ -167,7 +171,7 @@ mme_ue = bearer->mme_ue; ogs_assert(bearer); - e = mme_event_new(MME_EVT_ESM_TIMER); + e = mme_event_new(MME_EVENT_ESM_TIMER); e->timer_id = timer_id; e->mme_ue = mme_ue; e->bearer = bearer; @@ -190,7 +194,7 @@ mme_event_t *e = NULL; ogs_assert(data); - e = mme_event_new(MME_EVT_SGSAP_TIMER); + e = mme_event_new(MME_EVENT_SGSAP_TIMER); e->timer_id = MME_TIMER_SGS_CLI_CONN_TO_SRV; e->vlr = data; @@ -210,7 +214,7 @@ ogs_assert(data); enb_ue = data; - e = mme_event_new(MME_EVT_S1AP_TIMER); + e = mme_event_new(MME_EVENT_S1AP_TIMER); e->timer_id = MME_TIMER_S1_HOLDING; e->enb_ue = enb_ue; @@ -231,7 +235,7 @@ ogs_assert(data); sgw_ue = data; - e = mme_event_new(MME_EVT_S11_TIMER); + e = mme_event_new(MME_EVENT_S11_TIMER); e->timer_id = MME_TIMER_S11_HOLDING; e->sgw_ue = sgw_ue;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/mme/mme-timer.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/mme/mme-timer.h
Changed
@@ -49,6 +49,7 @@ } mme_timer_e; typedef struct mme_timer_cfg_s { + bool have; int max_count; ogs_time_t duration; } mme_timer_cfg_t;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/mme/s1ap-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/mme/s1ap-path.c
Changed
@@ -95,7 +95,7 @@ if (duration) { mme_event_t *e = NULL; - e = mme_event_new(MME_EVT_S1AP_TIMER); + e = mme_event_new(MME_EVENT_S1AP_TIMER); ogs_assert(e); e->timer = ogs_timer_add( ogs_app()->timer_mgr, mme_timer_s1_delayed_send, e); @@ -125,7 +125,7 @@ ogs_assert(mme_ue); ogs_assert(esmbuf); - e = mme_event_new(MME_EVT_ESM_MESSAGE); + e = mme_event_new(MME_EVENT_ESM_MESSAGE); ogs_assert(e); e->mme_ue = mme_ue; e->pkbuf = esmbuf; @@ -209,7 +209,7 @@ ogs_assert(h); if (h->protocol_discriminator == OGS_NAS_PROTOCOL_DISCRIMINATOR_EMM) { int rv; - e = mme_event_new(MME_EVT_EMM_MESSAGE); + e = mme_event_new(MME_EVENT_EMM_MESSAGE); if (!e) { ogs_error("s1ap_send_to_nas() failed"); ogs_pkbuf_free(nasbuf);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/mme/s1ap-sctp.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/mme/s1ap-sctp.c
Changed
@@ -114,7 +114,7 @@ ogs_info("eNB-S1 accepted%s:%d in s1_path module", OGS_ADDR(addr, buf), OGS_PORT(addr)); - s1ap_event_push(MME_EVT_S1AP_LO_ACCEPT, new, addr, NULL, 0, 0); + s1ap_event_push(MME_EVENT_S1AP_LO_ACCEPT, new, addr, NULL, 0, 0); } else { ogs_log_message(OGS_LOG_ERROR, ogs_socket_errno, "accept() failed"); } @@ -164,7 +164,7 @@ ogs_assert(addr); memcpy(addr, &from, sizeof(ogs_sockaddr_t)); - s1ap_event_push(MME_EVT_S1AP_LO_SCTP_COMM_UP, + s1ap_event_push(MME_EVENT_S1AP_LO_SCTP_COMM_UP, sock, addr, NULL, not->sn_assoc_change.sac_inbound_streams, not->sn_assoc_change.sac_outbound_streams); @@ -180,7 +180,7 @@ ogs_assert(addr); memcpy(addr, &from, sizeof(ogs_sockaddr_t)); - s1ap_event_push(MME_EVT_S1AP_LO_CONNREFUSED, + s1ap_event_push(MME_EVENT_S1AP_LO_CONNREFUSED, sock, addr, NULL, 0, 0); } break; @@ -195,7 +195,7 @@ ogs_assert(addr); memcpy(addr, &from, sizeof(ogs_sockaddr_t)); - s1ap_event_push(MME_EVT_S1AP_LO_CONNREFUSED, + s1ap_event_push(MME_EVENT_S1AP_LO_CONNREFUSED, sock, addr, NULL, 0, 0); break; @@ -237,7 +237,7 @@ ogs_assert(addr); memcpy(addr, &from, sizeof(ogs_sockaddr_t)); - s1ap_event_push(MME_EVT_S1AP_MESSAGE, sock, addr, pkbuf, 0, 0); + s1ap_event_push(MME_EVENT_S1AP_MESSAGE, sock, addr, pkbuf, 0, 0); return; } else { if (ogs_socket_errno != OGS_EAGAIN) {
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/mme/s1ap-sm.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/mme/s1ap-sm.c
Changed
@@ -67,7 +67,7 @@ break; case OGS_FSM_EXIT_SIG: break; - case MME_EVT_S1AP_MESSAGE: + case MME_EVENT_S1AP_MESSAGE: pdu = e->s1ap_message; ogs_assert(pdu);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/mme/sgsap-conv.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/mme/sgsap-conv.h
Changed
@@ -20,7 +20,7 @@ #ifndef SGSAP_CONV_H #define SGSAP_CONV_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" {
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/mme/sgsap-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/mme/sgsap-path.c
Changed
@@ -34,8 +34,7 @@ memset(&e, 0, sizeof(e)); e.vlr = vlr; - ogs_fsm_create(&vlr->sm, sgsap_state_initial, sgsap_state_final); - ogs_fsm_init(&vlr->sm, &e); + ogs_fsm_init(&vlr->sm, sgsap_state_initial, sgsap_state_final, &e); } return OGS_OK; @@ -51,7 +50,6 @@ e.vlr = vlr; ogs_fsm_fini(&vlr->sm, &e); - ogs_fsm_delete(&vlr->sm); } }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/mme/sgsap-sctp.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/mme/sgsap-sctp.c
Changed
@@ -126,7 +126,7 @@ ogs_assert(addr); memcpy(addr, &from, sizeof(ogs_sockaddr_t)); - sgsap_event_push(MME_EVT_SGSAP_LO_SCTP_COMM_UP, + sgsap_event_push(MME_EVENT_SGSAP_LO_SCTP_COMM_UP, sock, addr, NULL, not->sn_assoc_change.sac_inbound_streams, not->sn_assoc_change.sac_outbound_streams); @@ -142,7 +142,7 @@ ogs_assert(addr); memcpy(addr, &from, sizeof(ogs_sockaddr_t)); - sgsap_event_push(MME_EVT_SGSAP_LO_CONNREFUSED, + sgsap_event_push(MME_EVENT_SGSAP_LO_CONNREFUSED, sock, addr, NULL, 0, 0); } break; @@ -170,7 +170,7 @@ ogs_assert(addr); memcpy(addr, &from, sizeof(ogs_sockaddr_t)); - sgsap_event_push(MME_EVT_SGSAP_LO_CONNREFUSED, + sgsap_event_push(MME_EVENT_SGSAP_LO_CONNREFUSED, sock, addr, NULL, 0, 0); break; case SCTP_PEER_ADDR_CHANGE: @@ -197,7 +197,7 @@ ogs_assert(addr); memcpy(addr, &from, sizeof(ogs_sockaddr_t)); - sgsap_event_push(MME_EVT_SGSAP_MESSAGE, sock, addr, pkbuf, 0, 0); + sgsap_event_push(MME_EVENT_SGSAP_MESSAGE, sock, addr, pkbuf, 0, 0); return; } else { ogs_fatal("Invalid flag(0x%x)", flags);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/mme/sgsap-sm.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/mme/sgsap-sm.c
Changed
@@ -84,7 +84,7 @@ case OGS_FSM_EXIT_SIG: ogs_timer_stop(vlr->t_conn); break; - case MME_EVT_SGSAP_TIMER: + case MME_EVENT_SGSAP_TIMER: switch(e->timer_id) { case MME_TIMER_SGS_CLI_CONN_TO_SRV: vlr = e->vlr; @@ -108,7 +108,7 @@ break; } break; - case MME_EVT_SGSAP_LO_SCTP_COMM_UP: + case MME_EVENT_SGSAP_LO_SCTP_COMM_UP: OGS_FSM_TRAN(s, sgsap_state_connected); break; default: @@ -135,11 +135,11 @@ break; case OGS_FSM_EXIT_SIG: break; - case MME_EVT_SGSAP_LO_CONNREFUSED: + case MME_EVENT_SGSAP_LO_CONNREFUSED: mme_vlr_close(vlr); OGS_FSM_TRAN(s, sgsap_state_will_connect); break; - case MME_EVT_SGSAP_MESSAGE: + case MME_EVENT_SGSAP_MESSAGE: pkbuf = e->pkbuf; ogs_assert(pkbuf); type = *(unsigned char *)(pkbuf->data);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/nrf/context.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/nrf/context.c
Changed
@@ -47,7 +47,7 @@ ogs_list_for_each_safe( &ogs_sbi_self()->nf_instance_list, next_nf_instance, nf_instance) - nrf_nf_fsm_fini(nf_instance); + if (OGS_FSM_STATE(&nf_instance->sm)) nrf_nf_fsm_fini(nf_instance); context_initialized = 0; }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/nrf/event.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/nrf/event.h
Changed
@@ -20,7 +20,7 @@ #ifndef NRF_EVENT_H #define NRF_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { @@ -33,7 +33,7 @@ typedef struct ogs_sbi_subscription_s ogs_sbi_subscription_t; typedef enum { - NRF_EVT_BASE = OGS_FSM_USER_SIG, + NRF_EVT_BASE = OGS_MAX_NUM_OF_PROTO_EVENT, NRF_EVT_SBI_SERVER, NRF_EVT_SBI_CLIENT,
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/nrf/init.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/nrf/init.c
Changed
@@ -94,8 +94,7 @@ ogs_fsm_t nrf_sm; int rv; - ogs_fsm_create(&nrf_sm, nrf_state_initial, nrf_state_final); - ogs_fsm_init(&nrf_sm, 0); + ogs_fsm_init(&nrf_sm, nrf_state_initial, nrf_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -134,5 +133,4 @@ done: ogs_fsm_fini(&nrf_sm, 0); - ogs_fsm_delete(&nrf_sm); }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/nrf/nf-sm.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/nrf/nf-sm.c
Changed
@@ -30,9 +30,8 @@ memset(&e, 0, sizeof(e)); e.nf_instance = nf_instance; - ogs_fsm_create(&nf_instance->sm, - nrf_nf_state_initial, nrf_nf_state_final); - ogs_fsm_init(&nf_instance->sm, &e); + ogs_fsm_init(&nf_instance->sm, + nrf_nf_state_initial, nrf_nf_state_final, &e); } void nrf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance) @@ -44,7 +43,6 @@ e.nf_instance = nf_instance; ogs_fsm_fini(&nf_instance->sm, &e); - ogs_fsm_delete(&nf_instance->sm); } void nrf_nf_state_initial(ogs_fsm_t *s, nrf_event_t *e)
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/nrf/nnrf-handler.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/nrf/nnrf-handler.c
Changed
@@ -23,7 +23,6 @@ ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) { int status; - bool handled; ogs_sbi_response_t *response = NULL; OpenAPI_nf_profile_t *NFProfile = NULL; @@ -46,9 +45,7 @@ nf_instance->nf_profile, NFProfile); /* ogs_sbi_nnrf_handle_nf_profile() sends error response */ - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, stream, recvmsg); - if (!handled) return false; + ogs_sbi_nnrf_handle_nf_profile(nf_instance, NFProfile, stream, recvmsg); if (OGS_FSM_CHECK(&nf_instance->sm, nrf_nf_state_will_register)) { recvmsg->http.location = recvmsg->h.uri;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/nrf/sbi-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/nrf/sbi-path.c
Changed
@@ -93,13 +93,6 @@ client->cb = client_notify_cb; } - /* Timer expiration handler of client wait timer */ - ogs_sbi_self()->client_wait_expire = nrf_timer_sbi_client_wait_expire; - - /* NF register state in NF state machine */ - ogs_sbi_self()->nf_state_registered = - (ogs_fsm_handler_t)nrf_nf_state_registered; - if (ogs_sbi_server_start_all(server_cb) != OGS_OK) return OGS_ERROR;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/nrf/timer.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/nrf/timer.c
Changed
@@ -19,16 +19,6 @@ #include "context.h" -static nrf_timer_cfg_t g_nrf_timer_cfgMAX_NUM_OF_NRF_TIMER = { - /* Nothing */ -}; - -nrf_timer_cfg_t *nrf_timer_cfg(nrf_timer_e id) -{ - ogs_assert(id < MAX_NUM_OF_NRF_TIMER); - return &g_nrf_timer_cfgid; -} - const char *nrf_timer_get_name(nrf_timer_e id) { switch (id) { @@ -82,8 +72,3 @@ { timer_send_event(NRF_TIMER_SUBSCRIPTION_VALIDITY, data); } - -void nrf_timer_sbi_client_wait_expire(void *data) -{ - timer_send_event(NRF_TIMER_SBI_CLIENT_WAIT, data); -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/nrf/timer.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/nrf/timer.h
Changed
@@ -38,18 +38,10 @@ } nrf_timer_e; -typedef struct nrf_timer_cfg_s { - int max_count; - ogs_time_t duration; -} nrf_timer_cfg_t; - -nrf_timer_cfg_t *nrf_timer_cfg(nrf_timer_e id); - const char *nrf_timer_get_name(nrf_timer_e id); void nrf_timer_nf_instance_no_heartbeat(void *data); void nrf_timer_subscription_validity(void *data); -void nrf_timer_sbi_client_wait_expire(void *data); #ifdef __cplusplus }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/nssf/context.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/nssf/context.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. *
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/nssf/context.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/nssf/context.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -24,7 +24,6 @@ #include "ogs-sbi.h" #include "nssf-sm.h" -#include "timer.h" #ifdef __cplusplus extern "C" { @@ -41,22 +40,6 @@ ogs_list_t nsi_list; /* NSI List */ } nssf_context_t; -#define NSSF_NF_INSTANCE_CLEAR(_cAUSE, _nFInstance) \ - do { \ - ogs_assert(_nFInstance); \ - if ((_nFInstance)->reference_count == 1) { \ - ogs_info("%s (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ - nssf_nf_fsm_fini((_nFInstance)); \ - ogs_sbi_nf_instance_remove(_nFInstance); \ - } else { \ - /* There is an assocation with other context */ \ - ogs_info("%s:%d (%s) NF suspended", \ - _nFInstance->id, _nFInstance->reference_count, (_cAUSE)); \ - OGS_FSM_TRAN(&_nFInstance->sm, nssf_nf_state_de_registered); \ - ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ - } \ - } while(0) - void nssf_context_init(void); void nssf_context_final(void); nssf_context_t *nssf_self(void);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/nssf/event.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/nssf/event.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -18,60 +18,42 @@ */ #include "event.h" -#include "context.h" -static OGS_POOL(pool, nssf_event_t); - -void nssf_event_init(void) -{ - ogs_pool_init(&pool, ogs_app()->pool.event); -} - -void nssf_event_final(void) -{ - ogs_pool_final(&pool); -} - -nssf_event_t *nssf_event_new(nssf_event_e id) +nssf_event_t *nssf_event_new(int id) { nssf_event_t *e = NULL; - ogs_pool_alloc(&pool, &e); + e = ogs_event_size(id, sizeof(nssf_event_t)); ogs_assert(e); - memset(e, 0, sizeof(*e)); - e->id = id; + e->h.id = id; return e; } -void nssf_event_free(nssf_event_t *e) -{ - ogs_assert(e); - ogs_pool_free(&pool, e); -} - const char *nssf_event_get_name(nssf_event_t *e) { - if (e == NULL) + if (e == NULL) { return OGS_FSM_NAME_INIT_SIG; + } - switch (e->id) { - case OGS_FSM_ENTRY_SIG: + switch (e->h.id) { + case OGS_FSM_ENTRY_SIG: return OGS_FSM_NAME_ENTRY_SIG; - case OGS_FSM_EXIT_SIG: + case OGS_FSM_EXIT_SIG: return OGS_FSM_NAME_EXIT_SIG; - case NSSF_EVT_SBI_SERVER: - return "NSSF_EVT_SBI_SERVER"; - case NSSF_EVT_SBI_CLIENT: - return "NSSF_EVT_SBI_CLIENT"; - case NSSF_EVT_SBI_TIMER: - return "NSSF_EVT_SBI_TIMER"; + case OGS_EVENT_SBI_SERVER: + return OGS_EVENT_NAME_SBI_SERVER; + case OGS_EVENT_SBI_CLIENT: + return OGS_EVENT_NAME_SBI_CLIENT; + case OGS_EVENT_SBI_TIMER: + return OGS_EVENT_NAME_SBI_TIMER; - default: - break; + default: + break; } + ogs_error("Unknown Event%d", e->h.id); return "UNKNOWN_EVENT"; }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/nssf/event.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/nssf/event.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,49 +20,19 @@ #ifndef NSSF_EVENT_H #define NSSF_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { #endif -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_nf_instance_s ogs_sbi_nf_instance_t; -typedef struct ogs_sbi_subscription_s ogs_sbi_subscription_t; - -typedef enum { - NSSF_EVT_BASE = OGS_FSM_USER_SIG, - - NSSF_EVT_SBI_SERVER, - NSSF_EVT_SBI_CLIENT, - NSSF_EVT_SBI_TIMER, - - NSSF_EVT_TOP, - -} nssf_event_e; +typedef struct nssf_ue_s nssf_ue_t; typedef struct nssf_event_s { - int id; - int timer_id; - - struct { - ogs_sbi_request_t *request; - ogs_sbi_response_t *response; - void *data; - - ogs_sbi_message_t *message; - } sbi; - - ogs_timer_t *timer; + ogs_event_t h; } nssf_event_t; -void nssf_event_init(void); -void nssf_event_final(void); - -nssf_event_t *nssf_event_new(nssf_event_e id); -void nssf_event_free(nssf_event_t *e); +nssf_event_t *nssf_event_new(int id); const char *nssf_event_get_name(nssf_event_t *e);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/nssf/init.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/nssf/init.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -30,7 +30,6 @@ ogs_sbi_context_init(); nssf_context_init(); - nssf_event_init(); rv = ogs_sbi_context_parse_config("nssf", "nrf", "scp"); if (rv != OGS_OK) return rv; @@ -61,7 +60,7 @@ /* Sending NF Instance De-registeration to NRF */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) - nssf_nf_fsm_fini(nf_instance); + ogs_sbi_nf_fsm_fini(nf_instance); /* Starting holding timer */ t_termination_holding = ogs_timer_add(ogs_app()->timer_mgr, NULL, NULL); @@ -87,8 +86,6 @@ nssf_context_final(); ogs_sbi_context_final(); - - nssf_event_final(); /* Destroy event */ } static void nssf_main(void *data) @@ -96,8 +93,7 @@ ogs_fsm_t nssf_sm; int rv; - ogs_fsm_create(&nssf_sm, nssf_state_initial, nssf_state_final); - ogs_fsm_init(&nssf_sm, 0); + ogs_fsm_init(&nssf_sm, nssf_state_initial, nssf_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -130,11 +126,10 @@ ogs_assert(e); ogs_fsm_dispatch(&nssf_sm, e); - nssf_event_free(e); + ogs_event_free(e); } } done: ogs_fsm_fini(&nssf_sm, 0); - ogs_fsm_delete(&nssf_sm); }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/nssf/meson.build -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/nssf/meson.build
Changed
@@ -1,4 +1,4 @@ -# Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> +# Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> # This file is part of Open5GS. @@ -18,11 +18,6 @@ libnssf_sources = files(''' context.c event.c - timer.c - - nnrf-build.c - nnrf-handler.c - nf-sm.c nnssf-handler.c
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/nssf/nssf-sm.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/nssf/nssf-sm.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -54,17 +54,17 @@ ogs_assert(s); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case NSSF_EVT_SBI_SERVER: - request = e->sbi.request; + case OGS_EVENT_SBI_SERVER: + request = e->h.sbi.request; ogs_assert(request); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); rv = ogs_sbi_parse_request(&message, request); @@ -138,10 +138,10 @@ ogs_sbi_message_free(&message); break; - case NSSF_EVT_SBI_CLIENT: + case OGS_EVENT_SBI_CLIENT: ogs_assert(e); - response = e->sbi.response; + response = e->h.sbi.response; ogs_assert(response); rv = ogs_sbi_parse_response(&message, response); if (rv != OGS_OK) { @@ -163,23 +163,23 @@ SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - nf_instance = e->sbi.data; + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&nf_instance->sm, e); break; CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS) - subscription = e->sbi.data; + subscription = e->h.sbi.data; ogs_assert(subscription); SWITCH(message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) if (message.res_status == OGS_SBI_HTTP_STATUS_CREATED || message.res_status == OGS_SBI_HTTP_STATUS_OK) { - nssf_nnrf_handle_nf_status_subscribe( + ogs_nnrf_handle_nf_status_subscribe( subscription, &message); } else { ogs_error("%s HTTP response error %d", @@ -220,27 +220,27 @@ ogs_sbi_response_free(response); break; - case NSSF_EVT_SBI_TIMER: + case OGS_EVENT_SBI_TIMER: ogs_assert(e); - switch(e->timer_id) { - case NSSF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case NSSF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case NSSF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case NSSF_TIMER_NF_INSTANCE_VALIDITY: - nf_instance = e->sbi.data; + switch(e->h.timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + case OGS_TIMER_NF_INSTANCE_VALIDITY: + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); ogs_fsm_dispatch(&nf_instance->sm, e); - if (OGS_FSM_CHECK(&nf_instance->sm, nssf_nf_state_exception)) + if (OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_exception)) ogs_error("%s:%s State machine exception %d", OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id, e->timer_id); + nf_instance->id, e->h.timer_id); break; - case NSSF_TIMER_SUBSCRIPTION_VALIDITY: - subscription = e->sbi.data; + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + subscription = e->h.sbi.data; ogs_assert(subscription); ogs_assert(ogs_sbi_self()->nf_instance); @@ -256,7 +256,7 @@ default: ogs_error("Unknown timer%s:%d", - nssf_timer_get_name(e->timer_id), e->timer_id); + ogs_timer_get_name(e->h.timer_id), e->h.timer_id); } break;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/nssf/nssf-sm.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/nssf/nssf-sm.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -30,16 +30,6 @@ void nssf_state_final(ogs_fsm_t *s, nssf_event_t *e); void nssf_state_operational(ogs_fsm_t *s, nssf_event_t *e); -void nssf_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance); -void nssf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance); - -void nssf_nf_state_initial(ogs_fsm_t *s, nssf_event_t *e); -void nssf_nf_state_final(ogs_fsm_t *s, nssf_event_t *e); -void nssf_nf_state_will_register(ogs_fsm_t *s, nssf_event_t *e); -void nssf_nf_state_registered(ogs_fsm_t *s, nssf_event_t *e); -void nssf_nf_state_de_registered(ogs_fsm_t *s, nssf_event_t *e); -void nssf_nf_state_exception(ogs_fsm_t *s, nssf_event_t *e); - #define nssf_sm_debug(__pe) \ ogs_debug("%s(): %s", __func__, nssf_event_get_name(__pe))
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/nssf/sbi-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/nssf/sbi-path.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -27,17 +27,17 @@ ogs_assert(request); ogs_assert(data); - e = nssf_event_new(NSSF_EVT_SBI_SERVER); + e = nssf_event_new(OGS_EVENT_SBI_SERVER); ogs_assert(e); - e->sbi.request = request; - e->sbi.data = data; + e->h.sbi.request = request; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_request_free(request); - nssf_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -58,16 +58,16 @@ ogs_assert(response); - e = nssf_event_new(NSSF_EVT_SBI_CLIENT); + e = nssf_event_new(OGS_EVENT_SBI_CLIENT); ogs_assert(e); - e->sbi.response = response; - e->sbi.data = data; + e->h.sbi.response = response; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_response_free(response); - nssf_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -99,28 +99,20 @@ } /* Initialize NRF NF Instance */ - ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_sbi_client_t *client = NULL; - - /* Client callback is only used when NF sends to NRF */ - client = nf_instance->client; - ogs_assert(client); - client->cb = client_cb; - - /* NFRegister is sent and the response is received - * by the above client callback. */ - nssf_nf_fsm_init(nf_instance); - } + nf_instance = ogs_sbi_self()->nrf_instance; + if (nf_instance) { + ogs_sbi_client_t *client = NULL; + + /* Client callback is only used when NF sends to NRF */ + client = nf_instance->client; + ogs_assert(client); + client->cb = client_cb; + + /* NFRegister is sent and the response is received + * by the above client callback. */ + ogs_sbi_nf_fsm_init(nf_instance); } - /* Timer expiration handler of client wait timer */ - ogs_sbi_self()->client_wait_expire = nssf_timer_sbi_client_wait_expire; - - /* NF register state in NF state machine */ - ogs_sbi_self()->nf_state_registered = - (ogs_fsm_handler_t)nssf_nf_state_registered; - if (ogs_sbi_server_start_all(server_cb) != OGS_OK) return OGS_ERROR;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/nssf/sbi-path.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/nssf/sbi-path.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,7 +20,7 @@ #ifndef NSSF_SBI_PATH_H #define NSSF_SBI_PATH_H -#include "nnrf-build.h" +#include "context.h" #ifdef __cplusplus extern "C" {
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/pcf/am-sm.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/pcf/am-sm.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -50,17 +50,17 @@ pcf_ue = e->pcf_ue; ogs_assert(pcf_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case PCF_EVT_SBI_SERVER: - message = e->sbi.message; + case OGS_EVENT_SBI_SERVER: + message = e->h.sbi.message; ogs_assert(message); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); SWITCH(message->h.method) @@ -88,10 +88,10 @@ END break; - case PCF_EVT_SBI_CLIENT: - message = e->sbi.message; + case OGS_EVENT_SBI_CLIENT: + message = e->h.sbi.message; ogs_assert(message); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); SWITCH(message->h.service.name) @@ -161,7 +161,7 @@ pcf_ue = e->pcf_ue; ogs_assert(pcf_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; @@ -185,7 +185,7 @@ pcf_ue = e->pcf_ue; ogs_assert(pcf_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/pcf/context.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/pcf/context.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -159,8 +159,7 @@ memset(&e, 0, sizeof(e)); e.pcf_ue = pcf_ue; - ogs_fsm_create(&pcf_ue->sm, pcf_am_state_initial, pcf_am_state_final); - ogs_fsm_init(&pcf_ue->sm, &e); + ogs_fsm_init(&pcf_ue->sm, pcf_am_state_initial, pcf_am_state_final, &e); ogs_list_add(&self.pcf_ue_list, pcf_ue); @@ -178,7 +177,6 @@ memset(&e, 0, sizeof(e)); e.pcf_ue = pcf_ue; ogs_fsm_fini(&pcf_ue->sm, &e); - ogs_fsm_delete(&pcf_ue->sm); /* Free SBI object memory */ ogs_sbi_object_free(&pcf_ue->sbi); @@ -270,8 +268,7 @@ memset(&e, 0, sizeof(e)); e.sess = sess; - ogs_fsm_create(&sess->sm, pcf_sm_state_initial, pcf_sm_state_final); - ogs_fsm_init(&sess->sm, &e); + ogs_fsm_init(&sess->sm, pcf_sm_state_initial, pcf_sm_state_final, &e); ogs_list_add(&pcf_ue->sess_list, sess); @@ -290,7 +287,6 @@ memset(&e, 0, sizeof(e)); e.sess = sess; ogs_fsm_fini(&sess->sm, &e); - ogs_fsm_delete(&sess->sm); /* Free SBI object memory */ ogs_sbi_object_free(&sess->sbi);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/pcf/context.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/pcf/context.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -26,7 +26,6 @@ #include "ogs-dbi.h" #include "pcf-sm.h" -#include "timer.h" #ifdef __cplusplus extern "C" { @@ -47,22 +46,6 @@ ogs_hash_t *ipv6prefix_hash; } pcf_context_t; -#define PCF_NF_INSTANCE_CLEAR(_cAUSE, _nFInstance) \ - do { \ - ogs_assert(_nFInstance); \ - if ((_nFInstance)->reference_count == 1) { \ - ogs_info("%s (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ - pcf_nf_fsm_fini((_nFInstance)); \ - ogs_sbi_nf_instance_remove(_nFInstance); \ - } else { \ - /* There is an assocation with other context */ \ - ogs_info("%s:%d (%s) NF suspended", \ - _nFInstance->id, _nFInstance->reference_count, (_cAUSE)); \ - OGS_FSM_TRAN(&_nFInstance->sm, pcf_nf_state_de_registered); \ - ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ - } \ - } while(0) - struct pcf_ue_s { ogs_sbi_object_t sbi; ogs_fsm_t sm;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/pcf/event.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/pcf/event.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -18,60 +18,42 @@ */ #include "event.h" -#include "context.h" -static OGS_POOL(pool, pcf_event_t); - -void pcf_event_init(void) -{ - ogs_pool_init(&pool, ogs_app()->pool.event); -} - -void pcf_event_final(void) -{ - ogs_pool_final(&pool); -} - -pcf_event_t *pcf_event_new(pcf_event_e id) +pcf_event_t *pcf_event_new(int id) { pcf_event_t *e = NULL; - ogs_pool_alloc(&pool, &e); + e = ogs_event_size(id, sizeof(pcf_event_t)); ogs_assert(e); - memset(e, 0, sizeof(*e)); - e->id = id; + e->h.id = id; return e; } -void pcf_event_free(pcf_event_t *e) -{ - ogs_assert(e); - ogs_pool_free(&pool, e); -} - const char *pcf_event_get_name(pcf_event_t *e) { - if (e == NULL) + if (e == NULL) { return OGS_FSM_NAME_INIT_SIG; + } - switch (e->id) { - case OGS_FSM_ENTRY_SIG: + switch (e->h.id) { + case OGS_FSM_ENTRY_SIG: return OGS_FSM_NAME_ENTRY_SIG; - case OGS_FSM_EXIT_SIG: + case OGS_FSM_EXIT_SIG: return OGS_FSM_NAME_EXIT_SIG; - case PCF_EVT_SBI_SERVER: - return "PCF_EVT_SBI_SERVER"; - case PCF_EVT_SBI_CLIENT: - return "PCF_EVT_SBI_CLIENT"; - case PCF_EVT_SBI_TIMER: - return "PCF_EVT_SBI_TIMER"; + case OGS_EVENT_SBI_SERVER: + return OGS_EVENT_NAME_SBI_SERVER; + case OGS_EVENT_SBI_CLIENT: + return OGS_EVENT_NAME_SBI_CLIENT; + case OGS_EVENT_SBI_TIMER: + return OGS_EVENT_NAME_SBI_TIMER; - default: - break; + default: + break; } + ogs_error("Unknown Event%d", e->h.id); return "UNKNOWN_EVENT"; }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/pcf/event.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/pcf/event.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,57 +20,25 @@ #ifndef PCF_EVENT_H #define PCF_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { #endif -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_nf_instance_s ogs_sbi_nf_instance_t; -typedef struct ogs_sbi_subscription_s ogs_sbi_subscription_t; - typedef struct pcf_ue_s pcf_ue_t; typedef struct pcf_sess_s pcf_sess_t; typedef struct pcf_app_s pcf_app_t; -typedef enum { - PCF_EVT_BASE = OGS_FSM_USER_SIG, - - PCF_EVT_SBI_SERVER, - PCF_EVT_SBI_CLIENT, - PCF_EVT_SBI_TIMER, - - PCF_EVT_TOP, - -} pcf_event_e; - typedef struct pcf_event_s { - int id; - int timer_id; - - struct { - ogs_sbi_request_t *request; - ogs_sbi_response_t *response; - void *data; - - ogs_sbi_message_t *message; - } sbi; + ogs_event_t h; pcf_ue_t *pcf_ue; pcf_sess_t *sess; pcf_app_t *app; - - ogs_timer_t *timer; } pcf_event_t; -void pcf_event_init(void); -void pcf_event_final(void); - -pcf_event_t *pcf_event_new(pcf_event_e id); -void pcf_event_free(pcf_event_t *e); +pcf_event_t *pcf_event_new(int id); const char *pcf_event_get_name(pcf_event_t *e);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/pcf/init.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/pcf/init.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -30,7 +30,6 @@ ogs_sbi_context_init(); pcf_context_init(); - pcf_event_init(); rv = ogs_sbi_context_parse_config("pcf", "nrf", "scp"); if (rv != OGS_OK) return rv; @@ -64,7 +63,7 @@ /* Sending NF Instance De-registeration to NRF */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) - pcf_nf_fsm_fini(nf_instance); + ogs_sbi_nf_fsm_fini(nf_instance); /* Starting holding timer */ t_termination_holding = ogs_timer_add(ogs_app()->timer_mgr, NULL, NULL); @@ -92,8 +91,6 @@ pcf_context_final(); ogs_sbi_context_final(); - - pcf_event_final(); /* Destroy event */ } static void pcf_main(void *data) @@ -101,8 +98,7 @@ ogs_fsm_t pcf_sm; int rv; - ogs_fsm_create(&pcf_sm, pcf_state_initial, pcf_state_final); - ogs_fsm_init(&pcf_sm, 0); + ogs_fsm_init(&pcf_sm, pcf_state_initial, pcf_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -135,11 +131,10 @@ ogs_assert(e); ogs_fsm_dispatch(&pcf_sm, e); - pcf_event_free(e); + ogs_event_free(e); } } done: ogs_fsm_fini(&pcf_sm, 0); - ogs_fsm_delete(&pcf_sm); }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/pcf/meson.build -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/pcf/meson.build
Changed
@@ -1,4 +1,4 @@ -# Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> +# Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> # This file is part of Open5GS. @@ -18,12 +18,8 @@ libpcf_sources = files(''' context.c event.c - timer.c - nnrf-build.c nnrf-handler.c - nf-sm.c - npcf-handler.c nudr-build.c
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/pcf/nbsf-build.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/pcf/nbsf-build.c
Changed
@@ -36,10 +36,6 @@ ogs_sbi_nf_service_t *nf_service = NULL; int i; -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - int fqdn_len; - char fqdnOGS_MAX_FQDN_LEN; -#endif ogs_assert(sess); pcf_ue = sess->pcf_ue; @@ -68,18 +64,8 @@ nf_service = ogs_list_first(&nf_instance->nf_service_list); ogs_expect_or_return_val(nf_service, NULL); - if (nf_service->fqdn) { -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - memset(fqdn, 0, sizeof(fqdn)); - fqdn_len = ogs_fqdn_build(fqdn, - nf_service->fqdn, strlen(nf_service->fqdn)); - PcfBinding.pcf_fqdn = ogs_memdup(fqdn, fqdn_len+1); - ogs_expect_or_return_val(PcfBinding.pcf_fqdn, NULL); - PcfBinding.pcf_fqdnfqdn_len = 0; -#else + if (nf_service->fqdn) PcfBinding.pcf_fqdn = ogs_strdup(nf_service->fqdn); -#endif - } PcfIpEndPointList = OpenAPI_list_create(); ogs_assert(PcfIpEndPointList);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/pcf/nnrf-handler.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/pcf/nnrf-handler.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,233 +20,6 @@ #include "sbi-path.h" #include "nnrf-handler.h" -void pcf_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_nf_profile_t *NFProfile = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(nf_instance); - client = nf_instance->client; - ogs_assert(client); - - NFProfile = recvmsg->NFProfile; - if (!NFProfile) { - ogs_error("No NFProfile"); - return; - } - - /* TIME : Update heartbeat from NRF */ - if (NFProfile->is_heart_beat_timer == true) - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; -} - -void pcf_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_subscription_data_t *SubscriptionData = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(subscription); - client = subscription->client; - ogs_assert(client); - - SubscriptionData = recvmsg->SubscriptionData; - if (!SubscriptionData) { - ogs_error("No SubscriptionData"); - return; - } - - if (!SubscriptionData->subscription_id) { - ogs_error("No SubscriptionId"); - return; - } - ogs_sbi_subscription_set_id( - subscription, SubscriptionData->subscription_id); - - if (SubscriptionData->validity_time) { -#define VALIDITY_MINIMUM (10LL * OGS_USEC_PER_SEC) /* 10 seconds */ - ogs_time_t time, duration; - if (ogs_sbi_time_from_string( - &time, SubscriptionData->validity_time) == true) { - duration = time - ogs_time_now(); - if (duration < VALIDITY_MINIMUM) { - duration = VALIDITY_MINIMUM; - ogs_warn("%s Forced to %lld seconds", subscription->id, - (long long)ogs_time_sec(VALIDITY_MINIMUM)); - } - subscription->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - pcf_timer_subscription_validity, subscription); - ogs_assert(subscription->t_validity); - ogs_timer_start(subscription->t_validity, duration); - } else { - ogs_error("Cannot parse validitiyTime %s", - SubscriptionData->validity_time); - } - } -} - -bool pcf_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) -{ - int rv; - bool handled; - - ogs_sbi_response_t *response = NULL; - OpenAPI_notification_data_t *NotificationData = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_header_t header; - - ogs_assert(stream); - ogs_assert(recvmsg); - - NotificationData = recvmsg->NotificationData; - if (!NotificationData) { - ogs_error("No NotificationData"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NotificationData", NULL)); - return false; - } - - if (!NotificationData->nf_instance_uri) { - ogs_error("No nfInstanceUri"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No nfInstanceUri", NULL)); - return false; - } - - memset(&header, 0, sizeof(header)); - header.uri = NotificationData->nf_instance_uri; - - rv = ogs_sbi_parse_header(&message, &header); - if (rv != OGS_OK) { - ogs_error("Cannot parse nfInstanceUri %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - return false; - } - - if (!message.h.resource.component1) { - ogs_error("No nfInstanceId %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - ogs_sbi_header_free(&header); - return false; - } - - if (NF_INSTANCE_IS_SELF(message.h.resource.component1)) { - ogs_warn("%s The notification is not allowed", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_FORBIDDEN, - recvmsg, "The notification is not allowed", - message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - - if (NotificationData->event == - OpenAPI_notification_event_type_NF_REGISTERED) { - - OpenAPI_nf_profile_t *NFProfile = NULL; - - NFProfile = NotificationData->nf_profile; - if (!NFProfile) { - ogs_error("No NFProfile"); - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NFProfile", NULL)); - ogs_sbi_header_free(&header); - return false; - } - - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, - message.h.resource.component1); - - pcf_nf_fsm_init(nf_instance); - - ogs_info("%s (NRF-notify) NF registered", nf_instance->id); - - } else { - OGS_FSM_TRAN(&nf_instance->sm, pcf_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NRF-notify) NF has already been added", - message.h.resource.component1); - - } - - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, stream, recvmsg); - if (!handled) { - PCF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - ogs_info("%s (NRF-notify) NF Profile updated", nf_instance->id); - - handled = ogs_sbi_client_associate(nf_instance); - if (!handled) { - ogs_error("%s Cannot associate NF EndPoint", nf_instance->id); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot find NF EndPoint", nf_instance->id)); - PCF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - } else if (NotificationData->event == - OpenAPI_notification_event_type_NF_DEREGISTERED) { - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (nf_instance) { - PCF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - } else { - ogs_warn("%s (NRF-notify) Not found", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_NOT_FOUND, - recvmsg, "Not found", message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - } else { - char *eventstr = OpenAPI_notification_event_type_ToString( - NotificationData->event); - ogs_error("Not supported event %d:%s", - NotificationData->event, eventstr ? eventstr : "Unknown"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Not supported event", - eventstr ? eventstr : "Unknown")); - ogs_sbi_header_free(&header); - return false; - } - - response = ogs_sbi_build_response(recvmsg, OGS_SBI_HTTP_STATUS_NO_CONTENT); - ogs_assert(response); - ogs_assert(true == ogs_sbi_server_send_response(stream, response)); - - ogs_sbi_header_free(&header); - return true; -} - void pcf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { @@ -254,11 +27,7 @@ OpenAPI_nf_type_e target_nf_type = 0; ogs_sbi_discovery_option_t *discovery_option = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; - OpenAPI_search_result_t *SearchResult = NULL; - OpenAPI_lnode_t *node = NULL; - bool handled; ogs_assert(recvmsg); ogs_assert(xact); @@ -275,64 +44,8 @@ return; } - OpenAPI_list_for_each(SearchResult->nf_instances, node) { - OpenAPI_nf_profile_t *NFProfile = NULL; - - if (!node->data) continue; - - NFProfile = node->data; - - nf_instance = ogs_sbi_nf_instance_find(NFProfile->nf_instance_id); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id); - - pcf_nf_fsm_init(nf_instance); - - ogs_info("%s (NF-discover) NF registered", nf_instance->id); - } else { - OGS_FSM_TRAN(&nf_instance->sm, pcf_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NF-discover) NF has already been added", - NFProfile->nf_instance_id); - } - - if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) { - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, NULL, NULL); - if (!handled) { - ogs_error("%s ogs_sbi_nnrf_handle_nf_profile() failed", - nf_instance->id); - PCF_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); - continue; - } - - handled = ogs_sbi_client_associate(nf_instance); - if (!handled) { - ogs_error("%s Cannot assciate NF EndPoint", nf_instance->id); - PCF_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); - continue; - } - - /* TIME : Update validity from NRF */ - if (SearchResult->is_validity_period && - SearchResult->validity_period) { - nf_instance->time.validity_duration = - SearchResult->validity_period; - - ogs_assert(nf_instance->t_validity); - ogs_timer_start(nf_instance->t_validity, - ogs_time_from_sec(nf_instance->time.validity_duration)); - - } else - ogs_warn("%s NF Instance validity-time should not 0", - nf_instance->id); - - ogs_info("%s (NF-discover) NF Profile updated", nf_instance->id); - } - } + ogs_nnrf_handle_nf_discover_search_result( + sbi_object, target_nf_type, discovery_option, SearchResult); ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/pcf/nnrf-handler.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/pcf/nnrf-handler.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -26,14 +26,6 @@ extern "C" { #endif -void pcf_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg); -void pcf_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg); - -bool pcf_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); - void pcf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/pcf/pcf-sm.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/pcf/pcf-sm.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -59,17 +59,17 @@ ogs_assert(s); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case PCF_EVT_SBI_SERVER: - request = e->sbi.request; + case OGS_EVENT_SBI_SERVER: + request = e->h.sbi.request; ogs_assert(request); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); rv = ogs_sbi_parse_request(&message, request); @@ -100,7 +100,7 @@ CASE(OGS_SBI_RESOURCE_NAME_NF_STATUS_NOTIFY) SWITCH(message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) - pcf_nnrf_handle_nf_status_notify(stream, &message); + ogs_nnrf_handle_nf_status_notify(stream, &message); break; DEFAULT @@ -160,7 +160,7 @@ ogs_assert(OGS_FSM_STATE(&pcf_ue->sm)); e->pcf_ue = pcf_ue; - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&pcf_ue->sm, e); if (OGS_FSM_CHECK(&pcf_ue->sm, pcf_am_state_exception)) { ogs_error("%s State machine exception", pcf_ue->supi); @@ -214,7 +214,7 @@ ogs_assert(OGS_FSM_STATE(&sess->sm)); e->sess = sess; - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&sess->sm, e); if (OGS_FSM_CHECK(&sess->sm, pcf_sm_state_exception)) { ogs_error("%s:%d State machine exception", @@ -265,7 +265,7 @@ e->sess = sess; e->app = app_session; - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&sess->sm, e); if (OGS_FSM_CHECK(&sess->sm, pcf_sm_state_exception)) { ogs_error("%s:%d State machine exception", @@ -286,10 +286,10 @@ ogs_sbi_message_free(&message); break; - case PCF_EVT_SBI_CLIENT: + case OGS_EVENT_SBI_CLIENT: ogs_assert(e); - response = e->sbi.response; + response = e->h.sbi.response; ogs_assert(response); rv = ogs_sbi_parse_response(&message, response); if (rv != OGS_OK) { @@ -311,23 +311,23 @@ SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - nf_instance = e->sbi.data; + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&nf_instance->sm, e); break; CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS) - subscription = e->sbi.data; + subscription = e->h.sbi.data; ogs_assert(subscription); SWITCH(message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) if (message.res_status == OGS_SBI_HTTP_STATUS_CREATED || message.res_status == OGS_SBI_HTTP_STATUS_OK) { - pcf_nnrf_handle_nf_status_subscribe( + ogs_nnrf_handle_nf_status_subscribe( subscription, &message); } else { ogs_error("%s HTTP response error %d", @@ -362,7 +362,7 @@ CASE(OGS_SBI_SERVICE_NAME_NNRF_DISC) SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); SWITCH(message.h.method) @@ -392,7 +392,7 @@ CASE(OGS_SBI_RESOURCE_NAME_POLICY_DATA) SWITCH(message.h.resource.component3) CASE(OGS_SBI_RESOURCE_NAME_AM_DATA) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); sbi_xact = ogs_sbi_xact_cycle(sbi_xact); @@ -406,7 +406,7 @@ pcf_ue = (pcf_ue_t *)sbi_xact->sbi_object; ogs_assert(pcf_ue); - e->sbi.data = sbi_xact->assoc_stream; + e->h.sbi.data = sbi_xact->assoc_stream; ogs_sbi_xact_remove(sbi_xact); @@ -418,7 +418,7 @@ } e->pcf_ue = pcf_ue; - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&pcf_ue->sm, e); if (OGS_FSM_CHECK(&pcf_ue->sm, pcf_am_state_exception)) { @@ -428,7 +428,7 @@ break; CASE(OGS_SBI_RESOURCE_NAME_SM_DATA) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); sbi_xact = ogs_sbi_xact_cycle(sbi_xact); @@ -442,7 +442,7 @@ sess = (pcf_sess_t *)sbi_xact->sbi_object; ogs_assert(sess); - e->sbi.data = sbi_xact->assoc_stream; + e->h.sbi.data = sbi_xact->assoc_stream; ogs_sbi_xact_remove(sbi_xact); @@ -458,7 +458,7 @@ ogs_assert(pcf_ue); e->sess = sess; - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&sess->sm, e); if (OGS_FSM_CHECK(&sess->sm, pcf_sm_state_exception)) { @@ -487,7 +487,7 @@ SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_PCF_BINDINGS) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); sbi_xact = ogs_sbi_xact_cycle(sbi_xact); @@ -501,7 +501,7 @@ sess = (pcf_sess_t *)sbi_xact->sbi_object; ogs_assert(sess); - e->sbi.data = sbi_xact->assoc_stream; + e->h.sbi.data = sbi_xact->assoc_stream; ogs_sbi_xact_remove(sbi_xact); @@ -517,7 +517,7 @@ ogs_assert(pcf_ue); e->sess = sess; - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&sess->sm, e); if (OGS_FSM_CHECK(&sess->sm, pcf_sm_state_exception)) { @@ -547,27 +547,27 @@ ogs_sbi_response_free(response); break; - case PCF_EVT_SBI_TIMER: + case OGS_EVENT_SBI_TIMER: ogs_assert(e); - switch(e->timer_id) { - case PCF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case PCF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case PCF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case PCF_TIMER_NF_INSTANCE_VALIDITY: - nf_instance = e->sbi.data; + switch(e->h.timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + case OGS_TIMER_NF_INSTANCE_VALIDITY: + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); ogs_fsm_dispatch(&nf_instance->sm, e); - if (OGS_FSM_CHECK(&nf_instance->sm, pcf_nf_state_exception)) + if (OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_exception)) ogs_error("%s:%s State machine exception %d", OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id, e->timer_id); + nf_instance->id, e->h.timer_id); break; - case PCF_TIMER_SUBSCRIPTION_VALIDITY: - subscription = e->sbi.data; + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + subscription = e->h.sbi.data; ogs_assert(subscription); ogs_assert(ogs_sbi_self()->nf_instance); @@ -581,8 +581,8 @@ ogs_sbi_subscription_remove(subscription); break; - case PCF_TIMER_SBI_CLIENT_WAIT: - sbi_xact = e->sbi.data; + case OGS_TIMER_SBI_CLIENT_WAIT: + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); sbi_object = sbi_xact->sbi_object; @@ -636,7 +636,7 @@ default: ogs_error("Unknown timer%s:%d", - pcf_timer_get_name(e->timer_id), e->timer_id); + ogs_timer_get_name(e->h.timer_id), e->h.timer_id); } break;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/pcf/pcf-sm.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/pcf/pcf-sm.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -30,16 +30,6 @@ void pcf_state_final(ogs_fsm_t *s, pcf_event_t *e); void pcf_state_operational(ogs_fsm_t *s, pcf_event_t *e); -void pcf_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance); -void pcf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance); - -void pcf_nf_state_initial(ogs_fsm_t *s, pcf_event_t *e); -void pcf_nf_state_final(ogs_fsm_t *s, pcf_event_t *e); -void pcf_nf_state_will_register(ogs_fsm_t *s, pcf_event_t *e); -void pcf_nf_state_registered(ogs_fsm_t *s, pcf_event_t *e); -void pcf_nf_state_de_registered(ogs_fsm_t *s, pcf_event_t *e); -void pcf_nf_state_exception(ogs_fsm_t *s, pcf_event_t *e); - void pcf_am_state_initial(ogs_fsm_t *s, pcf_event_t *e); void pcf_am_state_final(ogs_fsm_t *s, pcf_event_t *e); void pcf_am_state_operational(ogs_fsm_t *s, pcf_event_t *e);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/pcf/sbi-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/pcf/sbi-path.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -27,17 +27,17 @@ ogs_assert(request); ogs_assert(data); - e = pcf_event_new(PCF_EVT_SBI_SERVER); + e = pcf_event_new(OGS_EVENT_SBI_SERVER); ogs_assert(e); - e->sbi.request = request; - e->sbi.data = data; + e->h.sbi.request = request; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_request_free(request); - pcf_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -58,16 +58,16 @@ ogs_assert(response); - e = pcf_event_new(PCF_EVT_SBI_CLIENT); + e = pcf_event_new(OGS_EVENT_SBI_CLIENT); ogs_assert(e); - e->sbi.response = response; - e->sbi.data = data; + e->h.sbi.response = response; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_response_free(response); - pcf_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -79,6 +79,11 @@ ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_nf_service_t *service = NULL; + /* To be notified when NF Instances registered/deregistered in NRF + * or when their profile is modified */ + ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_BSF); + ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_UDR); + /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); @@ -125,27 +130,19 @@ } /* Initialize NRF NF Instance */ - ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_sbi_client_t *client = NULL; - - /* Client callback is only used when NF sends to NRF */ - client = nf_instance->client; - ogs_assert(client); - client->cb = client_cb; - - /* NFRegister is sent and the response is received - * by the above client callback. */ - pcf_nf_fsm_init(nf_instance); - } - } - - /* Timer expiration handler of client wait timer */ - ogs_sbi_self()->client_wait_expire = pcf_timer_sbi_client_wait_expire; - - /* NF register state in NF state machine */ - ogs_sbi_self()->nf_state_registered = - (ogs_fsm_handler_t)pcf_nf_state_registered; + nf_instance = ogs_sbi_self()->nrf_instance; + if (nf_instance) { + ogs_sbi_client_t *client = NULL; + + /* Client callback is only used when NF sends to NRF */ + client = nf_instance->client; + ogs_assert(client); + client->cb = client_cb; + + /* NFRegister is sent and the response is received + * by the above client callback. */ + ogs_sbi_nf_fsm_init(nf_instance); + } if (ogs_sbi_server_start_all(server_cb) != OGS_OK) return OGS_ERROR;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/pcf/sbi-path.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/pcf/sbi-path.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,7 +20,6 @@ #ifndef PCF_SBI_PATH_H #define PCF_SBI_PATH_H -#include "nnrf-build.h" #include "nudr-build.h" #include "nbsf-build.h" #include "namf-build.h"
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/pcf/sm-sm.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/pcf/sm-sm.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -54,17 +54,17 @@ pcf_ue = sess->pcf_ue; ogs_assert(pcf_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case PCF_EVT_SBI_SERVER: - message = e->sbi.message; + case OGS_EVENT_SBI_SERVER: + message = e->h.sbi.message; ogs_assert(message); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); SWITCH(message->h.service.name) @@ -158,10 +158,10 @@ END break; - case PCF_EVT_SBI_CLIENT: - message = e->sbi.message; + case OGS_EVENT_SBI_CLIENT: + message = e->h.sbi.message; ogs_assert(message); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); SWITCH(message->h.service.name) @@ -285,7 +285,7 @@ pcf_ue = sess->pcf_ue; ogs_assert(pcf_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; @@ -314,7 +314,7 @@ pcf_ue = sess->pcf_ue; ogs_assert(pcf_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/scp/context.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/scp/context.h
Changed
@@ -23,7 +23,6 @@ #include "ogs-sbi.h" #include "ogs-app.h" -#include "timer.h" #include "scp-sm.h" #ifdef __cplusplus @@ -39,22 +38,6 @@ ogs_list_t conn_list; } scp_context_t; -#define SCP_NF_INSTANCE_CLEAR(_cAUSE, _nFInstance) \ - do { \ - ogs_assert(_nFInstance); \ - if ((_nFInstance)->reference_count == 1) { \ - ogs_info("%s (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ - scp_nf_fsm_fini((_nFInstance)); \ - ogs_sbi_nf_instance_remove(_nFInstance); \ - } else { \ - /* There is an assocation with other context */ \ - ogs_info("%s:%d (%s) NF suspended", \ - _nFInstance->id, _nFInstance->reference_count, (_cAUSE)); \ - OGS_FSM_TRAN(&_nFInstance->sm, scp_nf_state_de_registered); \ - ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ - } \ - } while(0) - typedef struct scp_conn_s scp_conn_t; typedef struct scp_conn_s {
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/scp/event.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/scp/event.c
Changed
@@ -18,60 +18,42 @@ */ #include "event.h" -#include "context.h" -static OGS_POOL(pool, scp_event_t); - -void scp_event_init(void) -{ - ogs_pool_init(&pool, ogs_app()->pool.event); -} - -void scp_event_final(void) -{ - ogs_pool_final(&pool); -} - -scp_event_t *scp_event_new(scp_event_e id) +scp_event_t *scp_event_new(int id) { scp_event_t *e = NULL; - ogs_pool_alloc(&pool, &e); + e = ogs_event_size(id, sizeof(scp_event_t)); ogs_assert(e); - memset(e, 0, sizeof(*e)); - e->id = id; + e->h.id = id; return e; } -void scp_event_free(scp_event_t *e) -{ - ogs_assert(e); - ogs_pool_free(&pool, e); -} - const char *scp_event_get_name(scp_event_t *e) { - if (e == NULL) + if (e == NULL) { return OGS_FSM_NAME_INIT_SIG; + } - switch (e->id) { - case OGS_FSM_ENTRY_SIG: + switch (e->h.id) { + case OGS_FSM_ENTRY_SIG: return OGS_FSM_NAME_ENTRY_SIG; - case OGS_FSM_EXIT_SIG: + case OGS_FSM_EXIT_SIG: return OGS_FSM_NAME_EXIT_SIG; - case SCP_EVT_SBI_SERVER: - return "SCP_EVT_SBI_SERVER"; - case SCP_EVT_SBI_CLIENT: - return "SCP_EVT_SBI_CLIENT"; - case SCP_EVT_SBI_TIMER: - return "SCP_EVT_SBI_TIMER"; + case OGS_EVENT_SBI_SERVER: + return OGS_EVENT_NAME_SBI_SERVER; + case OGS_EVENT_SBI_CLIENT: + return OGS_EVENT_NAME_SBI_CLIENT; + case OGS_EVENT_SBI_TIMER: + return OGS_EVENT_NAME_SBI_TIMER; - default: - break; + default: + break; } + ogs_error("Unknown Event%d", e->h.id); return "UNKNOWN_EVENT"; }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/scp/event.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/scp/event.h
Changed
@@ -20,52 +20,23 @@ #ifndef SCP_EVENT_H #define SCP_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { #endif typedef struct scp_sess_s scp_sess_t; -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_nf_instance_s ogs_sbi_nf_instance_t; -typedef enum { - SCP_EVT_BASE = OGS_FSM_USER_SIG, - - SCP_EVT_SBI_SERVER, - SCP_EVT_SBI_CLIENT, - SCP_EVT_SBI_TIMER, - - SCP_EVT_TOP, - -} scp_event_e; - typedef struct scp_event_s { - int id; - ogs_pkbuf_t *pkbuf; - int timer_id; - - struct { - ogs_sbi_request_t *request; - ogs_sbi_response_t *response; - void *data; - int state; - - ogs_sbi_message_t *message; - } sbi; + ogs_event_t h; ogs_sbi_nf_instance_t *nf_instance; scp_sess_t *sess; } scp_event_t; -void scp_event_init(void); -void scp_event_final(void); - -scp_event_t *scp_event_new(scp_event_e id); -void scp_event_free(scp_event_t *e); +scp_event_t *scp_event_new(int id); const char *scp_event_get_name(scp_event_t *e);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/scp/init.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/scp/init.c
Changed
@@ -32,7 +32,6 @@ ogs_sbi_context_init(); scp_context_init(); - scp_event_init(); rv = ogs_sbi_context_parse_config("scp", "nrf", "next_scp"); if (rv != OGS_OK) return rv; @@ -63,7 +62,7 @@ /* Sending NF Instance De-registeration to NRF */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) - scp_nf_fsm_fini(nf_instance); + ogs_sbi_nf_fsm_fini(nf_instance); /* Starting holding timer */ t_termination_holding = ogs_timer_add(ogs_app()->timer_mgr, NULL, NULL); @@ -88,10 +87,7 @@ scp_sbi_close(); scp_context_final(); - ogs_sbi_context_final(); - - scp_event_final(); /* Destroy event */ } static void scp_main(void *data) @@ -99,8 +95,7 @@ ogs_fsm_t scp_sm; int rv; - ogs_fsm_create(&scp_sm, scp_state_initial, scp_state_final); - ogs_fsm_init(&scp_sm, 0); + ogs_fsm_init(&scp_sm, scp_state_initial, scp_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -133,11 +128,10 @@ ogs_assert(e); ogs_fsm_dispatch(&scp_sm, e); - scp_event_free(e); + ogs_event_free(e); } } done: ogs_fsm_fini(&scp_sm, 0); - ogs_fsm_delete(&scp_sm); }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/scp/meson.build -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/scp/meson.build
Changed
@@ -18,12 +18,8 @@ libscp_sources = files(''' context.c event.c - timer.c - nnrf-build.c nnrf-handler.c - nf-sm.c - nscp-handler.c sbi-path.c
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/scp/nnrf-handler.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/scp/nnrf-handler.c
Changed
@@ -20,233 +20,6 @@ #include "sbi-path.h" #include "nnrf-handler.h" -void scp_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_nf_profile_t *NFProfile = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(nf_instance); - client = nf_instance->client; - ogs_assert(client); - - NFProfile = recvmsg->NFProfile; - if (!NFProfile) { - ogs_error("No NFProfile"); - return; - } - - /* TIME : Update heartbeat from NRF */ - if (NFProfile->is_heart_beat_timer == true) - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; -} - -void scp_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_subscription_data_t *SubscriptionData = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(subscription); - client = subscription->client; - ogs_assert(client); - - SubscriptionData = recvmsg->SubscriptionData; - if (!SubscriptionData) { - ogs_error("No SubscriptionData"); - return; - } - - if (!SubscriptionData->subscription_id) { - ogs_error("No SubscriptionId"); - return; - } - ogs_sbi_subscription_set_id( - subscription, SubscriptionData->subscription_id); - - if (SubscriptionData->validity_time) { -#define VALIDITY_MINIMUM (10LL * OGS_USEC_PER_SEC) /* 10 seconds */ - ogs_time_t time, duration; - if (ogs_sbi_time_from_string( - &time, SubscriptionData->validity_time) == true) { - duration = time - ogs_time_now(); - if (duration < VALIDITY_MINIMUM) { - duration = VALIDITY_MINIMUM; - ogs_warn("%s Forced to %lld seconds", subscription->id, - (long long)ogs_time_sec(VALIDITY_MINIMUM)); - } - subscription->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - scp_timer_subscription_validity, subscription); - ogs_assert(subscription->t_validity); - ogs_timer_start(subscription->t_validity, duration); - } else { - ogs_error("Cannot parse validitiyTime %s", - SubscriptionData->validity_time); - } - } -} - -bool scp_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) -{ - int rv; - bool handled; - - ogs_sbi_response_t *response = NULL; - OpenAPI_notification_data_t *NotificationData = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_header_t header; - - ogs_assert(stream); - ogs_assert(recvmsg); - - NotificationData = recvmsg->NotificationData; - if (!NotificationData) { - ogs_error("No NotificationData"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NotificationData", NULL)); - return false; - } - - if (!NotificationData->nf_instance_uri) { - ogs_error("No nfInstanceUri"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No nfInstanceUri", NULL)); - return false; - } - - memset(&header, 0, sizeof(header)); - header.uri = NotificationData->nf_instance_uri; - - rv = ogs_sbi_parse_header(&message, &header); - if (rv != OGS_OK) { - ogs_error("Cannot parse nfInstanceUri %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - return false; - } - - if (!message.h.resource.component1) { - ogs_error("No nfInstanceId %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - ogs_sbi_header_free(&header); - return false; - } - - if (NF_INSTANCE_IS_SELF(message.h.resource.component1)) { - ogs_warn("%s The notification is not allowed", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_FORBIDDEN, - recvmsg, "The notification is not allowed", - message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - - if (NotificationData->event == - OpenAPI_notification_event_type_NF_REGISTERED) { - - OpenAPI_nf_profile_t *NFProfile = NULL; - - NFProfile = NotificationData->nf_profile; - if (!NFProfile) { - ogs_error("No NFProfile"); - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NFProfile", NULL)); - ogs_sbi_header_free(&header); - return false; - } - - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, - message.h.resource.component1); - - scp_nf_fsm_init(nf_instance); - - ogs_info("%s (NRF-notify) NF registered", nf_instance->id); - - } else { - OGS_FSM_TRAN(&nf_instance->sm, scp_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NRF-notify) NF has already been added", - message.h.resource.component1); - - } - - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, stream, recvmsg); - if (!handled) { - SCP_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - ogs_info("%s (NRF-notify) NF Profile updated", nf_instance->id); - - handled = ogs_sbi_client_associate(nf_instance); - if (!handled) { - ogs_error("%s Cannot associate NF EndPoint", nf_instance->id); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot find NF EndPoint", nf_instance->id)); - SCP_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - } else if (NotificationData->event == - OpenAPI_notification_event_type_NF_DEREGISTERED) { - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (nf_instance) { - SCP_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - } else { - ogs_warn("%s (NRF-notify) Not found", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_NOT_FOUND, - recvmsg, "Not found", message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - } else { - char *eventstr = OpenAPI_notification_event_type_ToString( - NotificationData->event); - ogs_error("Not supported event %d:%s", - NotificationData->event, eventstr ? eventstr : "Unknown"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Not supported event", - eventstr ? eventstr : "Unknown")); - ogs_sbi_header_free(&header); - return false; - } - - response = ogs_sbi_build_response(recvmsg, OGS_SBI_HTTP_STATUS_NO_CONTENT); - ogs_assert(response); - ogs_assert(true == ogs_sbi_server_send_response(stream, response)); - - ogs_sbi_header_free(&header); - return true; -} - void scp_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { @@ -256,8 +29,6 @@ ogs_sbi_nf_instance_t *nf_instance = NULL; OpenAPI_search_result_t *SearchResult = NULL; - OpenAPI_lnode_t *node = NULL; - bool handled; ogs_assert(recvmsg); ogs_assert(xact); @@ -274,64 +45,8 @@ return; } - OpenAPI_list_for_each(SearchResult->nf_instances, node) { - OpenAPI_nf_profile_t *NFProfile = NULL; - - if (!node->data) continue; - - NFProfile = node->data; - - nf_instance = ogs_sbi_nf_instance_find(NFProfile->nf_instance_id); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id); - - scp_nf_fsm_init(nf_instance); - - ogs_info("%s (NF-discover) NF registered", nf_instance->id); - } else { - OGS_FSM_TRAN(&nf_instance->sm, scp_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NF-discover) NF has already been added", - NFProfile->nf_instance_id); - } - - if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) { - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, NULL, NULL); - if (!handled) { - ogs_error("ogs_sbi_nnrf_handle_nf_profile() failed %s", - nf_instance->id); - SCP_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); - continue; - } - - handled = ogs_sbi_client_associate(nf_instance); - if (!handled) { - ogs_error("%s Cannot assciate NF EndPoint", nf_instance->id); - SCP_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); - continue; - } - - /* TIME : Update validity from NRF */ - if (SearchResult->is_validity_period && - SearchResult->validity_period) { - nf_instance->time.validity_duration = - SearchResult->validity_period; - - ogs_assert(nf_instance->t_validity); - ogs_timer_start(nf_instance->t_validity, - ogs_time_from_sec(nf_instance->time.validity_duration)); - - } else - ogs_warn("%s NF Instance validity-time should not 0", - nf_instance->id); - - ogs_info("%s (NF-discover) NF Profile updated", nf_instance->id); - } - } + ogs_nnrf_handle_nf_discover_search_result( + sbi_object, target_nf_type, discovery_option, SearchResult); ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/scp/nnrf-handler.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/scp/nnrf-handler.h
Changed
@@ -26,14 +26,6 @@ extern "C" { #endif -void scp_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg); -void scp_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg); - -bool scp_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); - void scp_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/scp/sbi-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/scp/sbi-path.c
Changed
@@ -29,6 +29,17 @@ { ogs_sbi_nf_instance_t *nf_instance = NULL; + /* To be notified when NF Instances registered/deregistered in NRF + * or when their profile is modified */ + ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_AMF); + ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_AUSF); + ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_BSF); + ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_NSSF); + ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_PCF); + ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_SMF); + ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_UDM); + ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_UDR); + /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); @@ -59,16 +70,9 @@ /* NFRegister is sent and the response is received * by the above client callback. */ - scp_nf_fsm_init(nf_instance); + ogs_sbi_nf_fsm_init(nf_instance); } - /* Timer expiration handler of client wait timer */ - ogs_sbi_self()->client_wait_expire = scp_timer_sbi_client_wait_expire; - - /* NF register state in NF state machine */ - ogs_sbi_self()->nf_state_registered = - (ogs_fsm_handler_t)scp_nf_state_registered; - if (ogs_sbi_server_start_all(request_handler) != OGS_OK) return OGS_ERROR; @@ -259,17 +263,17 @@ } else if (headers.discovery) { scp_event_t *e = NULL; - e = scp_event_new(SCP_EVT_SBI_SERVER); + e = scp_event_new(OGS_EVENT_SBI_SERVER); ogs_assert(e); - e->sbi.request = source; - e->sbi.data = stream; + e->h.sbi.request = source; + e->h.sbi.data = stream; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_request_free(source); - scp_event_free(e); + ogs_event_free(e); return OGS_ERROR; } } else { @@ -279,17 +283,17 @@ ogs_assert(source); ogs_assert(data); - e = scp_event_new(SCP_EVT_SBI_SERVER); + e = scp_event_new(OGS_EVENT_SBI_SERVER); ogs_assert(e); - e->sbi.request = source; - e->sbi.data = data; + e->h.sbi.request = source; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_request_free(source); - scp_event_free(e); + ogs_event_free(e); return OGS_ERROR; } } @@ -344,16 +348,16 @@ ogs_assert(response); - e = scp_event_new(SCP_EVT_SBI_CLIENT); + e = scp_event_new(OGS_EVENT_SBI_CLIENT); ogs_assert(e); - e->sbi.response = response; - e->sbi.data = data; + e->h.sbi.response = response; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_response_free(response); - scp_event_free(e); + ogs_event_free(e); return OGS_ERROR; }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/scp/sbi-path.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/scp/sbi-path.h
Changed
@@ -20,7 +20,7 @@ #ifndef SCP_SBI_PATH_H #define SCP_SBI_PATH_H -#include "nnrf-build.h" +#include "context.h" #ifdef __cplusplus extern "C" {
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/scp/scp-sm.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/scp/scp-sm.c
Changed
@@ -54,17 +54,17 @@ ogs_assert(s); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case SCP_EVT_SBI_SERVER: - request = e->sbi.request; + case OGS_EVENT_SBI_SERVER: + request = e->h.sbi.request; ogs_assert(request); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); rv = ogs_sbi_parse_request(&message, request); @@ -95,7 +95,7 @@ CASE(OGS_SBI_RESOURCE_NAME_NF_STATUS_NOTIFY) SWITCH(message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) - scp_nnrf_handle_nf_status_notify(stream, &message); + ogs_nnrf_handle_nf_status_notify(stream, &message); break; DEFAULT @@ -195,10 +195,10 @@ ogs_sbi_message_free(&message); break; - case SCP_EVT_SBI_CLIENT: + case OGS_EVENT_SBI_CLIENT: ogs_assert(e); - response = e->sbi.response; + response = e->h.sbi.response; ogs_assert(response); rv = ogs_sbi_parse_response(&message, response); if (rv != OGS_OK) { @@ -220,23 +220,23 @@ SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - nf_instance = e->sbi.data; + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&nf_instance->sm, e); break; CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS) - subscription = e->sbi.data; + subscription = e->h.sbi.data; ogs_assert(subscription); SWITCH(message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) if (message.res_status == OGS_SBI_HTTP_STATUS_CREATED || message.res_status == OGS_SBI_HTTP_STATUS_OK) { - scp_nnrf_handle_nf_status_subscribe( + ogs_nnrf_handle_nf_status_subscribe( subscription, &message); } else { ogs_error("HTTP response error : %d", @@ -269,7 +269,7 @@ CASE(OGS_SBI_SERVICE_NAME_NNRF_DISC) SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); SWITCH(message.h.method) @@ -303,27 +303,27 @@ ogs_sbi_response_free(response); break; - case SCP_EVT_SBI_TIMER: + case OGS_EVENT_SBI_TIMER: ogs_assert(e); - switch(e->timer_id) { - case SCP_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case SCP_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case SCP_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case SCP_TIMER_NF_INSTANCE_VALIDITY: - nf_instance = e->sbi.data; + switch(e->h.timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + case OGS_TIMER_NF_INSTANCE_VALIDITY: + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); ogs_fsm_dispatch(&nf_instance->sm, e); - if (OGS_FSM_CHECK(&nf_instance->sm, scp_nf_state_exception)) + if (OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_exception)) ogs_error("%s:%s State machine exception %d", OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id, e->timer_id); + nf_instance->id, e->h.timer_id); break; - case SCP_TIMER_SUBSCRIPTION_VALIDITY: - subscription = e->sbi.data; + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + subscription = e->h.sbi.data; ogs_assert(subscription); ogs_assert(ogs_sbi_self()->nf_instance); @@ -337,8 +337,8 @@ ogs_sbi_subscription_remove(subscription); break; - case SCP_TIMER_SBI_CLIENT_WAIT: - sbi_xact = e->sbi.data; + case OGS_TIMER_SBI_CLIENT_WAIT: + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); stream = sbi_xact->assoc_stream; @@ -358,7 +358,7 @@ default: ogs_error("Unknown timer%s:%d", - scp_timer_get_name(e->timer_id), e->timer_id); + ogs_timer_get_name(e->h.timer_id), e->h.timer_id); } break;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/scp/scp-sm.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/scp/scp-sm.h
Changed
@@ -31,16 +31,6 @@ void scp_state_operational(ogs_fsm_t *s, scp_event_t *e); void scp_state_exception(ogs_fsm_t *s, scp_event_t *e); -void scp_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance); -void scp_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance); - -void scp_nf_state_initial(ogs_fsm_t *s, scp_event_t *e); -void scp_nf_state_final(ogs_fsm_t *s, scp_event_t *e); -void scp_nf_state_will_register(ogs_fsm_t *s, scp_event_t *e); -void scp_nf_state_registered(ogs_fsm_t *s, scp_event_t *e); -void scp_nf_state_de_registered(ogs_fsm_t *s, scp_event_t *e); -void scp_nf_state_exception(ogs_fsm_t *s, scp_event_t *e); - #define scp_sm_debug(__pe) \ ogs_debug("%s(): %s", __func__, scp_event_get_name(__pe))
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/sgwc/event.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/sgwc/event.h
Changed
@@ -20,7 +20,7 @@ #ifndef SGWC_EVENT_H #define SGWC_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { @@ -34,7 +34,7 @@ typedef struct sgwc_bearer_s sgwc_bearer_t; typedef enum { - SGWC_EVT_BASE = OGS_FSM_USER_SIG, + SGWC_EVT_BASE = OGS_MAX_NUM_OF_PROTO_EVENT, SGWC_EVT_S11_MESSAGE, SGWC_EVT_S5C_MESSAGE, @@ -49,9 +49,10 @@ typedef struct sgwc_event_s { int id; - ogs_pkbuf_t *pkbuf; int timer_id; + ogs_pkbuf_t *pkbuf; + ogs_gtp_node_t *gnode; ogs_gtp2_message_t *gtp_message;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/sgwc/init.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/sgwc/init.c
Changed
@@ -97,8 +97,7 @@ ogs_fsm_t sgwc_sm; int rv; - ogs_fsm_create(&sgwc_sm, sgwc_state_initial, sgwc_state_final); - ogs_fsm_init(&sgwc_sm, 0); + ogs_fsm_init(&sgwc_sm, sgwc_state_initial, sgwc_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -137,5 +136,4 @@ done: ogs_fsm_fini(&sgwc_sm, 0); - ogs_fsm_delete(&sgwc_sm); }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/sgwc/pfcp-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/sgwc/pfcp-path.c
Changed
@@ -34,8 +34,7 @@ ogs_assert(node->t_association); } - ogs_fsm_create(&node->sm, sgwc_pfcp_state_initial, sgwc_pfcp_state_final); - ogs_fsm_init(&node->sm, &e); + ogs_fsm_init(&node->sm, sgwc_pfcp_state_initial, sgwc_pfcp_state_final, &e); } static void pfcp_node_fsm_fini(ogs_pfcp_node_t *node) @@ -48,7 +47,6 @@ e.pfcp_node = node; ogs_fsm_fini(&node->sm, &e); - ogs_fsm_delete(&node->sm); if (node->t_association) ogs_timer_delete(node->t_association);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/sgwu/event.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/sgwu/event.h
Changed
@@ -20,7 +20,7 @@ #ifndef SGWU_EVENT_H #define SGWU_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { @@ -33,7 +33,7 @@ typedef struct sgwu_bearer_s sgwu_bearer_t; typedef enum { - SGWU_EVT_BASE = OGS_FSM_USER_SIG, + SGWU_EVT_BASE = OGS_MAX_NUM_OF_PROTO_EVENT, SGWU_EVT_SXA_MESSAGE, SGWU_EVT_SXA_TIMER, @@ -45,9 +45,10 @@ typedef struct sgwu_event_s { int id; - ogs_pkbuf_t *pkbuf; int timer_id; + ogs_pkbuf_t *pkbuf; + ogs_gtp_node_t *gnode; ogs_pfcp_node_t *pfcp_node;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/sgwu/init.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/sgwu/init.c
Changed
@@ -94,8 +94,7 @@ ogs_fsm_t sgwu_sm; int rv; - ogs_fsm_create(&sgwu_sm, sgwu_state_initial, sgwu_state_final); - ogs_fsm_init(&sgwu_sm, 0); + ogs_fsm_init(&sgwu_sm, sgwu_state_initial, sgwu_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -134,5 +133,4 @@ done: ogs_fsm_fini(&sgwu_sm, 0); - ogs_fsm_delete(&sgwu_sm); }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/sgwu/pfcp-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/sgwu/pfcp-path.c
Changed
@@ -34,8 +34,7 @@ ogs_assert(node->t_association); } - ogs_fsm_create(&node->sm, sgwu_pfcp_state_initial, sgwu_pfcp_state_final); - ogs_fsm_init(&node->sm, &e); + ogs_fsm_init(&node->sm, sgwu_pfcp_state_initial, sgwu_pfcp_state_final, &e); } static void pfcp_node_fsm_fini(ogs_pfcp_node_t *node) @@ -48,7 +47,6 @@ e.pfcp_node = node; ogs_fsm_fini(&node->sm, &e); - ogs_fsm_delete(&node->sm); if (node->t_association) ogs_timer_delete(node->t_association);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/context.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/smf/context.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -1111,8 +1111,7 @@ memset(&e, 0, sizeof(e)); e.sess = sess; - ogs_fsm_create(&sess->sm, smf_gsm_state_initial, smf_gsm_state_final); - ogs_fsm_init(&sess->sm, &e); + ogs_fsm_init(&sess->sm, smf_gsm_state_initial, smf_gsm_state_final, &e); sess->smf_ue = smf_ue; @@ -1321,8 +1320,7 @@ memset(&e, 0, sizeof(e)); e.sess = sess; - ogs_fsm_create(&sess->sm, smf_gsm_state_initial, smf_gsm_state_final); - ogs_fsm_init(&sess->sm, &e); + ogs_fsm_init(&sess->sm, smf_gsm_state_initial, smf_gsm_state_final, &e); sess->smf_ue = smf_ue; @@ -1602,7 +1600,6 @@ memset(&e, 0, sizeof(e)); e.sess = sess; ogs_fsm_fini(&sess->sm, &e); - ogs_fsm_delete(&sess->sm); OGS_TLV_CLEAR_DATA(&sess->gtp.ue_pco); OGS_TLV_CLEAR_DATA(&sess->gtp.user_location_information);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/context.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/smf/context.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -126,21 +126,6 @@ ogs_list_t sess_list; } smf_ue_t; -#define SMF_NF_INSTANCE_CLEAR(_cAUSE, _nFInstance) \ - do { \ - ogs_assert(_nFInstance); \ - if ((_nFInstance)->reference_count == 1) { \ - ogs_info("%s (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ - smf_nf_fsm_fini((_nFInstance)); \ - ogs_sbi_nf_instance_remove(_nFInstance); \ - } else { \ - /* There is an assocation with other context */ \ - ogs_info("%s:%d (%s) NF suspended", \ - _nFInstance->id, _nFInstance->reference_count, (_cAUSE)); \ - OGS_FSM_TRAN(&_nFInstance->sm, smf_nf_state_de_registered); \ - ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ - } \ - } while(0) #define SMF_SESS_CLEAR(__sESS) \ do { \ smf_ue_t *smf_ue = NULL; \
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/event.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/smf/event.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -18,52 +18,26 @@ */ #include "event.h" -#include "context.h" -static OGS_POOL(pool, smf_event_t); -static ogs_thread_mutex_t smf_event_alloc_mutex; - -void smf_event_init(void) -{ - ogs_pool_init(&pool, ogs_app()->pool.event); - ogs_thread_mutex_init(&smf_event_alloc_mutex); -} - -void smf_event_final(void) -{ - ogs_pool_final(&pool); - ogs_thread_mutex_destroy(&smf_event_alloc_mutex); -} - -smf_event_t *smf_event_new(smf_event_e id) +smf_event_t *smf_event_new(int id) { smf_event_t *e = NULL; - ogs_thread_mutex_lock(&smf_event_alloc_mutex); - ogs_pool_alloc(&pool, &e); - ogs_thread_mutex_unlock(&smf_event_alloc_mutex); + e = ogs_event_size(id, sizeof(smf_event_t)); ogs_assert(e); - memset(e, 0, sizeof(*e)); - e->id = id; + e->h.id = id; return e; } -void smf_event_free(smf_event_t *e) -{ - ogs_assert(e); - ogs_thread_mutex_lock(&smf_event_alloc_mutex); - ogs_pool_free(&pool, e); - ogs_thread_mutex_unlock(&smf_event_alloc_mutex); -} - const char *smf_event_get_name(smf_event_t *e) { - if (e == NULL) + if (e == NULL) { return OGS_FSM_NAME_INIT_SIG; + } - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: return OGS_FSM_NAME_ENTRY_SIG; case OGS_FSM_EXIT_SIG: @@ -86,12 +60,12 @@ case SMF_EVT_N4_NO_HEARTBEAT: return "SMF_EVT_N4_NO_HEARTBEAT"; - case SMF_EVT_SBI_SERVER: - return "SMF_EVT_SBI_SERVER"; - case SMF_EVT_SBI_CLIENT: - return "SMF_EVT_SBI_CLIENT"; - case SMF_EVT_SBI_TIMER: - return "SMF_EVT_SBI_TIMER"; + case OGS_EVENT_SBI_SERVER: + return OGS_EVENT_NAME_SBI_SERVER; + case OGS_EVENT_SBI_CLIENT: + return OGS_EVENT_NAME_SBI_CLIENT; + case OGS_EVENT_SBI_TIMER: + return OGS_EVENT_NAME_SBI_TIMER; case SMF_EVT_NGAP_MESSAGE: return "SMF_EVT_NGAP_MESSAGE"; @@ -107,5 +81,6 @@ break; } + ogs_error("Unknown Event%d", e->h.id); return "UNKNOWN_EVENT"; }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/event.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/smf/event.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,8 +20,7 @@ #ifndef SMF_EVENT_H #define SMF_EVENT_H -#include "ogs-core.h" -#include "ogs-gtp.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { @@ -29,6 +28,8 @@ typedef struct ogs_gtp_node_s ogs_gtp_node_t; typedef struct ogs_gtp_xact_s ogs_gtp_xact_t; +typedef struct ogs_gtp1_message_s ogs_gtp1_message_t; +typedef struct ogs_gtp2_message_s ogs_gtp2_message_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; @@ -38,16 +39,12 @@ typedef struct smf_sess_s smf_sess_t; typedef struct smf_upf_s smf_upf_t; typedef struct smf_gtp_node_s smf_gtp_node_t; -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; 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; typedef enum { - SMF_EVT_BASE = OGS_FSM_USER_SIG, + SMF_EVT_BASE = OGS_MAX_NUM_OF_PROTO_EVENT, SMF_EVT_S5C_MESSAGE, SMF_EVT_S6B_MESSAGE, @@ -59,10 +56,6 @@ SMF_EVT_N4_TIMER, SMF_EVT_N4_NO_HEARTBEAT, - SMF_EVT_SBI_SERVER, - SMF_EVT_SBI_CLIENT, - SMF_EVT_SBI_TIMER, - SMF_EVT_NGAP_MESSAGE, SMF_EVT_NGAP_TIMER, @@ -74,9 +67,9 @@ } smf_event_e; typedef struct smf_event_s { - int id; + ogs_event_t h; + ogs_pkbuf_t *pkbuf; - int timer_id; smf_gtp_node_t *gnode; ogs_gtp_xact_t *gtp_xact; @@ -97,15 +90,6 @@ }; struct { - ogs_sbi_request_t *request; - ogs_sbi_response_t *response; - void *data; - int state; - - ogs_sbi_message_t *message; - } sbi; - - struct { int type; ogs_ngap_message_t *message; } ngap; @@ -118,11 +102,7 @@ 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); +smf_event_t *smf_event_new(int id); const char *smf_event_get_name(smf_event_t *e);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/gsm-sm.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/smf/gsm-sm.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -235,7 +235,7 @@ sess = e->sess; ogs_assert(sess); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: /* reset state: */ sess->sm_data.gx_ccr_init_in_flight = false; @@ -298,10 +298,10 @@ } break; - case SMF_EVT_SBI_SERVER: - sbi_message = e->sbi.message; + case OGS_EVENT_SBI_SERVER: + sbi_message = e->h.sbi.message; ogs_assert(sbi_message); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); SWITCH(sbi_message->h.service.name) @@ -342,7 +342,7 @@ ogs_assert(nas_message); sess = e->sess; ogs_assert(sess); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); smf_ue = sess->smf_ue; ogs_assert(smf_ue); @@ -397,7 +397,7 @@ sess = e->sess; ogs_assert(sess); - switch (e->id) { + switch (e->h.id) { case SMF_EVT_GX_MESSAGE: gx_message = e->gx_message; ogs_assert(gx_message); @@ -482,14 +482,14 @@ sess = e->sess; ogs_assert(sess); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case SMF_EVT_SBI_CLIENT: - sbi_message = e->sbi.message; + case OGS_EVENT_SBI_CLIENT: + sbi_message = e->h.sbi.message; ogs_assert(sbi_message); sess = e->sess; @@ -499,7 +499,7 @@ SWITCH(sbi_message->h.service.name) CASE(OGS_SBI_SERVICE_NAME_NUDM_SDM) - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); SWITCH(sbi_message->h.resource.component1) @@ -545,8 +545,8 @@ break; CASE(OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL) - stream = e->sbi.data; - state = e->sbi.state; + stream = e->h.sbi.data; + state = e->h.sbi.state; SWITCH(sbi_message->h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_SM_POLICIES) @@ -648,7 +648,7 @@ sess = e->sess; ogs_assert(sess); - switch (e->id) { + switch (e->h.id) { case SMF_EVT_N4_MESSAGE: pfcp_xact = e->pfcp_xact; ogs_assert(pfcp_xact); @@ -757,7 +757,7 @@ sess = e->sess; ogs_assert(sess); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; @@ -812,10 +812,10 @@ } break; - case SMF_EVT_SBI_SERVER: - sbi_message = e->sbi.message; + case OGS_EVENT_SBI_SERVER: + sbi_message = e->h.sbi.message; ogs_assert(sbi_message); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); SWITCH(sbi_message->h.service.name) @@ -849,8 +849,8 @@ END break; - case SMF_EVT_SBI_CLIENT: - sbi_message = e->sbi.message; + case OGS_EVENT_SBI_CLIENT: + sbi_message = e->h.sbi.message; ogs_assert(sbi_message); sess = e->sess; @@ -860,7 +860,7 @@ SWITCH(sbi_message->h.service.name) CASE(OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL) - stream = e->sbi.data; + stream = e->h.sbi.data; SWITCH(sbi_message->h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_SM_POLICIES) @@ -940,7 +940,7 @@ SWITCH(sbi_message->h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_UE_CONTEXTS) smf_namf_comm_handle_n1_n2_message_transfer( - sess, e->sbi.state, sbi_message); + sess, e->h.sbi.state, sbi_message); break; DEFAULT @@ -963,7 +963,7 @@ ogs_assert(nas_message); sess = e->sess; ogs_assert(sess); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); smf_ue = sess->smf_ue; ogs_assert(smf_ue); @@ -1023,7 +1023,7 @@ case SMF_EVT_NGAP_MESSAGE: sess = e->sess; ogs_assert(sess); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); smf_ue = sess->smf_ue; ogs_assert(smf_ue); @@ -1160,7 +1160,7 @@ sess = e->sess; ogs_assert(sess); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: /* Since `pfcp_xact->epc` is not avaiable, * we'll use `sess->epc` */ @@ -1170,12 +1170,12 @@ smf_epc_pfcp_send_session_deletion_request(sess, e->gtp_xact)); } else { /* 5GC */ - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); ogs_assert(OGS_OK == smf_5gc_pfcp_send_session_deletion_request( - sess, stream, e->sbi.state)); + sess, stream, e->h.sbi.state)); } break; @@ -1286,7 +1286,7 @@ sess = e->sess; ogs_assert(sess); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: /* reset state: */ sess->sm_data.gx_cca_term_err = ER_DIAMETER_SUCCESS; @@ -1413,16 +1413,16 @@ sess = e->sess; ogs_assert(sess); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case SMF_EVT_SBI_SERVER: - sbi_message = e->sbi.message; + case OGS_EVENT_SBI_SERVER: + sbi_message = e->h.sbi.message; ogs_assert(sbi_message); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); SWITCH(sbi_message->h.service.name) @@ -1453,8 +1453,8 @@ END break; - case SMF_EVT_SBI_CLIENT: - sbi_message = e->sbi.message; + case OGS_EVENT_SBI_CLIENT: + sbi_message = e->h.sbi.message; ogs_assert(sbi_message); sess = e->sess; @@ -1467,7 +1467,7 @@ SWITCH(sbi_message->h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_UE_CONTEXTS) smf_namf_comm_handle_n1_n2_message_transfer( - sess, e->sbi.state, sbi_message); + sess, e->h.sbi.state, sbi_message); break; DEFAULT @@ -1488,7 +1488,7 @@ case SMF_EVT_NGAP_MESSAGE: sess = e->sess; ogs_assert(sess); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); smf_ue = sess->smf_ue; ogs_assert(smf_ue); @@ -1535,7 +1535,7 @@ ogs_assert(nas_message); sess = e->sess; ogs_assert(sess); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); smf_ue = sess->smf_ue; ogs_assert(smf_ue); @@ -1572,7 +1572,7 @@ sess = e->sess; ogs_assert(sess); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: SMF_SESS_CLEAR(sess); break; @@ -1601,7 +1601,7 @@ smf_ue = sess->smf_ue; ogs_assert(smf_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: ogs_error("%s:%d State machine exception", smf_ue->supi, sess->psi); SMF_SESS_CLEAR(sess);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/gtp-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/smf/gtp-path.c
Changed
@@ -108,7 +108,7 @@ if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_pkbuf_free(e->pkbuf); - smf_event_free(e); + ogs_event_free(e); } }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/gx-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/smf/gx-path.c
Changed
@@ -1008,7 +1008,7 @@ ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_session_data_free(&gx_message->session_data); ogs_free(gx_message); - smf_event_free(e); + ogs_event_free(e); } else { ogs_pollset_notify(ogs_app()->pollset); } @@ -1251,7 +1251,7 @@ ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_session_data_free(&gx_message->session_data); ogs_free(gx_message); - smf_event_free(e); + ogs_event_free(e); } else { ogs_pollset_notify(ogs_app()->pollset); }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/gy-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/smf/gy-path.c
Changed
@@ -1106,7 +1106,7 @@ if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_free(gy_message); - smf_event_free(e); + ogs_event_free(e); } else { ogs_pollset_notify(ogs_app()->pollset); } @@ -1235,7 +1235,7 @@ if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_free(gy_message); - smf_event_free(e); + ogs_event_free(e); } else { ogs_pollset_notify(ogs_app()->pollset); }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/init.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/smf/init.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -39,7 +39,6 @@ ogs_sbi_context_init(); smf_context_init(); - smf_event_init(); rv = ogs_gtp_xact_init(); if (rv != OGS_OK) return rv; @@ -100,7 +99,7 @@ /* Sending NF Instance De-registeration to NRF */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) - smf_nf_fsm_fini(nf_instance); + ogs_sbi_nf_fsm_fini(nf_instance); /* Starting holding timer */ t_termination_holding = ogs_timer_add(ogs_app()->timer_mgr, NULL, NULL); @@ -138,8 +137,6 @@ ogs_pfcp_xact_final(); ogs_gtp_xact_final(); - - smf_event_final(); /* Destroy event */ } static void smf_main(void *data) @@ -147,8 +144,7 @@ ogs_fsm_t smf_sm; int rv; - ogs_fsm_create(&smf_sm, smf_state_initial, smf_state_final); - ogs_fsm_init(&smf_sm, 0); + ogs_fsm_init(&smf_sm, smf_state_initial, smf_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -181,11 +177,10 @@ ogs_assert(e); ogs_fsm_dispatch(&smf_sm, e); - smf_event_free(e); + ogs_event_free(e); } } done: ogs_fsm_fini(&smf_sm, 0); - ogs_fsm_delete(&smf_sm); }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/meson.build -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/smf/meson.build
Changed
@@ -1,4 +1,4 @@ -# Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> +# Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> # This file is part of Open5GS. @@ -51,7 +51,6 @@ n4-build.h n4-handler.h binding.h - nnrf-build.h nnrf-handler.h nudm-build.h nudm-handler.h @@ -74,7 +73,6 @@ timer.c context.c smf-sm.c - nf-sm.c gsm-sm.c pfcp-sm.c gtp-path.c @@ -92,7 +90,6 @@ n4-build.c n4-handler.c binding.c - nnrf-build.c nnrf-handler.c nudm-build.c nudm-handler.c
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/n4-handler.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/smf/n4-handler.c
Changed
@@ -18,7 +18,6 @@ */ #include "context.h" -#include "timer.h" #include "s5c-build.h" #include "pfcp-path.h" #include "gtp-path.h"
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/nas-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/smf/nas-path.c
Changed
@@ -31,12 +31,12 @@ e = smf_event_new(SMF_EVT_5GSM_MESSAGE); ogs_assert(e); e->sess = sess; - e->sbi.data = stream; + e->h.sbi.data = stream; e->pkbuf = pkbuf; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_pkbuf_free(e->pkbuf); - smf_event_free(e); + ogs_event_free(e); } }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/ngap-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/smf/ngap-path.c
Changed
@@ -31,13 +31,13 @@ e = smf_event_new(SMF_EVT_NGAP_MESSAGE); ogs_assert(e); e->sess = sess; - e->sbi.data = stream; + e->h.sbi.data = stream; e->pkbuf = pkbuf; e->ngap.type = type; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_pkbuf_free(e->pkbuf); - smf_event_free(e); + ogs_event_free(e); } -} \ No newline at end of file +}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/nnrf-handler.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/smf/nnrf-handler.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,244 +20,14 @@ #include "sbi-path.h" #include "nnrf-handler.h" -void smf_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_nf_profile_t *NFProfile = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(nf_instance); - client = nf_instance->client; - ogs_assert(client); - - NFProfile = recvmsg->NFProfile; - if (!NFProfile) { - ogs_error("No NFProfile"); - return; - } - - /* TIME : Update heartbeat from NRF */ - if (NFProfile->is_heart_beat_timer == true) - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; -} - -void smf_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_subscription_data_t *SubscriptionData = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(subscription); - client = subscription->client; - ogs_assert(client); - - SubscriptionData = recvmsg->SubscriptionData; - if (!SubscriptionData) { - ogs_error("No SubscriptionData"); - return; - } - - if (!SubscriptionData->subscription_id) { - ogs_error("No SubscriptionId"); - return; - } - ogs_sbi_subscription_set_id( - subscription, SubscriptionData->subscription_id); - - if (SubscriptionData->validity_time) { -#define VALIDITY_MINIMUM (10LL * OGS_USEC_PER_SEC) /* 10 seconds */ - ogs_time_t time, duration; - if (ogs_sbi_time_from_string( - &time, SubscriptionData->validity_time) == true) { - duration = time - ogs_time_now(); - if (duration < VALIDITY_MINIMUM) { - duration = VALIDITY_MINIMUM; - ogs_warn("%s Forced to %lld seconds", subscription->id, - (long long)ogs_time_sec(VALIDITY_MINIMUM)); - } - subscription->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - smf_timer_subscription_validity, subscription); - ogs_assert(subscription->t_validity); - ogs_timer_start(subscription->t_validity, duration); - } else { - ogs_error("Cannot parse validitiyTime %s", - SubscriptionData->validity_time); - } - } -} - -bool smf_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) -{ - int rv; - bool handled; - - ogs_sbi_response_t *response = NULL; - OpenAPI_notification_data_t *NotificationData = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_header_t header; - - ogs_assert(stream); - ogs_assert(recvmsg); - - NotificationData = recvmsg->NotificationData; - if (!NotificationData) { - ogs_error("No NotificationData"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NotificationData", NULL)); - return false; - } - - if (!NotificationData->nf_instance_uri) { - ogs_error("No nfInstanceUri"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No nfInstanceUri", NULL)); - return false; - } - - memset(&header, 0, sizeof(header)); - header.uri = NotificationData->nf_instance_uri; - - rv = ogs_sbi_parse_header(&message, &header); - if (rv != OGS_OK) { - ogs_error("Cannot parse nfInstanceUri %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - return false; - } - - if (!message.h.resource.component1) { - ogs_error("No nfInstanceId %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - ogs_sbi_header_free(&header); - return false; - } - - if (NF_INSTANCE_IS_SELF(message.h.resource.component1)) { - ogs_warn("%s The notification is not allowed", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_FORBIDDEN, - recvmsg, "The notification is not allowed", - message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - - if (NotificationData->event == - OpenAPI_notification_event_type_NF_REGISTERED) { - - OpenAPI_nf_profile_t *NFProfile = NULL; - - NFProfile = NotificationData->nf_profile; - if (!NFProfile) { - ogs_error("No NFProfile"); - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NFProfile", NULL)); - ogs_sbi_header_free(&header); - return false; - } - - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, - message.h.resource.component1); - - smf_nf_fsm_init(nf_instance); - - ogs_info("%s (NRF-notify) NF registered", nf_instance->id); - - } else { - OGS_FSM_TRAN(&nf_instance->sm, smf_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NRF-notify) NF has already been added", - message.h.resource.component1); - - } - - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, stream, recvmsg); - if (!handled) { - SMF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - ogs_info("%s (NRF-notify) NF Profile updated", nf_instance->id); - - handled = ogs_sbi_client_associate(nf_instance); - if (!handled) { - ogs_error("%s Cannot associate NF EndPoint", nf_instance->id); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot find NF EndPoint", nf_instance->id)); - SMF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - } else if (NotificationData->event == - OpenAPI_notification_event_type_NF_DEREGISTERED) { - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (nf_instance) { - SMF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - } else { - ogs_warn("%s (NRF-notify) Not found", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_NOT_FOUND, - recvmsg, "Not found", message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - } else { - char *eventstr = OpenAPI_notification_event_type_ToString( - NotificationData->event); - ogs_error("Not supported event %d:%s", - NotificationData->event, eventstr ? eventstr : "Unknown"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Not supported event", - eventstr ? eventstr : "Unknown")); - ogs_sbi_header_free(&header); - return false; - } - - response = ogs_sbi_build_response(recvmsg, OGS_SBI_HTTP_STATUS_NO_CONTENT); - ogs_assert(response); - ogs_assert(true == ogs_sbi_server_send_response(stream, response)); - - ogs_sbi_header_free(&header); - return true; -} - void smf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { ogs_sbi_object_t *sbi_object = NULL; OpenAPI_nf_type_e target_nf_type = 0; ogs_sbi_discovery_option_t *discovery_option = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; OpenAPI_search_result_t *SearchResult = NULL; - OpenAPI_lnode_t *node = NULL; - bool handled; ogs_assert(recvmsg); ogs_assert(xact); @@ -274,64 +44,8 @@ return; } - OpenAPI_list_for_each(SearchResult->nf_instances, node) { - OpenAPI_nf_profile_t *NFProfile = NULL; - - if (!node->data) continue; - - NFProfile = node->data; - - nf_instance = ogs_sbi_nf_instance_find(NFProfile->nf_instance_id); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id); - - smf_nf_fsm_init(nf_instance); - - ogs_info("%s (NF-discover) NF registered", nf_instance->id); - } else { - OGS_FSM_TRAN(&nf_instance->sm, smf_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NF-discover) NF has already been added", - NFProfile->nf_instance_id); - } - - if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) { - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, NULL, NULL); - if (!handled) { - ogs_error("ogs_sbi_nnrf_handle_nf_profile() failed %s", - nf_instance->id); - SMF_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); - continue; - } - - handled = ogs_sbi_client_associate(nf_instance); - if (!handled) { - ogs_error("%s Cannot assciate NF EndPoint", nf_instance->id); - SMF_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); - continue; - } - - /* TIME : Update validity from NRF */ - if (SearchResult->is_validity_period && - SearchResult->validity_period) { - nf_instance->time.validity_duration = - SearchResult->validity_period; - - ogs_assert(nf_instance->t_validity); - ogs_timer_start(nf_instance->t_validity, - ogs_time_from_sec(nf_instance->time.validity_duration)); - - } else - ogs_warn("%s NF Instance validity-time should not 0", - nf_instance->id); - - ogs_info("%s (NF-discover) NF Profile updated", nf_instance->id); - } - } + ogs_nnrf_handle_nf_discover_search_result( + sbi_object, target_nf_type, discovery_option, SearchResult); ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/nnrf-handler.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/smf/nnrf-handler.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -26,14 +26,6 @@ extern "C" { #endif -void smf_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg); -void smf_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg); - -bool smf_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); - void smf_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/pfcp-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/smf/pfcp-path.c
Changed
@@ -74,8 +74,7 @@ ogs_assert(node->t_association); } - ogs_fsm_create(&node->sm, smf_pfcp_state_initial, smf_pfcp_state_final); - ogs_fsm_init(&node->sm, &e); + ogs_fsm_init(&node->sm, smf_pfcp_state_initial, smf_pfcp_state_final, &e); } static void pfcp_node_fsm_fini(ogs_pfcp_node_t *node) @@ -88,7 +87,6 @@ e.pfcp_node = node; ogs_fsm_fini(&node->sm, &e); - ogs_fsm_delete(&node->sm); if (node->t_association) ogs_timer_delete(node->t_association); @@ -159,7 +157,7 @@ if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_pkbuf_free(e->pkbuf); - smf_event_free(e); + ogs_event_free(e); } }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/pfcp-sm.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/smf/pfcp-sm.c
Changed
@@ -82,7 +82,7 @@ addr = node->sa_list; ogs_assert(addr); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: if (node->t_association) { ogs_timer_start(node->t_association, @@ -99,7 +99,7 @@ break; case SMF_EVT_N4_TIMER: - switch(e->timer_id) { + switch(e->h.timer_id) { case SMF_TIMER_PFCP_ASSOCIATION: node = e->pfcp_node; ogs_assert(node); @@ -115,7 +115,7 @@ break; default: ogs_error("Unknown timer%s:%d", - smf_timer_get_name(e->timer_id), e->timer_id); + smf_timer_get_name(e->h.timer_id), e->h.timer_id); break; } break; @@ -169,7 +169,7 @@ addr = node->sa_list; ogs_assert(addr); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: ogs_info("PFCP associated"); ogs_timer_start(node->t_no_heartbeat, @@ -290,7 +290,7 @@ break; case SMF_EVT_N4_TIMER: - switch(e->timer_id) { + switch(e->h.timer_id) { case SMF_TIMER_PFCP_NO_HEARTBEAT: node = e->pfcp_node; ogs_assert(node); @@ -300,7 +300,7 @@ break; default: ogs_error("Unknown timer%s:%d", - smf_timer_get_name(e->timer_id), e->timer_id); + smf_timer_get_name(e->h.timer_id), e->h.timer_id); break; } break; @@ -322,7 +322,7 @@ smf_sm_debug(e); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: @@ -353,7 +353,7 @@ rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); - smf_event_free(e); + ogs_event_free(e); } break; case OGS_PFCP_ASSOCIATION_SETUP_REQUEST_TYPE:
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/s6b-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/smf/s6b-path.c
Changed
@@ -714,7 +714,7 @@ if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_free(s6b_message); - smf_event_free(e); + ogs_event_free(e); } else { ogs_pollset_notify(ogs_app()->pollset); }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/sbi-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/smf/sbi-path.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -29,17 +29,17 @@ ogs_assert(request); ogs_assert(data); - e = smf_event_new(SMF_EVT_SBI_SERVER); + e = smf_event_new(OGS_EVENT_SBI_SERVER); ogs_assert(e); - e->sbi.request = request; - e->sbi.data = data; + e->h.sbi.request = request; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_request_free(request); - smf_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -60,16 +60,16 @@ ogs_assert(response); - e = smf_event_new(SMF_EVT_SBI_CLIENT); + e = smf_event_new(OGS_EVENT_SBI_CLIENT); ogs_assert(e); - e->sbi.response = response; - e->sbi.data = data; + e->h.sbi.response = response; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_response_free(response); - smf_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -81,6 +81,13 @@ ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_nf_service_t *service = NULL; + /* To be notified when NF Instances registered/deregistered in NRF + * or when their profile is modified */ + ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_AMF); + ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_PCF); + ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_UDM); + ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_UPF); + /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); @@ -100,28 +107,20 @@ } /* Initialize NRF NF Instance */ - ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_sbi_client_t *client = NULL; - - /* Client callback is only used when NF sends to NRF */ - client = nf_instance->client; - ogs_assert(client); - client->cb = client_cb; - - /* NFRegister is sent and the response is received - * by the above client callback. */ - smf_nf_fsm_init(nf_instance); - } + nf_instance = ogs_sbi_self()->nrf_instance; + if (nf_instance) { + ogs_sbi_client_t *client = NULL; + + /* Client callback is only used when NF sends to NRF */ + client = nf_instance->client; + ogs_assert(client); + client->cb = client_cb; + + /* NFRegister is sent and the response is received + * by the above client callback. */ + ogs_sbi_nf_fsm_init(nf_instance); } - /* Timer expiration handler of client wait timer */ - ogs_sbi_self()->client_wait_expire = smf_timer_sbi_client_wait_expire; - - /* NF register state in NF state machine */ - ogs_sbi_self()->nf_state_registered = - (ogs_fsm_handler_t)smf_nf_state_registered; - if (ogs_sbi_server_start_all(server_cb) != OGS_OK) return OGS_ERROR;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/sbi-path.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/smf/sbi-path.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,7 +20,6 @@ #ifndef SMF_SBI_PATH_H #define SMF_SBI_PATH_H -#include "nnrf-build.h" #include "nudm-build.h" #include "namf-build.h" #include "gsm-build.h"
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/smf-sm.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/smf/smf-sm.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -84,7 +84,7 @@ ogs_assert(s); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; @@ -418,10 +418,10 @@ ogs_fsm_dispatch(&pfcp_node->sm, e); break; - case SMF_EVT_SBI_SERVER: - sbi_request = e->sbi.request; + case OGS_EVENT_SBI_SERVER: + sbi_request = e->h.sbi.request; ogs_assert(sbi_request); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); rv = ogs_sbi_parse_request(&sbi_message, sbi_request); @@ -461,7 +461,7 @@ CASE(OGS_SBI_RESOURCE_NAME_NF_STATUS_NOTIFY) SWITCH(sbi_message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) - smf_nnrf_handle_nf_status_notify(stream, &sbi_message); + ogs_nnrf_handle_nf_status_notify(stream, &sbi_message); break; DEFAULT @@ -535,7 +535,7 @@ ogs_assert(OGS_FSM_STATE(&sess->sm)); e->sess = sess; - e->sbi.message = &sbi_message; + e->h.sbi.message = &sbi_message; ogs_fsm_dispatch(&sess->sm, e); } break; @@ -624,10 +624,10 @@ ogs_sbi_message_free(&sbi_message); break; - case SMF_EVT_SBI_CLIENT: + case OGS_EVENT_SBI_CLIENT: ogs_assert(e); - sbi_response = e->sbi.response; + sbi_response = e->h.sbi.response; ogs_assert(sbi_response); rv = ogs_sbi_parse_response(&sbi_message, sbi_response); if (rv != OGS_OK) { @@ -658,23 +658,23 @@ SWITCH(sbi_message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - nf_instance = e->sbi.data; + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); - e->sbi.message = &sbi_message; + e->h.sbi.message = &sbi_message; ogs_fsm_dispatch(&nf_instance->sm, e); break; CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS) - subscription = e->sbi.data; + subscription = e->h.sbi.data; ogs_assert(subscription); SWITCH(sbi_message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) if (sbi_message.res_status == OGS_SBI_HTTP_STATUS_CREATED || sbi_message.res_status == OGS_SBI_HTTP_STATUS_OK) { - smf_nnrf_handle_nf_status_subscribe( + ogs_nnrf_handle_nf_status_subscribe( subscription, &sbi_message); } else { ogs_error("HTTP response error : %d", @@ -708,7 +708,7 @@ CASE(OGS_SBI_SERVICE_NAME_NNRF_DISC) SWITCH(sbi_message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); SWITCH(sbi_message.h.method) @@ -736,7 +736,7 @@ CASE(OGS_SBI_SERVICE_NAME_NUDM_SDM) CASE(OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL) CASE(OGS_SBI_SERVICE_NAME_NAMF_COMM) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); sbi_xact = ogs_sbi_xact_cycle(sbi_xact); @@ -750,8 +750,8 @@ sess = (smf_sess_t *)sbi_xact->sbi_object; ogs_assert(sess); - e->sbi.data = sbi_xact->assoc_stream; - e->sbi.state = sbi_xact->state; + e->h.sbi.data = sbi_xact->assoc_stream; + e->h.sbi.state = sbi_xact->state; ogs_sbi_xact_remove(sbi_xact); @@ -767,7 +767,7 @@ ogs_assert(OGS_FSM_STATE(&sess->sm)); e->sess = sess; - e->sbi.message = &sbi_message; + e->h.sbi.message = &sbi_message; ogs_fsm_dispatch(&sess->sm, e); break; @@ -781,27 +781,27 @@ ogs_sbi_response_free(sbi_response); break; - case SMF_EVT_SBI_TIMER: + case OGS_EVENT_SBI_TIMER: ogs_assert(e); - switch(e->timer_id) { - case SMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case SMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case SMF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case SMF_TIMER_NF_INSTANCE_VALIDITY: - nf_instance = e->sbi.data; + switch(e->h.timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + case OGS_TIMER_NF_INSTANCE_VALIDITY: + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); ogs_fsm_dispatch(&nf_instance->sm, e); - if (OGS_FSM_CHECK(&nf_instance->sm, smf_nf_state_exception)) + if (OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_exception)) ogs_error("%s:%s State machine exception %d", OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id, e->timer_id); + nf_instance->id, e->h.timer_id); break; - case SMF_TIMER_SUBSCRIPTION_VALIDITY: - subscription = e->sbi.data; + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + subscription = e->h.sbi.data; ogs_assert(subscription); ogs_assert(ogs_sbi_self()->nf_instance); @@ -815,8 +815,8 @@ ogs_sbi_subscription_remove(subscription); break; - case SMF_TIMER_SBI_CLIENT_WAIT: - sbi_xact = e->sbi.data; + case OGS_TIMER_SBI_CLIENT_WAIT: + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); stream = sbi_xact->assoc_stream; @@ -836,14 +836,14 @@ default: ogs_error("Unknown timer%s:%d", - smf_timer_get_name(e->timer_id), e->timer_id); + ogs_timer_get_name(e->h.timer_id), e->h.timer_id); } break; case SMF_EVT_5GSM_MESSAGE: sess = e->sess; ogs_assert(sess); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); pkbuf = e->pkbuf; ogs_assert(pkbuf); @@ -868,7 +868,7 @@ case SMF_EVT_NGAP_MESSAGE: sess = e->sess; ogs_assert(sess); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); pkbuf = e->pkbuf; ogs_assert(pkbuf);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/smf-sm.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/smf/smf-sm.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -31,16 +31,6 @@ void smf_state_operational(ogs_fsm_t *s, smf_event_t *e); void smf_state_exception(ogs_fsm_t *s, smf_event_t *e); -void smf_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance); -void smf_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance); - -void smf_nf_state_initial(ogs_fsm_t *s, smf_event_t *e); -void smf_nf_state_final(ogs_fsm_t *s, smf_event_t *e); -void smf_nf_state_will_register(ogs_fsm_t *s, smf_event_t *e); -void smf_nf_state_registered(ogs_fsm_t *s, smf_event_t *e); -void smf_nf_state_de_registered(ogs_fsm_t *s, smf_event_t *e); -void smf_nf_state_exception(ogs_fsm_t *s, smf_event_t *e); - void smf_gsm_state_initial(ogs_fsm_t *s, smf_event_t *e); void smf_gsm_state_final(ogs_fsm_t *s, smf_event_t *e); void smf_gsm_state_wait_epc_auth_initial(ogs_fsm_t *s, smf_event_t *e);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/timer.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/smf/timer.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -17,33 +17,32 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -#include "timer.h" -#include "event.h" #include "context.h" -const char *smf_timer_get_name(smf_timer_e id) +const char *smf_timer_get_name(int timer_id) { - switch (id) { + switch (timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + return OGS_TIMER_NAME_NF_INSTANCE_REGISTRATION_INTERVAL; + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + return OGS_TIMER_NAME_NF_INSTANCE_HEARTBEAT_INTERVAL; + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + return OGS_TIMER_NAME_NF_INSTANCE_NO_HEARTBEAT; + case OGS_TIMER_NF_INSTANCE_VALIDITY: + return OGS_TIMER_NAME_NF_INSTANCE_VALIDITY; + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + return OGS_TIMER_NAME_SUBSCRIPTION_VALIDITY; + case OGS_TIMER_SBI_CLIENT_WAIT: + return OGS_TIMER_NAME_SBI_CLIENT_WAIT; case SMF_TIMER_PFCP_ASSOCIATION: return "SMF_TIMER_PFCP_ASSOCIATION"; case SMF_TIMER_PFCP_NO_HEARTBEAT: return "SMF_TIMER_PFCP_NO_HEARTBEAT"; - case SMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - return "SMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL"; - case SMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - return "SMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL"; - case SMF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - return "SMF_TIMER_NF_INSTANCE_NO_HEARTBEAT"; - case SMF_TIMER_NF_INSTANCE_VALIDITY: - return "SMF_TIMER_NF_INSTANCE_VALIDITY"; - case SMF_TIMER_SUBSCRIPTION_VALIDITY: - return "SMF_TIMER_SUBSCRIPTION_VALIDITY"; - case SMF_TIMER_SBI_CLIENT_WAIT: - return "SMF_TIMER_SBI_CLIENT_WAIT"; default: break; } + ogs_error("Unknown Timer%d", timer_id); return "UNKNOWN_TIMER"; } @@ -58,32 +57,9 @@ case SMF_TIMER_PFCP_NO_HEARTBEAT: e = smf_event_new(SMF_EVT_N4_TIMER); ogs_assert(e); - e->timer_id = timer_id; + e->h.timer_id = timer_id; e->pfcp_node = data; break; - case SMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case SMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case SMF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case SMF_TIMER_NF_INSTANCE_VALIDITY: - case SMF_TIMER_SUBSCRIPTION_VALIDITY: - e = smf_event_new(SMF_EVT_SBI_TIMER); - ogs_assert(e); - e->timer_id = timer_id; - e->sbi.data = data; - break; - case SMF_TIMER_SBI_CLIENT_WAIT: - e = smf_event_new(SMF_EVT_SBI_TIMER); - if (!e) { - ogs_sbi_xact_t *sbi_xact = data; - ogs_assert(sbi_xact); - - ogs_error("timer_send_event() failed"); - ogs_sbi_xact_remove(sbi_xact); - return; - } - e->timer_id = timer_id; - e->sbi.data = data; - break; default: ogs_fatal("Unknown timer id%d", timer_id); ogs_assert_if_reached(); @@ -93,8 +69,8 @@ rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed %d in %s", - (int)rv, smf_timer_get_name(e->timer_id)); - smf_event_free(e); + (int)rv, smf_timer_get_name(timer_id)); + ogs_event_free(e); } } @@ -107,33 +83,3 @@ { timer_send_event(SMF_TIMER_PFCP_NO_HEARTBEAT, data); } - -void smf_timer_nf_instance_registration_interval(void *data) -{ - timer_send_event(SMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, data); -} - -void smf_timer_nf_instance_heartbeat_interval(void *data) -{ - timer_send_event(SMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, data); -} - -void smf_timer_nf_instance_no_heartbeat(void *data) -{ - timer_send_event(SMF_TIMER_NF_INSTANCE_NO_HEARTBEAT, data); -} - -void smf_timer_nf_instance_validity(void *data) -{ - timer_send_event(SMF_TIMER_NF_INSTANCE_VALIDITY, data); -} - -void smf_timer_subscription_validity(void *data) -{ - timer_send_event(SMF_TIMER_SUBSCRIPTION_VALIDITY, data); -} - -void smf_timer_sbi_client_wait_expire(void *data) -{ - timer_send_event(SMF_TIMER_SBI_CLIENT_WAIT, data); -}
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/smf/timer.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/smf/timer.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,7 +20,7 @@ #ifndef SMF_TIMER_H #define SMF_TIMER_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { @@ -28,34 +28,20 @@ /* forward declaration */ typedef enum { - SMF_TIMER_BASE = 0, + SMF_TIMER_BASE = OGS_MAX_NUM_OF_PROTO_TIMER, SMF_TIMER_PFCP_ASSOCIATION, SMF_TIMER_PFCP_NO_HEARTBEAT, - SMF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL, - SMF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL, - SMF_TIMER_NF_INSTANCE_NO_HEARTBEAT, - SMF_TIMER_NF_INSTANCE_VALIDITY, - SMF_TIMER_SUBSCRIPTION_VALIDITY, - SMF_TIMER_SBI_CLIENT_WAIT, - MAX_NUM_OF_SMF_TIMER, } smf_timer_e; -const char *smf_timer_get_name(smf_timer_e id); +const char *smf_timer_get_name(int timer_id); void smf_timer_pfcp_association(void *data); void smf_timer_pfcp_no_heartbeat(void *data); -void smf_timer_nf_instance_registration_interval(void *data); -void smf_timer_nf_instance_heartbeat_interval(void *data); -void smf_timer_nf_instance_no_heartbeat(void *data); -void smf_timer_nf_instance_validity(void *data); -void smf_timer_subscription_validity(void *data); -void smf_timer_sbi_client_wait_expire(void *data); - #ifdef __cplusplus } #endif
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udm/context.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/udm/context.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -141,8 +141,7 @@ memset(&e, 0, sizeof(e)); e.udm_ue = udm_ue; - ogs_fsm_create(&udm_ue->sm, udm_ue_state_initial, udm_ue_state_final); - ogs_fsm_init(&udm_ue->sm, &e); + ogs_fsm_init(&udm_ue->sm, udm_ue_state_initial, udm_ue_state_final, &e); ogs_list_add(&self.udm_ue_list, udm_ue); @@ -160,7 +159,6 @@ memset(&e, 0, sizeof(e)); e.udm_ue = udm_ue; ogs_fsm_fini(&udm_ue->sm, &e); - ogs_fsm_delete(&udm_ue->sm); /* Free SBI object memory */ ogs_sbi_object_free(&udm_ue->sbi);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udm/context.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/udm/context.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -25,7 +25,6 @@ #include "ogs-sbi.h" #include "udm-sm.h" -#include "timer.h" #ifdef __cplusplus extern "C" { @@ -72,22 +71,6 @@ OpenAPI_auth_type_e auth_type; OpenAPI_rat_type_e rat_type; - -#define UDM_NF_INSTANCE_CLEAR(_cAUSE, _nFInstance) \ - do { \ - ogs_assert(_nFInstance); \ - if ((_nFInstance)->reference_count == 1) { \ - ogs_info("%s (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ - udm_nf_fsm_fini((_nFInstance)); \ - ogs_sbi_nf_instance_remove(_nFInstance); \ - } else { \ - /* There is an assocation with other context */ \ - ogs_info("%s:%d (%s) NF suspended", \ - _nFInstance->id, _nFInstance->reference_count, (_cAUSE)); \ - OGS_FSM_TRAN(&_nFInstance->sm, udm_nf_state_de_registered); \ - ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ - } \ - } while(0) }; void udm_context_init(void);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udm/event.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/udm/event.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -18,60 +18,41 @@ */ #include "event.h" -#include "context.h" -static OGS_POOL(pool, udm_event_t); - -void udm_event_init(void) -{ - ogs_pool_init(&pool, ogs_app()->pool.event); -} - -void udm_event_final(void) -{ - ogs_pool_final(&pool); -} - -udm_event_t *udm_event_new(udm_event_e id) +udm_event_t *udm_event_new(int id) { udm_event_t *e = NULL; - ogs_pool_alloc(&pool, &e); + e = ogs_event_size(id, sizeof(udm_event_t)); ogs_assert(e); - memset(e, 0, sizeof(*e)); - e->id = id; + e->h.id = id; return e; } -void udm_event_free(udm_event_t *e) -{ - ogs_assert(e); - ogs_pool_free(&pool, e); -} - const char *udm_event_get_name(udm_event_t *e) { if (e == NULL) return OGS_FSM_NAME_INIT_SIG; - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: return OGS_FSM_NAME_ENTRY_SIG; case OGS_FSM_EXIT_SIG: return OGS_FSM_NAME_EXIT_SIG; - case UDM_EVT_SBI_SERVER: - return "UDM_EVT_SBI_SERVER"; - case UDM_EVT_SBI_CLIENT: - return "UDM_EVT_SBI_CLIENT"; - case UDM_EVT_SBI_TIMER: - return "UDM_EVT_SBI_TIMER"; + case OGS_EVENT_SBI_SERVER: + return OGS_EVENT_NAME_SBI_SERVER; + case OGS_EVENT_SBI_CLIENT: + return OGS_EVENT_NAME_SBI_CLIENT; + case OGS_EVENT_SBI_TIMER: + return OGS_EVENT_NAME_SBI_TIMER; default: break; } + ogs_error("Unknown Event%d", e->h.id); return "UNKNOWN_EVENT"; }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udm/event.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/udm/event.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,53 +20,21 @@ #ifndef UDM_EVENT_H #define UDM_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { #endif -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_nf_instance_s ogs_sbi_nf_instance_t; -typedef struct ogs_sbi_subscription_s ogs_sbi_subscription_t; - typedef struct udm_ue_s udm_ue_t; -typedef enum { - UDM_EVT_BASE = OGS_FSM_USER_SIG, - - UDM_EVT_SBI_SERVER, - UDM_EVT_SBI_CLIENT, - UDM_EVT_SBI_TIMER, - - UDM_EVT_TOP, - -} udm_event_e; - typedef struct udm_event_s { - int id; - int timer_id; - - struct { - ogs_sbi_request_t *request; - ogs_sbi_response_t *response; - void *data; - - ogs_sbi_message_t *message; - } sbi; + ogs_event_t h; udm_ue_t *udm_ue; - - ogs_timer_t *timer; } udm_event_t; -void udm_event_init(void); -void udm_event_final(void); - -udm_event_t *udm_event_new(udm_event_e id); -void udm_event_free(udm_event_t *e); +udm_event_t *udm_event_new(int id); const char *udm_event_get_name(udm_event_t *e);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udm/init.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/udm/init.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -30,7 +30,6 @@ ogs_sbi_context_init(); udm_context_init(); - udm_event_init(); rv = ogs_sbi_context_parse_config("udm", "nrf", "scp"); if (rv != OGS_OK) return rv; @@ -61,7 +60,7 @@ /* Sending NF Instance De-registeration to NRF */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) - udm_nf_fsm_fini(nf_instance); + ogs_sbi_nf_fsm_fini(nf_instance); /* Starting holding timer */ t_termination_holding = ogs_timer_add(ogs_app()->timer_mgr, NULL, NULL); @@ -87,8 +86,6 @@ udm_context_final(); ogs_sbi_context_final(); - - udm_event_final(); /* Destroy event */ } static void udm_main(void *data) @@ -96,8 +93,7 @@ ogs_fsm_t udm_sm; int rv; - ogs_fsm_create(&udm_sm, udm_state_initial, udm_state_final); - ogs_fsm_init(&udm_sm, 0); + ogs_fsm_init(&udm_sm, udm_state_initial, udm_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -130,11 +126,10 @@ ogs_assert(e); ogs_fsm_dispatch(&udm_sm, e); - udm_event_free(e); + ogs_event_free(e); } } done: ogs_fsm_fini(&udm_sm, 0); - ogs_fsm_delete(&udm_sm); }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udm/meson.build -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/udm/meson.build
Changed
@@ -1,4 +1,4 @@ -# Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> +# Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> # This file is part of Open5GS. @@ -18,12 +18,8 @@ libudm_sources = files(''' context.c event.c - timer.c - nnrf-build.c nnrf-handler.c - nf-sm.c - nudm-handler.c nudr-build.c
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udm/nnrf-handler.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/udm/nnrf-handler.c
Changed
@@ -20,244 +20,14 @@ #include "sbi-path.h" #include "nnrf-handler.h" -void udm_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_nf_profile_t *NFProfile = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(nf_instance); - client = nf_instance->client; - ogs_assert(client); - - NFProfile = recvmsg->NFProfile; - if (!NFProfile) { - ogs_error("No NFProfile"); - return; - } - - /* TIME : Update heartbeat from NRF */ - if (NFProfile->is_heart_beat_timer == true) - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; -} - -void udm_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_subscription_data_t *SubscriptionData = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(subscription); - client = subscription->client; - ogs_assert(client); - - SubscriptionData = recvmsg->SubscriptionData; - if (!SubscriptionData) { - ogs_error("No SubscriptionData"); - return; - } - - if (!SubscriptionData->subscription_id) { - ogs_error("No SubscriptionId"); - return; - } - ogs_sbi_subscription_set_id( - subscription, SubscriptionData->subscription_id); - - if (SubscriptionData->validity_time) { -#define VALIDITY_MINIMUM (10LL * OGS_USEC_PER_SEC) /* 10 seconds */ - ogs_time_t time, duration; - if (ogs_sbi_time_from_string( - &time, SubscriptionData->validity_time) == true) { - duration = time - ogs_time_now(); - if (duration < VALIDITY_MINIMUM) { - duration = VALIDITY_MINIMUM; - ogs_warn("%s Forced to %lld seconds", subscription->id, - (long long)ogs_time_sec(VALIDITY_MINIMUM)); - } - subscription->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - udm_timer_subscription_validity, subscription); - ogs_assert(subscription->t_validity); - ogs_timer_start(subscription->t_validity, duration); - } else { - ogs_error("Cannot parse validitiyTime %s", - SubscriptionData->validity_time); - } - } -} - -bool udm_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) -{ - int rv; - bool handled; - - ogs_sbi_response_t *response = NULL; - OpenAPI_notification_data_t *NotificationData = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_header_t header; - - ogs_assert(stream); - ogs_assert(recvmsg); - - NotificationData = recvmsg->NotificationData; - if (!NotificationData) { - ogs_error("No NotificationData"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NotificationData", NULL)); - return false; - } - - if (!NotificationData->nf_instance_uri) { - ogs_error("No nfInstanceUri"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No nfInstanceUri", NULL)); - return false; - } - - memset(&header, 0, sizeof(header)); - header.uri = NotificationData->nf_instance_uri; - - rv = ogs_sbi_parse_header(&message, &header); - if (rv != OGS_OK) { - ogs_error("Cannot parse nfInstanceUri %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - return false; - } - - if (!message.h.resource.component1) { - ogs_error("No nfInstanceId %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - ogs_sbi_header_free(&header); - return false; - } - - if (NF_INSTANCE_IS_SELF(message.h.resource.component1)) { - ogs_warn("%s The notification is not allowed", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_FORBIDDEN, - recvmsg, "The notification is not allowed", - message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - - if (NotificationData->event == - OpenAPI_notification_event_type_NF_REGISTERED) { - - OpenAPI_nf_profile_t *NFProfile = NULL; - - NFProfile = NotificationData->nf_profile; - if (!NFProfile) { - ogs_error("No NFProfile"); - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NFProfile", NULL)); - ogs_sbi_header_free(&header); - return false; - } - - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, - message.h.resource.component1); - - udm_nf_fsm_init(nf_instance); - - ogs_info("%s (NRF-notify) NF registered", nf_instance->id); - - } else { - OGS_FSM_TRAN(&nf_instance->sm, udm_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NRF-notify) NF has already been added", - message.h.resource.component1); - - } - - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, stream, recvmsg); - if (!handled) { - UDM_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - ogs_info("%s (NRF-notify) NF Profile updated", nf_instance->id); - - handled = ogs_sbi_client_associate(nf_instance); - if (!handled) { - ogs_error("%s Cannot associate NF EndPoint", nf_instance->id); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot find NF EndPoint", nf_instance->id)); - UDM_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - } else if (NotificationData->event == - OpenAPI_notification_event_type_NF_DEREGISTERED) { - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (nf_instance) { - UDM_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - } else { - ogs_warn("%s (NRF-notify) Not found", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_NOT_FOUND, - recvmsg, "Not found", message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - } else { - char *eventstr = OpenAPI_notification_event_type_ToString( - NotificationData->event); - ogs_error("Not supported event %d:%s", - NotificationData->event, eventstr ? eventstr : "Unknown"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Not supported event", - eventstr ? eventstr : "Unknown")); - ogs_sbi_header_free(&header); - return false; - } - - response = ogs_sbi_build_response(recvmsg, OGS_SBI_HTTP_STATUS_NO_CONTENT); - ogs_assert(response); - ogs_assert(true == ogs_sbi_server_send_response(stream, response)); - - ogs_sbi_header_free(&header); - return true; -} - void udm_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { ogs_sbi_object_t *sbi_object = NULL; OpenAPI_nf_type_e target_nf_type = 0; ogs_sbi_discovery_option_t *discovery_option = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; OpenAPI_search_result_t *SearchResult = NULL; - OpenAPI_lnode_t *node = NULL; - bool handled; ogs_assert(recvmsg); ogs_assert(xact); @@ -274,64 +44,8 @@ return; } - OpenAPI_list_for_each(SearchResult->nf_instances, node) { - OpenAPI_nf_profile_t *NFProfile = NULL; - - if (!node->data) continue; - - NFProfile = node->data; - - nf_instance = ogs_sbi_nf_instance_find(NFProfile->nf_instance_id); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id); - - udm_nf_fsm_init(nf_instance); - - ogs_info("%s (NF-discover) NF registered", nf_instance->id); - } else { - OGS_FSM_TRAN(&nf_instance->sm, udm_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NF-discover) NF has already been added", - NFProfile->nf_instance_id); - } - - if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) { - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, NULL, NULL); - if (!handled) { - ogs_error("%s ogs_sbi_nnrf_handle_nf_profile() failed", - nf_instance->id); - UDM_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); - continue; - } - - handled = ogs_sbi_client_associate(nf_instance); - if (!handled) { - ogs_error("%s Cannot assciate NF EndPoint", nf_instance->id); - UDM_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); - continue; - } - - /* TIME : Update validity from NRF */ - if (SearchResult->is_validity_period && - SearchResult->validity_period) { - nf_instance->time.validity_duration = - SearchResult->validity_period; - - ogs_assert(nf_instance->t_validity); - ogs_timer_start(nf_instance->t_validity, - ogs_time_from_sec(nf_instance->time.validity_duration)); - - } else - ogs_warn("%s NF Instance validity-time should not 0", - nf_instance->id); - - ogs_info("%s (NF-discover) NF Profile updated", nf_instance->id); - } - } + ogs_nnrf_handle_nf_discover_search_result( + sbi_object, target_nf_type, discovery_option, SearchResult); ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udm/nnrf-handler.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/udm/nnrf-handler.h
Changed
@@ -26,14 +26,6 @@ extern "C" { #endif -void udm_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg); -void udm_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg); - -bool udm_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); - void udm_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udm/sbi-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/udm/sbi-path.c
Changed
@@ -27,17 +27,17 @@ ogs_assert(request); ogs_assert(data); - e = udm_event_new(UDM_EVT_SBI_SERVER); + e = udm_event_new(OGS_EVENT_SBI_SERVER); ogs_assert(e); - e->sbi.request = request; - e->sbi.data = data; + e->h.sbi.request = request; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_request_free(request); - udm_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -58,16 +58,16 @@ ogs_assert(response); - e = udm_event_new(UDM_EVT_SBI_CLIENT); + e = udm_event_new(OGS_EVENT_SBI_CLIENT); ogs_assert(e); - e->sbi.response = response; - e->sbi.data = data; + e->h.sbi.response = response; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_response_free(response); - udm_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -79,6 +79,10 @@ ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_nf_service_t *service = NULL; + /* To be notified when NF Instances registered/deregistered in NRF + * or when their profile is modified */ + ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_UDR); + /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); @@ -119,27 +123,19 @@ } /* Initialize NRF NF Instance */ - ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_sbi_client_t *client = NULL; - - /* Client callback is only used when NF sends to NRF */ - client = nf_instance->client; - ogs_assert(client); - client->cb = client_cb; - - /* NFRegister is sent and the response is received - * by the above client callback. */ - udm_nf_fsm_init(nf_instance); - } - } - - /* Timer expiration handler of client wait timer */ - ogs_sbi_self()->client_wait_expire = udm_timer_sbi_client_wait_expire; - - /* NF register state in NF state machine */ - ogs_sbi_self()->nf_state_registered = - (ogs_fsm_handler_t)udm_nf_state_registered; + nf_instance = ogs_sbi_self()->nrf_instance; + if (nf_instance) { + ogs_sbi_client_t *client = NULL; + + /* Client callback is only used when NF sends to NRF */ + client = nf_instance->client; + ogs_assert(client); + client->cb = client_cb; + + /* NFRegister is sent and the response is received + * by the above client callback. */ + ogs_sbi_nf_fsm_init(nf_instance); + } if (ogs_sbi_server_start_all(server_cb) != OGS_OK) return OGS_ERROR;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udm/sbi-path.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/udm/sbi-path.h
Changed
@@ -20,7 +20,6 @@ #ifndef UDM_SBI_PATH_H #define UDM_SBI_PATH_H -#include "nnrf-build.h" #include "nudr-build.h" #ifdef __cplusplus
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udm/udm-sm.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/udm/udm-sm.c
Changed
@@ -54,17 +54,17 @@ ogs_assert(s); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case UDM_EVT_SBI_SERVER: - request = e->sbi.request; + case OGS_EVENT_SBI_SERVER: + request = e->h.sbi.request; ogs_assert(request); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); rv = ogs_sbi_parse_request(&message, request); @@ -103,7 +103,7 @@ CASE(OGS_SBI_RESOURCE_NAME_NF_STATUS_NOTIFY) SWITCH(message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) - udm_nnrf_handle_nf_status_notify(stream, &message); + ogs_nnrf_handle_nf_status_notify(stream, &message); break; DEFAULT @@ -178,7 +178,7 @@ ogs_assert(OGS_FSM_STATE(&udm_ue->sm)); e->udm_ue = udm_ue; - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&udm_ue->sm, e); if (OGS_FSM_CHECK(&udm_ue->sm, udm_ue_state_exception)) { ogs_error("%s State machine exception", udm_ue->suci); @@ -198,10 +198,10 @@ ogs_sbi_message_free(&message); break; - case UDM_EVT_SBI_CLIENT: + case OGS_EVENT_SBI_CLIENT: ogs_assert(e); - response = e->sbi.response; + response = e->h.sbi.response; ogs_assert(response); rv = ogs_sbi_parse_response(&message, response); if (rv != OGS_OK) { @@ -231,23 +231,23 @@ SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - nf_instance = e->sbi.data; + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&nf_instance->sm, e); break; CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS) - subscription = e->sbi.data; + subscription = e->h.sbi.data; ogs_assert(subscription); SWITCH(message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) if (message.res_status == OGS_SBI_HTTP_STATUS_CREATED || message.res_status == OGS_SBI_HTTP_STATUS_OK) { - udm_nnrf_handle_nf_status_subscribe( + ogs_nnrf_handle_nf_status_subscribe( subscription, &message); } else { ogs_error("%s HTTP response error %d", @@ -282,7 +282,7 @@ CASE(OGS_SBI_SERVICE_NAME_NNRF_DISC) SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); SWITCH(message.h.method) @@ -310,7 +310,7 @@ CASE(OGS_SBI_SERVICE_NAME_NUDR_DR) SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTION_DATA) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); sbi_xact = ogs_sbi_xact_cycle(sbi_xact); @@ -324,7 +324,7 @@ udm_ue = (udm_ue_t *)sbi_xact->sbi_object; ogs_assert(udm_ue); - e->sbi.data = sbi_xact->assoc_stream; + e->h.sbi.data = sbi_xact->assoc_stream; ogs_sbi_xact_remove(sbi_xact); @@ -335,7 +335,7 @@ } e->udm_ue = udm_ue; - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&udm_ue->sm, e); if (OGS_FSM_CHECK(&udm_ue->sm, udm_ue_state_exception)) { @@ -361,27 +361,27 @@ ogs_sbi_response_free(response); break; - case UDM_EVT_SBI_TIMER: + case OGS_EVENT_SBI_TIMER: ogs_assert(e); - switch(e->timer_id) { - case UDM_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case UDM_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case UDM_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case UDM_TIMER_NF_INSTANCE_VALIDITY: - nf_instance = e->sbi.data; + switch(e->h.timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + case OGS_TIMER_NF_INSTANCE_VALIDITY: + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); ogs_fsm_dispatch(&nf_instance->sm, e); - if (OGS_FSM_CHECK(&nf_instance->sm, udm_nf_state_exception)) + if (OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_exception)) ogs_error("%s:%s State machine exception %d", OpenAPI_nf_type_ToString(nf_instance->nf_type), - nf_instance->id, e->timer_id); + nf_instance->id, e->h.timer_id); break; - case UDM_TIMER_SUBSCRIPTION_VALIDITY: - subscription = e->sbi.data; + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + subscription = e->h.sbi.data; ogs_assert(subscription); ogs_assert(ogs_sbi_self()->nf_instance); @@ -395,8 +395,8 @@ ogs_sbi_subscription_remove(subscription); break; - case UDM_TIMER_SBI_CLIENT_WAIT: - sbi_xact = e->sbi.data; + case OGS_TIMER_SBI_CLIENT_WAIT: + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); stream = sbi_xact->assoc_stream; @@ -413,7 +413,7 @@ default: ogs_error("Unknown timer%s:%d", - udm_timer_get_name(e->timer_id), e->timer_id); + ogs_timer_get_name(e->h.timer_id), e->h.timer_id); } break;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udm/udm-sm.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/udm/udm-sm.h
Changed
@@ -30,16 +30,6 @@ void udm_state_final(ogs_fsm_t *s, udm_event_t *e); void udm_state_operational(ogs_fsm_t *s, udm_event_t *e); -void udm_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance); -void udm_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance); - -void udm_nf_state_initial(ogs_fsm_t *s, udm_event_t *e); -void udm_nf_state_final(ogs_fsm_t *s, udm_event_t *e); -void udm_nf_state_will_register(ogs_fsm_t *s, udm_event_t *e); -void udm_nf_state_registered(ogs_fsm_t *s, udm_event_t *e); -void udm_nf_state_de_registered(ogs_fsm_t *s, udm_event_t *e); -void udm_nf_state_exception(ogs_fsm_t *s, udm_event_t *e); - void udm_ue_state_initial(ogs_fsm_t *s, udm_event_t *e); void udm_ue_state_final(ogs_fsm_t *s, udm_event_t *e); void udm_ue_state_operational(ogs_fsm_t *s, udm_event_t *e);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udm/ue-sm.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/udm/ue-sm.c
Changed
@@ -48,17 +48,17 @@ udm_ue = e->udm_ue; ogs_assert(udm_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case UDM_EVT_SBI_SERVER: - message = e->sbi.message; + case OGS_EVENT_SBI_SERVER: + message = e->h.sbi.message; ogs_assert(message); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); SWITCH(message->h.service.name) @@ -181,13 +181,13 @@ END break; - case UDM_EVT_SBI_CLIENT: - message = e->sbi.message; + case OGS_EVENT_SBI_CLIENT: + message = e->h.sbi.message; ogs_assert(message); udm_ue = e->udm_ue; ogs_assert(udm_ue); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); SWITCH(message->h.service.name) @@ -252,7 +252,7 @@ udm_ue = e->udm_ue; ogs_assert(udm_ue); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udr/context.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/udr/context.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. *
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udr/context.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/udr/context.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -25,7 +25,6 @@ #include "ogs-sbi.h" #include "udr-sm.h" -#include "timer.h" #ifdef __cplusplus extern "C" { @@ -41,22 +40,6 @@ typedef struct udr_context_s { } udr_context_t; -#define UDR_NF_INSTANCE_CLEAR(_cAUSE, _nFInstance) \ - do { \ - ogs_assert(_nFInstance); \ - if ((_nFInstance)->reference_count == 1) { \ - ogs_info("%s (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ - udr_nf_fsm_fini((_nFInstance)); \ - ogs_sbi_nf_instance_remove(_nFInstance); \ - } else { \ - /* There is an assocation with other context */ \ - ogs_info("%s:%d (%s) NF suspended", \ - _nFInstance->id, _nFInstance->reference_count, (_cAUSE)); \ - OGS_FSM_TRAN(&_nFInstance->sm, udr_nf_state_de_registered); \ - ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ - } \ - } while(0) - void udr_context_init(void); void udr_context_final(void); udr_context_t *udr_self(void);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udr/event.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/udr/event.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -18,60 +18,42 @@ */ #include "event.h" -#include "context.h" -static OGS_POOL(pool, udr_event_t); - -void udr_event_init(void) -{ - ogs_pool_init(&pool, ogs_app()->pool.event); -} - -void udr_event_final(void) -{ - ogs_pool_final(&pool); -} - -udr_event_t *udr_event_new(udr_event_e id) +udr_event_t *udr_event_new(int id) { udr_event_t *e = NULL; - ogs_pool_alloc(&pool, &e); + e = ogs_event_size(id, sizeof(udr_event_t)); ogs_assert(e); - memset(e, 0, sizeof(*e)); - e->id = id; + e->h.id = id; return e; } -void udr_event_free(udr_event_t *e) -{ - ogs_assert(e); - ogs_pool_free(&pool, e); -} - const char *udr_event_get_name(udr_event_t *e) { - if (e == NULL) + if (e == NULL) { return OGS_FSM_NAME_INIT_SIG; + } - switch (e->id) { - case OGS_FSM_ENTRY_SIG: + switch (e->h.id) { + case OGS_FSM_ENTRY_SIG: return OGS_FSM_NAME_ENTRY_SIG; - case OGS_FSM_EXIT_SIG: + case OGS_FSM_EXIT_SIG: return OGS_FSM_NAME_EXIT_SIG; - case UDR_EVT_SBI_SERVER: - return "UDR_EVT_SBI_SERVER"; - case UDR_EVT_SBI_CLIENT: - return "UDR_EVT_SBI_CLIENT"; - case UDR_EVT_SBI_TIMER: - return "UDR_EVT_SBI_TIMER"; + case OGS_EVENT_SBI_SERVER: + return OGS_EVENT_NAME_SBI_SERVER; + case OGS_EVENT_SBI_CLIENT: + return OGS_EVENT_NAME_SBI_CLIENT; + case OGS_EVENT_SBI_TIMER: + return OGS_EVENT_NAME_SBI_TIMER; - default: - break; + default: + break; } + ogs_error("Unknown Event%d", e->h.id); return "UNKNOWN_EVENT"; }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udr/event.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/udr/event.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,49 +20,17 @@ #ifndef UDR_EVENT_H #define UDR_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { #endif -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_nf_instance_s ogs_sbi_nf_instance_t; -typedef struct ogs_sbi_subscription_s ogs_sbi_subscription_t; - -typedef enum { - UDR_EVT_BASE = OGS_FSM_USER_SIG, - - UDR_EVT_SBI_SERVER, - UDR_EVT_SBI_CLIENT, - UDR_EVT_SBI_TIMER, - - UDR_EVT_TOP, - -} udr_event_e; - typedef struct udr_event_s { - int id; - int timer_id; - - struct { - ogs_sbi_request_t *request; - ogs_sbi_response_t *response; - void *data; - - ogs_sbi_message_t *message; - } sbi; - - ogs_timer_t *timer; + ogs_event_t h; } udr_event_t; -void udr_event_init(void); -void udr_event_final(void); - -udr_event_t *udr_event_new(udr_event_e id); -void udr_event_free(udr_event_t *e); +udr_event_t *udr_event_new(int id); const char *udr_event_get_name(udr_event_t *e);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udr/init.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/udr/init.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -30,7 +30,6 @@ ogs_sbi_context_init(); udr_context_init(); - udr_event_init(); rv = ogs_sbi_context_parse_config("udr", "nrf", "scp"); if (rv != OGS_OK) return rv; @@ -64,7 +63,7 @@ /* Sending NF Instance De-registeration to NRF */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) - udr_nf_fsm_fini(nf_instance); + ogs_sbi_nf_fsm_fini(nf_instance); /* Starting holding timer */ t_termination_holding = ogs_timer_add(ogs_app()->timer_mgr, NULL, NULL); @@ -92,8 +91,6 @@ udr_context_final(); ogs_sbi_context_final(); - - udr_event_final(); /* Destroy event */ } static void udr_main(void *data) @@ -101,8 +98,7 @@ ogs_fsm_t udr_sm; int rv; - ogs_fsm_create(&udr_sm, udr_state_initial, udr_state_final); - ogs_fsm_init(&udr_sm, 0); + ogs_fsm_init(&udr_sm, udr_state_initial, udr_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -135,11 +131,10 @@ ogs_assert(e); ogs_fsm_dispatch(&udr_sm, e); - udr_event_free(e); + ogs_event_free(e); } } done: ogs_fsm_fini(&udr_sm, 0); - ogs_fsm_delete(&udr_sm); }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udr/meson.build -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/udr/meson.build
Changed
@@ -1,4 +1,4 @@ -# Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> +# Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> # This file is part of Open5GS. @@ -18,11 +18,6 @@ libudr_sources = files(''' context.c event.c - timer.c - - nnrf-build.c - nnrf-handler.c - nf-sm.c nudr-handler.c
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udr/nudr-handler.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/udr/nudr-handler.c
Changed
@@ -18,7 +18,6 @@ */ #include "sbi-path.h" -#include "nnrf-handler.h" #include "nudr-handler.h" bool udr_nudr_dr_handle_subscription_authentication(
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udr/sbi-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/udr/sbi-path.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -27,17 +27,17 @@ ogs_assert(request); ogs_assert(data); - e = udr_event_new(UDR_EVT_SBI_SERVER); + e = udr_event_new(OGS_EVENT_SBI_SERVER); ogs_assert(e); - e->sbi.request = request; - e->sbi.data = data; + e->h.sbi.request = request; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_request_free(request); - udr_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -58,16 +58,16 @@ ogs_assert(response); - e = udr_event_new(UDR_EVT_SBI_CLIENT); + e = udr_event_new(OGS_EVENT_SBI_CLIENT); ogs_assert(e); - e->sbi.response = response; - e->sbi.data = data; + e->h.sbi.response = response; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_response_free(response); - udr_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -100,28 +100,20 @@ } /* Initialize NRF NF Instance */ - ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_sbi_client_t *client = NULL; - - /* Client callback is only used when NF sends to NRF */ - client = nf_instance->client; - ogs_assert(client); - client->cb = client_cb; - - /* NFRegister is sent and the response is received - * by the above client callback. */ - udr_nf_fsm_init(nf_instance); - } + nf_instance = ogs_sbi_self()->nrf_instance; + if (nf_instance) { + ogs_sbi_client_t *client = NULL; + + /* Client callback is only used when NF sends to NRF */ + client = nf_instance->client; + ogs_assert(client); + client->cb = client_cb; + + /* NFRegister is sent and the response is received + * by the above client callback. */ + ogs_sbi_nf_fsm_init(nf_instance); } - /* Timer expiration handler of client wait timer */ - ogs_sbi_self()->client_wait_expire = udr_timer_sbi_client_wait_expire; - - /* NF register state in NF state machine */ - ogs_sbi_self()->nf_state_registered = - (ogs_fsm_handler_t)udr_nf_state_registered; - if (ogs_sbi_server_start_all(server_cb) != OGS_OK) return OGS_ERROR;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udr/sbi-path.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/udr/sbi-path.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,7 +20,7 @@ #ifndef UDR_SBI_PATH_H #define UDR_SBI_PATH_H -#include "nnrf-build.h" +#include "context.h" #ifdef __cplusplus extern "C" {
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udr/udr-sm.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/udr/udr-sm.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -18,7 +18,6 @@ */ #include "sbi-path.h" -#include "nnrf-handler.h" #include "nudr-handler.h" void udr_state_initial(ogs_fsm_t *s, udr_event_t *e) @@ -53,17 +52,17 @@ ogs_assert(s); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case UDR_EVT_SBI_SERVER: - request = e->sbi.request; + case OGS_EVENT_SBI_SERVER: + request = e->h.sbi.request; ogs_assert(request); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); rv = ogs_sbi_parse_request(&message, request); @@ -94,7 +93,7 @@ CASE(OGS_SBI_RESOURCE_NAME_NF_STATUS_NOTIFY) SWITCH(message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) - udr_nnrf_handle_nf_status_notify(stream, &message); + ogs_nnrf_handle_nf_status_notify(stream, &message); break; DEFAULT @@ -188,10 +187,10 @@ ogs_sbi_message_free(&message); break; - case UDR_EVT_SBI_CLIENT: + case OGS_EVENT_SBI_CLIENT: ogs_assert(e); - response = e->sbi.response; + response = e->h.sbi.response; ogs_assert(response); rv = ogs_sbi_parse_response(&message, response); if (rv != OGS_OK) { @@ -213,23 +212,23 @@ SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - nf_instance = e->sbi.data; + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&nf_instance->sm, e); break; CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS) - subscription = e->sbi.data; + subscription = e->h.sbi.data; ogs_assert(subscription); SWITCH(message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) if (message.res_status == OGS_SBI_HTTP_STATUS_CREATED || message.res_status == OGS_SBI_HTTP_STATUS_OK) { - udr_nnrf_handle_nf_status_subscribe( + ogs_nnrf_handle_nf_status_subscribe( subscription, &message); } else { ogs_error("%s HTTP response error %d", @@ -270,26 +269,26 @@ ogs_sbi_response_free(response); break; - case UDR_EVT_SBI_TIMER: + case OGS_EVENT_SBI_TIMER: ogs_assert(e); - switch(e->timer_id) { - case UDR_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case UDR_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case UDR_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case UDR_TIMER_NF_INSTANCE_VALIDITY: - nf_instance = e->sbi.data; + switch(e->h.timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + case OGS_TIMER_NF_INSTANCE_VALIDITY: + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); ogs_fsm_dispatch(&nf_instance->sm, e); - if (OGS_FSM_CHECK(&nf_instance->sm, udr_nf_state_exception)) + if (OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_exception)) ogs_error("%s State machine exception %d", - nf_instance->id, e->timer_id); + nf_instance->id, e->h.timer_id); break; - case UDR_TIMER_SUBSCRIPTION_VALIDITY: - subscription = e->sbi.data; + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + subscription = e->h.sbi.data; ogs_assert(subscription); ogs_assert(ogs_sbi_self()->nf_instance); @@ -305,7 +304,7 @@ default: ogs_error("Unknown timer%s:%d", - udr_timer_get_name(e->timer_id), e->timer_id); + ogs_timer_get_name(e->h.timer_id), e->h.timer_id); } break;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/udr/udr-sm.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/udr/udr-sm.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. *
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/upf/event.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/upf/event.h
Changed
@@ -20,7 +20,7 @@ #ifndef UPF_EVENT_H #define UPF_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { @@ -32,7 +32,7 @@ typedef struct upf_sess_s upf_sess_t; typedef enum { - UPF_EVT_BASE = OGS_FSM_USER_SIG, + UPF_EVT_BASE = OGS_MAX_NUM_OF_PROTO_EVENT, UPF_EVT_N4_MESSAGE, UPF_EVT_N4_TIMER, @@ -44,9 +44,10 @@ typedef struct upf_event_s { int id; - ogs_pkbuf_t *pkbuf; int timer_id; + ogs_pkbuf_t *pkbuf; + ogs_pfcp_node_t *pfcp_node; ogs_pfcp_xact_t *pfcp_xact; ogs_pfcp_message_t *pfcp_message;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/upf/init.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/upf/init.c
Changed
@@ -97,8 +97,7 @@ ogs_fsm_t upf_sm; int rv; - ogs_fsm_create(&upf_sm, upf_state_initial, upf_state_final); - ogs_fsm_init(&upf_sm, 0); + ogs_fsm_init(&upf_sm, upf_state_initial, upf_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -137,5 +136,4 @@ done: ogs_fsm_fini(&upf_sm, 0); - ogs_fsm_delete(&upf_sm); }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/src/upf/pfcp-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/src/upf/pfcp-path.c
Changed
@@ -37,8 +37,7 @@ ogs_assert(node->t_association); } - ogs_fsm_create(&node->sm, upf_pfcp_state_initial, upf_pfcp_state_final); - ogs_fsm_init(&node->sm, &e); + ogs_fsm_init(&node->sm, upf_pfcp_state_initial, upf_pfcp_state_final, &e); } static void pfcp_node_fsm_fini(ogs_pfcp_node_t *node) @@ -51,7 +50,6 @@ e.pfcp_node = node; ogs_fsm_fini(&node->sm, &e); - ogs_fsm_delete(&node->sm); if (node->t_association) ogs_timer_delete(node->t_association);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/tests/af/af-sm.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/tests/af/af-sm.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -57,17 +57,17 @@ ogs_assert(s); - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: break; case OGS_FSM_EXIT_SIG: break; - case AF_EVT_SBI_SERVER: - request = e->sbi.request; + case OGS_EVENT_SBI_SERVER: + request = e->h.sbi.request; ogs_assert(request); - stream = e->sbi.data; + stream = e->h.sbi.data; ogs_assert(stream); rv = ogs_sbi_parse_request(&message, request); @@ -98,7 +98,7 @@ CASE(OGS_SBI_RESOURCE_NAME_NF_STATUS_NOTIFY) SWITCH(message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) - af_nnrf_handle_nf_status_notify(stream, &message); + ogs_nnrf_handle_nf_status_notify(stream, &message); break; DEFAULT @@ -189,10 +189,10 @@ ogs_sbi_message_free(&message); break; - case AF_EVT_SBI_CLIENT: + case OGS_EVENT_SBI_CLIENT: ogs_assert(e); - response = e->sbi.response; + response = e->h.sbi.response; ogs_assert(response); rv = ogs_sbi_parse_response(&message, response); if (rv != OGS_OK) { @@ -214,23 +214,23 @@ SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - nf_instance = e->sbi.data; + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); - e->sbi.message = &message; + e->h.sbi.message = &message; ogs_fsm_dispatch(&nf_instance->sm, e); break; CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS) - subscription = e->sbi.data; + subscription = e->h.sbi.data; ogs_assert(subscription); SWITCH(message.h.method) CASE(OGS_SBI_HTTP_METHOD_POST) if (message.res_status == OGS_SBI_HTTP_STATUS_CREATED || message.res_status == OGS_SBI_HTTP_STATUS_OK) { - af_nnrf_handle_nf_status_subscribe( + ogs_nnrf_handle_nf_status_subscribe( subscription, &message); } else { ogs_error("HTTP response error : %d", @@ -263,7 +263,7 @@ CASE(OGS_SBI_SERVICE_NAME_NNRF_DISC) SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); SWITCH(message.h.method) @@ -291,7 +291,7 @@ CASE(OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT) SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_PCF_BINDINGS) - sbi_xact = e->sbi.data; + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); sbi_xact = ogs_sbi_xact_cycle(sbi_xact); @@ -331,7 +331,7 @@ CASE(OGS_SBI_SERVICE_NAME_NPCF_POLICYAUTHORIZATION) SWITCH(message.h.resource.component0) CASE(OGS_SBI_RESOURCE_NAME_APP_SESSIONS) - sess = e->sbi.data; + sess = e->h.sbi.data; ogs_assert(sess); if (message.h.resource.component1) { @@ -393,25 +393,25 @@ ogs_sbi_response_free(response); break; - case AF_EVT_SBI_TIMER: + case OGS_EVENT_SBI_TIMER: ogs_assert(e); - switch(e->timer_id) { - case AF_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: - case AF_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: - case AF_TIMER_NF_INSTANCE_NO_HEARTBEAT: - case AF_TIMER_NF_INSTANCE_VALIDITY: - nf_instance = e->sbi.data; + switch(e->h.timer_id) { + case OGS_TIMER_NF_INSTANCE_REGISTRATION_INTERVAL: + case OGS_TIMER_NF_INSTANCE_HEARTBEAT_INTERVAL: + case OGS_TIMER_NF_INSTANCE_NO_HEARTBEAT: + case OGS_TIMER_NF_INSTANCE_VALIDITY: + nf_instance = e->h.sbi.data; ogs_assert(nf_instance); ogs_assert(OGS_FSM_STATE(&nf_instance->sm)); ogs_fsm_dispatch(&nf_instance->sm, e); - if (OGS_FSM_CHECK(&nf_instance->sm, af_nf_state_exception)) - ogs_error("State machine exception %d", e->timer_id); + if (OGS_FSM_CHECK(&nf_instance->sm, ogs_sbi_nf_state_exception)) + ogs_error("State machine exception %d", e->h.timer_id); break; - case AF_TIMER_SUBSCRIPTION_VALIDITY: - subscription = e->sbi.data; + case OGS_TIMER_SUBSCRIPTION_VALIDITY: + subscription = e->h.sbi.data; ogs_assert(subscription); ogs_assert(ogs_sbi_self()->nf_instance); @@ -425,8 +425,8 @@ ogs_sbi_subscription_remove(subscription); break; - case AF_TIMER_SBI_CLIENT_WAIT: - sbi_xact = e->sbi.data; + case OGS_TIMER_SBI_CLIENT_WAIT: + sbi_xact = e->h.sbi.data; ogs_assert(sbi_xact); stream = sbi_xact->assoc_stream; @@ -446,7 +446,7 @@ default: ogs_error("Unknown timer%s:%d", - af_timer_get_name(e->timer_id), e->timer_id); + ogs_timer_get_name(e->h.timer_id), e->h.timer_id); } break;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/tests/af/af-sm.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/tests/af/af-sm.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -31,16 +31,6 @@ void af_state_operational(ogs_fsm_t *s, af_event_t *e); void af_state_exception(ogs_fsm_t *s, af_event_t *e); -void af_nf_fsm_init(ogs_sbi_nf_instance_t *nf_instance); -void af_nf_fsm_fini(ogs_sbi_nf_instance_t *nf_instance); - -void af_nf_state_initial(ogs_fsm_t *s, af_event_t *e); -void af_nf_state_final(ogs_fsm_t *s, af_event_t *e); -void af_nf_state_will_register(ogs_fsm_t *s, af_event_t *e); -void af_nf_state_registered(ogs_fsm_t *s, af_event_t *e); -void af_nf_state_de_registered(ogs_fsm_t *s, af_event_t *e); -void af_nf_state_exception(ogs_fsm_t *s, af_event_t *e); - #define af_sm_debug(__pe) \ ogs_debug("%s(): %s", __func__, af_event_get_name(__pe))
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/tests/af/context.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/tests/af/context.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. *
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/tests/af/context.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/tests/af/context.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -24,7 +24,6 @@ #include "ogs-app.h" #include "event.h" -#include "timer.h" #include "local.h" #include "af-sm.h" @@ -46,22 +45,6 @@ ogs_list_t sess_list; } af_context_t; -#define AF_NF_INSTANCE_CLEAR(_cAUSE, _nFInstance) \ - do { \ - ogs_assert(_nFInstance); \ - if ((_nFInstance)->reference_count == 1) { \ - ogs_info("%s (%s) NF removed", (_nFInstance)->id, (_cAUSE)); \ - af_nf_fsm_fini((_nFInstance)); \ - ogs_sbi_nf_instance_remove(_nFInstance); \ - } else { \ - /* There is an assocation with other context */ \ - ogs_info("%s:%d (%s) NF suspended", \ - _nFInstance->id, _nFInstance->reference_count, (_cAUSE)); \ - OGS_FSM_TRAN(&_nFInstance->sm, af_nf_state_de_registered); \ - ogs_fsm_dispatch(&_nFInstance->sm, NULL); \ - } \ - } while(0) - typedef struct af_sess_s af_sess_t; typedef struct af_sess_s {
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/tests/af/event.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/tests/af/event.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -19,54 +19,37 @@ #include "context.h" -static OGS_POOL(pool, af_event_t); - -void af_event_init(void) -{ - ogs_pool_init(&pool, ogs_app()->pool.event); -} - -void af_event_final(void) -{ - ogs_pool_final(&pool); -} - -af_event_t *af_event_new(af_event_e id) +af_event_t *af_event_new(int id) { af_event_t *e = NULL; - ogs_pool_alloc(&pool, &e); + e = ogs_event_size(id, sizeof(af_event_t)); ogs_assert(e); - memset(e, 0, sizeof(*e)); - e->id = id; + e->h.id = id; return e; } -void af_event_free(af_event_t *e) -{ - ogs_assert(e); - ogs_pool_free(&pool, e); -} - const char *af_event_get_name(af_event_t *e) { - if (e == NULL) + if (e == NULL) { return OGS_FSM_NAME_INIT_SIG; + } - switch (e->id) { + switch (e->h.id) { case OGS_FSM_ENTRY_SIG: return OGS_FSM_NAME_ENTRY_SIG; case OGS_FSM_EXIT_SIG: return OGS_FSM_NAME_EXIT_SIG; - case AF_EVT_SBI_SERVER: - return "AF_EVT_SBI_SERVER"; - case AF_EVT_SBI_CLIENT: - return "AF_EVT_SBI_CLIENT"; - case AF_EVT_SBI_TIMER: - return "AF_EVT_SBI_TIMER"; + case OGS_EVENT_SBI_SERVER: + return OGS_EVENT_NAME_SBI_SERVER; + case OGS_EVENT_SBI_CLIENT: + return OGS_EVENT_NAME_SBI_CLIENT; + case OGS_EVENT_SBI_TIMER: + return OGS_EVENT_NAME_SBI_TIMER; + case AF_EVT_SBI_LOCAL: return "AF_EVT_SBI_LOCAL"; @@ -74,5 +57,6 @@ break; } + ogs_error("Unknown Event%d", e->h.id); return "UNKNOWN_EVENT"; }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/tests/af/event.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/tests/af/event.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,24 +20,17 @@ #ifndef AF_EVENT_H #define AF_EVENT_H -#include "ogs-core.h" +#include "ogs-proto.h" #ifdef __cplusplus extern "C" { #endif typedef struct af_sess_s af_sess_t; -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; typedef enum { - AF_EVT_BASE = OGS_FSM_USER_SIG, + AF_EVT_BASE = OGS_MAX_NUM_OF_PROTO_EVENT, - AF_EVT_SBI_SERVER, - AF_EVT_SBI_CLIENT, - AF_EVT_SBI_TIMER, AF_EVT_SBI_LOCAL, AF_EVT_TOP, @@ -45,34 +38,21 @@ } af_event_e; typedef struct af_event_s { - int id; - ogs_pkbuf_t *pkbuf; - int timer_id; + ogs_event_t h; int local_id; + ogs_pkbuf_t *pkbuf; + struct { OpenAPI_nf_type_e target_nf_type; void *data; ogs_sbi_request_t *(*build)(af_sess_t *sess, void *data); } local; - struct { - ogs_sbi_request_t *request; - ogs_sbi_response_t *response; - void *data; - int state; - - ogs_sbi_message_t *message; - } sbi; - af_sess_t *sess; } af_event_t; -void af_event_init(void); -void af_event_final(void); - -af_event_t *af_event_new(af_event_e id); -void af_event_free(af_event_t *e); +af_event_t *af_event_new(int id); const char *af_event_get_name(af_event_t *e);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/tests/af/init.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/tests/af/init.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -32,7 +32,6 @@ ogs_sbi_context_init(); af_context_init(); - af_event_init(); rv = ogs_sbi_context_parse_config("af", "nrf", "scp"); if (rv != OGS_OK) return rv; @@ -63,7 +62,7 @@ /* Sending NF Instance De-registeration to NRF */ ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) - af_nf_fsm_fini(nf_instance); + ogs_sbi_nf_fsm_fini(nf_instance); /* Starting holding timer */ t_termination_holding = ogs_timer_add(ogs_app()->timer_mgr, NULL, NULL); @@ -88,10 +87,7 @@ af_sbi_close(); af_context_final(); - ogs_sbi_context_final(); - - af_event_final(); /* Destroy event */ } static void af_main(void *data) @@ -99,8 +95,7 @@ ogs_fsm_t af_sm; int rv; - ogs_fsm_create(&af_sm, af_state_initial, af_state_final); - ogs_fsm_init(&af_sm, 0); + ogs_fsm_init(&af_sm, af_state_initial, af_state_final, 0); for ( ;; ) { ogs_pollset_poll(ogs_app()->pollset, @@ -133,11 +128,10 @@ ogs_assert(e); ogs_fsm_dispatch(&af_sm, e); - af_event_free(e); + ogs_event_free(e); } } done: ogs_fsm_fini(&af_sm, 0); - ogs_fsm_delete(&af_sm); }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/tests/af/init.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/tests/af/init.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. *
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/tests/af/local.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/tests/af/local.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -51,8 +51,8 @@ rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed %d in %s", - (int)rv, af_timer_get_name(e->timer_id)); - af_event_free(e); + (int)rv, af_local_get_name(e->local_id)); + ogs_event_free(e); } else { ogs_pollset_notify(ogs_app()->pollset); } @@ -77,8 +77,8 @@ rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed %d in %s", - (int)rv, af_timer_get_name(e->timer_id)); - af_event_free(e); + (int)rv, af_local_get_name(e->local_id)); + ogs_event_free(e); } else { ogs_pollset_notify(ogs_app()->pollset); }
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/tests/af/local.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/tests/af/local.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. *
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/tests/af/meson.build -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/tests/af/meson.build
Changed
@@ -1,4 +1,4 @@ -# Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com> +# Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> # This file is part of Open5GS. @@ -18,12 +18,9 @@ libaf_sources = files(''' context.c event.c - timer.c local.c - nnrf-build.c nnrf-handler.c - nf-sm.c nbsf-build.c nbsf-handler.c
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/tests/af/nbsf-handler.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/tests/af/nbsf-handler.c
Changed
@@ -28,9 +28,6 @@ OpenAPI_pcf_binding_t *PcfBinding = NULL; OpenAPI_list_t *PcfIpEndPointList = NULL; OpenAPI_lnode_t *node = NULL; -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - char fqdnOGS_MAX_FQDN_LEN; -#endif ogs_assert(sess); ogs_assert(recvmsg); @@ -46,19 +43,10 @@ } if (PcfBinding->pcf_fqdn) { -#if SBI_FQDN_WITH_ONE_OCTET_LENGTH - ogs_assert(0 < ogs_fqdn_parse(fqdn, PcfBinding->pcf_fqdn, - ogs_min(strlen(PcfBinding->pcf_fqdn), OGS_MAX_FQDN_LEN))); - if (sess->pcf.fqdn) - ogs_free(sess->pcf.fqdn); - sess->pcf.fqdn = ogs_strdup(fqdn); - ogs_assert(sess->pcf.fqdn); -#else if (sess->pcf.fqdn) ogs_free(sess->pcf.fqdn); sess->pcf.fqdn = ogs_strdup(PcfBinding->pcf_fqdn); ogs_assert(sess->pcf.fqdn); -#endif } PcfIpEndPointList = PcfBinding->pcf_ip_end_points;
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/tests/af/nnrf-handler.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/tests/af/nnrf-handler.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,248 +20,14 @@ #include "sbi-path.h" #include "nnrf-handler.h" -void af_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_nf_profile_t *NFProfile = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(nf_instance); - client = nf_instance->client; - ogs_assert(client); - - NFProfile = recvmsg->NFProfile; - if (!NFProfile) { - ogs_error("No NFProfile"); - return; - } - - /* TIME : Update heartbeat from NRF */ - if (NFProfile->nf_profile_changes_ind == true) { - if (NFProfile->heart_beat_timer) - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; - } else { - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; - } -} - -void af_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg) -{ - OpenAPI_subscription_data_t *SubscriptionData = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(recvmsg); - ogs_assert(subscription); - client = subscription->client; - ogs_assert(client); - - SubscriptionData = recvmsg->SubscriptionData; - if (!SubscriptionData) { - ogs_error("No SubscriptionData"); - return; - } - - if (!SubscriptionData->subscription_id) { - ogs_error("No SubscriptionId"); - return; - } - ogs_sbi_subscription_set_id( - subscription, SubscriptionData->subscription_id); - - if (SubscriptionData->validity_time) { -#define VALIDITY_MINIMUM (10LL * OGS_USEC_PER_SEC) /* 10 seconds */ - ogs_time_t time, duration; - if (ogs_sbi_time_from_string( - &time, SubscriptionData->validity_time) == true) { - duration = time - ogs_time_now(); - if (duration < VALIDITY_MINIMUM) { - duration = VALIDITY_MINIMUM; - ogs_warn("%s Forced to %lld seconds", subscription->id, - (long long)ogs_time_sec(VALIDITY_MINIMUM)); - } - subscription->t_validity = ogs_timer_add(ogs_app()->timer_mgr, - af_timer_subscription_validity, subscription); - ogs_assert(subscription->t_validity); - ogs_timer_start(subscription->t_validity, duration); - } else { - ogs_error("Cannot parse validitiyTime %s", - SubscriptionData->validity_time); - } - } -} - -bool af_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg) -{ - int rv; - bool handled; - - ogs_sbi_response_t *response = NULL; - OpenAPI_notification_data_t *NotificationData = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; - - ogs_sbi_message_t message; - ogs_sbi_header_t header; - - ogs_assert(stream); - ogs_assert(recvmsg); - - NotificationData = recvmsg->NotificationData; - if (!NotificationData) { - ogs_error("No NotificationData"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NotificationData", NULL)); - return false; - } - - if (!NotificationData->nf_instance_uri) { - ogs_error("No nfInstanceUri"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No nfInstanceUri", NULL)); - return false; - } - - memset(&header, 0, sizeof(header)); - header.uri = NotificationData->nf_instance_uri; - - rv = ogs_sbi_parse_header(&message, &header); - if (rv != OGS_OK) { - ogs_error("Cannot parse nfInstanceUri %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - return false; - } - - if (!message.h.resource.component1) { - ogs_error("No nfInstanceId %s", header.uri); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot parse nfInstanceUri", header.uri)); - ogs_sbi_header_free(&header); - return false; - } - - if (NF_INSTANCE_IS_SELF(message.h.resource.component1)) { - ogs_warn("%s The notification is not allowed", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_FORBIDDEN, - recvmsg, "The notification is not allowed", - message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - - if (NotificationData->event == - OpenAPI_notification_event_type_NF_REGISTERED) { - - OpenAPI_nf_profile_t *NFProfile = NULL; - - NFProfile = NotificationData->nf_profile; - if (!NFProfile) { - ogs_error("No NFProfile"); - ogs_assert(true == - ogs_sbi_server_send_error( - stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "No NFProfile", NULL)); - ogs_sbi_header_free(&header); - return false; - } - - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, - message.h.resource.component1); - - af_nf_fsm_init(nf_instance); - - ogs_info("%s (NRF-notify) NF registered", nf_instance->id); - - } else { - OGS_FSM_TRAN(&nf_instance->sm, af_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NRF-notify) NF has already been added", - message.h.resource.component1); - - } - - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, stream, recvmsg); - if (!handled) { - AF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - ogs_info("%s (NRF-notify) NF Profile updated", nf_instance->id); - - handled = ogs_sbi_client_associate(nf_instance); - if (!handled) { - ogs_error("%s Cannot associate NF EndPoint", nf_instance->id); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Cannot find NF EndPoint", nf_instance->id)); - AF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - ogs_sbi_header_free(&header); - return false; - } - - } else if (NotificationData->event == - OpenAPI_notification_event_type_NF_DEREGISTERED) { - nf_instance = ogs_sbi_nf_instance_find(message.h.resource.component1); - if (nf_instance) { - AF_NF_INSTANCE_CLEAR("NRF-notify", nf_instance); - } else { - ogs_warn("%s (NRF-notify) Not found", - message.h.resource.component1); - ogs_assert(true == - ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_NOT_FOUND, - recvmsg, "Not found", message.h.resource.component1)); - ogs_sbi_header_free(&header); - return false; - } - } else { - char *eventstr = OpenAPI_notification_event_type_ToString( - NotificationData->event); - ogs_error("Not supported event %d:%s", - NotificationData->event, eventstr ? eventstr : "Unknown"); - ogs_assert(true == - ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, - recvmsg, "Not supported event", - eventstr ? eventstr : "Unknown")); - ogs_sbi_header_free(&header); - return false; - } - - response = ogs_sbi_build_response(recvmsg, OGS_SBI_HTTP_STATUS_NO_CONTENT); - ogs_assert(response); - ogs_assert(true == ogs_sbi_server_send_response(stream, response)); - - ogs_sbi_header_free(&header); - return true; -} - void af_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg) { ogs_sbi_object_t *sbi_object = NULL; OpenAPI_nf_type_e target_nf_type = 0; ogs_sbi_discovery_option_t *discovery_option = NULL; - ogs_sbi_nf_instance_t *nf_instance = NULL; OpenAPI_search_result_t *SearchResult = NULL; - OpenAPI_lnode_t *node = NULL; - bool handled; ogs_assert(recvmsg); ogs_assert(xact); @@ -278,63 +44,8 @@ return; } - OpenAPI_list_for_each(SearchResult->nf_instances, node) { - OpenAPI_nf_profile_t *NFProfile = NULL; - - if (!node->data) continue; - - NFProfile = node->data; - - nf_instance = ogs_sbi_nf_instance_find(NFProfile->nf_instance_id); - if (!nf_instance) { - nf_instance = ogs_sbi_nf_instance_add(); - ogs_assert(nf_instance); - ogs_sbi_nf_instance_set_id(nf_instance, NFProfile->nf_instance_id); - - af_nf_fsm_init(nf_instance); - - ogs_info("%s (NF-discover) NF registered", nf_instance->id); - } else { - OGS_FSM_TRAN(&nf_instance->sm, af_nf_state_registered); - ogs_fsm_dispatch(&nf_instance->sm, NULL); - - ogs_warn("%s (NF-discover) NF has already been added", - NFProfile->nf_instance_id); - } - - if (NF_INSTANCE_IS_OTHERS(nf_instance->id)) { - handled = ogs_sbi_nnrf_handle_nf_profile( - nf_instance, NFProfile, NULL, NULL); - if (!handled) { - ogs_error("ogs_sbi_nnrf_handle_nf_profile() failed %s", - nf_instance->id); - AF_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); - continue; - } - - handled = ogs_sbi_client_associate(nf_instance); - if (!handled) { - ogs_error("%s Cannot assciate NF EndPoint", nf_instance->id); - AF_NF_INSTANCE_CLEAR("NRF-discover", nf_instance); - continue; - } - - /* TIME : Update validity from NRF */ - if (SearchResult->validity_period) { - nf_instance->time.validity_duration = - SearchResult->validity_period; - - ogs_assert(nf_instance->t_validity); - ogs_timer_start(nf_instance->t_validity, - ogs_time_from_sec(nf_instance->time.validity_duration)); - - } else - ogs_warn("%s NF Instance validity-time should not 0", - nf_instance->id); - - ogs_info("%s (NF-discover) NF Profile updated", nf_instance->id); - } - } + ogs_nnrf_handle_nf_discover_search_result( + sbi_object, target_nf_type, discovery_option, SearchResult); ogs_sbi_select_nf(sbi_object, target_nf_type, discovery_option);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/tests/af/nnrf-handler.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/tests/af/nnrf-handler.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -26,14 +26,6 @@ extern "C" { #endif -void af_nnrf_handle_nf_register( - ogs_sbi_nf_instance_t *nf_instance, ogs_sbi_message_t *recvmsg); -void af_nnrf_handle_nf_status_subscribe( - ogs_sbi_subscription_t *subscription, ogs_sbi_message_t *recvmsg); - -bool af_nnrf_handle_nf_status_notify( - ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg); - void af_nnrf_handle_nf_discover( ogs_sbi_xact_t *xact, ogs_sbi_message_t *recvmsg);
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/tests/af/sbi-path.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/tests/af/sbi-path.c
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -27,17 +27,17 @@ ogs_assert(request); ogs_assert(data); - e = af_event_new(AF_EVT_SBI_SERVER); + e = af_event_new(OGS_EVENT_SBI_SERVER); ogs_assert(e); - e->sbi.request = request; - e->sbi.data = data; + e->h.sbi.request = request; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_request_free(request); - af_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -58,16 +58,16 @@ ogs_assert(response); - e = af_event_new(AF_EVT_SBI_CLIENT); + e = af_event_new(OGS_EVENT_SBI_CLIENT); ogs_assert(e); - e->sbi.response = response; - e->sbi.data = data; + e->h.sbi.response = response; + e->h.sbi.data = data; rv = ogs_queue_push(ogs_app()->queue, e); if (rv != OGS_OK) { ogs_error("ogs_queue_push() failed:%d", (int)rv); ogs_sbi_response_free(response); - af_event_free(e); + ogs_event_free(e); return OGS_ERROR; } @@ -79,6 +79,10 @@ ogs_sbi_nf_instance_t *nf_instance = NULL; ogs_sbi_nf_service_t *service = NULL; + /* To be notified when NF Instances registered/deregistered in NRF + * or when their profile is modified */ + ogs_sbi_add_to_be_notified_nf_type(OpenAPI_nf_type_BSF); + /* Add SELF NF instance */ nf_instance = ogs_sbi_self()->nf_instance; ogs_assert(nf_instance); @@ -97,32 +101,23 @@ } /* Initialize NRF NF Instance */ - ogs_list_for_each(&ogs_sbi_self()->nf_instance_list, nf_instance) { - if (NF_INSTANCE_IS_NRF(nf_instance)) { - ogs_sbi_client_t *client = NULL; - - /* Client callback is only used when NF sends to NRF */ - client = nf_instance->client; - ogs_assert(client); - client->cb = client_cb; - - /* NFRegister is sent and the response is received - * by the above client callback. */ - af_nf_fsm_init(nf_instance); - } + nf_instance = ogs_sbi_self()->nrf_instance; + if (nf_instance) { + ogs_sbi_client_t *client = NULL; + + /* Client callback is only used when NF sends to NRF */ + client = nf_instance->client; + ogs_assert(client); + client->cb = client_cb; + + /* NFRegister is sent and the response is received + * by the above client callback. */ + ogs_sbi_nf_fsm_init(nf_instance); } - /* Timer expiration handler of client wait timer */ - ogs_sbi_self()->client_wait_expire = af_timer_sbi_client_wait_expire; - - /* NF register state in NF state machine */ - ogs_sbi_self()->nf_state_registered = - (ogs_fsm_handler_t)af_nf_state_registered; - if (ogs_sbi_server_start_all(server_cb) != OGS_OK) return OGS_ERROR; - return OGS_OK; } @@ -132,21 +127,6 @@ ogs_sbi_server_stop_all(); } -bool af_nnrf_nfm_send_nf_register(ogs_sbi_nf_instance_t *nf_instance) -{ - ogs_sbi_request_t *request = NULL; - ogs_sbi_client_t *client = NULL; - - ogs_assert(nf_instance); - client = nf_instance->client; - ogs_assert(client); - - request = af_nnrf_nfm_build_register(); - ogs_expect_or_return_val(request, false); - return ogs_sbi_client_send_request( - client, client->cb, request, nf_instance); -} - bool af_sbi_send_request( ogs_sbi_object_t *sbi_object, OpenAPI_nf_type_e target_nf_type,
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/tests/af/sbi-path.h -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/tests/af/sbi-path.h
Changed
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com> + * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com> * * This file is part of Open5GS. * @@ -20,7 +20,6 @@ #ifndef AF_SBI_PATH_H #define AF_SBI_PATH_H -#include "nnrf-build.h" #include "nbsf-build.h" #include "npcf-build.h" @@ -31,8 +30,6 @@ int af_sbi_open(void); void af_sbi_close(void); -bool af_nnrf_nfm_send_nf_register(ogs_sbi_nf_instance_t *nf_instance); - bool af_sbi_send_request( ogs_sbi_object_t *sbi_object, OpenAPI_nf_type_e target_nf_type,
View file
open5gs_2.4.9.14.ec9fe.202208120002.tar.xz/tests/core/fsm-test.c -> open5gs_2.4.9.17.603a74.202208130002.tar.xz/tests/core/fsm-test.c
Changed
@@ -41,12 +41,6 @@ void bomb_setting(bomb_t *s, tick_event_t *e); void bomb_timing(bomb_t *s, tick_event_t *e); -void bomb_create(bomb_t *s, uint8_t defuse) -{ - ogs_fsm_create(&s->fsm, &bomb_initial, 0); - s->defuse = defuse; -} - void bomb_initial(bomb_t *s, tick_event_t *e) { s->timeout = 10; @@ -98,9 +92,8 @@ bomb_t bomb; tick_event_t tick_event; - bomb_create(&bomb, 14); - - ogs_fsm_init(&bomb, 0); + ogs_fsm_init(&bomb, &bomb_initial, 0, 0); + bomb.defuse = 14; ABTS_PTR_EQUAL(tc, &bomb_setting, OGS_FSM_STATE(&bomb)); ABTS_INT_EQUAL(tc, 10, bomb.timeout); @@ -246,9 +239,7 @@ set_event_t set_event; time_event_t time_event; - ogs_fsm_create(&alarm.fsm, &alarm_initial, 0); - - ogs_fsm_init(&alarm, 0); + ogs_fsm_init(&alarm, &alarm_initial, 0, 0); ABTS_PTR_EQUAL(tc, &alarm_off, OGS_FSM_STATE(&alarm)); ABTS_INT_EQUAL(tc, 1200, alarm.time);
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.