diff options
| author | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2024-11-12 11:58:52 -0300 |
|---|---|---|
| committer | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2024-11-12 12:11:54 -0300 |
| commit | 0bfb5da3109dee3cbd31bd479c08800c7ca43285 (patch) | |
| tree | 21fd49db4ba1627217838499cff3829281e71b4f | |
| parent | 78a892fdad3d84e2b170e057b245e43318459c31 (diff) | |
Added gh open5gs/freediameter commit as patches
17 files changed, 1855 insertions, 2 deletions
diff --git a/debian/patches/0001-Open5GS-Patch-for-freeDiameter-1.5.0.patch b/debian/patches/0001-Open5GS-Patch-for-freeDiameter-1.5.0.patch new file mode 100644 index 0000000..24f5e32 --- /dev/null +++ b/debian/patches/0001-Open5GS-Patch-for-freeDiameter-1.5.0.patch @@ -0,0 +1,971 @@ +From 365fe96e9a9f127a7fedeab47f43a891ebff4f74 Mon Sep 17 00:00:00 2001 +From: Sukchan Lee <acetcom@gmail.com> +Date: Sun, 21 Mar 2021 17:44:22 +0900 +Subject: [PATCH 01/16] Open5GS Patch for freeDiameter-1.5.0 + +--- + extensions/dict_dcca/dict_dcca.c | 17 +- + extensions/dict_dcca_3gpp/dict_dcca_3gpp.c | 4 - + extensions/dict_nasreq/dict_nasreq.c | 2 +- + extensions/meson.build | 47 +++++ + include/freeDiameter/libfdproto.h | 2 +- + include/freeDiameter/meson.build | 185 ++++++++++++++++++++ + libfdcore/endpoints.c | 6 +- + libfdcore/fdd.y | 4 +- + libfdcore/meson.build | 78 +++++++++ + libfdcore/p_psm.c | 4 +- + libfdcore/peers.c | 4 + + libfdcore/sctp-internal.h | 18 ++ + libfdcore/sctp.c | 31 +++- + libfdcore/sctp_compat.c | 193 +++++++++++++++++++++ + libfdproto/meson.build | 48 +++++ + meson.build | 71 ++++++++ + 16 files changed, 693 insertions(+), 21 deletions(-) + create mode 100644 extensions/meson.build + create mode 100644 include/freeDiameter/meson.build + create mode 100644 libfdcore/meson.build + create mode 100644 libfdcore/sctp-internal.h + create mode 100644 libfdcore/sctp_compat.c + create mode 100644 libfdproto/meson.build + create mode 100644 meson.build + +diff --git a/extensions/dict_dcca/dict_dcca.c b/extensions/dict_dcca/dict_dcca.c +index 5d94603..8ab5a97 100644 +--- a/extensions/dict_dcca/dict_dcca.c ++++ b/extensions/dict_dcca/dict_dcca.c +@@ -69,11 +69,16 @@ static int dict_dcca_entry(char * conffile) + + /* Applications section */ + { +- /* DCCA */ +- { +- struct dict_application_data data = { 4, "Diameter Credit Control Application" }; +- CHECK_dict_new( DICT_APPLICATION, &data, NULL, &dcca); +- } ++ { ++ struct dict_vendor_data vendor_data = { 10415, "3GPP" }; ++ CHECK_FCT(fd_dict_new(fd_g_config->cnf_dict, DICT_VENDOR, &vendor_data, NULL, NULL)); ++ } ++ { ++ struct dict_object * vendor; ++ CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_BY_NAME, "3GPP", &vendor, ENOENT)); ++ struct dict_application_data app_data = { 16777238, "Gx" }; ++ CHECK_FCT(fd_dict_new(fd_g_config->cnf_dict, DICT_APPLICATION, &app_data, vendor, &dcca)); ++ } + } + + /* Result codes */ +@@ -1362,7 +1367,7 @@ static int dict_dcca_entry(char * conffile) + { "Origin-Realm", RULE_REQUIRED, -1, 1 }, + { "Destination-Realm", RULE_REQUIRED, -1, 1 }, + { "Auth-Application-Id", RULE_REQUIRED, -1, 1 }, +- { "Service-Context-Id", RULE_REQUIRED, -1, 1 }, ++ { "Service-Context-Id", RULE_OPTIONAL, -1, 1 }, + { "CC-Request-Type", RULE_REQUIRED, -1, 1 }, + { "CC-Request-Number", RULE_REQUIRED, -1, 1 }, + { "Destination-Host", RULE_OPTIONAL, -1, 1 }, +diff --git a/extensions/dict_dcca_3gpp/dict_dcca_3gpp.c b/extensions/dict_dcca_3gpp/dict_dcca_3gpp.c +index 3d58cf6..038e707 100644 +--- a/extensions/dict_dcca_3gpp/dict_dcca_3gpp.c ++++ b/extensions/dict_dcca_3gpp/dict_dcca_3gpp.c +@@ -153,10 +153,6 @@ static int dict_dcca_3gpp_entry(char * conffile) + + { + /* Create the vendors */ +- { +- struct dict_vendor_data vendor_data = { 10415, "3GPP" }; +- CHECK_FCT(fd_dict_new(fd_g_config->cnf_dict, DICT_VENDOR, &vendor_data, NULL, NULL)); +- } + { + struct dict_vendor_data vendor_data = { 5535, "3GPP2" }; + CHECK_FCT(fd_dict_new(fd_g_config->cnf_dict, DICT_VENDOR, &vendor_data, NULL, NULL)); +diff --git a/extensions/dict_nasreq/dict_nasreq.c b/extensions/dict_nasreq/dict_nasreq.c +index 0878ae1..1d96f23 100644 +--- a/extensions/dict_nasreq/dict_nasreq.c ++++ b/extensions/dict_nasreq/dict_nasreq.c +@@ -3013,7 +3013,7 @@ static int dnr_entry(char * conffile) + ,{ "Origin-Host", RULE_REQUIRED, -1, 1 } + ,{ "Origin-Realm", RULE_REQUIRED, -1, 1 } + ,{ "Destination-Realm", RULE_REQUIRED, -1, 1 } +- ,{ "Auth-Request-Type", RULE_REQUIRED, -1, 1 } ++ ,{ "Auth-Request-Type", RULE_OPTIONAL, -1, 1 } + ,{ "Destination-Host", RULE_OPTIONAL, -1, 1 } + ,{ "NAS-Identifier", RULE_OPTIONAL, -1, 1 } + ,{ "NAS-IP-Address", RULE_OPTIONAL, -1, 1 } +diff --git a/extensions/meson.build b/extensions/meson.build +new file mode 100644 +index 0000000..9c00f6d +--- /dev/null ++++ b/extensions/meson.build +@@ -0,0 +1,47 @@ ++# 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/>. ++ ++fd_ext_sources = (''' ++ dbg_msg_dumps ++ dict_rfc5777 ++ dict_mip6i ++ dict_nasreq ++ dict_nas_mipv6 ++ dict_dcca ++'''.split()) ++ ++foreach s : fd_ext_sources ++ shared_module(s, ++ sources : [files(join_paths(s, s+'.c'))], ++ include_directories : freeDiameter_includes, ++ dependencies : libfdcore_dep, ++ name_prefix : '', ++ name_suffix : 'fdx', ++ install : true, ++ install_dir : freeDiameter_extensionsdir) ++endforeach ++ ++shared_module('dict_dcca_3gpp', ++ sources : [files( ++ 'dict_dcca_3gpp/dict_dcca_3gpp.c', ++ 'dict_dcca_3gpp/add_avps.c')], ++ include_directories : freeDiameter_includes, ++ dependencies : libfdcore_dep, ++ name_prefix : '', ++ name_suffix : 'fdx', ++ install : true, ++ install_dir : freeDiameter_extensionsdir) +diff --git a/include/freeDiameter/libfdproto.h b/include/freeDiameter/libfdproto.h +index 66f4b3b..26f8617 100644 +--- a/include/freeDiameter/libfdproto.h ++++ b/include/freeDiameter/libfdproto.h +@@ -298,7 +298,7 @@ static char * file_bname_init(char * full) { file_bname = basename(full); return + + + /* In DEBUG mode, we add meta-information along each trace. This makes multi-threading problems easier to debug. */ +-#if (defined(DEBUG) && defined(DEBUG_WITH_META)) ++#if 1 /* Open5GS : enable log file and line number */ + # define STD_TRACE_FMT_STRING "pid:%s in %s@%s:%d: " + # define STD_TRACE_FMT_ARGS , ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed"), __PRETTY_FUNCTION__, __STRIPPED_FILE__, __LINE__ + #else /* DEBUG && DEBUG_WITH_META */ +diff --git a/include/freeDiameter/meson.build b/include/freeDiameter/meson.build +new file mode 100644 +index 0000000..5497d7d +--- /dev/null ++++ b/include/freeDiameter/meson.build +@@ -0,0 +1,185 @@ ++# 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/>. ++# ++ ++freeDiameter_host_conf = configuration_data() ++freeDiameter_version_conf = configuration_data() ++ ++freeDiameter_sysconfdir = join_paths(sysconfdir, 'freeDiameter') ++freeDiameter_extensionsdir = join_paths(libdir, 'freeDiameter') ++ ++# Informations to display in daemon's help ++freeDiameter_host_conf.set_quoted('FD_PROJECT_BINARY', meson.project_name() + 'd') ++freeDiameter_host_conf.set_quoted('FD_PROJECT_NAME', meson.project_name()) ++freeDiameter_host_conf.set_quoted('FD_PROJECT_VERSION', freeDiameter_version) ++freeDiameter_host_conf.set_quoted('FD_PROJECT_COPYRIGHT', 'Copyright (c) 2008-2015, WIDE Project (www.wide.ad.jp) and NICT (www.nict.go.jp)') ++ ++# Version of the source code ++version_arr = freeDiameter_version.split('.') ++freeDiameter_host_conf.set('FD_PROJECT_VERSION_MAJOR', version_arr[0].to_int()) ++freeDiameter_host_conf.set('FD_PROJECT_VERSION_MINOR', version_arr[1].to_int()) ++freeDiameter_host_conf.set('FD_PROJECT_VERSION_REV', version_arr[2].to_int()) ++ ++# Version of the API with the library ++freeDiameter_host_conf.set('FD_PROJECT_VERSION_API', 6) ++freeDiameter_host_conf.set_quoted('DEFAULT_CONF_PATH', ++ freeDiameter_sysconfdir) ++freeDiameter_host_conf.set_quoted('DEFAULT_EXTENSIONS_PATH', ++ freeDiameter_extensionsdir) ++freeDiameter_host_conf.set_quoted('FD_DEFAULT_CONF_FILENAME', ++ 'freeDiameter.conf') ++ ++if host_machine.endian() == 'big' ++ freeDiameter_host_conf.set('HOST_BIG_ENDIAN', 1) ++endif ++ ++freeDiameter_host_conf.set('FD_IS_CONFIG', true) ++freeDiameter_host_conf.set('_GNU_SOURCE', true) ++freeDiameter_host_conf.set('FD_HOOK_HANDLE_LIMIT', 5) ++ ++freeDiameter_headers = (''' ++ malloc.h ++ signalent.h ++'''.split()) ++ ++foreach h : freeDiameter_headers ++ if cc.has_header(h) ++ define = 'HAVE_' + h.underscorify().to_upper() ++ freeDiameter_host_conf.set(define, 1) ++ endif ++endforeach ++ ++freeDiameter_functions = (''' ++ strndup ++ getopt_long ++ getifaddrs ++'''.split()) ++ ++foreach f : freeDiameter_functions ++ if cc.has_function(f) ++ define = 'HAVE_' + f.underscorify().to_upper() ++ freeDiameter_host_conf.set(define, 1) ++ set_variable('have_func_' + f, true) ++ else ++ set_variable('have_func_' + f, false) ++ endif ++endforeach ++ ++# Check for ntohll ++if cc.has_header_symbol('netinet/in.h', 'ntohll') ++ freeDiameter_host_conf.set('HAVE_NTOHLL', 1) ++endif ++ ++# Check for AI_ADDRCONFIG ++if cc.has_header_symbol('netdb.h', 'AI_ADDRCONFIG') ++ freeDiameter_host_conf.set('HAVE_AI_ADDRCONFIG', 1) ++endif ++ ++# Determination of thread implementation ++threads = [] ++if host_system == 'windows' and not get_option('force_posix_threads') ++else ++ threads = dependency('threads') ++ if cc.has_header_symbol('pthread.h', 'pthread_barrier_wait') ++ freeDiameter_host_conf.set('HAVE_PTHREAD_BAR', 1) ++ endif ++endif ++ ++# Check for clock_gettime() ++clock_gettime_test_code = ''' ++ #include <time.h> ++ struct timespec t; ++ int main (int argc, char ** argv) { ++ return clock_gettime(CLOCK_REALTIME, &t); ++ }''' ++librt = [] ++if cc.links(clock_gettime_test_code, name : 'clock_gettime()') ++ freeDiameter_host_conf.set('HAVE_CLOCK_GETTIME', 1) ++elif cc.links(clock_gettime_test_code, args : '-lrt', name : 'clock_gettime() in librt') ++ freeDiameter_host_conf.set('HAVE_CLOCK_GETTIME', 1) ++ librt = cc.find_library('rt') ++elif cc.links(clock_gettime_test_code, args : '-lposix4', name : 'clock_gettime() in libposix4') ++ freeDiameter_host_conf.set('HAVE_CLOCK_GETTIME', 1) ++ librt = cc.find_library('posix4') ++else ++ error('Could not find clock_gettime()') ++endif ++ ++# Check for dlopen() ++dlopen_dlsym_test_code = ''' ++ #include <dlfcn.h> ++ int underscore_test (void) { return 42; } ++ int main (int argc, char ** argv) { ++ void *f1 = (void*)0, *f2 = (void*)0, *handle; ++ handle = dlopen ((void*)0, 0); ++ if (handle) { ++ f1 = dlsym (handle, "underscore_test"); ++ f2 = dlsym (handle, "_underscore_test"); ++ } ++ return (!f2 || f1); ++ }''' ++libdl = [] ++if cc.links(dlopen_dlsym_test_code, name : 'dlopen() and dlsym() in system libraries') ++ freeDiameter_host_conf.set('HAVE_DLOPEN', 1) ++elif cc.links(dlopen_dlsym_test_code, args : '-ldl', name : 'dlopen() and dlsym() in libdl') ++ freeDiameter_host_conf.set('HAVE_DLOPEN', 1) ++ libdl = cc.find_library('dl') ++else ++ error('Could not find dlopen()') ++endif ++ ++# Check for gcrypt/idn library ++libgcrypt = cc.find_library('gcrypt') ++libidn = cc.find_library('idn') ++ ++# Check for gnutls library ++libgnutls = cc.find_library('gnutls') ++if cc.has_function('gnutls_hash', args : '-lgnutls') ++ freeDiameter_host_conf.set('GNUTLS_VERSION_210', 1) ++endif ++if cc.has_function('gnutls_transport_set_vec_push_function', args : '-lgnutls') ++ freeDiameter_host_conf.set('GNUTLS_VERSION_212', 1) ++endif ++if cc.has_function('gnutls_x509_trust_list_verify_crt', args : '-lgnutls') ++ freeDiameter_host_conf.set('GNUTLS_VERSION_300', 1) ++endif ++if cc.has_function('gnutls_handshake_set_timeout', args : '-lgnutls') ++ freeDiameter_host_conf.set('GNUTLS_VERSION_310', 1) ++endif ++ ++# Check for SCTP ++libsctp = cc.find_library('sctp', required : false) ++if libsctp.found() ++ if cc.compiles('''#include <unistd.h> ++ #include <netinet/sctp.h> ++ int main (int argc, char ** argv) { ++ sctp_connectx(0, NULL, 0, NULL); ++ }''', name : 'sctp_connectx() accepts 4 arguments') ++ freeDiameter_host_conf.set('SCTP_CONNECTX_4_ARGS', 1) ++ endif ++ if host_system == 'freebsd' ++ freeDiameter_host_conf.set('SCTP_USE_MAPPED_ADDRESSES', 1) ++ endif ++else ++ freeDiameter_host_conf.set('DISABLE_SCTP', 1) ++endif ++ ++configure_file(output : 'freeDiameter-host.h', ++ configuration : freeDiameter_host_conf) ++ ++configure_file(output : 'version.h', ++ configuration : freeDiameter_version_conf) +diff --git a/libfdcore/endpoints.c b/libfdcore/endpoints.c +index e80c2a3..4c1f537 100644 +--- a/libfdcore/endpoints.c ++++ b/libfdcore/endpoints.c +@@ -64,7 +64,6 @@ int fd_ep_add_merge( struct fd_list * list, sSA * sa, socklen_t sl, uint32_t fla + case AF_INET: + if (! (flags & EP_ACCEPTALL)) { + if (IN_IS_ADDR_UNSPECIFIED(&ptr.sin->sin_addr) +- || IN_IS_ADDR_LOOPBACK(&ptr.sin->sin_addr) + /* the next one filters both EXPERIMENTAL, BADCLASS and MULTICAST. */ + || ((ntohl(ptr.sin->sin_addr.s_addr) & 0xe0000000) == 0xe0000000) + || (ptr.sin->sin_addr.s_addr == INADDR_BROADCAST)) { +@@ -78,10 +77,7 @@ int fd_ep_add_merge( struct fd_list * list, sSA * sa, socklen_t sl, uint32_t fla + case AF_INET6: + if (! (flags & EP_ACCEPTALL)) { + if (IN6_IS_ADDR_UNSPECIFIED(&ptr.sin6->sin6_addr) +- || IN6_IS_ADDR_LOOPBACK(&ptr.sin6->sin6_addr) +- || IN6_IS_ADDR_MULTICAST(&ptr.sin6->sin6_addr) +- || IN6_IS_ADDR_LINKLOCAL(&ptr.sin6->sin6_addr) +- || IN6_IS_ADDR_SITELOCAL(&ptr.sin6->sin6_addr)) { ++ || IN6_IS_ADDR_MULTICAST(&ptr.sin6->sin6_addr)) { + LOG_A(" DEBUG:fd_ep_add_merge Address was ignored, not added."); + return 0; + } +diff --git a/libfdcore/fdd.y b/libfdcore/fdd.y +index 9b36887..1a9729e 100644 +--- a/libfdcore/fdd.y ++++ b/libfdcore/fdd.y +@@ -43,13 +43,13 @@ + + /* For development only : */ + %debug +-%error-verbose ++%define parse.error verbose + + %parse-param {struct fd_config * conf} + + /* Keep track of location */ + %locations +-%pure-parser ++%define api.pure + + %{ + #include "fdcore-internal.h" +diff --git a/libfdcore/meson.build b/libfdcore/meson.build +new file mode 100644 +index 0000000..f3b7210 +--- /dev/null ++++ b/libfdcore/meson.build +@@ -0,0 +1,78 @@ ++# 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/>. ++ ++fdcore_sources = files(''' ++ fdcore-internal.h ++ apps.c ++ cnxctx.h ++ config.c ++ core.c ++ cnxctx.c ++ endpoints.c ++ events.c ++ extensions.c ++ fifo_stats.c ++ hooks.c ++ dict_base_proto.c ++ messages.c ++ queues.c ++ peers.c ++ p_ce.c ++ p_cnx.c ++ p_dw.c ++ p_dp.c ++ p_expiry.c ++ p_out.c ++ p_psm.c ++ p_sr.c ++ routing_dispatch.c ++ server.c ++ tcp.c ++ version.c ++'''.split()) ++ ++if libsctp.found() ++fdcore_sources += files('sctp.c', 'sctp3436.c', 'sctp_compat.c') ++endif ++ ++lgen = generator(flex, ++ output : '@PLAINNAME@.yy.c', ++ arguments : ['-p', '-Cem', '-Pfdd', '-o', '@OUTPUT@', '@INPUT@']) ++ ++lfiles = lgen.process('fdd.l') ++ ++pgen = generator(bison, ++ output : ['@BASENAME@.tab.c', '@BASENAME@.tab.h'], ++ arguments : ['-p', 'fdd', '-d', ++ '@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@']) ++ ++pfiles = pgen.process('fdd.y') ++ ++libfdcore = library('fdcore', ++ sources : [lfiles, pfiles, fdcore_sources], ++ version : freeDiameter_version, ++ soversion : freeDiameter_soversion, ++ include_directories : freeDiameter_includes, ++ dependencies : [libfdproto_dep, ++ libdl, libsctp, libgcrypt, libgnutls], ++ install : true) ++ ++libfdcore_dep = declare_dependency( ++ link_with : libfdcore, ++ include_directories : freeDiameter_includes, ++ dependencies : [libfdproto_dep, ++ libdl, libsctp, libgcrypt, libgnutls]) +diff --git a/libfdcore/p_psm.c b/libfdcore/p_psm.c +index 755e133..801d579 100644 +--- a/libfdcore/p_psm.c ++++ b/libfdcore/p_psm.c +@@ -891,7 +891,7 @@ psm_end: + if ((cur_state == STATE_CLOSING) || (cur_state == STATE_CLOSING_GRACE)) { + LOG_N("%s: Going to ZOMBIE state (no more activity) after normal shutdown", peer->p_hdr.info.pi_diamid); + } else { +- LOG_E("%s: Going to ZOMBIE state (no more activity) after abnormal shutdown", peer->p_hdr.info.pi_diamid); ++ LOG_N("%s: Going to ZOMBIE state (no more activity) after abnormal shutdown", peer->p_hdr.info.pi_diamid); + } + fd_psm_cleanup(peer, 1); + TRACE_DEBUG(INFO, "'%s'\t-> 'STATE_ZOMBIE' (terminated)\t'%s'", +@@ -950,8 +950,10 @@ void fd_psm_abord(struct fd_peer * peer ) + /* Cleanup the data */ + fd_psm_cleanup(peer, 1); + ++#if 0 /* Open5GS : not stable to finish freeDiameter */ + /* Destroy the event list */ + CHECK_FCT_DO( fd_fifo_del(&peer->p_events), /* continue */ ); ++#endif + + /* Remaining cleanups are performed in fd_peer_free */ + return; +diff --git a/libfdcore/peers.c b/libfdcore/peers.c +index 5ac9ccf..456638f 100644 +--- a/libfdcore/peers.c ++++ b/libfdcore/peers.c +@@ -397,7 +397,11 @@ int fd_peer_fini() + wait_until.tv_nsec = now.tv_nsec; + } + ++#if 0 /* Open5GS : not stable to finish freeDiameter */ + while ((!list_empty) && (TS_IS_INFERIOR(&now, &wait_until))) { ++#else ++ if (!list_empty) { ++#endif + + /* Allow the PSM(s) to execute */ + usleep(100000); +diff --git a/libfdcore/sctp-internal.h b/libfdcore/sctp-internal.h +new file mode 100644 +index 0000000..128d8df +--- /dev/null ++++ b/libfdcore/sctp-internal.h +@@ -0,0 +1,18 @@ ++#ifndef _SCTP_INTERNAL_H ++#define _SCTP_INTERNAL_H ++ ++extern int sctp_sockopt_event_subscribe_size; ++extern int sctp_sockopt_paddrparams_size; ++ ++struct sctp_event_subscribe; ++struct sctp_paddrparams; ++ ++int determine_sctp_sockopt_event_subscribe_size(void); ++int determine_sctp_sockopt_paddrparams_size(void); ++ ++int sctp_setsockopt_event_subscribe_workaround( ++ int fd, const struct sctp_event_subscribe *event_subscribe); ++int sctp_setsockopt_paddrparams_workaround( ++ int fd, const struct sctp_paddrparams *paddrparams); ++ ++#endif /* _SCTP_INTERNAL_H */ +diff --git a/libfdcore/sctp.c b/libfdcore/sctp.c +index 9305b31..4d376c9 100644 +--- a/libfdcore/sctp.c ++++ b/libfdcore/sctp.c +@@ -39,6 +39,10 @@ + #include <netinet/sctp.h> + #include <sys/uio.h> + ++#if 1 /* Open5GS : for SCTP patch */ ++#include "sctp-internal.h" ++#endif ++ + /* Size of buffer to receive ancilliary data. May need to be enlarged if more sockopt are set... */ + #ifndef CMSG_BUF_LEN + #define CMSG_BUF_LEN 1024 +@@ -48,7 +52,7 @@ + /* #define OLD_SCTP_SOCKET_API */ + + /* Automatically fallback to old API if some of the new symbols are not defined */ +-#if (!defined(SCTP_CONNECTX_4_ARGS) || (!defined(SCTP_RECVRCVINFO)) || (!defined(SCTP_SNDINFO)) || (!defined(SCTP_SEND_FAILED_EVENT))) ++#if (!defined(SCTP_CONNECTX_4_ARGS) || (!defined(SCTP_RECVRCVINFO)) || (!defined(SCTP_SNDINFO)) || (!defined(SCTP_SEND_FAILED_EVENT)) || (!defined(SCTP_NOTIFICATIONS_STOPPED_EVENT))) + # define OLD_SCTP_SOCKET_API + #endif + +@@ -341,13 +345,24 @@ static int fd_setsockopt_prebind(int sk) + + /* Some kernel versions need this to be set */ + parms.spp_address.ss_family = AF_INET; ++ ++#if 1 /* Open5GS : workaround for SCTP */ ++ if (determine_sctp_sockopt_paddrparams_size() < 0) { ++ LOG_E("Cannot determine SCTP_EVENTS socket option size"); ++ return -1; ++ } ++#endif + + if (TRACE_BOOL(ANNOYING)) { + sz = sizeof(parms); + + /* Read socket defaults */ + CHECK_SYS( sctp_opt_info(sk, 0, SCTP_PEER_ADDR_PARAMS, &parms, &sz) ); ++#if 0 /* Open5GS : workaround for SCTP */ + if (sz != sizeof(parms)) ++#else ++ if (sz != sizeof(parms) && sz != sctp_sockopt_paddrparams_size) ++#endif + { + TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(parms)); + return ENOTSUP; +@@ -371,7 +386,11 @@ static int fd_setsockopt_prebind(int sk) + #endif /* ADJUST_RTX_PARAMS */ + + /* Set the option to the socket */ ++#if 0 /* Open5GS : workaround for SCTP */ + CHECK_SYS( setsockopt(sk, IPPROTO_SCTP, SCTP_PEER_ADDR_PARAMS, &parms, sizeof(parms)) ); ++#else ++ CHECK_SYS( sctp_setsockopt_paddrparams_workaround(sk, &parms) ); ++#endif + + if (TRACE_BOOL(ANNOYING)) { + /* Check new values */ +@@ -410,12 +429,20 @@ static int fd_setsockopt_prebind(int sk) + // event.sctp_authentication_event = 0; /* when new key is made active */ + + /* Set the option to the socket */ ++#if 0 /* Open5GS : workaround for SCTP */ + CHECK_SYS( setsockopt(sk, IPPROTO_SCTP, SCTP_EVENTS, &event, sizeof(event)) ); ++#else ++ CHECK_SYS( sctp_setsockopt_event_subscribe_workaround(sk, &event) ); ++#endif + + if (TRACE_BOOL(ANNOYING)) { + sz = sizeof(event); + CHECK_SYS( getsockopt(sk, IPPROTO_SCTP, SCTP_EVENTS, &event, &sz) ); ++#if 0 /* Open5GS : workaround for SCTP */ + if (sz != sizeof(event)) ++#else ++ if (sz != sizeof(event) && sz != sctp_sockopt_event_subscribe_size) ++#endif + { + TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(event)); + return ENOTSUP; +@@ -1138,10 +1165,12 @@ ssize_t fd_sctp_sendstrv(struct cnxctx * conn, uint16_t strid, const struct iove + hdr->cmsg_type = SCTP_SNDRCV; + sndrcv = (struct sctp_sndrcvinfo *)CMSG_DATA(hdr); + sndrcv->sinfo_stream = strid; ++ sndrcv->sinfo_ppid = htonl(46); + #else /* OLD_SCTP_SOCKET_API */ + hdr->cmsg_type = SCTP_SNDINFO; + sndinf = (struct sctp_sndinfo *)CMSG_DATA(hdr); + sndinf->snd_sid = strid; ++ sndinf->snd_ppid = htonl(46); + #endif /* OLD_SCTP_SOCKET_API */ + /* note : we could store other data also, for example in .sinfo_ppid for remote peer or in .sinfo_context for errors. */ + +diff --git a/libfdcore/sctp_compat.c b/libfdcore/sctp_compat.c +new file mode 100644 +index 0000000..9c7c922 +--- /dev/null ++++ b/libfdcore/sctp_compat.c +@@ -0,0 +1,193 @@ ++#include "fdcore-internal.h" ++#include "sctp-internal.h" ++ ++#include <netinet/sctp.h> ++ ++int sctp_sockopt_event_subscribe_size = 0; ++int sctp_sockopt_paddrparams_size = 0; ++ ++/* is any of the bytes from offset .. u8_size in 'u8' non-zero? return offset ++ * or -1 if all zero */ ++static int byte_nonzero( ++ const uint8_t *u8, unsigned int offset, unsigned int u8_size) ++{ ++ int j; ++ ++ for (j = offset; j < u8_size; j++) { ++ if (u8[j] != 0) ++ return j; ++ } ++ ++ return -1; ++} ++ ++int determine_sctp_sockopt_event_subscribe_size(void) ++{ ++ uint8_t buf[256]; ++ socklen_t buf_len = sizeof(buf); ++ int sd, rc; ++ ++ /* only do this once */ ++ if (sctp_sockopt_event_subscribe_size != 0) ++ return 0; ++ ++ sd = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP); ++ if (sd < 0) ++ return sd; ++ ++ memset(buf, 0, sizeof(buf)); ++ rc = getsockopt(sd, IPPROTO_SCTP, SCTP_EVENTS, buf, &buf_len); ++ close(sd); ++ if (rc < 0) { ++ LOG_E("getsockopt(SCTP_PEER_ADDR_PARAMS) failed [%d:%s]", ++ rc, strerror(errno)); ++ return rc; ++ } ++ ++ sctp_sockopt_event_subscribe_size = buf_len; ++ ++ LOG_D("sizes of 'struct sctp_event_subscribe': " ++ "compile-time %zu, kernel: %u", ++ sizeof(struct sctp_event_subscribe), ++ sctp_sockopt_event_subscribe_size); ++ return 0; ++} ++ ++/* ++ * The workaround is stolen from libosmo-netif. ++ * - http://osmocom.org/projects/libosmo-netif/repository/revisions/master/entry/src/stream.c ++ * ++ * Attempt to work around Linux kernel ABI breakage ++ * ++ * The Linux kernel ABI for the SCTP_EVENTS socket option has been broken ++ * repeatedly. ++ * - until commit 35ea82d611da59f8bea44a37996b3b11bb1d3fd7 ( kernel < 4.11), ++ * the size is 10 bytes ++ * - in 4.11 it is 11 bytes ++ * - in 4.12 .. 5.4 it is 13 bytes ++ * - in kernels >= 5.5 it is 14 bytes ++ * ++ * This wouldn't be a problem if the kernel didn't have a "stupid" assumption ++ * that the structure size passed by userspace will match 1:1 the length ++ * of the structure at kernel compile time. In an ideal world, it would just ++ * use the known first bytes and assume the remainder is all zero. ++ * But as it doesn't do that, let's try to work around this */ ++int sctp_setsockopt_event_subscribe_workaround( ++ int fd, const struct sctp_event_subscribe *event_subscribe) ++{ ++ const unsigned int compiletime_size = sizeof(*event_subscribe); ++ int rc; ++ ++ if (determine_sctp_sockopt_event_subscribe_size() < 0) { ++ LOG_E("Cannot determine SCTP_EVENTS socket option size"); ++ return -1; ++ } ++ ++ if (compiletime_size == sctp_sockopt_event_subscribe_size) { ++ /* no kernel workaround needed */ ++ return setsockopt(fd, IPPROTO_SCTP, SCTP_EVENTS, ++ event_subscribe, compiletime_size); ++ } else if (compiletime_size < sctp_sockopt_event_subscribe_size) { ++ /* we are using an older userspace with a more modern kernel ++ * and hence need to pad the data */ ++ uint8_t buf[256]; ++ ASSERT(sctp_sockopt_event_subscribe_size <= sizeof(buf)); ++ ++ memcpy(buf, event_subscribe, compiletime_size); ++ memset(buf + sizeof(*event_subscribe), ++ 0, sctp_sockopt_event_subscribe_size - compiletime_size); ++ return setsockopt(fd, IPPROTO_SCTP, SCTP_EVENTS, ++ buf, sctp_sockopt_event_subscribe_size); ++ } else /* if (compiletime_size > sctp_sockopt_event_subscribe_size) */ { ++ /* we are using a newer userspace with an older kernel and hence ++ * need to truncate the data - but only if the caller didn't try ++ * to enable any of the events of the truncated portion */ ++ rc = byte_nonzero((const uint8_t *)event_subscribe, ++ sctp_sockopt_event_subscribe_size, compiletime_size); ++ if (rc >= 0) { ++ LOG_E("Kernel only supports sctp_event_subscribe of %u bytes, " ++ "but caller tried to enable more modern event at offset %u", ++ sctp_sockopt_event_subscribe_size, rc); ++ return -1; ++ } ++ ++ return setsockopt(fd, IPPROTO_SCTP, SCTP_EVENTS, event_subscribe, ++ sctp_sockopt_event_subscribe_size); ++ } ++} ++ ++int determine_sctp_sockopt_paddrparams_size(void) ++{ ++ uint8_t buf[256]; ++ socklen_t buf_len = sizeof(buf); ++ int sd, rc; ++ ++ /* only do this once */ ++ if (sctp_sockopt_paddrparams_size != 0) ++ return 0; ++ ++ sd = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP); ++ if (sd < 0) ++ return sd; ++ ++ memset(buf, 0, sizeof(buf)); ++ rc = getsockopt(sd, IPPROTO_SCTP, SCTP_PEER_ADDR_PARAMS, buf, &buf_len); ++ close(sd); ++ if (rc < 0) { ++ LOG_E("getsockopt(SCTP_PEER_ADDR_PARAMS) failed [%d:%s]", ++ rc, strerror(errno)); ++ return rc; ++ } ++ ++ sctp_sockopt_paddrparams_size = buf_len; ++ ++ LOG_D("sizes of 'struct sctp_event_subscribe': " ++ "compile-time %zu, kernel: %u", ++ sizeof(struct sctp_event_subscribe), ++ sctp_sockopt_event_subscribe_size); ++ return 0; ++} ++ ++int sctp_setsockopt_paddrparams_workaround( ++ int fd, const struct sctp_paddrparams *paddrparams) ++{ ++ const unsigned int compiletime_size = sizeof(*paddrparams); ++ int rc; ++ ++ if (determine_sctp_sockopt_paddrparams_size() < 0) { ++ LOG_E("Cannot determine SCTP_EVENTS socket option size"); ++ return -1; ++ } ++ ++ if (compiletime_size == sctp_sockopt_paddrparams_size) { ++ /* no kernel workaround needed */ ++ return setsockopt(fd, IPPROTO_SCTP, SCTP_PEER_ADDR_PARAMS, ++ paddrparams, compiletime_size); ++ } else if (compiletime_size < sctp_sockopt_paddrparams_size) { ++ /* we are using an older userspace with a more modern kernel ++ * and hence need to pad the data */ ++ uint8_t buf[256]; ++ ASSERT(sctp_sockopt_paddrparams_size <= sizeof(buf)); ++ ++ memcpy(buf, paddrparams, compiletime_size); ++ memset(buf + sizeof(*paddrparams), ++ 0, sctp_sockopt_paddrparams_size - compiletime_size); ++ return setsockopt(fd, IPPROTO_SCTP, SCTP_PEER_ADDR_PARAMS, ++ buf, sctp_sockopt_paddrparams_size); ++ } else /* if (compiletime_size > sctp_sockopt_paddrparams_size) */ { ++ /* we are using a newer userspace with an older kernel and hence ++ * need to truncate the data - but only if the caller didn't try ++ * to enable any of the events of the truncated portion */ ++ rc = byte_nonzero((const uint8_t *)paddrparams, ++ sctp_sockopt_paddrparams_size, compiletime_size); ++ if (rc >= 0) { ++ LOG_E("Kernel only supports sctp_event_subscribe of %u bytes, " ++ "but caller tried to enable more modern event at offset %u", ++ sctp_sockopt_paddrparams_size, rc); ++ return -1; ++ } ++ ++ return setsockopt(fd, IPPROTO_SCTP, SCTP_PEER_ADDR_PARAMS, paddrparams, ++ sctp_sockopt_paddrparams_size); ++ } ++} +diff --git a/libfdproto/meson.build b/libfdproto/meson.build +new file mode 100644 +index 0000000..1bf0963 +--- /dev/null ++++ b/libfdproto/meson.build +@@ -0,0 +1,48 @@ ++# 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/>. ++ ++fdproto_sources = files(''' ++ fdproto-internal.h ++ dictionary.c ++ dictionary_functions.c ++ dispatch.c ++ fifo.c ++ init.c ++ lists.c ++ log.c ++ messages.c ++ ostr.c ++ portability.c ++ rt_data.c ++ sessions.c ++ utils.c ++ version.c ++'''.split()) ++ ++libfdproto = library('fdproto', ++ sources : [fdproto_sources], ++ version : freeDiameter_version, ++ soversion : freeDiameter_soversion, ++ include_directories : freeDiameter_includes, ++ dependencies : [threads, librt, libidn ], ++ install : true) ++ ++libfdproto_dep = declare_dependency( ++ link_with : libfdproto, ++ include_directories : freeDiameter_includes, ++ dependencies : [threads, librt, libidn ], ++) +diff --git a/meson.build b/meson.build +new file mode 100644 +index 0000000..4b29e30 +--- /dev/null ++++ b/meson.build +@@ -0,0 +1,71 @@ ++# 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/>. ++ ++project('freediameter', 'c', ++ version : '1.3.2', ++ license : 'BSD-3-clause', ++ meson_version : '>= 0.43.0', ++ default_options : [ ++ 'warning_level=1', ++ 'c_std=gnu89', ++ 'prefix=/usr', ++ ], ++) ++ ++freeDiameter_version = meson.project_version() ++freeDiameter_soversion = '7' ++ ++prefix = get_option('prefix') ++bindir = join_paths(prefix, get_option('bindir')) ++libdir = join_paths(prefix, get_option('libdir')) ++sysconfdir = join_paths(prefix, get_option('sysconfdir')) ++localstatedir = join_paths(prefix, get_option('localstatedir')) ++ ++cc = meson.get_compiler('c') ++host_system = host_machine.system() ++ ++flex = find_program('flex') ++bison = find_program('bison') ++ ++# Compiler flags ++if cc.get_id() == 'gcc' or cc.get_id() == 'clang' ++ possible_cc_flags = [ ++ '-Werror', ++ ++ '-Wno-unused-variable', ++ '-Wno-unused-but-set-variable', ++ '-Wno-maybe-uninitialized', ++ '-Wno-format-truncation', ++ '-Wno-stringop-truncation', ++ ] ++else ++ possible_cc_flags = [] ++endif ++ ++add_project_arguments( ++ cc.get_supported_arguments(possible_cc_flags), ++ language : 'c') ++ ++freeDiameter_includes = include_directories(''' ++ include ++ . ++'''.split()) ++ ++subdir('include/freeDiameter') ++subdir('libfdproto') ++subdir('libfdcore') ++subdir('extensions') +-- +2.39.5 + diff --git a/debian/patches/0002-Redundant-So-I-removed-it.patch b/debian/patches/0002-Redundant-So-I-removed-it.patch new file mode 100644 index 0000000..2871585 --- /dev/null +++ b/debian/patches/0002-Redundant-So-I-removed-it.patch @@ -0,0 +1,27 @@ +From 13d7b451ffdf6f58afcd95e4f9814fc18f845293 Mon Sep 17 00:00:00 2001 +From: Sukchan Lee <acetcom@gmail.com> +Date: Mon, 29 Mar 2021 22:29:41 +0900 +Subject: [PATCH 02/16] Redundant! So, I removed it + +--- + libfdcore/p_psm.c | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/libfdcore/p_psm.c b/libfdcore/p_psm.c +index 801d579..6368bb0 100644 +--- a/libfdcore/p_psm.c ++++ b/libfdcore/p_psm.c +@@ -950,10 +950,8 @@ void fd_psm_abord(struct fd_peer * peer ) + /* Cleanup the data */ + fd_psm_cleanup(peer, 1); + +-#if 0 /* Open5GS : not stable to finish freeDiameter */ + /* Destroy the event list */ + CHECK_FCT_DO( fd_fifo_del(&peer->p_events), /* continue */ ); +-#endif + + /* Remaining cleanups are performed in fd_peer_free */ + return; +-- +2.39.5 + diff --git a/debian/patches/0003-Rollback-for-open5gs-from-v1.1.0-to-v1.2.4.patch b/debian/patches/0003-Rollback-for-open5gs-from-v1.1.0-to-v1.2.4.patch new file mode 100644 index 0000000..514f936 --- /dev/null +++ b/debian/patches/0003-Rollback-for-open5gs-from-v1.1.0-to-v1.2.4.patch @@ -0,0 +1,129 @@ +From 089e7cfa4c7947563ded23c2a6e6661aa5ac6fc7 Mon Sep 17 00:00:00 2001 +From: Sukchan Lee <acetcom@gmail.com> +Date: Thu, 1 Apr 2021 09:23:07 +0900 +Subject: [PATCH 03/16] Rollback for open5gs from v1.1.0 to v1.2.4 + +--- + extensions/dict_dcca_3gpp/add_avps.c | 8 ++++++++ + include/freeDiameter/libfdproto.h | 4 ++++ + libfdproto/log.c | 24 ++++++++++++++++++++++++ + 3 files changed, 36 insertions(+) + +diff --git a/extensions/dict_dcca_3gpp/add_avps.c b/extensions/dict_dcca_3gpp/add_avps.c +index 60d3c64..f8caeb6 100644 +--- a/extensions/dict_dcca_3gpp/add_avps.c ++++ b/extensions/dict_dcca_3gpp/add_avps.c +@@ -264,7 +264,11 @@ int add_avps() + struct dict_avp_data data = { + 15, /* Code */ + 10415, /* Vendor */ ++#if 0 /* For Open5GS from v1.1.0 to v2.2.2 */ + "3GPP-SGSN-Ipv6-Address", /* Name */ ++#else ++ "3GPP-SGSN-IPv6-Address", /* Name */ ++#endif + AVP_FLAG_VENDOR |AVP_FLAG_MANDATORY, /* Fixed flags */ + AVP_FLAG_VENDOR |AVP_FLAG_MANDATORY, /* Fixed flag values */ + AVP_TYPE_OCTETSTRING /* base type of data */ +@@ -9056,7 +9060,11 @@ int add_avps() + struct dict_avp_data data = { + 1488, /* Code */ + 10415, /* Vendor */ ++#if 0 /* For Open5GS from v1.1.0 to v2.2.2 */ + "Call-Barring-Info", /* Name */ ++#else ++ "Call-Barring-Infor-List", /* Name */ ++#endif + AVP_FLAG_VENDOR |AVP_FLAG_MANDATORY, /* Fixed flags */ + AVP_FLAG_VENDOR |AVP_FLAG_MANDATORY, /* Fixed flag values */ + AVP_TYPE_GROUPED /* base type of data */ +diff --git a/include/freeDiameter/libfdproto.h b/include/freeDiameter/libfdproto.h +index 26f8617..0118dc6 100644 +--- a/include/freeDiameter/libfdproto.h ++++ b/include/freeDiameter/libfdproto.h +@@ -208,7 +208,11 @@ char * fd_log_time ( struct timespec * ts, char * buf, size_t len, int incl_date + * RETURN VALUE: + * int : Success or failure + */ ++#if 0 /* For Open5GS from v1.1.0 to v2.2.2 */ + int fd_log_handler_register ( void (*logger)(int loglevel, const char * format, va_list args) ); ++#else ++int fd_log_handler_register ( void (*logger)(int loglevel, const char *fname, int line, const char * format, va_list args) ); ++#endif + + /* + * FUNCTION: fd_log_handler_unregister +diff --git a/libfdproto/log.c b/libfdproto/log.c +index c0b6ec5..5c81666 100644 +--- a/libfdproto/log.c ++++ b/libfdproto/log.c +@@ -41,7 +41,11 @@ pthread_mutex_t fd_log_lock = PTHREAD_MUTEX_INITIALIZER; + pthread_key_t fd_log_thname; + int fd_g_debug_lvl = FD_LOG_NOTICE; + ++#if 0 /* For Open5GS from v1.1.0 to v2.2.2 */ + static void fd_internal_logger( int, const char *, va_list ); ++#else ++static void fd_internal_logger( int, const char *, int, const char *, va_list ); ++#endif + static int use_colors = 0; /* 0: not init, 1: yes, 2: no */ + + /* These may be used to pass specific debug requests via the command-line parameters */ +@@ -53,10 +57,18 @@ int fd_breaks = 0; + int fd_breakhere(void) { return ++fd_breaks; } + + /* Allow passing of the log and debug information from base stack to extensions */ ++#if 0 /* For Open5GS from v1.1.0 to v2.2.2 */ + void (*fd_logger)( int loglevel, const char * format, va_list args ) = fd_internal_logger; ++#else ++void (*fd_logger)( int loglevel, const char *fname, int line, const char * format, va_list args ) = fd_internal_logger; ++#endif + + /* Register an external call back for tracing and debug */ ++#if 0 /* For Open5GS from v1.1.0 to v2.2.2 */ + int fd_log_handler_register( void (*logger)(int loglevel, const char * format, va_list args) ) ++#else ++int fd_log_handler_register ( void (*logger)(int loglevel, const char *fname, int line, const char * format, va_list args) ) ++#endif + { + CHECK_PARAMS( logger ); + +@@ -85,7 +97,11 @@ static void fd_cleanup_mutex_silent( void * mutex ) + } + + ++#if 0 /* For Open5GS from v1.1.0 to v2.2.2 */ + static void fd_internal_logger( int printlevel, const char *format, va_list ap ) ++#else ++static void fd_internal_logger( int printlevel, const char *fname, int line, const char *format, va_list ap ) ++#endif + { + char buf[25]; + +@@ -136,7 +152,11 @@ void fd_log ( int loglevel, const char * format, ... ) + pthread_cleanup_push(fd_cleanup_mutex_silent, &fd_log_lock); + + va_start(ap, format); ++#if 0 /* For Open5GS from v1.1.0 to v2.2.2 */ + fd_logger(loglevel, format, ap); ++#else ++ fd_logger(loglevel, NULL, 0, format, ap); ++#endif + va_end(ap); + + pthread_cleanup_pop(0); +@@ -150,7 +170,11 @@ void fd_log_va ( int loglevel, const char * format, va_list args ) + (void)pthread_mutex_lock(&fd_log_lock); + + pthread_cleanup_push(fd_cleanup_mutex_silent, &fd_log_lock); ++#if 0 /* For Open5GS from v1.1.0 to v2.2.2 */ + fd_logger(loglevel, format, args); ++#else ++ fd_logger(loglevel, NULL, 0, format, args); ++#endif + pthread_cleanup_pop(0); + + (void)pthread_mutex_unlock(&fd_log_lock); +-- +2.39.5 + diff --git a/debian/patches/0004-Use-freeDiameter-1.5.0-in-Open5GS-v2.2.3-or-higher.patch b/debian/patches/0004-Use-freeDiameter-1.5.0-in-Open5GS-v2.2.3-or-higher.patch new file mode 100644 index 0000000..bae16f6 --- /dev/null +++ b/debian/patches/0004-Use-freeDiameter-1.5.0-in-Open5GS-v2.2.3-or-higher.patch @@ -0,0 +1,129 @@ +From cbb9232111b8b1bb4997e0cbb083b727d0dc8a77 Mon Sep 17 00:00:00 2001 +From: Sukchan Lee <acetcom@gmail.com> +Date: Thu, 1 Apr 2021 09:26:44 +0900 +Subject: [PATCH 04/16] Use freeDiameter-1.5.0 in Open5GS v2.2.3 or higher + +--- + extensions/dict_dcca_3gpp/add_avps.c | 8 -------- + include/freeDiameter/libfdproto.h | 4 ---- + libfdproto/log.c | 24 ------------------------ + 3 files changed, 36 deletions(-) + +diff --git a/extensions/dict_dcca_3gpp/add_avps.c b/extensions/dict_dcca_3gpp/add_avps.c +index f8caeb6..60d3c64 100644 +--- a/extensions/dict_dcca_3gpp/add_avps.c ++++ b/extensions/dict_dcca_3gpp/add_avps.c +@@ -264,11 +264,7 @@ int add_avps() + struct dict_avp_data data = { + 15, /* Code */ + 10415, /* Vendor */ +-#if 0 /* For Open5GS from v1.1.0 to v2.2.2 */ + "3GPP-SGSN-Ipv6-Address", /* Name */ +-#else +- "3GPP-SGSN-IPv6-Address", /* Name */ +-#endif + AVP_FLAG_VENDOR |AVP_FLAG_MANDATORY, /* Fixed flags */ + AVP_FLAG_VENDOR |AVP_FLAG_MANDATORY, /* Fixed flag values */ + AVP_TYPE_OCTETSTRING /* base type of data */ +@@ -9060,11 +9056,7 @@ int add_avps() + struct dict_avp_data data = { + 1488, /* Code */ + 10415, /* Vendor */ +-#if 0 /* For Open5GS from v1.1.0 to v2.2.2 */ + "Call-Barring-Info", /* Name */ +-#else +- "Call-Barring-Infor-List", /* Name */ +-#endif + AVP_FLAG_VENDOR |AVP_FLAG_MANDATORY, /* Fixed flags */ + AVP_FLAG_VENDOR |AVP_FLAG_MANDATORY, /* Fixed flag values */ + AVP_TYPE_GROUPED /* base type of data */ +diff --git a/include/freeDiameter/libfdproto.h b/include/freeDiameter/libfdproto.h +index 0118dc6..26f8617 100644 +--- a/include/freeDiameter/libfdproto.h ++++ b/include/freeDiameter/libfdproto.h +@@ -208,11 +208,7 @@ char * fd_log_time ( struct timespec * ts, char * buf, size_t len, int incl_date + * RETURN VALUE: + * int : Success or failure + */ +-#if 0 /* For Open5GS from v1.1.0 to v2.2.2 */ + int fd_log_handler_register ( void (*logger)(int loglevel, const char * format, va_list args) ); +-#else +-int fd_log_handler_register ( void (*logger)(int loglevel, const char *fname, int line, const char * format, va_list args) ); +-#endif + + /* + * FUNCTION: fd_log_handler_unregister +diff --git a/libfdproto/log.c b/libfdproto/log.c +index 5c81666..c0b6ec5 100644 +--- a/libfdproto/log.c ++++ b/libfdproto/log.c +@@ -41,11 +41,7 @@ pthread_mutex_t fd_log_lock = PTHREAD_MUTEX_INITIALIZER; + pthread_key_t fd_log_thname; + int fd_g_debug_lvl = FD_LOG_NOTICE; + +-#if 0 /* For Open5GS from v1.1.0 to v2.2.2 */ + static void fd_internal_logger( int, const char *, va_list ); +-#else +-static void fd_internal_logger( int, const char *, int, const char *, va_list ); +-#endif + static int use_colors = 0; /* 0: not init, 1: yes, 2: no */ + + /* These may be used to pass specific debug requests via the command-line parameters */ +@@ -57,18 +53,10 @@ int fd_breaks = 0; + int fd_breakhere(void) { return ++fd_breaks; } + + /* Allow passing of the log and debug information from base stack to extensions */ +-#if 0 /* For Open5GS from v1.1.0 to v2.2.2 */ + void (*fd_logger)( int loglevel, const char * format, va_list args ) = fd_internal_logger; +-#else +-void (*fd_logger)( int loglevel, const char *fname, int line, const char * format, va_list args ) = fd_internal_logger; +-#endif + + /* Register an external call back for tracing and debug */ +-#if 0 /* For Open5GS from v1.1.0 to v2.2.2 */ + int fd_log_handler_register( void (*logger)(int loglevel, const char * format, va_list args) ) +-#else +-int fd_log_handler_register ( void (*logger)(int loglevel, const char *fname, int line, const char * format, va_list args) ) +-#endif + { + CHECK_PARAMS( logger ); + +@@ -97,11 +85,7 @@ static void fd_cleanup_mutex_silent( void * mutex ) + } + + +-#if 0 /* For Open5GS from v1.1.0 to v2.2.2 */ + static void fd_internal_logger( int printlevel, const char *format, va_list ap ) +-#else +-static void fd_internal_logger( int printlevel, const char *fname, int line, const char *format, va_list ap ) +-#endif + { + char buf[25]; + +@@ -152,11 +136,7 @@ void fd_log ( int loglevel, const char * format, ... ) + pthread_cleanup_push(fd_cleanup_mutex_silent, &fd_log_lock); + + va_start(ap, format); +-#if 0 /* For Open5GS from v1.1.0 to v2.2.2 */ + fd_logger(loglevel, format, ap); +-#else +- fd_logger(loglevel, NULL, 0, format, ap); +-#endif + va_end(ap); + + pthread_cleanup_pop(0); +@@ -170,11 +150,7 @@ void fd_log_va ( int loglevel, const char * format, va_list args ) + (void)pthread_mutex_lock(&fd_log_lock); + + pthread_cleanup_push(fd_cleanup_mutex_silent, &fd_log_lock); +-#if 0 /* For Open5GS from v1.1.0 to v2.2.2 */ + fd_logger(loglevel, format, args); +-#else +- fd_logger(loglevel, NULL, 0, format, args); +-#endif + pthread_cleanup_pop(0); + + (void)pthread_mutex_unlock(&fd_log_lock); +-- +2.39.5 + diff --git a/debian/patches/0005-Update-version-file-to-1.5.0-in-meson.build.patch b/debian/patches/0005-Update-version-file-to-1.5.0-in-meson.build.patch new file mode 100644 index 0000000..91d2336 --- /dev/null +++ b/debian/patches/0005-Update-version-file-to-1.5.0-in-meson.build.patch @@ -0,0 +1,25 @@ +From 0dec8211fe61fccf188a191041d5191b083eb490 Mon Sep 17 00:00:00 2001 +From: Sukchan Lee <acetcom@gmail.com> +Date: Wed, 16 Jun 2021 22:02:04 +0900 +Subject: [PATCH 05/16] Update version file to 1.5.0 in meson.build + +--- + meson.build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/meson.build b/meson.build +index 4b29e30..42a45b5 100644 +--- a/meson.build ++++ b/meson.build +@@ -16,7 +16,7 @@ + # along with this program. If not, see <https://www.gnu.org/licenses/>. + + project('freediameter', 'c', +- version : '1.3.2', ++ version : '1.5.0', + license : 'BSD-3-clause', + meson_version : '>= 0.43.0', + default_options : [ +-- +2.39.5 + diff --git a/debian/patches/0006-Result-Code-is-optional-in-Rx.patch b/debian/patches/0006-Result-Code-is-optional-in-Rx.patch new file mode 100644 index 0000000..a530dba --- /dev/null +++ b/debian/patches/0006-Result-Code-is-optional-in-Rx.patch @@ -0,0 +1,26 @@ +From 6ffb9fb9d18ee4160e5a4d45b7e0cbfbad4cb772 Mon Sep 17 00:00:00 2001 +From: Sukchan Lee <acetcom@gmail.com> +Date: Thu, 29 Jul 2021 17:28:47 +0900 +Subject: [PATCH 06/16] Result-Code is optional in Rx + +--- + extensions/dict_nasreq/dict_nasreq.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/extensions/dict_nasreq/dict_nasreq.c b/extensions/dict_nasreq/dict_nasreq.c +index 1d96f23..5bf13c5 100644 +--- a/extensions/dict_nasreq/dict_nasreq.c ++++ b/extensions/dict_nasreq/dict_nasreq.c +@@ -3169,7 +3169,9 @@ static int dnr_entry(char * conffile) + { { "Session-Id", RULE_FIXED_HEAD, -1, 1 } + ,{ "Auth-Application-Id", RULE_REQUIRED, -1, 1 } + ,{ "Auth-Request-Type", RULE_REQUIRED, -1, 1 } ++#if 0 /* modified by acetcom */ + ,{ "Result-Code", RULE_REQUIRED, -1, 1 } ++#endif + ,{ "Origin-Host", RULE_REQUIRED, -1, 1 } + ,{ "Origin-Realm", RULE_REQUIRED, -1, 1 } + ,{ "User-Name", RULE_OPTIONAL, -1, 1 } +-- +2.39.5 + diff --git a/debian/patches/0007-Result-Code-changes-to-Optional.patch b/debian/patches/0007-Result-Code-changes-to-Optional.patch new file mode 100644 index 0000000..97a3127 --- /dev/null +++ b/debian/patches/0007-Result-Code-changes-to-Optional.patch @@ -0,0 +1,46 @@ +From b80a8cf50ed1d1dc8263745a1a9f3186c4569488 Mon Sep 17 00:00:00 2001 +From: Sukchan Lee <acetcom@gmail.com> +Date: Thu, 29 Jul 2021 18:05:33 +0900 +Subject: [PATCH 07/16] Result-Code changes to Optional + +--- + libfdcore/dict_base_proto.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/libfdcore/dict_base_proto.c b/libfdcore/dict_base_proto.c +index 5eb7c58..a40c329 100644 +--- a/libfdcore/dict_base_proto.c ++++ b/libfdcore/dict_base_proto.c +@@ -2940,7 +2940,9 @@ int fd_dict_base_protocol(struct dictionary * dict) + }; + struct local_rules_definition rules[] = + { { "Session-Id", RULE_FIXED_HEAD, -1, 1 } ++#if 0 /* modified by acetcom */ + ,{ "Result-Code", RULE_REQUIRED, -1, 1 } ++#endif + ,{ "Origin-Host", RULE_REQUIRED, -1, 1 } + ,{ "Origin-Realm", RULE_REQUIRED, -1, 1 } + ,{ "User-Name", RULE_OPTIONAL, -1, 1 } +@@ -3058,7 +3060,9 @@ int fd_dict_base_protocol(struct dictionary * dict) + }; + struct local_rules_definition rules[] = + { { "Session-Id", RULE_FIXED_HEAD, -1, 1 } ++#if 0 /* modified by acetcom */ + ,{ "Result-Code", RULE_REQUIRED, -1, 1 } ++#endif + ,{ "Origin-Host", RULE_REQUIRED, -1, 1 } + ,{ "Origin-Realm", RULE_REQUIRED, -1, 1 } + ,{ "User-Name", RULE_OPTIONAL, -1, 1 } +@@ -3173,7 +3177,9 @@ int fd_dict_base_protocol(struct dictionary * dict) + }; + struct local_rules_definition rules[] = + { { "Session-Id", RULE_FIXED_HEAD, -1, 1 } ++#if 0 /* modified by acetcom */ + ,{ "Result-Code", RULE_REQUIRED, -1, 1 } ++#endif + ,{ "Origin-Host", RULE_REQUIRED, -1, 1 } + ,{ "Origin-Realm", RULE_REQUIRED, -1, 1 } + ,{ "User-Name", RULE_OPTIONAL, -1, 1 } +-- +2.39.5 + diff --git a/debian/patches/0008-adding-support-for-building-the-acl_wl-freeDiameter-.patch b/debian/patches/0008-adding-support-for-building-the-acl_wl-freeDiameter-.patch new file mode 100644 index 0000000..36ce4d3 --- /dev/null +++ b/debian/patches/0008-adding-support-for-building-the-acl_wl-freeDiameter-.patch @@ -0,0 +1,54 @@ +From 265bb92e93be81c77e30946e548cb7971121c340 Mon Sep 17 00:00:00 2001 +From: Spencer Sevilla <spencer.builds.networks@gmail.com> +Date: Tue, 7 Sep 2021 10:51:04 -0700 +Subject: [PATCH 08/16] adding support for building the acl_wl freeDiameter + extension. + +--- + extensions/acl_wl/meson.build | 21 +++++++++++++++++++++ + extensions/meson.build | 2 ++ + 2 files changed, 23 insertions(+) + create mode 100644 extensions/acl_wl/meson.build + +diff --git a/extensions/acl_wl/meson.build b/extensions/acl_wl/meson.build +new file mode 100644 +index 0000000..00c4249 +--- /dev/null ++++ b/extensions/acl_wl/meson.build +@@ -0,0 +1,21 @@ ++lgen = generator(flex, ++ output : 'lex.@BASENAME@.c', ++ arguments : ['-p', '-Cem', '-Paw_conf', '-o', '@OUTPUT@', '@INPUT@']) ++lfiles = lgen.process('aw_conf.l') ++ ++pgen = generator(bison, ++ output : ['@BASENAME@.tab.c', '@BASENAME@.tab.h'], ++ arguments : ['-p', 'aw_conf', '-d', ++ '@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@']) ++pfiles = pgen.process('aw_conf.y') ++ ++shared_module('acl_wl', ++ sources : [lfiles, pfiles, files( ++ 'acl_wl.c', ++ 'aw_tree.c')], ++ include_directories : freeDiameter_includes, ++ dependencies : libfdcore_dep, ++ name_prefix : '', ++ name_suffix : 'fdx', ++ install : true, ++ install_dir : freeDiameter_extensionsdir) +\ No newline at end of file +diff --git a/extensions/meson.build b/extensions/meson.build +index 9c00f6d..8a36773 100644 +--- a/extensions/meson.build ++++ b/extensions/meson.build +@@ -45,3 +45,5 @@ shared_module('dict_dcca_3gpp', + name_suffix : 'fdx', + install : true, + install_dir : freeDiameter_extensionsdir) ++ ++subdir('acl_wl') +\ No newline at end of file +-- +2.39.5 + diff --git a/debian/patches/0009-adding-DISABLE_PEER_EXPIRY-flag.patch b/debian/patches/0009-adding-DISABLE_PEER_EXPIRY-flag.patch new file mode 100644 index 0000000..a2fdce9 --- /dev/null +++ b/debian/patches/0009-adding-DISABLE_PEER_EXPIRY-flag.patch @@ -0,0 +1,24 @@ +From 369b884a07d1f7aed35049a7cf1e8abce8a5338a Mon Sep 17 00:00:00 2001 +From: Spencer Sevilla <spencer.builds.networks@gmail.com> +Date: Tue, 7 Sep 2021 10:59:06 -0700 +Subject: [PATCH 09/16] adding DISABLE_PEER_EXPIRY flag + +--- + meson.build | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/meson.build b/meson.build +index 42a45b5..0e49526 100644 +--- a/meson.build ++++ b/meson.build +@@ -51,6 +51,7 @@ if cc.get_id() == 'gcc' or cc.get_id() == 'clang' + '-Wno-maybe-uninitialized', + '-Wno-format-truncation', + '-Wno-stringop-truncation', ++ '-DDISABLE_PEER_EXPIRY', + ] + else + possible_cc_flags = [] +-- +2.39.5 + diff --git a/debian/patches/0010-move-DISABLE_PEER_EXPIRY-to-libfdcore-1.patch b/debian/patches/0010-move-DISABLE_PEER_EXPIRY-to-libfdcore-1.patch new file mode 100644 index 0000000..1cc90ad --- /dev/null +++ b/debian/patches/0010-move-DISABLE_PEER_EXPIRY-to-libfdcore-1.patch @@ -0,0 +1,37 @@ +From d77a2254f5185f1305ddceea2543004e100bcf3b Mon Sep 17 00:00:00 2001 +From: Sukchan Lee <acetcom@gmail.com> +Date: Sat, 11 Sep 2021 19:41:01 +0900 +Subject: [PATCH 10/16] move DISABLE_PEER_EXPIRY to libfdcore (#1) + +--- + libfdcore/meson.build | 1 + + meson.build | 1 - + 2 files changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libfdcore/meson.build b/libfdcore/meson.build +index f3b7210..5a26558 100644 +--- a/libfdcore/meson.build ++++ b/libfdcore/meson.build +@@ -66,6 +66,7 @@ libfdcore = library('fdcore', + sources : [lfiles, pfiles, fdcore_sources], + version : freeDiameter_version, + soversion : freeDiameter_soversion, ++ c_args : '-DDISABLE_PEER_EXPIRY', + include_directories : freeDiameter_includes, + dependencies : [libfdproto_dep, + libdl, libsctp, libgcrypt, libgnutls], +diff --git a/meson.build b/meson.build +index 0e49526..42a45b5 100644 +--- a/meson.build ++++ b/meson.build +@@ -51,7 +51,6 @@ if cc.get_id() == 'gcc' or cc.get_id() == 'clang' + '-Wno-maybe-uninitialized', + '-Wno-format-truncation', + '-Wno-stringop-truncation', +- '-DDISABLE_PEER_EXPIRY', + ] + else + possible_cc_flags = [] +-- +2.39.5 + diff --git a/debian/patches/0011-refine-meson-file-for-extensions-2.patch b/debian/patches/0011-refine-meson-file-for-extensions-2.patch new file mode 100644 index 0000000..c51025b --- /dev/null +++ b/debian/patches/0011-refine-meson-file-for-extensions-2.patch @@ -0,0 +1,118 @@ +From 814906ada09c6d2964592d696dab6226d11e8f06 Mon Sep 17 00:00:00 2001 +From: Sukchan Lee <acetcom@gmail.com> +Date: Sat, 11 Sep 2021 20:17:25 +0900 +Subject: [PATCH 11/16] refine meson file for extensions (#2) + +--- + extensions/acl_wl/aw_conf.y | 4 ++-- + extensions/acl_wl/meson.build | 30 +++++++++++++-------------- + extensions/dict_dcca_3gpp/meson.build | 10 +++++++++ + extensions/meson.build | 14 ++----------- + 4 files changed, 29 insertions(+), 29 deletions(-) + create mode 100644 extensions/dict_dcca_3gpp/meson.build + +diff --git a/extensions/acl_wl/aw_conf.y b/extensions/acl_wl/aw_conf.y +index 3825aa2..43255cb 100644 +--- a/extensions/acl_wl/aw_conf.y ++++ b/extensions/acl_wl/aw_conf.y +@@ -39,14 +39,14 @@ + + /* For development only : */ + %debug +-%error-verbose ++%define parse.error verbose + + /* The parser receives the configuration file filename as parameter */ + %parse-param {char * conffile} + + /* Keep track of location */ + %locations +-%pure-parser ++%define api.pure + + %{ + #include "acl_wl.h" +diff --git a/extensions/acl_wl/meson.build b/extensions/acl_wl/meson.build +index 00c4249..c0fcf1b 100644 +--- a/extensions/acl_wl/meson.build ++++ b/extensions/acl_wl/meson.build +@@ -1,21 +1,21 @@ + lgen = generator(flex, +- output : 'lex.@BASENAME@.c', +- arguments : ['-p', '-Cem', '-Paw_conf', '-o', '@OUTPUT@', '@INPUT@']) ++ output : 'lex.@BASENAME@.c', ++ arguments : ['-p', '-Cem', '-Paw_conf', '-o', '@OUTPUT@', '@INPUT@']) + lfiles = lgen.process('aw_conf.l') + + pgen = generator(bison, +- output : ['@BASENAME@.tab.c', '@BASENAME@.tab.h'], +- arguments : ['-p', 'aw_conf', '-d', +- '@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@']) ++ output : ['@BASENAME@.tab.c', '@BASENAME@.tab.h'], ++ arguments : ['-p', 'aw_conf', '-d', ++ '@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@']) + pfiles = pgen.process('aw_conf.y') + +-shared_module('acl_wl', +- sources : [lfiles, pfiles, files( +- 'acl_wl.c', +- 'aw_tree.c')], +- include_directories : freeDiameter_includes, +- dependencies : libfdcore_dep, +- name_prefix : '', +- name_suffix : 'fdx', +- install : true, +- install_dir : freeDiameter_extensionsdir) +\ No newline at end of file ++shared_module('../acl_wl', ++ sources : [lfiles, pfiles, files( ++ 'acl_wl.c', ++ 'aw_tree.c')], ++ include_directories : freeDiameter_includes, ++ dependencies : libfdcore_dep, ++ name_prefix : '', ++ name_suffix : 'fdx', ++ install : true, ++ install_dir : freeDiameter_extensionsdir) +diff --git a/extensions/dict_dcca_3gpp/meson.build b/extensions/dict_dcca_3gpp/meson.build +new file mode 100644 +index 0000000..061490a +--- /dev/null ++++ b/extensions/dict_dcca_3gpp/meson.build +@@ -0,0 +1,10 @@ ++shared_module('../dict_dcca_3gpp', ++ sources : [files( ++ 'dict_dcca_3gpp.c', ++ 'add_avps.c')], ++ include_directories : freeDiameter_includes, ++ dependencies : libfdcore_dep, ++ name_prefix : '', ++ name_suffix : 'fdx', ++ install : true, ++ install_dir : freeDiameter_extensionsdir) +diff --git a/extensions/meson.build b/extensions/meson.build +index 8a36773..ff833c1 100644 +--- a/extensions/meson.build ++++ b/extensions/meson.build +@@ -35,15 +35,5 @@ foreach s : fd_ext_sources + install_dir : freeDiameter_extensionsdir) + endforeach + +-shared_module('dict_dcca_3gpp', +- sources : [files( +- 'dict_dcca_3gpp/dict_dcca_3gpp.c', +- 'dict_dcca_3gpp/add_avps.c')], +- include_directories : freeDiameter_includes, +- dependencies : libfdcore_dep, +- name_prefix : '', +- name_suffix : 'fdx', +- install : true, +- install_dir : freeDiameter_extensionsdir) +- +-subdir('acl_wl') +\ No newline at end of file ++subdir('dict_dcca_3gpp') ++subdir('acl_wl') +-- +2.39.5 + diff --git a/debian/patches/0012-Remove-DISABLE_PEER_EXPIRY-1.patch b/debian/patches/0012-Remove-DISABLE_PEER_EXPIRY-1.patch new file mode 100644 index 0000000..ecfb0c3 --- /dev/null +++ b/debian/patches/0012-Remove-DISABLE_PEER_EXPIRY-1.patch @@ -0,0 +1,24 @@ +From b9a1bdd79c9dbba9d7e17dc83ba9b08cd018b231 Mon Sep 17 00:00:00 2001 +From: Sukchan Lee <acetcom@gmail.com> +Date: Sat, 11 Sep 2021 21:45:52 +0900 +Subject: [PATCH 12/16] Remove DISABLE_PEER_EXPIRY (#1) + +--- + libfdcore/meson.build | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/libfdcore/meson.build b/libfdcore/meson.build +index 5a26558..f3b7210 100644 +--- a/libfdcore/meson.build ++++ b/libfdcore/meson.build +@@ -66,7 +66,6 @@ libfdcore = library('fdcore', + sources : [lfiles, pfiles, fdcore_sources], + version : freeDiameter_version, + soversion : freeDiameter_soversion, +- c_args : '-DDISABLE_PEER_EXPIRY', + include_directories : freeDiameter_includes, + dependencies : [libfdproto_dep, + libdl, libsctp, libgcrypt, libgnutls], +-- +2.39.5 + diff --git a/debian/patches/0013-Add-DISABLE_PEER_EXPIRY-to-the-c_arg.patch b/debian/patches/0013-Add-DISABLE_PEER_EXPIRY-to-the-c_arg.patch new file mode 100644 index 0000000..2ebba54 --- /dev/null +++ b/debian/patches/0013-Add-DISABLE_PEER_EXPIRY-to-the-c_arg.patch @@ -0,0 +1,24 @@ +From b884d6e77cf22bc8bc713546f2592e9be95c1253 Mon Sep 17 00:00:00 2001 +From: Sukchan Lee <acetcom@gmail.com> +Date: Fri, 17 Sep 2021 17:20:21 +0900 +Subject: [PATCH 13/16] Add DISABLE_PEER_EXPIRY to the c_arg + +--- + libfdcore/meson.build | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/libfdcore/meson.build b/libfdcore/meson.build +index f3b7210..5a26558 100644 +--- a/libfdcore/meson.build ++++ b/libfdcore/meson.build +@@ -66,6 +66,7 @@ libfdcore = library('fdcore', + sources : [lfiles, pfiles, fdcore_sources], + version : freeDiameter_version, + soversion : freeDiameter_soversion, ++ c_args : '-DDISABLE_PEER_EXPIRY', + include_directories : freeDiameter_includes, + dependencies : [libfdproto_dep, + libdl, libsctp, libgcrypt, libgnutls], +-- +2.39.5 + diff --git a/debian/patches/0014-fix-the-build-error-in-meson-v0.6.0.patch b/debian/patches/0014-fix-the-build-error-in-meson-v0.6.0.patch new file mode 100644 index 0000000..1645cca --- /dev/null +++ b/debian/patches/0014-fix-the-build-error-in-meson-v0.6.0.patch @@ -0,0 +1,36 @@ +From 33dbbd20c9107a765dbafb9b1fef16f5f47c65cd Mon Sep 17 00:00:00 2001 +From: Sukchan Lee <acetcom@gmail.com> +Date: Wed, 27 Oct 2021 18:57:00 +0900 +Subject: [PATCH 14/16] fix the build error in meson v0.6.0 + +--- + extensions/acl_wl/meson.build | 2 +- + extensions/dict_dcca_3gpp/meson.build | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/extensions/acl_wl/meson.build b/extensions/acl_wl/meson.build +index c0fcf1b..6619ec6 100644 +--- a/extensions/acl_wl/meson.build ++++ b/extensions/acl_wl/meson.build +@@ -9,7 +9,7 @@ pgen = generator(bison, + '@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@']) + pfiles = pgen.process('aw_conf.y') + +-shared_module('../acl_wl', ++shared_module('acl_wl', + sources : [lfiles, pfiles, files( + 'acl_wl.c', + 'aw_tree.c')], +diff --git a/extensions/dict_dcca_3gpp/meson.build b/extensions/dict_dcca_3gpp/meson.build +index 061490a..95e3569 100644 +--- a/extensions/dict_dcca_3gpp/meson.build ++++ b/extensions/dict_dcca_3gpp/meson.build +@@ -1,4 +1,4 @@ +-shared_module('../dict_dcca_3gpp', ++shared_module('dict_dcca_3gpp', + sources : [files( + 'dict_dcca_3gpp.c', + 'add_avps.c')], +-- +2.39.5 + diff --git a/debian/patches/0015-compile-rt_default-rt_redirect-extension-3.patch b/debian/patches/0015-compile-rt_default-rt_redirect-extension-3.patch new file mode 100644 index 0000000..d832d42 --- /dev/null +++ b/debian/patches/0015-compile-rt_default-rt_redirect-extension-3.patch @@ -0,0 +1,115 @@ +From 738b648ea7c79d401fac2ba367e8727d7304348d Mon Sep 17 00:00:00 2001 +From: Rekord <1324596506@qq.com> +Date: Sun, 21 Jan 2024 14:24:27 +0800 +Subject: [PATCH 15/16] compile rt_default & rt_redirect extension (#3) + +* compile rt_default & rt_redirect extension + +* chore: update rtd_conf.y & restore rt_default-host.h.in +--- + extensions/meson.build | 2 ++ + extensions/rt_default/meson.build | 35 ++++++++++++++++++++++++++++++ + extensions/rt_default/rtd_conf.y | 4 ++-- + extensions/rt_redirect/meson.build | 16 ++++++++++++++ + 4 files changed, 55 insertions(+), 2 deletions(-) + create mode 100644 extensions/rt_default/meson.build + create mode 100644 extensions/rt_redirect/meson.build + +diff --git a/extensions/meson.build b/extensions/meson.build +index ff833c1..68ddb1c 100644 +--- a/extensions/meson.build ++++ b/extensions/meson.build +@@ -37,3 +37,5 @@ endforeach + + subdir('dict_dcca_3gpp') + subdir('acl_wl') ++subdir('rt_redirect') ++subdir('rt_default') +diff --git a/extensions/rt_default/meson.build b/extensions/rt_default/meson.build +new file mode 100644 +index 0000000..9d79aa4 +--- /dev/null ++++ b/extensions/rt_default/meson.build +@@ -0,0 +1,35 @@ ++if cc.has_function('regexec', prefix : '#include <regex.h>') ++ conf_data = configuration_data() ++ conf_data.set('HAVE_REG_STARTEND', 1) ++endif ++configure_file(output : 'rt_default-host.h', ++ configuration : conf_data) ++ ++ ++lgen = generator(flex, ++ output : 'lex.@BASENAME@.c', ++ arguments : ['-p', '-Cem', '-Prtd_conf', '-o', '@OUTPUT@', '@INPUT@'] ++ ) ++lfiles = lgen.process('rtd_conf.l') ++ ++pgen = generator(bison, ++ output : ['@BASENAME@.tab.c', '@BASENAME@.tab.h'], ++ arguments : ['-p', 'rtd_conf', '-d', ++ '@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@']) ++pfiles = pgen.process('rtd_conf.y') ++ ++# List of source files ++rt_default_src = files( ++ 'rt_default.c', ++ 'rt_default.h', ++ 'rtd_rules.c', ++) ++ ++shared_module('rt_default', ++ sources : [rt_default_src, lfiles, pfiles], ++ include_directories : freeDiameter_includes, ++ dependencies : libfdcore_dep, ++ name_prefix : '', ++ name_suffix : 'fdx', ++ install : true, ++ install_dir : freeDiameter_extensionsdir) +diff --git a/extensions/rt_default/rtd_conf.y b/extensions/rt_default/rtd_conf.y +index e02303c..1ef24ab 100644 +--- a/extensions/rt_default/rtd_conf.y ++++ b/extensions/rt_default/rtd_conf.y +@@ -39,14 +39,14 @@ + + /* For development only : */ + %debug +-%error-verbose ++%define parse.error verbose + + /* The parser receives the configuration file filename as parameter */ + %parse-param {char * conffile} + + /* Keep track of location */ + %locations +-%pure-parser ++%define api.pure + + %{ + #include "rt_default.h" +diff --git a/extensions/rt_redirect/meson.build b/extensions/rt_redirect/meson.build +new file mode 100644 +index 0000000..8a5bfe4 +--- /dev/null ++++ b/extensions/rt_redirect/meson.build +@@ -0,0 +1,16 @@ ++shared_module('rt_redirect', ++ sources : [files( ++ 'rt_redir.h', ++ 'rt_redir.c', ++ 'redir_entries.c', ++ 'redir_expiry.c', ++ 'redir_fwd.c', ++ 'redir_out.c', ++ 'uthash.h' ++ )], ++ include_directories : freeDiameter_includes, ++ dependencies : libfdcore_dep, ++ name_prefix : '', ++ name_suffix : 'fdx', ++ install : true, ++ install_dir : freeDiameter_extensionsdir) +\ No newline at end of file +-- +2.39.5 + diff --git a/debian/patches/0016-fix-extensions-rt_default-meson.build.patch b/debian/patches/0016-fix-extensions-rt_default-meson.build.patch new file mode 100644 index 0000000..591a697 --- /dev/null +++ b/debian/patches/0016-fix-extensions-rt_default-meson.build.patch @@ -0,0 +1,55 @@ +From 20196a265aecb7b1573ceb526bb619e092c1fd3f Mon Sep 17 00:00:00 2001 +From: Sukchan Lee <acetcom@gmail.com> +Date: Sun, 24 Mar 2024 18:33:19 +0900 +Subject: [PATCH 16/16] fix extensions/rt_default/meson.build + +from extensions/rt_default/meson.build, +HAVE_REG_STARTEND is defined according to this block: + +``` +if cc.has_function('regexec', prefix : '#include <regex.h>') + conf_data = configuration_data() + conf_data.set('HAVE_REG_STARTEND', 1) +endif +``` + +However, this block is insufficient to determine +whether REG_STARTEND is defined, as not all regex.h contain the macro. + +Something like the following in extensions/rt_ereg/CMakeLists.txt +should be used instead: + +``` +CHECK_C_SOURCE_COMPILES("${CHECK_REG_STARTEND_SOURCE_CODE}" HAVE_REG_STARTEND) +IF (HAVE_REG_STARTEND) + ADD_DEFINITIONS(-DHAVE_REG_STARTEND) +ENDIF (HAVE_REG_STARTEND) +``` + +So, I've fixed it as below. + +``` +conf_data = configuration_data() +if cc.has_header_symbol('regex.h', 'REG_STARTEND') + conf_data.set('HAVE_REG_STARTEND', 1) +endif +``` +--- + extensions/rt_default/meson.build | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/extensions/rt_default/meson.build b/extensions/rt_default/meson.build +index 9d79aa4..0d75877 100644 +--- a/extensions/rt_default/meson.build ++++ b/extensions/rt_default/meson.build +@@ -1,5 +1,5 @@ +-if cc.has_function('regexec', prefix : '#include <regex.h>') +- conf_data = configuration_data() ++conf_data = configuration_data() ++if cc.has_header_symbol('regex.h', 'REG_STARTEND') + conf_data.set('HAVE_REG_STARTEND', 1) + endif + configure_file(output : 'rt_default-host.h', +-- +2.39.5 + diff --git a/debian/patches/series b/debian/patches/series index ce4dbf6..6024aac 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,7 +1,20 @@ +#0002-install-extensions-in-usr-lib-freeDiameter.-Do-not-i.patch +#0003-Set-default-debian-location-for-freeDiameter-configu.patch +#0004-Disable-running-tests-that-require-the-kernel-module.patch +#0005-Build-using-old-API-since-the-new-FTBFS-on-sid.patc 0001-Fix-some-spelling-errors.patch 0002-install-extensions-in-usr-lib-freeDiameter.-Do-not-i.patch 0003-Set-default-debian-location-for-freeDiameter-configu.patch 0004-Disable-running-tests-that-require-the-kernel-module.patch -#0005-Build-using-old-API-since-the-new-FTBFS-on-sid.patc - +#0005-Build-using-old-API-since-the-new-FTBFS-on-sid.patch #CVE-2020-6098.patch +0007-Result-Code-changes-to-Optional.patch +#0008-adding-support-for-building-the-acl_wl-freeDiameter-.patch +#0009-adding-DISABLE_PEER_EXPIRY-flag.patch +#0010-move-DISABLE_PEER_EXPIRY-to-libfdcore-1.patch +#0011-refine-meson-file-for-extensions-2.patch +#0012-Remove-DISABLE_PEER_EXPIRY-1.patch +#0013-Add-DISABLE_PEER_EXPIRY-to-the-c_arg.patch +#0014-fix-the-build-error-in-meson-v0.6.0.patch +0015-compile-rt_default-rt_redirect-extension-3.patch +0016-fix-extensions-rt_default-meson.build.patch |
