The PTON call converts an IP address in its standard text presentation form to its numeric binary form. On successful completion, PTON returns the converted IP address in the buffer provided.
Authorization: | Supervisor state or problem state, any PSW key. |
Dispatchable unit mode: | Task. |
Cross memory mode: | PASN = HASN. |
Amode: | 31-bit or 24-bit. Note: See "Addressability
mode (Amode) considerations" under CALL instruction API environmental restrictions and programming requirements.
|
ASC mode: | Primary address space control (ASC) mode. |
Interrupt status: | Enabled for interrupts. |
Locks: | Unlocked. |
Control parameters: | All parameters must be addressable by the caller and in the primary address space. |
Figure 1 shows an example of PTON call instructions.
WORKING-STORAGE SECTION.
01 SOC-BIND-FUNCTION PIC X(16) VALUE IS 'BIND'.
01 SOC-PTON-FUNCTION PIC X(16) VALUE IS 'PTON'.
01 S PIC 9(4) BINARY.
* IPv4 socket structure.
01 NAME.
03 FAMILY PIC 9(4) BINARY.
03 PORT PIC 9(4) BINARY.
03 IP-ADDRESS PIC 9(8) BINARY.
03 RESERVED PIC X(8).
* IPv6 socket structure.
01 NAME.
03 FAMILY PIC 9(4) BINARY.
03 PORT PIC 9(4) BINARY.
03 FLOWINFO PIC 9(8) BINARY.
03 IP-ADDRESS.
10 FILLER PIC 9(16) BINARY.
10 FILLER PIC 9(16) BINARY.
03 SCOPE-ID PIC 9(8) BINARY.
01 AF-INET PIC 9(8) BINARY VALUE 2.
01 AF-INET6 PIC 9(8) BINARY VALUE 19.
* IPv4 address.
01 PRESENTABLE-ADDRESS PIC X(45).
01 PRESENTABLE-ADDRESS-IPV4 REDEFINES PRESENTABLE-ADDRESS.
05 PRESENTABLE-IPV4-ADDRESS PIC X(15) VALUE '192.26.5.19'.
05 FILLER PIC X(30).
01 PRESENTABLE-ADDRESS-LEN PIC 9(4) BINARY VALUE 11.
* IPv6 address.
01 PRESENTABLE-ADDRESS PIC X(45)
VALUE '12f9:0:0:c30:123:457:9cb:1112'.
01 PRESENTABLE-ADDRESS-LEN PIC 9(4) BINARY VALUE 29.
* IPv4-mapped IPv6 address.
01 PRESENTABLE-ADDRESS PIC X(45)
VALUE '12f9:0:0:c30:123:457:192.26.5.19'.
01 PRESENTABLE-ADDRESS-LEN PIC 9(4) BINARY VALUE 32.
01 ERRNO PIC 9(8) BINARY.
01 RETCODE PIC S9(8) BINARY.
PROCEDURE DIVISION.
* IPv4 address.
CALL 'EZASOKET' USING SOC-PTON-FUNCTION AF-INET PRESENTABLE-ADDRESS
PRESENTABLE-ADDRESS-LEN IP-ADDRESS ERRNO RETURN-CODE.
* IPv6 address.
CALL 'EZASOKET' USING SOC-PTON-FUNCTION AF-INET6 PRESENTABLE-ADDRESS
PRESENTABLE-ADDRESS-LEN IP-ADDRESS ERRNO RETURN-CODE.
CALL 'EZASOKET' USING SOC-BIND-FUNCTION S NAME ERRNO RETURN-CODE.