Using UIE Function Commands

The BIG-IP includes special function commands that you can use as part of expressions. These iRule commands constitute part of the Universal Inspection Engine (UIE).

A primary use of UIE expressions is to either return a string for persistence or to return a node to which the pool can send traffic directly.

Note


For more information on persistence, see Working with Profiles.

The function commands that you can use within UIE expressions fall into two categories: commands that return a string, and commands that directly select a node.

Commands that return a string

Table 1 lists and describes the commands that return a string that you specify. The pages following the table provide detail and examples of the commands.

Command Description
findstr Finds a string within another string and returns the string starting at the offset specified from the match.
substr Finds a string within another string and returns the string starting at the offset specified from the match.
getfield Splits a string on a character, and returns the string corresponding to the specific field
findclass Finds the member of a class that contains the result of the specified expression, and returns that class member.
decode_uri Evaluates the expression, and returns a string with any %XX escape sequences decoded as per HTTP escape sequences defined in RFC2396.
domain Parses and returns up to the specified number of trailing parts of a domain name from the specified expression.
imid Used to parse the http_uri variable and user-agent header field for an i-mode® identifier string that you can use for persisting i-mode sessions.

findstr

The findstr command finds the string within and returns a sub-string based on the and from the matched location.

Note the following;

  • may be either a character or length.
  • If is not specified, it defaults to zero.
  • If is not specified, it defaults to the end of the string.
  • This command (without or ) is equivalent to the following Tcl command: "string range [string first ] end".

The syntax of the findstr() command is as follows:

findstr [ []

Figure 2 shows an example of an iRule using the findstr command.

Figure 2: An iRule using the findstr command

iRule my_iRule 
when CLIENT_ACCEPTED{{
  if { [findstr [http_uri] "?type=" 6 "&"] == "cgi" } { 
    pool cgi_servers 
  } else { 
    pool web_servers 
  } 
}

substr

The substr command returns a sub-string <string> based on the values of and .

Note the following:

  • The and arguments are used in the same way as they are for the findstr command.
  • This command is equivalent to the Tcl string range command except that the value of may be either a character or a count.

The syntax of the substr command is:

substr []

getfield

The getfield command splits a string on a character, and returns the string corresponding to the specific field.

The syntax of the getfield command is:

getfield

findclass

The findclass command searches a data group list for a member that starts with and returns the data-group member string. This is similar to the matchclass command, except that the member is not required to be equal; instead, the member is only required to start with the string and the command returns the entire member value.

The syntax of the findclass command is:

findclass

decode_uri

The decode_uri command decodes the string using HTTP URI encoding per RFC2616 and returns the result.

The syntax of the decode_uri command is:

decode_uri

domain

The domain command parses the string as a dotted domain name and return the last portions of the domain name.

The syntax of the domain command is:

domain

imid

The imid function is specifically used to parse the HTTP::uri and HTTP::header "user-agent" values for a unique i-mode user identifier string that you can use for session persistence. The imid command takes no arguments and simply returns the string representing the i-mode identifier or the empty string, if none is found.

The syntax of the imid command is:

imid

Commands that return a node address

Table 3 lists and describes the commands that return a node address to directly select a pool member.

Command Description
node Returns a literal node address converted from a string representation of an address and port.
mapclass2node Represents a short-hand combination of the commands findclass, findstr, and node.
wlnode Returns a literal node address converted from a specific BEA WebLogicTM string format, representing the application IP address and service, into a literal node address.

node

The node command returns a literal node address converted from a string representation of an address and port. This function is designed primarily to be used with the persistence expressions for directly selecting a node to which to persist.

The syntax of the node command is:

node

mapclass2node

The mapclass2node command finds a class member in that starts with and then splits the member string on and converts the second field into a node object. If is not specified, it defaults to a space character. This command is equivalent to the following aggregate commands: node [getfield [findclass ] 2]. The mapclass2node command is a short-hand combination of the commands findclass, findstr, and node.

wlnode

The wlnode function returns a literal node address converted from a string of the BEA WebLogicTM format for identifying the application node to which the connection should persist.

The wlnode function is designed primarily to be used with the persistence expressions for directly selecting a node to which to persist.