![]() |
![]() |
|
|
![]() |
![]() |
X25/9000: X.25/9000 Programmer's Guide > Chapter 5 Receiving and Transmitting
Out-of-Band Information![]() Transmitting Out-of-Band Events |
|
There are three types of out-of-band events that can be sent by the X.25 application: CLEAR packets, RESET packets, and INTERRUPT packets. These packets can be sent at any time as the needs of the program dictate. While Chapter 3 “ Establishing and Terminating a Socket Connection” discussed the use of the close() system call for the transmission of CLEAR packets, this chapter covers the use of the cause and diagnostic codes, as well as the facilities and user data fields. An SVC can be cleared when one of the processes that use it (X.25 or the network provider) issues a CLEAR REQUEST packet. A CLEAR REQUEST packet can be sent by the X.25 application (with a close() call) otherwise it will be sent if the process terminates without executing a close() call. Once a CLEAR REQUEST packet is issued, data cannot be sent or received over the connection because the connection is destroyed. The X.25 application can control the contents of certain data fields in the CLEAR REQUEST packet. These fields and the ioctl() calls which control them are:
All of these calls must be issued prior to the close() call. The ioctl(X25_WR_CAUSE_DIAG) and ioctl(X25_WR_USER_DATA) calls are described below. The ioctl(X25_WR_FACILITIES) call is described in Chapter 6 “Extended Features”. The cause code that is sent depends upon the cause code specified with the ioctl(X25_WR_CAUSE_DIAG)call and the network type specified during X.25 interface configuration. The table below summarizes cause code settings. Table 5-2 Setting Cause Codes
The ioctl(X25_WR_CAUSE_DIAG) call must be issued prior to a RESET or CLEAR packet in order to set cause and diagnostic codes.
The ioctl(X25_WR_CAUSE_DIAG) call and its parameters are described below.
sdA socket descriptor for an SVC socket. X25_WR_CAUSE_DIAGThe definition for the request. diagIndicates the cause and diagnostic codes to be sent. errUpon successful completion, err is set to 0. Otherwise, a value of -1 is returned and errno is set to indicate the error. The ioctl(X25_WR_USER_DATA) call is used to write data to the user data fields in CLEAR REQUEST, CALL REQUEST, and CALL ACCEPTED packets. Call acceptance must be in effect before the call can be used on a CALL ACCEPTED packet. You can use this call in any of the these three situations:
The ioctl(X25_RD_USER_DATA) call cannot be used to read data previously written with the ioctl(X25_WR_USER_DATA) call. The ioctl(X25_WR_USER_DATA) call and its parameters are described below.
sdA socket descriptor for an SVC socket. X25_WR_USER_DATAThe definition for the request. udataContains the length and the data for the user data field (x25_cud_data). The maximum length is 126 bytes. If you want to send more than this, the ioctl() call must be called again. Usually the maximum length of the call user data field is 16 bytes. If the fast select facility is specified, the maximum length of the call user data field is 128 bytes. errUpon successful completion, err is set to 0. Otherwise, a value of -1 is returned and errno is set to indicate the error.
The ioctl(X25_RD_USER_DATA) call can read any data in the clear user data field of a CLEAR INDICATION packet or the call user data field of an incoming CALL INDICATION or CALL CONNECTED packet. This call is best used with the ioctl(X25_NEXT_MSG_STAT) call. The ioctl(X25_NEXT_MSG_STAT) call can determine whether call user data is available in the next message, and whether or not clear user data is available. There may not be any user data available or there may only be clear or call user data available. Also both clear and call user data may be available. Use ioctl(X25_NEXT_MESG_STAT) to determine if both are available. If both call user data and clear user data are available, you should issue an ioctl(X25_RD_USER_DATA) call sequence to read the call user data first, until ioctl(X25_NEXT_MSG_STAT) says there is no longer call user data available, then issue an additional ioctl(X25_RD_USER_DATA) call sequence to read the clear user data. The ioctl(X25_RD_USER_DATA) call can read a maximum of 126 bytes of call or clear user data (one byte must contain the length) per ioctl() call. If more than 126 bytes of call or clear user data is received, the ioctl(X25_RD_USER_DATA) must be called, until returned buffer length is 0. The syntax for the ioctl(X25_RD_USER_DATA) call and its parameters are described below.
sdA socket descriptor for an SVC socket over which a CLEAR INDICATION packet, CALL INDICATION packet, or CALL CONNECTED packet has been received. X25_RD_USER_DATAThe definition for the request. udataContains the length of and data for the user data field, where the maximum length is 126 bytes. If there is more than 126 bytes of call or clear user data, the ioctl() must be called, until udata.x25_cud_len is 0. errUpon successful completion, err is set to 0. Otherwise, a value of -1 is returned and errno is set to indicate the error. The code example below shows how to use the ioctl(X25_RD_USER_DATA) call to obtain the data from a CALL or CLEAR packet.
This section describes how to send RESET packets. A RESET packet clears all data on a connection, including any inbound data queued but not yet read, while maintaining the virtual circuit. The user application must be prepared to handle RESET packets; the handling of RESET packets at the application level is not defined by X.25. RESET packets can be generated by the X.25 subsystem, by the application processes on either side of the VC, or by the network provider. If the user application wants to send a RESET packet, the application can set a cause code and diagnostic code with the ioctl(X25_WR_CAUSE_DIAG) call, then issue a RESET packet with the ioctl(X25_RESET_VC). The ioctl(X25_WR_CAUSE_DIAG) call is described above under "Clearing a Switched Virtual Circuit". The ioctl(X25_RESET_VC) call sends a RESET REQUEST packet over the virtual circuit. A VC cannot be reset before a connection is established or after a connection has been cleared. When a user application resets a circuit, and blocking I/O is in effect, the application is blocked until a RESET CONFIRMATION packet is received. The X.25 subsystem sends a RESET CONFIRMATION packet when the application reads the RESET out-of-band event without the MSG_PEEK flag set. If nonblocking I/O is in effect, the ioctl(X25_RESET_VC) call does not block the caller. When the RESET CONFIRMATION packet arrives and the socket is in the nonblocking state, an out-of-band event (OOB_RESET_CONF) is placed in the socket's out-of-band queue. Also, SIGURG is sent to the process, which must have a signal handler installed for the SIGURG signal and enabled the socket to transmit SIGURG signals. The ioctl(X25_RESET_VC) and its parameters are described below.
sdA socket descriptor for an SVC socket. X25_RESET_VCThe definition for the request which cause a RESET packet to be sent on the VC. 0A dummy parameter for the system call. errUpon successful completion, err is set to 0. Otherwise, a value of -1 is returned and errno is set to indicate the error.
An INTERRUPT packet can be sent at any time by either side of a VC after call connection has been established. X.25 supports sending up to 32 bytes of interrupt data in an INTERRUPT packet. To send an INTERRUPT packet, issue the send() system call with the MSG_OOB flag set. If blocking I/O is being used, the application process remains blocked until the INTERRUPT CONFIRMATION packet is received. If nonblocking I/O is being used, the confirmation is received as an out-of-band event (00B_VC_INTERRUPT_CONF). See Chapter 4 “ Sending and Receiving Data” for a description of how to send interrupt data. |
![]() |
||
![]() |
![]() |
![]() |
|||||||||
|