beautypg.com

Context, Usage, Input parameters – Brocade Virtual ADX OpenScript API Guide (Supporting ADX v03.1.00) User Manual

Page 125

background image

Brocade Virtual ADX OpenScript API Guide

113

53-1003243-01

Methods

9

OS_PAYLOAD_INSPECT::matched_replace(mstr1, rstr1, [mstr2, rstr2,
…])

Replaces match strings with replacement strings.

Context

This function can only be called in the PAYLOAD_INSPECT_MATCHED event handler.

Usage

Replaces the matched string with the next string. Each pair of input arguments for this API is
associated with the corresponding input argument to the

OS_PAYLOAD_INSPECT::match(regexp1,

[regexp2 …])

API.

For example, the first pair of arguments mstr1 and rstr1 work only with regexp1 from the

OS_PAYLOAD_INSPECT::match(regexp1, [regexp2 …])

API to define the call behavior of both APIs.

When regexp1 is found and matched in the payload stream, a matched event is triggered. During
this event, a search occurs only for mstr1. If it is found, it is replaced by rstr1. During a matched
event for regexp1, the input arguments mstr2, rstr2, mstr3, and rstr3 are not considered.

Similarly, when regexp2 is found and matched, only a search for mstr2 occurs. When it is found, it
is replaced by rstr2 in the matched event script. The same type of input argument grouping also
applies to the third group of parameters, regexp3, rstr3, and mstr3. You can provide a maximum of
three pairs of input parameters. When you enter more than three parameters, the additional
parameters are silently dropped but debugging messages are displayed.

To replace a matched regular expression instead of a string, an empty string "" or 0 is expected as
the mstr parameter and a replacement string is expected as the rstr parameter. For example, use
OS_PAYLOAD_INSPECT::matched_replace("","abc") or
OS_PAYLOAD_INSPECT::matched_replace(0,"abc").

To define no operation on the input parameter pair, an empty string "" or 0 is expected as the mstr
parameter and another 0 is expected as the rstr parameter. For example, use
OS_PAYLOAD_INSPECT::matched_replace("",0) or OS_PAYLOAD_INSPECT::matched_replace(0,0).

Input parameters

The following table contains the input values.

TABLE 132

Input values

Name

Type

Description

mstr1

string

The string to match. The string can be a fixed length only with a
maximum length of 128 bytes.

rstr1

string

The replacement string for the mstr1 matched string. The string can
be a fixed length only with a maximum length of 128 bytes.

mstr2

string

The string to match. The string can be a fixed length only with a
maximum length of 128 bytes.

rstr2

string

The replacement string for the mstr2 matched string. The string can
be a fixed length only with a maximum length of 128 bytes.