Commit 0cf05b55 authored by Garcia's avatar Garcia
Browse files

Start support of SIP part

parent d94f6a9e
Loading
Loading
Loading
Loading
+988 −0

File added.

Preview size limit exceeded, changes collapsed.

+62 −0
Original line number Diff line number Diff line
#pragma once

#include "codec.hh"
#include "params.hh"

#include "osipparser2/osip_parser.h"

class Base_Type;
class TTCN_Typedescriptor_t;
class TTCN_Buffer;

namespace LibSip__SIPTypesAndValues {
  class Request;
  class HostPort;
  class Authorization;
  class From;
  class To;
  class Via;
}

namespace LibSip__Common {
  class SemicolonParam__List;
  class AmpersandParam__List;
}
// class OPTIONAL<LibSip__Common::SemicolonParam__List>;
// class OPTIONAL<LibSip__Common::AmpersandParam__List>;

class sip_codec_request: public codec <
LibSip__SIPTypesAndValues::Request,
LibSip__SIPTypesAndValues::Request>
{
public:
  explicit sip_codec_request() : codec<LibSip__SIPTypesAndValues::Request, LibSip__SIPTypesAndValues::Request>() { };
  virtual ~sip_codec_request() { };

  virtual int encode (const LibSip__SIPTypesAndValues::Request& msg, OCTETSTRING& data);
  virtual int decode (const OCTETSTRING& data, LibSip__SIPTypesAndValues::Request& msg, params* p_params = NULL);
private: //! \todo Move this section into a sip_codec_helper class, need to decode Response too
  void fill_message_body(const osip_message_t* p_sip_message, LibSip__SIPTypesAndValues::Request& p_request);
  void fill_payload(const osip_message_t* p_sip_message, LibSip__SIPTypesAndValues::Request& p_request);
  void fill_uri(LibSip__SIPTypesAndValues::SipUrl& p_sip_url, const osip_uri_t* p_uri);
  void fill_request_line(const osip_message_t* p_sip_message, LibSip__SIPTypesAndValues::Request& msg);
  void fill_headers(const osip_message_t* p_sip_message, LibSip__SIPTypesAndValues::Request& msg);


  void fill_accept_header(const osip_message_t* p_sip_message, LibSip__SIPTypesAndValues::Accept& p_accept_header);
  void fill_accept_contact_header(const osip_message_t* p_sip_message, LibSip__SIPTypesAndValues::AcceptContact& p_accept_contact_header);
  void fill_accept_encoding_header(const osip_message_t* p_sip_message, LibSip__SIPTypesAndValues::AcceptEncoding& p_accept_encoding_header);
  void fill_accept_language_header(const osip_message_t* p_sip_message, LibSip__SIPTypesAndValues::AcceptLanguage& p_accept_language_header);
  void fill_alert_info_header(const osip_message_t* p_sip_message, LibSip__SIPTypesAndValues::AlertInfo& p_alert_info_header);
  void fill_allow_header(const osip_message_t* p_sip_message, LibSip__SIPTypesAndValues::Allow& p_allow_header);
  void fill_allow_events_header(const osip_message_t* p_sip_message, LibSip__SIPTypesAndValues::AllowEvents& p_allow_events_header);
  void fill_authorization_header(const osip_message_t* p_sip_message, LibSip__SIPTypesAndValues::Authorization& p_authorization_header);
  void fill_from_header(const osip_from_t* p_sip_from, LibSip__SIPTypesAndValues::From& p_from_header);
  void fill_to_header(const osip_to_t* p_sip_to, LibSip__SIPTypesAndValues::To& p_to_header);
  void fill_via_header(const osip_message_t* p_sip_via_list, LibSip__SIPTypesAndValues::Via& p_via_header);
  
  void fill_host_port(const char* p_host, const char* p_port, LibSip__SIPTypesAndValues::HostPort& p_host_port);
  void fill_semi_colon_params(const osip_list_t& p_sip_list, OPTIONAL<LibSip__Common::SemicolonParam__List>& p_list);
  void fill_ampersand_params(const osip_list_t& p_sip_list, OPTIONAL<LibSip__Common::AmpersandParam__List>& p_list);

}; // End of class sip_codec_request
+37 −33
Original line number Diff line number Diff line
@@ -28,13 +28,6 @@ tcp_layer::tcp_layer(const std::string & p_type, const std::string & param) : la
  if (!parameter_set(params::server.c_str(), _params[params::server].c_str())) {
    loggers::get_instance().warning("tcp_layer::set_parameter: Unprocessed parameter: %s", params::server.c_str());
  }
  it = _params.find(params::port);
  if (it == _params.cend()) {
    _params.insert(std::pair<std::string, std::string>(std::string("port"), "80"));
  }
  if (!parameter_set(params::port.c_str(), _params[params::port].c_str())) {
    loggers::get_instance().warning("tcp_layer::set_parameter: Unprocessed parameter: %s", params::server.c_str());
  }
  set_ssl_use_ssl(false);
  it = _params.find(params::use_ssl);
  if (it == _params.cend()) {
@@ -42,6 +35,17 @@ tcp_layer::tcp_layer(const std::string & p_type, const std::string & param) : la
  } else if (it->second.compare("1") == 0) {
    set_ssl_use_ssl(true);
  }
  it = _params.find(params::port);
  if (it == _params.cend()) {
    if (_params[params::use_ssl].compare("0") == 0) { // Use standard HTTP port
      _params.insert(std::pair<std::string, std::string>(std::string("port"), "80"));
    } else { // Use standard HTTPS port
      _params.insert(std::pair<std::string, std::string>(std::string("port"), "443"));
    }
  }
  if (!parameter_set(params::port.c_str(), _params[params::port].c_str())) {
    loggers::get_instance().warning("tcp_layer::set_parameter: Unprocessed parameter: %s", params::server.c_str());
  }

  parameter_set(use_connection_ASPs_name(), "yes");
  parameter_set(server_backlog_name(), "1024");
+49 −46
Original line number Diff line number Diff line
# Copyright ETSI 2018
# See: https://forge.etsi.org/etsi-forge-copyright-statement.txt
FROM ubuntu:18.04

FROM gcc:latest
MAINTAINER ETSI STF 525

MAINTAINER STF549

LABEL description="STF549 Docker Image"
LABEL description="STF525 Docker Image"

ENV TERM=linux
ENV HOSTNAME docker-titan-STF549
ENV HOSTNAME docker-titan-STF525

ARG USERNAME
ARG PASSWORD
ARG ssh_pub_key

RUN echo "docker-titan" > /etc/hostname \
RUN echo "docker-titan-STF525" > /etc/hostname \
    && echo "root:etsi" | chpasswd \
    && DEBIAN_FRONTEND=noninteractive apt-get update \
    && DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y \
    && DEBIAN_FRONTEND=noninteractive apt-get install software-properties-common -y \
    && DEBIAN_FRONTEND=noninteractive add-apt-repository ppa:linuxuprising/java -y \
    && DEBIAN_FRONTEND=noninteractive apt-get update \
    && DEBIAN_FRONTEND=noninteractive apt-get install -y \
    && DEBIAN_FRONTEND=noninteractive apt-get --allow-unauthenticated install -y \
      autoconf \
      bison \
      build-essential \
@@ -28,10 +26,13 @@ RUN echo "docker-titan" > /etc/hostname \
      emacs \
      expect \
      flex \
      graphviz \
      g++-8 \
      gcc-8 \
      gdb \
      git-core \
      gnutls-bin \
      graphviz \
      inetutils-ping \
      libglib2.0-dev \
      libpcap-dev \
      libgcrypt-dev \
@@ -53,54 +54,56 @@ RUN echo "docker-titan" > /etc/hostname \
      tcpdump \
      texlive-font-utils \
      tshark \
      tzdata \
      valgrind \
      vim \
      vsftpd \
      xutils-dev \ 
      tree \
      unzip \
      wget \
    && DEBIAN_FRONTEND=noninteractive apt-get install oracle-java10-installer oracle-java10-set-default -y \
    && DEBIAN_FRONTEND=noninteractive apt-get autoremove -y \
    && DEBIAN_FRONTEND=noninteractive apt-get autoclean -y \
    && DEBIAN_FRONTEND=noninteractive apt-get autoremove --purge -y \
    && DEBIAN_FRONTEND=noninteractive apt-get autoclean \
    && useradd --create-home --shell /bin/bash etsi \
    && echo "etsi:etsi" | chpasswd \
    && adduser etsi sudo \
    && su - etsi \
    && whoami \
    && cd /home/etsi \
    && mkdir -p bin lib include tmp frameworks docs dev \
    && ls -ltr \
    && echo "" >> /etc/profile \
    && echo "export HOME=/home/etsi" >> /etc/profile \
    && echo "export LD_LIBRARY_PATH=/home/etsi/TriesAndDelete/etsi_its/lib:$LD_LIBRARY_PATH" >> /etc/profile \
    && echo "export PATH=/home/etsi/bin:$PATH" >> /etc/profile \
    && echo "cd /home/etsi" >> /etc/profile \
    && echo ". ./devenv.bash" >> /etc/profile 

USER etsi

RUN cd /home/etsi \
    && mkdir -p .ssh bin lib include tmp frameworks docs man dev \
    && echo "$ssh_pub_key" > /home/etsi/.ssh/id_rsa.pub \
    && cat /home/etsi/.ssh/id_rsa.pub \
    && cd /home/etsi/dev \
    && git clone http://forge.etsi.org/gitlab/emergency-communications/NG112.git STF549_Ng112 \
    && cd /home/etsi/dev/STF549_Ng112/ttcn \
        && svn co --username $USERNAME --password $PASSWORD --non-interactive https://oldforge.etsi.org/svn/LibCommon/tags/v1.4.0/ttcn \
        && svn co --username $USERNAME --password $PASSWORD --non-interactive https://oldforge.etsi.org/svn/LibSip/trunk \
    && cd /home/etsi/dev/STF549_Ng112/scripts \
    && chmod 775 *.bash devenv.bash.ubuntu \
    && svn co --non-interactive https://oldforge.etsi.org/svn/ITS/branches/STF525 ./STF525_Its \
    && cd /home/etsi/dev/STF525_Its/scripts \
    && chmod 775 *.bash devenv.bash.* \
    && cd /home/etsi \
    && ln -sf /home/etsi/dev/STF549_Ng112/scripts/devenv.bash.ubuntu /home/etsi/devenv.bash \
    && ln -sf /home/etsi/dev/STF525_Its/scripts/devenv.bash.ubuntu /home/etsi/devenv.bash \
    && ls -ltr /home/etsi \
    && export HOME=/home/etsi \
    && . /home/etsi/devenv.bash \
    && cd /home/etsi/frameworks \
    && git clone https://github.com/YannGarcia/osip osip \
    && cd /home/etsi/frameworks/osip \
    && ./autogen.sh \
    && make check \
    && echo "" >> /home/etsi/.bashrc \
    && echo ". ./devenv.bash" >> /home/etsi/.bashrc \
    && echo "" >> /home/etsi/.bashrc \
    && cd /home/etsi/dev/STF549_Ng112/scripts \
    && git clone https://github.com/vlm/asn1c.git asn1c \
    && cd asn1c \
    && test -f configure || autoreconf -iv \
    && ./configure --prefix=/home/etsi \
    && make && make install \
    && cd /home/etsi/frameworks \
    && wget 'http://ftp.halifax.rwth-aachen.de/eclipse//technology/epp/downloads/release/oxygen/2/eclipse-cpp-oxygen-2-linux-gtk-x86_64.tar.gz' -Oeclipse-cpp-oxygen-2-linux-gtk-x86_64.tar.gz \
    && tar -zxvf ./eclipse-cpp-oxygen-2-linux-gtk-x86_64.tar.gz \
    && rm -f ./eclipse-cpp-oxygen-2-linux-gtk-x86_64.tar.gz \
    && . /home/etsi/devenv.bash \
    && cd /home/etsi/dev/STF525_Its/scripts \
    && ./build_titan.bash \
    && cd /home/etsi \
    && . /home/etsi/devenv.bash \
    && cd /home/etsi/dev/STF549_Ng112/scripts \
    && ./update_emcom_project.bash \
    && ls -ltr /home/etsi/dev/STF549_Ng112 \
    && cd /home/etsi/dev/STF549_Ng112/etsi_emcom/src/AtsNg112/objs \
    && ../bin/ng112.bash


    && ./update_its_project.bash

CMD ["/bin/bash", "-c", "su - etsi"]
CMD ["/bin/bash"]

# That's all Floks
+8 −7
Original line number Diff line number Diff line
@@ -3,23 +3,24 @@
# See: https://forge.etsi.org/etsi-forge-copyright-statement.txt

set -e
#set -vx

USERNAME=<username>
PASSWORD=<password>
set -vx

DOCKER_FILE=./Dockerfile
if [ -f ${DOCKER_FILE} ]
then
    IMAGES=$(docker images -q)
    if [ "${IMAGES}" != "" ]
    then
      docker rmi -f $(docker images -q)
    docker build --tag stf549_ng112 --force-rm --build-arg USERNAME=${USERNAME} --build-arg PASSWORD=${PASSWORD} .
    fi
    docker build --tag stf525_its --force-rm --build-arg ssh_pub_key="$(cat ~/.ssh/id_rsa.pub)" .
    if [ "$?" != "0" ]
    then
        echo "Docker build failed: $?"
        exit -1
    fi
    docker image ls -a
    docker inspect stf549_ng112:latest
    docker inspect stf525_its:latest
    if [ "$?" != "0" ]
    then
        echo "Docker inspect failed: $?"
Loading