Loading ReadMe.md +14 −2 Original line number Diff line number Diff line Loading @@ -5,10 +5,21 @@ Initial, simple experiments with sending/ receiving SCTP messages within TTCN code using Titan's SCTP ASPs. There is a server and a client test wihch can run on different hosts. Olaf Bergengruen, January 2026 ## References - Titan compiler - SCTPasp repository and documentation in the Titan repository page: https://gitlab.eclipse.org/eclipse/titan ## To build the project - Create bin folder Loading @@ -17,9 +28,10 @@ Olaf Bergengruen, January 2026 ## Run the tests Run the server on host A Run the server on host A: ./SCTPTest Server.cfg Then run the client on host B Then run the client on host B: ./SCTPTest Client.cfg titan.TestPorts.SCTPasp/src/SCTPasp_PT.cc 0 → 100644 +1672 −0 File added.Preview size limit exceeded, changes collapsed. Show changes titan.TestPorts.SCTPasp/src/SCTPasp_PT.hh 0 → 100644 +155 −0 Original line number Diff line number Diff line /****************************************************************************** * Copyright (c) 2000-2023 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 * * Contributors: * Peter Dimitrov- initial implementation and initial documentation * Adam Delic * Eduard Czimbalmos * Endre Kulcsar * Gabor Bettesch * Gabor Szalai * Tamas Buti * Zoltan Medve ******************************************************************************/ // // File: SCTPasp_PT.hh // Description: SCTPasp test port header // #ifndef SCTPasp__PT_HH #define SCTPasp__PT_HH #include <TTCN3.hh> #include "SCTPasp_Types.hh" #include <sys/socket.h> #include <netinet/in.h> #include <netinet/sctp.h> namespace SCTPasp__Types { class ASP__SCTP; class ASP__SCTP__Connect; class ASP__SCTP__ConnectFrom; class ASP__SCTP__Listen; class SCTP__INIT; class SCTP__EVENTS; class SO__LINGER; class SCTP__RTOINFO; class SAC__STATE; class SPC__STATE; class ASP__SCTP__SetSocketOptions; class ASP__SCTP__Close; class ASP__SCTP__ASSOC__CHANGE; class ASP__SCTP__PEER__ADDR__CHANGE; class ASP__SCTP__SEND__FAILED; class ASP__SCTP__REMOTE__ERROR; class ASP__SCTP__SHUTDOWN__EVENT; class ASP__SCTP__PARTIAL__DELIVERY__EVENT; class ASP__SCTP__ADAPTION__INDICATION; class ASP__SCTP__Connected; class ASP__SCTP__SENDMSG__ERROR; class ASP__SCTP__RESULT; } namespace SCTPasp__PortType { class SCTPasp__PT_PROVIDER : public PORT { public: SCTPasp__PT_PROVIDER(const char *par_port_name = NULL); ~SCTPasp__PT_PROVIDER(); void set_parameter(const char *parameter_name, const char *parameter_value); void Handle_Fd_Event_Error(int my_fd); void Handle_Fd_Event_Writable(int my_fd); void Handle_Fd_Event_Readable(int my_fd); protected: void user_map(const char *system_port); void user_unmap(const char *system_port); void user_start(); void user_stop(); void outgoing_send(const SCTPasp__Types::ASP__SCTP__Connect& send_par); void outgoing_send(const SCTPasp__Types::ASP__SCTP__ConnectFrom& send_par); void outgoing_send(const SCTPasp__Types::ASP__SCTP__Listen& send_par); void outgoing_send(const SCTPasp__Types::ASP__SCTP__SetSocketOptions& send_par); void outgoing_send(const SCTPasp__Types::ASP__SCTP__Close& send_par); void outgoing_send(const SCTPasp__Types::ASP__SCTP& send_par); virtual void incoming_message(const SCTPasp__Types::ASP__SCTP& incoming_par) = 0; virtual void incoming_message(const SCTPasp__Types::ASP__SCTP__ASSOC__CHANGE& incoming_par) = 0; virtual void incoming_message(const SCTPasp__Types::ASP__SCTP__PEER__ADDR__CHANGE& incoming_par) = 0; virtual void incoming_message(const SCTPasp__Types::ASP__SCTP__SEND__FAILED& incoming_par) = 0; virtual void incoming_message(const SCTPasp__Types::ASP__SCTP__REMOTE__ERROR& incoming_par) = 0; virtual void incoming_message(const SCTPasp__Types::ASP__SCTP__SHUTDOWN__EVENT& incoming_par) = 0; virtual void incoming_message(const SCTPasp__Types::ASP__SCTP__PARTIAL__DELIVERY__EVENT& incoming_par) = 0; virtual void incoming_message(const SCTPasp__Types::ASP__SCTP__ADAPTION__INDICATION& incoming_par) = 0; virtual void incoming_message(const SCTPasp__Types::ASP__SCTP__Connected& incoming_par) = 0; virtual void incoming_message(const SCTPasp__Types::ASP__SCTP__SENDMSG__ERROR& incoming_par) = 0; virtual void incoming_message(const SCTPasp__Types::ASP__SCTP__RESULT& incoming_par) = 0; private: enum return_value_t { WHOLE_MESSAGE_RECEIVED, PARTIAL_RECEIVE, EOF_OR_ERROR }; return_value_t getmsg(int fd, struct msghdr *msg); void handle_event(void *buf); void log(const char *fmt, ...); void error(const char *fmt, ...); void handle_event_reconnect(void *buf); void forced_reconnect(int attempts); // map operations void map_put_item(int fd); int map_get_item(int fd); void map_delete_item_fd(int fd); void map_delete_item(int index); void map_put_item_server(int fd, const CHARSTRING& local_IP_address, unsigned short local_port); int map_get_item_server(int fd); void map_delete_item_fd_server(int fd); void map_delete_item_server(int index); int create_socket(int addr_family); int fill_addr_struct(const char* name, int port, struct sockaddr_storage* sa, socklen_t& saLen); void setNonBlocking(int fd); boolean simple_mode; boolean reconnect; int reconnect_max_attempts; boolean server_mode; boolean debug; int server_backlog; CHARSTRING local_IP_address; CHARSTRING peer_IP_address; unsigned short local_port; unsigned short peer_port; struct sctp_event_subscribe events; struct sctp_initmsg initmsg; boolean local_port_is_present; boolean peer_IP_address_is_present; boolean peer_port_is_present; int fd; int receiving_fd; struct fd_map_item; fd_map_item *fd_map; int list_len; struct fd_map_server_item; fd_map_server_item *fd_map_server; int list_len_server; }; } #endif titan.TestPorts.SCTPasp/src/SCTPasp_PortType.ttcn 0 → 100644 +58 −0 Original line number Diff line number Diff line /****************************************************************************** * Copyright (c) 2000-2023 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 * * Contributors: * Peter Dimitrov- initial implementation and initial documentation * Adam Delic * Eduard Czimbalmos * Endre Kulcsar * Gabor Bettesch * Gabor Szalai * Tamas Buti * Zoltan Medve ******************************************************************************/ // // File: SCTPasp_PortType.ttcn // Description: SCTPasp testport definition file // module SCTPasp_PortType { import from SCTPasp_Types all; //========================================================================= //Port Types //========================================================================= type port SCTPasp_PT message { inout ASP_SCTP; out ASP_SCTP_Connect; out ASP_SCTP_ConnectFrom; out ASP_SCTP_Listen; out ASP_SCTP_SetSocketOptions; out ASP_SCTP_Close; in ASP_SCTP_ASSOC_CHANGE; in ASP_SCTP_PEER_ADDR_CHANGE; in ASP_SCTP_SEND_FAILED; in ASP_SCTP_REMOTE_ERROR; in ASP_SCTP_SHUTDOWN_EVENT; in ASP_SCTP_PARTIAL_DELIVERY_EVENT; in ASP_SCTP_ADAPTION_INDICATION; in ASP_SCTP_Connected; in ASP_SCTP_SENDMSG_ERROR; in ASP_SCTP_RESULT; } with { extension "provider" } }//end of module titan.TestPorts.SCTPasp/src/SCTPasp_Types.ttcn 0 → 100644 +196 −0 Original line number Diff line number Diff line /****************************************************************************** * Copyright (c) 2000-2023 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 * * Contributors: * Peter Dimitrov- initial implementation and initial documentation * Adam Delic * Eduard Czimbalmos * Endre Kulcsar * Gabor Bettesch * Gabor Szalai * Tamas Buti * Zoltan Medve ******************************************************************************/ // // File: SCTPasp_Types.ttcn // Description: SCTP ASP definition file // module SCTPasp_Types { //========================================================================= // Data Types //========================================================================= type octetstring PDU_SCTP; type record ASP_SCTP { integer client_id optional, integer sinfo_stream, integer sinfo_ppid, PDU_SCTP data } type record ASP_SCTP_Connect { charstring peer_hostname optional, integer peer_portnumber (1..65535) optional } type record ASP_SCTP_ConnectFrom { charstring local_hostname optional, integer local_portnumber (1..65535), charstring peer_hostname optional, integer peer_portnumber (1..65535) optional } type record ASP_SCTP_Listen { charstring local_hostname optional, integer local_portnumber (1..65535) } type record SCTP_INIT { integer sinit_num_ostreams, integer sinit_max_instreams, integer sinit_max_attempts, integer sinit_max_init_timeo } type record SCTP_EVENTS { boolean sctp_data_io_event, boolean sctp_association_event, boolean sctp_address_event, boolean sctp_send_failure_event, boolean sctp_peer_error_event, boolean sctp_shutdown_event, boolean sctp_partial_delivery_event, boolean sctp_adaption_layer_event } type record SO_LINGER { integer l_onoff, integer l_linger } type record SCTP_RTOINFO { integer client_id, integer srto_initial, integer srto_max, integer srto_min } type union ASP_SCTP_SetSocketOptions { SCTP_INIT Sctp_init, SCTP_EVENTS Sctp_events, SO_LINGER So_linger, SCTP_RTOINFO Sctp_rtoinfo } type record ASP_SCTP_Close { integer client_id optional } type enumerated SAC_STATE { SCTP_COMM_UP, SCTP_COMM_LOST, SCTP_RESTART, SCTP_SHUTDOWN_COMP, SCTP_CANT_STR_ASSOC, SCTP_UNKNOWN_SAC_STATE } type record ASP_SCTP_ASSOC_CHANGE { integer client_id, SAC_STATE sac_state } type enumerated SPC_STATE { SCTP_ADDR_AVAILABLE, SCTP_ADDR_UNREACHABLE, SCTP_ADDR_REMOVED, SCTP_ADDR_ADDED, SCTP_ADDR_MADE_PRIM, SCTP_ADDR_CONFIRMED, SCTP_UNKNOWN_SPC_STATE } type record ASP_SCTP_PEER_ADDR_CHANGE { integer client_id, SPC_STATE spc_state } type record ASP_SCTP_SEND_FAILED { integer client_id } type record ASP_SCTP_REMOTE_ERROR { integer client_id } type record ASP_SCTP_SHUTDOWN_EVENT { integer client_id } type record ASP_SCTP_PARTIAL_DELIVERY_EVENT { integer client_id } type record ASP_SCTP_ADAPTION_INDICATION { integer client_id } type record ASP_SCTP_Connected { integer client_id, charstring local_hostname, integer local_portnumber (1..65535), charstring peer_hostname, integer peer_portnumber (1..65535) } type record ASP_SCTP_SENDMSG_ERROR { integer client_id optional, integer sinfo_stream, integer sinfo_ppid, PDU_SCTP data } type record ASP_SCTP_RESULT { integer client_id optional, boolean error_status, charstring error_message optional } }//end of module Loading
ReadMe.md +14 −2 Original line number Diff line number Diff line Loading @@ -5,10 +5,21 @@ Initial, simple experiments with sending/ receiving SCTP messages within TTCN code using Titan's SCTP ASPs. There is a server and a client test wihch can run on different hosts. Olaf Bergengruen, January 2026 ## References - Titan compiler - SCTPasp repository and documentation in the Titan repository page: https://gitlab.eclipse.org/eclipse/titan ## To build the project - Create bin folder Loading @@ -17,9 +28,10 @@ Olaf Bergengruen, January 2026 ## Run the tests Run the server on host A Run the server on host A: ./SCTPTest Server.cfg Then run the client on host B Then run the client on host B: ./SCTPTest Client.cfg
titan.TestPorts.SCTPasp/src/SCTPasp_PT.cc 0 → 100644 +1672 −0 File added.Preview size limit exceeded, changes collapsed. Show changes
titan.TestPorts.SCTPasp/src/SCTPasp_PT.hh 0 → 100644 +155 −0 Original line number Diff line number Diff line /****************************************************************************** * Copyright (c) 2000-2023 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 * * Contributors: * Peter Dimitrov- initial implementation and initial documentation * Adam Delic * Eduard Czimbalmos * Endre Kulcsar * Gabor Bettesch * Gabor Szalai * Tamas Buti * Zoltan Medve ******************************************************************************/ // // File: SCTPasp_PT.hh // Description: SCTPasp test port header // #ifndef SCTPasp__PT_HH #define SCTPasp__PT_HH #include <TTCN3.hh> #include "SCTPasp_Types.hh" #include <sys/socket.h> #include <netinet/in.h> #include <netinet/sctp.h> namespace SCTPasp__Types { class ASP__SCTP; class ASP__SCTP__Connect; class ASP__SCTP__ConnectFrom; class ASP__SCTP__Listen; class SCTP__INIT; class SCTP__EVENTS; class SO__LINGER; class SCTP__RTOINFO; class SAC__STATE; class SPC__STATE; class ASP__SCTP__SetSocketOptions; class ASP__SCTP__Close; class ASP__SCTP__ASSOC__CHANGE; class ASP__SCTP__PEER__ADDR__CHANGE; class ASP__SCTP__SEND__FAILED; class ASP__SCTP__REMOTE__ERROR; class ASP__SCTP__SHUTDOWN__EVENT; class ASP__SCTP__PARTIAL__DELIVERY__EVENT; class ASP__SCTP__ADAPTION__INDICATION; class ASP__SCTP__Connected; class ASP__SCTP__SENDMSG__ERROR; class ASP__SCTP__RESULT; } namespace SCTPasp__PortType { class SCTPasp__PT_PROVIDER : public PORT { public: SCTPasp__PT_PROVIDER(const char *par_port_name = NULL); ~SCTPasp__PT_PROVIDER(); void set_parameter(const char *parameter_name, const char *parameter_value); void Handle_Fd_Event_Error(int my_fd); void Handle_Fd_Event_Writable(int my_fd); void Handle_Fd_Event_Readable(int my_fd); protected: void user_map(const char *system_port); void user_unmap(const char *system_port); void user_start(); void user_stop(); void outgoing_send(const SCTPasp__Types::ASP__SCTP__Connect& send_par); void outgoing_send(const SCTPasp__Types::ASP__SCTP__ConnectFrom& send_par); void outgoing_send(const SCTPasp__Types::ASP__SCTP__Listen& send_par); void outgoing_send(const SCTPasp__Types::ASP__SCTP__SetSocketOptions& send_par); void outgoing_send(const SCTPasp__Types::ASP__SCTP__Close& send_par); void outgoing_send(const SCTPasp__Types::ASP__SCTP& send_par); virtual void incoming_message(const SCTPasp__Types::ASP__SCTP& incoming_par) = 0; virtual void incoming_message(const SCTPasp__Types::ASP__SCTP__ASSOC__CHANGE& incoming_par) = 0; virtual void incoming_message(const SCTPasp__Types::ASP__SCTP__PEER__ADDR__CHANGE& incoming_par) = 0; virtual void incoming_message(const SCTPasp__Types::ASP__SCTP__SEND__FAILED& incoming_par) = 0; virtual void incoming_message(const SCTPasp__Types::ASP__SCTP__REMOTE__ERROR& incoming_par) = 0; virtual void incoming_message(const SCTPasp__Types::ASP__SCTP__SHUTDOWN__EVENT& incoming_par) = 0; virtual void incoming_message(const SCTPasp__Types::ASP__SCTP__PARTIAL__DELIVERY__EVENT& incoming_par) = 0; virtual void incoming_message(const SCTPasp__Types::ASP__SCTP__ADAPTION__INDICATION& incoming_par) = 0; virtual void incoming_message(const SCTPasp__Types::ASP__SCTP__Connected& incoming_par) = 0; virtual void incoming_message(const SCTPasp__Types::ASP__SCTP__SENDMSG__ERROR& incoming_par) = 0; virtual void incoming_message(const SCTPasp__Types::ASP__SCTP__RESULT& incoming_par) = 0; private: enum return_value_t { WHOLE_MESSAGE_RECEIVED, PARTIAL_RECEIVE, EOF_OR_ERROR }; return_value_t getmsg(int fd, struct msghdr *msg); void handle_event(void *buf); void log(const char *fmt, ...); void error(const char *fmt, ...); void handle_event_reconnect(void *buf); void forced_reconnect(int attempts); // map operations void map_put_item(int fd); int map_get_item(int fd); void map_delete_item_fd(int fd); void map_delete_item(int index); void map_put_item_server(int fd, const CHARSTRING& local_IP_address, unsigned short local_port); int map_get_item_server(int fd); void map_delete_item_fd_server(int fd); void map_delete_item_server(int index); int create_socket(int addr_family); int fill_addr_struct(const char* name, int port, struct sockaddr_storage* sa, socklen_t& saLen); void setNonBlocking(int fd); boolean simple_mode; boolean reconnect; int reconnect_max_attempts; boolean server_mode; boolean debug; int server_backlog; CHARSTRING local_IP_address; CHARSTRING peer_IP_address; unsigned short local_port; unsigned short peer_port; struct sctp_event_subscribe events; struct sctp_initmsg initmsg; boolean local_port_is_present; boolean peer_IP_address_is_present; boolean peer_port_is_present; int fd; int receiving_fd; struct fd_map_item; fd_map_item *fd_map; int list_len; struct fd_map_server_item; fd_map_server_item *fd_map_server; int list_len_server; }; } #endif
titan.TestPorts.SCTPasp/src/SCTPasp_PortType.ttcn 0 → 100644 +58 −0 Original line number Diff line number Diff line /****************************************************************************** * Copyright (c) 2000-2023 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 * * Contributors: * Peter Dimitrov- initial implementation and initial documentation * Adam Delic * Eduard Czimbalmos * Endre Kulcsar * Gabor Bettesch * Gabor Szalai * Tamas Buti * Zoltan Medve ******************************************************************************/ // // File: SCTPasp_PortType.ttcn // Description: SCTPasp testport definition file // module SCTPasp_PortType { import from SCTPasp_Types all; //========================================================================= //Port Types //========================================================================= type port SCTPasp_PT message { inout ASP_SCTP; out ASP_SCTP_Connect; out ASP_SCTP_ConnectFrom; out ASP_SCTP_Listen; out ASP_SCTP_SetSocketOptions; out ASP_SCTP_Close; in ASP_SCTP_ASSOC_CHANGE; in ASP_SCTP_PEER_ADDR_CHANGE; in ASP_SCTP_SEND_FAILED; in ASP_SCTP_REMOTE_ERROR; in ASP_SCTP_SHUTDOWN_EVENT; in ASP_SCTP_PARTIAL_DELIVERY_EVENT; in ASP_SCTP_ADAPTION_INDICATION; in ASP_SCTP_Connected; in ASP_SCTP_SENDMSG_ERROR; in ASP_SCTP_RESULT; } with { extension "provider" } }//end of module
titan.TestPorts.SCTPasp/src/SCTPasp_Types.ttcn 0 → 100644 +196 −0 Original line number Diff line number Diff line /****************************************************************************** * Copyright (c) 2000-2023 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 * * Contributors: * Peter Dimitrov- initial implementation and initial documentation * Adam Delic * Eduard Czimbalmos * Endre Kulcsar * Gabor Bettesch * Gabor Szalai * Tamas Buti * Zoltan Medve ******************************************************************************/ // // File: SCTPasp_Types.ttcn // Description: SCTP ASP definition file // module SCTPasp_Types { //========================================================================= // Data Types //========================================================================= type octetstring PDU_SCTP; type record ASP_SCTP { integer client_id optional, integer sinfo_stream, integer sinfo_ppid, PDU_SCTP data } type record ASP_SCTP_Connect { charstring peer_hostname optional, integer peer_portnumber (1..65535) optional } type record ASP_SCTP_ConnectFrom { charstring local_hostname optional, integer local_portnumber (1..65535), charstring peer_hostname optional, integer peer_portnumber (1..65535) optional } type record ASP_SCTP_Listen { charstring local_hostname optional, integer local_portnumber (1..65535) } type record SCTP_INIT { integer sinit_num_ostreams, integer sinit_max_instreams, integer sinit_max_attempts, integer sinit_max_init_timeo } type record SCTP_EVENTS { boolean sctp_data_io_event, boolean sctp_association_event, boolean sctp_address_event, boolean sctp_send_failure_event, boolean sctp_peer_error_event, boolean sctp_shutdown_event, boolean sctp_partial_delivery_event, boolean sctp_adaption_layer_event } type record SO_LINGER { integer l_onoff, integer l_linger } type record SCTP_RTOINFO { integer client_id, integer srto_initial, integer srto_max, integer srto_min } type union ASP_SCTP_SetSocketOptions { SCTP_INIT Sctp_init, SCTP_EVENTS Sctp_events, SO_LINGER So_linger, SCTP_RTOINFO Sctp_rtoinfo } type record ASP_SCTP_Close { integer client_id optional } type enumerated SAC_STATE { SCTP_COMM_UP, SCTP_COMM_LOST, SCTP_RESTART, SCTP_SHUTDOWN_COMP, SCTP_CANT_STR_ASSOC, SCTP_UNKNOWN_SAC_STATE } type record ASP_SCTP_ASSOC_CHANGE { integer client_id, SAC_STATE sac_state } type enumerated SPC_STATE { SCTP_ADDR_AVAILABLE, SCTP_ADDR_UNREACHABLE, SCTP_ADDR_REMOVED, SCTP_ADDR_ADDED, SCTP_ADDR_MADE_PRIM, SCTP_ADDR_CONFIRMED, SCTP_UNKNOWN_SPC_STATE } type record ASP_SCTP_PEER_ADDR_CHANGE { integer client_id, SPC_STATE spc_state } type record ASP_SCTP_SEND_FAILED { integer client_id } type record ASP_SCTP_REMOTE_ERROR { integer client_id } type record ASP_SCTP_SHUTDOWN_EVENT { integer client_id } type record ASP_SCTP_PARTIAL_DELIVERY_EVENT { integer client_id } type record ASP_SCTP_ADAPTION_INDICATION { integer client_id } type record ASP_SCTP_Connected { integer client_id, charstring local_hostname, integer local_portnumber (1..65535), charstring peer_hostname, integer peer_portnumber (1..65535) } type record ASP_SCTP_SENDMSG_ERROR { integer client_id optional, integer sinfo_stream, integer sinfo_ppid, PDU_SCTP data } type record ASP_SCTP_RESULT { integer client_id optional, boolean error_status, charstring error_message optional } }//end of module