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 /*
   3  * Copyright (C) 2003 by Darren Reed.
   4  *
   5  * See the IPFILTER.LICENCE file for details on licencing.
   6  *
   7  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
   8  * Use is subject to license terms.

   9  */
  10 
  11 #pragma ident   "%Z%%M% %I%     %E% SMI"
  12 
  13 #include <sys/types.h>
  14 #include <sys/time.h>
  15 #include <sys/param.h>
  16 #include <sys/socket.h>
  17 #if defined(BSD) && (BSD >= 199306)
  18 # include <sys/cdefs.h>
  19 #endif
  20 #include <sys/ioctl.h>
  21 
  22 #include <net/if.h>
  23 #if __FreeBSD_version >= 300000
  24 # include <net/if_var.h>
  25 #endif
  26 #include <netinet/in.h>
  27 
  28 #include <arpa/inet.h>
  29 
  30 #include <stdio.h>
  31 #include <fcntl.h>
  32 #include <stdlib.h>
  33 #include <string.h>
  34 #include <netdb.h>
  35 #include <ctype.h>
  36 #include <unistd.h>

  37 
  38 #include "ipf.h"
  39 #include "netinet/ip_lookup.h"
  40 #include "netinet/ip_pool.h"
  41 #include "netinet/ip_htable.h"
  42 #include "ippool_l.h"
  43 #include "kmem.h"
  44 
  45 #define YYDEBUG 1
  46 
  47 extern  int     yyparse __P((void));
  48 extern  int     yydebug;
  49 extern  FILE    *yyin;
  50 
  51 static  iphtable_t      ipht;
  52 static  iphtent_t       iphte;
  53 static  ip_pool_t       iplo;
  54 static  ioctlfunc_t     poolioctl = NULL;
  55 static  char            poolname[FR_GROUPLEN];
  56 static  int             set_ipv6_addr = 0;
  57 
  58 %}
  59 
  60 %union  {
  61         char    *str;
  62         u_32_t  num;
  63         struct  in_addr addr;
  64         struct  alist_s *alist;
  65         union   i6addr  adrmsk[2];
  66         iphtent_t       *ipe;
  67         ip_pool_node_t  *ipp;
  68         union   i6addr  ip6;

  69 }
  70 
  71 %token  <num>   YY_NUMBER YY_HEX
  72 %token  <str>   YY_STR
  73 %token    YY_COMMENT 
  74 %token    YY_CMP_EQ YY_CMP_NE YY_CMP_LE YY_CMP_GE YY_CMP_LT YY_CMP_GT
  75 %token    YY_RANGE_OUT YY_RANGE_IN
  76 %token  <ip6>   YY_IPV6

  77 
  78 %token  IPT_IPF IPT_NAT IPT_COUNT IPT_AUTH IPT_IN IPT_OUT
  79 %token  IPT_TABLE IPT_GROUPMAP IPT_HASH
  80 %token  IPT_ROLE IPT_TYPE IPT_TREE
  81 %token  IPT_GROUP IPT_SIZE IPT_SEED IPT_NUM IPT_NAME
  82 %type   <num> role table inout
  83 %type   <ipp> ipftree range addrlist
  84 %type   <adrmsk> addrmask
  85 %type   <ipe> ipfgroup ipfhash hashlist hashentry
  86 %type   <ipe> groupentry setgrouplist grouplist
  87 %type   <ip6> ipaddr mask ipv4
  88 %type   <str> number setgroup
  89 
  90 %%
  91 file:   line
  92         | assign
  93         | file line
  94         | file assign
  95         ;
  96 


   1 %{
   2 /*
   3  * Copyright (C) 2003 by Darren Reed.
   4  *
   5  * See the IPFILTER.LICENCE file for details on licencing.
   6  *
   7  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
   8  * Use is subject to license terms.
   9  * Copyright 2019 Joyent, Inc.
  10  */
  11 
  12 #pragma ident   "%Z%%M% %I%     %E% SMI"
  13 
  14 #include <sys/types.h>
  15 #include <sys/time.h>
  16 #include <sys/param.h>
  17 #include <sys/socket.h>
  18 #if defined(BSD) && (BSD >= 199306)
  19 # include <sys/cdefs.h>
  20 #endif
  21 #include <sys/ioctl.h>
  22 
  23 #include <net/if.h>
  24 #if __FreeBSD_version >= 300000
  25 # include <net/if_var.h>
  26 #endif
  27 #include <netinet/in.h>
  28 
  29 #include <arpa/inet.h>
  30 
  31 #include <stdio.h>
  32 #include <fcntl.h>
  33 #include <stdlib.h>
  34 #include <string.h>
  35 #include <netdb.h>
  36 #include <ctype.h>
  37 #include <unistd.h>
  38 #include <uuid/uuid.h>
  39 
  40 #include "ipf.h"
  41 #include "netinet/ip_lookup.h"
  42 #include "netinet/ip_pool.h"
  43 #include "netinet/ip_htable.h"
  44 #include "ippool_l.h"
  45 #include "kmem.h"
  46 
  47 #define YYDEBUG 1
  48 
  49 extern  int     yyparse __P((void));
  50 extern  int     yydebug;
  51 extern  FILE    *yyin;
  52 
  53 static  iphtable_t      ipht;
  54 static  iphtent_t       iphte;
  55 static  ip_pool_t       iplo;
  56 static  ioctlfunc_t     poolioctl = NULL;
  57 static  char            poolname[FR_GROUPLEN];
  58 static  int             set_ipv6_addr = 0;
  59 
  60 %}
  61 
  62 %union  {
  63         char    *str;
  64         u_32_t  num;
  65         struct  in_addr addr;
  66         struct  alist_s *alist;
  67         union   i6addr  adrmsk[2];
  68         iphtent_t       *ipe;
  69         ip_pool_node_t  *ipp;
  70         union   i6addr  ip6;
  71         uuid_t  uuid;
  72 }
  73 
  74 %token  <num>   YY_NUMBER YY_HEX
  75 %token  <str>   YY_STR
  76 %token    YY_COMMENT 
  77 %token    YY_CMP_EQ YY_CMP_NE YY_CMP_LE YY_CMP_GE YY_CMP_LT YY_CMP_GT
  78 %token    YY_RANGE_OUT YY_RANGE_IN
  79 %token  <ip6>   YY_IPV6
  80 %token  <uuid>    YY_UUID
  81 
  82 %token  IPT_IPF IPT_NAT IPT_COUNT IPT_AUTH IPT_IN IPT_OUT
  83 %token  IPT_TABLE IPT_GROUPMAP IPT_HASH
  84 %token  IPT_ROLE IPT_TYPE IPT_TREE
  85 %token  IPT_GROUP IPT_SIZE IPT_SEED IPT_NUM IPT_NAME
  86 %type   <num> role table inout
  87 %type   <ipp> ipftree range addrlist
  88 %type   <adrmsk> addrmask
  89 %type   <ipe> ipfgroup ipfhash hashlist hashentry
  90 %type   <ipe> groupentry setgrouplist grouplist
  91 %type   <ip6> ipaddr mask ipv4
  92 %type   <str> number setgroup
  93 
  94 %%
  95 file:   line
  96         | assign
  97         | file line
  98         | file assign
  99         ;
 100