The BIND2ADDRSEL call binds a socket to the local IP address
that would be selected by the stack to communicate with the input
destination IP address.
Use the BIND2ADDRSEL call when the application must verify
that the local IP address assigned by the stack meets its address
selection criteria as specified by the IPV6_ADDR_PREFERENCES socket
option before the stack sends any packets to the remote host. In a
TCP or UDP application, the BIND2ADDRSEL call usually follows the
SETSOCKOPT call with option IPV6_ADDR_PREFERENCES and precedes any
communication with a remote host.
Result: The stack attempts
to select a local IP address according to your application preferences.
However, a successful BIND2ADDRSEL call does not guarantee that all
of your source IP address selection preferences were met.
Guidelines: - Use the SETSOCKOPT call to set the IPV6_ADDR_PREFERENCES option
to indicate your selection preferences of source IP address before
binding the socket and before allowing an implicit bind of the socket
to occur.
Result: If a socket has
not been explicitly bound to a local IP address with a BIND or BIND2ADDRSEL
call when a CONNECT, SENDTO, or SENDMSG call is issued, an implicit
bind occurs. The stack chooses the local IP address used for outbound
packets.
Requirement: When your application is using stream sockets, and must prevent the
stack from sending any packets whatsoever (such as SYN) to the remote
host before it can verify that the local IP address meets the values
specified for the IPV6_ADDR_PREFERENCES option, do not allow the CONNECT
call to implicitly bind the socket to a local IP address. Instead,
bind the socket with the BIND2ADDRSEL call and test the local IP address
assigned with the INET6_IS_SRCADDR call. If the assigned local IP
address is satisfactory, you can then use the CONNECT call to establish
communication with the remote host.
- After you successfully issue the BIND2ADDRSEL call, use the GETSOCKNAME
call to obtain the local IP address that is bound to the socket. When
the local IP address is obtained, use the INET6_IS_SRCADDR call to
verify that the local IP address meets your address selection criteria.
The following requirements apply to this call:
Authorization: |
Supervisor state or problem state, any PSW key. |
Dispatchable unit mode: |
Task. |
Cross memory mode: |
PASN = HASN. |
Amode: |
31-bit or 24-bit.
|
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 BIND2ADDRSEL call instructions.
Figure 1. BIND2ADDRSEL
call instruction example WORKING-STORAGE SECTION.
01 SOC-FUNCTION PIC X(16) VALUE IS 'BIND2ADDRSEL'.
01 S PIC 9(4) BINARY.
* IPv6 socket address 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 ERRNO PIC 9(8) BINARY.
01 RETCODE PIC S9(8) BINARY.
PROCEDURE DIVISION.
CALL 'EZASOKET' USING SOC-FUNCTION S NAME ERRNO RETCODE.