Provided by: wipl-daemon_20020601-11.3_i386 bug


       wipllang - Description of the wipl programming language


       This manual page describes the wipl programming language as implemented
       by the two programs wipld and wiplcExec.  Look at the pages  for  these
       programs for examples of programs usable in practice.

       The programs always have access to the shared memory area maintained by
       the wipld daemon and the purpose of the programs are to  update  and/or
       print  information  about  the  counters  in  this  area. Only a single
       program at a time can access the shared memory  area  maintained  by  a
       wipld daemon, so a program can assume that the counters are not changed
       by others while it executes.


       The following program will print the numbers from 1 to 10:

              int a=1;
              while(a<=10) {
                prints(a); print("\n");

       When executed by  wiplcExec  they  will  be  printed  on  stdout.  When
       executed  by  wipld  they will be written to the logfile. Note that the
       language does not have traditional lexical scoping.  So  the  following
       program is not valid:

              if(false) {
                int a;
              int a; // Error - variable a already declared

       A  variable  of  type int should be at least a 64 bit signed number and
       thus has more bits than the C type int has on most  current  platforms.
       An integer literal on more than 32 bits can be written in the form a:b.
       This is equivalent  to  (but  more  efficient  to  evaluate  than)  the
       expression: (a<<32)+b.

       The  language   has a bool type which can be either true or false.  You
       need an explicit cast to convert values between these two  types.   For

              int a=42;
              bool b=false;
              b=bool(a); // Ok, b will now be true
              a=int(b); // Ok, a will now be 1
              b=a; // Error
              a=b; // Error

       Besides the types int and bool the language also has the types maca and
       ipa.  A  variable  of  type  maca  can  contain  a  MAC  address  (like
       11:22:33:44:55:66) and a variable of type ipa can contain an IP version
       4 address (like

       With our new terminology we can say that wipld creates a shared  memory
       area.  This  area  contains  an array. Depending on the addressing mode
       selected by wipld the array is indexed either by the maca  or  the  ipa
       type. Each element in this array has a list of counters of type int.

       If the daemon is in MAC addressing mode you can access counter 2 of the
       MAC address 11:22:33:44:55:66 by the  expression  11:22:33:44:55:66[2].
       To set the value of this counter to 10 use:


       The following code will have the same effect:

              maca a=11:22:33:44:55:66;

       If the daemon is in IP addressing mode you should use IP instead of MAC

       A rich set of operators on int arguments is available. For example  one
       can  use  +,  -,  * and / for addition, subtraction, multiplication and
       division respectively. The operators << and >> can be used for  bitwise
       left and right shifting.

       Note  that  the  / operator has a special meaning when used in the form
       ip/number: it gives the network  part  of  the  IP  address,  with  the
       network  mask  given  by the number.  For example: is
       the  same  as,  and  is  the  same  as

       For  a  complete  reference  of the grammar of the language look in the
       module parseprg.y in the source code of wipl.


       Several functions are available for the programs and these will will be
       described below.

       print, prints
              These functions can be used to print variables or strings as the
              in the example above.  print is defined for all build  in  types
              described  above.  It  can  also be used to print strings, like:
              print("Hello World"); The prints function is  only  defined  for
              integer  arguments.  On  most platforms it will print the 64 bit
              signed parameter as an unsigned 32 bit number.

              The expression TBLcardcnt() evaluates to the number  of  entries
              (i.e.  MAC/IP addresses) in the table in the shared memory area.
              These are numbered from 0.

              The expression TBLcntcnt() evaluates to the number  of  counters
              defined for each entry in the table.

              The  expression  TBLidxget(a)  will  return  the index the given
              address has in the table. If the daemon  is  in  MAC  addressing
              mode  a must be a MAC address. If it is in IP addressing mode it
              must be an IP address. If no entry in the table exists  for  the
              given address an entry is created with all counters set to 0.

              The  expression  MACgetmacaddr(i) will return the MAC address of
              the i’th entry in the table.

              The expression MACgetipaddr(i) will return the IP address of the
              i’th entry in the table.

              The  expression TBLidxdel(i) will delete the i’th entry from the


       All programs have access to the following predefined variables:

              This is the current time in number of seconds since  1.  January
              1970 GMT.

       hour, min, wday, mday
              Evaluate  to  an  integer  representation  of  the hour, minute,
              weekday and day in month.

       Besides these variables programs executed from wipld have access  other
       variables reflecting the current packet being handled:

       srcmac, srcip, srcport, dstmac, dstip, dstport
              The  source  and destination of the packet.  srcport and dstport
              will evaluate to 0 if the packet is not a TCP or UDP packet.

              The size of the IP part of the packet


       The error messages for wrong programs are not always very  informative.


       wipl(1), wiplc(1), wipld(8)

                                   June 2000                       wipllang(5)