Print this page
OS-7667 IPFilter needs to keep and report state for cloud firewall logging
Portions contributed by: Mike Gerdts <mike.gerdts@joyent.com>
   1 /*
   2  * Copyright (C) 1993-2005  by Darren Reed.
   3  * See the IPFILTER.LICENCE file for details on licencing.


   4  */ 
   5 
   6 %{
   7 #include "ipf.h"
   8 #include <syslog.h>

   9 #undef  OPT_NAT
  10 #undef  OPT_VERBOSE
  11 #include "ipmon_l.h"
  12 #include "ipmon.h"
  13 
  14 #define YYDEBUG 1
  15 
  16 extern  void    yyerror __P((char *));
  17 extern  int     yyparse __P((void));
  18 extern  int     yylex __P((void));
  19 extern  int     yydebug;
  20 extern  FILE    *yyin;
  21 extern  int     yylineNum;
  22 
  23 typedef struct  opt     {
  24         struct  opt     *o_next;
  25         int             o_line;
  26         int             o_type;
  27         int             o_num;
  28         char            *o_str;
  29         struct in_addr  o_ip;
  30 } opt_t;
  31 
  32 static  void    build_action __P((struct opt *));
  33 static  opt_t   *new_opt __P((int));
  34 static  void    free_action __P((ipmon_action_t *));
  35 
  36 static  ipmon_action_t  *alist = NULL;
  37 %}
  38 
  39 %union  {
  40         char    *str;
  41         u_32_t  num;
  42         struct in_addr  addr;
  43         struct opt      *opt;
  44         union   i6addr  ip6;

  45 }
  46 
  47 %token  <num>     YY_NUMBER YY_HEX
  48 %token  <str>     YY_STR
  49 %token  <ip6>     YY_IPV6

  50 %token  YY_COMMENT 
  51 %token  YY_CMP_EQ YY_CMP_NE YY_CMP_LE YY_CMP_GE YY_CMP_LT YY_CMP_GT
  52 %token  YY_RANGE_OUT YY_RANGE_IN
  53 
  54 %token  IPM_MATCH IPM_BODY IPM_COMMENT IPM_DIRECTION IPM_DSTIP IPM_DSTPORT
  55 %token  IPM_EVERY IPM_EXECUTE IPM_GROUP IPM_INTERFACE IPM_IN IPM_NO IPM_OUT
  56 %token  IPM_PACKET IPM_PACKETS IPM_POOL IPM_PROTOCOL IPM_RESULT IPM_RULE
  57 %token  IPM_SECOND IPM_SECONDS IPM_SRCIP IPM_SRCPORT IPM_LOGTAG IPM_WITH
  58 %token  IPM_DO IPM_SAVE IPM_SYSLOG IPM_NOTHING IPM_RAW IPM_TYPE IPM_NAT
  59 %token  IPM_STATE IPM_NATTAG IPM_IPF
  60 %type   <addr> ipv4
  61 %type   <opt> direction dstip dstport every execute group interface
  62 %type   <opt> protocol result rule srcip srcport logtag matching
  63 %type   <opt> matchopt nattag type doopt doing save syslog nothing
  64 %type   <num> saveopts saveopt typeopt
  65 
  66 %%
  67 file:   line
  68         | assign
  69         | file line


   1 /*
   2  * Copyright (C) 1993-2005  by Darren Reed.
   3  * See the IPFILTER.LICENCE file for details on licencing.
   4  *
   5  * Copyright 2019 Joyent, Inc.
   6  */ 
   7 
   8 %{
   9 #include "ipf.h"
  10 #include <syslog.h>
  11 #include <uuid/uuid.h>
  12 #undef  OPT_NAT
  13 #undef  OPT_VERBOSE
  14 #include "ipmon_l.h"
  15 #include "ipmon.h"
  16 
  17 #define YYDEBUG 1
  18 
  19 extern  void    yyerror __P((char *));
  20 extern  int     yyparse __P((void));
  21 extern  int     yylex __P((void));
  22 extern  int     yydebug;
  23 extern  FILE    *yyin;
  24 extern  int     yylineNum;
  25 
  26 typedef struct  opt     {
  27         struct  opt     *o_next;
  28         int             o_line;
  29         int             o_type;
  30         int             o_num;
  31         char            *o_str;
  32         struct in_addr  o_ip;
  33 } opt_t;
  34 
  35 static  void    build_action __P((struct opt *));
  36 static  opt_t   *new_opt __P((int));
  37 static  void    free_action __P((ipmon_action_t *));
  38 
  39 static  ipmon_action_t  *alist = NULL;
  40 %}
  41 
  42 %union  {
  43         char    *str;
  44         u_32_t  num;
  45         struct in_addr  addr;
  46         struct opt      *opt;
  47         union   i6addr  ip6;
  48         uuid_t  uuid;
  49 }
  50 
  51 %token  <num>     YY_NUMBER YY_HEX
  52 %token  <str>     YY_STR
  53 %token  <ip6>     YY_IPV6
  54 %token  <uuid>    YY_UUID
  55 %token  YY_COMMENT 
  56 %token  YY_CMP_EQ YY_CMP_NE YY_CMP_LE YY_CMP_GE YY_CMP_LT YY_CMP_GT
  57 %token  YY_RANGE_OUT YY_RANGE_IN
  58 
  59 %token  IPM_MATCH IPM_BODY IPM_COMMENT IPM_DIRECTION IPM_DSTIP IPM_DSTPORT
  60 %token  IPM_EVERY IPM_EXECUTE IPM_GROUP IPM_INTERFACE IPM_IN IPM_NO IPM_OUT
  61 %token  IPM_PACKET IPM_PACKETS IPM_POOL IPM_PROTOCOL IPM_RESULT IPM_RULE
  62 %token  IPM_SECOND IPM_SECONDS IPM_SRCIP IPM_SRCPORT IPM_LOGTAG IPM_WITH
  63 %token  IPM_DO IPM_SAVE IPM_SYSLOG IPM_NOTHING IPM_RAW IPM_TYPE IPM_NAT
  64 %token  IPM_STATE IPM_NATTAG IPM_IPF
  65 %type   <addr> ipv4
  66 %type   <opt> direction dstip dstport every execute group interface
  67 %type   <opt> protocol result rule srcip srcport logtag matching
  68 %type   <opt> matchopt nattag type doopt doing save syslog nothing
  69 %type   <num> saveopts saveopt typeopt
  70 
  71 %%
  72 file:   line
  73         | assign
  74         | file line