mirror of https://github.com/PentHertz/srsLTE.git
ttcn3_dut: add basic DRB handler skeleton
the handler is currently just listening on the designated port and prints the received JSON string
This commit is contained in:
parent
925225dbeb
commit
54a99d3f66
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* Copyright 2013-2020 Software Radio Systems Limited
|
||||
*
|
||||
* This file is part of srsLTE.
|
||||
*
|
||||
* srsLTE 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.
|
||||
*
|
||||
* srsLTE 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 Affero General Public License for more details.
|
||||
*
|
||||
* A copy of the GNU Affero General Public License can be found in
|
||||
* the LICENSE file in the top-level directory of this distribution
|
||||
* and at http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SRSUE_TTCN3_DRB_INTERFACE_H
|
||||
#define SRSUE_TTCN3_DRB_INTERFACE_H
|
||||
|
||||
#include "srslte/common/buffer_pool.h"
|
||||
#include "srslte/common/common.h"
|
||||
#include "srslte/common/pdu.h"
|
||||
#include "ttcn3_interfaces.h"
|
||||
#include "ttcn3_port_handler.h"
|
||||
#include <srslte/interfaces/ue_interfaces.h>
|
||||
|
||||
using namespace srslte;
|
||||
|
||||
// The DRB interface
|
||||
class ttcn3_drb_interface : public ttcn3_port_handler
|
||||
{
|
||||
public:
|
||||
ttcn3_drb_interface() : pool(byte_buffer_pool::get_instance()) {}
|
||||
~ttcn3_drb_interface() = default;
|
||||
|
||||
int init(ss_srb_interface* syssim_, srslte::log* log_, std::string net_ip_, uint32_t net_port_)
|
||||
{
|
||||
syssim = syssim_;
|
||||
log = log_;
|
||||
net_ip = net_ip_;
|
||||
net_port = net_port_;
|
||||
initialized = true;
|
||||
log->debug("Initialized.\n");
|
||||
return port_listen();
|
||||
}
|
||||
|
||||
void tx(unique_byte_buffer_t pdu)
|
||||
{
|
||||
if (initialized) {
|
||||
log->info_hex(pdu->msg, pdu->N_bytes, "Sending %d B to Titan\n", pdu->N_bytes);
|
||||
send(pdu->msg, pdu->N_bytes);
|
||||
} else {
|
||||
log->error("Trying to transmit but port not connected.\n");
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
///< Main message handler
|
||||
int handle_message(const unique_byte_array_t& rx_buf, const uint32_t n)
|
||||
{
|
||||
log->debug_hex(rx_buf->begin(), n, "Received %d B from remote.\n", n);
|
||||
|
||||
// Chop incoming msg, first two bytes are length of the JSON
|
||||
// (see IPL4_EUTRA_SYSTEM_Definitions.ttcn
|
||||
uint16_t json_len = ((uint16_t)rx_buf->at(0) << 8) | rx_buf->at(1);
|
||||
|
||||
// The data part after the JSON starts right here but handling
|
||||
// is done in the respective functions
|
||||
uint16_t rx_buf_offset = json_len + 2;
|
||||
|
||||
Document document;
|
||||
if (document.Parse((char*)&rx_buf->at(2)).HasParseError() || document.IsObject() == false) {
|
||||
log->error_hex((uint8*)&rx_buf->at(2), json_len, "Error parsing incoming data.\n");
|
||||
return SRSLTE_ERROR;
|
||||
}
|
||||
|
||||
// Pretty-print
|
||||
StringBuffer buffer;
|
||||
PrettyWriter<StringBuffer> writer(buffer);
|
||||
document.Accept(writer);
|
||||
log->info("Received JSON with %d B\n%s\n", json_len, (char*)buffer.GetString());
|
||||
|
||||
// TODO: call handler
|
||||
|
||||
return SRSLTE_SUCCESS;
|
||||
}
|
||||
|
||||
ss_srb_interface* syssim = nullptr;
|
||||
byte_buffer_pool* pool = nullptr;
|
||||
|
||||
int drb_fd = 0;
|
||||
};
|
||||
|
||||
#endif // SRSUE_TTCN3_DRB_INTERFACE_H
|
|
@ -28,6 +28,7 @@
|
|||
#include "srslte/upper/pdcp.h"
|
||||
#include "srslte/upper/rlc.h"
|
||||
#include "ttcn3_common.h"
|
||||
#include "ttcn3_drb_interface.h"
|
||||
#include "ttcn3_ip_ctrl_interface.h"
|
||||
#include "ttcn3_ip_sock_interface.h"
|
||||
#include "ttcn3_srb_interface.h"
|
||||
|
@ -87,6 +88,7 @@ public:
|
|||
ip_sock_log.init("IP_S", logger);
|
||||
ip_ctrl_log.init("IP_C", logger);
|
||||
srb_log.init("SRB ", logger);
|
||||
drb_log.init("DRB ", logger);
|
||||
srslte::logmap::register_log(std::unique_ptr<srslte::log>{new log_filter{"SS-RLC", logger}});
|
||||
srslte::logmap::register_log(std::unique_ptr<srslte::log>{new log_filter{"SS-PDCP", logger}});
|
||||
|
||||
|
@ -96,6 +98,7 @@ public:
|
|||
ip_sock_log.set_level(args.log.all_level);
|
||||
ip_ctrl_log.set_level(args.log.all_level);
|
||||
srb_log.set_level(args.log.all_level);
|
||||
drb_log.set_level(args.log.all_level);
|
||||
ss_mac_log->set_level(args.log.all_level);
|
||||
ss_rlc_log->set_level(args.log.all_level);
|
||||
ss_pdcp_log->set_level(args.log.all_level);
|
||||
|
@ -106,6 +109,7 @@ public:
|
|||
ip_sock_log.set_hex_limit(args.log.all_hex_limit);
|
||||
ip_ctrl_log.set_hex_limit(args.log.all_hex_limit);
|
||||
srb_log.set_hex_limit(args.log.all_hex_limit);
|
||||
drb_log.set_hex_limit(args.log.all_hex_limit);
|
||||
ss_mac_log->set_hex_limit(args.log.all_hex_limit);
|
||||
ss_rlc_log->set_hex_limit(args.log.all_hex_limit);
|
||||
ss_pdcp_log->set_hex_limit(args.log.all_hex_limit);
|
||||
|
@ -188,6 +192,15 @@ public:
|
|||
event_handler.insert({srb_fd, &srb});
|
||||
log->console("SRB handler listening on SCTP port %d\n", SRB_PORT);
|
||||
|
||||
// add DRB fd
|
||||
int drb_fd = drb.init(this, &drb_log, listen_address, DRB_PORT);
|
||||
if (add_epoll(drb_fd, epoll_fd) != SRSLTE_SUCCESS) {
|
||||
log->error("Error while adding DRB port to epoll\n");
|
||||
return SRSLTE_ERROR;
|
||||
}
|
||||
event_handler.insert({drb_fd, &drb});
|
||||
log->console("DRB handler listening on SCTP port %d\n", DRB_PORT);
|
||||
|
||||
return SRSLTE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1168,6 +1181,7 @@ private:
|
|||
ttcn3_ip_sock_interface ip_sock;
|
||||
ttcn3_ip_ctrl_interface ip_ctrl;
|
||||
ttcn3_srb_interface srb;
|
||||
ttcn3_drb_interface drb;
|
||||
|
||||
// Epoll
|
||||
int epoll_fd = -1;
|
||||
|
@ -1186,6 +1200,7 @@ private:
|
|||
srslte::log_filter ip_sock_log;
|
||||
srslte::log_filter ip_ctrl_log;
|
||||
srslte::log_filter srb_log;
|
||||
srslte::log_filter drb_log;
|
||||
srslte::log_ref ss_mac_log{"SS-MAC"};
|
||||
srslte::log_ref ss_rlc_log{"SS-RLC"};
|
||||
srslte::log_ref ss_pdcp_log{"SS-PDCP"};
|
||||
|
@ -1263,6 +1278,7 @@ private:
|
|||
const uint32_t IPSOCK_PORT = 2224;
|
||||
const uint32_t IPCTRL_PORT = 2225;
|
||||
const uint32_t SRB_PORT = 2226;
|
||||
const uint32_t DRB_PORT = 2227;
|
||||
};
|
||||
|
||||
#endif // SRSUE_TTCN3_SYSSIM_H
|
||||
|
|
Loading…
Reference in New Issue