HPlogo X25/9000: X.25/9000 Programmer's Guide > Chapter 3  Establishing and Terminating a Socket Connection

Controlling Call Acceptance

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

The server process can control the acceptance of incoming CALL REQUESTs. How call acceptance operates is controlled through the use of ioctl(X25_CALL_ACPT_APPROVAL) and ioctl(X25_SEND_CALL_ACEPT) calls.

The steps required for controlling call acceptance are shown in the following table.

Table 3-1 Controlling Call Acceptance when Establishing an SVC

Server Events

X.25 Events

Client Events

1. socket()

No Event

No Event

2. bind()

No Event

No Event

3. ioctl (X25_CALL_ACPT_APPROVAL)

No Event

No Event

4. listen()

No Event

No Event

5. accept() blocks

No Event

No Event

6. No Event

No Event

socket()

7. No Event

CALL REQUEST packet transmitted

connect() blocks

8. No Event

CALL INDICATION packet received

No Event

9. accept() unblocks

No Event

No Event

10. ioctl(X25_SEND_CALL_ACEPT)

CALL ACCEPTED packet transmitted

No Event

11. No Event

CALL CONNECTED packet received

connect() unblocks

 

The ioctl(X25_CALL_ACPT_APPROVAL) call is used to instruct X.25 not to automatically send the CALL ACCEPTED packet. For a listen socket, the ioctl(X25_CALL_ACPT_APPROVAL) call should be implemented before the listen() call. If the ioctl() call is issued after the listen() call there is a risk that incoming calls might be automatically accepted during the brief delay that occurs between the listen() and accept() calls. The accept() still returns a socket descriptor connected to the incoming SVC, but no packets are sent.

NOTE: Any CALL INDICATION packet received after a listen() and before a ioctl(X25_CALL_ACPT_APPROVAL) is automatically accepted. Use the ioctl(X25_NEXT_MSG_STAT) to detect if the call has been automatically connected.

When the ioctl(X25_SEND_CALL_ACEPT) call is issued on an SVC socket it causes a CALL ACCEPTED packet to be transmitted.

The two ioctl() call acceptance calls are described below.

The ioctl (X25_CALL_ACPT_APPROVAL)

The ioctl(X25_CALL_ACPT_APPROVAL) call allows applications to screen incoming calls. When the call is issued for a given listen() socket, a new accept() socket is still created whenever a valid call comes in, but no data can be sent or received on the new socket until an ioctl(X25_SEND_CALL_ACPT) call is issued on the new socket. This feature must be set if:

  • the process is going to control use of the D bit,

  • facilities are specified,

  • or user data in the CALL ACCEPTED packet.

If the application does not want to accept the call, the circuit can be cleared with the close() call. The ioctl(X25_SEND_CALL_ACPT) call is described below.

Once the ioctl(X25_CALL_ACPT_APPROVAL) is enabled, it cannot be turned off, unless the listen socket is closed and the socket(), bind(), and listen() calls are repeated.

Syntax for ioctl (X25_CALL_ACPT_APPROVAL)

The ioctl(X25_CALL_ACPT_APPROVAL) call and its parameters are described below.

#include <x25/x25ioctls.h>
int err;
int sd;
err = ioctl(sd, X25_CALL_ACPT_APPROVAL, 0);

sd

A socket descriptor for a listen socket that has no accept() pending on it.

X25_CALL_ACPT_APPROVAL

The definition for the request.

0

A dummy variable used because ioctl(X25_CALL_ACPT_APPROVAL) does not use any arguments.

The ioctl (X25_SEND_CALL_ACEPT) Call

The ioctl(X25_SEND_CALL_ACEPT) call causes X.25 (level 3) to send a CALL ACCEPTED packet. The call is executed on a socket descriptor returned from an accept() call. The listen socket on which the accept() call was issued must have previously had an ioctl(X25_CALL_APPROVAL) issued on it. The ioctl(X25_SEND_CALL_ACEPT) causes a CALL ACCEPTED packet to be sent on the SVC.

If the application determines that the call should not be accepted, the call can be rejected with a CLEAR packet by calling close() or shutdown() on the socket descriptor.

The application may specify D bit usage, facilities, and call user data to be placed in the CALL ACCEPTED packet. The ioctl(X25_SEND_TYPE), ioctl(X25_WR_USER_DATA), and ioctl(X25_WR_FACILITIES) calls control these functions. They must be issued prior to accepting the call with the ioctl(X25_SEND_CALL_ACEPT).

The ioctl(X25_SEND_TYPE) is described in Chapter 4 “ Sending and Receiving Data”, the ioctl(X25_WR_USER_DATA) is described in Chapter 5 “ Receiving and Transmitting Out-of-Band Information”, and the ioctl(X25_WR_FACILITIES) is described in Chapter 6 “Extended Features”.

Syntax for ioctl(X25_SEND_CALL_ACEPT)

The ioctl(X25_SEND_CALL_ACEPT) call and its parameters are described below.

#include <x25/x25ioctls.h>
int err;
int sd;
err = ioctl(sd, X25_SEND_CALL_ACEPT, 0);

sd

A socket descriptor for an SVC socket. Is returned during an accept() call.

X25_SEND_CALL_ACEPT

The definition for the request.

0

A dummy variable used because X25_SEND_CALL_ACEPT does not use any arguments.