Commit 25b6b4a6 authored by juvancic's avatar juvancic
Browse files

Added NGAP layer support

parent c9e3c590
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
sources := ngap_layer.cc
includes := . ../NGAP/ ../pcpp/Packet/ ../pcpp/Common/
 No newline at end of file
+54 −0
Original line number Diff line number Diff line
/*!
 * \file      ngap_layer.cc
 * \brief     CC file for NGAP protocol layer.
 * \author    ETSI TTF041
 * \copyright ETSI Copyright Notification
 *            No part may be reproduced except as authorized by written permission.
 *            The copyright and the foregoing restriction extend to reproduction in all media.
 *            All rights reserved.
 * \version   0.1
 */

#include "ngap_types.hh"

#include "NGAP_TestSystem.hh"
#include "ngap_layer_factory.hh"

#include "registration.hh"

#include "loggers.hh"

ngap_layer::ngap_layer(const std::string &p_type, const std::string &param) : t_layer<LibNGAP__Interface::NGAPPort>(p_type), _params(), _codec(), _ng_nas_dl_codec(), _ng_nas_ul_codec() {
  loggers::get_instance().log(">>> ngap_layer::ngap_layer: %s, %s", to_string().c_str(), param.c_str());
  // Setup parameters
  params::convert(_params, param);
  // Register this object for AdapterControlPort
  loggers::get_instance().log("ngap_layer::ngap_layer: Register %s/%p", p_type.c_str(), this);
  registration<ngap_layer>::get_instance().add_item(p_type, this);
}

void ngap_layer::sendMsg(const NGAP__PDU__Descriptions::NGAP__PDU& p, params &params) {
  loggers::get_instance().log_msg(">>> ngap_layer::sendMsg: ", p);

  OCTETSTRING data = int2oct(0,1);
  send_data(data, _params);
}

void ngap_layer::send_data(OCTETSTRING &data, params &p_params) {
  loggers::get_instance().log_msg(">>> ngap_layer::send_data: ", data);

  send_to_all_layers(data, p_params);  
}


void ngap_layer::receive_data(OCTETSTRING &data, params &p_params) {
  loggers::get_instance().log_msg(">>> ngap_layer::receive_data: ", data);

  NGAP__PDU__Descriptions::NGAP__PDU p;
  _codec.decode(data, p, &p_params);
 
  // Pass it to the ports if any
  to_all_upper_ports(p, p_params);
}

ngap_layer_factory ngap_layer_factory::_f;
+74 −0
Original line number Diff line number Diff line
/*!
 * \file      ngap_layer.hh
 * \brief     Header file for NGAP protocol layer.
 * \author    ETSI TTF041
 * \copyright ETSI Copyright Notification
 *            No part may be reproduced except as authorized by written permission.
 *            The copyright and the foregoing restriction extend to reproduction in all media.
 *            All rights reserved.
 * \version   0.1
 */
#pragma once
#include "ng_nas_dl_codec.hh"
#include "ng_nas_ul_codec.hh"
#include "ngap_codec.hh"
#include "t_layer.hh"

namespace LibNGAP__Interface {
  class NGAPPort; //! Forward declaration of TITAN class
} // namespace LibNGAP__Interface

/*!
 * \class ngap_layer
 * \brief  This class provides description of NGAP protocol layer
 */
class ngap_layer : public t_layer<LibNGAP__Interface::NGAPPort> {
  params _params; //! Layer parameters
  ngap_codec  _codec;  //! NGAP codec
  ng_nas_dl_codec _ng_nas_dl_codec;
  ng_nas_ul_codec _ng_nas_ul_codec;
public:              //! \publicsection
  /*!
   * \brief Default constructor
   *        Create a new instance of the ngap_layer class
   */
  explicit ngap_layer() : t_layer<LibNGAP__Interface::NGAPPort>(), _params(), _codec(),_ng_nas_dl_codec(),_ng_nas_ul_codec(){};
  /*!
   * \brief Specialised constructor
   *        Create a new instance of the ngap_layer class
   * \param[in] p_type \todo
   * \param[in] p_param \todo
   */
  ngap_layer(const std::string &p_type, const std::string &param);
  /*!
   * \brief Default destructor
   */
  virtual ~ngap_layer(){};

  /*!
   * \fn void sendMsg(const NGAP__PDU__Descriptions::NGAP__PDU& p_ngap, params& p_params);
   * \brief Send NGAP message to the lower layers
   * \param[in] p_ngap_req The CA message to be sent
   * \param[in] p_params Some parameters to overwrite default value of the lower layers parameters
   */
  void sendMsg(const NGAP__PDU__Descriptions::NGAP__PDU& p_ngap, params &p_params);

  /*!
   * \virtual
   * \fn void send_data(OCTETSTRING& data, params& params);
   * \brief Send bytes formated data to the lower layers
   * \param[in] p_data The data to be sent
   * \param[in] p_params Some parameters to overwrite default value of the lower layers parameters
   */
  virtual void send_data(OCTETSTRING &data, params &params);

  /*!
   * \virtual
   * \fn void receive_data(OCTETSTRING& data, params& params);
   * \brief Receive bytes formated data from the lower layers
   * \param[in] p_data The bytes formated data received
   * \param[in] p_params Some lower layers parameters values when data was received
   */
  virtual void receive_data(OCTETSTRING &data, params &info);

}; // End of class ngap_layer
+41 −0
Original line number Diff line number Diff line
/*!
 * \file      ngap_layer_factory.hh
 * \brief     Header file for NGAP protocol layer factory.
 * \author    ETSI TTF041
 * \copyright ETSI Copyright Notification
 *            No part may be reproduced except as authorized by written permission.
 *            The copyright and the foregoing restriction extend to reproduction in all media.
 *            All rights reserved.
 * \version   0.1
 */
#pragma once

#include "layer_stack_builder.hh"

#include "ngap_layer.hh"

/*!
 * \class ngap_layer_factory
 * \brief  This class provides a factory class to create a ngap_layer class instance
 */
class ngap_layer_factory : public layer_factory {
  static ngap_layer_factory _f; //! Reference to the unique instance of this class
public:                        //! \publicsection
  /*!
   * \brief Default constructor
   *        Create a new instance of the ngap_layer_factory class
   * \remark The NGAP layer identifier is NGAP
   */
  ngap_layer_factory() {
    // Register factory
    layer_stack_builder::register_layer_factory("NGAP", this);
  };
  /*!
   * \fn layer* create_layer(const std::string & type, const std::string & param);
   * \brief  Create the layers stack based on the provided layers stack description
   * \param[in] p_type The provided layers stack description
   * \param[in] p_params Optional parameters
   * \return 0 on success, -1 otherwise
   */
  inline virtual layer *create_layer(const std::string &p_type, const std::string &p_param) { return new ngap_layer(p_type, p_param); };
}; // End of class ngap_layer_factory