Kernel 8.0 APIs Banner
Office of Information and Technology (OIT) Banner
[skip navigation]

$$FORCEIP4^XLFIPV(): Convert any IP Address to IPv4

Reference Type: Supported, Category: IP Address Functions, ICR#: 5844

Description

The $$FORCEIP4^XLFIPV extrinsic function converts an IP address (either IPv4 or IPv6) into an IPv4 address in a standardized format consisting of four decimal numbers, each in the range 0 to 255. For example:

    001.99.001.9

Format

  $$FORCEIP4^XLFIPV(ip)

Input Parameters

ip:

(required) IPv4 or IPv6 address (string; in quotes) to be converted.

Output

returns:

Returns:

  • An IPv4 address in “nnn.nnn.nnn.nnn” notation if the input address is valid and has an IPv4 equivalent.

  • The NULL address “0.0.0.0” if the input address is invalid.

  • The NULL address “0.0.0.0” if an IPv6 address is input that does not have an IPv4 equivalent.

 

Examples

Example 1

>S X=$$FORCEIP4^XLFIPV("10.126.3.1")

>W X
10.126.3.1

Example 2

>S X=$$FORCEIP4^XLFIPV("10.999.3.1")

>W X
0.0.0.0

Example 3

>S X=$$FORCEIP4^XLFIPV("2001:db8::8a2e:370:7334")

>W X
0.0.0.0

Example 4

>S X=$$FORCEIP4^XLFIPV("::ffff:10.126.3.1")

>W X
10.126.3.1

Example 5

>S X=$$FORCEIP4^XLFIPV("::ffff:c000:2eb")

>W X
192.0.2.235