| /////////////////////////////////////////////////////////////////////////////// |
| // Copyright (c) 2000-2018 Ericsson Telecom AB |
| // All rights reserved. This program and the accompanying materials |
| // are made available under the terms of the Eclipse Public License v2.0 |
| // which accompanies this distribution, and is available at |
| // https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html |
| /////////////////////////////////////////////////////////////////////////////// |
| // |
| // File: SCTP_Daemon_Dynamic_Interface_Definitions.ttcn |
| // Description: SDD <-> Testcase interface data and port types |
| // Rev: <RnXnn> |
| // Prodnr: CNL 113 630 |
| // Updated: 2012-01-20 |
| // Contact: http://ttcn.ericsson.se |
| |
| |
| module SCTP_Daemon_Dynamic_Interface_Definitions |
| { |
| |
| //========================================================================= |
| // Import Part |
| //========================================================================= |
| |
| import from IPL4asp_Types all; |
| import from IPL4asp_PortType all; |
| |
| //========================================================================= |
| // Data Types |
| //========================================================================= |
| |
| type record SDD_Message_with_ClientId { |
| integer client_id optional, |
| SDD_Message msg |
| } |
| |
| type union SDD_Message { |
| |
| // Both-way traffic |
| SDD_SCTPData sctpData, // send SCTP data |
| |
| // Requests |
| SDD_QueryAssociations queryAssociations, // query the state of the active associations |
| SDD_Listen sctpListen, // define a new server association |
| SDD_Connect sctpConnect, // define a new client association |
| SDD_Close sctpClose, // close an association |
| SDD_SubscribeToAssociation subscribeToAssociation, // subscribe to an association's events |
| |
| // Indications |
| SDD_Result sctpResult, // result comes in response to defineServerAssociation and defineClientAssociation |
| // and contains the new associationId |
| |
| SDD_Associations associations, // response to queryAssociations |
| SDD_AssociationChanged associationChanged, // indicates the change of the state of an association |
| SDD_Connected sctpConnected // indicates that a client has been connected to one of our SCTP server |
| |
| } with { |
| variant "TAG( |
| sctpData, messageType = 0; |
| queryAssociations, messageType = 1; |
| sctpListen, messageType = 2; |
| sctpConnect, messageType = 3; |
| sctpClose, messageType = 4; |
| subscribeToAssociation, messageType = 5; |
| |
| sctpResult, messageType = 100; |
| associations, messageType = 101; |
| associationChanged, messageType = 102; |
| sctpConnected, messageType = 103)" |
| |
| } |
| |
| group MainMessageTypes { |
| |
| type record SDD_SCTPData { |
| integer messageType, |
| integer associationId, |
| integer sinfo_stream, |
| integer sinfo_ppid, |
| integer dataLength (0..65526), |
| octetstring data |
| } with { |
| variant (associationId) "FIELDLENGTH(32), COMP(signbit)" |
| variant (dataLength) "FIELDLENGTH(16)" |
| variant (sinfo_stream, sinfo_ppid) "FIELDLENGTH(32)" |
| variant (dataLength) "LENGTHTO(data)"; |
| } |
| |
| type record SDD_QueryAssociations { |
| integer messageType |
| } |
| |
| type record SDD_Listen { |
| integer messageType, |
| SDD_Interface localInterface |
| } |
| |
| type record SDD_Connect { |
| integer messageType, |
| boolean autoReconnect, |
| boolean localInterfacePresent, |
| SDD_Interface localInterface optional, |
| SDD_Interface remoteInterface |
| } with { |
| variant (autoReconnect, localInterfacePresent) "FIELDLENGTH(8)" |
| variant (localInterface) "PRESENCE (localInterfacePresent=true)" |
| } |
| |
| type record SDD_Close { |
| integer messageType, |
| integer associationId |
| } with { |
| variant (associationId) "FIELDLENGTH(32), COMP(signbit)" |
| } |
| |
| type record SDD_SubscribeToAssociation { |
| integer messageType, |
| integer associationId |
| } with { |
| variant (associationId) "FIELDLENGTH(32), COMP(signbit)" |
| } |
| |
| type record SDD_Result { |
| integer messageType, |
| integer associationId, |
| boolean errorStatus, |
| charstring errorMessage optional |
| } with { |
| variant (associationId) "FIELDLENGTH(32), COMP(signbit)" |
| variant (errorStatus) "FIELDLENGTH(8)" |
| variant (errorMessage) "PRESENCE (errorStatus=true)" |
| } |
| |
| type record SDD_Associations { |
| integer messageType, |
| SDD_AssociationList associationList |
| } |
| |
| type record SDD_AssociationChanged { |
| integer messageType, |
| integer associationId, |
| SAC_STATE state |
| } with { |
| variant (associationId) "FIELDLENGTH(32), COMP(signbit)" |
| variant (state) "FIELDLENGTH(8)" |
| } |
| |
| type record SDD_Connected { |
| integer messageType, |
| integer associationId, |
| SDD_Interface remoteInterface |
| } with { |
| variant (associationId) "FIELDLENGTH(32), COMP(signbit)"; |
| } |
| |
| } |
| |
| group SubTypes { |
| |
| type record SDD_Interface { |
| integer hostNameLength, |
| charstring hostName, |
| integer portNumber (1..65535) optional |
| } with { |
| variant (hostNameLength) "LENGTHTO(hostName)"; |
| variant (portNumber) "FIELDLENGTH(16)"; |
| } |
| |
| type record of SDD_Interface SDD_InterfaceList; |
| |
| type record SDD_Association { |
| integer associationId, |
| boolean serverAssociation, // true := server, false: client |
| boolean autoReconnect, |
| boolean localInterfacePresent, |
| SDD_Interface localInterface optional, |
| boolean remoteInterfacePresent, |
| SDD_Interface remoteInterface optional |
| } with { |
| variant (associationId) "FIELDLENGTH(32), COMP(signbit)"; |
| variant (localInterface) "PRESENCE (localInterfacePresent=true)" |
| variant (remoteInterface) "PRESENCE (remoteInterfacePresent=true)" |
| variant (serverAssociation, autoReconnect, localInterfacePresent, remoteInterfacePresent) "FIELDLENGTH(8)"; // take a byte to make debugging a little easier |
| } |
| |
| type record of SDD_Association SDD_AssociationList; |
| |
| type record SDD_AssociationConfig { |
| boolean serverAssociation, // true := server, false: client |
| boolean autoReconnect, |
| SDD_Interface localInterface optional, |
| SDD_Interface remoteInterface optional |
| } |
| } |
| |
| //========================================================================= |
| //Port Types |
| //========================================================================= |
| |
| type port SDD_Interface_PT message { |
| in ASP_Event; |
| inout SDD_Message_with_ClientId |
| } with { extension "user IPL4asp_PT |
| in( ASP_Event -> ASP_Event: simple; |
| ASP_RecvFrom -> SDD_Message_with_ClientId: function(f_dec_SDD_Message)) |
| out(SDD_Message_with_ClientId -> ASP_Send: function(f_enc_SDD_Message))" |
| } |
| |
| //========================================================================= |
| // Constants |
| //========================================================================= |
| |
| // none yet |
| |
| //========================================================================= |
| // Encoder and Decoder Functions |
| //========================================================================= |
| function f_SDD_getMsgLen(in octetstring stream, inout ro_integer args) return integer { |
| var integer stream_length := lengthof(stream); |
| var integer pdu_length; |
| if (stream_length >=4) { |
| pdu_length:=oct2int(substr(stream,2,2)); |
| if (stream_length >= pdu_length){ |
| return pdu_length; |
| } |
| else{return 0;} |
| } |
| else{return 0;} |
| } |
| |
| function f_dec_SDD_Message(in ASP_RecvFrom aspTCP, out SDD_Message_with_ClientId daemonMsg) return integer { |
| daemonMsg.client_id := aspTCP.connId; |
| daemonMsg.msg := dec_SDD_Message(substr(aspTCP.msg, 4, lengthof(aspTCP.msg)-4)); |
| return 0; |
| } with { extension "prototype(backtrack)" } |
| |
| function f_enc_SDD_Message(in SDD_Message_with_ClientId sctpMsg, out ASP_Send aspTCP) return integer { |
| aspTCP.connId := sctpMsg.client_id; |
| var octetstring vl_encoded := enc_SDD_Message(sctpMsg.msg); |
| // assemble TPKT here; TPKT: |
| // 1st octet: version |
| // 2nd octet: '00'O |
| // 3rd-4th octet: message length; used to separate the messages travelling on TCP |
| aspTCP.msg := '0300'O & int2oct((lengthof(vl_encoded) + 4), 2) & vl_encoded; |
| aspTCP.proto := {tcp:={}}; |
| return 0; |
| } with { extension "prototype(backtrack)" } |
| |
| // created automatically by compiler's RAW Encoder/Decoder code generator |
| external function enc_SDD_Message(in SDD_Message pdu) return octetstring |
| with { extension "prototype(convert) encode(RAW)" } |
| |
| // created automatically by compiler's RAW Encoder/Decoder code generator |
| external function dec_SDD_Message(in octetstring stream) return SDD_Message |
| with { extension "prototype(convert) decode(RAW)" } |
| |
| } with {encode "RAW"} // end of module |