ns_addr()--Translate Network Services Address to 12-byte Address


  Syntax
 #include <sys/types.h>
 #include <netns/ns.h>

 struct ns_addr ns_addr(char *address_string)

  Service Program Name: QSOSRV2

  Default Public Authority: *USE

  Threadsafe: Yes

The ns_addr() function is used to translate a network services address from human readable format to a 12-byte hexadecimal address.


Authorities and Locks

None.


Parameters

char *address_string
(Input) The network services address in human readable format.

Return Value

The ns_addr() function returns an ns_addr structure.


Usage Notes

Notation of the human readable address string can be in many forms. The following notation rules apply to all the format examples shown here.

  1. There are three fields to the address string: the network field denoted by bytes n1 through n4, the host field denoted by bytes h1 through h6, and the port number field denoted by bytes p1 and p2. These three fields can be separated by a period (.), a colon (:), or a (#). Once one of these three separator characters is encountered, the rest of the fields (the host field and the port number field) may be byte separated by a period or a colon. The network field cannot use byte separators because it is the first field and a field separator has not been encountered. Also, you may not use the same character as a field separator and a byte separator.

  2. Each field may be specified as either decimal, hexadecimal, or octal. Octal is specified by a preceding zero (for example, 011 is decimal value 9). Hexadecimal can be specified in the following ways:

The following are valid formats:

Although they can have byte separators, the host and port fields do not need to be byte separated. Also, not all bytes need be specified for a given field. If not all bytes are specified, the specified bytes are right-justified in the field.

Note: If the host field is not byte separated, the number must not be larger than what can be contained in a 4-byte integer. That is, to use nonzero values for bytes h1 and h2, you must byte separate the host field.

The following formats are also valid:

Not all fields need be specified. The following formats are also valid:

As a further example, the following are just some of the ways that a network number of 71 decimal, a host number of 8374930 decimal, and a port number of 9341 can be specified.



API introduced: V3R6
Top | UNIX-Type APIs | APIs by category