Commit d8cba37f authored by liuyu's avatar liuyu

add udp server, add udp send

parent 72e5a714
......@@ -5,3 +5,4 @@ archives/
*.html
*.swp
.vscode
build
\ No newline at end of file
......@@ -400,7 +400,7 @@ void amf_n2::handle_itti_message(
bstring b = blk2bstr(buffer, encoded);
sctp_s_38412.sctp_send_msg(itti_msg->assoc_id, itti_msg->stream, &b);
sctp_s_38412.curl_http_client_Plugin(itti_msg->assoc_id, itti_msg->stream, b);
// sctp_s_38412.curl_http_client_Plugin(itti_msg->assoc_id, itti_msg->stream, b);
Logger::amf_n2().error(
"[gNB ID %d] No common PLMN between gNB and AMF, encoding "
"NG_SETUP_FAILURE with cause (Unknown PLMN)",
......@@ -453,8 +453,8 @@ void amf_n2::handle_itti_message(
}
bstring b = blk2bstr(buffer, encoded);
// sctp_s_38412.sctp_send_msg(itti_msg->assoc_id, itti_msg->stream, &b);
sctp_s_38412.curl_http_client_Plugin(itti_msg->assoc_id, itti_msg->stream, b);
sctp_s_38412.sctp_send_msg(itti_msg->assoc_id, itti_msg->stream, &b);
// sctp_s_38412.curl_http_client_Plugin(itti_msg->assoc_id, itti_msg->stream, b);
Logger::amf_n2().debug("Sending NG_SETUP_RESPONSE Ok");
gc->ng_state = NGAP_READY;
Logger::amf_n2().debug(
......@@ -533,8 +533,8 @@ void amf_n2::handle_itti_message(itti_ng_reset& itti_msg) {
int encoded_size = ng_reset_ack->Encode(buffer, BUFFER_SIZE_512);
bstring b = blk2bstr(buffer, encoded_size);
// sctp_s_38412.sctp_send_msg(gc->sctp_assoc_id, itti_msg.stream, &b);
sctp_s_38412.curl_http_client_Plugin(gc->sctp_assoc_id, itti_msg.stream, b);
sctp_s_38412.sctp_send_msg(gc->sctp_assoc_id, itti_msg.stream, &b);
// sctp_s_38412.curl_http_client_Plugin(gc->sctp_assoc_id, itti_msg.stream, b);
bdestroy_wrapper(&b);
return;
}
......@@ -811,8 +811,8 @@ void amf_n2::handle_itti_message(itti_dl_nas_transport& dl_nas_transport) {
uint8_t buffer[BUFFER_SIZE_1024];
int encoded_size = ngap_msg->Encode(buffer, BUFFER_SIZE_1024);
bstring b = blk2bstr(buffer, encoded_size);
// sctp_s_38412.sctp_send_msg(gc->sctp_assoc_id, unc->sctp_stream_send, &b);
sctp_s_38412.curl_http_client_Plugin(gc->sctp_assoc_id, unc->sctp_stream_send, b);
sctp_s_38412.sctp_send_msg(gc->sctp_assoc_id, unc->sctp_stream_send, &b);
// sctp_s_38412.curl_http_client_Plugin(gc->sctp_assoc_id, unc->sctp_stream_send, b);
bdestroy_wrapper(&b);
}
......@@ -977,8 +977,8 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) {
uint8_t buffer[BUFFER_SIZE_2048];
int encoded_size = msg->Encode(buffer, BUFFER_SIZE_2048);
bstring b = blk2bstr(buffer, encoded_size);
// sctp_s_38412.sctp_send_msg(gc->sctp_assoc_id, unc->sctp_stream_send, &b);
sctp_s_38412.curl_http_client_Plugin(gc->sctp_assoc_id, unc->sctp_stream_send, b);
sctp_s_38412.sctp_send_msg(gc->sctp_assoc_id, unc->sctp_stream_send, &b);
// sctp_s_38412.curl_http_client_Plugin(gc->sctp_assoc_id, unc->sctp_stream_send, b);
bdestroy_wrapper(&b);
}
......@@ -1062,8 +1062,8 @@ void amf_n2::handle_itti_message(
Logger::amf_n2().debug(" (%d bytes) \n", encoded_size);
bstring b = blk2bstr(buffer, encoded_size);
// sctp_s_38412.sctp_send_msg(gc->sctp_assoc_id, unc->sctp_stream_send, &b);
sctp_s_38412.curl_http_client_Plugin(gc->sctp_assoc_id, unc->sctp_stream_send, b);
sctp_s_38412.sctp_send_msg(gc->sctp_assoc_id, unc->sctp_stream_send, &b);
// sctp_s_38412.curl_http_client_Plugin(gc->sctp_assoc_id, unc->sctp_stream_send, b);
bdestroy_wrapper(&b);
}
......@@ -1122,8 +1122,8 @@ void amf_n2::handle_itti_message(
Logger::amf_n2().debug(" (%d bytes) \n", encoded_size);
bstring b = blk2bstr(buffer, encoded_size);
// sctp_s_38412.sctp_send_msg(gc->sctp_assoc_id, unc->sctp_stream_send, &b);
sctp_s_38412.curl_http_client_Plugin(gc->sctp_assoc_id, unc->sctp_stream_send, b);
sctp_s_38412.sctp_send_msg(gc->sctp_assoc_id, unc->sctp_stream_send, &b);
// sctp_s_38412.curl_http_client_Plugin(gc->sctp_assoc_id, unc->sctp_stream_send, b);
// free memory
bdestroy_wrapper(&b);
}
......@@ -1177,8 +1177,8 @@ void amf_n2::handle_itti_message(
Logger::amf_n2().debug(" (%d bytes) \n", encoded_size);
bstring b = blk2bstr(buffer, encoded_size);
// sctp_s_38412.sctp_send_msg(gc->sctp_assoc_id, unc->sctp_stream_send, &b);
sctp_s_38412.curl_http_client_Plugin(gc->sctp_assoc_id, unc->sctp_stream_send, b);
sctp_s_38412.sctp_send_msg(gc->sctp_assoc_id, unc->sctp_stream_send, &b);
// sctp_s_38412.curl_http_client_Plugin(gc->sctp_assoc_id, unc->sctp_stream_send, b);
// free memory
bdestroy_wrapper(&b);
}
......@@ -1201,8 +1201,8 @@ void amf_n2::handle_itti_message(itti_ue_context_release_request& itti_msg) {
int encoded_size = ueCtxRelCmd->Encode(buffer, BUFFER_SIZE_512);
bstring b = blk2bstr(buffer, encoded_size);
// sctp_s_38412.sctp_send_msg(itti_msg.assoc_id, itti_msg.stream, &b);
sctp_s_38412.curl_http_client_Plugin(itti_msg.assoc_id, itti_msg.stream, b);
sctp_s_38412.sctp_send_msg(itti_msg.assoc_id, itti_msg.stream, &b);
// sctp_s_38412.curl_http_client_Plugin(itti_msg.assoc_id, itti_msg.stream, b);
bdestroy_wrapper(&b);
}
......@@ -1248,8 +1248,8 @@ void amf_n2::handle_itti_message(itti_ue_context_release_command& itti_msg) {
int encoded_size = ueCtxRelCmd->Encode(buffer, BUFFER_SIZE_256);
bstring b = blk2bstr(buffer, encoded_size);
// sctp_s_38412.sctp_send_msg(gc->sctp_assoc_id, unc->sctp_stream_send, &b);
sctp_s_38412.curl_http_client_Plugin(gc->sctp_assoc_id, unc->sctp_stream_send, b);
sctp_s_38412.sctp_send_msg(gc->sctp_assoc_id, unc->sctp_stream_send, &b);
// sctp_s_38412.curl_http_client_Plugin(gc->sctp_assoc_id, unc->sctp_stream_send, b);
bdestroy_wrapper(&b);
// Send ITTI to N11 SBI, notify CommunicationFailure Report, RAN Cause
......@@ -1796,8 +1796,8 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
}
unc->target_gnb_assoc_id = gc_target->sctp_assoc_id;
// sctp_s_38412.sctp_send_msg(gc_target->sctp_assoc_id, 0, &b);
sctp_s_38412.curl_http_client_Plugin(gc_target->sctp_assoc_id, 0, b);
sctp_s_38412.sctp_send_msg(gc_target->sctp_assoc_id, 0, &b);
// sctp_s_38412.curl_http_client_Plugin(gc_target->sctp_assoc_id, 0, b);
bdestroy_wrapper(&b);
return true;
}
......@@ -1955,8 +1955,8 @@ void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) {
uint8_t buffer[BUFFER_SIZE_1024];
int encoded_size = handovercommand->Encode(buffer, BUFFER_SIZE_1024);
bstring b = blk2bstr(buffer, encoded_size);
// sctp_s_38412.sctp_send_msg(unc->gnb_assoc_id, 0, &b);
sctp_s_38412.curl_http_client_Plugin(unc->gnb_assoc_id, 0, b);
sctp_s_38412.sctp_send_msg(unc->gnb_assoc_id, 0, &b);
// sctp_s_38412.curl_http_client_Plugin(unc->gnb_assoc_id, 0, b);
bdestroy_wrapper(&b);
}
......@@ -2094,8 +2094,8 @@ void amf_n2::handle_itti_message(itti_handover_notify& itti_msg) {
int encoded_size = ueContextReleaseCommand->Encode(buffer, BUFFER_SIZE_1024);
bstring b = blk2bstr(buffer, encoded_size);
// sctp_s_38412.sctp_send_msg(unc->gnb_assoc_id, 0, &b);
sctp_s_38412.curl_http_client_Plugin(unc->gnb_assoc_id, 0, b);
sctp_s_38412.sctp_send_msg(unc->gnb_assoc_id, 0, &b);
// sctp_s_38412.curl_http_client_Plugin(unc->gnb_assoc_id, 0, b);
bdestroy_wrapper(&b);
string ue_context_key =
......@@ -2187,8 +2187,8 @@ void amf_n2::handle_itti_message(itti_uplink_ran_status_transfer& itti_msg) {
uint8_t buffer[BUFFER_SIZE_1024];
int encode_size = dl_ran_status_transfer->Encode(buffer, BUFFER_SIZE_1024);
bstring b = blk2bstr(buffer, encode_size);
// sctp_s_38412.sctp_send_msg(unc->target_gnb_assoc_id, 0, &b);
sctp_s_38412.curl_http_client_Plugin(unc->target_gnb_assoc_id, 0, b);
sctp_s_38412.sctp_send_msg(unc->target_gnb_assoc_id, 0, &b);
// sctp_s_38412.curl_http_client_Plugin(unc->target_gnb_assoc_id, 0, b);
bdestroy_wrapper(&b);
}
......@@ -2253,8 +2253,8 @@ void amf_n2::send_handover_preparation_failure(
ho_preparation_failure_msg->Encode(buffer, BUFFER_SIZE_1024);
bstring b = blk2bstr(buffer, encoded_size);
// sctp_s_38412.sctp_send_msg(gnb_assoc_id, 0, &b);
sctp_s_38412.curl_http_client_Plugin(gnb_assoc_id, 0, b);
sctp_s_38412.sctp_send_msg(gnb_assoc_id, 0, &b);
// sctp_s_38412.curl_http_client_Plugin(gnb_assoc_id, 0, b);
bdestroy_wrapper(&b);
}
......
......@@ -107,6 +107,16 @@ typedef struct Guami_s {
std::string AmfPointer;
} Guami_t;
typedef struct {
uint8_t pduSessionId;
OCTET_STRING_t pathSwitchRequestTransfer;
} PduSessionResourceToBeSwitchedDLItem_t;
typedef struct {
uint8_t pduSessionId;
OCTET_STRING_t pathSwitchRequestAcknowledgeTransfer;
} PduSessionResourceSwitchedItem_t;
typedef struct {
uint8_t pduSessionId;
bstring nas_pdu;
......
......@@ -109,7 +109,7 @@ void ngap_app::handle_receive(
"Handling SCTP payload from SCTP Server on assoc_id (%d), stream_id "
"(%d), instreams (%d), outstreams (%d)",
assoc_id, stream, instreams, outstreams);
bool priority = false;
bool priority = true;
Ngap_NGAP_PDU_t* ngap_msg_pdu =
(Ngap_NGAP_PDU_t*) calloc(1, sizeof(Ngap_NGAP_PDU_t));
asn_dec_rval_t rc = asn_decode(
......@@ -132,8 +132,7 @@ void ngap_app::handle_receive(
}
// Handle the message
if(ngap_msg_pdu->choice.initiatingMessage->procedureCode != 25 && priority == true
&& ngap_msg_pdu->choice.initiatingMessage->procedureCode != 21)
if(priority == true)
{
Logger::ngap().info("starting udp send");
Logger::ngap().debug("assoc_id = %d",assoc_id);
......@@ -160,7 +159,7 @@ void ngap_app::handle_receive(
// // octet_stream_2_hex_stream2((uint8_t*) bdata(payload), blength(payload), ngapmsg);
// //curl_http_another_amf(assoc_id,stream,ngapmsg);
// UdpSend(buffer,n+2,"10.103.238.72",9000);
UdpSend(buffer,n,"10.103.238.31",20001);
}
else{
//Handle the message
......
......@@ -117,7 +117,8 @@ int main(int argc, char** argv) {
Logger::amf_app().debug("Initiating AMF server endpoints");
// AMF HTTP1 server
udp_server udp_("10.103.239.31",9000);
udp_server udp_downlink_(inet_ntoa(amf_cfg.sbi.addr4),20002);
udp_server udp_uplink_(inet_ntoa(amf_cfg.sbi.addr4),20003);
Pistache::Address addr(
std::string(inet_ntoa(*((struct in_addr*) &amf_cfg.sbi.addr4))),
......
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