Commit 1f74fd47 authored by liuyu's avatar liuyu

add udp-> ngap handle

parent d8cba37f
...@@ -51,6 +51,7 @@ using namespace sctp; ...@@ -51,6 +51,7 @@ using namespace sctp;
using namespace config; using namespace config;
using namespace ngap; using namespace ngap;
extern bool priority;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
ngap_app::ngap_app(const std::string& address, const uint16_t port_num) ngap_app::ngap_app(const std::string& address, const uint16_t port_num)
: ppid_(60), sctp_s_38412(address.c_str(), port_num) { : ppid_(60), sctp_s_38412(address.c_str(), port_num) {
...@@ -109,7 +110,7 @@ void ngap_app::handle_receive( ...@@ -109,7 +110,7 @@ void ngap_app::handle_receive(
"Handling SCTP payload from SCTP Server on assoc_id (%d), stream_id " "Handling SCTP payload from SCTP Server on assoc_id (%d), stream_id "
"(%d), instreams (%d), outstreams (%d)", "(%d), instreams (%d), outstreams (%d)",
assoc_id, stream, instreams, outstreams); assoc_id, stream, instreams, outstreams);
bool priority = true;
Ngap_NGAP_PDU_t* ngap_msg_pdu = Ngap_NGAP_PDU_t* ngap_msg_pdu =
(Ngap_NGAP_PDU_t*) calloc(1, sizeof(Ngap_NGAP_PDU_t)); (Ngap_NGAP_PDU_t*) calloc(1, sizeof(Ngap_NGAP_PDU_t));
asn_dec_rval_t rc = asn_decode( asn_dec_rval_t rc = asn_decode(
...@@ -159,7 +160,7 @@ void ngap_app::handle_receive( ...@@ -159,7 +160,7 @@ void ngap_app::handle_receive(
// // octet_stream_2_hex_stream2((uint8_t*) bdata(payload), blength(payload), ngapmsg); // // octet_stream_2_hex_stream2((uint8_t*) bdata(payload), blength(payload), ngapmsg);
// //curl_http_another_amf(assoc_id,stream,ngapmsg); // //curl_http_another_amf(assoc_id,stream,ngapmsg);
UdpSend(buffer,n,"10.103.238.31",20001); UdpSend(buffer,n,"10.103.239.31",20001);
} }
else{ else{
//Handle the message //Handle the message
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <sys/time.h> #include <sys/time.h>
#include <unistd.h> #include <unistd.h>
// #include "amf_sbi.hpp" #include "amf_sbi.hpp"
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -22,13 +22,16 @@ ...@@ -22,13 +22,16 @@
#include <thread> #include <thread>
#include "bstrlib.h" #include "bstrlib.h"
#include "sstream" #include "sstream"
// #include "ngap_message_callback.hpp"
extern "C" { extern "C" {
#include "Ngap_InitiatingMessage.h" #include "Ngap_InitiatingMessage.h"
#include "Ngap_NGAP-PDU.h" #include "Ngap_NGAP-PDU.h"
} }
using namespace std; using namespace std;
bool priority = true;
udp_server::udp_server(const char* udp_address,uint16_t udp_port_num){ udp_server::udp_server(const char* udp_address,uint16_t udp_port_num){
cout<<"start create socket"<<endl; cout<<"start create socket"<<endl;
create_socket(udp_address,udp_port_num); create_socket(udp_address,udp_port_num);
...@@ -182,6 +185,11 @@ vector<string> SplitString(string s, string c){ ...@@ -182,6 +185,11 @@ vector<string> SplitString(string s, string c){
} }
void udp_server::handle_receive_udp(int r,uint8_t udp_recv[]){ void udp_server::handle_receive_udp(int r,uint8_t udp_recv[]){
if(priority==true)
{
Logger::ngap().info("synchronize context");
}
else{
stringstream ngap_msg_stream; stringstream ngap_msg_stream;
sctp_stream_id_t stream; sctp_stream_id_t stream;
...@@ -214,21 +222,21 @@ void udp_server::handle_receive_udp(int r,uint8_t udp_recv[]){ ...@@ -214,21 +222,21 @@ void udp_server::handle_receive_udp(int r,uint8_t udp_recv[]){
assoc_id = _assoc_id; assoc_id = _assoc_id;
bstring payload=blk2bstr(buffer,r-2); bstring payload=blk2bstr(buffer,r-2);
// //bstring udp_recv_bstr=bfromcstr(content.c_str()); // bstring udp_recv_bstr=bfromcstr(content.c_str());
// cout<<"data:"<<payload->data<<endl; // cout<<"data:"<<payload->data<<endl;
// cout<<"slen"<<payload->slen<<endl; // cout<<"slen"<<payload->slen<<endl;
// cout<<"mlen"<<payload->mlen<<endl; // cout<<"mlen"<<payload->mlen<<endl;
cout<<"start handle"<<endl; cout<<"start handle"<<endl;
// ngap_app("0",0).handle_receive(payload,assoc_id,stream,0,0); ngap_app("0",0).handle_receive(payload,assoc_id,stream,0,0,buffer,r-2);
// Ngap_NGAP_PDU_t* ngap_msg_pdu = // Ngap_NGAP_PDU_t* ngap_msg_pdu =
// (Ngap_NGAP_PDU_t*) calloc(1, sizeof(Ngap_NGAP_PDU_t)); // (Ngap_NGAP_PDU_t*) calloc(1, sizeof(Ngap_NGAP_PDU_t));
// Logger::udp().info("start decode"); // Logger::ngap().info("start decode");
// asn_dec_rval_t rc = asn_decode( // asn_dec_rval_t rc = asn_decode(
// NULL, ATS_ALIGNED_CANONICAL_PER, &asn_DEF_Ngap_NGAP_PDU, // NULL, ATS_ALIGNED_CANONICAL_PER, &asn_DEF_Ngap_NGAP_PDU,
// (void**) &ngap_msg_pdu, bdata(udp_recv_bstr), blength(udp_recv_bstr)); // (void**) &ngap_msg_pdu, bdata(payload), blength(payload));
// Logger::udp().debug( // Logger::ngap().debug(
// "Decoded UDP message, procedure code %d, present %d", // "Decoded UDP message, procedure code %d, present %d",
// ngap_msg_pdu->choice.initiatingMessage->procedureCode, // ngap_msg_pdu->choice.initiatingMessage->procedureCode,
// ngap_msg_pdu->present); // ngap_msg_pdu->present);
...@@ -237,6 +245,6 @@ void udp_server::handle_receive_udp(int r,uint8_t udp_recv[]){ ...@@ -237,6 +245,6 @@ void udp_server::handle_receive_udp(int r,uint8_t udp_recv[]){
// [ngap_msg_pdu->present - 1])( // [ngap_msg_pdu->present - 1])(
// assoc_id, stream, ngap_msg_pdu); // assoc_id, stream, ngap_msg_pdu);
}
} }
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