Commit dd0a47bd authored by Elemer Lelik's avatar Elemer Lelik
Browse files

Initial contribution

parent 16de06b9
# titan.TestPorts.SUNRPCasp
Main project page:
https://projects.eclipse.org/projects/tools.titan
The source code of the TTCN-3 compiler and executor:
https://github.com/eclipse/titan.core
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2015 Ericsson
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
File: SUNRPCasp_CNL113493.tpd
Description: tpd project file
Rev: R5A
Prodnr: CNL 113 493
-->
<TITAN_Project_File_Information version="1.0">
<ProjectName>SUNRPCasp_CNL113493</ProjectName>
<ReferencedProjects>
<ReferencedProject name="Abstract_Socket_CNL113384" projectLocationURI="../Common_Components/Abstract_Socket_CNL113384/Abstract_Socket_CNL113384.tpd"/>
</ReferencedProjects>
<Files>
<FileResource projectRelativePath="SunRPCasp_PT.cc" relativeURI="src/SunRPCasp_PT.cc"/>
<FileResource projectRelativePath="SunRPCasp_PT.hh" relativeURI="src/SunRPCasp_PT.hh"/>
<FileResource projectRelativePath="SunRPCasp_PortType.ttcn" relativeURI="src/SunRPCasp_PortType.ttcn"/>
<FileResource projectRelativePath="SunRPCasp_Types.ttcn" relativeURI="src/SunRPCasp_Types.ttcn"/>
</Files>
<ActiveConfiguration>Default</ActiveConfiguration>
<Configurations>
<Configuration name="Default">
<ProjectProperties>
<MakefileSettings>
<generateInternalMakefile>true</generateInternalMakefile>
<GNUMake>true</GNUMake>
<incrementalDependencyRefresh>true</incrementalDependencyRefresh>
<targetExecutable>bin/SUNRPCasp_CNL113493</targetExecutable>
<buildLevel>Level 3 - Creating object files with dependency update</buildLevel>
</MakefileSettings>
<LocalBuildSettings>
<workingDirectory>bin</workingDirectory>
</LocalBuildSettings>
</ProjectProperties>
</Configuration>
</Configurations>
</TITAN_Project_File_Information>
[MAIN_CONTROLLER]
KillTimer := 1
TCPPort := 3333
[EXECUTE]
SunRPC_Demo.tc_both_client_server
[TESTPORT_PARAMETERS]
*.rpc_client_port.socket_debugging := "yes"
*.tcp_client_port.socket_debugging := "yes"
*.tcp_client_port.use_connection_ASPs := "yes"
*.rpc_server_port.socket_debugging := "yes"
[LOGGING]
FileMask := LOG_ALL | TTCN_DEBUG
ConsoleMask := TTCN_ERROR | TTCN_WARNING | TTCN_PORTEVENT | TTCN_TIMEROP | TTCN_VERDICTOP | TTCN_ACTION | TTCN_TESTCASE | TTCN_FUNCTION | TTCN_USER | TTCN_STATISTICS
SourceInfoFormat := Single
//saved by GUI
<!DOCTYPE TITAN_GUI_project_file>
<Project>
<General>
<Project_Name>SunRPC_Demo</Project_Name>
<Executable_Path>../bin/SunRPC_Demo</Executable_Path>
<Working_Dir>../bin</Working_Dir>
<Build_Host>alpha</Build_Host>
<Execution_Mode>Parallel</Execution_Mode>
<Log_Format>yes</Log_Format>
<Update_Symlinks>yes</Update_Symlinks>
<Create_Absolute_Symlinks>yes</Create_Absolute_Symlinks>
<Update_Makefile>yes</Update_Makefile>
<Localhost_Execute>yes</Localhost_Execute>
<Execute_Command>rsh %host &quot;cd %project_working_dir ; &quot;%executable&quot; %localhost %mctr_port&quot;</Execute_Command>
<Execute_Hosts>alfa, beta, gamma</Execute_Hosts>
<UnUsed_List></UnUsed_List>
</General>
<Modules>
<Module>../src/SunRPCasp_PortType.ttcn</Module>
<Module>../src/SunRPCasp_Types.ttcn</Module>
<Module>SunRPC_Demo.ttcn</Module>
<Module>../../TCPasp_CNL113347/src/TCPasp_PortType.ttcn</Module>
<Module>../../TCPasp_CNL113347/src/TCPasp_Types.ttcn</Module>
</Modules>
<TestPorts>
<TestPort>../src/SunRPCasp_PT.cc</TestPort>
<TestPort>../src/SunRPCasp_PT.hh</TestPort>
<TestPort>../../TCPasp_CNL113347/src/TCPasp_PT.cc</TestPort>
<TestPort>../../TCPasp_CNL113347/src/TCPasp_PT.hh</TestPort>
</TestPorts>
<Other_Sources>
<Other_Source>../../Common_Components/Abstract_Socket_CNL113384/src/Abstract_Socket.cc</Other_Source>
<Other_Source>../../Common_Components/Abstract_Socket_CNL113384/src/Abstract_Socket.hh</Other_Source>
</Other_Sources>
<Configs>
<Config>SunRPC.cfg</Config>
</Configs>
<Test_Cases>
<Test_Case>SunRPC_Demo.tc_both_client_server</Test_Case>
<Test_Case>SunRPC_Demo.tc_TCP_client_RPC_server_RPC_decode_test</Test_Case>
</Test_Cases>
</Project>
/******************************************************************************
* Copyright (c) 2006, 2015 Ericsson AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Eduard Czimbalmos
* Attila Balasko
* Csaba Feher
* Gabor Szalai
* Kulcsr Endre
******************************************************************************/
//
// File: SunRPC_Demo.cc
// Description: SunRPC test port demo
// Rev: R5A
// Prodnr: CNL 113 493
//
module SunRPC_Demo {
import from SunRPCasp_PortType all;
import from SunRPCasp_Types all;
import from TCPasp_Types all;
import from TCPasp_PortType all;
type component RPC_test {
};
type component RPC_client {
port SunRPCasp_PT rpc_client_port;
};
type component TCP_client {
port TCPasp_PT tcp_client_port;
};
type component RPC_server {
port SunRPCasp_PT rpc_server_port;
};
type record of octetstring OCTETSTRINGS;
testcase tc_both_client_server() runs on RPC_test
{
var RPC_client rpc_client_PTC;
var RPC_server rpc_server_PTC;
rpc_client_PTC := RPC_client.create;
rpc_server_PTC := RPC_server.create;
rpc_server_PTC.start(rpc_server());
timer T_wait := 0.2; T_wait.start; T_wait.timeout;
rpc_client_PTC.start(rpc_client());
rpc_client_PTC.done;
rpc_server_PTC.done;
}
testcase tc_TCP_client_RPC_server_RPC_decode_test() runs on RPC_test
{
var TCP_client tcp_client_PTC;
var RPC_server rpc_server_PTC;
tcp_client_PTC := TCP_client.create;
rpc_server_PTC := RPC_server.create;
rpc_server_PTC.start(rpc_server());
timer T_wait := 0.2; T_wait.start; T_wait.timeout;
tcp_client_PTC.start(tcp_client());
tcp_client_PTC.done;
rpc_server_PTC.done;
}
function tcp_client() runs on TCP_client {
var OCTETSTRINGS test_msgs := {
// RPC Call
/*'8000008cdee336f60000000000000002000186a30000000300000010000000010000002c4408159f000000076865696e74656c000000efd9000039d00000000400001a44000039e2000039d00000000a000000000000000000000020400a0001ffffffff000a0000000c391300000003000a00000000960d000000020000000000000000000000000000000000000418'O,
// RPC REPLY
'80000418dee336f60000000100000000000000000000000000000000000000000000000100000002000001ed000000270000efd900001a4400000000000020000000000000002000000000000000000000000000400a000100000000000c39134408159f1b05adc84408159a235d8ef04408159a235d8ef000000000000000000000000100000000000c3913000000012e000000000000000000000100000001000000000000960d000000022e2e000000000000000002040000000100000000000c392e000000062e6c6f67696e000000000000000002140000000100000000000c392f000000026c68000000000000000002200000000100000000000c39300000000a2e494341436c69656e74000000000000000002340000000100000000000c3933000000092e526174696f6e616c00000000000000000002480000000100000000000c3936000000082e6163726f626174000000000000025c0000000100000000000c3938000000062e61646f62650000000000000000026c0000000100000000000c3939000000092e617073746f6f6c7300000000000000000002800000000100000000000c393c000000062e6365646974000000000000000002900000000100000000000c393e000000032e64740000000000000002a00000000100000000000c3968000000032e666d0000000000000002b00000000100000000000c3971000000062e6672616d65000000000000000002c00000000100000000000c3973000000032e68680000000000000002d00000000100000000000c3975000000052e696e736f00000000000000000002e00000000100000000000cf32b000000052e6a61766100000000000000000002f00000000100000000000c397b0000000a2e6a70695f6361636865000000000000000003040000000100000000000c3984000000042e6b646500000000000003140000000100000000000c398c000000032e6d630000000000000003240000000100000000000c398e0000000a2e6d6963726f736f6674000000000000000003380000000100000000000c26ea000000082e6d6f7a696c6c61000000000000034c0000000100000000000ca962000000092e6b6579737461746500000000000000000003600000000100000000000c410a000000082e6e657473686f7700000000000003740000000100000000000c410b000000062e6f70657261000000000000000003840000000100000000000c410f000000032e71740000000000000003940000000100000000000c40f2000000092e736f6c726567697300000000000000000003a80000000100000000000c4111000000042e73736800000000000003b80000000100000000000c4112000000092e776d706c6179657200000000000000000003cc0000000100000000000c4113000000042e79657300000000000003dc0000000000000000'O,
// RPC Call in two fragments, second fragment is emtpy
'0000008cdee336f60000000000000002000186a30000000300000010000000010000002c4408159f000000076865696e74656c000000efd9000039d00000000400001a44000039e2000039d00000000a000000000000000000000020400a0001ffffffff000a0000000c391300000003000a00000000960d00000002000000000000000000000000000000000000041880000000'O,
// RPC Call in two fragments, second fragment is not empty
'0000008adee336f60000000000000002000186a30000000300000010000000010000002c4408159f000000076865696e74656c000000efd9000039d00000000400001a44000039e2000039d00000000a000000000000000000000020400a0001ffffffff000a0000000c391300000003000a00000000960d00000002000000000000000000000000000000000000800000020418'O,
// RPC REPLY, 3 fragments in 3 TCP packet
'00000114dee336f60000000100000000000000000000000000000000000000000000000100000002000001ed000000270000efd900001a4400000000000020000000000000002000000000000000000000000000400a000100000000000c39134408159f1b05adc84408159a235d8ef04408159a235d8ef000000000000000000000000100000000000c3913000000012e000000000000000000000100000001000000000000960d000000022e2e000000000000000002040000000100000000000c392e000000062e6c6f67696e000000000000000002140000000100000000000c392f000000026c68000000000000000002200000000100000000000c39300000000a2e494341436c69656e7400000000000000000234'O,
'0000019b0000000100000000000c3933000000092e526174696f6e616c00000000000000000002480000000100000000000c3936000000082e6163726f626174000000000000025c0000000100000000000c3938000000062e61646f62650000000000000000026c0000000100000000000c3939000000092e617073746f6f6c7300000000000000000002800000000100000000000c393c000000062e6365646974000000000000000002900000000100000000000c393e000000032e64740000000000000002a00000000100000000000c3968000000032e666d0000000000000002b00000000100000000000c3971000000062e6672616d65000000000000000002c00000000100000000000c3973000000032e68680000000000000002d00000000100000000000c3975000000052e696e736f00000000000000000002e00000000100000000000cf32b000000052e6a61766100000000000000000002f00000000100000000000c397b0000000a2e6a70695f6361636865000000000000000003040000000100000000000c3984000000042e6b646500000000000003'O,
'80000169140000000100000000000c398c000000032e6d630000000000000003240000000100000000000c398e0000000a2e6d6963726f736f6674000000000000000003380000000100000000000c26ea000000082e6d6f7a696c6c61000000000000034c0000000100000000000ca962000000092e6b6579737461746500000000000000000003600000000100000000000c410a000000082e6e657473686f7700000000000003740000000100000000000c410b000000062e6f70657261000000000000000003840000000100000000000c410f000000032e71740000000000000003940000000100000000000c40f2000000092e736f6c726567697300000000000000000003a80000000100000000000c4111000000042e73736800000000000003b80000000100000000000c4112000000092e776d706c6179657200000000000000000003cc0000000100000000000c4113000000042e79657300000000000003dc0000000000000000'O,*/
// RPC CALL, 1 fragment in 2 TCP packet
'80000820463ba799000000000000000220000200000000010000000100000000000000000000000000000000000000010000000a76657273696f6e3d323000000000000100000015435553545f54454c5f4e4f3d34353531303230303000000000000001000000146f726967696e5f6e6f64655f747970653d49565200000001000000156f726967696e5f6e6f64655f69643d77733134393400000000000001000000237472616e73616374696f6e5f69643d383030353534393935323737343931313832363400000000010000002f7472616e73616374696f6e5f646174655f74696d653d323030372d30352d30345431333a33353a31302b30323a30300000000001000000176f726967696e5f6f70657261746f725f69643d6e7573610000000001000000106f7065726174696f6e3d555044415445000000010000000a63757272656e63793d31000000000001000000176465646963617465645f6163636f756e745f69643d31300000000001000000166465646963617465645f616d6f756e743d3130323030000000000001000000246465646963617465645f6578706972795f646174655f6f6c643d323030372d30352d303400000001000000246465646963617465645f6578706972795f646174655f6e65773d323030372d30352d323400000001000000166465646963617465645f6163636f756e745f69643d39000000000001000000156465646963617465645f616d6f756e743d3931383000000000000001000000246465646963617465645f6578706972795f646174655f6f6c643d323030372d30352d303400000001000000246465646963617465645f6578706972795f646174655f6e65773d323030372d30352d323200000001000000166465646963617465645f6163636f756e745f69643d38000000000001000000156465646963617465645f616d6f756e743d3831363000000000000001000000246465646963617465645f6578706972795f646174655f6f6c643d323030372d30352d303400000001000000246465646963617465645f6578706972795f646174655f6e65773d323030372d30352d323000000001000000166465646963617465645f6163636f756e745f69643d37000000000001000000156465646963617465645f616d6f756e743d3731343000000000000001000000246465646963617465645f6578706972795f646174655f6f6c643d323030372d30352d303400000001000000246465646963617465645f6578706972795f646174655f6e65773d323030372d30352d313800000001000000166465646963617465645f6163636f756e745f69643d36000000000001000000156465646963617465645f616d6f756e743d3631323000000000000001000000246465646963617465645f6578706972795f646174655f6f6c643d323030372d30352d303400000001000000246465646963617465645f6578706972795f646174655f6e65773d323030372d30352d313600000001000000166465646963617465645f6163636f756e745f69643d35000000000001000000156465646963617465645f616d6f756e743d3531303000000000000001000000246465646963617465645f6578706972795f646174655f6f6c643d323030372d30352d303400000001000000246465646963617465645f6578706972795f646174655f6e65773d323030372d30352d313400000001000000166465646963617465645f6163636f756e745f69643d34000000000001000000156465646963617465645f616d6f756e743d3430383000000000000001000000246465646963617465645f6578706972795f646174655f6f6c643d323030372d30352d303400000001000000246465646963617465645f6578706972795f646174655f6e65773d323030372d30352d313200000001000000166465646963617465645f6163636f756e745f69643d33000000000001000000156465646963617465645f616d6f756e743d33303630000000'O,
'00000001000000246465646963617465645f6578706972795f646174655f6f6c643d323030372d30352d303400000001000000246465646963617465645f6578706972795f646174655f6e65773d323030372d30352d313000000001000000166465646963617465645f6163636f756e745f69643d32000000000001000000156465646963617465645f616d6f756e743d3230343000000000000001000000246465646963617465645f6578706972795f646174655f6f6c643d323030372d30352d303400000001000000246465646963617465645f6578706972795f646174655f6e65773d323030372d30352d303800000001000000166465646963617465645f6163636f756e745f69643d31000000000001000000156465646963617465645f616d6f756e743d3130323000000000000001000000246465646963617465645f6578706972795f646174655f6f6c643d323030372d30352d303400000001000000246465646963617465645f6578706972795f646174655f6e65773d323030372d30352d30360000000100000019616374696f6e5f6465645f6163635f616d6f756e743d4144440000000000000100000013736572766963655f636c6173735f6f6c643d330000000001000000206372656469745f636c656172616e63655f67726163655f706572696f643d3135000000010000001c736572765f72656d6f76616c5f67726163655f706572696f643d3230000000010000001b616374696f6e5f726566696c6c5f62617272696e673d434c454152000000000100000017726566696c6c5f756e6261725f646174655f74696d653d00000000010000000a726561736f6e3d313238000000000000'O
}
map(self:tcp_client_port, system:tpp_client_port);
var ASP_TCP_Connect v_connect := {hostname := "localhost", portnumber := 3344, local_hostname := omit, local_portnumber := omit};
tcp_client_port.send(v_connect);
tcp_client_port.send(v_connect);
template ASP_TCP_Connect_result t_connect_result := {client_id := ?};
var ASP_TCP_Connect_result vl_connect_result;
timer T_guard := 2.0;
T_guard.start;
var integer vl_clients := 0;
alt
{
[] tcp_client_port.receive(t_connect_result) -> value vl_connect_result {
T_guard.stop;
vl_clients := vl_clients + 1;
if(vl_clients < 2)
{
repeat;
}
}
[] T_guard.timeout {
setverdict(fail);
return;
}
}
template ASP_TCP t_ASP_TCP := ?;
var ASP_TCP v_ASP_TCP;
var ASP_TCP v_ASP_TCP_reply;
v_ASP_TCP.client_id := vl_connect_result.client_id;
timer T_wait := 0.2;
var integer i;
for(i := 0; i < sizeof(test_msgs); i := i + 1)
{
T_wait.start; T_wait.timeout;
v_ASP_TCP.data := test_msgs[i];
tcp_client_port.send(v_ASP_TCP);
}
var octetstring received_reply := ''O;
T_guard.start(0.5);
alt {
[] tcp_client_port.receive(t_ASP_TCP) -> value v_ASP_TCP_reply {
received_reply := received_reply & v_ASP_TCP_reply.data;
repeat;
/*else {
log("REPLIED DATA MATCHES THE SENT");
repeat;
}*/
}
[] T_guard.timeout {
}
};
if(received_reply == '8000008CDEE336F60000000000000002000186A30000000300000010000000010000002C4408159F000000076865696E74656C000000EFD9000039D00000000400001A44000039E2000039D00000000A000000000000000000000020400A0001FFFFFFFF000A0000000C391300000003000A00000000960D00000002000000000000000000000000000000000000041880000418DEE336F60000000100000000000000000000000000000000000000000000000100000002000001ED000000270000EFD900001A4400000000000020000000000000002000000000000000000000000000400A000100000000000C39134408159F1B05ADC84408159A235D8EF04408159A235D8EF000000000000000000000000100000000000C3913000000012E000000000000000000000100000001000000000000960D000000022E2E000000000000000002040000000100000000000C392E000000062E6C6F67696E000000000000000002140000000100000000000C392F000000026C68000000000000000002200000000100000000000C39300000000A2E494341436C69656E74000000000000000002340000000100000000000C3933000000092E526174696F6E616C00000000000000000002480000000100000000000C3936000000082E6163726F626174000000000000025C0000000100000000000C3938000000062E61646F62650000000000000000026C0000000100000000000C3939000000092E617073746F6F6C7300000000000000000002800000000100000000000C393C000000062E6365646974000000000000000002900000000100000000000C393E000000032E64740000000000000002A00000000100000000000C3968000000032E666D0000000000000002B00000000100000000000C3971000000062E6672616D65000000000000000002C00000000100000000000C3973000000032E68680000000000000002D00000000100000000000C3975000000052E696E736F00000000000000000002E00000000100000000000CF32B000000052E6A61766100000000000000000002F00000000100000000000C397B0000000A2E6A70695F6361636865000000000000000003040000000100000000000C3984000000042E6B646500000000000003140000000100000000000C398C000000032E6D630000000000000003240000000100000000000C398E0000000A2E6D6963726F736F6674000000000000000003380000000100000000000C26EA000000082E6D6F7A696C6C61000000000000034C0000000100000000000CA962000000092E6B6579737461746500000000000000000003600000000100000000000C410A000000082E6E657473686F7700000000000003740000000100000000000C410B000000062E6F70657261000000000000000003840000000100000000000C410F000000032E71740000000000000003940000000100000000000C40F2000000092E736F6C726567697300000000000000000003A80000000100000000000C4111000000042E73736800000000000003B80000000100000000000C4112000000092E776D706C6179657200000000000000000003CC0000000100000000000C4113000000042E79657300000000000003DC00000000000000008000008CDEE336F60000000000000002000186A30000000300000010000000010000002C4408159F000000076865696E74656C000000EFD9000039D00000000400001A44000039E2000039D00000000A000000000000000000000020400A0001FFFFFFFF000A0000000C391300000003000A00000000960D0000000200000000000000000000000000000000000004188000008CDEE336F60000000000000002000186A30000000300000010000000010000002C4408159F000000076865696E74656C000000EFD9000039D00000000400001A44000039E2000039D00000000A000000000000000000000020400A0001FFFFFFFF000A0000000C391300000003000A00000000960D00000002000000000000000000000000000000000000041880000418DEE336F60000000100000000000000000000000000000000000000000000000100000002000001ED000000270000EFD900001A4400000000000020000000000000002000000000000000000000000000400A000100000000000C39134408159F1B05ADC84408159A235D8EF04408159A235D8EF000000000000000000000000100000000000C3913000000012E000000000000000000000100000001000000000000960D000000022E2E000000000000000002040000000100000000000C392E000000062E6C6F67696E000000000000000002140000000100000000000C392F000000026C68000000000000000002200000000100000000000C39300000000A2E494341436C69656E74000000000000000002340000000100000000000C3933000000092E526174696F6E616C00000000000000000002480000000100000000000C3936000000082E6163726F626174000000000000025C0000000100000000000C3938000000062E61646F62650000000000000000026C0000000100000000000C3939000000092E617073746F6F6C7300000000000000000002800000000100000000000C393C000000062E6365646974000000000000000002900000000100000000000C393E000000032E64740000000000000002A00000000100000000000C3968000000032E666D0000000000000002B00000000100000000000C3971000000062E6672616D65000000000000000002C00000000100000000000C3973000000032E68680000000000000002D00000000100000000000C3975000000052E696E736F00000000000000000002E00000000100000000000CF32B000000052E6A61766100000000000000000002F00000000100000000000C397B0000000A2E6A70695F6361636865000000000000000003040000000100000000000C3984000000042E6B646500000000000003140000000100000000000C398C000000032E6D630000000000000003240000000100000000000C398E0000000A2E6D6963726F736F6674000000000000000003380000000100000000000C26EA000000082E6D6F7A696C6C61000000000000034C0000000100000000000CA962000000092E6B6579737461746500000000000000000003600000000100000000000C410A000000082E6E657473686F7700000000000003740000000100000000000C410B000000062E6F70657261000000000000000003840000000100000000000C410F000000032E71740000000000000003940000000100000000000C40F2000000092E736F6C726567697300000000000000000003A80000000100000000000C4111000000042E73736800000000000003B80000000100000000000C4112000000092E776D706C6179657200000000000000000003CC0000000100000000000C4113000000042E79657300000000000003DC0000000000000000'O)
{
log("Received replies match the expected data.");
setverdict(pass);
}
else
{
log("!!! Received replies does not match the expected data.!!!");
setverdict(fail);
}
unmap(self:tcp_client_port, system:tcp_client_port);
}
function rpc_client() runs on RPC_client {
var SunRPC_message test_msg := {
xid := 'DEE336F6'O,
msg_type := rpc_call,
body := {
cbody := {
rpcvers := 2,
prog := 100003,
vers := 3,
proc := 16,
cred := {
flavor := auth_unix,
body := {
len := 44,
data := '4408159F000000076865696E74656C000000EFD9000039D00000000400001A44000039E2000039D00000000A'O
}
},
verf := {
flavor := auth_null,
body := {
len := 0,
data := ''O
}
},
proc_spec_parameters := '00000020400A0001FFFFFFFF000A0000000C391300000003000A00000000960D000000020000000000000000000000000000000000000418'O
}
}
}
map(self:rpc_client_port, system:rpc_client_port);
var ASP_SunRPC_Connect v_connect := {hostname := "localhost", portnumber := 3344, local_hostname := omit, local_portnumber := omit};
rpc_client_port.send(v_connect);
template ASP_SunRPC_Connect_result t_connect_result := {client_id := ?};
rpc_client_port.receive(t_connect_result);
template SunRPC_message t_SunRPC_message := ?;
var SunRPC_message v_rpc_message;
timer T_guard := 2.0;
T_guard.start;
rpc_client_port.send(test_msg);
var integer i := 0;
alt {
[] rpc_client_port.receive(t_SunRPC_message) -> value v_rpc_message {
rpc_client_port.send(v_rpc_message);
i := i + 1;
if(i < 10) {
repeat;
}
}
[] T_guard.timeout {
setverdict(fail);
}
};
setverdict(pass);
unmap(self:rpc_client_port, system:rpc_client_port);
}
function rpc_server() runs on RPC_server {
map(self:rpc_server_port, system:rpc_server_port);
var ASP_SunRPC_Listen v_listen := {portnumber := 3344, local_hostname := omit};
rpc_server_port.send(v_listen);
template ASP_SunRPC_Listen_result t_listen_result := {portnumber := ?};
rpc_server_port.receive(t_listen_result);
template ASP_SunRPC_Connected t_connected := {hostname := ?, portnumber := ?, client_id := ?};
template ASP_SunRPC_Close t_close := {client_id := ?};
timer T_guard := 2.0;
T_guard.start;
timer T_wait := 0.1;
template SunRPC_message t_SunRPC_message := ?;
template SunRPC_message_multiple_client t_SunRPC_message_multiple_client := ?;
var SunRPC_message v_rpc_message;
var SunRPC_message_multiple_client v_rpc_message_multiple_client;
alt {
[] rpc_server_port.receive(t_SunRPC_message) -> value v_rpc_message {
rpc_server_port.send(v_rpc_message);
repeat;
}
[] rpc_server_port.receive(t_SunRPC_message_multiple_client) -> value v_rpc_message_multiple_client {
rpc_server_port.send(v_rpc_message_multiple_client);
repeat;
}
[] rpc_server_port.receive(t_connected) {
repeat;
}
[] rpc_server_port.receive(t_close)
{
setverdict(pass);
}
[] T_guard.timeout {
setverdict(fail);
}
};
unmap(self:rpc_server_port, system:rpc_server_port);
}
}
<!--
/******************************************************************************
* Copyright (c) 2006, 2015 Ericsson AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Eduard Czimbalmos
* Attila Balasko
* Csaba Feher
* Gabor Szalai
* Kulcsr Endre
******************************************************************************/
//
// File: SUNRPCasp.grp
// Description: Group file for SUNRPC test port implementation
// Rev: R5A
// Prodnr: CNL 113 493
///////////////////////////////////////////////////////////////////////////////
-->
<!DOCTYPE TITAN_GUI_FileGroup_file>
<FileGroup TITAN_version="1.8.pl2" >
<File_Group name="SUNRPCasp" >
<File path="SunRPCasp_PT.cc" />
<File path="SunRPCasp_PT.hh" />
<File path="SunRPCasp_PortType.ttcn" />
<File path="SunRPCasp_Types.ttcn" />
</File_Group>
</FileGroup>
/******************************************************************************
* Copyright (c) 2006, 2015 Ericsson AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Eduard Czimbalmos
* Attila Balasko
* Csaba Feher
* Gabor Szalai
* Kulcsr Endre
******************************************************************************/
//
// File: SunRPCasp_PT.cc
// Description: SunRPC test port source
// Rev: R5A
// Prodnr: CNL 113 493
//
#include "SunRPCasp_PT.hh"
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
namespace SunRPCasp__PortType {
using namespace SunRPCasp__Types;
SunRPCasp__PT::SunRPCasp__PT(const char *par_port_name)
#ifdef AS_USE_SSL
: SSL_Socket("SunRPC", par_port_name)
#else
: Abstract_Socket("SunRPC", par_port_name)
#endif
, SunRPCasp__PT_BASE(par_port_name)
{
parameter_set(use_connection_ASPs_name(), "yes");
set_ttcn_buffer_usercontrol(true);
}
SunRPCasp__PT::~SunRPCasp__PT()
{
}
void SunRPCasp__PT::set_parameter(const char *parameter_name,
const char *parameter_value)
{
log_debug("entering SunRPCasp__PT::set_parameter(%s, %s)", parameter_name, parameter_value);
if(!parameter_set(parameter_name ,parameter_value))
TTCN_warning("SunRPCasp__PT::set_parameter(): Unsupported Test Port parameter: %s", parameter_name);
log_debug("leaving SunRPCasp__PT::set_parameter(%s, %s)", parameter_name, parameter_value);
}
void SunRPCasp__PT::Handle_Fd_Event(int fd,
boolean is_readable, boolean is_writable, boolean is_error)
{
log_debug("entering SunRPCasp__PT::Handle_Fd_Event()");
Handle_Socket_Event(fd, is_readable, is_writable, is_error);
log_debug("leaving SunRPCasp__PT::Handle_Fd_Event()");
}
void SunRPCasp__PT::Handle_Timeout(double time_since_last_call)
{
log_debug("entering SunRPCasp__PT::Handle_Timeout()");
Handle_Timeout_Event(time_since_last_call);
log_debug("leaving SunRPCasp__PT::Handle_Timeout()");
}
void SunRPCasp__PT::outgoing_send(const SunRPCasp__Types::SunRPC__message& send_par)
{
log_debug("entering SunRPCmsg__PT::outgoing_send(SunRPC__message)");
outgoing_send(send_par, -1);
log_debug("leaving SunRPCmsg__PT::outgoing_send(SunRPC__message)");
}
void SunRPCasp__PT::outgoing_send(const SunRPCasp__Types::SunRPC__message__multiple__client& send_par)
{
log_debug("entering SunRPCmsg__PT::outgoing_send(SunRPC__message__multiple__client)");
if(send_par.client__id().ispresent())
outgoing_send(send_par.rpc__msg(), send_par.client__id()());
else
outgoing_send(send_par.rpc__msg(), -1);
log_debug("leaving SunRPCmsg__PT::outgoing_send(SunRPC__message__multiple__client)");
}
void SunRPCasp__PT::outgoing_send(const SunRPCasp__Types::SunRPC__message& send_par, int client_id)
{
TTCN_Buffer fragment;
fragment.clear();
send_par.encode(SunRPC__message_descr_, fragment, TTCN_EncDec::CT_RAW);
unsigned int first_four_bytes = fragment.get_len();
// put an 1 into the first bit
first_four_bytes |= (1 << 31);
unsigned char first_four_chars[4];
//for(unsigned int i = 0; i < 4; i++)
// first_four_chars[i] = first_four_bytes >> (8 * (4 - i - 1));
// The same with less arithmetical operations:
first_four_chars[0] = first_four_bytes >> 24;
first_four_chars[1] = first_four_bytes >> 16;
first_four_chars[2] = first_four_bytes >> 8;
first_four_chars[3] = first_four_bytes;
OCTETSTRING data(4, first_four_chars);
data = data + OCTETSTRING(fragment.get_len(), fragment.get_data());
if(client_id < 0)
send_outgoing((const unsigned char*)data, data.lengthof());
else
send_outgoing((const unsigned char*)data, data.lengthof(), client_id);
}
void SunRPCasp__PT::message_incoming(const unsigned char* msg, int messageLength, int client_id)
{
log_debug("entering SunRPCmsg__PT::message_incoming()");
TTCN_Buffer msg_buf;
msg_buf.clear();
SunRPC__message rpc_msg;
TTCN_Buffer* buf_p = get_buffer(client_id);
buf_p->rewind();
bool last_fragment = 0;
// at least 4 bytes are needed in the buffer
while(buf_p->get_read_len() > 3)
{
log_debug("SunRPCasp__PT::message_incoming(): decoding next message, buffer len: %d", buf_p->get_read_len());
const unsigned char* msg_p = buf_p->get_read_data();
unsigned int msg_length = 0;
last_fragment = msg_p[0] & (1 << 7);
log_debug("last_fragment: %s", last_fragment ? "yes" : "no");
//for(unsigned int i = 0; i < 4; i++)
// msg_length += msg_p[i] << (8 * (4 - i - 1));
//msg_length &= 0x7FFFFFFF;
//log_debug("fragment size: %d", msg_length);
// The same with less arithmetical operations:
msg_length += (msg_p[0] << 24) & 0x7FFFFFFF;
msg_length += msg_p[1] << 16;
msg_length += msg_p[2] << 8;
msg_length += msg_p[3];
log_debug("fragment size: %d", msg_length);
buf_p->set_pos(buf_p->get_pos() + 4);
if(buf_p->get_read_len() >= msg_length)
{
msg_buf.put_os(OCTETSTRING(msg_length, buf_p->get_read_data()));
buf_p->set_pos(buf_p->get_pos() + msg_length);
if(last_fragment)
{
log_hex("Buffer to be decoded: ", msg_buf.get_read_data(), msg_buf.get_read_len());
rpc_msg.decode(SunRPC__message_descr_, msg_buf, TTCN_EncDec::CT_RAW);
msg_buf.clear();
buf_p->cut();
buf_p->rewind();
if(peer_list_get_nr_of_peers() == 1)
incoming_message(rpc_msg);
else
{
SunRPC__message__multiple__client msg_multiple;
msg_multiple.client__id() = client_id;
msg_multiple.rpc__msg() = rpc_msg;
incoming_message(msg_multiple);
}
}
else
{
log_debug("Fragment is not the last fragment of the message, waiting for the next fragment...");
}
}
else
{
log_debug("Fragment is not entirely received, waiting for more data...");