HPlogo X25/9000: X.25/9000 Programmer's Guide > Chapter 2 X.25 Addressing

Using Wildcard Addressing

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

Wildcard addresses are used in bind() calls only. They cannot be used in connect() calls. Wildcard addressing allows a single listen socket to connect to incoming calls using a variety of addresses and protocol IDs.

The re are three types of wildcard addressing. The one which is implemented depends on the field in the x25addrstr structure that is being used. When an incoming CALL REQUEST packet is received, the x25addrstr structure fields are checked in the following order: x25ifname, x25_host and then x25pid.

Wildcard Addresses in the x25ifname[] Field

The x25ifname[] field has only one form of wildcard addressing. If you specify the null string ("\0"), the specified address will match the X.121 address of any interface connected to your system. If you specify an inter face name, only calls from that one interface will match.

Wildcard Addresses in the x25_host[] Field

A wildcard address in the x25_host[] field may be the null string or use special wildcard characters. As described above, the null string will match only the X.121 address of the interface on the receiving end, but not the sub address.

The valid wildcard characters are the question mark ("?"), and the asterisk ("*"). These characters may be used in combination with the decimal digits normally specified in this field. When they are specified in the x25_host field and are matched with an incoming call's called address field they have the properties described in table below.

Table 2-1 Wildcard Characters

Character

Meaning

?

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 decimal digit, including none; for example, 1* matches any address beginning with 1 including 1 itself. It can be used alone or as a suffix.

 

The table below illustrates the various possibilities of matching an non- matching addresses for a given number using wildcard characters.

Table 2-2 Wildcard Address Matching for x25_host

Example Address

Matching Addresses

Non-Matching Addresses

7234

7234

All addresses except 7234.

723?

7230, 7231, 7232, 7233,7234,7235, 7236,7237,7238, or 7239

All addresses that do not begin with 723, and all addresses that are not 4 digits long.

72?4

7204, 7214, 7224, 7234, 7244, 7254, 7264,7274, 7284, or 7294

All addresses that do not begin with 72 and end with 4, and all addresses that are not 4 digits long

*

All addresses are valid.

None.

??*

All addresses of 2 digits or more are valid.

Addresses with only 1 digit (0, 1, 2, 3, 4, 5, 6, 7, 8, or 9).

*??

Invalid syntax - nothing matches.

Invalid syntax.

 

Setting a Wildcard Protocol ID Local Address Mask

The server specifies the protocol ID for its listen socket in the x25pid field of the x25addrstr structure. The protocol ID is part of the call user data field in the CALL REQUEST packet. This field is added (ANDed) with the mask specified in the ioctl(X25_WR_MASK_DATA). The x25pid field and the mask specified in the ioctl(X25_WR_MASK_DATA) can be combined to enable a certain degree of 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. If the result is unequal, the comparison fails. If equal, the comparison continues with the next byte of each field until a mismatch occurs or the number of bytes in the bind address's x25_pidlen field has been compared.

Use this wildcard method if the incoming protocol ID you need isn't a whole number of bytes, or there are bytes within the field that are not part of the protocol ID. For example, some systems place a length byte at the beginning of the call user data field, which should be ignored in protocol ID matching.

The bit-by-bit comparison is described in the following table:

Table 2-3 x25pid and x25_mask Usage

Call User Data Bit

x25_mask Data Bit

x25pid Data Bit

0 or 1

0

0 always matches

0 or 1

0

1 always fails

0

1

0 matches

1

1

1 matches

1

1

0 fails

0

1

1 fails

 

Syntax for ioctl (X25_WR_MASK_DATA)

The syntax for the ioctl(X25_WR_MASK_DATA) system call and its parameters are described below.

#include <x25/x25ioctls.h>
#include <x25/x25.h>
int err;
/* DEFINE X25_MAX_PIDLEN 8
* struct x25_mask_data {
* 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() being performed. 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. This has the same effect as if the call were not made.

mask

Indicates the mask to be ANDed with the protocol ID specified in the CALL REQUEST packet. The x25_mask_len field indicates the length of the mask, and the x25_mask indicates the mask to be used.