36960-90061.bk Page 1 Friday, November 10, 2000 3:42 PM HP X.25/9000 Programmer’s Guide Edition 5 Customer Order Number: J2793-90048 Manufacturing Part Number: J2793-90048 E1100 United States © Copyright 1983-2000 Hewlett-Packard Company.
36960-90061.bk Page 2 Friday, November 10, 2000 3:42 PM Legal Notices The information in this document is subject to change without notice. Hewlett-Packard makes no warranty of any kind with regard to this manual, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose.
6960-90061.bk Page 3 Friday, November 10, 2000 3:42 PM Contents 1. Introduction to X.25 Programmatic Access Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 X.25 Product Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 Using BSD IPC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5 Using BSD IPC and X.25 With the Client/Server Model . . . . . . . . . . . .
36960-90061.bk Page 4 Friday, November 10, 2000 3:42 PM Contents Connection Establishment for the Server Process . . . . . . . . . . . . . . . . . Creating a Socket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Binding an X.121 Address to a Socket . . . . . . . . . . . . . . . . . . . . . . . . . Preparing a Listen Socket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Accepting a connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
36960-90061.bk Page 5 Friday, November 10, 2000 3:42 PM Contents Nonblocking Behavior of System Calls . . . . . . . . . . . . . . . . . . . . . . . . .58 Getting Next Message Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .61 The ioctl(X25_NEXT_MSG_STAT) Call . . . . . . . . . . . . . . . . . . . . . . . .61 Setting Buffer Thresholds and Sizes . . . . . . . . . . . . . . . . . . . . . . . . . . . .63 Setting the Write Buffer Threshold. . . . . . . . . . . . . . . . . . . . . . .
36960-90061.bk Page 6 Friday, November 10, 2000 3:42 PM Contents Using Fast Select . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Fast select on the calling side. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Fast Select on the Called Side . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Fast Select Operation Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Initial Steps for Fast Select . . . . . . . . . . . . . . . . . .
36960-90061.bk Page 7 Friday, November 10, 2000 3:42 PM Contents Example Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
36960-90061.
36960-90061.bk Page 9 Friday, November 10, 2000 3:42 PM Printing history The manual printing date and part number indicate its current edition. The printing date will change when a new edition is printed. Minor changes may be made at reprint without changing the printing date. The manual part number will change when extensive changes are made. Manual updates may be issued between editions to correct errors or document product changes.
36960-90061.
36960-90061.bk Page 1 Friday, November 10, 2000 3:42 PM 1 Introduction to X.
36960-90061.bk Page 2 Friday, November 10, 2000 3:42 PM Introduction to X.25 Programmatic Access Introduction Introduction This chapter introduces the X.25 product and the X.25 programmatic access (X.25/PA) interface. Using the X.25 programmatic access interface, application programs can control X.25 packet transmission (level 3 of the Open Systems Interconnectivity (OSI) model). This chapter contains three parts: • X.25 product description • Using BSD IPC • Getting started with X.
36960-90061.bk Page 3 Friday, November 10, 2000 3:42 PM Introduction to X.25 Programmatic Access X.25 Product Description X.25 Product Description The X.25 link software and hardware enable an HP system to communicate with other HP and non-HP hosts by way of an X.25 Packet Switching Network (PSN). The CCITT X.25 Recommendations describe the packet interface between a DTE (Data Terminating Equipment) and a DCE (Data Communications Equipment).
36960-90061.bk Page 4 Friday, November 10, 2000 3:42 PM Introduction to X.25 Programmatic Access X.25 Product Description Figure 1-2 Back-to-back Configuration HP 9000 X.25 DTE Modem Eliminator Remote Host X.25 DTE or DCE The term “remote” is used to designate a distant DTE. A remote host can be a few feet or thousands of miles away from the local DTE. X.25 allows for the creation of multiple virtual connections over the same connection to a PSN. Each connection is called a virtual circuit (VC). X.
36960-90061.bk Page 5 Friday, November 10, 2000 3:42 PM Introduction to X.25 Programmatic Access Using BSD IPC Using BSD IPC BSD IPC is a set of program development tools for interprocess communication. HP's implementation of BSD IPC is a subset of the networking services originally developed by the University of California at Berkeley. Before you attempt to use BSD IPC, you must be familiar with the C programming language.
36960-90061.bk Page 6 Friday, November 10, 2000 3:42 PM Introduction to X.25 Programmatic Access Using BSD IPC 2. The server process, receives the CALL INDICATION packet and accepts it by sending a CALL ACCEPTED packet. Prior to receiving connection requests, the server process must: a. create a socket, binding an (X.121) address or range of addresses to it, b. set up a listen queue for receiving connection requests. The server then passively waits for connection requests until they arrive. 3.
36960-90061.bk Page 7 Friday, November 10, 2000 3:42 PM Introduction to X.25 Programmatic Access Getting Started with X.25 Programmatic Access Getting Started with X.25 Programmatic Access Before you begin designing your application: Step 1. Finish reading this manual so you understand how processes establish a connection, exchange data, handle asynchronous (out-of-band) events, and terminate connections. Step 2. Check that your node or system manager has installed and configured the X.
36960-90061.bk Page 8 Friday, November 10, 2000 3:42 PM Introduction to X.25 Programmatic Access Getting Started with X.25 Programmatic Access that one side of the connection requests and the other services. Often the client/server model is retained during this phase of the connection, but it is not required. Example Programs Several pairs of example programs are shipped with the X.25 product. These programs are in the /var/x25/netdemo directory.
36960-90061.bk Page 9 Friday, November 10, 2000 3:42 PM 2 X.
36960-90061.bk Page 10 Friday, November 10, 2000 3:42 PM X.25 Addressing Introduction Introduction This chapter discusses the issues associated with addressing over an X.25 interface. Addressing is used to define the particular interface and application that is used during a Switched Virtual Circuit (SVC) connection. NOTE The information in this chapter applies only to SVCs. It does not apply to Permanent Virtual Circuits (PVCs).
36960-90061.bk Page 11 Friday, November 10, 2000 3:42 PM X.25 Addressing Levels of Addressing Levels of Addressing X.25 allows call addressing to use an interface’s programmatic access name, the X.121 address and subaddress, and protocol ID. This information is contained in the x25addrstr structure, described below. • The application can specify which X.25 interface to use when receiving and connecting calls. This level of addressing is only useful when there is more than one X.
36960-90061.bk Page 12 Friday, November 10, 2000 3:42 PM X.25 Addressing Preparing Address Variables Preparing Address Variables All addressing information for both the client and server is contained in the x25addrstr structure. This structure is defined in the include file x25/x25addrstr.h. It is used by the client in the connect() system call and by the server in the bind() system call.
36960-90061.bk Page 13 Friday, November 10, 2000 3:42 PM X.25 Addressing Preparing Address Variables Options for Servers” below. This field can also include a subaddress. x25ifname[13] Specifies the name of the X.25 interface as set during X.25 configuration. The null string (“\0”) specifies the default interface in connect() and all interfaces in bind(). Range: 1 to 12 alphanumeric characters terminated by the null character (“\0”).
36960-90061.bk Page 14 Friday, November 10, 2000 3:42 PM X.25 Addressing Addressing Options for Clients Addressing Options for Clients The client process specifies the address to which it wants to connect an SVC. The client uses the x25addrstr structure in the connect() system call to specify most of the addressing information. If protocol IDs are used for call matching, the client process will also use ioctl(X25_WR_USER_DATA). In general, clients have no real addressing options.
36960-90061.bk Page 15 Friday, November 10, 2000 3:42 PM X.25 Addressing Addressing Options for Servers Addressing Options for Servers A server uses the X.25 socket address information to identify which calls it will process. Each server uses the bind(2) system call to define the addressing information for calls it will process. The bind() system call is described in Chapter 3 , “Establishing and Terminating a Socket Connection,” and in your HP-UX man pages.
36960-90061.bk Page 16 Friday, November 10, 2000 3:42 PM X.25 Addressing Addressing Options for Servers NOTE If any of the three tests fail the call is cleared before reaching the socket, and the server application (above the socket) will never know anything about the incoming call request. The matching tests for incoming calls and how a server controls calls are described below. Call-matching by X.25 Interface Name The name of an X.25 interface is assigned during configuration. Refer to the X.
36960-90061.bk Page 17 Friday, November 10, 2000 3:42 PM X.25 Addressing Addressing Options for Servers with a called address field equal to the X.121 address assigned to the interface will be delivered to the interface. In this case, specifying an X.121 address is equivalent to specifying an interface name. In back-to-back configurations, a CALL REQUEST packet with any valid X.121 address can be received by the interface. Any CALL REQUEST packet, regardless of its X.
36960-90061.bk Page 18 Friday, November 10, 2000 3:42 PM X.25 Addressing Addressing Options for Servers Call-matching by Protocol ID Call-matching by protocol ID is a flexible way to allow multiple servers to service incoming calls over the same interface. First the incoming call’s X.121 address and subaddress is tested and then the protocol ID. If the x25pidlen field is 0, the protocol ID is not used. The protocol ID field is at the beginning of the call user data field of the CALL REQUEST packet.
36960-90061.bk Page 19 Friday, November 10, 2000 3:42 PM X.25 Addressing Using Wildcard Addressing Using Wildcard Addressing Wildcard addressing lets a single listen socket connect to incoming calls using a variety of addresses and protocol IDs. NOTE Wildcard addresses are used in bind() calls only. They cannot be used in connect() calls. When an incoming CALL REQUEST packet is received, the x25addrstr structure fields are checked in the following order: x25ifname, x25_host, and then x25pid.
36960-90061.bk Page 20 Friday, November 10, 2000 3:42 PM X.25 Addressing Using Wildcard Addressing Table 2-1 Wildcard Characters ? Matches any single digit in the same position (for example, 1? matches 10, 11, 12, 13, 14, 15, 16, 17, 18, and 19). * Matches any string of decimal digits, including none (for example, 1* matches any address beginning with 1 including 1 itself). It can be used alone or as a suffix.
36960-90061.bk Page 21 Friday, November 10, 2000 3:42 PM X.25 Addressing Using Wildcard Addressing The protocol ID masking match works as follows: 1. The first byte from the CALL INDICATION packet’s call user data field is “masked” (that is, logically ANDed bit-by-bit) with the first byte of the mask specified with the ioctl(X25_WR_MASK_DATA). 2. The result is compared to the value specified in the first byte of the x25pid field in the x25addrstr structure specified in the bind() call. 3.
36960-90061.bk Page 22 Friday, November 10, 2000 3:42 PM X.25 Addressing Using Wildcard Addressing * u_char x25_masklen; * u_char x25_mask[X25_MAX_PIDLEN]; * } */ int sd; struct x25_mask_data mask; err = ioctl(sd, X25_WR_MASK_DATA, &mask); sd A socket descriptor for a listen socket. X25_WR_MASK_ DATA Indicates the type of ioctl() call. If the X25_WR_MASK_DATA value or x25_mask_len value is set to 0, the ioctl() call returns no error and an empty mask is used.
36960-90061.bk Page 23 Friday, November 10, 2000 3:42 PM X.25 Addressing Address Space Conflicts Address Space Conflicts The X.25 subsystem’s programming access prevents any two sockets from binding to the same address structure. When a bind() call is made, the subsystem checks the specified address against addresses that are already associated with the socket. The bind() call is rejected if there is a conflict in the space allocation of components in the address structure.
36960-90061.bk Page 24 Friday, November 10, 2000 3:42 PM X.25 Addressing Address Space Conflicts addressing. Avoid wildcards that specify large address spaces when specifying subaddresses. Specify an address space of exactly one address when specifying non-wildcard addresses. Each question mark increases the address space by a factor of 10; an asterisk increases the address space by several orders of magnitude.
36960-90061.
960-90061.bk Page 26 Friday, November 10, 2000 3:42 PM Establishing and Terminating a Socket Connection Introduction Introduction This chapter describes the steps needed to establish and terminate a switched virtual circuit (SVC), and establish a permanent virtual circuit (PVC) using a BSD IPC (socket).
36960-90061.bk Page 27 Friday, November 10, 2000 3:42 PM Establishing and Terminating a Socket Connection Connection Establishment for the Server Process Connection Establishment for the Server Process This section describes the system calls and parameters executed by the server process to establish a connection. In the simplest case, there are four steps that the server process must complete before a connection can be made with a client: 1. Create a socket with socket(). 2.
36960-90061.bk Page 28 Friday, November 10, 2000 3:42 PM Establishing and Terminating a Socket Connection Connection Establishment for the Server Process must specify AF_CCITT. type Identifies the type of socket. For X.25 programmatic access, you must specify SOCK_STREAM. protocol Identifies the underlying protocol to be used for the socket. For X.25 programmatic access, specify X25_PROTO_NUM (or 0 to specify that the default, which is X25_PROTO_NUM, is used).
36960-90061.bk Page 29 Friday, November 10, 2000 3:42 PM Establishing and Terminating a Socket Connection Connection Establishment for the Server Process that the server will handle. For a description of the issues associated with addressing, see Chapter 2 , “X.25 Addressing.” addrlen Length of the x25addrstr structure in bytes. error If the call completes successfully, error contains a 0. If the system call encountered an error, –1 is returned in error and errno contains the cause of the error.
36960-90061.bk Page 30 Friday, November 10, 2000 3:42 PM Establishing and Terminating a Socket Connection Connection Establishment for the Server Process error If the call completes successfully, error contains a 0. If an error is encountered, –1 is returned in error and errno contains the cause of the error. Incoming CALL INDICATION packets that match the socket’s bind address (and the sockets created for them) are placed in the listen queue in the order in which they are received.
36960-90061.bk Page 31 Friday, November 10, 2000 3:42 PM Establishing and Terminating a Socket Connection Connection Establishment for the Server Process Accepting a connection The accept() system call returns a socket descriptor for a socket associated with an SVC connection. This call usually establishes a connection when returned, although that can also be controlled by the application.
36960-90061.bk Page 32 Friday, November 10, 2000 3:42 PM Establishing and Terminating a Socket Connection Connection Establishment for the Server Process ioctl(X25_SEND_CALL_ACEPT) calls are used to control CALL ACCEPTED packets (see “Controlling Call Acceptance”). If you set up the listen socket to perform nonblocking I/O, your process will not block. Your request will return –1, and errno will contain EWOULDBLOCK.
36960-90061.bk Page 33 Friday, November 10, 2000 3:42 PM Establishing and Terminating a Socket Connection Connection Establishment for the Server Process 5. Terminate the connection (close()). 6. Go to step 2. Notice that the listen socket is not closed, so incoming CALL REQUESTs are queued on the listen socket but not acted upon until the service request is completed.
36960-90061.bk Page 34 Friday, November 10, 2000 3:42 PM Establishing and Terminating a Socket Connection Connection Establishment for the Client Process Connection Establishment for the Client Process This section discusses the system calls which the client process must make to establish an SVC with a server process. There are two mandatory steps: 1. Create a socket using the socket() call. 2. Make a connection request using the connect() call. These steps are described below.
36960-90061.bk Page 35 Friday, November 10, 2000 3:42 PM Establishing and Terminating a Socket Connection Connection Establishment for the Client Process Syntax for connect() The connect() system call and its parameters are described below. #include #include #include int err; int sd; struct x25addrstr to_addr; int to_addrlen; err = connect(sd, &to_addr, to_addrlen); sd Socket descriptor returned by a previous socket() system call.
36960-90061.bk Page 36 Friday, November 10, 2000 3:42 PM Establishing and Terminating a Socket Connection Connection Establishment for the Client Process NOTE The first initialized interface is the one that is first initialized when the sub-system is restarted after all cards are stopped. You can use the x25ifname field to control performance. Each interface used to connect to a particular network can only support a fixed number of circuits.
36960-90061.bk Page 37 Friday, November 10, 2000 3:42 PM Establishing and Terminating a Socket Connection Controlling Call Acceptance Controlling Call Acceptance The server process can control the acceptance of incoming CALL REQUESTs using the ioctl(X25_CALL_ACPT_APPROVAL) and ioctl(X25_SEND_CALL_ACEPT) calls. The following table shows the steps required for controlling call acceptance. Table 3-1 Controlling Call Acceptance When Establishing an SVC Server Events X.25 Events Client Events 1.
36960-90061.bk Page 38 Friday, November 10, 2000 3:42 PM Establishing and Terminating a Socket Connection Controlling Call Acceptance Table 3-1 Controlling Call Acceptance When Establishing an SVC 11. No event CALL CONNECTED packet received connect() unblocks The ioctl(X25_CALL_ACPT_APPROVAL) call is used to instruct X.25 not to send the CALL ACCEPTED packet when the user does an accept(). For a listen socket, the ioctl(X25_CALL_ACPT_APPROVAL) call should be implemented before the listen() call.
36960-90061.bk Page 39 Friday, November 10, 2000 3:42 PM Establishing and Terminating a Socket Connection Controlling Call Acceptance int sd; err = ioctl(sd, X25_CALL_ACPT_APPROVAL, 0); sd Socket descriptor for a listen socket that has no accept() pending on it. X25_CALL_ACPT _APPROVAL Definition for the request. 0 Dummy variable (ioctl(X25_CALL_ACPT_APPROVAL) does not take any arguments). The ioctl (X25_SEND_CALL_ACEPT) Call The ioctl(X25_SEND_CALL_ACEPT) call causes X.
36960-90061.bk Page 40 Friday, November 10, 2000 3:42 PM Establishing and Terminating a Socket Connection Controlling Call Acceptance err = ioctl(sd, X25_SEND_CALL_ACEPT, 0); sd Socket descriptor for an SVC socket returned during an accept() call. X25_SEND_CALL _ACEPT Definition for the request. 0 A dummy variable (X25_SEND_CALL_ACEPT does not take any arguments).
36960-90061.bk Page 41 Friday, November 10, 2000 3:42 PM Establishing and Terminating a Socket Connection Terminating a Connection Terminating a Connection When data communications activity over an SVC is completed, terminate the connection to free network memory and other resources. Terminating the connection also reduces communications costs since most PDNs charge for transmission and connection time. An SVC is terminated when a CLEAR REQUEST packet is transmitted.
36960-90061.bk Page 42 Friday, November 10, 2000 3:42 PM Establishing and Terminating a Socket Connection Terminating a Connection int sd; err = close(sd); sd A socket descriptor for a listen socket or an SVC socket. If there are other open socket descriptors for the socket, the socket is no longer usable by the process issuing the call. If there are no other open socket descriptors for the socket, the socket is destroyed and may not be used again by any process.
36960-90061.bk Page 43 Friday, November 10, 2000 3:42 PM Establishing and Terminating a Socket Connection Terminating a Connection NOTE Closing a socket immediately after sending data can result in data loss. Shutting Down a Socket When your program finishes reading or writing on a particular socket connection, it can call shutdown(2) to bring down a part of the connection. Unlike close(), shutdown() affects the entire socket and all other socket descriptors.
36960-90061.bk Page 44 Friday, November 10, 2000 3:42 PM Establishing and Terminating a Socket Connection Terminating a Connection err On successful completion, err is set to 0. Otherwise, a value of –1 is returned and errno is set to indicate the error. The shutdown() and close() calls differ in that shutdown() takes effect regardless of the number of open socket descriptors, while close() takes effect only when the last process with an open socket descriptor makes the call.
36960-90061.bk Page 45 Friday, November 10, 2000 3:42 PM Establishing and Terminating a Socket Connection Using Permanent Virtual Circuits Using Permanent Virtual Circuits Permanent virtual circuits (PVCs) are provided by a network provider and are set up during X.25 configuration. Refer to your X.25/9000 User’s Guide for details on configuring PVCs. A PVC is similar to a “leased line” in that it is always connected and terminates at a single destination.
36960-90061.bk Page 46 Friday, November 10, 2000 3:42 PM Establishing and Terminating a Socket Connection Using Permanent Virtual Circuits If the ioctl(X25_SETUP_PVC) call is successful, the socket is bound to the PVC as a dedicated socket. However, there is no guarantee that there is a process running at the other end of the PVC. Applications should send a message to say that they are alive, then wait for a reply from the remote end of the PVC (a “handshake”).
36960-90061.bk Page 47 Friday, November 10, 2000 3:42 PM Establishing and Terminating a Socket Connection Using Permanent Virtual Circuits not exist. ENETDOWN indicates the interface is down because it has been shut down, suffered either a power fail without being reinitialized or incurred a hard error. EINVAL indicates the virtual circuit is illegal or not a PVC. EBUSY indicates that the lci is in use.
36960-90061.
36960-90061.
36960-90061.bk Page 50 Friday, November 10, 2000 3:42 PM Sending and Receiving Data Introduction Introduction This chapter describes how applications can send and receive data on a virtual circuit (VC) socket. It applies equally to SVCs and PVCs.
36960-90061.bk Page 51 Friday, November 10, 2000 3:42 PM Sending and Receiving Data Data Transmission Requirements Data Transmission Requirements Once a VC has been connected, processes on either side of a VC can transmit and receive data freely without distinctions between client and server. An application process can use the send() and write() system calls to transmit data, and the recv() and read() system calls to receive data.
36960-90061.bk Page 52 Friday, November 10, 2000 3:42 PM Sending and Receiving Data Data Transmission Requirements sd Socket descriptor for a connected VC socket. msg Pointer to the buffer containing the data to be transmitted over the VC. Although this is a character buffer, X.25 has no requirement that the data actually be ASCII characters. This is entirely up to the application. len Length of the msg buffer in bytes. flags Indicates the type of data and packet in which to send the data.
36960-90061.bk Page 53 Friday, November 10, 2000 3:42 PM Sending and Receiving Data Data Transmission Requirements int sd; char *buf; int len, flags; count = recv(sd, buf, len, flags); sd Socket descriptor for a connected VC socket. buf Pointer to the buffer which will receive the data message. Although this is a character buffer, X.25 has no requirement that the data actually be ASCII characters. This is entirely up to the application. len Length of buf in bytes.
36960-90061.bk Page 54 Friday, November 10, 2000 3:42 PM Sending and Receiving Data Data Transmission Requirements automatically scattered across several DATA packets as part of the X.25 protocol. Each packet will have its M bit (“More” bit) set, except for the last packet, to indicate that there is at least one more packet to follow. Once the last packet (the one without an M bit) has been received, the message is assembled again. If X.
36960-90061.bk Page 55 Friday, November 10, 2000 3:42 PM Sending and Receiving Data Data Transmission Requirements time in the CALL REQUEST or CALL ACCEPTED packet. Setting the D Bit in CALL REQUEST Packets Use the ioctl(X25_SEND_TYPE) call to set the D bit in a CALL REQUEST packet. After the D bit is set, issue the connect() call to transmit the CALL REQUEST packet.
36960-90061.bk Page 56 Friday, November 10, 2000 3:42 PM Sending and Receiving Data Data Transmission Requirements with a second ioctl(X25_SEND_TYPE) call. Refer to “Controlling the MDTF, D, and Q bits” below for the syntax for ioctl(X25_SEND_TYPE) Detecting D Bit Arrival and Confirmation If you have not set the D bit during connection establishment, you will not be able to determine if the D bit is set on an incoming message with ioctl(X25_NEXT_MSG_STAT) (described later in this chapter).
36960-90061.bk Page 57 Friday, November 10, 2000 3:42 PM Sending and Receiving Data Data Transmission Requirements packets. X.25 applications can control the use of these bits with ioctl(X25_SEND_TYPE). Syntax for ioctl(X25_SEND_TYPE) The syntax for the ioctl(X25_SEND_TYPE) system call and its parameters are described below. Refer also to the socket_x25(7) entry in your HP-UX man pages for more information on ioctl(X25_SEND_TYPE). #include #include
36960-90061.bk Page 58 Friday, November 10, 2000 3:42 PM Sending and Receiving Data Using Nonblocking I/O Using Nonblocking I/O Although sockets are created in blocking I/O mode by default, you can specify that a socket be put in nonblocking I/O mode using the ioctl(FIOSNBIO) call as shown below. The behavior of many system calls changes when the socket is in nonblocking mode. These differences in behaviour are also described in this section.
36960-90061.bk Page 59 Friday, November 10, 2000 3:42 PM Sending and Receiving Data Using Nonblocking I/O are described below: • accept() returns immediately. If there are no connection requests in the listen queue, accept() returns –1 and the EWOULDBLOCK error is contained in errno. If a connection request is present in the listen queue, accept() returns a socket descriptor for the VC. • connect() returns –1 immediately and the EINPROGRESS error is contained in errno.
36960-90061.bk Page 60 Friday, November 10, 2000 3:42 PM Sending and Receiving Data Using Nonblocking I/O the out-of-band queue. The process must not send a second INTERRUPT packet until interrupt confirmation has been received or a reset indication has been received. • ioctl() returns immediately. Most ioctl() values used by X.25 are not directly related to transmiting and receiving packets. The ioctl(X25_RESET_VC) and ioctl(X25_SEND_CALL_ACEPT) calls cause the transmission of packets.
36960-90061.bk Page 61 Friday, November 10, 2000 3:42 PM Sending and Receiving Data Getting Next Message Status Getting Next Message Status You can use the ioctl(X25_NEXT_MSG_STAT) system call to obtain information about the next available message. ioctl(X25_NEXT_MSG_STAT) is almost always used when the ioctl(X25_SET_FRAGMENT_SIZE) is used.
36960-90061.bk Page 62 Friday, November 10, 2000 3:42 PM Sending and Receiving Data Getting Next Message Status status Indicates the current status of the next message. If status.x25_msg_size is 0, there is no message in the queue. Otherwise, it indicates the size of the next message or the next fragment of a message to be read. This is useful to ensure that there is enough buffer space for the next read() system call. The status.
36960-90061.bk Page 63 Friday, November 10, 2000 3:42 PM Sending and Receiving Data Setting Buffer Thresholds and Sizes Setting Buffer Thresholds and Sizes X.25 allows developers to fine-tune socket behavior by specifying certain characteristics such as when a socket allows information to be written to its buffers (is “writable”). This is done by setting the threshold values that control the size of the three socket buffers: outbound message, send, and receive.
36960-90061.bk Page 64 Friday, November 10, 2000 3:42 PM Sending and Receiving Data Setting Buffer Thresholds and Sizes err = ioctl(sd, X25_WR_WTHRESHOLD, &thresh); sd Socket descriptor for a VC socket. X25_WR _WTHRESHOLD Indicates that the write threshold is being changed. thresh New value for the write threshold. err On successful completion, err is set to 0. Otherwise, a value of –1 is returned and errno is set to indicate the error. Setting the Read Message Fragment Size X.
36960-90061.bk Page 65 Friday, November 10, 2000 3:42 PM Sending and Receiving Data Setting Buffer Thresholds and Sizes Syntax for ioctl(X25_SET_FRAGMENT_SIZE) The syntax for the ioctl(X25_SET_FRAGMENT_SIZE) system call and its parameters are described below. #include #include int err; int sd, size; err = ioctl(sd, X25_SET_FRAGMENT_SIZE, &size); sd Socket descriptor for a VC socket.
36960-90061.bk Page 66 Friday, November 10, 2000 3:42 PM Sending and Receiving Data Setting Buffer Thresholds and Sizes optlen = sizeof(int); err = setsockopt(sd, level, optname,(char*) &optval, optlen); sd Socket descriptor for a VC socket. level Indicates the level at which the socket takes effect (this must be set to SOL_SOCKET). optname Indicates the type of option to be modified. This can be SO_SNDBUF to change the size of the send buffer, or SO_RCVBUF to change the size of the receive buffer.
36960-90061.
36960-90061.bk Page 68 Friday, November 10, 2000 3:42 PM Receiving and Transmitting Out-of-band Information Introduction Introduction This chapter describes how to send and receive out-of-band events. Many of the out-of-band events are associated with the arrival or transmission of a particular type of packet. However, in some cases, out-of-band events are independent of the particular packet type.
36960-90061.bk Page 69 Friday, November 10, 2000 3:42 PM Receiving and Transmitting Out-of-band Information Receiving Out-of-band Events Receiving Out-of-band Events Out-of-band events, such as RESET INDICATION, INTERRUPT, and CLEAR INDICATION packets, occur during typical X.25 VC operation. When an out-of-band event occurs, X.25 indicates the event by sending a SIGURG signal and places a description of the event in the out-of-band queue. CAUTION Applications using X.
36960-90061.bk Page 70 Friday, November 10, 2000 3:42 PM Receiving and Transmitting Out-of-band Information Receiving Out-of-band Events */ vec.sv_handler = onurg; vec.sv_mask; = 0 vec.sv_onstack = 0; if (sigvector(SIGURG, &vec, 0) < 0) { perror(”sigvector(SIGURG)”); } In addition to installing the signal handler, you must also call ioctl(SIOCSPGRP) to ensure that the SIGURG signal is delivered when the out-of-bound data is received, as shown in the code example below.
36960-90061.bk Page 71 Friday, November 10, 2000 3:42 PM Receiving and Transmitting Out-of-band Information Building a Signal Handler Building a Signal Handler A signal handler is a routine that is called when a signal arrives. The signal handler executes in the process address space, and all global data items are available to the signal handler. The process is halted while the signal handler executes. When the signal handler returns, the process resumes execution at the point where it was halted.
36960-90061.bk Page 72 Friday, November 10, 2000 3:42 PM Receiving and Transmitting Out-of-band Information Building a Signal Handler Step 3. Get any out-of-band events which may have arrived while the signal handler was executing. No more than one signal of the same type can be blocked while a signal handler is operating. If a second signal arrives, the first is lost. To make sure that no data is lost, once it’s executed the signal handler should get all of the data in the out-of-band queue (i.e.
36960-90061.
36960-90061.bk Page 74 Friday, November 10, 2000 3:42 PM Receiving and Transmitting Out-of-band Information Building a Signal Handler CAUTION If the out-of-band data is not read quickly, the out-of-band data queue could overflow. If the queue overflows, subsequent out-of-band events are discarded. Out-of-band Events There are eight out-of-band (OOB) events which a signal handler can receive. The out-of-band values are defined in x25.h.
36960-90061.bk Page 75 Friday, November 10, 2000 3:42 PM Receiving and Transmitting Out-of-band Information Building a Signal Handler OOB_VC_CLEAR A CLEAR INDICATION packet was received on the VC. The VC is closed and can no longer send or receive data. The OOB_VC_CLEAR is always the last event in the out-of-band queue. You can use the recv(MSG_OOB) call to read out-of-band data that arrived before the CLEAR INDICATION packet.
36960-90061.bk Page 76 Friday, November 10, 2000 3:42 PM Receiving and Transmitting Out-of-band Information Building a Signal Handler OOB_VC_L2DOWN X.25 level 2 is down. This event is returned only on a socket accessing a permanent virtual circuit (PVC). On an SVC, a clear indication is sent. Recover by issuing a close() on the socket, creating another socket with the socket() system call, and binding the new socket to a PVC with the ioctl(X25_SET_PVC) call.
36960-90061.bk Page 77 Friday, November 10, 2000 3:42 PM Receiving and Transmitting Out-of-band Information Building a Signal Handler The first two bytes of buf[] contain the buffer length and the event code respectively. The third byte (buf[2]) contains the cause code. The fourth byte (buf[3]) contains the diagnostic code. If the diagnostic code was not present in the packet, 0 is specified. The fifth byte (buf[4]) contains the reason the RESET INDICATION packet was sent.
36960-90061.bk Page 78 Friday, November 10, 2000 3:42 PM Receiving and Transmitting Out-of-band Information Transmitting Out-of-band Events 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 program requires.
36960-90061.bk Page 79 Friday, November 10, 2000 3:42 PM Receiving and Transmitting Out-of-band Information Transmitting Out-of-band Events settings. Table 5-2 Setting Cause Codes Network Type Cause Specified Cause Sent DTE 84 any as specified DCE (1980 or 1984) any as specified DTE 80 any 0 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.
36960-90061.bk Page 80 Friday, November 10, 2000 3:42 PM Receiving and Transmitting Out-of-band Information Transmitting Out-of-band Events diag Indicates the cause and diagnostic codes to be sent. err On 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 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.
36960-90061.bk Page 81 Friday, November 10, 2000 3:42 PM Receiving and Transmitting Out-of-band Information Transmitting Out-of-band Events * u_char x25_cud_data[X25_MAX_CU_LEN]; * } */ int err; int sd; struct x25_userdata udata; err = ioctl(sd, X25_WR_USER_DATA, &udata); sd Socket descriptor for an VC socket. X25_WR_USER_D Definition for the request. ATA udata Contains the length and the data for the user data field (x25_cud_data). The maximum length is 126 bytes.
36960-90061.bk Page 82 Friday, November 10, 2000 3:42 PM Receiving and Transmitting Out-of-band Information Transmitting Out-of-band Events ioctl(X25_RD_USER_DATA) call sequence to read the call user data 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.
36960-90061.bk Page 83 Friday, November 10, 2000 3:42 PM Receiving and Transmitting Out-of-band Information Transmitting Out-of-band Events struct x25_userdata userdata; struct x25_msg_stat msgstat; unsigned char call_udata[128], clear_udata[128]; int i, call_ndata = 0,clear_ndata = 0, error = 0; while ( !error ) { error = ioctl(s, X25_NEXT_MSG_STAT, &msgstat); if (error< 0 ) { perror(”ioctl(X25_NEXT_MSG_STAT) failed”); exit(1); } if (msgstat.
36960-90061.bk Page 84 Friday, November 10, 2000 3:42 PM Receiving and Transmitting Out-of-band Information Transmitting Out-of-band Events } if (userdata.x25_cud_len == 0) break; for (i = 0; i < userdata.x25_cud_len; i++) clear_udata[clear_ndata++] = userdata.x25_cu_data[i]; } else break; } /* * If error = 0 at this point all of the clear data is now in “clear_udata”. * “clear_ndata” gives the number of bytes of data. */ Resetting a Virtual Circuit This section describes how to send RESET packets.
36960-90061.bk Page 85 Friday, November 10, 2000 3:42 PM Receiving and Transmitting Out-of-band Information Transmitting Out-of-band Events 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.
36960-90061.bk Page 86 Friday, November 10, 2000 3:42 PM Receiving and Transmitting Out-of-band Information Transmitting Out-of-band Events 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).
36960-90061.
36960-90061.bk Page 88 Friday, November 10, 2000 3:42 PM Extended Features Introduction Introduction This section discusses the extended features available through X.25.
36960-90061.bk Page 89 Friday, November 10, 2000 3:42 PM Extended Features Using Facilities Using Facilities X.25 permits the negotiation of facilities that can be implemented when calls are connected or cleared. Facilities are specified in the following packet types: • CALL REQUEST/CALL INDICATION, • CALL ACCEPTED/CALL CONNECTED, • CLEAR REQUEST/CLEAR INDICATION, • CLEAR CONFIRMATION. X.25 includes the default facilities settings specified at configuration time for CALL REQUEST packets.
36960-90061.bk Page 90 Friday, November 10, 2000 3:42 PM Extended Features Using Facilities Flow control negotiation, throughput class negotiation, and fast select/reverse charging are subject to X.25 configuration constraints. Some network providers also place further constraints on the facilities that may be used. The facilities supported for ioctl(X25_RD_FACILITIES) are those described in the CCITT X.25 Recommendation (1988).
36960-90061.bk Page 91 Friday, November 10, 2000 3:42 PM Extended Features Using Facilities sd Socket descriptor for a VC socket that has just received a CALL INDICATION, CALL CONNECTED, or CLEAR INDICATION packet. X25_RD_FACILITIE Definition for the request. S fac_data Indicates the facilities from the packet received. The x25_fac[] field contains the facilities in the format that is required by the X.25 recommendations.
36960-90061.bk Page 92 Friday, November 10, 2000 3:42 PM Extended Features Using Facilities The facilities supported for ioctl(X25_WR_FACILITIES) are those specified in the CCITT and X.25 (1988) recommendation. These include: • Flow Control Parameter Negotiation – if your configuration specifies that flow control negotiation is ON and Flow Control facilities are not requested with the ioctl(X25_WR_FACILITIES) call, your default values for Packet Size and Window Size facilities are inserted in the packet.
36960-90061.bk Page 93 Friday, November 10, 2000 3:42 PM Extended Features Using Facilities facilities markers are those described in the 1988 CCITT X.25 Recommendations and in the 1987 ISO 8208 Standard. Legal facilities markers are: • 0x000f – for CCITT specified DTE facilities used to support the OSI Network service. • 0x0000 – for non-X.25 facilities supported by the local network for an internal network call, or for non-X.
36960-90061.bk Page 94 Friday, November 10, 2000 3:42 PM Extended Features Using Facilities fac_data Indicates the facilities to be included in the CALL REQUEST, CALL ACCEPTED, or CLEAR REQUEST packet. The x25_fac[] field contains the facilities in the exact format that is required by the X.25 recommendations.
36960-90061.bk Page 95 Friday, November 10, 2000 3:42 PM Extended Features Using Fast Select Using Fast Select The use of fast select in X.25 is described in X.25: The PSN Connection. This section describes how to access this facility through X.25. The fast select facility lets processes specify up to 128 bytes of call user data in the CALL REQUEST, CALL ACCEPTED, and CLEAR REQUEST packets.
36960-90061.bk Page 96 Friday, November 10, 2000 3:42 PM Extended Features Using Fast Select specified in separate ioctl() calls or combined into one, but the protocol ID must come first. Remember that the protocol ID length is not defined by the CCITT. Developers of the two processes must agree on the number of bits of the call user data field to use for the protocol ID before connection establishment begins.
36960-90061.bk Page 97 Friday, November 10, 2000 3:42 PM Extended Features Using Fast Select Fast Select Operation Summary A server can respond to a fast select call in any of three ways: • The call can be cleared immediately with no data • The call can be cleared with user data specified • A normal VC can be established with or without user data specified in the call accept packet Which of these alternatives are available depends on the design of the client and server processes.
36960-90061.bk Page 98 Friday, November 10, 2000 3:42 PM Extended Features Using Fast Select Step 10. The server's accept() call unblocks when it receives the CALL INDICATION packet. Step 11. The server reads and parses the facilities field. Step 12. The server reads and interprets the user data field. Table 6-1 Steps for Fast Select 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.
36960-90061.bk Page 99 Friday, November 10, 2000 3:42 PM Extended Features Using Fast Select which are discussed individually in the next three subsections. Clearing a fast select call immediately If the server detects that it cannot handle the fast select call for any reason, it can clear the circuit immediately. The steps for clearing the circuit are described below and in Table 6-2, “Clearing a Fast Select Call Immediately.
36960-90061.bk Page 100 Friday, November 10, 2000 3:42 PM Extended Features Using Fast Select appropriate actions. Table 6-3 Sending Clear User Data for a Fast Select Server Events X.25 Events Client Events 1. ioctl(X25_WR_USER_DATA) No event No event 2. close() CLEAR REQUEST packet transmitted No event 3.
36960-90061.bk Page 101 Friday, November 10, 2000 3:42 PM Extended Features Using Fast Select Table 6-4 Fast Select Connection Establishment 2. ioctl(X25_SEND_CALL_ACEPT) CALL ACCEPTED packet transmitted No event 3. No event CALL INDICATION packet received connect() unblocks (returns 0) 4. read() and write() DATA packets transmitted and received read() and write() 5.
36960-90061.bk Page 102 Friday, November 10, 2000 3:42 PM Extended Features Reestablishing Terminated Connections Reestablishing Terminated Connections Maintaining a connection over an X.25 network may not suit all applications. For example, a client may send a request to a server that may require processing for an extended period of time before a reply can be sent. It would not be economical to maintain the connection until data processing has been completed.
36960-90061.bk Page 103 Friday, November 10, 2000 3:42 PM Extended Features Reestablishing Terminated Connections X25_WR_CALLIN G _SUBADDR The definition for the request. subaddr Indicates the subaddress to be added to the calling address field in the CALL REQUEST packet. Only the x25_family, x25hostlen, and x25_host from the x25addrstr structure are used. The x25hostlen field contains only the subaddress to be added to the calling address field. The rest of the address is supplied by X.25.
36960-90061.bk Page 104 Friday, November 10, 2000 3:42 PM Extended Features Getting Programmatic Diagnostics and Status Information Getting Programmatic Diagnostics and Status Information Diagnostic and status information for applications that use X.25 programmatic access can be obtained using the following features: • Error codes and log messages. • The ioctl(X25_RD_CTI) call (to get the circuit table index entry associated with a particular socket).
36960-90061.bk Page 105 Friday, November 10, 2000 3:42 PM Extended Features Getting Programmatic Diagnostics and Status Information information concerning the VC. The cti is also useful for network logging. EINVAL is returned if the circuit is not connected or if the socket is no longer bound to a circuit. For details on logging, see your X.25/9000 User’s Guide. Syntax for ioctl (X25_RD_CTI) #include #include
36960-90061.bk Page 106 Friday, November 10, 2000 3:42 PM Extended Features Getting Programmatic Diagnostics and Status Information int sd, lci; err = ioctl(sd, X25_RD_LCI, &lci); sd Socket descriptor for a connected VC socket. X25_RD_LCI Definition for the request. lci Contains the logical channel indicator for the socket. err Set to 0 if the call was successful. Otherwise, contains –1 and errno contains the cause of the error.
36960-90061.bk Page 107 Friday, November 10, 2000 3:42 PM Extended Features Getting Programmatic Diagnostics and Status Information down. X25_RD_HOSTAD R Definition for the request. addr Indicates the X.25 interface name. x25_family must be set to AF_CCITT. x25ifname must be set to a name string (with “\0” at the end). The address is returned in x25hostl() and x25hostlen.
36960-90061.bk Page 108 Friday, November 10, 2000 3:42 PM 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.
36960-90061.bk Page 109 Friday, November 10, 2000 3:42 PM Extended Features Getting Programmatic Diagnostics and Status Information Syntax for getpeername() getpeername() and its parameters are described below. #include #include #include int error; int sd, addrlen; struct x25addrstr addr; addrlen = sizeof(struct x25addrstr); error = getpeername(sd, &addr, addrlen); sd Socket descriptor for the socket whose peer address will be returned.
36960-90061.bk Page 110 Friday, November 10, 2000 3:42 PM Extended Features Getting Programmatic Diagnostics and Status Information returned. addr If the call completes successfully, this x25addrstr structure contains the X.121 address specified by the remote process to make the connection. This information is useful when using wildcard addressing. addrlen If the call completes successfully, addrlen contains the length in bytes of the x25addrstr structure pointed to by addr.
36960-90061.bk Page 111 Friday, November 10, 2000 3:42 PM A X.
36960-90061.bk Page 112 Friday, November 10, 2000 3:42 PM X.25 Packet Formats Introduction Introduction This appendix describes some of the packet formats specified in the CCITT X.25 Recommendations. It also describes the X.25 actions required to transmit the packet and the X.25 events that occur when the packet is received.
36960-90061.bk Page 113 Friday, November 10, 2000 3:42 PM X.25 Packet Formats CALL REQUEST/INDICATION Packet CALL REQUEST/INDICATION Packet A client process sends a CALL REQUEST packet to establish a VC with a remote host. The packet is transmitted when a connect() system call is issued. When the X.
36960-90061.bk Page 114 Friday, November 10, 2000 3:42 PM X.25 Packet Formats CALL REQUEST/INDICATION Packet This field cannot be read by the application. To write this field on an outgoing packet: X.25 700/800 applications use the ioctl(X25_SEND_TYPE)call to set the D bit. Logical Channel Identifier Associates a logical channel number with the VC. This field is controlled by the X.25 subsystem. It can be read with ioctl(X25_RD_LCI) after the call has been established.
36960-90061.bk Page 115 Friday, November 10, 2000 3:42 PM X.25 Packet Formats CALL REQUEST/INDICATION Packet To write this field on an outgoing packet: The subsystem computes this field from the x25addrstr returned in the connect() system call. Facilities (Length) Optional. Indicates the facilities used for this VC. To read this field on an incoming packet: Use ioctl(X25_RD_FACILITIES) to read this field. To write this field on an outgoing packet: Use ioctl(X25_WR_FACILITIES) to write this field.
36960-90061.bk Page 116 Friday, November 10, 2000 3:42 PM X.25 Packet Formats CALL ACCEPTED/CONNECTED Packet CALL ACCEPTED/CONNECTED Packet A CALL ACCEPTED/CONNECTED packet establishes a VC with a remote host. A CALL ACCEPTED packet is sent in response to a CALL INDICATION packet. Typically, the X.25 subsystem sends a CALL ACCEPTED packet immediately in response to a CALL INDICATION packet when an accept system call is issued on a listen socket.
36960-90061.bk Page 117 Friday, November 10, 2000 3:42 PM X.25 Packet Formats CALL ACCEPTED/CONNECTED Packet where this information can be posted. To read this field on an incoming packet: This field cannot be read by the application. To write this field on an outgoing packet: X.25/800 applications use the ioctl(X25_SEND_TYPE) call to set the D bit. Logical Channel Identifier Associates a logical channel number with the VC. This field is controlled by the X.25 subsystem.
36960-90061.bk Page 118 Friday, November 10, 2000 3:42 PM X.25 Packet Formats CALL ACCEPTED/CONNECTED Packet The X.25 subsystem computes this field from the information supplied in the CALL REQUEST packet. Facilities (Length) Optional. Indicates the facilities used for this VC. To read this field on an incoming packet: This field can be read using ioctl(X25_RD_FACILITIES). To write this field on an outgoing packet: Use ioctl(X25_WR_FACILITIES) prior to issuing an ioctl(X25_SEND_CALL_ACEPT) call.
36960-90061.bk Page 119 Friday, November 10, 2000 3:42 PM X.25 Packet Formats CLEAR REQUEST/INDICATION Packet CLEAR REQUEST/INDICATION Packet A client process sends a CLEAR REQUEST/INDICATION packet to terminate an SVC with a remote host. The subsystem sends a CLEAR REQUEST/INDICATION packet when a close or shutdown() system call is issued.
36960-90061.bk Page 120 Friday, November 10, 2000 3:42 PM X.25 Packet Formats CLEAR REQUEST/INDICATION Packet Packet Type Identifier Indicates the kind of packet. This field cannot be read or written directly, but through system calls CLEAR REQUEST/INDICATION packets can be transmitted or detected. To read this field on an incoming packet: recv(MSG_OOB) returns a buffer the second byte of which (buf[1]) will contain OOB_VC_CLEAR if a CLEAR INDICATION packet was received.
36960-90061.bk Page 121 Friday, November 10, 2000 3:42 PM X.25 Packet Formats CLEAR REQUEST/INDICATION Packet To write this field on an outgoing packet: The X.25 subsystem computes this field. Facilities (Length) Optional. Indicates the facilities used for this VC. To read this field on an incoming packet: Use ioctl(X25_RD_FACILITIES) to read this field. To write this field on an outgoing packet: Use ioctl(X25_WR_FACILITIES) to write this field. Call User Data Optional.
36960-90061.bk Page 122 Friday, November 10, 2000 3:42 PM X.25 Packet Formats DATA Packet DATA Packet A client process sends a DATA packet to terminate an SVC with a remote server. The subsystem sends a DATA packet when a send() or write() system call is issued.
36960-90061.bk Page 123 Friday, November 10, 2000 3:42 PM X.25 Packet Formats DATA Packet Receive Sequence Indicates the sequence number of the last packet received. It is Number controlled by the subsystem and cannot be read or written by the application. M Bit Indicates that the packet is part of a group of packets (a message).
36960-90061.bk Page 124 Friday, November 10, 2000 3:42 PM X.25 Packet Formats INTERRUPT Packet INTERRUPT Packet A application process sends an INTERRUPT packet to transmit out-of-band data to the remote process.
36960-90061.bk Page 125 Friday, November 10, 2000 3:42 PM X.25 Packet Formats INTERRUPT Packet When the SIGURG signal handler is called, issue a recv() system call with the MSG_OOB flag set. To write this field on an outgoing packet: Use the send() system call with the MSG_OOB flag set to transmit an INTERRUPT packet and specify the interrupt user data field.
36960-90061.bk Page 126 Friday, November 10, 2000 3:42 PM X.25 Packet Formats INTERRUPT CONFIRMATION Packet INTERRUPT CONFIRMATION Packet This packet is transmitted automatically by the X.25/800 subsystem when an INTERRUPT packet is received. The X.25/800 subsystem transmits this packet when the application process reads the interrupt data (issues a recv(MSG_OOB) system call).
36960-90061.bk Page 127 Friday, November 10, 2000 3:42 PM X.25 Packet Formats INTERRUPT CONFIRMATION Packet data field is read with a recv(MSG_OOB) system call.
36960-90061.bk Page 128 Friday, November 10, 2000 3:42 PM X.25 Packet Formats RESET REQUEST/INDICATION Packet RESET REQUEST/INDICATION Packet A process sends a RESET REQUEST packet to reset a VC. The subsystem sends a RESET REQUEST when a close() or shutdown() system call is issued on a PVC.
36960-90061.bk Page 129 Friday, November 10, 2000 3:42 PM X.25 Packet Formats RESET REQUEST/INDICATION Packet To read this field on an incoming packet: recv(MSG_OOB) returns a buffer the third byte of which (buf[2]) contains the resetting cause field. To write this field on an outgoing packet: Use an ioctl(X25_WR_CAUSE_DIAG) call before the ioctl(X25_RESET_VC) call is issued. Diagnostic Code Contains the diagnostic code for the RESET REQUEST/INDICATION packet.
36960-90061.bk Page 130 Friday, November 10, 2000 3:42 PM X.25 Packet Formats RESET CONFIRMATION Packet RESET CONFIRMATION Packet A RESET CONFIRMATION packet is automatically generated by the subsystem when the application process reads the reset data (issues a recv(MSG_OOB) system call).
36960-90061.bk Page 131 Friday, November 10, 2000 3:42 PM X.25 Packet Formats RESET CONFIRMATION Packet The X.25/800 subsystem transmits an RESET CONFIRMATION packet when the corresponding RESET packet's reset user data field is read with a recv(MSG_OOB) system call.
36960-90061.bk Page 132 Friday, November 10, 2000 3:42 PM X.
36960-90061.
36960-90061.bk Page 134 Friday, November 10, 2000 3:42 PM Program Examples Example Programs Example Programs Several pairs of example programs are shipped with the X.25 product. These programs can be found in the /var/x2r/netdemo directory. Table B-1 Program name Purpose client.c /server.c Send/receive one message of data, no out-of-band signal handling. For Switched Virtual Circuits only. client2.c /server2.
36960-90061.bk Page 135 Friday, November 10, 2000 3:42 PM Index A accept(), 31 and nonblocking I/O, 59 parameters, 31 syntax, 31 accepting a connection, 31 address binding, 28 address family, 28, 35 address matching binding, 28 addresses X.
36960-90061.
36960-90061.
36960-90061.
36960-90061.