blob: ea1d2a75b22653660fc2e4359f5cc75a6936114f [file] [log] [blame]
///////////////////////////////////////////////////////////////////////////////
// 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: IPDD <-> Testcase interface data and port types
// Rev: <RnXnn>
// Prodnr: CNL 113 630
// Updated: 2012-11-10
// Contact: http://ttcn.ericsson.se
module IP_Daemon_Dynamic_Interface_Definitions
{
//=========================================================================
// Import Part
//=========================================================================
import from IPL4asp_Types all;
import from IPL4asp_PortType all;
//=========================================================================
// Data Types
//=========================================================================
type record IPDD_Message_with_ClientId {
integer client_id optional,
IPDD_Message msg
}
type union IPDD_Message {
// Both-way traffic
IPDD_Data ipdd_data, // send data
// Requests
IPDD_QueryConnections ipdd_queryConnections, // query the state of the active connections
IPDD_Listen ipdd_listen, // define a new server connection
IPDD_Connect ipdd_connect, // define a new client connection
IPDD_Close ipdd_close, // close a connection
IPDD_SubscribeToConnection ipdd_subscribeToConnection, // subscribe to an connection's events
// Indications
IPDD_Result ipdd_result, // result comes in response to Listen and Connect, and contains the new connectionId
IPDD_Connections ipdd_connections, // response to queryConnections
IPDD_ConnectionChanged ipdd_connectionChanged, // indicates the change of the state of a connection
IPDD_Connected ipdd_connected, // indicates that a client has been connected to one of our IP server
IPDD_Closed ipdd_closed // indicates that a connection has been closed
} with {
variant "TAG(
ipdd_data, messageType = 0;
ipdd_queryConnections, messageType = 1;
ipdd_listen, messageType = 2;
ipdd_connect, messageType = 3;
ipdd_close, messageType = 4;
ipdd_subscribeToConnection, messageType = 5;
ipdd_result, messageType = 100;
ipdd_connections, messageType = 101;
ipdd_connectionChanged, messageType = 102;
ipdd_connected, messageType = 103;
ipdd_closed, messageType = 104)"
}
group MainMessageTypes {
type record IPDD_Data {
integer messageType,
IPDD_INT32 connectionId,
boolean sctpAttributesPresent,
IPDD_SctpAttributes sctpAttributes optional,
integer dataLength (0..65526),
octetstring data
} with {
variant (sctpAttributesPresent) "FIELDLENGTH(8)"
variant (sctpAttributes) "PRESENCE (sctpAttributesPresent=true)"
variant (dataLength) "FIELDLENGTH(16)"
variant (dataLength) "LENGTHTO(data)"
}
type record IPDD_QueryConnections {
integer messageType
}
type record IPDD_Listen {
integer messageType,
IPDD_Interface localInterface,
ProtoTupleEnum proto,
boolean sctpProtoAttributesPresent,
IPDD_SctpProtoAttributes sctpProtoAttributes optional
} with {
variant (sctpProtoAttributesPresent) "FIELDLENGTH(8)"
variant (sctpProtoAttributes) "PRESENCE (sctpProtoAttributesPresent=true)"
}
type record IPDD_Connect {
integer messageType,
boolean autoReconnect,
boolean localInterfacePresent,
IPDD_Interface localInterface optional,
IPDD_Interface remoteInterface,
ProtoTupleEnum proto,
boolean sctpProtoAttributesPresent,
IPDD_SctpProtoAttributes sctpProtoAttributes optional
} with {
variant (autoReconnect, localInterfacePresent, sctpProtoAttributesPresent) "FIELDLENGTH(8)"
variant (localInterface) "PRESENCE (localInterfacePresent=true)"
variant (sctpProtoAttributes) "PRESENCE (sctpProtoAttributesPresent=true)"
}
type record IPDD_Close {
integer messageType,
IPDD_INT32 connectionId
}
type record IPDD_SubscribeToConnection {
integer messageType,
IPDD_INT32 connectionId
}
type record IPDD_Result {
integer messageType,
IPDD_INT32 connectionId,
boolean errorStatus,
charstring errorMessage optional
} with {
variant (errorStatus) "FIELDLENGTH(8)"
variant (errorMessage) "PRESENCE (errorStatus=true)"
}
type record IPDD_Connections {
integer messageType,
IPDD_ConnectionList connectionList
}
type record IPDD_ConnectionChanged {
integer messageType,
IPDD_INT32 connectionId,
boolean eventPresent,
IPDD_Event event optional,
boolean sctpStatePresent,
SAC_STATE sctpState optional
} with {
variant (eventPresent, sctpStatePresent, sctpState) "FIELDLENGTH(8)"
variant (event) "PRESENCE (eventPresent=true)"
variant (sctpState) "PRESENCE (sctpStatePresent=true)"
}
type record IPDD_Connected {
integer messageType,
IPDD_INT32 serverId,
IPDD_INT32 connectionId,
IPDD_Interface remoteInterface
}
type record IPDD_Closed {
integer messageType,
IPDD_INT32 connectionId
}
}
group SubTypes {
type integer IPDD_INT32 with {
variant "FIELDLENGTH(32), COMP(signbit)"
}
type integer IPDD_ULONG with {
variant "FIELDLENGTH(32), COMP(nosign)"
}
type record IPDD_SctpAttributes {
IPDD_ULONG sinfo_stream,
IPDD_ULONG sinfo_ppid
}
type enumerated ProtoTupleEnum {
udp,
tcp,
sctp,
ssl,
unspecified
} with {
variant "FIELDLENGTH(8)"
}
type record IPDD_SctpProtoAttributes {
boolean sinfo_streamAttributesPresent,
IPDD_ULONG sinfo_stream optional,
boolean sinfo_ppidPresent,
IPDD_ULONG sinfo_ppid optional,
boolean remSocksPresent,
IPDD_InterfaceList remSocks optional,
boolean assocIdPresent,
IPDD_ULONG assocId optional
} with {
variant (sinfo_streamAttributesPresent, sinfo_ppidPresent, remSocksPresent, assocIdPresent) "FIELDLENGTH(8)"
variant (sinfo_stream) "PRESENCE (sinfo_streamAttributesPresent=true)"
variant (sinfo_ppid) "PRESENCE (sinfo_ppidPresent=true)"
variant (remSocks) "PRESENCE (remSocksPresent=true)"
variant (assocId) "PRESENCE (assocIdPresent=true)"
}
type record IPDD_Event {
boolean errorCodePresent,
PortError errorCode optional,
boolean os_error_codePresent,
integer os_error_code optional,
integer os_error_textLength,
charstring os_error_text optional
} with {
variant (errorCodePresent, os_error_codePresent, os_error_textLength) "FIELDLENGTH(8)"
variant (errorCode) "PRESENCE (errorCodePresent=true)"
variant (os_error_code) "PRESENCE (os_error_codePresent=true)"
variant (os_error_textLength) "LENGTHTO (os_error_text)"
}
type record IPDD_Interface {
integer hostNameLength,
charstring hostName,
integer portNumber (0..65535) optional
} with {
variant (hostNameLength) "LENGTHTO(hostName)";
variant (portNumber) "FIELDLENGTH(16)";
}
type record of IPDD_Interface IPDD_InterfaceList;
type record IPDD_Connection {
IPDD_INT32 connectionId,
boolean serverConnection, // true := server, false: client
boolean autoReconnect,
boolean localInterfacePresent,
IPDD_Interface localInterface optional,
boolean remoteInterfacePresent,
IPDD_Interface remoteInterface optional,
ProtoTupleEnum proto,
boolean sctpProtoAttributesPresent,
IPDD_SctpProtoAttributes sctpProtoAttributes optional
} with {
variant (localInterface) "PRESENCE (localInterfacePresent=true)"
variant (remoteInterface) "PRESENCE (remoteInterfacePresent=true)"
variant (sctpProtoAttributes) "PRESENCE (sctpProtoAttributesPresent=true)"
variant (serverConnection, autoReconnect, localInterfacePresent, remoteInterfacePresent, sctpProtoAttributesPresent) "FIELDLENGTH(8)"; // take a byte to make debugging a little easier
}
type record of IPDD_Connection IPDD_ConnectionList;
type record IPDD_ConnectionConfig {
boolean serverConnection, // true := server, false: client
boolean autoReconnect,
IPDD_Interface localInterface optional,
IPDD_Interface remoteInterface optional
}
}
//=========================================================================
//Port Types
//=========================================================================
type port IPDD_Interface_PT message {
in ASP_Event;
inout IPDD_Message_with_ClientId
} with { extension "user IPL4asp_PT
in( ASP_Event -> ASP_Event: simple;
ASP_RecvFrom -> IPDD_Message_with_ClientId: function(f_dec_IPDD_Message))
out(IPDD_Message_with_ClientId -> ASP_Send: function(f_enc_IPDD_Message))"
}
//=========================================================================
// Encoder and Decoder Functions
//=========================================================================
function f_IPDD_getMsgLen(in octetstring stream, inout ro_integer args) return integer {
var integer stream_length := lengthof(stream);
if (stream_length >=4) {
return oct2int(substr(stream,2,2));
}
return -1;
}
function f_dec_IPDD_Message(in ASP_RecvFrom aspTCP, out IPDD_Message_with_ClientId daemonMsg) return integer {
daemonMsg.client_id := aspTCP.connId;
daemonMsg.msg := dec_IPDD_Message(substr(aspTCP.msg, 4, lengthof(aspTCP.msg)-4));
return 0;
} with { extension "prototype(backtrack)" }
function f_enc_IPDD_Message(in IPDD_Message_with_ClientId sctpMsg, out ASP_Send aspTCP) return integer {
aspTCP.connId := sctpMsg.client_id;
var octetstring vl_encoded := enc_IPDD_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_IPDD_Message(in IPDD_Message pdu) return octetstring
with { extension "prototype(convert) encode(RAW)" }
// created automatically by compiler's RAW Encoder/Decoder code generator
external function dec_IPDD_Message(in octetstring stream) return IPDD_Message
with { extension "prototype(convert) decode(RAW)" }
} with {encode "RAW"} // end of module