/******************************************************************************/ // @copyright 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. // Trademark 2012, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC). // All rights reserved. // @version: 36.523-3v10.1.0 // $Date: 2012-09-03 10:54:34 +0200 (Mon, 03 Sep 2012) $ // $Rev: 7249 $ /******************************************************************************/ module CommonDefs { //---------------------------------------------------------------------------- // type definitions: type bitstring B1_Type length(1); type bitstring B2_Type length(2); type bitstring B3_Type length(3); type bitstring B4_Type length(4); type bitstring B5_Type length(5); type bitstring B6_Type length(6); type bitstring B7_Type length(7); type bitstring B7_15_Type length(7..15); // NOTE: length restriction can only be a range but not two destinct lengths type bitstring B8_Type length(8); type bitstring B9_Type length(9); type bitstring B10_Type length(10); type bitstring B11_Type length(11); type bitstring B12_Type length(12); type bitstring B14_Type length(14); type bitstring B15_Type length(15); type bitstring B16_Type length(16); type bitstring B20_Type length(20); type bitstring B24_Type length(24); type bitstring B27_Type length(27); type bitstring B28_Type length(28); type bitstring B32_Type length(32); type bitstring B36_Type length(36); type bitstring B40_Type length(40); type bitstring B41_Type length(41); type bitstring B43_Type length(43); type bitstring B47_Type length(47); type bitstring B48_Type length(48); type bitstring B56_Type length(56); type bitstring B64_Type length(64); type bitstring B80_Type length(80); type bitstring B112_Type length(112); type bitstring B128_Type length(128); type bitstring B160_Type length(160); type bitstring B192_Type length(192); type bitstring B256_Type length(256); type bitstring B32_128_Type length(32..128); type B128_Type B128_Key_Type; /* 128 bit security key */ type B256_Type B256_Key_Type; /* 256 bit security key */ type octetstring O1_Type length(1); type octetstring O2_Type length(2); type octetstring O3_Type length(3); type octetstring O4_Type length(4); type octetstring O5_Type length(5); type octetstring O6_Type length(6); type octetstring O8_Type length(8); type octetstring O9_Type length(9); type octetstring O10_Type length(10); type octetstring O14_Type length(14); type octetstring O13_Type length(14); type octetstring O15_Type length(15); type octetstring O16_Type length(16); type octetstring O32_Type length(32); type octetstring O43_Type length(43); type hexstring H2_Type length(2); type hexstring H4_Type length(4); type boolean Null_Type (true); // dummy type for 'typeless' fields in unions type boolean Dummy_Type (true); // dummy type for temporary purposes only const integer tsc_UInt8Max := 255; const integer tsc_UInt16Max := 65535; const integer tsc_UInt20Max := 1048575; const integer tsc_UInt32Max := 4294967295; type integer UInt_Type (0 .. infinity); type integer UInt8_Type (0 .. tsc_UInt8Max); type integer UInt16_Type (0 .. tsc_UInt16Max); type integer UInt20_Type (0 .. tsc_UInt20Max); type integer UInt32_Type (0 .. tsc_UInt32Max); type charstring Char1_Type length (1); type record of Char1_Type Char1List_Type; type record of charstring CharStringList_Type; type record of integer IntegerList_Type; type enumerated SinglePLMN_TestedType {SinglePLMN, MultiPLMN, MultiPLMNinPrimaryBand, MultiPLMNinSecondaryBand}; // @sic R5-123667 sic@ type enumerated EUTRA_ATTACH_TESTED_Type { EPS_ATTACH_ONLY, COMBINED_ATTACH}; type enumerated NAS_ATTACH_STATE_Type {ATTACHED, DETACHED}; type enumerated UTRAN_FDD_TDD_Type {UTRAN_FDD, UTRAN_TDD}; type enumerated RATComb_Tested_Type {EUTRA_UTRA, EUTRA_GERAN, EUTRA_Only}; type enumerated EUTRA_CellId_Type { eutra_Cell_NonSpecific, eutra_Cell1, eutra_Cell2, eutra_Cell3, eutra_Cell4, eutra_Cell6, eutra_Cell10, eutra_Cell11, eutra_Cell12, eutra_Cell13, eutra_Cell14, eutra_Cell23, eutra_Cell28, eutra_Cell29, eutra_Cell30, eutra_CellA, eutra_CellB, eutra_CellC, eutra_CellD, eutra_CellE, eutra_CellG, eutra_CellH, eutra_CellI, eutra_CellJ, eutra_CellK, eutra_CellL, eutra_CellM }; // To indicate which PTCs are configured (EUTRA alone is included for completeness) type enumerated IRAT_ConfiguredPTCs_Type { EUTRA_Only, EUTRA_UTRAN, EUTRA_GERAN, EUTRA_UTRAN_GERAN, EUTRA_CDMA2000, UTRAN_Only } /* @status APPROVED */ // definitions needed for IP and IMS handling const integer tsc_NoOfPDNs := 2; /* @status APPROVED */ const integer tsc_Index_PDN1 := 0; /* @status APPROVED */ const integer tsc_Index_PDN2 := 1; /* @status APPROVED */ type enumerated PDN_Index_Type { PDN_1 (0), PDN_2 (1) }; //---------------------------------------------------------------------------- // constant to generate PRBS sequence const octetstring tsc_RandomPRBS := /* @status APPROVED */ 'FFE665A5C5CA3452085408ABEECE4B0B813FD337873F2CD1E29AE91BD6C8E14F'O & 'DE630F8195688EBE465F09816A8EEB1B83953DD362DAE3B06D5B76D8E3E53087'O & 'EA645A09017FD99C3CACBB46DF1CD61DA9C435F89943DF9CC34ADEE31AD6E24F'O & 'A1903D53778D949742750DD49DE9CE9E430AD448A14575D89C16025508814020'O //octets 0 .. 127 & '0555DDC9CBCB9EC31F833F866A5BA390680EAB11282EAE44F5E7658F6B247A0C'O & '54A21057F73278595C235077F267A59097E8CEB4EDE49A16FDB36D2485EA3107'O & 'D59DC360700D5488BEB9B96C24AF44DF498BC135788C14A8BBEC64A5EF64DA1C'O & '5608FEB312D7B738D3E2CFB4C74A7458A3EF9B3C79F3CD348740DFE330780C01'O //octets 128 .. 255 & 'FFCCCB4B8B9468A410A81157DD9C9617027FA66F0E7E59A3C535D237AD91C29F'O & 'BCC61F032AD11D7C8CBE1302D51DD637072A7BA6C5B5C760DAB6EDB1C7CA610F'O & 'D4C8B41202FFB3387959768DBE39AC3B53886BF13287BF398695BDC635ADC49F'O & '43207AA6EF1B292E84EA1BA93BD39D3C8615A891428AEBB1382C04AA11028040'O //octets 256 .. 383 & '0AABBB9397973D863F067F0CD4B74720D01D5622505D5C89EBCECB1ED648F418'O & 'A94420AFEE64F0B2B846A0EFE4CF4B212FD19D69DBC9342DFB66DA490BD4620F'O & 'AB3B86C0E01AA9117D7372D8495E89BE9317826AF118295177D8C94BDEC9B438'O & 'AC11FD6625AF6E71A7C59F698E94E8B147DF3678F3E79A690E81BFC660F01803'O //octets 384 .. 511 & 'FF9996971728D148215022AFBB392C2E04FF4CDE1CFCB3478A6BA46F5B23853F'O & '798C3E0655A23AF9197C2605AA3BAC6E0E54F74D8B6B8EC1B56DDB638F94C21F'O & 'A991682405FF6670F2B2ED1B7C735876A710D7E2650F7E730D2B7B8C6B5B893E'O & '8640F54DDE36525D09D4375277A73A790C2B51228515D7627058095422050080'O //octets 512 .. 639 & '155777272F2E7B0C7E0CFE19A96E8E41A03AAC44A0BAB913D79D963DAC91E831'O & '5288415FDCC9E165708D41DFC99E96425FA33AD3B792685BF6CDB49217A8C41F'O & '56770D81C0355222FAE6E5B092BD137D262F04D5E23052A2EFB19297BD936871'O & '5823FACC4B5EDCE34F8B3ED31D29D1628FBE6CF1E7CF34D21D037F8CC1E03007'O //octets 640 .. 767 & 'FF332D2E2E51A29042A0455F7672585C09FE99BC39F9668F14D748DEB6470A7E'O & 'F3187C0CAB4475F232F84C0B547758DC1CA9EE9B16D71D836ADBB6C71F29843F'O & '5322D0480BFECCE1E565DA36F8E6B0ED4E21AFC4CA1EFCE61A56F718D6B7127D'O & '0C81EA9BBC6CA4BA13A86EA4EF4E74F21856A2450A2BAEC4E0B012A8440A0100'O //octets 768 .. 895 & '2AAEEE4E5E5CF618FC19FC3352DD1C834075588941757227AF3B2C7B5923D062'O & 'A51082BFB993C2CAE11A83BF933D2C84BF4675A76F24D0B7ED9B69242F51883E'O & 'ACEE1B03806AA445F5CDCB61257A26FA4C5E09ABC460A545DF63252F7B26D0E2'O & 'B047F59896BDB9C69F167DA63A53A2C51F7CD9E3CF9E69A43A06FF1983C0600F'O //octets 896 .. 1023 & 'FE665A5C5CA3452085408ABEECE4B0B813FD337873F2CD1E29AE91BD6C8E14FD'O & 'E630F8195688EBE465F09816A8EEB1B83953DD362DAE3B06D5B76D8E3E53087E'O & 'A645A09017FD99C3CACBB46DF1CD61DA9C435F89943DF9CC34ADEE31AD6E24FA'O & '1903D53778D949742750DD49DE9CE9E430AD448A14575D89C160255088140200'O //octets 1024 .. 1151 & '555DDC9CBCB9EC31F833F866A5BA390680EAB11282EAE44F5E7658F6B247A0C5'O & '4A21057F73278595C235077F267A59097E8CEB4EDE49A16FDB36D2485EA3107D'O & '59DC360700D5488BEB9B96C24AF44DF498BC135788C14A8BBEC64A5EF64DA1C5'O & '608FEB312D7B738D3E2CFB4C74A7458A3EF9B3C79F3CD348740DFE330780C01F'O //octets 1152 .. 1279 & 'FCCCB4B8B9468A410A81157DD9C9617027FA66F0E7E59A3C535D237AD91C29FB'O & 'CC61F032AD11D7C8CBE1302D51DD637072A7BA6C5B5C760DAB6EDB1C7CA610FD'O & '4C8B41202FFB3387959768DBE39AC3B53886BF13287BF398695BDC635ADC49F4'O & '3207AA6EF1B292E84EA1BA93BD39D3C8615A891428AEBB1382C04AA110280400'O //octets 1280 .. 1407 & 'AABBB9397973D863F067F0CD4B74720D01D5622505D5C89EBCECB1ED648F418A'O & '94420AFEE64F0B2B846A0EFE4CF4B212FD19D69DBC9342DFB66DA490BD4620FA'O & 'B3B86C0E01AA9117D7372D8495E89BE9317826AF118295177D8C94BDEC9B438A'O & 'C11FD6625AF6E71A7C59F698E94E8B147DF3678F3E79A690E81BFC660F01803F'O //octets 1408 .. 1535 & 'F9996971728D148215022AFBB392C2E04FF4CDE1CFCB3478A6BA46F5B23853F7'O & '98C3E0655A23AF9197C2605AA3BAC6E0E54F74D8B6B8EC1B56DDB638F94C21FA'O & '991682405FF6670F2B2ED1B7C735876A710D7E2650F7E730D2B7B8C6B5B893E8'O & '640F54DDE36525D09D4375277A73A790C2B51228515D76270580954220500801'O //octets 1536 .. 1663 & '55777272F2E7B0C7E0CFE19A96E8E41A03AAC44A0BAB913D79D963DAC91E8315'O & '288415FDCC9E165708D41DFC99E96425FA33AD3B792685BF6CDB49217A8C41F5'O & '6770D81C0355222FAE6E5B092BD137D262F04D5E23052A2EFB19297BD9368715'O & '823FACC4B5EDCE34F8B3ED31D29D1628FBE6CF1E7CF34D21D037F8CC1E03007F'O //octets 1664 .. 1791 & 'F332D2E2E51A29042A0455F7672585C09FE99BC39F9668F14D748DEB6470A7EF'O & '3187C0CAB4475F232F84C0B547758DC1CA9EE9B16D71D836ADBB6C71F29843F5'O & '322D0480BFECCE1E565DA36F8E6B0ED4E21AFC4CA1EFCE61A56F718D6B7127D0'O & 'C81EA9BBC6CA4BA13A86EA4EF4E74F21856A2450A2BAEC4E0B012A8440A01002'O //octets 1792 .. 1919 & 'AAEEE4E5E5CF618FC19FC3352DD1C834075588941757227AF3B2C7B5923D062A'O & '51082BFB993C2CAE11A83BF933D2C84BF4675A76F24D0B7ED9B69242F51883EA'O & 'CEE1B03806AA445F5CDCB61257A26FA4C5E09ABC460A545DF63252F7B26D0E2B'O & '047F59896BDB9C69F167DA63A53A2C51F7CD9E3CF9E69A43A06FF1983C0600'O; //octets 1920 .. 2046 //---------------------------------------------------------------------------- // common functions: type integer LineNo_Type; /* * @desc local function * @param p_FileName * @param p_LineNo * @param p_Msg * @return charstring * @status APPROVED */ function fl_FormatLog(charstring p_FileName, LineNo_Type p_LineNo, charstring p_Msg) return charstring { var charstring v_LineNoStr := int2str(p_LineNo); return p_FileName & ":" & v_LineNoStr & ": " & p_Msg; /* common "UNIX style" format as e.g. used by grep; * the final format for this output is FFS */ } //---------------------------------------------------------------------------- /* * @desc function for common error logging * @param p_FileName * @param p_LineNo * @param p_Msg * @status APPROVED */ function f_ErrorLog(charstring p_FileName, LineNo_Type p_LineNo, charstring p_Msg) { log(fl_FormatLog(p_FileName, p_LineNo, p_Msg)); }; //---------------------------------------------------------------------------- /* * @desc common function for verdict assignment * @param p_Verdict * @param p_FileName * @param p_LineNo * @param p_Msg * @status APPROVED */ function f_SetVerdict(verdicttype p_Verdict, charstring p_FileName, LineNo_Type p_LineNo, charstring p_Msg) { var charstring v_OutputLine := fl_FormatLog(p_FileName, p_LineNo, p_Msg); setverdict(p_Verdict, v_OutputLine); } //---------------------------------------------------------------------------- /* * @desc Common functions to be called in case unrecoverable errors * (i.e. runtimer errors generated by TTCN) * @param p_FileName * @param p_LineNo * @param p_Msg * @status APPROVED */ function FatalError(charstring p_FileName, LineNo_Type p_LineNo, charstring p_Msg) { // setverdict(inconc); // setverdict causes problems when FatalError is used in a function called from within a template f_ErrorLog(p_FileName, p_LineNo, p_Msg); testcase.stop (p_Msg); // This operation now defined in TTCN3 v4.2.1 }; //---------------------------------------------------------------------------- /* * @desc Common function to delay the test case for the given time * @param p_DelayTime * @status APPROVED */ function f_Delay ( float p_DelayTime ) { timer t_Delay; t_Delay.start ( p_DelayTime ); t_Delay.timeout; }; //---------------------------------------------------------------------------- function f_TemplateBit2Int(template (present) integer p_Val, integer p_Length) return template bitstring { /* Auxiliary function * note: there is no possibility in TTCN-3 to check whether a template parameter * which is not a value is "*", "?" or omit * => we restrict p_Val to "template (present)", i.e it shall be a value or "?" */ if (isvalue(p_Val)) { return int2bit(valueof(p_Val), p_Length); } else { return ?; } } //---------------------------------------------------------------------------- /* * @desc returns index of first occurency of any char of p_CharList in p_String starting from p_StartIndex; * returns -1 if there is no occurency * @param p_String * @param p_CharList * @param p_StartIndex * @return integer * @status APPROVED */ function f_StringFindChar(charstring p_String, Char1List_Type p_CharList, UInt_Type p_StartIndex) return integer { var integer v_NoOfChars := lengthof(p_CharList); var integer v_Index; var integer i; var Char1_Type v_Char; if (v_NoOfChars == 0) { return -1; } for (v_Index:=p_StartIndex; v_Index 0) // if not already byte aligned { v_PaddingLength := 8 - (v_BitLength mod 8); for (i:=0; i < v_PaddingLength; i := i+1) { v_Bitstring := v_Bitstring & '0'B; } } return v_Bitstring; } //---------------------------------------------------------------------------- /* * @desc function to extract output string from random test pattern of a certain length and at a starting point * @param p_Start * @param p_N * @return octetstring * @status APPROVED */ function f_GetN_OctetsFromPRBS(UInt_Type p_Start, UInt_Type p_N) return octetstring { var integer i; var integer k; var octetstring v_Noctets :=''O; // output string to be extracted from random test pattern for (i:= 0; i< p_N; i := i+1) { k := p_Start + i; k := k mod 2047; v_Noctets := v_Noctets & tsc_RandomPRBS[k]; } return v_Noctets; } //---------------------------------------------------------------------------- /* * @desc check whether given testase name fits L2 test case * @return boolean * @status APPROVED */ function f_TestcaseIsL2Testcase() return boolean { var charstring v_TestcaseName := testcasename(); // This operation now defined in TTCN3 v4.2.1 var template charstring v_L2TestcasePattern := pattern "TC_7_*"; /* @sic R5s100136 sic@ */ return (match(v_TestcaseName, v_L2TestcasePattern)); } //---------------------------------------------------------------------------- function f_TestcaseIsDrbTestcase() return boolean { var charstring v_TestcaseName := testcasename(); // This operation now defined in TTCN3 v4.2.1 var template charstring v_L2TestcasePattern := pattern "TC_12_*"; return (match(v_TestcaseName, v_L2TestcasePattern)); } //---------------------------------------------------------------------------- type enumerated Gsm7BitPacking_Type { SMS_Packing, CBS_Packing, USSD_Packing }; /* * @desc Packing of a 7 bit ASCII string to an 8 bit octet string (TS 23.038 cl. 6.1.2): * SMS Packing (TS 23.038 cl. 6.1.2.1) * CBS Packing (TS 23.038 cl. 6.1.2.2) * USSD Packing (TS 23.038 cl. 6.1.2.3) * @param p_Text * @param p_Packing * @return octetstring * @status APPROVED */ function f_CharPacking_IA5toGsm7Bit(charstring p_Text, Gsm7BitPacking_Type p_Packing) return octetstring { var octetstring v_OctetString := char2oct(p_Text); // "Hallo" -> '48616C6C6F'O var bitstring v_BitString := ''B; var bitstring v_Padding := ''B; var integer v_TextLength := lengthof(p_Text); var integer v_BitStringLength := 0; var integer v_IntValue; var integer v_NoOfOctets; var integer v_NoOfPaddingBits; var integer v_Index; var integer i; if (((p_Packing == SMS_Packing) and (v_TextLength > 160)) or // a maximum of 160 characters for SMS (i.e. 140 octets) ((p_Packing == CBS_Packing) and (v_TextLength > 93)) or // a maximum of 93 characters for CBS (i.e. 82 octets) ((p_Packing == USSD_Packing) and (v_TextLength > 182))) { // a maximum of 182 characters for USSD (i.e. 160 octets) FatalError(__FILE__, __LINE__, "input string is too long"); } for (i:=0; i 0) { if ((p_Packing == USSD_Packing) and (v_NoOfPaddingBits == 7)) { v_Padding := '0001101'B; // use instead of the @ character; see TS 23.038 cl. 6.1.2.3.1 } else { v_Padding := int2bit(0, v_NoOfPaddingBits); // 1..7 padding bits, all 0 } } v_BitString := v_Padding & v_BitString; // convert bitstring back to octetstring: the first character is at the end of the bitstring // => we need to take the octets from the end of the bitstring v_OctetString := ''O; for (i:=0; i < v_NoOfOctets; i:=i+1) { v_Index := (v_NoOfOctets - (i+1)) * 8; // get start index of the next octet v_OctetString[i] := bit2oct(substr(v_BitString, v_Index, 8)); } return v_OctetString; } function f_CharPacking_IA5toBCD(charstring p_ASCII_String) return octetstring { /* Packed BCD coding with "swaping of nibbles" as reuired e.g. for encoding of called and calling party numbers in NAS messages (e.g. TS 24.004 cl. 10.5.4.7 and 10.5.4.9); when the length of the input string is odd 'F' is aded as padding: "0613454120" -> '6031541402'O - even number of digits "06134541209" -> '6031541402F9'O - odd number of digits (padding) "A6134541209" -> error */ var integer i; var charstring v_BcdString; var integer v_Length := lengthof(p_ASCII_String); var charstring v_ASCII_String := p_ASCII_String; // check input string for (i := 0; i < v_Length; i := i+1) { if (not match(p_ASCII_String[i], pattern "[0-9]")) { FatalError(__FILE__, __LINE__, "invalid character for BCD string"); } } // add padding (if needed) if (v_Length mod 2 != 0) { v_ASCII_String := v_ASCII_String & "F"; } // swap digits for (i := 0; i < v_Length; i := i+2) { v_BcdString[i] := v_ASCII_String[i+1]; v_BcdString[i+1] := v_ASCII_String[i]; } return str2oct(v_BcdString); } //---------------------------------------------------------------------------- function f_BitstringReplaceMSB(bitstring p_Bitstring, B1_Type p_NewMSB) return bitstring { return replace(p_Bitstring, 0, 1, p_NewMSB); } //---------------------------------------------------------------------------- function f_Bitstring_BitIsSet(bitstring p_Bitstring, integer p_Index) return boolean { if (p_Index >= lengthof(p_Bitstring)) { FatalError(__FILE__, __LINE__, "invalid bit position"); } return (substr(p_Bitstring, p_Index, 1) == '1'B); } }