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.
- 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.
- 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:
- Specifying 0xnn.
- Specifying 0Xnn.
- Specifying xnn.
- Specifying Xnn.
- Specifying an H character at the end of the field.
- Using a byte separator (only allowed for the host field or port number) in
the field that contains the byte.
- Using any of the characters a,b,c,d,e,f,A,B,C,D,E,F in any byte in the
field.
The following are valid formats:
- Format 1 - n1n2n3n4:h1.h2.h3.h4.h5.h6:p1.p2
- Format 2 - n1n2n3n4.h1:h2:h3:h4:h5:h6.p1:p2
- Format 3 - n1n2n3n4#h1.h2.h3.h4.h5.h6#p1.p2
- Format 4 - n1n2n3n4#h1:h2:h3:h4:h5:h6#p1:p2
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:
- Format 5 - n1n2n3n4:h1h2h3h4h5h6:p1p2
- Format 6 - n1:h1.h2.h3.h4.h5.h6:p1p2
- Format 7 - n1:h1h2h3h4h5h6:p1.p2
Not all fields need be specified. The following formats are also valid:
- Format 8 - n1
- Format 9 - n1:h1
- Format 10 - n1::p1
- Format 11 - ::p1
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.
- 71:8374930:9341
- 71:00.00.00.7f.ca.92:9341
- 71:7f.ca.92:9341
- 0x47:7fca92:247d
- 47H:7f.ca.92:9341
- 47H.7fca92.247d
API introduced: V3R6