Message.h 6.84 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
 * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The OpenAirInterface Software Alliance licenses this file to You under
 * the OAI Public License, Version 1.0  (the "License"); you may not use this file
 * except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.openairinterface.org/?page_id=698
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *-------------------------------------------------------------------------------
 * For more information about the OpenAirInterface (OAI) Software Alliance:
 *      contact@openairinterface.org
 */

22 23 24 25 26 27 28 29 30 31 32 33
#ifndef _MESSAGE_H_
#    define _MESSAGE_H_

#    include <string>
#    include <cstring>

#    include "socket_include.h"
#    include "storage.h"
#    include "platform.h"

#define MESSAGE_DESERIALIZE_BUFFER_SIZE 2048
#define MESSAGE_SERIALIZE_BUFFER_SIZE   2048
34 35 36
class           Message
{
public:
37 38


39
  typedef std::pair<std::string,int> e_nodeb_internet_address_id_t;
40

41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
  //============ STATUS ======================
  static const msg_response_status_t STATUS_CONNECTION_ACCEPTED                     = 1;
  static const msg_response_status_t STATUS_CONNECTION_FAILED                       = -1;
  static const msg_response_status_t STATUS_ADD_USER_SUCCESSFULL                    = 2;
  static const msg_response_status_t STATUS_ADD_USER_FAILED                         = -2;
  static const msg_response_status_t STATUS_REMOVE_USER_SUCCESSFULL                 = 3;
  static const msg_response_status_t STATUS_REMOVE_USER_FAILED                      = -3;
  static const msg_response_status_t STATUS_ADD_RADIO_ACCESS_BEARER_SUCCESSFULL     =  4;
  static const msg_response_status_t STATUS_ADD_RADIO_ACCESS_BEARER_FAILED          = -4;
  static const msg_response_status_t STATUS_REMOVE_RADIO_ACCESS_BEARER_SUCCESSFULL  =  5;
  static const msg_response_status_t STATUS_REMOVE_RADIO_ACCESS_BEARER_FAILED       = -5;
  //============ MESSAGES ======================
  static const msg_type_t MESSAGE_CONNECTION_REQUEST                                   = 0;
  static const msg_type_t MESSAGE_CONNECTION_RESPONSE                                  = 1;
  static const msg_type_t MESSAGE_CONNECTION_CLOSE                                     = 2;
  static const msg_type_t MESSAGE_CONNECTION_CLOSE_ACK                                 = 3;
  static const msg_type_t MESSAGE_ADD_USER_REQUEST                                     = 4;
  static const msg_type_t MESSAGE_ADD_USER_RESPONSE                                    = 5;
  static const msg_type_t MESSAGE_ADD_USER_CONFIRM                                     = 6;
  static const msg_type_t MESSAGE_REMOVE_USER_REQUEST                                  = 7;
  static const msg_type_t MESSAGE_REMOVE_USER_RESPONSE                                 = 8;
  static const msg_type_t MESSAGE_ADD_RADIO_ACCESS_BEARER_REQUEST                      = 9;
  static const msg_type_t MESSAGE_ADD_RADIO_ACCESS_BEARER_RESPONSE                     = 10;
  static const msg_type_t MESSAGE_ADD_RADIO_ACCESS_BEARER_CONFIRM                      = 11;
  static const msg_type_t MESSAGE_REMOVE_RADIO_ACCESS_BEARER_REQUEST                   = 12;
  static const msg_type_t MESSAGE_REMOVE_RADIO_ACCESS_BEARER_RESPONSE                  = 13;
  static const msg_type_t MESSAGE_MEASUREMENT_REQUEST                                  = 14;
  static const msg_type_t MESSAGE_L1_MEASUREMENT_RG_INTERNAL_REPORT                    = 15;
  static const msg_type_t MESSAGE_L1_MEASUREMENT_RG_QUALITY_REPORT                     = 16;
  static const msg_type_t MESSAGE_L1_MEASUREMENT_RG_TRAFFIC_VOLUME_REPORT              = 17;
  static const msg_type_t MESSAGE_L1_MEASUREMENT_RG_PHYSICAL_CHANNEL_DATA_AMP_REPORT   = 18;
  static const msg_type_t MESSAGE_L1_MEASUREMENT_MT_INTERNAL_REPORT                    = 19;
  static const msg_type_t MESSAGE_L1_MEASUREMENT_MT_QUALITY_REPORT                     = 20;
  static const msg_type_t MESSAGE_L1_MEASUREMENT_MT_TRAFFIC_VOLUME_REPORT              = 21;
  static const msg_type_t MESSAGE_L1_MEASUREMENT_MT_INTRA_FREQUENCY_REPORT             = 22;
  static const msg_type_t MESSAGE_UPLINK_PHYSICAL_CHANNEL_CONTROL                      = 23;
  static const msg_type_t MESSAGE_CONFIG_REQUEST                                       = 24;
  static const msg_type_t MESSAGE_ACK                                                  = 25;
  static const msg_type_t MESSAGE_UPDATE_DSCH                                          = 26;
  //============ REASONS ======================
  static const msg_response_reason_t    MSG_RESP_OK                     = 0;
  static const msg_response_reason_t    MSG_RESP_PROTOCOL_ERROR         = 1;
  static const msg_response_reason_t    MSG_RESP_RESSOURCES_UNAVAILABLE = 2;
  static const msg_response_reason_t    MSG_RESP_UNKNOWN_MESSAGE        = 128;
  static const msg_response_reason_t    MSG_RESP_INTERNAL_ERROR         = 255;
86

87
  static  uint8_t s_buffer[MESSAGE_DESERIALIZE_BUFFER_SIZE];
88

89 90 91 92 93
  Message ();
  Message(tcpip::Storage&);
  virtual void    Serialize () {};
  virtual void    Forward () {};
  virtual void    Serialize (char *out_bufferP, size_t* size_dataP) {};
94

95 96 97 98 99 100 101 102 103 104 105 106 107
  static Message *DeserializeRRCMessage(const char *in_bufferP,size_t size_dataP,struct sockaddr *sa_fromP,socklen_t sa_lenP);
  static Message *DeserializeRRMMessage(const char *in_bufferP,size_t size_dataP,struct sockaddr *sa_fromP,socklen_t sa_lenP);
  static Message *Deserialize (const char *in_bufferP,size_t size_dataP,struct sockaddr *sa_fromP,socklen_t sa_lenP);
  void            ParseIpParameters(struct sockaddr *sa_fromP,socklen_t sa_lenP);
  msg_length_t    GetSerializedMessageSize();
  const char*     GetSerializedMessageBuffer();
  const int       GetSrcPort() {
    return m_port_src;
  };
  const char*     GetSrcAddress() {
    return m_ip_char_src;
  };
  virtual ~ Message ();
108

109 110
  static std::string StatusToString(msg_response_status_t);
  static std::string ReasonToString(msg_response_reason_t);
111 112


113 114 115 116 117 118 119 120 121 122
protected:
  msg_type_t            m_type;
  bool                  m_is_ipv6;
  struct sockaddr_in    m_sockaddr_in4_src;
  struct sockaddr_in6   m_sockaddr_in6_src;
  std::string           m_ip_str_src;
  char*                 m_ip_char_src;
  int                   m_port_src;
  tcpip::Storage        m_message_storage;
  unsigned char*        m_message_buffer;
123

124 125 126
  msg_length_t         m_msg_length;
  uint8_t              m_message_serialize_buffer[MESSAGE_SERIALIZE_BUFFER_SIZE];
  //uint8_t               m_message_serialize_buffer[MESSAGE_DESERIALIZE_BUFFER_SIZE];
127 128 129
};

#    endif