/**
* Nudsf_DataRepository
* Nudsf Data Repository Service. © 2021, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved. 
*
* The version of the OpenAPI document: 1.1.0-alpha.2
* 
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

#include "PluginApiImpl.hpp"
#include "logger.hpp"
#include <list>
#include "sctp_server.hpp"
extern std::string amf_ip;
extern unsigned int amf_port;
using namespace sctp;
extern sctp_server* sctp_s_38412;

extern unsigned char* format_string_as_hex(std::string str);
namespace org {
namespace openapitools {
namespace server {
namespace api {

//using namespace org::openapitools::server::model;

PluginApiImpl::PluginApiImpl(std::shared_ptr<Pistache::Rest::Router> rtr)
    : PluginApi(rtr)
    {  }
    
void PluginApiImpl::n2_trans_to_gnb(const std::uint32_t &assoc_id, const uint16_t &stream,TransData &transdata, Pistache::Http::ResponseWriter &response)
{
    

    std::string aaaa = transdata.get_amf_data();
    Logger::plugin_server().info("amf data = (%s-- %dbyte)",aaaa.c_str(),aaaa.length());


    uint8_t buffer[SCTP_RECV_BUFFER_SIZE];
    std::memcpy(buffer, format_string_as_hex(transdata.get_amf_data()),transdata.get_amf_data().length()/2+1);
    bstring b = blk2bstr(buffer, transdata.get_amf_data().length()/2+1);
    sctp_s_38412->sctp_send_msg(assoc_id, stream, &b);



    response.send(Pistache::Http::Code::Ok, "n2 receive \n");
}
void PluginApiImpl::modify_AmfIP(const std::string &amfip, const unsigned int &amfport, Pistache::Http::ResponseWriter &response)
{
    Logger::plugin_server().info("old  amf_ip = (%s), amf_port = (%d)",amf_ip.c_str(),amf_port);
    amf_ip = amfip;
    amf_port = amfport;
    Logger::plugin_server().info("new  amf_ip = (%s), amf_port = (%d)",amf_ip.c_str(),amf_port);
    response.send(Pistache::Http::Code::Ok);
}
}
}
}
}

