IRISLIB database
INetInfo Class Reference

The <class>SYSTEM.INetInfo</class> class provides an interface for Internet address manipulation. More...

Inheritance diagram for INetInfo:
Collaboration diagram for INetInfo:

Static Public Member Functions

_.Library.String AddrToHostName (_.Library.String Addr)
 The <class>SYSTEM.INetInfo</class> class provides an interface for Internet address manipulation. More...
 
_.Library.Integer AddrType (_.Library.String Addr)
 Find the type of an address text. More...
 
_.Library.String BinaryAddrToText (_.Library.String Addr)
 Convert a binary Internet address to a readable text string. More...
 
_.Library.Integer CheckAddressExist (_.Library.String IPAddr)
 CheckAddressExist: More...
 
_.Library.Boolean CheckArpingInstalled ()
 Check if 'arping' command is installed in the system. More...
 
_.Library.Integer CheckInterfaceExist (_.Library.String Interface, _.Library.Integer MatchExact)
 CheckInterfaceExist: More...
 
_.Library.Integer CheckSubnetMatch (_.Library.String Interface, _.Library.String IPAddr)
 CheckSubnetMatch: More...
 
_.Library.Boolean Connected ()
 The Connected() class method checks if the current device is a TCP device has been. More...
 
_.Library.Integer DisableIPV6 (_.Library.Integer System)
 Disable IPV6 process or system wide. More...
 
_.Library.Integer EnableIPV6 (_.Library.Integer System)
 Enable IPV6 process or system wide. More...
 
_.Library.String EthernetAddress (_.Library.Integer flag, _.Library.String Name)
 EthernetAddress(flag[,name]) is a class method that determines Ethernet address. More...
 
_.Library.String GetInterfacesInfo (_.Library.String Interface)
 Get interfaces information configured in the system. More...
 
_.Library.List GetListOfConfiguredInterfaces (_.Library.Boolean InterfaceNamesOnly, _.Library.String VIP)
 Get interfaces information configured in the system excluding loopback interface. More...
 
_.Library.List GetServiceByName (_.Library.String Name, _.Library.String Proto, _.Library.Integer Family)
 Get port number, protocol name and IP Family from a service name. More...
 
_.Library.String GetServiceByPort (_.Library.Integer Port, _.Library.Integer Family)
 Get a service name from a port number. More...
 
_.Library.String HostNameToAddr (_.Library.String HostName, _.Library.Integer Family, _.Library.Integer Format)
 Get one IP address from a host name. More...
 
_.Library.List HostNameToAddrMulti (_.Library.String HostName, _.Library.Integer Family, _.Library.Integer Format)
 Get all IP addresses from a host name. More...
 
_.Library.Integer HostToNetLong (_.Library.Integer Addr)
 Convert a 4-byte unsigned integer from Host order to Network order (htonl()). More...
 
_.Library.Integer HostToNetShort (_.Library.Integer Port)
 Convert a 2-byte unsigned integer from Host order to Network order (htons()). More...
 
_.Library.String IsIPV6Enabled (_.Library.Integer System)
 Check if IPV6 is enabled. More...
 
_.Library.String LocalHostName ()
 Return the local host name. More...
 
_.Library.Integer NetToHostLong (_.Library.Integer Addr)
 Convert a 4-byte unsigned integer from Network order to Host order (htonl()). More...
 
_.Library.Integer NetToHostShort (_.Library.Integer Port)
 Convert a 2-byte unsigned integer from Network order to Host order (ntohs()). More...
 
_.Library.Integer OSsupportsIPV6 ()
 $SYSTEM.InetInfo.OSsupportsIPV6() provides a way to determine if IPV6 is supported by the operating system. More...
 
_.Library.Integer SetListenQSize ()
 This funciton is DEPRECATED. More...
 
_.Library.String TCPName ()
 TCPName is a class method called by a child process to retrieve the TCP device. More...
 
_.Library.Integer TCPStats (_.Library.Integer Code)
 TCPStats(Code) returns statistics from the current TCP device. More...
 
_.Library.String TextAddrToBinary (_.Library.String Addr)
 Convert a readable Internet address text string to a binary Internet address string. More...
 
- Static Public Member Functions inherited from Help
_.Library.String Help (_.Library.String method)
 This is a helper class that is used by the various SYSTEM classes to provide a Help method. More...
 

Detailed Description

The <class>SYSTEM.INetInfo</class> class provides an interface for Internet address manipulation.


These interfaces support both IPV6 and IPV4 internet addresses.

Member Function Documentation

◆ AddrToHostName()

_.Library.String AddrToHostName ( _.Library.String  Addr)
static

The <class>SYSTEM.INetInfo</class> class provides an interface for Internet address manipulation.


These interfaces support both IPV6 and IPV4 internet addresses.

Find a host name for an Internet address.


Parameters:
Addr - An Internet address in binary form. The length is 4 for IPV4, 16 for IPV6.
The address should be in Network order.

Return:
This method returns a host name string, it returns a null string if no host name is associated with the Internet address.

◆ AddrType()

_.Library.Integer AddrType ( _.Library.String  Addr)
static

Find the type of an address text.



Parameters:
Addr - A text string could be a hostname, an IPV4 dotted address or an IPV6 colon-hex text address.

Return:
This method returns 0 for hostname, 1 for IPV4 address type or 2 for IPV6 address type.

◆ BinaryAddrToText()

_.Library.String BinaryAddrToText ( _.Library.String  Addr)
static

Convert a binary Internet address to a readable text string.



Parameters:
Addr - An Internet address in binary form. The length is 4 for IPV4, 16 for IPV6.
The address should be in Network order.

Return:
This method returns a 'dotted' decimal string if the input address is IPV4 address (worked as inet_ntoa()).
It returns colon-hex address string if the input address is IPV6 address.
If the address could not be translated, a null string is returned.

◆ CheckAddressExist()

_.Library.Integer CheckAddressExist ( _.Library.String  IPAddr)
static

CheckAddressExist:

Description

Check if the specific IP address exists in the network or not.
Returns 1 if the IP address exists in the network, otherwise return 0.

◆ CheckArpingInstalled()

_.Library.Boolean CheckArpingInstalled ( )
static

Check if 'arping' command is installed in the system.


Return:
For non-Linux system this function always returns True. This function is for Linux/Ubuntu system only.
Returns 1 if 'arping' is installed in the system, otherwse returns 0.

◆ CheckInterfaceExist()

_.Library.Integer CheckInterfaceExist ( _.Library.String  Interface,
_.Library.Integer  MatchExact 
)
static

CheckInterfaceExist:

Description

Check if the specific network interface exists in the system or not.
Returns 1 if the network interface exists in the system, otherwise return 0.

◆ CheckSubnetMatch()

_.Library.Integer CheckSubnetMatch ( _.Library.String  Interface,
_.Library.String  IPAddr 
)
static

CheckSubnetMatch:

Description

Check to see if the subnets for the IP for a given physical interface match a requested virtual IP.
Returns 1 if the subnets match, otherwise return 0.

◆ Connected()

_.Library.Boolean Connected ( )
static

The Connected() class method checks if the current device is a TCP device has been.

disconnected from the remote site. It returns 0 if the TCP device is disconnected. It returns 1 if the TCP device is still connected. An error <FUNCT> is generated if the current device is not a TCP device.

You can also have the system poll asynchronously for a TCP disconnect by using the D mode option for the OPEN or USE command.

◆ DisableIPV6()

_.Library.Integer DisableIPV6 ( _.Library.Integer  System)
static

Disable IPV6 process or system wide.



Parameters:
System - Disable IPV6 for process or system wide, 1 for system wide, 0 for process wide (default).

Return:
Return whether the IPV6 was enabled or not, 1 - was enabled, 0 - was disabled.

◆ EnableIPV6()

_.Library.Integer EnableIPV6 ( _.Library.Integer  System)
static

Enable IPV6 process or system wide.



Parameters:
System - Enable IPV6 for process or system wide, 1 for system wide, 0 for process wide (default).

Return:
Return whether the IPV6 was enabled or not, 1 - was enabled, 0 - was disabled.

◆ EthernetAddress()

_.Library.String EthernetAddress ( _.Library.Integer  flag,
_.Library.String  Name 
)
static

EthernetAddress(flag[,name]) is a class method that determines Ethernet address.

Description

You can return a string containing ethernet address information by issuing a call to the following class method.

EthernetAddress(0) returns the address of the primary ethernet device. This primary ethernet device is the first ethernet device found on the device names list with a valid ethernet address. Any ethernet device can be designated the primary ethernet device.

EthernetAddress(0,name) returns the address of any attached ethernet device specified by name. On OpenVMS systems, this is the physical port address of the ethernet device, not the hardware address. The ethernet address is returned as a string of 12 characters that represent the 48-bit ethernet address. The name is not case sensitive. The maximum length of a device names list is platform-dependent, but the name of an individual device cannot be more than 15 characters in length. An invalid name value results in a <FUNCTION> error.

EthernetAddress(0) returns a null string, rather than an ethernet address if:

The primary ethernet device is not present in the device names list. EthernetAddress(0,name) returns a null string if the named device is not present in the device names list, or has no corresponding ethernet address.

On Windows systems, the InterSystems Packet Driver is not installed.

On IBM AIX(r) systems, the DLPI (Data Link Provider Interface) packages are not installed.

The ethernet adapters are protected against access by non-root users, and the process invoking EthernetAddress(0) is not the root user.

EthernetAddress(1) returns the current list of attached ethernet device names, delimited by $CHAR(1). The first name in this list is the primary ethernet device.

EthernetAddress(2) returns the current list of ethernet device names, delimited by commas. This feature is not available on Windows systems.

EthernetAddress(2,name) replaces the current ethernet device names list with the list specified in name; it then returns the ethernet device names list prior to the replacement. This feature is not available on Windows systems.

Parameters

flag – The switch that specifies the information that EthernetAddress is to return. Valid values are:

0 Returns the address of an attached ethernet device. When name is specified, it returns the address of the named device. When name is not specified, it returns the primary ethernet device.

1 Returns a list of the ethernet device names actually present on the system. This is a subset of the list returned by flag= 2. Listed names are separated by the $CHAR(1) character.

2 Returns the current list of ethernet device names, as set by system startup or by a subsequent invocation of EthernetAddress(2,name). Listed names are separated by commas. This flag value is not available on Windows systems.

name Optional – Ethernet device name(s). Valid values are:

When flag = 0 name is the name of a specific ethernet device. EthernetAddress(0,name) returns the address of the named device.

When flag= 2 name is an ethernet device names list, enclosed in quotes with individual device names separated by commas. A name list specified in EthernetAddress(2,name) cannot contain control characters. The ethernet device names cannot be changed on Windows systems.

◆ GetInterfacesInfo()

_.Library.String GetInterfacesInfo ( _.Library.String  Interface)
static

Get interfaces information configured in the system.


Parameters:
Interface - Null string will return information of all interfaces otherwise it returns the information of the specified interface.

Return:
Each interface is separated by $c(0) character. Within each interface it contains interface name and IP addresses separated by $c(1) character.
The first field separated by $c(1) is interface name and rest fields of them are the IP addresses configured on this interface.

◆ GetListOfConfiguredInterfaces()

_.Library.List GetListOfConfiguredInterfaces ( _.Library.Boolean  InterfaceNamesOnly,
_.Library.String  VIP 
)
static

Get interfaces information configured in the system excluding loopback interface.


Parameters:
InterfaceNamesOnly - If set it will return only interface name otherwise return interface name and IP address.
VIP - If this is non-null string it will return only interfaces with matching subnet of the VIP.

Return:
For InterfaceNamesOnly is set, it returns all the interface names in $LIST() format, e.g. $LB(InterfaceName1,InterfaceName2,...)
If it is not set it returns all interfaces in a nested $LIST() format, e.g. $LB(Interface1,Interface2,...)
Each interface is also a $LIST() containing interface name and IP addresses, e.g. $LB(InterfaceName,IPv4,IPv6). Please note that the sequence of IPv4 and IPv6 might be reversed, you need to check whether it is IPv4 or not by $Length(IP,":"), if it is > 2 then it is IPv6 otherwise it is IPv4. And there can be more than one IPV4 or IPV6 addresses in the interfaces.

◆ GetServiceByName()

_.Library.List GetServiceByName ( _.Library.String  Name,
_.Library.String  Proto,
_.Library.Integer  Family 
)
static

Get port number, protocol name and IP Family from a service name.



Parameters:
Name - The service name string to be translated.
Proto - The protocol of service to be returned. If this parameter is omitted the default value is "". The value could be:

  • "": return services for both TCP and UDP protocols.
  • "tcp": return service for TCP protocol.
  • "udp": return service for UDP protocol.

Family - The family of the service to be returned. If this parameter is omitted the default value is 0. The value could be:

  • 0: depends on value of $SYSTEM.INetInfo.IsIPV6Enabled(), if IPV6 is NOT enabled IPV4 service is returned, otherwise it returns services for both IPV4 and IPV6.
  • 1: Only return IPV4 service, if no IPV4 service then return null string as failure.
  • 2: Only return IPV6 service, if no IPV6 service then return null string as failure.

Return:
Returns a List, its element is port number, protocol name and family type separated by "," (e.g. 23,tcp,IPV4).
The port number returned is in Host order.
Returns null string if the service name could not be resolved.

◆ GetServiceByPort()

_.Library.String GetServiceByPort ( _.Library.Integer  Port,
_.Library.Integer  Family 
)
static

Get a service name from a port number.



Parameters:
Port - The port number to be translated. This port number is in Host order.

Family - The family of the service to be returned. If this parameter is omitted the default value is 0. The value could be:

  • 0: depends on value of $SYSTEM.INetInfo.IsIPV6Enabled(), if IPV6 is NOT enabled IPV4 service is returned, otherwise it returns services for IPV6.
  • 1: Only return IPV4 service, if no IPV4 service then return null string as failure.
  • 2: Only return IPV6 service, if no IPV6 service then return null string as failure.

Return:
Returns a service name string.
Returns null string if the service name could not be found.

◆ HostNameToAddr()

_.Library.String HostNameToAddr ( _.Library.String  HostName,
_.Library.Integer  Family,
_.Library.Integer  Format 
)
static

Get one IP address from a host name.



Parameters:
HostName - The host name string to be translated.
Family - The family of the IP address to be returned. If this argument is omitted the default value is 0. The value could be:

  • 0: depends on value of $SYSTEM.INetInfo.IsIPV6Enabled(), if IPV6 is NOT enabled IPV4 address is returned, otherwise it returns whatever the system supports.
  • 1: Always return IPV4 address, if no IPV4 address then return null string as failure.
  • 2: Always return IPV6 address, if no IPV6 address then return null string as failure.

Format - The format of address to be returned. If this argument is omitted the default value is 0. The value could be:

  • 0: in text format, 'dotted' decimal string for IPV4, colon-hex address string for IPV6.
  • 1: in binary format, 4 character length for IPV4, 16 characters for IPV6.

Return:
Returns the primary IP address of the specified host name. It could be in binary or text format depends on the Format parameter. For binary format the IP address is in Network order.
If the host name could not be resolved a null string is returned.

◆ HostNameToAddrMulti()

_.Library.List HostNameToAddrMulti ( _.Library.String  HostName,
_.Library.Integer  Family,
_.Library.Integer  Format 
)
static

Get all IP addresses from a host name.



Parameters:
HostName - The host name string to be translated.
Family - The family of the IP address to be returned. If this argument is omitted the default value is 0. The value could be:

  • 0: depends on value of $SYSTEM.INetInfo.IsIPV6Enabled(), if IPV6 is NOT enabled IPV4 address is returned, otherwise it returns whatever the system supports.
  • 1: Always return IPV4 address, if no IPV4 address then return null string as failure.
  • 2: Always return IPV6 address, if no IPV6 address then return null string as failure.

Format - The format of address to be returned. If this argument is omitted the default value is 0. The value could be:

  • 0: in text format, 'dotted' decimal string for IPV4, colon-hex address string for IPV6.
  • 1: in binary format, 4 character length for IPV4, 16 characters for IPV6.

Return:
Returns all the IP addresses of the specified host name in a List. Each IP address in the List could be in binary or text format depends on the Format parameter. For binary format the IP address is in Network order.
If the host name could not be resolved a null string is returned.

◆ HostToNetLong()

_.Library.Integer HostToNetLong ( _.Library.Integer  Addr)
static

Convert a 4-byte unsigned integer from Host order to Network order (htonl()).

This is used to convert the binary IPV4 address.


Parameters:
Port - A 4-byte unsigned integer as a binary IPV4 address in Host order.

Return:
Return a A 4-byte unsigned integer as a binary IPV4 address in Network order.

◆ HostToNetShort()

_.Library.Integer HostToNetShort ( _.Library.Integer  Port)
static

Convert a 2-byte unsigned integer from Host order to Network order (htons()).

This is used to convert the Port number.


Parameters:
Port - A 2-byte unsigned integer as a port number in Host order.

Return:
Return a 2-byte unsigned integer as a port number in Network order.

◆ IsIPV6Enabled()

_.Library.String IsIPV6Enabled ( _.Library.Integer  System)
static

Check if IPV6 is enabled.



Parameters:
System - Check for process or system wide, 1 for system wide, 0 for process wide (default).
Return:
Return whether the IPV6 is enabled or not, 1 - is enabled, 0 - is disabled.

◆ LocalHostName()

_.Library.String LocalHostName ( )
static

Return the local host name.

(gethostname()).

◆ NetToHostLong()

_.Library.Integer NetToHostLong ( _.Library.Integer  Addr)
static

Convert a 4-byte unsigned integer from Network order to Host order (htonl()).

This is used to convert the binary IPV4 address.


Parameters:
Port - A 4-byte unsigned integer as a binary IPV4 address in Network order.

Return:
Return a 4-byte unsigned integer as a binary IPV4 address in Host order.

◆ NetToHostShort()

_.Library.Integer NetToHostShort ( _.Library.Integer  Port)
static

Convert a 2-byte unsigned integer from Network order to Host order (ntohs()).

This is used to convert the Port number.


Parameters:
Port - A 2-byte unsigned integer as a port number in Network order.

Return:
Return a 2-byte unsigned integer as a port number in Host order.

◆ OSsupportsIPV6()

_.Library.Integer OSsupportsIPV6 ( )
static

$SYSTEM.InetInfo.OSsupportsIPV6() provides a way to determine if IPV6 is supported by the operating system.



Return:
Returns 1 if the operating system supports IPV6.
Returns 0 if the operating system does not support IPV6.

◆ SetListenQSize()

_.Library.Integer SetListenQSize ( )
static

This funciton is DEPRECATED.

Set queue size for listen() when /CLOSELISTEN option is set on TCP device.
For non-Linux system, the queue size is always set to 0.
For Linux system the queue size is set based on the value of net.ipv4.tcp_syncookies, when net.ipv4.tcp_syncookies is set to 1 then the listen queue will be set to 0, otherwise the listen queue is set to 1.
This method needs to be called whenever users change the setting of net.ipv4.tcp_syncookies while IRIS is running.
Return:
1 - the listen queue size is 1 when /CLOSELISTEN option is set.
0 - the listen queue size is 0 when /CLOSELISTEN option is set.

◆ TCPName()

_.Library.String TCPName ( )
static

TCPName is a class method called by a child process to retrieve the TCP device.

name assigned by the parent process.

◆ TCPStats()

_.Library.Integer TCPStats ( _.Library.Integer  Code)
static

TCPStats(Code) returns statistics from the current TCP device.

Description

TCPStats(2) returns the number of bytes that have been read from the current TCP device.

TCPStats(3) returns the number of bytes that have been read from the current TCP device and clears the counter.

TCPStats(4) returns the number of bytes that have been written to the current TCP device.

TCPStats(5) returns the number of bytes that have been written to the current TCP device and clears the counter.

◆ TextAddrToBinary()

_.Library.String TextAddrToBinary ( _.Library.String  Addr)
static

Convert a readable Internet address text string to a binary Internet address string.



Parameters:
Addr - Internet address, a string with address in text form. It is a 'dotted' decimal string for IPV4, colon-hex address string for IPV6.

Return:
This method (worked as inet_addr()) returns a binary IP address in Network order, the length is 4 for IPV4, 16 for IPV6.
If the address could not be translated, a null string is returned.