Os_payload_inspect::matched_idx (), Context, Usage – Brocade Virtual ADX OpenScript API Guide (Supporting ADX v03.1.00) User Manual
Page 130: Return values

118
Brocade Virtual ADX OpenScript API Guide
53-1003243-01
Methods
9
In the following example, the script searches for the ‘correct’ and ‘login’ strings in the response
payload. If it finds the ‘correct’ string, the script replaces the string with the 'Valid' string, and if it
finds the ‘login’ string, it logs onto the log server.
OS_PAYLOAD_INSPECT::matched_idx ()
Returns the index that indicates which input parameters of the
OS_PAYLOAD_INSPECT::match(regexp1, [regexp2 …])
function triggered this matched event.
Context
This function is only callable in the PAYLOAD_INSPECT_MATCHED event.
Usage
The index is one-based. For example, receiving a returned value 1 means the first parameter in the
parameter list has matched.
Return values
The following table contains the return values.
TABLE 135
Return values
Name
Type
Description
integer
Integer that is the matched index.
use OS_HTTP_RESPONSE;
use OS_PAYLOAD_INSPECT;
use OS_SLB;
sub HTTP_RESPONSE {
my $type = OS_HTTP_RESPONSE::content_type;
if (OS_HTTP_RESPONSE::content_type =~ /text/) {
OS_PAYLOAD_INSPECT::match('correct', 'login');
}
}
sub PAYLOAD_INSPECT_MATCHED {
if ( OS_PAYLOAD_INSPECT::matched_str() == "correct") {
OS_PAYLOAD_INSPECT::matched_replace("", 'Valid', 'My', 'Your' );
} else {
OS_SLB::log("Somebody login");
}
}