beautypg.com

Openscript fundamentals, Overview, Structure of a brocade virtual adx perl script – Brocade Virtual ADX OpenScript Programmer’s Guide (Supporting ADX v03.1.00) User Manual

Page 15: Chapter 2, Chapter

background image

Brocade Virtual ADX OpenScript Programmer’s Guide

7

53-1003244-01

Chapter

2

OpenScript Fundamentals

Overview

This following sections of this chapter describe the process of creating a simple script using the
Perl-based, OpenScript environment.

Structure of a Brocade Virtual ADX Perl script

The structure of a Perl script written for OpenScript differs slightly from the standard free-flowing
script program usually associated with Perl. In a regular Perl script, methods (subs) can be freely
defined and invoked from the main body of the script. To provide for optimal packet processing,
scripts written for the OpenScript environment build their behavior around the scripting engine with
application and protocol event handlers. These handlers are a published list of events that a user
script can catch by enclosing their event handling code in a Perl function or sub named after the
event.

Table 3

provides a list of application and protocol events provided for OpenScript. For a

complete list of events, refer to the Brocade OpenScript API Reference Guide.

TABLE 3

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.
NOTE: Only triggered by

OS_HTTP_REQUEST::
collect() API.

HTTP_REQUEST_DATA

Inspect and modify HTTP
request payload data.

On response header parsing
completion.

HTTP_RESPONSE

Perform response header
inspection and insertion or
deletion.

Response payload data available.
Called when entire response
payload is available.
NOTE: Only triggered by

OS_HTTP_RESPONSE::
collect() API.

HTTP_RESPONSE_DATA

Inspect and modify HTTP
response payload.

TCP

On new client SYN request.

TCP_CLIENT_SYN

Authentication, connection
rate-limiting based on IP.

On successful TCP client
connection establishment.

TCP_CLIENT_ESTABLISHED

Pre-TCP data transfer
processing context.