rfc2723.txt

来自「中、英文RFC文档大全打包下载完全版 .」· 文本 代码 · 共 1,236 行 · 第 1/3 页

TXT
1,236
字号
   An ELSE Clause provides a statement which will be executed if the   IF's test fails.  The statement following ELSE will often be another   IF statement, providing SRL's version of a 'select' statement.  Note   that an ELSE clause always matches the immediately preceding IF.3.2  Compound_statement   -------+-------------+----- { ---+---- Statement ----+--- } -------          |             |           |                   |          +-- label : --+           +--------<----------+   A compound statement is a sequence of statements enclosed in braces.   Each statement will terminate with a semicolon, unless it is another   compound statement (which terminates with a right brace).   A compound statement may be labelled, i.e. preceded by an identifier   followed by a semi-colon.  Each statement inside the braces is   executed in sequence unless an EXIT statement is performed, as   explained below.   Labels have a well-defined scope, within which they must be unique.   Labels within a subroutine (i.e. between a SUBROUTINE and its   matching ENDSUB) are local to that subroutine and are not visible   outside it.  Labels outside subroutines are part of a program's outer   block.Brownlee                     Informational                      [Page 8]RFC 2723              SRL: A Traffic Flow Language          October 19993.3  Imperative_statement   ------+---------------------------------------------------+------ ;         |                                                   |         +-- SAVE attrib --+--+-----------+--+---------------+         |                 |  |           |  |               |         |                 |  +- / width -+  |               |         |                 |  |           |  |               |         |                 |  +- & mask --+  |               |         |                 |                 |               |         |                 +--- = operand ---+               |         |                                                   |         +-- COUNT ------------------------------------------+         |                                                   |         +-- EXIT label  ------------------------------------+         |                                                   |         +-- IGNORE -----------------------------------------+         |                                                   |         +-- NOMATCH ----------------------------------------+         |                                                   |         +-- RETURN --+-------+------------------------------+         |            |       |                              |         |            +-- n --+                              |         |                                                   |         +-- STORE variable := value ------------------------+3.3.1  SAVE Statement   The SAVE statement saves information which will (later) identify the   flow in the meter's flow table.  It does not actually record anything   in the table; this is done when a subsequent COUNT statement   executes.   SAVE has two possible forms:   SAVE attrib = operand ; saves the attribute, mask and value as given        in the statement.  This form of the SAVE statement is similar to        that allowed in an IF statement, except that - since imperative        statements do not perform a test - you may save an arbitrary        value.   SAVE attrib ;   SAVE attrib / width ;   SAVE attrib & mask ; saves the attribute and mask from the statement,        and the value resulting from their application to the current        packet.  This is most useful when used to save a value with a        wider mask than than was used to select the packet.  For        example:Brownlee                     Informational                      [Page 9]RFC 2723              SRL: A Traffic Flow Language          October 1999             IF DestPeerAddress == 130.216/16                     NOMATCH;             ELSE IF SourcePeerAddress == 130.216/16 {                     SAVE SourcePeerAddress /24;                     COUNT;                     }             ELSE IGNORE;3.3.2  COUNT Statement   The COUNT statement appears after all testing and saving is complete;   it instructs the PME to build the flow identifier from the attributes   which have been SAVEd, find it in the meter's flow table (creating a   new entry if this is the first packet observed for the flow), and   increment its counters.  The meter then moves on to examine the next   incoming packet.3.3.3  EXIT Statement   The EXIT statement exits a labelled compound statement.  The next   statement to be executed will be the one following that compound   statement.  This provides a well-defined way to jump to a clearly   identified point in a program.  For example:   outer: {      ...      if SourcePeerAddress == 192.168/16         exit outer;  # exits the statement labelled 'outer'      ...      }   # execution resumes here   In practice the language provides sufficient logical structure that   one seldom - if ever - needs to use the EXIT statement.3.3.4  IGNORE Statement   The IGNORE statement terminates examination of the current packet   without saving any information from it.  The meter then moves on to   examine the next incoming packet, beginning again at the first   statement of its program.3.3.5  NOMATCH Statement   The NOMATCH statement indicates that matching has failed for this   execution of the program.  If it is executed when a packet is being   processed with its addresses in 'on the wire' order, the PME willBrownlee                     Informational                     [Page 10]RFC 2723              SRL: A Traffic Flow Language          October 1999   perform the program again from the beginning with source and   destination addresses interchanged.  If it is executed following such   an interchange, the packet will be IGNOREd.   NOMATCH is illustrated in the SAVE example (section 3.3.1), where it   is used to ensure that flows having 130.216/16 as an end-point are   counted as though 130.216 had been those flows' source peer (IP)   address.3.3.6  STORE Statement   The STORE statement assigns a value to an SRL variable and SAVEs it.   There are six SRL variables:           SourceClass        SourceKind           DestClass          DestKind           FlowClass          FlowKind   Their names have no particular significance; they were arbitrarily   chosen as likely RTFM attributes but can be used to store any   single-byte integer values.  Their values are set to zero each time   examination of a new packet begins.  For example:   STORE SourceClass := 3;   STORE FlowKind := 'W'3.3.7  RETURN Statement   The RETURN statement is used to return from subroutines and can be   used only within the context of a subroutine.  It is described in   detail below (CALL statement).3.4  Subroutine_declaration   -- SUBROUTINE subname ( --+-----------------------------+-- ) -->                             |                             |                             +--+-- ADDRESS --- pname --+--+                                |                       |                                +-- VARIABLE -- pname --+                                |                       |                                +------<------- , ------+          >------+-------- Statement ---------+----- ENDSUB -------- ;                 |                            |                 +-------------<--------------+Brownlee                     Informational                     [Page 11]RFC 2723              SRL: A Traffic Flow Language          October 1999   A Subroutine declaration has three parts:      the subname is an identifier, used to name the subroutine.      the parameter list specifies the subroutine's parameters.  Each         parameter is preceded with a keyword indicating its type -         VARIABLE indicates an SRL variable (see the STORE statement         above), ADDRESS indicates any other RTFM attribute.  A         parameter name may be any identifier, and its scope is limited         to the subroutine's body.      the body specifies what processing the subroutine will perform.         This is simply a sequence of Statements, terminated by the         ENDSUB keyword.   Note that EXITs in a subroutine may not refer to labels outside it.   The only way to leave a subroutine is via a RETURN statement.3.5  CALL_statement   ---- CALL subname ( --+---------------------+-- ) ---->                         |                     |                         +--+-- parameter --+--+                            |               |                            +----<--- , ----+         >---+-------------------------------------+--- ENDCALL ---- ;             |                                     |             +---+--+-- n : --+--- Statement --+---+                 |  |         |                |                 |  +----<----+                |                 |                             |                 +--------------<--------------+   The CALL statement invokes an SRL subroutine.  The parameters are SRL   variables or other RTFM attributes, and their types must match those   in the subroutine declaration.  Following the parameters is a   sequence of statements, each preceded by an integer label.  These   labels will normally be 1:, 2:, 3:, etc, but they do not have to be   contiguous, nor in any particular order.  They are referred to in   RETURN statements within the subroutine body.   e.g. RETURN 2;   would return to the statement labelled 2:                       within in the CALL statement.   Execution of the labelled statement completes the CALL.Brownlee                     Informational                     [Page 12]RFC 2723              SRL: A Traffic Flow Language          October 1999   If the return statement does not specify a return label, the first   statement executed after RETURN will be the statement immediately   following ENDCALL.4  Example Programs4.1  Classify IP Port Numbers   #   #  Classify IP port numbers   #      define IPv4 = 1;  # Address Family number from [ASG-NBR]   #      define ftp = (20, 21);  # Well-Known Port numbers from [ASG-NBR]      define telnet = 23;      define www = 80;   #      define tcp = 6;  # Protocol numbers from [ASG-NBR]      define udp = 17;   #      if SourcePeerType == IPv4 save;      else ignore;  # Not an IPv4 packet   #      if (SourceTransType == tcp || SourceTransType == udp) save, {         if SourceTransAddress == (www, ftp, telnet)  nomatch;            # We want the well-known port as Dest   #         if DestTransAddress == telnet            save, store FlowKind := 'T';         else if DestTransAddress == www            save, store FlowKind := 'W';         else if DestTransAddress == ftp            save, store FlowKind := 'F';         else {            save DestTransAddress;            store FlowKind := '?';            }         }      else save SourceTransType = 0;   #      save SourcePeerAddress /32;      save DestPeerAddress   /32;      count;   #Brownlee                     Informational                     [Page 13]RFC 2723              SRL: A Traffic Flow Language          October 1999   This program counts only IP packets, saving SourceTransType (tcp, udp   or 0), Source- and DestPeerAddress (32-bit IP addresses) and FlowKind   ('W' for www, 'F' for ftp, 'T' for telnet, '?' for unclassified).   The program uses a NOMATCH action to specify the packet direction -   its resulting flows will have the well-known ports as their   destination.4.2  Classify Traffic into Groups of Networks   #   # SRL program to classify traffic into network groups   #   define my_net = 130.216/16;   define k_nets = ( 130.217/16, 130.123/16, 130.195/16,                    132.181/16, 138.75/16, 139.80/16 );   #      call net_kind (SourcePeerAddress, SourceKind)         endcall;      call net_kind (DestPeerAddress,   DestKind)         endcall;      count;   #      subroutine net_kind (address addr, variable net)         if addr == my_net save, {            store net := 10;  return 1;            }         else if addr == k_nets save, {            store net := 20;  return 2;            }         save addr/24;  # Not my_net or in k_nets         store net := 30;  return 3;         endsub;   #   The net_kind subroutine determines whether addr is my network   (130.216), one of the Kawaihiko networks (in the k_nets list), or   some other network.  It saves the network address from addr (16 bits   for my_net and the k_net networks, 24 bits for others), stores a   value of 10, 20 or 30 in net, and returns to 1:, 2:  or 3:.  Note   that the network numbers used are contained within the two DEFINEs,   making them easy to change.   net_kind is called twice, saving Source- and DestPeerAddress and   Source- and DestKind; the COUNT statement produces flows identified   by these four RTFM attributes, with no particular source-dest   ordering.Brownlee                     Informational                     [Page 14]RFC 2723              SRL: A Traffic Flow Language          October 1999   In the program no use is made of return numbers and they could have   been omitted.  However, we might wish to re-use the subroutine in   another program doing different things for different return numbers,   as in the version below.   call net_kind (DestPeerAddress, DestKind)      1: nomatch;  # We want my_net as source         endcall;   call net_kind (SourcePeerAddress, SourceKind)      1: count;    # my_net -> other networks         endcall;   save SourcePeerAddress /24;   save DestPeerAddress /24;   count;   This version uses a NOMATCH statement to ensure that its resulting   flows have my_net as their source.  The NOMATCH also rejects my_net   -> my_net traffic.  Traffic which doesn't have my_net as source or   destination saves 24 bits of its peer addresses (the subroutine might   only have saved 16) before counting such an unusual flow.5  Security Considerations   SRL is a language for creating rulesets (i.e. configuration files)   for RTFM Traffic Meters - it does not present any security issues in   itself.   On the other hand, flow data gathered using such rulesets may well be   valuable.  It is therefore important to take proper precautions to   ensure that access to the meter and its data is secure.  Ways to   achieve this are discussed in detail in the Architecture and Meter   MIB documents [RTFM-ARC, RTFM-MIB].6  IANA Considerations

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?