Solstice X.25 provides a library of functions that can be used in applications.
Many of the functions make use of the padent and xhostent structures, they are therefore described first. A description of the functions follows, in alphabetical order. The tables below group the functions together according to function. The PAD and xhosts related functions are based on similar functions that are available with IP.
The support library for use on 32-bit systems resides in /opt/SUNWconn/x25/lib/libsx25.so. To link against it, use a command like this:
hostname% cc -o test test.c -L /opt/SUNWconn/x25/lib -R /opt/SUNWconn/x25/lib -lsx25 |
The support library for use on 64-bit systems resides in /opt/SUNWconn/x25/lib/sparcv9/libsx25.so. To link against it, use a command like this:
hostname% cc -o test test.c -L /opt/SUNWconn/x25/lib -R /opt/SUNWconn/x25/lib -lsx25 |
The header files used by the NLI support functions are contained in the /usr/include/netx25 directory.
These functions are related to the PAD Hosts Database:
Table 8-1 PAD related functions
function |
description |
---|---|
endpadent |
closes the PAD Hosts Database |
getpadbyaddr |
finds the PAD Hosts Database entry for a given address |
getpadent |
reads the next line in the PAD Hosts Database |
padtos |
converts a network PAD Hosts Database structure into a string |
setpadent |
opens and rewinds the PAD Hosts Database |
These entries are related to the xhosts file:
Table 8-2 xhosts functions
function |
description |
---|---|
endxhostent |
closes the xhosts file |
getxhostbyaddr |
finds an entry in the xhosts file by address |
getxhostbyname |
finds an entry in the xhosts by name |
getxhostent |
reads the next line of the xhosts file |
setxhostent |
opens and rewinds the xhosts file |
These functions are related to X.25 addressing:
Table 8-3 X.25 addressing functions
function |
description |
---|---|
equalx25 |
compares two X.25 addresses |
stox25 |
converts an X.25 dot format address to an X.25 xaddrf structure |
x25tos |
converts an X.25 xaddrf structure to an X.25 dot format address |
These functions are related to configuration files:
Table 8-4 Configuration file functions
function |
description |
---|---|
x25_find_link_parameters |
finds link configuration files and builds a linked list of links. |
x25_read_config_parameters |
reads a configuration files into a data structure by link number |
x25_read_config_parameters_file |
reads a configuration file into a data structure by filename |
x25_save_link_parameters |
updates the configuration files |
x25_write_config_parameters |
writes a data structure into a configuration file identified by a link number |
x25_write_config_parameters_file |
writes a data structure into a configuration file identified by a filename |
x25_set_parse_error_function |
installs a function as the default error handler. |
These functions are related to links:
Table 8-5 Link functions
function |
description |
---|---|
getnettype |
returns the type of network configured for a link |
linkidtox25 |
converts a character format link identifier to numeric format |
x25tolinkid |
converts a numeric link identifier to a string |
The padent structure is defined in the /usr/include/netx25/xnetdb.h file. It has this format:
struct padent { struct xaddrf xaddr; unsigned char x29; struct extraformat xtras; unsigned char cud[MAxnetdb.hXCUDFSIZE + 1]; };
The padent structure contains a single entry from the /etc/SUNWconn/x25/padmapconf file. This contains information about facilities and so on to be used when making PAD calls to a particular address.
The members of the padent structure are:
Table 8-6 Members of padent structure
Member |
Description |
---|---|
xaddr |
The hosts X.25 address. |
x29 |
The X.29 version specifier. Possible values are: 0--use the configured default X.29 address 1--use X.29(80) yellow book 2--use X.29(84) red book 3--use X.29(88) blue book |
xtras |
Any facilities and QOS parameters defined for this entry |
cud |
Any Call User Data defined for this entry. |
The xhostent structure is defined in the /usr/include/netx25/xnetdb.h file. It has this format:
struct xhostent { char *h_name; char **h_aliases; int h_addrtype; int h_length; char *h_addr; };
The xhostent structure contains a single entry from the xhosts file. This contains information mapping host names to X.25 addresses and is used when making PAD calls. By default this file is in the /etc/SUNWconn/x25 directory.
The members of the structure are:
Table 8-7 Members of xhostent structure
Member |
Description |
---|---|
h_name |
A pointer to the name of the X.25 host, as defined in the xhosts file. |
h_aliases |
A pointer to an array of character pointers that point to aliases for the X.25 host. |
h_addrtype |
The type of address being returned. This is always CCITT_X25. |
h_length |
The length in bytes of the structure that contains the X.25 address. |
h_addr |
A pointer to an xaddrf structure containing the network address of the X.25 host. |
#include <netx25/x25_proto.h> #include <netx25/xnetdb.h> endpadent()
endpadent closes the PAD Hosts Database.
endpadent does not take any parameters.
#include <netx25/x25_proto.h> #include <netx25/xnetdb.h> endxhostent()
endxhostent closes the xhosts file. By default, this file is located in the /etc/SUNWconn/x25/ directory.
There are no parameters.
This function has no return values.
#include <netx25/x25_proto.h> #include <netx25/x25db.h> int equalx25 ( struct xaddrf *x1, struct xaddrf *x2 );
Compares two X.25 addresses by checking to see whether the two xaddrf structures holding them are the same.
The members of the structure are:
Table 8-8 Members of xaddrf structure
Member |
Description |
---|---|
x1 |
A pointer to the structure containing the first X.25 address for checking. |
x2 |
A pointer to the structure containing the second X.25 address for checking. |
Returns 1 if the two structures are the same, and 0 if they are not.
#include <netx25/x25_proto.h> #include <netx25/xnetdb.h> int getnettype ( unsigned char *linkid );
Determines the type of network referred to by a particular link identifier.
The parameters are:
Table 8-9 getnettype parameters
Parameter |
Description |
---|---|
linkid |
A pointer to the link identifier. |
A negative value indicates an invalid link identifier. The possible network types are:
Table 8-10 Network Type
return value |
network type |
---|---|
LAN |
local area network |
W80 |
wide area network conforming to 1980 X.25 |
W84 |
wide area network conforming to 1984 X.25 |
W88 |
wide area network conforming to 1988 X.25 |
MLPn |
A multi-link connection with n links. |
#include <netx25/x25_proto.h> #include <netx25/xnetdb.h> struct padent * getpadbyaddr( char *addr );
getpadbyaddr returns a pointer to the padent structure, containing the entry from the PAD Hosts Database for the specified address. See "8.3 The padent Structure" for a description of the padent structure.
The parameters are:
Table 8-11 getpadbyaddr parameters
Parameter |
Description |
---|---|
addr |
A pointer to a structure containing the address of the host whose database entry you want. |
getpadbyaddr returns a pointer to static storage. You must copy the value in order to keep and reuse it. A return value of 0 indicates that no match was found.
#include <netx25/x25_proto.h> #include <netx25/xnetdb.h> struct padent *getpadent( )
The getpadent subroutine returns a pointer to a padent structure, which contains the next entry from the PAD Hosts Database. If necessary getpadent opens the file.
There are no parameters.
A return value of 0 indicates an error.
#include <netx25/x25_proto.h> #include <netx25/xnetdb.h> struct xhostent *getxhostbyaddr( char *addr, int len, int type );
getxhostbyaddr searches the xhosts file for an entry with a matching X.25 host address. By default, this file is located in the /etc/SUNWconn/x25 directory. It returns a pointer to a xhostent structure containing information on the entry.
The parameters are:
Table 8-12 getxhostbyaddr parameters
Parameter |
Description |
---|---|
addr |
A pointer to an xaddrf structure containing the address of the host whose entry you want. |
len |
The length in bytes of addr. |
type |
The address type required. This is always CCITT_X25. |
getxhostbyaddr returns a pointer to static storage. You must copy the value in order to keep and reuse it. A return value of 0 indicates the address supplied is either invalid or unknown.
#include <netx25/x25_proto.h> #include <netx25/xnetdb.h> struct xhostent *getxhostbyname( char *name );
getxhostbyname searches the xhosts file for an entry with a matching host name.By default, this file is located in the /etc/SUNWconn/x25 directory. It returns a pointer to a xhostent structure containing information on the entry.
The parameters are:
Table 8-13 getxhostbyname parameters
Parameter |
Description |
---|---|
name |
A pointer to the address of a string containing the name of the host whose entry you want. |
A pointer to the xhostent structure. A return value of 0 indicates the name supplied is either invalid or unknown.
#include <netx25/x25_proto.h> #include <netx25/xnetdb.h> struct xhostent *getxhostent( );
getxhostent reads the next line of the /etc/SUNWconn/x25/hosts file. It opens the file if necessary.
There are no parameters.
A pointer to an xhostent structure. A return value of 0 indicates an error.
#include <netx25/x25_proto.h> #include <netx25/xnetdb.h> uint32_t linkidtox25(linkid) unsigned char *linkid;
Converts a character string link identifier to the numeric format used in X.25 primitives, with a range of 0 - 254.
The parameters are:
Table 8-14 linkidtox25 parameters
Parameter |
Description |
---|---|
str_linkid |
A pointer to the string containing the character format link id. |
On success 0 is returned. On failure the value of MAX_LINKID is returned. By default, this is 255.
#include <netx25/x25_proto.h> #include <netx25/xnetdb.h> int padtos ( struct padent *p, unsigned char *strp );
Converts a PAD structure into a string containing all the facilities, CUGs, RPOAs and call user data defined in the PAD structure. The validity of the structure is checked before conversion.
The parameters are:
Table 8-15 padtos parameters
Parameter |
Description |
---|---|
p |
A pointer to the padent structure for conversion. |
strp |
A pointer to the character string that will hold the result. |
The character string pointed to by strp takes this format:
~CUD facilities year CUG RPOA
All of the values are optional:
Table 8-16 strp character string values
Value |
Description |
---|---|
CUD |
Call User Data. This is always preceded by a tilde (~). |
Facilities |
Holds the values for packet size, window size, fast select and reverse charging. |
Year |
Possible values are 80, 84 and 88. These correspond to the X.29(80) Yellow Book, X.29(84) Red Book and X.29(88) Blue Book. |
CUG |
Specifies any call user groups that apply to this call. Preceded by g, G, b or B. b and B signify bilateral CUGs. |
RPOA |
Signifies any Recognized Private Operating Agency. Always preceded by T or t. |
For example this string:
~hello p7/9w4/2fr 80 B1234 T5678
has the following meaning:
The CUD is hello. There is a local-to-remote packet size of 7 a remote-to-local packet size of 9, a local-to-remote window size of 4 a remote -to-local window size of 2. Fast select and reverse charging are set. The X.29(80) Yellow Book recommendation is being used. The bilateral CUG is 1234 and the RPOA is 5678.
On success this function returns 0. A negative return value indicates that the pad structure was invalid.
#include <netx25/x25_proto.h> #include <netx25/xnetdb.h> void setpadent( int stayopen );
setpadent opens and rewinds the PAD Hosts Database.
The parameters are:
Table 8-17 setpadent parameters
Parameter |
Description |
---|---|
stayopen |
If this is set to 0, the PAD Hosts Database is closed after each getpadent call. Otherwise, the PAD Hosts Database is not closed. |
#include <netx25/x25_proto.h> #include <netx25/xnetdb.h> void setxhostent( int stayopen );
setxhostent opens the xhosts file and rewinds it. By default, this file is located in the /etc/SUNWconn/x25 directory.
The parameters are:
Table 8-18 setxhostent parameters
Parameter |
Description |
---|---|
stayopen |
Determines whether the file is closed once it has been rewound. 0 indicates the file is to be closed. |
#include <netx25/x25_proto.h> #include <netx25/x25db.h> int stox25 ( unsigned char *cp, /* X.25 dot format address */ struct xaddrf *xad, /* The returned structure */ int lookup );
Converts an X.25 format address into an xaddrf structure. Can also be used as a validity check for X.25 addresses.
The parameters are:
Table 8-19 stox25 parameters
Parameter |
Description |
---|---|
cp |
Points to a character string containing the X.25 address for conversion. |
xad |
Points to the xaddrf structure containing the X.25 dot format address. |
lookup |
Determines the level of address checking carried out before the address is converted. 0 indicates no address checking is carried out. This allows for faster conversion, but means the address may not be valid for the type of network it is used on. A non-zero value means that the address format is checked with the configuration file for the link. |
0 indicates successful completion. A negative return value indicates that the X.25 address was invalid.
#include <netx25/x25_proto.h> #include <netx25/x25db.h> #include <netx25/config_functions.h> int x25_find_link_parameters ( struct link_data ** lptr );
This function scans the directory containing the X.25 configuration files and builds a linked list of data structures.
The members of the structure are:
Table 8-20 Members of link_data structure
Member |
Description |
---|---|
lptr |
Points to the address of a pointer to a link_data structure. Memory for these structures is dynamically allocated using calloc(). |
Returns 0 on success.
#include <netx25/x25_proto.h> #include <netx25/xnetdb.h> #include <netx25/config_functions.h> int x25_read_config_parameters ( int linkid struct config_ident *ipt, struct LINK_config_data *lpt, struct X25_config_data *xpt, struct MLP_config_data *mpt, struct LAPB_config_data *lbp, struct LLC2_config_data *l2p, struct WAN_config_data *wpt, int *flags );
x25_read_config_parameters reads the configuration file for the specified link into a data structure.
The parameters are:
Table 8-21 read_confing_parameters parameters
Parameter |
Description |
---|---|
linkid |
The identifier of the link concerned. |
ipt |
A pointer to the config_ident structure containing the link identifier. Setting this variable is mandatory. |
lpt |
A pointer to the link_item structure containing link information. Setting this variable is mandatory. |
xpt |
A pointer to the wlcfg structure containing the layer 3 (X.25) parameters. If you set this variable to NULL, information on these parameters is omitted. |
mpt |
A pointer to the mlp_item structure containing the MLP parameters. If you set this variable to NULL, information on these parameters is omitted. As the number of devices required by an MLP link is unknown, this routine allocates memory as required using calloc(). |
lbp |
A pointer to the lliun_t structure containing the layer 2 LAPB parameters. If you set this variable to NULL, information on these parameters is omitted. |
l2p |
A pointer to the lliun_t structure containing the LLC2 parameters. If you set this variable to NULL, information on these parameters is omitted. |
wpt |
A pointer to the wan_tnioc structure containing the layer 1 (physical) parameters. If you set this variable to NULL, information on these parameters is omitted. |
flag |
Indicates whether data is being read for LLC2, LAPB or MLP. |
A return value of 0 indicates success.
#include <netx25/x25_proto.h> #include <netx25/xnetdb.h> #include <netx25/config_functions.h> int X25_read_config_parameters_file ( char filename struct config_ident *ipt, struct LINK_config_data *lpt, struct X25_config_data *xpt, struct MLP_config_data *mpt, struct LAPB_config_data *lbp, struct LLC2_config_data *l2p, struct WAN_config_data *wpt, int *flag );
x25_read_config_parameters reads the specified configuration file into a data structure.
The parameters are:
Table 8-22 x25_read_config_parameters_file parameters
Parameter |
Description |
---|---|
filename |
The name of the file concerned. |
ipt |
A pointer to the config_ident structure containing the link identifier. Setting this variable is mandatory. |
lpt |
A pointer to the link_item structure containing link information. Setting this variable is mandatory. |
xpt |
A pointer to the wlcfg structure containing the layer 3 (X.25) parameters. If you set this variable to NULL, information on these parameters is omitted. |
mpt |
A pointer to the mlp_item structure containing the MLP parameters. If you set this variable to NULL, information on these parameters is omitted. As the number of devices required by an MLP link is unknown, this routine allocates memory as required using calloc(). |
lbp |
A pointer to the lliun_t structure containing the layer 2 LAPB parameters. If you set this variable to NULL, information on these parameters is omitted. |
l2p |
A pointer to the lliun_t structure containing the LLC2 parameters. If you set this variable to NULL, information on these parameters is omitted. |
wpt |
A pointer to the wan_tnioc structure containing the layer 1 (physical) parameters. If you set this variable to NULL, information on these parameters is omitted. |
flag |
Indicates whether data is being read for LLC2, LAPB or MLP. |
A return value of 0 indicates success.
#include <netx25/x25_proto.h> #include <netx25/x25db.h> #include <netx25/config_functions.h> int x25_save_link_parameters ( struct link_data * linkid );
This function takes the information in the LINK_config_data structures and updates the X.25 configuration files as necessary.
The parameters are:
Table 8-23 x25_save_link_parameters parameters
Parameter |
Description |
---|---|
linkid |
A pointer to the address of a link_data structure, which is the first in a linked list. |
Returns 0 on success.
#include <netx25/config_functions.h> int (*x25_set_parse_error_function(int (*func)(char *)))(char *)
By default, errors are handled by printing a message to stderr and continuing. The x25_set_parse_error_function function allows a different function to be installed for use, for example with windowing programs.
The parameters are:
Table 8-24 x25_set_parse_error_function parameter
Parameter |
Description |
---|---|
func |
A pointer to a function which is installed as the default error handler. This function will be called with a single argument, a pointer to the error string. If this is set to NULL, the default action if restored. |
The address of the previous error function is returned.
#include <netx25/x25_proto.h> #include <netx25/xnetdb.h> #include <netx25/config_functions.h> int x25_write_config_parameters (struct config_ident *idptr, struct LINK_config_data *ptr, struct X25_config_data *xptr, struct MLP_config_data *mptr, struct LAPB_config_data *lbptr, struct LLC2_config_data *l2ptr, struct WAN_config_data *wptr);
x25_write_config_parameters writes the specified data structure(s) into a configuration file identified by the number of the link it configures.
The parameters are:
Table 8-25 x25_write_config_parameters parameters
Parameters |
Description |
---|---|
idptr |
A pointer to the config_ident structure containing the link identifier. Setting this variable is mandatory. |
ptr |
A pointer to the link_item structure containing link information. Setting this variable is mandatory. |
xptr |
A pointer to the wlcfg structure containing the layer 3 (X.25) parameters. This parameter is mandatory. |
mptr |
A pointer to the mlp_item structure containing the MLP parameters. If you set this variable to NULL, information on these parameters is omitted. |
lbptr |
A pointer to the lliun_t structure containing the layer 2 LAPB parameters. If you set this variable to NULL, information on these parameters is omitted. |
l2ptr |
A pointer to the lliun_t structure containing the LLC2 parameters. If you set this variable to NULL, information on these parameters is omitted. |
wptr |
A pointer to the wan_tnioc structure containing the layer 1 (physical) parameters. If you set this variable to NULL, information on these parameters is omitted. |
A return value of 0 indicates success.
#include <netx25/x25_proto.h> #include <netx25/xnetdb.h> #include <netx25/config_functions.h> int x25_write_config_parameter_file (char *infname, struct config_ident *idptr, struct LINK_config_data *ptr, struct X25_config_data *xptr, struct MLP_config_data *mptr, struct LAPB_config_data *lbptr, struct LLC2_config_data *l2ptr, struct WAN_config_data *wptr);
x25_write_config_parameters_file writes the specified data structure(s) into a configuration file identified by its filename.
Parameter |
Description |
---|---|
filename |
The name of the file to contain the data structure. |
idptr |
A pointer to the config_ident structure containing the link identifier. Setting this variable is mandatory. |
ptr |
A pointer to the link_item structure containing link information. Setting this variable is mandatory. |
xptr |
A pointer to the wlcfg structure containing the layer 3 (X.25) parameters. This parameter is mandatory. |
mptr |
A pointer to the mlp_item structure containing the MLP parameters. If you set this variable to NULL, information on these parameters is omitted. |
lbptr |
A pointer to the lliun_t structure containing the layer 2 LAPB parameters. If you set this variable to NULL, information on these parameters is omitted. |
l2ptr |
A pointer to the lliun_t structure containing the LLC2 parameters. If you set this variable to NULL, information on these parameters is omitted. |
wptr |
A pointer to the wan_tnioc structure containing the layer 1 (physical) parameters. If you set this variable to NULL, information on these parameters is omitted. |
A return value of 0 indicates an error.
#include <netx25/x25_proto.h> #include <netx25/xnetdb.h> int x25tolinkid(linkid, str_linkid) uint32_t linkid; unsigned char *str_linkid;
Converts a link identifier of the numeric format used in X.25 primitives to a character string.
The parameters are:
Table 8-27 x25tolinkid parameters
Parameters |
Description |
---|---|
linkid |
The numeric format link identifier. |
str_linkid |
A pointer to the string that is to contain the character format link identifier |
On success 0 is returned. On failure -1 is returned.
#include <netx25/x25_proto.h> #include <netx25/x25db.h> int x25tos ( struct xaddrf *xad, /* The X.25 structure */ unsigned char *cp, /* The returned string */ int lookup );
Converts an xaddrf structure into an X.25 address. Before doing so, it checks the validity of the xaddrf structure.
The parameters are:
Table 8-28 x25tos parameters
Parameters |
Description |
---|---|
xad |
Points to the xaddrf structure for conversion. |
cp |
Points to the string the X.25 address will be written to. |
lookup |
Determines the level of address checking carried out before the structure is converted. 0 indicates no checking is carried out. This allows for faster conversion, but means the structure may not be valid for the type of network it refers to. A non-zero value means that the structure is checked using the configuration files. |
0 indicates successful completion. A negative return value indicates that the structure was invalid.