Solstice X.25 9.2 Developer's Guide

12.3.8 Explicit Link Selection--Calling Side

As discussed in a previous subsection, Solstice X.25 automatically selects a link for an outgoing call if so requested by the caller. If you do nothing to call automatic link selection into play, the call is sent over the lowest numbered WAN link by default. The calling side can override automatic link selection, and specify a desired link using the X25_SET_LINK ioctl:

int s, error;
 int linkid;        /* id of desired link for outgoing call */
 CONN_DB addr;      /* destination address */
 linkid = 3;        /* want to send call over link 3 */
 error = ioctl(s, X25_SET_LINK, &linkid);

 /* check error here */

 error = connect(s, &addr, sizeof(addr));

Note that a full X.121 address must be specified (and so indicated by setting the ANY_LINK bit as described earlier) if you want Solstice X.25 to process the address as required by the PSDN, using the parameters specified in the link configuration file. Otherwise, the address set in the Call Request packet will be exactly what you specified, and so you must take care to provide the address in exactly the form required by the PSDN.

Since setting the link prevents Solstice X.25 from consulting the routing table, all the information required to establish connection with the remote user must be provided. For example, if the link selected supports 1984 X.25, Called and Calling AEFs may be required. If the link selected is a LAN interface, the LSAP address of the remote user must be provided. This is done as follows:

typedef struct {
    u_char   lsel;
    u_char   maclen;
 #define MACADDR_LEN   6
    u_char   macaddr[MACADDR_LEN];
 } X25_MACADDR;

 X25_MACADDR dst_mac;         /* LSAP address */
 int s;                        /* socket */

 /* set the lsel, maclen and macaddr fields here */

 error = ioctl(s, X25_WR_MACADDR, &dst_mac);

If the lsel field is set to zero, Solstice X.25 will use the value specified in the link configuration file. After connection is established, the LSAP address of the remote user can be read using the X25_RD_MACADDR command:

X25_MACADDR dst_mac;         /* LSAP address */
 int s;                       /*socket */

 error = ioctl(s, X25_RD_MACADDR, &dst_mac);