Next Previous Contents

4. SUA Application Program Interface (SUA API)

4.1 General API issues.

4.1.1 Constants

The maximum size of an IPv4/IPv6 address string is limited to SCTP_MAX_IP_LEN. An endpoint may (for now) have a maximum number of addresses, which is limited to SCTP_MAX_NUM_ADDRESSES. The maximum size of a datagram that may be passed to the sctp_send() function is SCTP_MAXIMUM_DATA_ LENGTH. Since we do NOT do proper MTU path discovery in this release, we cannot guarantee that IP fragmentation occurs, but for Ethernet hardware type and most packets, these settings will ensure that there is no fragmentation.

#define SCTP_MAX_IP_LEN 46

#define SCTP_MAX_NUM_ADDRESSES 20

#define SCTP_MAXIMUM_DATA_LENGTH 1400

4.1.2 Type definitions

The main include file of sua.h defines a number of types that are used throughout the library as well as in some of the interface functions. They will be explained in the subsequent sections.

4.1.3 SUA_ulpCallbacks

This is a structure containing pointers to functions (used as callbacks for SUA events that may occur and that the ULP needs to be notified of), which are all explained in detail in section 6.5. This structure is usually initialized early in the program, and then passed to the function sua_registerInstance() (see section 4.2.2.3), which in turn registers the appropriate functions from this structure for the corresponding events.

Definition:

Struct{

void (*ulp_ClDataIndNotif) ( unsigned int local_sua_Id,

unsigned int primitive,

unsigned int datalen

);

void (*ulp_ConnIndNotif) ( unsigned int local_sua_id,

unsigned int local_sua_ref,

unsigned int datalen

);

void (*ulp_ConnConfIndNotif) ( unsigned int local_sua_id,

unsigned int local_sua_ref,

unsigned int datalen

);

void (*ulp_ConnDataIndNotif) ( unsigned int local_sua_id,

unsigned int local_sua_ref,

unsigned int datalen

);

void (*ulp_DisConnIndNotif) ( unsigned int local_sua_id,

unsigned int local_sua_ref,

unsigned int reason,

unsigned int datalen

);

} Sua_ULP_CallBacks;

parameters:

Local_sua_Id : identifies the local SUA instance

Primitive: identifies the CLDT or CLDR in case of a Connectionless Data Notification

Local_sua_ref : reference to the SUA connection used for data transfer

Reason: reason for the release of the SUA connection

4.1.4 SCTP Helper Functions

The libsctp-library contains a few functions that influence the general control flow of a program using them, and are needed to create an application that works as expected. The important functions needed in any program using the libsctp-library are the functions sctp_eventLoop()

4.1.4.1 sctp_timerCallback

Definition: see also [3].

typedef void (*sctp_timerCallback) (unsigned int, void *, void *);

Defines the callback function that is called when a timer expires. Parameters:

unsigned int ID of timer

void* pointer to param1

void* pointer to param2

param1 and param2 are pointers to data that are returned to the callback function, when the timer expires. These must still exist at that time and point to valid data !

4.1.4.2 sctp_eventLoop()

Basically this is a wrapper to a poll() or select()-system call. The function waits until either of one events occurrs:

1. the time for which a timer event was scheduled has passed by, so the callback function belonging to that (previously registered) event is executed.

2. one of the sockets that had previously been registered with the function sua_registerCallback() or the raw socket that waits for incoming SCTP packets has encountered a read event, so there is data available. The appropriate function callback is then called to treat that event. The control flow of the program is given to the callback function which may in turn register new timer events. The function returns -1 if an error ocurrs, 0 if a timeout has ocurred, or else the number of file descriptor events that have been treated.

Definition:

int sctp_eventLoop();

4.1.4.3 sctp_registerStdinCallback()

6.3.4 This function is supposed to register a callback function for catching input from the Unix STDIN file descriptor. We expect this to be useful in test programs mainly, so it is provided here for convenience. Events on this file descriptor are dispatched differently, as applications may read directly from STDIN (i.e. the callback function buffer does not contain the data from STDIN, and the registered callback function may retrieve this data with functions as fgets()).

scf callback funtion that is called when data has arrived

It returns 0, or -1 if an error ocurred.

Definition:

int sctp_registerStdinCallback(sctp_socketCallback scf);

4.1.4.4 sctp_startTimer()

This function adds a callback that is to be called some time from now. It realizes the timer (in an ordered list). The function takes the following parameters:

milliseconds action is to be started in milliseconds ms from now

timer_cb pointer to a function to be executed, when timer expires

param1 pointer to be returned to the caller when timer expires

param2 pointer to be returned to the caller when timer expires

The function returns a timer ID value, that can be used to cancel or restart this timer. NOTE: the pointers param1 and param2 exist to point to data useful for the function callback. They need to point to data that is still valid at the time the callback is activated. Do not pass pointers to temporary objects !

Definition:

unsigned int sctp_startTimer(unsigned int milliseconds, sctp_timerCallback timer_cb, void *param1, void *param2);

4.1.4.5 sctp_stopTimer()

This function stops a previously started timer. The function takes the following parameter:

tid timer-id of timer to be removed

The function returns 0 on success, 1 if tid not in the list, -1 on error.

Definition:

int sctp_stopTimer(unsigned int tid);

4.1.4.6 sctp_restartTimer()

Restarts a timer that is currently running. The function takes the following parameters:

timer_id the timer id returned by start_timer

milliseconds action is to be taken in milliseconds ms from now

The function returns a new timer ID, zero when there is an error (i.e. the timer was not running). The function basically stops the old timer, and sets a new timer. So it is there for convenience. The timer ID will be different after calling this function !

Definition:

unsigned int sctp_restartTimer(unsigned int timer_id, unsigned int milliseconds);

4.1.4.7 sctp_getTime()

This helper function returns a 32 bit value representing the current time in milliseconds. Beware, this counter wraps about once per 20 days. Keep that in mind when calculating time differences ! This function may be useful, or may not be useful.

Definition:

unsigned int sctp_getTime(void);

4.2 standard SUA API

4.2.1 ULP-to-SUA

4.2.1.1 sua_read_config_file()

sua_read_config_file() is called to fill in the internal SUA database.

The file can contain:

- only IP source address(es) and portnumber(s) of local SUA instance(s) or

- IP source and destination address togethers with the portnumbers for setting up SCTP associations between the specified endpoints.

If the port is not specified then the default SUA port 14001 will be used.

Definition:

unsigned int sua_read_config_file

( char *pConfFile );

Parameters:

*pConfFile: pointer to a char array. Containing the filename Filename has to be terminated with ‘\0’ character.

4.2.1.2 sua_registerInstance()

sua_registerInstance() is called to initialize one SUA instance. On the very first call, it will open raw sockets for capturing SCTP packets (IPv4 and if possible, IPv6, too) from the network. An application may register several instances with different sets of callback functions, but there should not be several instances with the same subsystemnumber(local SSN).

Definition:

unsigned int sua_registerInstance

( short local_ssn,

Sua_ULP_CallBacks ulp_callback

);

The function returns the instance name of this new SUA instance.

Parameters:

short local_ssn: SSN used for registering the callback function

Sua_ULP_CallBacks ulp_callback : callbackfunction to be used for that SSN

4.2.1.3 sua_unregisterInstance()

???

4.2.1.4 sua_associate()

This function is called to set up one or more SCTP associations. It uses the info provided with the configuration file which was entered in the SUA database.

Definition:

unsigned int sua_associate ( );

4.2.1.5 sua_shutdown()

???

4.2.1.6 sua_send()

sua_send() is used by the ULP to send data as SUA messages. There are quite a few parameters that can be or must be passed along:

Definition:

unsigned int Send_sua_primitive( unsigned int primitive,

unsigned int &sua_ConnId,

sccp_QOS_str &QOS,

sccp_addr_str &called_pty_address,

sccp_addr_str &calling_pty_address,

char *buffer,

unsigned int len

);

The function returns an error code: -1 for send error, 1 for association error, 0 if successful.

Parameters:

Primitive: the primitive indicating to do CLDT, CODT, CORE, CORE, RELRE,RELCO processing.

sua_ConnID: identifies the connection to be used in case of connection oriented transfer. The field is ignored as input in case of Connectionless CLDT and CORE. it returns the specific connection identifier in case of the CORE primitive as output.

QOS : specifies the QOS parameters needed with the primitive.

Called_pty_address: provide destination/remote address for connectionless CLDT and connection oriented CORE. Ignored for other primitives

Calling_pty_address: provide source/local address for connectionless CLDT and connection oriented CORE. Ignored for other primitives.

*buffer: application data(memory space MUST be assigned by the application)

Len : length of the application data.

4.2.1.7 sua_receive()

sua_receive() is called in response to the DataArrive-Notification to get the received data.

Definition:

unsigned int Receive_sua_primitive( unsigned int &primitive,

unsigned int &sua_ConnId,

sccp_QOS_str &QOS,

sccp_addr_str &called_pty_address,

sccp_addr_str &calling_pty_address,

char *buffer,

unsigned int len

);

It returns 1 if association does not exist, 0 if okay

parameters:

Primitive: the primitive indicating which msg type was received(ex. CLDT, CODT, CORE, CORE, RELRE,RELCO …)

sua_ConnID: identifies the connection on which the data is received in case of connection oriented transfer. The field is ignored as input in case of Connectionless CLDT.

QOS : returns the QOS parameters used with the primitive.

Called_pty_address: returns destination/remote address for connectionless CLDT, CLDA and connection oriented CORE. Ignored for other primitives

Calling_pty_address: returns source/local address for connectionless CLDT, CLDA and connection oriented CORE. Ignored for other primitives.

*buffer: application data(memory space MUST be assigned by the application)

Len : length of the application data.

4.2.2 SUA-to-ULP

4.2.2.1 Sua address structure

Defines the structure of the source/calling party and the destination/called party address.

The sockaddr, sockaddr_in and sockaddr_in6 address structure can be found in [4].

union sockunion

{ struct sockaddr sa;

struct sockaddr_in sin;

struct sockaddr_in6 sin6;

unsigned char ch[SCTP_MAX_IP_LEN];

};

typedef enum { ITU14bit,

ITU24bit,

ANSI24bit

} SS7pc_set;

typedef struct {

SS7pc_set family;

uint32_t pc;

} SS7_ITU14_str;

/* define structure of SS7 MTP pointcode (ITU/ANSI/other...) */

union SS7union

{

SS7_ITU14_str ITU14;

SS7_ITU14_str ITU24;

SS7_ITU14_str ANSI24;

};

typedef enum { no_pc_present,

ipvx_pc_present, // IPvx(4 or 6) present in pc field

ss7_pc_present // SS7 pointcode present in pc field

} pointcode_set;

typedef enum { no_name_present,

hostname_present,

GT_present

} name_gt_set;

typedef enum { no_sap_present,

ssn_present,

portnumber_present

} application_SAP_set;

typedef enum { include_nothing,

include_pc_in_header,

include_ssn_port_in_header

} sua_header_set;

typedef struct {

pointcode_set pc;

name_gt_set name_gt;

application_SAP_set ssn_port;

sua_header_set field_in_header;

} addr_elements_str;

typedef struct {

SS7union ss7;

sockunion ipvx;

} pointcode_str;

typedef char hostname_str[255];

typedef char global_title_str[255]

; typedef union {

global_title_str GT;

hostname_str HostName;

}name_str;

typedef short application_sap_str;

typedef enum { route_on_ssn, // use pointcode for routing

route_on_name_gt, // use gt/name for routing

route_on_name_gt_next_office, // perform GTT in next node

no_address_present // no routing requested

} routing_type_set;

typedef struct {

addr_elements_str address_fields_present; // which fields are present?

pointcode_str pc; // pointcode field

name_str name; //global title/hostname field

application_sap_str ssn; // application ssn/port

routing_type_set routing_ind; // how must msg be routed

short network_apperance;

} sccp_addr_str;

4.2.2.2 sua Quality Of Service(QOS) structure

typedef enum { class0, // connectionless transport, non-sequenced class1, // connectionless transport, sequenced class2, // connectionoriented class3 // connectionoriented with flow control } protocol_class_set; typedef struct { protocol_class_set prot_class; // class 0, 1 or 2 bool in_sequence; // msg delivevered in sequence short sequence_number; // = stream number bool return_msg_on_error; // return a CLDR msg on err short importance; // importance of msg(0..7) short hopcounter; // hopcounter } sccp_QOS_str;

4.2.2.3 sua ULPcallbackFunctions

typedef struct { void (*ulp_ClDataIndNotif) ( unsigned int local_sua_Id, unsigned int primitive, unsigned int datalen ); void (*ulp_ConnIndNotif) ( unsigned int local_sua_id, unsigned int local_sua_ref, unsigned int datalen ); void (*ulp_ConnConfIndNotif) ( unsigned int local_sua_id, unsigned int local_sua_ref, unsigned int datalen ); void (*ulp_ConnDataIndNotif) ( unsigned int local_sua_id, unsigned int local_sua_ref, unsigned int datalen ); void (*ulp_DisConnIndNotif) ( unsigned int local_sua_id, unsigned int local_sua_ref, unsigned int reason, unsigned int datalen ); } Sua_ULP_CallBacks;

4.3 SUA light API

This is a Siemens specific interface. WARNING: The SUA and the SUAL structures, callbackfunctions, config files and functions cannot be mixed with each other.

4.3.1 SUAL address structure

typedef struct sual_PeerAddr { int AddrType; /* predefined values for AddrType to indicate which type is used in uPeerAddr: SUAL_ADDRTYPE_IPV4, SUAL_ADDRTYPE_IPV6 */ union uPeerAddr { struct in_addr ip4; struct in6_addr ip6; } uPeerAddr; } sual_PeerAddr_t; typedef enum { SUAL_ADDRTYPE_IPV4, SUAL_ADDRTYPE_IPV6 } sual_IpAddrType_t;

4.3.2 SUAL ULPcallbackFunctions

/* SUAL_ULP_CallBacks definitions */ typedef struct sual_ULPcallbackFunctions { void (*ConnIndNotif)( sual_id_t sual_ConnId, sual_PeerAddr_t *pPeerAddr, uint UserDataLen ); void (*ConnConfNotif)( sual_id_t sual_ConnId, uint UserDataLen ); void (*CoDataIndNotif)( sual_id_t sual_ConnId, uint UserDataLen ); void (*DisconnIndNotif)( sual_id_t sual_ConnId, reason_t reason, uint UserDataLen ); void (*ClDataIndNotif)( sual_id_t sual_DataId, uint ControlNumer, sual_PeerAddr_t *pPeerAddr, uint UserDataLen ); } sual_ULPcallbackFunctions_t;

4.3.3 SUAL sual_init ()

extern int sual_init( unsigned char *pConfFile );

4.3.4 SUAL sual_RegisterSUAL_Instance ()

extern sual_InstId_t sual_RegisterSUAL_Instance( sual_port_t LocalPort, sual_ULPcallbackFunctions_t *pULPcallbackFunctions );

4.3.5 SUAL sual_ConnReq ()

sual_id_t sual_ConnReq( sual_id_t InstId, sual_PeerAddr_t *pPeerAddr, unsigned char *pUserData, uint UserDataLen );

4.3.6 SUAL sual _ConnResp ()

6.6.6 int sual_ConnResp( sual_id_t InstId, sual_id_t sual_ConnId, unsigned char *pUserData, uint UserDataLen );

4.3.7 SUAL sual_DisconnReq ()

int sual_DisconnReq( sual_id_t InstId, sual_id_t sual_ConnId, unsigned char *pUserData, uint UserDataLen );

4.3.8 SUAL sual_CoDataRead ()

int sual_CoDataRead( sual_id_t InstId, sual_id_t sual_ConnId, unsigned char *pBuff, uint BuffLen );

4.3.9 SUAL sual_ClDataRead ()

int sual_ClDataRead( sual_id_t InstId, sual_DataId_t DataId, unsigned char *pBuff, uint BuffLen );

4.3.10 SUAL sual_CoDataReq ()

int sual_CoDataReq( sual_id_t InstId, sual_id_t sual_ConnId, unsigned char *pUserData, uint UserDataLen );

4.3.11 SUAL sual_ClDataReq ()

int sual_ClDataReq( sual_id_t InstId, sual_PeerAddr_t *pPeerAddr, uint ControlNumber, unsigned char *pUserData, uint UserDataLen );


Next Previous Contents