play_scenario_sctp.c 3.42 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
/*******************************************************************************
    OpenAirInterface
    Copyright(c) 1999 - 2014 Eurecom

    OpenAirInterface is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.


    OpenAirInterface 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 General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with OpenAirInterface.The full GNU General Public License is
    included in this distribution in the file called "COPYING". If not,
    see <http://www.gnu.org/licenses/>.

  Contact Information
  OpenAirInterface Admin: openair_admin@eurecom.fr
  OpenAirInterface Tech : openair_tech@eurecom.fr
  OpenAirInterface Dev  : openair4g-devel@lists.eurecom.fr

  Address      : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE

 *******************************************************************************/

/*
                                play_scenario_sctp.c
                                -------------------
  AUTHOR  : Lionel GAUTHIER
  COMPANY : EURECOM
  EMAIL   : Lionel.Gauthier@eurecom.fr
 */


#include <errno.h>

#include "intertask_interface.h"
#include "platform_types.h"
#include "assertions.h"
#include "play_scenario.h"

46 47 48 49
//------------------------------------------------------------------------------
int et_sctp_data_is_matching(sctp_datahdr_t * const sctp1, sctp_datahdr_t * const sctp2, const uint32_t constraints)
{
  // no comparison for ports
50 51 52 53 54 55 56 57
  if (sctp1->ppid     != sctp2->ppid) {
    S1AP_WARN("No Matching SCTP PPID %u %u\n", sctp1->ppid, sctp2->ppid);
    return -ET_ERROR_MATCH_PACKET_SCTP_PPID;
  }
  if (sctp1->assoc_id != sctp2->assoc_id) {
    S1AP_WARN("No Matching SCTP assoc id %u %u\n", sctp1->assoc_id, sctp2->assoc_id);
    return -ET_ERROR_MATCH_PACKET_SCTP_ASSOC_ID;
  }
58 59
  if (sctp1->stream != sctp2->stream) {
    if (constraints & ET_BIT_MASK_MATCH_SCTP_STREAM) {
60
      return -ET_ERROR_MATCH_PACKET_SCTP_STREAM_ID;
61 62 63 64 65 66
    } else {
      S1AP_WARN("No Matching SCTP stream %u %u\n", sctp1->stream, sctp2->stream);
    }
  }
  if (sctp1->ssn != sctp2->ssn) {
    if (constraints & ET_BIT_MASK_MATCH_SCTP_SSN) {
67
      return -ET_ERROR_MATCH_PACKET_SCTP_SSN;
68
    } else {
69
      S1AP_WARN("No Matching SCTP STREAM SN %u %u\n", sctp1->ssn, sctp2->ssn);
70 71 72 73 74 75 76 77 78
    }
  }
  return et_s1ap_is_matching(&sctp1->payload, &sctp2->payload,  constraints);
}

//------------------------------------------------------------------------------
int et_sctp_is_matching(et_sctp_hdr_t * const sctp1, et_sctp_hdr_t * const sctp2, const uint32_t constraints)
{
  // no comparison for ports
79
  if (sctp1->chunk_type != sctp2->chunk_type) return -ET_ERROR_MATCH_PACKET_SCTP_CHUNK_TYPE;
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
  switch (sctp1->chunk_type) {
    case SCTP_CID_DATA:
      return et_sctp_data_is_matching(&sctp1->u.data_hdr, &sctp2->u.data_hdr, constraints);
      break;

    case SCTP_CID_INIT:
      AssertFatal(0, "Not needed now");
      break;
    case SCTP_CID_INIT_ACK:
      AssertFatal(0, "Not needed now");
      break;
    default:
      AssertFatal(0, "Not needed now cid %d", sctp1->chunk_type);
  }

  return 0;
}