fix identation in HSS

This commit is contained in:
Sukchan Lee 2019-07-11 22:16:32 +09:00
parent 27d5208ea3
commit 97afc2db60
7 changed files with 265 additions and 255 deletions

View File

@ -1,3 +1,22 @@
/*
* 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-crypt.h"
#include "base/types.h"

View File

@ -1,11 +1,34 @@
#ifndef __HSS_KDF_H__
#define __HSS_KDF_H__
/*
* 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 HSS_KDF_H
#define HSS_KDF_H
#include "ogs-core.h"
#define HSS_SQN_LEN 6
#define HSS_AK_LEN 6
#ifdef __cplusplus
extern "C" {
#endif
void hss_auc_kasme(const uint8_t *ck, const uint8_t *ik,
const uint8_t plmn_id[3], const uint8_t *sqn, const uint8_t *ak,
uint8_t *kasme);
@ -14,4 +37,8 @@ void hss_auc_sqn(
const uint8_t *opc, const uint8_t *k, const uint8_t *auts,
uint8_t *sqn_ms, uint8_t *mac_s);
#endif /* __HSS_KDF_H__ */
#ifdef __cplusplus
}
#endif
#endif /* HSS_KDF_H */

View File

@ -1,3 +1,22 @@
/*
* 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 <mongoc.h>
#include <yaml.h>
@ -58,8 +77,7 @@ static int hss_context_validation()
if (self.fd_conf_path == NULL &&
(self.fd_config->cnf_diamid == NULL ||
self.fd_config->cnf_diamrlm == NULL ||
self.fd_config->cnf_addr == NULL))
{
self.fd_config->cnf_addr == NULL)) {
ogs_error("No hss.freeDiameter in '%s'", context_self()->config.path);
return OGS_ERROR;
}
@ -82,116 +100,85 @@ int hss_context_parse_config()
if (rv != OGS_OK) return rv;
ogs_yaml_iter_init(&root_iter, document);
while(ogs_yaml_iter_next(&root_iter))
{
while (ogs_yaml_iter_next(&root_iter)) {
const char *root_key = ogs_yaml_iter_key(&root_iter);
ogs_assert(root_key);
if (!strcmp(root_key, "hss"))
{
if (!strcmp(root_key, "hss")) {
ogs_yaml_iter_t hss_iter;
ogs_yaml_iter_recurse(&root_iter, &hss_iter);
while(ogs_yaml_iter_next(&hss_iter))
{
while (ogs_yaml_iter_next(&hss_iter)) {
const char *hss_key = ogs_yaml_iter_key(&hss_iter);
ogs_assert(hss_key);
if (!strcmp(hss_key, "freeDiameter"))
{
if (!strcmp(hss_key, "freeDiameter")) {
yaml_node_t *node =
yaml_document_get_node(document, hss_iter.pair->value);
ogs_assert(node);
if (node->type == YAML_SCALAR_NODE)
{
if (node->type == YAML_SCALAR_NODE) {
self.fd_conf_path = ogs_yaml_iter_value(&hss_iter);
}
else if (node->type == YAML_MAPPING_NODE)
{
} else if (node->type == YAML_MAPPING_NODE) {
ogs_yaml_iter_t fd_iter;
ogs_yaml_iter_recurse(&hss_iter, &fd_iter);
while(ogs_yaml_iter_next(&fd_iter))
{
while (ogs_yaml_iter_next(&fd_iter)) {
const char *fd_key = ogs_yaml_iter_key(&fd_iter);
ogs_assert(fd_key);
if (!strcmp(fd_key, "identity"))
{
if (!strcmp(fd_key, "identity")) {
self.fd_config->cnf_diamid =
ogs_yaml_iter_value(&fd_iter);
}
else if (!strcmp(fd_key, "realm"))
{
} else if (!strcmp(fd_key, "realm")) {
self.fd_config->cnf_diamrlm =
ogs_yaml_iter_value(&fd_iter);
}
else if (!strcmp(fd_key, "port"))
{
} else if (!strcmp(fd_key, "port")) {
const char *v = ogs_yaml_iter_value(&fd_iter);
if (v) self.fd_config->cnf_port = atoi(v);
}
else if (!strcmp(fd_key, "sec_port"))
{
} else if (!strcmp(fd_key, "sec_port")) {
const char *v = ogs_yaml_iter_value(&fd_iter);
if (v) self.fd_config->cnf_port_tls = atoi(v);
}
else if (!strcmp(fd_key, "no_sctp"))
{
} else if (!strcmp(fd_key, "no_sctp")) {
self.fd_config->cnf_flags.no_sctp =
ogs_yaml_iter_bool(&fd_iter);
}
else if (!strcmp(fd_key, "listen_on"))
{
} else if (!strcmp(fd_key, "listen_on")) {
self.fd_config->cnf_addr =
ogs_yaml_iter_value(&fd_iter);
}
else if (!strcmp(fd_key, "load_extension"))
{
} else if (!strcmp(fd_key, "load_extension")) {
ogs_yaml_iter_t ext_array, ext_iter;
ogs_yaml_iter_recurse(&fd_iter, &ext_array);
do
{
do {
const char *module = NULL;
const char *conf = NULL;
if (ogs_yaml_iter_type(&ext_array) ==
YAML_MAPPING_NODE)
{
YAML_MAPPING_NODE) {
memcpy(&ext_iter, &ext_array,
sizeof(ogs_yaml_iter_t));
}
else if (ogs_yaml_iter_type(&ext_array) ==
YAML_SEQUENCE_NODE)
{
} else if (ogs_yaml_iter_type(&ext_array) ==
YAML_SEQUENCE_NODE) {
if (!ogs_yaml_iter_next(&ext_array))
break;
ogs_yaml_iter_recurse(
&ext_array, &ext_iter);
}
else if (ogs_yaml_iter_type(&ext_array) ==
YAML_SCALAR_NODE)
{
} else if (ogs_yaml_iter_type(&ext_array) ==
YAML_SCALAR_NODE) {
break;
}
else
} else
ogs_assert_if_reached();
while(ogs_yaml_iter_next(&ext_iter))
{
while (ogs_yaml_iter_next(&ext_iter)) {
const char *ext_key =
ogs_yaml_iter_key(&ext_iter);
ogs_assert(ext_key);
if (!strcmp(ext_key, "module"))
{
module = ogs_yaml_iter_value(&ext_iter);
}
else if (!strcmp(ext_key, "conf"))
{
conf = ogs_yaml_iter_value(&ext_iter);
}
else
ogs_warn("unknown key `%s`", ext_key);
if (!strcmp(ext_key, "module")) {
module = ogs_yaml_iter_value(
&ext_iter);
} else if (!strcmp(ext_key, "conf")) {
conf = ogs_yaml_iter_value(
&ext_iter);
} else
ogs_warn("unknown key `%s`",
ext_key);
}
if (module)
{
if (module) {
self.fd_config->
ext[self.fd_config->num_of_ext].
module = module;
@ -200,65 +187,49 @@ int hss_context_parse_config()
conf = conf;
self.fd_config->num_of_ext++;
}
} while(ogs_yaml_iter_type(&ext_array) ==
} while (ogs_yaml_iter_type(&ext_array) ==
YAML_SEQUENCE_NODE);
}
else if (!strcmp(fd_key, "connect"))
{
} else if (!strcmp(fd_key, "connect")) {
ogs_yaml_iter_t conn_array, conn_iter;
ogs_yaml_iter_recurse(&fd_iter, &conn_array);
do
{
do {
const char *identity = NULL;
const char *addr = NULL;
uint16_t port = 0;
if (ogs_yaml_iter_type(&conn_array) ==
YAML_MAPPING_NODE)
{
YAML_MAPPING_NODE) {
memcpy(&conn_iter, &conn_array,
sizeof(ogs_yaml_iter_t));
}
else if (ogs_yaml_iter_type(&conn_array) ==
YAML_SEQUENCE_NODE)
{
} else if (ogs_yaml_iter_type(&conn_array) ==
YAML_SEQUENCE_NODE) {
if (!ogs_yaml_iter_next(&conn_array))
break;
ogs_yaml_iter_recurse(&conn_array, &conn_iter);
}
else if (ogs_yaml_iter_type(&conn_array) ==
YAML_SCALAR_NODE)
{
} else if (ogs_yaml_iter_type(&conn_array) ==
YAML_SCALAR_NODE) {
break;
}
else
} else
ogs_assert_if_reached();
while(ogs_yaml_iter_next(&conn_iter))
{
while (ogs_yaml_iter_next(&conn_iter)) {
const char *conn_key =
ogs_yaml_iter_key(&conn_iter);
ogs_assert(conn_key);
if (!strcmp(conn_key, "identity"))
{
identity = ogs_yaml_iter_value(&conn_iter);
}
else if (!strcmp(conn_key, "addr"))
{
if (!strcmp(conn_key, "identity")) {
identity = ogs_yaml_iter_value(
&conn_iter);
} else if (!strcmp(conn_key, "addr")) {
addr = ogs_yaml_iter_value(&conn_iter);
}
else if (!strcmp(conn_key, "port"))
{
} else if (!strcmp(conn_key, "port")) {
const char *v =
ogs_yaml_iter_value(&conn_iter);
if (v) port = atoi(v);
}
else
} else
ogs_warn("unknown key `%s`", conn_key);
}
if (identity && addr)
{
if (identity && addr) {
self.fd_config->
conn[self.fd_config->num_of_conn].
identity = identity;
@ -270,15 +241,13 @@ int hss_context_parse_config()
port = port;
self.fd_config->num_of_conn++;
}
} while(ogs_yaml_iter_type(&conn_array) ==
} while (ogs_yaml_iter_type(&conn_array) ==
YAML_SEQUENCE_NODE);
}
else
} else
ogs_warn("unknown key `%s`", fd_key);
}
}
}
else
} else
ogs_warn("unknown key `%s`", hss_key);
}
}
@ -292,8 +261,7 @@ int hss_context_parse_config()
int hss_db_init()
{
if (context_self()->db.client && context_self()->db.name)
{
if (context_self()->db.client && context_self()->db.name) {
self.subscriberCollection = mongoc_client_get_collection(
context_self()->db.client,
context_self()->db.name, "subscribers");
@ -305,8 +273,7 @@ int hss_db_init()
int hss_db_final()
{
if (self.subscriberCollection)
{
if (self.subscriberCollection) {
mongoc_collection_destroy(self.subscriberCollection);
}
@ -341,24 +308,21 @@ int hss_db_auth_info(
MONGOC_QUERY_NONE, 0, 0, 0, query, NULL, NULL);
#endif
if (!mongoc_cursor_next(cursor, &document))
{
if (!mongoc_cursor_next(cursor, &document)) {
ogs_warn("Cannot find IMSI in DB : %s", imsi_bcd);
rv = OGS_ERROR;
goto out;
}
if (mongoc_cursor_error(cursor, &error))
{
if (mongoc_cursor_error(cursor, &error)) {
ogs_error("Cursor Failure: %s", error.message);
rv = OGS_ERROR;
goto out;
}
if (!bson_iter_init_find(&iter, document, "security"))
{
if (!bson_iter_init_find(&iter, document, "security")) {
ogs_error("No 'security' field in this document");
rv = OGS_ERROR;
@ -367,38 +331,26 @@ int hss_db_auth_info(
memset(auth_info, 0, sizeof(hss_db_auth_info_t));
bson_iter_recurse(&iter, &inner_iter);
while(bson_iter_next(&inner_iter))
{
while (bson_iter_next(&inner_iter)) {
const char *key = bson_iter_key(&inner_iter);
if (!strcmp(key, "k") && BSON_ITER_HOLDS_UTF8(&inner_iter))
{
if (!strcmp(key, "k") && BSON_ITER_HOLDS_UTF8(&inner_iter)) {
utf8 = (char *)bson_iter_utf8(&inner_iter, &length);
memcpy(auth_info->k, OGS_HEX(utf8, length, buf), HSS_KEY_LEN);
}
else if (!strcmp(key, "opc") && BSON_ITER_HOLDS_UTF8(&inner_iter))
{
} else if (!strcmp(key, "opc") && BSON_ITER_HOLDS_UTF8(&inner_iter)) {
utf8 = (char *)bson_iter_utf8(&inner_iter, &length);
auth_info->use_opc = 1;
memcpy(auth_info->opc, OGS_HEX(utf8, length, buf), HSS_KEY_LEN);
}
else if (!strcmp(key, "op") && BSON_ITER_HOLDS_UTF8(&inner_iter))
{
} else if (!strcmp(key, "op") && BSON_ITER_HOLDS_UTF8(&inner_iter)) {
utf8 = (char *)bson_iter_utf8(&inner_iter, &length);
memcpy(auth_info->op, OGS_HEX(utf8, length, buf), HSS_KEY_LEN);
}
else if (!strcmp(key, "amf") && BSON_ITER_HOLDS_UTF8(&inner_iter))
{
} else if (!strcmp(key, "amf") && BSON_ITER_HOLDS_UTF8(&inner_iter)) {
utf8 = (char *)bson_iter_utf8(&inner_iter, &length);
memcpy(auth_info->amf, OGS_HEX(utf8, length, buf), HSS_AMF_LEN);
}
else if (!strcmp(key, "rand") && BSON_ITER_HOLDS_UTF8(&inner_iter))
{
} else if (!strcmp(key, "rand") && BSON_ITER_HOLDS_UTF8(&inner_iter)) {
utf8 = (char *)bson_iter_utf8(&inner_iter, &length);
memcpy(auth_info->rand, OGS_HEX(utf8, length, buf), RAND_LEN);
}
else if (!strcmp(key, "sqn") && BSON_ITER_HOLDS_INT64(&inner_iter))
{
} else if (!strcmp(key, "sqn") && BSON_ITER_HOLDS_INT64(&inner_iter)) {
auth_info->sqn = bson_iter_int64(&inner_iter);
}
}
@ -434,8 +386,7 @@ int hss_db_update_rand_and_sqn(
"}");
if (!mongoc_collection_update(self.subscriberCollection,
MONGOC_UPDATE_NONE, query, update, NULL, &error))
{
MONGOC_UPDATE_NONE, query, update, NULL, &error)) {
ogs_error("mongoc_collection_update() failure: %s", error.message);
rv = OGS_ERROR;
@ -465,8 +416,7 @@ int hss_db_increment_sqn(char *imsi_bcd)
"security.sqn", BCON_INT64(32),
"}");
if (!mongoc_collection_update(self.subscriberCollection,
MONGOC_UPDATE_NONE, query, update, NULL, &error))
{
MONGOC_UPDATE_NONE, query, update, NULL, &error)) {
ogs_error("mongoc_collection_update() failure: %s", error.message);
rv = OGS_ERROR;
@ -480,8 +430,7 @@ int hss_db_increment_sqn(char *imsi_bcd)
"{", "and", BCON_INT64(max_sqn), "}",
"}");
if (!mongoc_collection_update(self.subscriberCollection,
MONGOC_UPDATE_NONE, query, update, NULL, &error))
{
MONGOC_UPDATE_NONE, query, update, NULL, &error)) {
ogs_error("mongoc_collection_update() failure: %s", error.message);
rv = OGS_ERROR;
@ -523,24 +472,21 @@ int hss_db_subscription_data(
MONGOC_QUERY_NONE, 0, 0, 0, query, NULL, NULL);
#endif
if (!mongoc_cursor_next(cursor, &document))
{
if (!mongoc_cursor_next(cursor, &document)) {
ogs_error("Cannot find IMSI in DB : %s", imsi_bcd);
rv = OGS_ERROR;
goto out;
}
if (mongoc_cursor_error(cursor, &error))
{
if (mongoc_cursor_error(cursor, &error)) {
ogs_error("Cursor Failure: %s", error.message);
rv = OGS_ERROR;
goto out;
}
if (!bson_iter_init(&iter, document))
{
if (!bson_iter_init(&iter, document)) {
ogs_error("bson_iter_init failed in this document");
rv = OGS_ERROR;
@ -548,63 +494,46 @@ int hss_db_subscription_data(
}
memset(subscription_data, 0, sizeof(s6a_subscription_data_t));
while(bson_iter_next(&iter))
{
while (bson_iter_next(&iter)) {
const char *key = bson_iter_key(&iter);
if (!strcmp(key, "access_restriction_data") &&
BSON_ITER_HOLDS_INT32(&iter))
{
BSON_ITER_HOLDS_INT32(&iter)) {
subscription_data->access_restriction_data =
bson_iter_int32(&iter);
}
else if (!strcmp(key, "subscriber_status") &&
BSON_ITER_HOLDS_INT32(&iter))
{
} else if (!strcmp(key, "subscriber_status") &&
BSON_ITER_HOLDS_INT32(&iter)) {
subscription_data->subscriber_status =
bson_iter_int32(&iter);
}
else if (!strcmp(key, "network_access_mode") &&
BSON_ITER_HOLDS_INT32(&iter))
{
} else if (!strcmp(key, "network_access_mode") &&
BSON_ITER_HOLDS_INT32(&iter)) {
subscription_data->network_access_mode =
bson_iter_int32(&iter);
}
else if (!strcmp(key, "subscribed_rau_tau_timer") &&
BSON_ITER_HOLDS_INT32(&iter))
{
} else if (!strcmp(key, "subscribed_rau_tau_timer") &&
BSON_ITER_HOLDS_INT32(&iter)) {
subscription_data->subscribed_rau_tau_timer =
bson_iter_int32(&iter);
}
else if (!strcmp(key, "ambr") &&
BSON_ITER_HOLDS_DOCUMENT(&iter))
{
} else if (!strcmp(key, "ambr") &&
BSON_ITER_HOLDS_DOCUMENT(&iter)) {
bson_iter_recurse(&iter, &child1_iter);
while(bson_iter_next(&child1_iter))
{
while (bson_iter_next(&child1_iter)) {
const char *child1_key = bson_iter_key(&child1_iter);
if (!strcmp(child1_key, "uplink") &&
BSON_ITER_HOLDS_INT64(&child1_iter))
{
BSON_ITER_HOLDS_INT64(&child1_iter)) {
subscription_data->ambr.uplink =
bson_iter_int64(&child1_iter) * 1024;
}
else if (!strcmp(child1_key, "downlink") &&
BSON_ITER_HOLDS_INT64(&child1_iter))
{
} else if (!strcmp(child1_key, "downlink") &&
BSON_ITER_HOLDS_INT64(&child1_iter)) {
subscription_data->ambr.downlink =
bson_iter_int64(&child1_iter) * 1024;
}
}
}
else if (!strcmp(key, "pdn") &&
BSON_ITER_HOLDS_ARRAY(&iter))
{
} else if (!strcmp(key, "pdn") &&
BSON_ITER_HOLDS_ARRAY(&iter)) {
int pdn_index = 0;
bson_iter_recurse(&iter, &child1_iter);
while(bson_iter_next(&child1_iter))
{
while (bson_iter_next(&child1_iter)) {
const char *child1_key = bson_iter_key(&child1_iter);
pdn_t *pdn = NULL;
@ -615,118 +544,88 @@ int hss_db_subscription_data(
pdn = &subscription_data->pdn[pdn_index];
bson_iter_recurse(&child1_iter, &child2_iter);
while(bson_iter_next(&child2_iter))
{
while (bson_iter_next(&child2_iter)) {
const char *child2_key = bson_iter_key(&child2_iter);
if (!strcmp(child2_key, "apn") &&
BSON_ITER_HOLDS_UTF8(&child2_iter))
{
BSON_ITER_HOLDS_UTF8(&child2_iter)) {
utf8 = bson_iter_utf8(&child2_iter, &length);
ogs_cpystrn(pdn->apn, utf8,
ogs_min(length, MAX_APN_LEN)+1);
}
else if (!strcmp(child2_key, "type") &&
BSON_ITER_HOLDS_INT32(&child2_iter))
{
} else if (!strcmp(child2_key, "type") &&
BSON_ITER_HOLDS_INT32(&child2_iter)) {
pdn->pdn_type = bson_iter_int32(&child2_iter);
}
else if (!strcmp(child2_key, "qos") &&
BSON_ITER_HOLDS_DOCUMENT(&child2_iter))
{
} else if (!strcmp(child2_key, "qos") &&
BSON_ITER_HOLDS_DOCUMENT(&child2_iter)) {
bson_iter_recurse(&child2_iter, &child3_iter);
while(bson_iter_next(&child3_iter))
{
while (bson_iter_next(&child3_iter)) {
const char *child3_key =
bson_iter_key(&child3_iter);
if (!strcmp(child3_key, "qci") &&
BSON_ITER_HOLDS_INT32(&child3_iter))
{
BSON_ITER_HOLDS_INT32(&child3_iter)) {
pdn->qos.qci = bson_iter_int32(&child3_iter);
}
else if (!strcmp(child3_key, "arp") &&
BSON_ITER_HOLDS_DOCUMENT(&child3_iter))
{
} else if (!strcmp(child3_key, "arp") &&
BSON_ITER_HOLDS_DOCUMENT(&child3_iter)) {
bson_iter_recurse(&child3_iter, &child4_iter);
while(bson_iter_next(&child4_iter))
{
while (bson_iter_next(&child4_iter)) {
const char *child4_key =
bson_iter_key(&child4_iter);
if (!strcmp(child4_key, "priority_level") &&
BSON_ITER_HOLDS_INT32(&child4_iter))
{
BSON_ITER_HOLDS_INT32(&child4_iter)) {
pdn->qos.arp.priority_level =
bson_iter_int32(&child4_iter);
}
else if (!strcmp(child4_key,
} else if (!strcmp(child4_key,
"pre_emption_capability") &&
BSON_ITER_HOLDS_INT32(&child4_iter))
{
BSON_ITER_HOLDS_INT32(&child4_iter)) {
pdn->qos.arp.pre_emption_capability =
bson_iter_int32(&child4_iter);
}
else if (!strcmp(child4_key,
} else if (!strcmp(child4_key,
"pre_emption_vulnerability") &&
BSON_ITER_HOLDS_INT32(&child4_iter))
{
BSON_ITER_HOLDS_INT32(&child4_iter)) {
pdn->qos.arp.pre_emption_vulnerability =
bson_iter_int32(&child4_iter);
}
}
}
}
}
else if (!strcmp(child2_key, "ambr") &&
BSON_ITER_HOLDS_DOCUMENT(&child2_iter))
{
} else if (!strcmp(child2_key, "ambr") &&
BSON_ITER_HOLDS_DOCUMENT(&child2_iter)) {
bson_iter_recurse(&child2_iter, &child3_iter);
while(bson_iter_next(&child3_iter))
{
while (bson_iter_next(&child3_iter)) {
const char *child3_key =
bson_iter_key(&child3_iter);
if (!strcmp(child3_key, "uplink") &&
BSON_ITER_HOLDS_INT64(&child3_iter))
{
BSON_ITER_HOLDS_INT64(&child3_iter)) {
pdn->ambr.uplink =
bson_iter_int64(&child3_iter) * 1024;
}
else if (!strcmp(child3_key, "downlink") &&
BSON_ITER_HOLDS_INT64(&child3_iter))
{
} else if (!strcmp(child3_key, "downlink") &&
BSON_ITER_HOLDS_INT64(&child3_iter)) {
pdn->ambr.downlink =
bson_iter_int64(&child3_iter) * 1024;
}
}
}
else if (!strcmp(child2_key, "pgw") &&
BSON_ITER_HOLDS_DOCUMENT(&child2_iter))
{
} else if (!strcmp(child2_key, "pgw") &&
BSON_ITER_HOLDS_DOCUMENT(&child2_iter)) {
bson_iter_recurse(&child2_iter, &child3_iter);
while(bson_iter_next(&child3_iter))
{
while (bson_iter_next(&child3_iter)) {
const char *child3_key =
bson_iter_key(&child3_iter);
if (!strcmp(child3_key, "addr") &&
BSON_ITER_HOLDS_UTF8(&child3_iter))
{
BSON_ITER_HOLDS_UTF8(&child3_iter)) {
ogs_ipsubnet_t ipsub;
const char *v =
bson_iter_utf8(&child3_iter, &length);
rv = ogs_ipsubnet(&ipsub, v, NULL);
if (rv == OGS_OK)
{
if (rv == OGS_OK) {
pdn->pgw_ip.ipv4 = 1;
pdn->pgw_ip.both.addr = ipsub.sub[0];
}
}
else if (!strcmp(child3_key, "addr6") &&
BSON_ITER_HOLDS_UTF8(&child3_iter))
{
} else if (!strcmp(child3_key, "addr6") &&
BSON_ITER_HOLDS_UTF8(&child3_iter)) {
ogs_ipsubnet_t ipsub;
const char *v =
bson_iter_utf8(&child3_iter, &length);
rv = ogs_ipsubnet(&ipsub, v, NULL);
if (rv == OGS_OK)
{
if (rv == OGS_OK) {
pdn->pgw_ip.ipv6 = 1;
memcpy(pdn->pgw_ip.both.addr6,
ipsub.sub, sizeof(ipsub.sub));

View File

@ -1,11 +1,30 @@
#ifndef __HSS_CONTEXT_H__
#define __HSS_CONTEXT_H__
/*
* 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 HSS_CONTEXT_H
#define HSS_CONTEXT_H
#include "fd/s6a/s6a-message.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif
#define HSS_KEY_LEN 16
#define HSS_AMF_LEN 2
@ -38,7 +57,7 @@ typedef struct _hss_context_t {
void hss_context_init(void);
void hss_context_final(void);
hss_context_t* hss_self(void);
hss_context_t *hss_self(void);
int hss_context_parse_config(void);
@ -54,6 +73,6 @@ int hss_db_subscription_data(
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
#endif /* __HSS_CONTEXT_H__ */
#endif /* HSS_CONTEXT_H */

View File

@ -1,16 +1,35 @@
#ifndef __HSS_FD_PATH_H__
#define __HSS_FD_PATH_H__
/*
* 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 HSS_FD_PATH_H
#define HSS_FD_PATH_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif
int hss_fd_init(void);
void hss_fd_final(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
#endif /* __HSS_FD_PATH_H__ */
#endif /* HSS_FD_PATH_H */

View File

@ -1,3 +1,22 @@
/*
* 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 "app/context.h"
#include "hss-context.h"

View File

@ -6,8 +6,12 @@
* See README for more details.
*/
#ifndef __MILENAGE_H__
#define __MILENAGE_H__
#ifndef MILENAGE_H
#define MILENAGE_H
#ifdef __cplusplus
extern "C" {
#endif
void milenage_generate(const uint8_t *opc, const uint8_t *amf,
const uint8_t *k, const uint8_t *sqn, const uint8_t *_rand,
@ -30,4 +34,8 @@ int milenage_f2345(const uint8_t *opc, const uint8_t *k,
void milenage_opc(const uint8_t *k, const uint8_t *op, uint8_t *opc);
#endif /* __MILENAGE_H__ */
#ifdef __cplusplus
}
#endif
#endif /* MILENAGE_H */