Solstice X.25 9.2 Developer's Guide

6.4.15 N_Xlisten--Listen Command/Response

Synopsis
#include <stream.h>
 #include <netx25/x25_proto.h >

 struct strbuf ctlb;
 struct strbuf datab;

 struct xlistenf listen;
 char          lisbuf[MAXLIS];
 .
 .
 .
 ctlb.len = sizeof(struct xlistenf);
 ctlb.buf = (char *)listen;

 datab.len = lislen;
 datab.buf = lisbuf;

 putmsg(x25_fd, &ctlb, &datab, 0);
Description

N_Xlisten is used to listen for incoming calls. When used with putmsg, N_Xlisten is a Listen Command, when used with getmsg, it is a Listen Response. Example 6-1 shows how a getmsg can be constructed. The control part of the Listen Command or Response is defined by the xlistenf structure.

The data part is treated as a byte stream of CUD and addresses conforming to the following definition:

unsigned char l_cumode;
 unsigned char l_culength;
 unsigned char l_cubytes [l_culength];
 unsigned char l_mode;
 unsigned char l_type;
 unsigned char l_length;
 unsigned char l_add[(l_length+1)>>1];

Not all variables need be present. Refer to the individual variable descriptions below for more details.

The fields l_cumode, l_culength and l_cubytes are used to match the CUD field of the incoming call against that specified in the Listen request.

Table 6-16 Variables for CUD matching

Variable Name 

Description 

l_cumode

Defines the type of matching: 

X25_DONTCARE The listener ignores the CUD; l_culength and l_cubytes are omitted.

X25_IDENTITY The listener match is only made if all bytes of the CUD field are the same as the supplied l_cubytes.

X25_STARTSWITH The listener match is only made if the leading bytes of the CUD Field are the same as the supplied l_cubytes.

l_culength

Length of the CUD in octets for an X25_IDENTITY or X25_STARTSWITH CUD Field match. If l_culength is zero, the l_cubytes are omitted. The range for l_culength is zero to 16 inclusive. If more than 16 bytes are present, the application still has to check the full CUD Field.

l_cubytes

String of bytes sought in the call user data field when l_cumode is X25_IDENTITY or X25_STARTSWITH.

The fields l_mode, l_type, l_length and l_add are used to match the called address field(s) of the incoming call against that specified in the Listen request.

Table 6-17 Variables for address matching

Variable Name 

Description 

l_mode

Defines the type of matching: 

X25_DONTCARE

The listener ignores the address; l_type, l_length, and l_add are omitted.

X25_IDENTITY

The listener match is only made if all digits of the address are the same as the supplied l_add.

X25_STARTSWITH

The listener match is only made if the leading digits of the address are the same as the supplied l_add.

X25_PATTERN

The listener match is made on partial addresses, allowing the use of wildcard digits. 

l_type

The type of the address entry; l_type can have two values, X25_DTE or X25_NSAP. It denotes the important addressing quantity. For X.25 (84) and X.25 (88), for example, NSAP addresses (or extended addresses) are the important addresses, while for X.25 (80), where there is no NSAP address, the DTE address is the important quantity. Applications can be distinguished by X.25 DTE subaddress where necessary. On many X.25 (84) and X.25 (88) networks, it is possible to listen on either X25_DTE or X25_NSAP addresses. This is not possible when running X.25 (84) or X.25 (88) over LLC2 on the LAN. In this case, the DTE address field is NULL and the X25_NSAP field is used.

l_length

Length of the address l_add in BCD digits--the common format for X.25 DTE and NSAP addresses. If l_length is zero, then l_add is omitted. The maximum values for l_length are 15 for X25_DTE and 40 for X25_NSAP.

l_add

Contains the address to be compared with the called address field of the incoming call packet. l_add is omitted when l_length is zero.


Note -

To use wildcards, represent * by 0x0F and ? by 0x0E. * represents 0 or more characters. ? represents a single character.


The xlistenf structure is shown below:

struct xlistenf {
 	unsigned char xl_type; /* Always XL_CTL */
 	unsigned char xl_command; /* Always N_Xlisten */
 	int lmax; /* Maximum number of CI's at a time */
 	int l_result; /* Result flag */
 };

The members of the xlistenf structure are.

Table 6-18 Listen Command/Response Parameters

Member 

Description 

lmax

Maximum number of Connect Indications that the listener can handle at one time. Note: listen requests are cumulative but the lmax value (number of simultaneously handled Connect Indications) is not. This means that several listen requests can be made on a single stream, in which case the lmax value contained in the last listen message specifies the number of simultaneously handled Connect Indications.

l_result

The result of the listen request is acknowledged upstream with the same message. An error in the parameters or a lack of resources to set up the listen causes this flag to be set to a non-zero value. 


Note -

For example code using listening, refer to Chapter 4, Listening for Calls.