The FTCHKIP user exit

FTCHKIP is called at the initial stage of login or whenever the user issues an OPEN command to open a new connection. The IP and PORT addresses of the local and remote hosts are passed to the user exit. The user exit can use them to determine whether the remote host's control connection should be canceled. The message 421 User Exit rejects open for connection is sent to the user if the connection is denied. The following parameter list is passed to FTCHKIP.
Offset
Value
+0
Pointer to the word with the return code
+4
Pointer to a word containing the number of following parameters (7)
+8
Pointer to the fullword remote IP address. If the client's address is an IPv6 address, this field points to a word containing x'FFFFFFFF' and the passed socket address structure for the client must be used instead. If the client's address is an IPv4 address, either this field or the socket address structure can be used.
+12
Pointer to the halfword remote port number. Valid only when the fullword remote IP address is not x'FFFFFFFF'.
+16
Pointer to the fullword local IP address. If the server's address is an IPv6 address, this field points to a word containing x'FFFFFFFF' and the passed socket address structure for the server should be used instead. If the server's address is an IPv4 address, either this field or the socket address structure can be used.
+20
Pointer to the halfword local port number. Valid only when the fullword local IP address is not x'FFFFFFFF'.
+24
Pointer to a copy of the socket address structure for the client's control connection. This area is mapped by the SOCKADDR DSECT found in the sample exit. The FAMILY field denotes whether the structure contains an IPv4 or an IPv6 address. When the family is AF_INET, the structure contains an IPv4 address. When the FAMILY is AF_INET6, you must inspect the address itself to determine whether it is an IPv6 address or an IPv4 mapped IPv6 address.
+28
Pointer to a copy of the socket address structure for the server's control connection. This area is mapped by the SOCKADDR DSECT found in the sample exit. The FAMILY field denotes whether the structure contains an IPv4 or an IPv6 address. When the family is AF_INET, the structure contains an IPv4 address. When the FAMILY is AF_INET6, you must inspect the address itself to determine whether it is an IPv6 address or an IPv4 mapped IPv6 address.
+32
Pointer to a buffer containing a 2-byte length followed by the session identifier created by the daemon when the connection was first established for this session. The identifier has a maximum length of 14 bytes and is unique within this instance of the server.
FTCHKIP has been placed before the user logs in, and if access is denied, the user receives a message and the control connection is severed. This message comes at a point when most clients expect to continue with the login process by sending the user ID and password. Even though it is possible, some FTP clients might not expect a 421 message at this point, but it is the most appropriate place for this exit.