//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project / SSCOP protocol
//
//File: sscop.h
//
//Version: $Revision: 1.8 $
//
//State: $State: Exp $
//
//Date: $Date: 1999/03/11 18:53:55 $
//
//Organisation:
//      Helsinki University of Technology
//      Laboratory of Telecommunications and Multimedia
//
//Author:
//      Juhana Räsänen
//
//Description:
//      General definitions of the SSCOP protocol module
//
//Copyright:
//      Copyright 1999 Helsinki University of Technology
//      ALL RIGHTS RESERVED BETWEEN JANUARY 1996 AND JUNE 1999.
//
//Licence:
//
//
//History: 


#ifndef __SSCOP_H__
#define __SSCOP_H__

#include "pf/types.h"


// SSCOP sequence numbers go up to 2^24-1 as defined in Q.2110 (07/94)
// clause 7.4 page 18
const pfUlong SSCOP_SEQUENCE_MODULUS = 16777216L;
const pfUlong SSCOP_CC_SEQUENCE_MODULUS = 256L;


// SSCOP PDU type codes from TABLE 2/Q.2110
enum sscopPDU {sscopBGNpdu     =  1,
               sscopBGAKpdu    =  2,
               sscopBGREJpdu   =  7,
               sscopENDpdu     =  3,
               sscopENDAKpdu   =  4,
               sscopRSpdu      =  5,
               sscopRSAKpdu    =  6,
               sscopERpdu      =  9,
               sscopERAKpdu    = 15,
               sscopSDpdu      =  8,
               sscopPOLLpdu    = 10,
               sscopSTATpdu    = 11,
               sscopUSTATpdu   = 12,
               sscopUDpdu      = 13,
               sscopMDpdu      = 14,
               sscopINVALIDpdu = 16};  // Locally defined - not in Q.2110


// SSCOP PDU minimum (or absolute) lengths from FIGURE 8/Q.2110 (in octets).
// PDUs that have ABSLEN don't have a variable-length field (SSCOP_UU or
// Information frame).
const unsigned int sscopBGNpdu_MINLEN = 8;
const unsigned int sscopBGAKpdu_MINLEN = 8;
const unsigned int sscopBGREJpdu_MINLEN = 8;
const unsigned int sscopENDpdu_MINLEN = 8;
const unsigned int sscopENDAKpdu_ABSLEN = 8;
const unsigned int sscopRSpdu_MINLEN = 8;
const unsigned int sscopRSAKpdu_ABSLEN = 8;
const unsigned int sscopERpdu_ABSLEN = 8;
const unsigned int sscopERAKpdu_ABSLEN = 8;
const unsigned int sscopSDpdu_MINLEN = 4;
const unsigned int sscopPOLLpdu_ABSLEN = 8;
const unsigned int sscopSTATpdu_MINLEN = 12;
const unsigned int sscopUSTATpdu_ABSLEN = 16;
const unsigned int sscopUDpdu_MINLEN = 4;
const unsigned int sscopMDpdu_MINLEN = 4;


// SSCOP PDU minimum length is 4 octets
const unsigned int SSCOP_MIN_PDU_LENGTH = 4;


// SSCOP PDU decoding errors
const int SSCOP_PDU_OK = 0;
const int SSCOP_PDU_INVALID_LENGTH = 1;
const int SSCOP_PDU_OTHER_ERROR = 2;


// SSCOP error codes (to the management layer) TABLE A.1/Q.2110
enum sscopError {SSCOP_ERROR_A,  // Inappropriate SD
                 SSCOP_ERROR_B,  // Inappropriate BGN
                 SSCOP_ERROR_C,  // Inappropriate BGAK
                 SSCOP_ERROR_D,  // Inappropriate BGREJ
                 SSCOP_ERROR_E,  // Inappropriate END
                 SSCOP_ERROR_F,  // Inappropriate ENDAK
                 SSCOP_ERROR_G,  // Inappropriate POLL
                 SSCOP_ERROR_H,  // Inappropriate STAT
                 SSCOP_ERROR_I,  // Inappropriate USTAT
                 SSCOP_ERROR_J,  // Inappropriate RS
                 SSCOP_ERROR_K,  // Inappropriate RSAK
                 SSCOP_ERROR_L,  // Inappropriate ER
                 SSCOP_ERROR_M,  // Inappropriate ERAK
                 SSCOP_ERROR_O,  // VT(CC) >= MaxCC
                 SSCOP_ERROR_P,  // Timer_NO_RESPONSE expiry
                 SSCOP_ERROR_Q,  // SD or POLL N(S) error
                 SSCOP_ERROR_R,  // STAT N(PS) error
                 SSCOP_ERROR_S,  // STAT N(R) or list elements error
                 SSCOP_ERROR_T,  // USTAT N(R) or list elements error
                 SSCOP_ERROR_U,  // PDU length violation
                 SSCOP_ERROR_V,  // SD PDUs must be retransmitted
                 SSCOP_ERROR_W,  // Lack of credit
                 SSCOP_ERROR_X}; // Credit obtained


// SSCOP connection release initiator (SSCOP or user)
const pfUlong SSCOP_RELEASE_USER = 0;
const pfUlong SSCOP_RELEASE_SSCOP = 1;


// SSCOP MaxSTAT parameter default value from Q.2110 page 21
const int SSCOP_DEFAULT_MAX_STAT = 67;

// Initial window size
const int SSCOP_INITIAL_VR_MR = 30;


#endif // __SSCOP_H__
