2020-05-18 21:00:37 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
|
|
|
*
|
|
|
|
* This file is part of Open5GS.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if !defined(OGS_SBI_INSIDE) && !defined(OGS_SBI_COMPILATION)
|
|
|
|
#error "This header cannot be included directly."
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef OGS_SBI_CLIENT_H
|
|
|
|
#define OGS_SBI_CLIENT_H
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define OGS_SETUP_SBI_CLIENT(__cTX, __pCLIENT) \
|
|
|
|
do { \
|
|
|
|
ogs_assert((__cTX)); \
|
|
|
|
ogs_assert((__pCLIENT)); \
|
2020-06-04 18:12:05 +00:00
|
|
|
if ((__cTX)->client != __pCLIENT) \
|
|
|
|
__pCLIENT->reference_count++; \
|
2020-05-18 21:00:37 +00:00
|
|
|
(__cTX)->client = __pCLIENT; \
|
2020-07-29 02:35:43 +00:00
|
|
|
ogs_trace("client->reference_count = %d", __pCLIENT->reference_count); \
|
2020-05-18 21:00:37 +00:00
|
|
|
} while(0)
|
2020-07-09 05:38:09 +00:00
|
|
|
|
|
|
|
typedef int (*ogs_sbi_client_cb_f)(ogs_sbi_response_t *response, void *data);
|
|
|
|
|
2020-05-18 21:00:37 +00:00
|
|
|
typedef struct ogs_sbi_client_s {
|
2020-11-27 02:44:37 +00:00
|
|
|
ogs_socknode_t node;
|
2020-05-18 21:00:37 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
const char *key;
|
|
|
|
const char *pem;
|
|
|
|
} tls;
|
|
|
|
|
2020-07-09 05:38:09 +00:00
|
|
|
ogs_sbi_client_cb_f cb; /* Only used when NF send to NRF */
|
2020-05-18 21:00:37 +00:00
|
|
|
|
2020-06-04 18:12:05 +00:00
|
|
|
ogs_timer_t *t_curl; /* timer for CURL */
|
|
|
|
ogs_list_t connection_list; /* CURL connection list */
|
2020-05-18 21:00:37 +00:00
|
|
|
|
2020-06-04 18:12:05 +00:00
|
|
|
void *multi; /* CURL multi handle */
|
|
|
|
int still_running; /* number of running CURL handle */
|
|
|
|
|
|
|
|
unsigned int reference_count; /* reference count for memory free */
|
2020-05-18 21:00:37 +00:00
|
|
|
} ogs_sbi_client_t;
|
|
|
|
|
2020-06-17 05:22:28 +00:00
|
|
|
typedef struct ogs_sbi_nf_instance_s ogs_sbi_nf_instance_t;
|
|
|
|
|
2020-05-18 21:00:37 +00:00
|
|
|
void ogs_sbi_client_init(int num_of_sockinfo_pool, int num_of_connection_pool);
|
|
|
|
void ogs_sbi_client_final(void);
|
|
|
|
|
|
|
|
ogs_sbi_client_t *ogs_sbi_client_add(ogs_sockaddr_t *addr);
|
|
|
|
void ogs_sbi_client_remove(ogs_sbi_client_t *client);
|
|
|
|
ogs_sbi_client_t *ogs_sbi_client_find(ogs_sockaddr_t *addr);
|
|
|
|
|
2021-06-06 13:35:46 +00:00
|
|
|
bool ogs_sbi_client_send_request(
|
2020-07-09 05:38:09 +00:00
|
|
|
ogs_sbi_client_t *client, ogs_sbi_client_cb_f client_cb,
|
2020-06-17 05:22:28 +00:00
|
|
|
ogs_sbi_request_t *request, void *data);
|
2020-05-18 21:00:37 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* OGS_SBI_CLIENT_H */
|