Commit 2c5aefe9 authored by yangjian's avatar yangjian

BUG: sync failure

parent abe5b331
......@@ -1126,10 +1126,10 @@ void amf_n1::run_registration_procedure(std::shared_ptr<nas_context>& nc) {
// TODO: should be done in UDM/AUSF
bool amf_n1::auth_vectors_generator(std::shared_ptr<nas_context>& nc) {
Logger::amf_n1().debug("Start to generate authentication vectors");
authentication_vectors_generator_in_udm(nc);
if (amf_cfg.is_Nausf) {
if (!authentication_vectors_from_ausf(nc)) return false;
} else {
authentication_vectors_generator_in_udm(nc);
authentication_vectors_generator_in_ausf(nc);
Logger::amf_n1().debug("Deriving kamf");
for (int i = 0; i < MAX_5GS_AUTH_VECTORS; i++) {
......@@ -1281,6 +1281,51 @@ bool amf_n1::authentication_vectors_from_ausf(
AuthenticationInfo authenticationinfo;
authenticationinfo.setSupiOrSuci(nc.get()->imsi);
authenticationinfo.setServingNetworkName(nc.get()->serving_network);
ResynchronizationInfo resynchronizationInfo;
uint8_t auts_len = blength(nc.get()->auts);
uint8_t* auts_value = (uint8_t *)bdata(nc.get()->auts);
std::string authenticationinfo_auts;
std::string authenticationinfo_rand;
if(auts_value)
{
Logger::amf_n1().debug("********* has auts *********");
char* auts_s = (char*)malloc(auts_len*2+1);
char* rand_s = (char*)malloc(RAND_LENGTH*2+1);
memset(auts_s,0,sizeof(auts_s));
memset(rand_s,0,sizeof(rand_s));
uint8_t rand_value[RAND_LENGTH];
Logger::amf_n1().debug("********* auts_len (%d) *********",auts_len);
for(int i=0;i<auts_len;i++)
{
sprintf(&auts_s[i*2],"%02X",auts_value[i]);
}
authenticationinfo_auts = auts_s;
print_buffer("amf_n1", "********** ausf ***********", auts_value, auts_len);
Logger::amf_n1().info("********** ausf_s (%s) ***********",auts_s);
generate_random(rand_value, RAND_LENGTH);
for(int i=0;i<RAND_LENGTH;i++)
{
sprintf(&rand_s[i*2],"%02X",rand_value[i]);
}
authenticationinfo_rand = rand_s;
print_buffer("amf_n1", "********** rand ***********", rand_value, RAND_LENGTH);
Logger::amf_n1().info("********** rand_s (%s) ***********",rand_s);
resynchronizationInfo.setAuts(authenticationinfo_auts);
resynchronizationInfo.setRand(authenticationinfo_rand);
authenticationinfo.setResynchronizationInfo(resynchronizationInfo);
free(auts_s);
free(rand_s);
}
to_json(authenticationinfo_j, authenticationinfo);
msgBody = authenticationinfo_j.dump();
curl_http_client(remoteUri, "POST", msgBody, Response);
......
......@@ -20,7 +20,7 @@ namespace model {
AuthenticationInfo::AuthenticationInfo() {
m_SupiOrSuci = "";
m_ServingNetworkName = "";
// m_ResynchronizationInfoIsSet = false;
m_ResynchronizationInfoIsSet = false;
// m_Pei = "";
// m_PeiIsSet = false;
// m_TraceDataIsSet = false;
......@@ -43,8 +43,8 @@ void to_json(nlohmann::json& j, const AuthenticationInfo& o) {
j = nlohmann::json();
j["supiOrSuci"] = o.m_SupiOrSuci;
j["servingNetworkName"] = o.m_ServingNetworkName;
// if(o.resynchronizationInfoIsSet())
// j["resynchronizationInfo"] = o.m_ResynchronizationInfo;
if(o.resynchronizationInfoIsSet())
j["resynchronizationInfo"] = o.m_ResynchronizationInfo;
// if(o.peiIsSet())
// j["pei"] = o.m_Pei;
// if(o.traceDataIsSet())
......@@ -62,11 +62,11 @@ void to_json(nlohmann::json& j, const AuthenticationInfo& o) {
void from_json(const nlohmann::json& j, AuthenticationInfo& o) {
j.at("supiOrSuci").get_to(o.m_SupiOrSuci);
j.at("servingNetworkName").get_to(o.m_ServingNetworkName);
// if(j.find("resynchronizationInfo") != j.end())
// {
// j.at("resynchronizationInfo").get_to(o.m_ResynchronizationInfo);
// o.m_ResynchronizationInfoIsSet = true;
// }
if(j.find("resynchronizationInfo") != j.end())
{
j.at("resynchronizationInfo").get_to(o.m_ResynchronizationInfo);
o.m_ResynchronizationInfoIsSet = true;
}
// if(j.find("pei") != j.end())
// {
// j.at("pei").get_to(o.m_Pei);
......@@ -111,24 +111,24 @@ std::string AuthenticationInfo::getServingNetworkName() const {
void AuthenticationInfo::setServingNetworkName(std::string const& value) {
m_ServingNetworkName = value;
}
// ResynchronizationInfo AuthenticationInfo::getResynchronizationInfo() const
//{
// return m_ResynchronizationInfo;
//}
// void AuthenticationInfo::setResynchronizationInfo(ResynchronizationInfo
// const& value)
//{
// m_ResynchronizationInfo = value;
// m_ResynchronizationInfoIsSet = true;
//}
// bool AuthenticationInfo::resynchronizationInfoIsSet() const
//{
// return m_ResynchronizationInfoIsSet;
//}
// void AuthenticationInfo::unsetResynchronizationInfo()
//{
// m_ResynchronizationInfoIsSet = false;
//}
ResynchronizationInfo AuthenticationInfo::getResynchronizationInfo() const
{
return m_ResynchronizationInfo;
}
void AuthenticationInfo::setResynchronizationInfo(ResynchronizationInfo
const& value)
{
m_ResynchronizationInfo = value;
m_ResynchronizationInfoIsSet = true;
}
bool AuthenticationInfo::resynchronizationInfoIsSet() const
{
return m_ResynchronizationInfoIsSet;
}
void AuthenticationInfo::unsetResynchronizationInfo()
{
m_ResynchronizationInfoIsSet = false;
}
// std::string AuthenticationInfo::getPei() const
//{
// return m_Pei;
......
......@@ -19,7 +19,7 @@
#ifndef AuthenticationInfo_H_
#define AuthenticationInfo_H_
//#include "ResynchronizationInfo.h"
#include "ResynchronizationInfo.h"
//#include "TraceData.h"
#include <nlohmann/json.hpp>
#include <string>
......@@ -55,10 +55,10 @@ public:
/// <summary>
///
/// </summary>
// ResynchronizationInfo getResynchronizationInfo() const;
// void setResynchronizationInfo(ResynchronizationInfo const &value);
// bool resynchronizationInfoIsSet() const;
// void unsetResynchronizationInfo();
ResynchronizationInfo getResynchronizationInfo() const;
void setResynchronizationInfo(ResynchronizationInfo const &value);
bool resynchronizationInfoIsSet() const;
void unsetResynchronizationInfo();
// /// <summary>
// ///
// /// </summary>
......@@ -110,8 +110,8 @@ protected:
std::string m_ServingNetworkName;
// ResynchronizationInfo m_ResynchronizationInfo;
// bool m_ResynchronizationInfoIsSet;
ResynchronizationInfo m_ResynchronizationInfo;
bool m_ResynchronizationInfoIsSet;
// std::string m_Pei;
// bool m_PeiIsSet;
// TraceData m_TraceData;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment