53-1003243-01 July 2014 Brocade Virtual ADX OpenScript API Guide Supporting Brocade Virtual ADX version 03.1.
Copyright © 2014 Brocade Communications Systems, Inc. All Rights Reserved. ADX, AnyIO, Brocade, Brocade Assurance, the B-wing symbol, DCX, Fabric OS, ICX, MLX, MyBrocade, OpenScript, VCS, VDX, and Vyatta are registered trademarks, and HyperEdge, The Effortless Network, and The On-Demand Data Center are trademarks of Brocade Communications Systems, Inc., in the United States and/or in other countries. Other brands, products, or service names mentioned may be trademarks of their respective owners.
Contents Preface Document conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix Text formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix Command syntax conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . x Notes, cautions, and warnings . . . . . . . . . . . . . . . . . . . . . . . . . . . x Brocade resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 OS_TCP::src . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 OS_TCP::dst . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 OS_TCP::flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 OS_TCP::win . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 OS_TCP::seq . . .
Methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 OS_HTTP_REQUEST::method . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 OS_HTTP_REQUEST::method($val). . . . . . . . . . . . . . . . . . . . . . . 38 OS_HTTP_REQUEST::url . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 OS_HTTP_REQUEST::url($val) . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 OS_HTTP_REQUEST::path . . . . . . . . . . . . . . . . . . . . . . . . . . .
Methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 OS_HTTP_RESPONSE::code . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 OS_HTTP_RESPONSE::code ($val) . . . . . . . . . . . . . . . . . . . . . . . 64 OS_HTTP_RESPONSE::version . . . . . . . . . . . . . . . . . . . . . . . . . . 65 OS_HTTP_RESPONSE::version ($val) . . . . . . . . . . . . . . . . . . . . . 65 OS_HTTP_RESPONSE::header ($name) . . . . . . . . . . . . . . . . . . .
Methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 OS_SLB:: server_name($id) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 OS_SLB:: server_id($name, $port). . . . . . . . . . . . . . . . . . . . . . . 90 OS_SLB:: servers($group_id) . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 OS_SLB::is_server_up("server-name"=>$name, "server-id"=>$id, "port"=>$port) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
viii Brocade Virtual ADX OpenScript API Guide 53-1003243-01
Preface Document conventions This section describes text formatting conventions and important notice formats that may be used in this document. Text formatting The following text formatting conventions may be used in the flow of the text to highlight specific words or phrases.
Command syntax conventions Convention Description bold text Identifies command names, keywords, and command options. italic text Identifies variables. [] Syntax components displayed within square brackets are optional. { x | y |z } A choice of required parameters is enclosed in curly braces separated byvertical bars. You must select one. x|y A vertical bar separates mutually exclusive elements. <> Nonprinting characters, for example, passwords, are enclosed in angle brackets. ...
Brocade resources To get up-to-the-minute information, go to http://my.brocade.com to register at no cost for a user ID and password. Release notes are available at http://my.brocade.com. White papers, online demonstrations, and data sheets are available through the Brocade website at: http://www.brocade.com/products-solutions/products/index.page Select Application Delivery Switches on this page to navigate to the relevant product information.
Document feedback • Brocade Supplemental Support augments your existing OEM support contract, providing direct access to Brocade expertise. For more information, contact Brocade or your OEM. • For questions regarding service levels and response times, contact your OEM/Solution Provider. Document feedback Quality is our first concern at Brocade and we have made every effort to ensure the accuracy and completeness of this document.
Chapter About OpenScript 1 Overview Brocade Virtual ADX Perl Extensions allow scripts to access load-balancing functionality such as content manipulation and server selection. Some of these extensions (HTTP, TCP, IP) follow the syntax and semantics of equivalent extensions found on CPAN. Others specific to Brocade Virtual ADX, follow the same convention.
1 Overview Table 1 provides a list of application and protocol events provided for OpenScript. TABLE 1 Application and protocol events in ADX scripts Application or protocol Event description Attached script method Use HTTP On request header parsing completion. HTTP_REQUEST Perform request header inspection and insertion or deletion Request payload data available. Called when entire payload available. HTTP_REQUEST_DATA Inspect and modify HTTP request payload data.
Overview TABLE 1 1 Application and protocol events in ADX scripts (Continued) Application or protocol Event description Attached script method Use SLB On server selection failure. SERVER_SELECTION_FAILURE Customize action for recovery. Content inspection When payload inspection finds a matched pattern in HTTP payload data. PAYLOAD_INSPECT_MATCHED Return a matched pattern.
1 Reducing memory usage Reducing memory usage OpenScript will automatically free up memory when the variables go out of the scope although the global variables will not be freed until the script is unbound. Be cautious of the memory usage of the global variables. The example below will free the memory used by a hash entry after it is no longer used.
Chapter IP API reference 2 In this chapter This chapter contains the following sections: • Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 • Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Overview The OS_IP module includes the APIs to retrieve the fields in the current IP header.
2 Methods Return Values The following table contains the return values. TABLE 1 Return Values Name Type Description string String representing Source IP address Example use OS_IP; use OS_SLB; use OS_HTTP_REQUEST; sub HTTP_REQUEST{ my $client_ip = OS_IP::src; print "Client IP Address - $client_ip\n"; OS_HTTP_REQUEST::header("X-Forwarded-For", "$client_ip"); OS_SLB::forward("30"); } OS_IP::dst Description Returns the destination IP address of an incoming packet.
Methods 2 Example use OS_IP; use OS_SLB; use OS_HTTP_REQUEST; sub HTTP_REQUEST{ if( OS_IP::dst eq '192.168.1.1'){ OS_SLB::reset_client; } else { OS_SLB::forward(); } } OS_IP::protocol Description Returns the protocol type of the current packet. Context Called in context of TCP, UDP and HTTP. Usage Used in performing load-balancing based on the protocol type. Input Parameters None. Return Values The following table contains sample return values.
2 Methods Example use OS_IP; use OS_SLB; use OS_HTTP_REQUEST; #Event triggered on http request sub HTTP_REQUEST{ #Retrieve protocol type if(OS_IP::protocol eq 6){ OS_SLB::forward(3); } else { OS_SLB::forward(4); } } OS_IP::flags Description Returns the flags set in the current packet. Context Called in context of TCP, UDP and HTTP context. Usage Used in performing load-balancing based on the flags. Input Parameters None. Return Values The following table contains the return values.
Methods 2 Example use OS_IP; use OS_SLB; use OS_HTTP_REQUEST; #Event triggered on http request sub HTTP_REQUEST{ #Reset according to some flags if(OS_IP::flags eq 34 ){ OS_SLB::reset_client; } else { OS_SLB::forward(4); } } OS_IP::tos Description Returns the type of service flag set in the current packet. Context Called in context of TCP, UDP and HTTP. Usage Used in performing load-balancing based on the TOS flag. Input Parameters None. Return Values The following table contains the return values.
2 Methods Example use OS_IP; use OS_SLB; use OS_HTTP_REQUEST; sub HTTP_REQUEST{ #retrieve type of service flag my $tos = OS_IP::tos; if ($tos == 0){ OS_SLB::forward(3); } elsif ($tos == 1) { OS_SLB::forward(4); } } OS_IP::options Description Returns options in the current packet if present otherwise it will return undefined. Context Called in context of TCP, UDP and HTTP. Usage Used in performing load-balancing based on the options. Input Parameters None.
Methods 2 Example use OS_IP; use OS_SLB; use OS_HTTP_REQUEST; sub HTTP_REQUEST{ $options = OS_IP::options; if(defined $options){ #process options; OS_SLB::reset_client; } } OS_IP::getHeaderLength Description Returns the IP header length in bytes. Header length does not include the length of options present. Context Called in context of TCP, UDP and HTTP. Usage Used in performing load-balancing based on the header length. Input Parameters None.
2 Methods Example use OS_IP; use OS_SLB; use OS_HTTP_REQUEST; sub HTTP_REQUEST{ $header_length = OS_IP::getHeaderLength; if($header_length < 20){ OS_SLB::reset_client; } } OS_IP::getPayloadLength Description Returns payload length of current packet in bytes. Payload includes encapsulated layers (layer 4 + layer 7). Context Called in context of TCP, UDP and HTTP. Usage Used in performing load-balancing based on the payload length. Input Parameters None.
Methods 2 Example use OS_IP; use OS_SLB; use OS_HTTP_REQUEST; sub HTTP_REQUEST{ $length = OS_IP::getPayloadLength; if($length > 2000){ OS_SLB::reset_client; } } OS_IP::getOptionsLength Description Returns the length of options in bytes if present, otherwise it will return 0. Context Called in context of TCP, UDP and HTTP. Usage Used in performing load-balancing based on the option length. Input Parameters None. Return Values The following table contains the return values.
2 Methods Example use OS_IP; use OS_SLB; use OS_HTTP_REQUEST; sub HTTP_REQUEST{ $options = OS_IP::options; $option_len = OS_IP::getOptionsLength; if( defined $options){ if(defined $option_len){ #process options } else { OS_SLB::reset_client; } } } OS_IP::raw Description Returns the data within an IP packet including the IP header. Context Called in context of TCP, UDP and HTTP. Usage Used in performing load-balancing based on the whole IP packet. Input Parameters None.
Methods 2 Example use OS_IP; use OS_HTTP_REQUEST; sub HTTP_REQUEST{ $raw_data = OS_IP::raw; if(defined $raw_data) if(defined $option_len){ { # process raw data } } } Brocade Virtual ADX OpenScript API Guide 53-1003243-01 15
2 16 Methods Brocade Virtual ADX OpenScript API Guide 53-1003243-01
Chapter TCP API reference 3 In this chapter This chapter contains the following sections: • Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 • Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Overview The OS_TCP module includes the APIs to retrieve the fields in the current TCP header.
3 Methods Return Values The following table contains the return values. TABLE 11 Return Values Name Type Description Source port number. Example use OS_TCP; use OS_SLB; use OS_HTTP_REQUEST; sub HTTP_REQUEST{ $port = OS_TCP::src; if($port == 1000){ OS_SLB::reset_client; } else { OS_SLB::forward(4); } } OS_TCP::dst Description Returns the destination port number of the current packet. Context Called in context of TCP and HTTP.
Methods 3 Example use OS_TCP; use OS_SLB; use OS_HTTP_REQUEST; sub HTTP_REQUEST{ if(OS_TCP::dst !=80){ OS_SLB::reset_client; } else { OS_SLB::forward(4); } } OS_TCP::flags Description Returns the TCP flag set in packet. Context Called in context of TCP and HTTP. Usage Can be used to perform load-balancing based on the flags. Input Parameters None. Return Values The hexadecimal number of the TCP flags.
3 Methods OS_TCP::win Description Returns the window size (in bytes) of the current TCP packet. Returns undefined if called in invalid context. Context Called in context of TCP and HTTP. Usage Can be used to perform load-balancing based on the window size. Input Parameters None. Return Values The following table contains the return values. TABLE 13 Return Values Name Type Description Window size of current TCP packet else returns undefined if called in invalid context.
Methods 3 Context Called in context of TCP and HTTP. Usage Can be used to perform load-balancing based on sequence number. Input Parameters None. Return Values The following table contains the return values. TABLE 14 Return Values Name Type Description Sequence number.
3 Methods Return Values The following table contains the return values. TABLE 15 Return Values Name Type Description Acknowledgement number. Example use OS_TCP; use OS_HTTP_REQUEST; sub HTTP_REQUEST { my $ack = OS_TCP::ack; print "Acknowledge number is $ack\n"; } OS_TCP::options Description Returns options as hexadecimal string if present otherwise it returns undefined. Context Called in context of TCP and HTTP. Usage Can be used to perform load-balancing based on options. Input Parameters None.
Methods 3 Example use OS_TCP; use OS_HTTP_REQUEST; sub HTTP_REQUEST { my $options = OS_TCP::options; if(defined $options) { #process options } } OS_TCP::getHeaderLength Description Returns TCP header length in bytes. Header length does not include length of options present. Context Called in context of TCP and HTTP. Usage Can be used to perform load-balancing based on header length. Input Parameters None. Return Values The following table contains the return values.
3 Methods Example use OS_TCP; use OS_SLB; use OS_HTTP_REQUEST; sub HTTP_REQUEST { my $hdrlen = OS_TCP::getHeaderLength; if($hdrlen > 20) { OS_SLB::reset_client; } } OS_TCP::getPayloadLength Description Returns payload length of current packet. Payload contains encapsulated layers (layer 4). Context Called in context of TCP and HTTP. Usage Can be used to perform load-balancing based on payload length. Input Parameters None. Return Values The following table contains the return values.
Methods 3 Example use OS_TCP; use OS_SLB; use OS_HTTP_REQUEST; sub HTTP_REQUEST { my $payloadlen = OS_TCP::getPayloadLength; if($payloadlen > 1500) { OS_SLB::reset_client; } } OS_TCP::getOptionsLength Description Returns length of options if present, otherwise will return 0. Context Called in context of TCP and HTTP. Usage Can be used to perform load-balancing based on the option length. Input Parameters None. Return Values The following table contains the return values.
3 Methods Example use OS_TCP; use OS_SLB; use OS_HTTP_REQUEST; sub HTTP_REQUEST { my $optlen = OS_TCP::getOptionLength; my $options = OS_TCP::options; if($optlen > 0 && !(defined $options)) { OS_SLB::reset_client; } } OS_TCP::collect Description Returns the TCP data within a TCP packet. Context Called in context of TCP. Usage Used to trigger the data event (TCP_CLIENT_DATA or TCP_SERVER_DATA). If the script does not act on the data (e.g. through forwarding), the data is held. Input Parameters None.
Methods 3 Example use OS_TCP; use OS_SLB; sub TCP_CLIENT_ESTABLISHED { OS_TCP::collect; } sub TCP_CLIENT_DATA{ $data = OS_TCP::payload(); $data =~ m/index/undef/g; OS_TCP::payload($data); OS_SLB::forward(4); } OS_TCP::payload Description Returns a packet's TCP payload. Before calling this function, a user should register to collect TCP payload by calling the “OS_TCP::collect API” within the Client events (“TCP_CLIENT_SYN” or “TCP_CLIENT_ESTABLISHED”) or Server events (“TCP_SERVER_ESTABLISHED”) handler.
3 Methods Constraint A “TCP_SERVER_DATA/ TCP_CLIENT_DATA” buffered payload will be forwarded to the default server. If a user wants to change or override a default server selection, an explicit call to “OS_SLB::forward” needs to be done. Depending on the application traffic, PERL utilities unpack/ pack might have to be used before manipulating the payload. Performance Impact This function will have a significant impact on system performance.
Methods 3 Performance Impact This function will have a significant impact on system performance.
3 30 Methods Brocade Virtual ADX OpenScript API Guide 53-1003243-01
Chapter UDP API reference 4 In this chapter This chapter contains the following sections: • Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 • Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Overview The OS_UDP module includes the APIs to retrieve the fields in the current UDP header.
4 Methods Return Values The following table contains the return values. TABLE 22 Return Values Name Type Description Source port number Example use OS_UDP; use OS_SLB; sub UDP_CLIENT_DATA{ my $port = OS_UDP::src(); if($port == 1000){ OS_SLB::drop; } else { OS_SLB::forward(4); } } OS_UDP::dst Returns the destination port number if called in correct context otherwise undefined is returned. Context Called in UDP context. Usage Can be used to perform load-balancing based on the destination port.
Methods 4 Example use OS_UDP; use OS_SLB; sub UDP_CLIENT_DATA{ if(OS_UDP::dst == 21){ OS_SLB::drop; } else { OS_SLB::forward(4); } } OS_UDP::getLength Returns UDP header and payload length in bytes. Context Called in UDP context only. Usage Can be used to perform load-balancing based on the UDP length. Input Parameters None. Return Values The following table contains the return values.
4 Methods Context Called in UDP context only. Usage Can be used to perform load-balancing based on the UDP payload length. Input Parameters None. Return Values The following table contains the return values. TABLE 25 Return Values Name Type Description bytes Payload length in bytes Example use OS_UDP; use OS_SLB; sub UDP_CLIENT_DATA{ my $length = OS_UDP::getPayloadLength; if($length > 1500) { OS_SLB::drop; } } OS_UDP::payload Description Returns the UDP payload of the current packet.
Methods 4 Return Values The following table contains the return values. TABLE 26 Return Values Name Type Description string String representing the UDP payload Example use OS_UDP; sub UDP_CLIENT_DATA{ $data = OS_UDP::payload; $data_hex = unpack("H*", "$data"); print "Hex format of UDP payload is - $data_hex\n"; } OS_UDP::payload ($data) Replaces the existing UDP payload in a packet with the value supplied. Context Can be called in UDP context only. Usage Can be used to modify the UDP payload.
4 Methods Example use OS_UDP; sub UDP_CLIENT_DATA{ $data = OS_UDP::payload; $data_hex = unpack("H*", "$data"); $data ~= s/xyz/abc/g; OS_UDP::payload($data); } OS_UDP::raw Description Returns the data within a UDP packet including the UDP header. Context Called in context of UDP. Usage Used in performing load-balancing based on the whole UDP packet. Input Parameters None. Return Values The following table contains the return values.
Chapter HTTP REQUEST API reference 5 In this chapter This chapter contains the following sections: • Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 • Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Overview The OS_HTTP_REQUEST module includes the APIs to retrieve or set the value of the fields in the current HTTP request headers.
5 Methods Usage Can be used to perform load-balancing based on the method. Input Parameters None. Return Values The following table contains the return values. TABLE 29 Name Return Values Type Description string value of the method type if present. If not present, undefined is returned.
Methods 5 Input Parameters The following table contains the input values. TABLE 30 Input Values Name Type Description $val string A string representing the value of the method type. Return Values None Example use OS_HTTP_REQUEST; sub HTTP_REQUEST{ OS_HTTP_REQUEST::method("GET"); } OS_HTTP_REQUEST::url Returns url specified in HTTP request header if it exists, otherwise it will return NULL. Context HTTP request event. If called in the HTTP response context, undefined will be returned.
5 Methods Example use OS_HTTP_REQUEST; use OS_SLB; sub HTTP_REQUEST{ my $url = OS_HTTP_REQUEST::url; my $method = OS_HTTP_REQUEST::method; if ( defined $url && $url eq "/index.html" ){ OS_SLB::forward(1); } elsif ( defined $method && $method eq "GET" ) { OS_SLB::forward(2); } } OS_HTTP_REQUEST::url($val) Sets the value of the URL to the value specified in $val. Context HTTP request event. If called in the HTTP response context, undefined will be returned. Usage Can be used to rewrite a url.
Methods 5 OS_HTTP_REQUEST::path Returns URL path specified in HTTP request header if it exists, otherwise it will return NULL. Context HTTP request event. If called in the HTTP response context, undefined will be returned. Usage Can be used to perform load-balancing based on the url path. Input Parameters None. Return Values The following table contains the return values. TABLE 33 Return Values Name Type Description string Value of the url. If not present, undefined is returned.
5 Methods Input Parameters The following table contains the input values. TABLE 34 Input Values Name Type Description $val string A string representing the value of the URL path Return Values None Example use OS_HTTP_REQUEST; sub HTTP_REQUEST{ OS_HTTP_REQUEST::path("/search/"); } OS_HTTP_REQUEST::query Returns URL query specified in the HTTP request header if it exists, otherwise it will return NULL. Context HTTP request event.
Methods 5 Example use OS_SLB; use OS_HTTP_REQUEST; sub HTTP_REQUEST{ my $query = OS_HTTP_REQUEST::query; my $method = OS_HTTP_REQUEST::method; if ( defined $querry && $query eq "search=sometext") { OS_SLB::forward(1); } elsif ( defined $query && query eq "search=othertext") { OS_SLB::forward(2); } } OS_HTTP_REQUEST::query($val) Sets the value of the URL query to the value specified in $val. Context HTTP request event. If called in the HTTP response context, undefined will be returned.
5 Methods OS_HTTP_REQUEST::url_extension Returns URL extension specified in the HTTP request header if it exists, otherwise it will return NULL. Context HTTP request event. If called in the HTTP response context, undefined will be returned. Usage Can be used to perform load-balancing based on a url extension. Input Parameters None. Return Values The following table contains the return values. TABLE 37 Name Return Values Type Description string Value of the URL extension.
Methods 5 Usage Can be used to perform load-balancing based on the version. Input Parameters None. Return Values The following table contains the return values. TABLE 38 Return Values Name Type Description string Value of the request version. If not present, undefined is returned. Example use OS_HTTP_REQUEST; use OS_SLB; sub HTTP_REQUEST{ my $version = OS_HTTP_REQUEST::version; my $method = OS_HTTP_REQUEST::method; if ( defined $version && $version eq "1.
5 Methods Return Values None Example use OS_HTTP_REQUEST; sub HTTP_REQUEST{ OS_HTTP_REQUEST::version("1.1"); } OS_HTTP_REQUEST::header($name) Return the HTTP header value of the header specified by the value in $name. Context HTTP request event. If called in the HTTP response context, undefined will be returned. Usage Can be used to perform load-balancing based on the specified header. Input Parameters The following table contains the input values.
Methods 5 Example use OS_SLB; use OS_HTTP_REQUEST; sub HTTP_REQUEST { my $hostheader = OS_HTTP_REQUEST::header("Host"); if (defined $hostheader && $hostheader eq "www.abc.com") { OS_SLB::forward(1); } else { OS_SLB::forward(2); } } OS_HTTP_REQUEST::header($name, $value) Set the HTTP header value to the value specified in $name. Context HTTP request event. If called in the HTTP response context, undefined will be returned. Usage Can be used to replace an existing header or to insert a new header.
5 Methods OS_HTTP_REQUEST::headers($name) Gets all the HTTP headers with the same name as an array. This can be useful in a scenario where the request is coming through multiple proxies and has many X-Forwarded-For headers. Context HTTP request event. If called in the HTTP response context, undefined will be returned. Input Parameters The following table contains the input values. TABLE 43 Input Values Name Type Description $name string A string representing the value of the header name.
Methods 5 Return Values The following table contains the return values. TABLE 45 Return Values Name Type Description string value of the host. If not present, undefined is returned. Example use OS_HTTP_REQUEST; use OS_SLB; sub HTTP_REQUEST{ my $host = OS_HTTP_REQUEST::host; if (defined $host && $host eq "www.brocade.com" ) { OS_SLB::forward(1); } } OS_HTTP_REQUEST::host($value) Sets the value of the host to the value specified in $value. Context HTTP request event.
5 Methods OS_HTTP_REQUEST::collect Starts collecting an HTTP request payload. This is useful only for HTTP requests with a payload component (for example: POST requests). • An “HTTP_REQUEST_DATA” event will be triggered once the collect condition is satisfied. • A server load balancing action cannot be taken based on the content collected. • If more data is needed after the “HTTP_REQUEST_DATA” event is triggered, the collect function should be called again to start a new data collection sequence.
Methods 5 OS_HTTP_REQUEST::content Returns the request content specified in the HTTP request if it exists otherwise it will return undefined. A server load balancing action cannot be taken based on the content collected. The size of content returned can be: 1. Larger than specified in the collect call if more data is available when the content is called. 2. Smaller than specified in the collect call if the actual complete body is smaller.
5 Methods OS_HTTP_REQUEST::content($value) Sets the request content to the value specified in $value. Context This function called in http response context will have no effect. Input Parameters The following table contains the input values. TABLE 49 Input Values Name Type Description $value string A string representing the value of the request content. Return Values None Performance impact Using this function will have a significant impact on system performance.
Methods 5 Usage Can be used to insert a header. Input Parameters The following table contains the input values. TABLE 50 Input Values Name Type Description $name string A string representing the name of the HTTP header. $value string A string representing the value of the HTTP header.
5 Methods Input Parameters The following table contains the input values. TABLE 51 Input Values Name Type Description $name string A string representing the name of the HTTP header. Return Values None Example use OS_HTTP_REQUEST; sub HTTP_REQUEST{ OS_HTTP_REQUEST::remove_header("X-forwarded-for"); } OS_HTTP_REQUEST::remove_all_headers($name) Removes all HTTP headers with the same specified names. If such a header is not present, this function will have no effect.
Methods 5 Example use OS_HTTP_REQUEST; sub HTTP_REQUEST{ OS_HTTP_REQUEST::remove_all_headers("X-forwarded-for"); } OS_HTTP_REQUEST::content_type Returns request content type if the content-type header is present otherwise it returns NULL. Context TTP request event. If called in the HTTP response context, undefined will be returned. Usage Can be used to perform load-balancing based on the content type. Input Parameters None. Return Values The following table contains the return values.
5 Methods Usage Can be used to perform load-balancing based on the content length. Input Parameters None. Return Values The following table contains the return values. TABLE 54 Name Return Values Type Description integer The length of the request content Example use OS_HTTP_REQUEST; sub HTTP_REQUEST{ my $content_length = OS_HTTP_REQUEST::content_length; } OS_HTTP_REQUEST::cookie ($name) Returns the cookie value specified by $name if it is present otherwise it returns undefined.
Methods 5 Return Values The following table contains the return values. TABLE 56 Return Values Name Type Description string Value of the cookies specified by $name. If not present, undefined is returned. Example use OS_HTTP_REQUEST; sub HTTP_REQUEST{ my $server_id = OS_HTTP_REQUEST::cookie("ServerID"); } OS_HTTP_REQUEST::cookie ($name, $value) Sets the cookie value specified by $name. Context HTTP request event. If called in the HTTP response context, undefined will be returned.
5 Methods OS_HTTP_REQUEST::cookie_count Returns the number of cookies present in the HTTP request. Context This function called in http response context will have no effect. Usage Can be used to perform load-balancing based on the number of cookies. Input Parameters None. Return Values The following table contains the return values. TABLE 58 Name Return Values Type Description integer The number of cookies present in the request.
Methods 5 Input Parameters The following table contains the input values. TABLE 59 Input Values Name Type Description $cookie_name string A string representing the name of the inserted cookie. $domain string A string representing the domain attribute of the inserted cookie. $path string A string representing the path attribute of the inserted cookie. $age integer An integer representing the age attribute of the inserted cookie. The unit is minute, for example 60 = 1 hour.
5 Methods Input Parameters The following table contains the input values. TABLE 60 Input Values Name Type Description $domain_value string A string representing the value of the domain name. $status_code integer An integer representing the status code. $url_value string A string representing the value of the URL. $port_value integer An integer representing the value of the port. Return Values None Example use OS_HTTP_REQUEST; sub HTTP_REQUEST { OS_HTTP_REQUEST::redirect(domain=>'www.
Methods 5 Example use OS_HTTP_REQUEST; sub HTTP_REQUEST{ my $all_headers = OS_HTTP_REQUEST::headers_as_string; } Brocade Virtual ADX OpenScript API Guide 53-1003243-01 61
5 62 Methods Brocade Virtual ADX OpenScript API Guide 53-1003243-01
Chapter HTTP RESPONSE API reference 6 In this chapter This chapter contains the following sections: • Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 • Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Overview The OS_HTTP_RESPONSE module includes the APIs to retrieve or set the value of the fields in the current HTTP response headers.
6 Methods Usage Can be used to retrieve the response code. Input Parameters None. Return Values The following table contains the return values. TABLE 62 Return Values Name Type Description integer The value of response code. Example use OS_HTTP_RESPONSE; sub HTTP_RESPONSE{ my $code = OS_HTTP_RESPONSE::code; } OS_HTTP_RESPONSE::code ($val) Sets the status code specified by $val. Context This function called in http request context will have no effect. Usage Can be used to rewrite the code.
Methods 6 Example use OS_HTTP_RESPONSE; sub HTTP_RESPONSE{ OS_HTTP_RESPONSE::code(”200”); } OS_HTTP_RESPONSE::version Returns the response version specified in the HTTP response header if it exists otherwise it returns NULL. Context This function called in http request context will have no effect. Usage Can be used to retrieve the version. Input Parameters None. Return Values The following table contains the return values.
6 Methods Usage Can be used to set the version. Input Parameters The following table contains the input values. TABLE 65 Input Values Name Type Description $val string An string representing the version value. Return Values None Example use OS_HTTP_RESPONSE; sub HTTP_RESPONSE{ OS_HTTP_RESPONSE::version("1.1"); } OS_HTTP_RESPONSE::header ($name) Returns the value of the HTTP header specified by $name if present otherwise undefined.
Methods 6 Return Values The following table contains the return values. TABLE 67 Return Values Name Type Description string The value of the HTTP header specified by $name if present otherwise undefined. Example use OS_HTTP_RESPONSE; sub HTTP_RESPONSE{ my $cookie = OS_HTTP_RESPONSE::header("Set-Cookie"); } OS_HTTP_RESPONSE::header ($name, $value) Sets the HTTP header value specified in $name. Context This function called in http request context will have no effect.
6 Methods Example use OS_HTTP_RESPONSE; sub HTTP_RESPONSE{ if ( defined $version && version eq "1.0") { OS_HTTP_RESPONSE::header("Set-Cookie", "ServerID=1101"); } } OS_HTTP_RESPONSE::headers($name) Gets the HTTP headers with the same name as a array. Context This function called in context other than http response will have no effect. Input Parameters The following table contains the input values.
Methods 6 Context This function can be called from an HTTP_RESPONSE_DATA event. Usage This function is useful only for HTTP responses with a payload component. Input Parameters The following table contains the input values. TABLE 71 Input Values Name Type Description 1 Collects the whole body of the response requested. integer Specifies the minimum number of bytes of the response body data to be collected. none Collects response body data per packet.
6 Methods Usage A server load balancing action cannot be taken based on the content collected. Input Parameters None. Return Values The following table contains the return values. TABLE 72 Name Return Values Type Description string The value of the response content if present otherwise undefined. Performance impact Use of this function will have a significant impact to system performance.
Methods 6 Return Values None Performance impact Using this function will have a significant impact on system performance.
6 Methods Example use OS_HTTP_RESPONSE; sub HTTP_RESPONSE{ OS_HTTP_RESPONSE::push_header("my-header", "my header value"); } OS_HTTP_RESPONSE::remove_header ($name) Removes the HTTP header specified in $name. If no header is present, this function will have no effect. NOTE This API will remove a header with a value specified for the $name variable (case insensitive).
Methods 6 NOTE This API will remove all headers with a value specified by the $name variable (case insensitive). For example, OS_HTTP_RESPONSE::remove_all_headers("X-Forwarded-For") will remove ALL occurrences of headers by that name (case insensitive). Context This function called in a context other than the http response context will have no effect. Input Parameters The following table contains the input values.
6 Methods Return Values The following table contains the return values. TABLE 77 Return Values Name Type Description string Value of the response content type. If not present, undefined is returned. Example use OS_HTTP_RESPONSE; sub HTTP_RESPONSE{ my $content_type = OS_HTTP_RESPONSE::content_type; } OS_HTTP_RESPONSE::content_length Returns response content length specified in the HTTP response if it exists, otherwise it will return NULL.
Methods 6 Example use OS_HTTP_RESPONSE; sub HTTP_RESPONSE{ my $content_length = OS_HTTP_RESPONSE::content_length; } OS_HTTP_RESPONSE::cookie ($name) Returns the cookie value for the cookies specified by the $name variable if it is present, otherwise undefined is returned. Context This function called in http request context will have no effect. Usage Can be used to rewrite the cookie value. Input Parameters The following table contains the input values.
6 Methods Context This function called in http request context will have no effect. Usage Can be used to rewrite the cookie value. Input Parameters The following table contains the input values. TABLE 81 Input Values Name Type Description $name string A string representing the cookie name. $value string A string representing the cookie value.
Methods 6 Input Parameters The following table contains the input values. TABLE 82 Input Values Name Type Description $name string A string representing the cookie name. Return Values The following table contains the output values. TABLE 83 Input Values Name Type Description string Value of the cookie version specified by $name.
6 Methods Example use OS_HTTP_RESPONSE; sub HTTP_RESPONSE{ OS_HTTP_RESPONSE::cookie_version("ServerID","1048"); } OS_HTTP_RESPONSE::cookie_path ($name) Gets the cookie path specified by $name if it is present otherwise it returns undefined. Context This function called in http request context will have no effect. Usage Can be used to get the cookie path. Input Parameters The following table contains the input values.
Methods 6 Context This function called in http request context will have no effect. Usage Can be used to set the cookie path. Input Parameters The following table contains the input values. TABLE 87 Input Values Name Type Description $name string A string representing the cookie name. $value string Value of the cookie path for the cookie specified by $name.
6 Methods Return Values The following table contains the output values. TABLE 89 Input Values Name Type Description string Value of the domain for the cookie specified by $name. Example use OS_HTTP_RESPONSE; sub HTTP_RESPONSE{ my $cookie_domain = OS_HTTP_RESPONSE::cookie_domain("ServerID"); } OS_HTTP_RESPONSE::cookie_domain($name, $value) Sets the cookie domain of the cookie specified by $name to the value specified by $value. If it is not present there is no operation.
Methods 6 Example use OS_HTTP_RESPONSE; sub HTTP_RESPONSE{ OS_HTTP_RESPONSE::cookie_domain("ServerID", "www.brocade.com"); } OS_HTTP_RESPONSE::cookie_port ($name) Gets the cookie ports for the cookie specified by $name if it is present otherwise it returns undefined. Context This function called in http request context will have no effect. Usage Can be used to get the cookie ports. Input Parameters The following table contains the input values.
6 Methods OS_HTTP_RESPONSE::cookie_port ($name, $value) Sets the ports of the cookie specified by $name to the value specified by $value. If it is not present there is no operation. Context This function called in http request context will have no effect. Usage Can be used to set the cookie ports. Input Parameters The following table contains the input values. TABLE 93 Input Values Name Type Description $name string A string representing the cookie name.
Methods 6 Input Parameters The following table contains the input values. TABLE 94 Input Values Name Type Description $name string A string representing the cookie name. Return Values The following table contains the output values. TABLE 95 Input Values Name Type Description string Value of the max age for the ports for the cookie specified by $name.
6 Methods Return Values None. Example use OS_HTTP_RESPONSE; sub HTTP_RESPONSE{ OS_HTTP_RESPONSE::cookie_maxage("ServerID", "100"); } OS_HTTP_RESPONSE::cookie_expiration($name) Gets the expiration date and time for the cookie specified by $name if it is present otherwise it returns undefined. Context This function called in http request context will have no effect. Usage Can be used to get expiration date for a cookie. Input Parameters The following table contains the input values.
Methods 6 OS_HTTP_RESPONSE::cookie_expiration($name, $value) Sets the expiration date and time of the cookie specified by $name to the value specified by $value. Context This function called in http request context will have no effect. Usage Can be used to set the expiration date and time for a cookie. Input Parameters The following table contains the input values. TABLE 99 Input Values Name Type Description $name string A string representing the cookie name.
6 Methods Input Parameters The following table contains the input values. TABLE 100 Input Values Name Type Description $name string A string representing the cookie name. Return Values The following table contains the output values. TABLE 101 Name Input Values Type Description string Comment value for the cookie specified by $name.
Methods 6 Return Values None. Example use OS_HTTP_RESPONSE; sub HTTP_RESPONSE{ OS_HTTP_RESPONSE::cookie_comment("ServerID", "cookie comment"); } OS_HTTP_RESPONSE::cookie_count Returns the number of cookies present in the HTTP response. Context This function called in http request context will have no effect. Usage Can be used to return the number of cookies present. Input Parameters None. Return Values The following table contains the return values.
6 Methods OS_HTTP_RESPONSE::headers_as_string Returns a string representation of all HTTP response headers. Context This function called in http request context will have no effect. Usage Can be used to retrieve the HTTP headers and to parse in the script. Input Parameters None. Return Values The following table contains the return values. TABLE 104 Name Return Values Type Description string All HTTP response headers represented as a string.
Chapter Server Load Balancing API Reference 7 In this chapter This chapter contains the following sections: • Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 • Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 Overview The OS_SLB module includes the APIs to retrieve the information about real servers. These APIs can be called from any event.
7 Methods Input Parameters The following table contains the input values. TABLE 105 Input Values Name Type Description $id integer The server ID. Return Values The following table contains the return values. TABLE 106 Name Return Values Type Description string The server name that corresponds to the ID value specified by $id.
Methods 7 Return Values The following table contains the return values. TABLE 108 Return Values Name Type Description integer The server ID that corresponds to the name value specified by $name. Example use OS_SLB; use OS_HTTP_REQUEST; sub HTTP_REQUEST{ my $id = OS_SLB::server_id("rs1", 80); print "The id of the real server rs1 port 80 is: $id\n"; } OS_SLB:: servers($group_id) Returns an array of real servers that belong to the group specified by $group_id.
7 Methods Example use OS_SLB; use OS_HTTP_REQUEST; sub HTTP_REQUEST{ my @servers = OS_SLB::servers($id); } OS_SLB::is_server_up("server-name"=>$name, "server-id"=>$id, "port"=>$port) Returns “1” if the server specified by $name, $port or $id is up. Context This function can be called from any event. Usage Can be used to check the server health status from the script. Input Parameters The following table contains the input values.
Methods 7 Example use OS_SLB; use OS_HTTP_REQUEST; sub HTTP_REQUEST{ if(OS_SLB::is_server_up("server-name" => "rs1", "port" => 80) == 0) { print "Real server rs1 port 80 is down\n"; } } OS_SLB:: get_server_current_connections($name) Returns the number of current connections for the real server specified by $name. Context This function can be called from any event. Usage Can be used for monitoring purpose. Input Parameters The following table contains the input values.
7 Methods OS_SLB:: get_server_port_current_connections ($name, $port) Returns the current connections for the real server port specified by $name. Context This function can be called from any event. Usage Can be used for monitoring purposes. Input Parameters The following table contains the input values. TABLE 115 Input Values Name Type Description $name string The real server name. $port integer The port number. Return Values The following table contains the return values.
Methods 7 Usage Can be used to perform SSL specific operations. Input Parameters None. Return Values The following table contains the return values. TABLE 117 Return Values Name Type Description integer 1 is returned if the client connection is SSL. Otherwise 0 is returned. Example use OS_SLB; use OS_HTTP_REQUEST; sub HTTP_REQUEST { if(OS_SLB::is_client_ssl == 1) { print "The client connection is SSL\n"; } } OS_SLB:: is_server_ssl Returns “1” of the current server connection is SSL.
7 Methods Return Values The following table contains the return values. TABLE 118 Name Return Values Type Description integer 1 is returned if the server connection is SSL. Otherwise 0 is returned. Example use OS_SLB; use OS_HTTP_REQUEST; sub HTTP_REQUEST { if(OS_SLB::is_server_ssl == 1) { print "The server connection is SSL\n"; } } OS_SLB:: persist($method, $string) Causes the system to select a real server based on the persist method specified by $method and $string.
Methods 7 Return Values None Example use OS_HTTP_REQUEST; use OS_SLB; sub HTTP_REQUEST{ OS_SLB::persist("hash-to-bucket", OS_HTTP_REQUEST::url); } OS_SLB:: passive_persist($method, $string) Causes the system to add a persist entry to the system. Context This function can be called from HTTP events. Usage Can be used with the persist action to perform passive persist. Input Parameters The following table contains the input values.
7 Methods OS_SLB:: persist_lookup($method, $string) Returns the server name stored in the persist entry. Context This function can be called from HTTP events. Usage Can be used to return the server name stored in the persist entry. Input Parameters The following table contains the input values. TABLE 121 Input Values Name Type Description $method method The value of passive-persist. $string string The string to persist on.
Methods 7 Example use OS_SLB; use OS_HTTP_REQUEST; use OS_HTTP_RESPONSE; sub HTTP_REQUEST { # Get the Cookie from the request my $mycookie = OS_HTTP_REQUEST::cookie("ServerID"); #print "\n my cookie is: $mycookie\n"; if (defined $mycookie) { $serverName = OS_SLB::persist_lookup("passive-persist", "$mycookie"); #print "\n\n\n &&& my server is: $serverName\n"; } if (defined $serverName ) { # forward to server based on passive cookie persistence OS_SLB::persist("passive-persist","$mycookie"); } else { OS_SLB
7 Methods Input Parameters The following table contains the input values. TABLE 122 Input Values Name Type Description $data string The error page you want to send (optional) string The default string sent if one is not specified by $data. I Return Values None Example use OS_SLB; use OS_HTTP_REQUEST; sub HTTP_REQUEST{ OS_SLB::reply("HTTP/1.1 403 Forbidden\r\nServer: HTTP Proxy/1.
Methods 7 Example use OS_SLB; use OS_HTTP_REQUEST; sub HTTP_REQUEST{ OS_SLB::reset_client; } OS _SLB:: log($log_string) Description Causes the system to send the log string to the syslog. Context This function can be called from an HTTP request event. Usage Can be used to view the log string sent to the syslog. NOTE The syslog server should be connected to the Brocade Virtual ADX via its data ports. Input Parameters The following table contains the input values.
7 Methods OS _SLB:: drop Description Causes the system to drop a UDP packet. Context This function can be called from UDP events. Input Parameters None. Return Values None. Example use OS_SLB; use OS_UDP; sub UDP_CLIENT_DATA{ OS_SLB::drop; } OS _SLB:: forward($server) Description Causes the system to send a request to a server specified by $server_id or $group_id. If use $group_id here. OS_SLB::forward can be used in most of the events, like OS_HTTP_REQUEST and OS_HTTP_RESPONSE.
Methods 7 Input Parameters The following table contains the input values. TABLE 124 Input Values Name Type Description $server string Server name. Integer Values of 1 to 1024 for group ID and 1025 and above for real server ID NOTE If no input is included, the system will perform Layer-4 load balancing. Return Values None.
7 Methods Return Values None. Example use OS_SLB; use OS_TCP sub TCP_SERVER_ESTABLISHED{ OS_TCP::collect; } sub TCP_SERVER_DATA { OS_SLB::send_to_client; } OS _SLB:: send_to_server Description Causes the system send the collected payload to the server. Context This function can be called from an HTTP request event. Usage This function can be used to send the payload data to the server. NOTE Data sent out will be in chunked-encoding format. Input Parameters None Return Values None.
Methods 7 Example use OS_SLB; use OS_HTTP_REQUEST; sub HTTP_REQUEST { OS_HTTP_REQUEST::collect; } sub HTTP_REQUEST_DATA { OS_SLB::send_to_server; } OS _SLB:: is_group_up($group-id) Description Returns the state of the certain group. Context This function can be called from any event. Usage This function can be used to check the state of the certain group. Input Parameters The following table contains the input values. TABLE 125 Input Values Name Type Description $group-id Integer The group id.
7 Methods Example use OS_SLB; use OS_HTTP_REQUEST; sub HTTP_REQUEST { my $groupStatus = OS_SLB::is_group_up(“10”); } NOTE This API returns the status of the real server ports, which belong to group-id 10, that are bind to the virtual service port where OpenScript is bind only. OS _SLB:: virtual_server_name() Description Returns the name of the virtual server. Context This function can be called from any event. Usage This function can be used to check the virtual server name.
Chapter 8 Connection API Reference In this chapter This chapter contains the following sections: • Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 • Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 Overview The OS_CONN module includes the APIs to retrieve the information about client and server connections. These APIs can be called from any event.
8 Methods Return Values The following table contains the return values. TABLE 129 Name Return Values Type Description integer The index of the client connection in the current flow.
Chapter Content Inspection API Reference 9 In this chapter This chapter contains the following sections: • OS_PAYLOAD_INSPECT module overview . . . . . . . . . . . . . . . . . . . . . . . . . . 109 • Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9 Methods • Content Inspection API operations are transactional: - The matching and replacing of content are within the boundary of each HTTP transaction. You can choose to turn on or off content inspection based on predefined parameters such as HTML Content-Type. - There is no partial matching capability. When scanning content for a pattern, either there is a match or there is not.
Methods TABLE 130 9 Input values (Continued) Name Type Description regexp3 regular expression An optional additional regular expression to match with a maximum length of 128 bytes. string3 string The replacement string for the regexp3 matched regular expression. The string can be a fixed length only with a maximum length of 128 bytes.
9 Methods Input parameters The following table contains the input values. TABLE 131 Input values Name Type Description regexp1 regular expression The regular expression to match with a maximum length of 128 bytes. regexp2 regular expression An optional additional regular expression to match with a maximum length of 128 bytes. regexp3 regular expression An optional additional regular expression to match with a maximum length of 128 bytes.
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.
9 Methods TABLE 132 Input values (Continued) Name Type Description mstr3 string The string to match. The string can be a fixed length only with a maximum length of 128 bytes. rstr3 string The replacement string for the mstr3 matched string. The string can be a fixed length only with a maximum length of 128 bytes.
Methods 9 In the following example, when response content type is text, the script replaces all of the "correct" strings with "valid", the "This" string with "That", and the "test" string with "TEST" in the response payload .
9 Methods Example In the following example, the script changes the maximum match size during payload matching from the default value of 1024 to 512. use OS_HTTP_RESPONSE; use OS_PAYLOAD_INSPECT; sub HTTP_RESPONSE { if (OS_HTTP_RESPONSE::content_type =~ /text/) { OS_PAYLOAD_INSPECT::match_size(512); OS_PAYLOAD_INSPECT::substitute( ‘credit*card=[0-9]{32}’,‘#### ####’, ‘SSN=[0-9]{9}’,‘###-##-####’); } } OS_PAYLOAD_INSPECT::disable () Disables payload inspection for the current transaction.
Methods 9 OS_PAYLOAD_INSPECT::matched_str () Returns the substring that was matched in scanning payload data during a OS_PAYLOAD_INSPECT::match(regexp1, [regexp2 …]) call. Context This function is only callable in the PAYLOAD_INSPECT_MATCHED event. Return values The following table contains the return values. TABLE 134 Return values Name Type Description string String that is the matched substring.
9 Methods 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.
Methods 9 Example In the following example, the script scans the payload to read the member information. If it finds the ‘visitor’ string, it logs a warning on the log server and replaces ‘login.php' with 'visitor.php'. If it finds other member information, it replaces 'login.php' with 'gold_login' or 'basic_login'.
9 120 Methods Brocade Virtual ADX OpenScript API Guide 53-1003243-01