HP X.25/9000 Programmer's Guide
108 Chapter6
Extended Features
Getting Programmatic Diagnostics and Status Information
error = ioctl(sd, X25_GET_IFSTATE, &state_str);
sd Socket descriptor for an X.25 socket. Note that this can be a completely
new socket, a connected socket or a connected socket that has been shut
down.
X25_GET_IFSTATE Definition for the request.
state_str Contains the state of the interface.
The state of the interface is returned in ifstate and can take the
following values:
IFSTATE_UNINIT – The interface has been stopped.
IFSTATE_INIT – Level 3 is up (R1).
IFSTATE_L2DOWN – Level 3 is down (not R1).
error Set to 0 if the call was successful. Otherwise, contains –1 and
errno
contains the cause of the error.
A programming example is shown below.
/* Get if state */
result = ioctl( call_soc, X25_GET_IFSTATE, &if_state);
if (result == -1) {
perror(”ioctl(X25_GET_IFSTATE) call”);
exit(1);
}
Getting Status Information Programmatically
X.25 uses two system calls to return information on the status of a
circuit: getpeername() to get the address of the remote DTE, and
getsockname() to get the address of the local DTE.
Using getpeername() after a call has been established, a process can get
the caller's address from the calling address field of the CALL
ACCEPTED/INDICATION packet.
Using getsockname() after a call has been established, a process can get
the called address from the CALL ACCEPTED/INDICATION packet.
getsockname() can be used to get the actual called address when
wildcard addressing is being used.
36960-90061.bk Page 108 Friday, November 10, 2000 3:42 PM










