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) 2001-2008 by Darren Reed.
   4  *
   5  * See the IPFILTER.LICENCE file for details on licencing.
   6  *
   7  * Copyright 2008 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 #ifdef  __FreeBSD__
  14 # ifndef __FreeBSD_cc_version
  15 #  include <osreldate.h>
  16 # else
  17 #  if __FreeBSD_cc_version < 430000
  18 #   include <osreldate.h>
  19 #  endif
  20 # endif
  21 #endif
  22 #include <stdio.h>
  23 #include <unistd.h>
  24 #include <string.h>
  25 #include <fcntl.h>
  26 #include <errno.h>
  27 #if !defined(__SVR4) && !defined(__GNUC__)
  28 #include <strings.h>
  29 #endif
  30 #include <sys/types.h>
  31 #include <sys/param.h>
  32 #include <sys/file.h>
  33 #include <stdlib.h>
  34 #include <stddef.h>
  35 #include <sys/socket.h>
  36 #include <sys/ioctl.h>
  37 #include <netinet/in.h>
  38 #include <netinet/in_systm.h>
  39 #include <sys/time.h>
  40 #include <syslog.h>
  41 #include <net/if.h>

  42 #if __FreeBSD_version >= 300000
  43 # include <net/if_var.h>
  44 #endif
  45 #include <netdb.h>
  46 #include <arpa/nameser.h>
  47 #include <resolv.h>
  48 #include "ipf.h"
  49 #include "netinet/ipl.h"
  50 #include "ipnat_l.h"
  51 
  52 #define YYDEBUG 1
  53 
  54 extern  void    yyerror __P((char *));
  55 extern  int     yyparse __P((void));
  56 extern  int     yylex __P((void));
  57 extern  int     yydebug;
  58 extern  FILE    *yyin;
  59 extern  int     yylineNum;
  60 
  61 static  ipnat_t         *nattop = NULL;


  72         char    *str;
  73         u_32_t  num;
  74         struct  {
  75                 i6addr_t        a;
  76                 int             v;
  77         } ipa;
  78         frentry_t       fr;
  79         frtuc_t *frt;
  80         u_short port;
  81         struct  {
  82                 u_short p1;
  83                 u_short p2;
  84                 int     pc;
  85         } pc;
  86         struct  {
  87                 i6addr_t        a;
  88                 i6addr_t        m;
  89                 int     v;
  90         } ipp;
  91         union   i6addr  ip6;

  92 };
  93 
  94 %token  <num>   YY_NUMBER YY_HEX
  95 %token  <str>   YY_STR
  96 %token    YY_COMMENT 
  97 %token    YY_CMP_EQ YY_CMP_NE YY_CMP_LE YY_CMP_GE YY_CMP_LT YY_CMP_GT
  98 %token    YY_RANGE_OUT YY_RANGE_IN
  99 %token  <ip6>   YY_IPV6

 100 
 101 %token  IPNY_MAPBLOCK IPNY_RDR IPNY_PORT IPNY_PORTS IPNY_AUTO IPNY_RANGE
 102 %token  IPNY_MAP IPNY_BIMAP IPNY_FROM IPNY_TO IPNY_MASK IPNY_PORTMAP IPNY_ANY
 103 %token  IPNY_ROUNDROBIN IPNY_FRAG IPNY_AGE IPNY_ICMPIDMAP IPNY_PROXY
 104 %token  IPNY_TCP IPNY_UDP IPNY_TCPUDP IPNY_STICKY IPNY_MSSCLAMP IPNY_TAG
 105 %token  IPNY_TLATE IPNY_SEQUENTIAL
 106 %type   <port> portspec
 107 %type   <num> hexnumber compare range proto
 108 %type   <num> saddr daddr sobject dobject mapfrom rdrfrom dip
 109 %type   <ipa> hostname ipv4 ipaddr
 110 %type   <ipp> addr rhaddr
 111 %type   <pc> portstuff
 112 %%
 113 file:   line
 114         | assign
 115         | file line
 116         | file assign
 117         ;
 118 
 119 line:   xx rule         { while ((nat = nattop) != NULL) {


   1 %{
   2 /*
   3  * Copyright (C) 2001-2008 by Darren Reed.
   4  *
   5  * See the IPFILTER.LICENCE file for details on licencing.
   6  *
   7  * Copyright 2008 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 #ifdef  __FreeBSD__
  15 # ifndef __FreeBSD_cc_version
  16 #  include <osreldate.h>
  17 # else
  18 #  if __FreeBSD_cc_version < 430000
  19 #   include <osreldate.h>
  20 #  endif
  21 # endif
  22 #endif
  23 #include <stdio.h>
  24 #include <unistd.h>
  25 #include <string.h>
  26 #include <fcntl.h>
  27 #include <errno.h>
  28 #if !defined(__SVR4) && !defined(__GNUC__)
  29 #include <strings.h>
  30 #endif
  31 #include <sys/types.h>
  32 #include <sys/param.h>
  33 #include <sys/file.h>
  34 #include <stdlib.h>
  35 #include <stddef.h>
  36 #include <sys/socket.h>
  37 #include <sys/ioctl.h>
  38 #include <netinet/in.h>
  39 #include <netinet/in_systm.h>
  40 #include <sys/time.h>
  41 #include <syslog.h>
  42 #include <net/if.h>
  43 #include <uuid/uuid.h>
  44 #if __FreeBSD_version >= 300000
  45 # include <net/if_var.h>
  46 #endif
  47 #include <netdb.h>
  48 #include <arpa/nameser.h>
  49 #include <resolv.h>
  50 #include "ipf.h"
  51 #include "netinet/ipl.h"
  52 #include "ipnat_l.h"
  53 
  54 #define YYDEBUG 1
  55 
  56 extern  void    yyerror __P((char *));
  57 extern  int     yyparse __P((void));
  58 extern  int     yylex __P((void));
  59 extern  int     yydebug;
  60 extern  FILE    *yyin;
  61 extern  int     yylineNum;
  62 
  63 static  ipnat_t         *nattop = NULL;


  74         char    *str;
  75         u_32_t  num;
  76         struct  {
  77                 i6addr_t        a;
  78                 int             v;
  79         } ipa;
  80         frentry_t       fr;
  81         frtuc_t *frt;
  82         u_short port;
  83         struct  {
  84                 u_short p1;
  85                 u_short p2;
  86                 int     pc;
  87         } pc;
  88         struct  {
  89                 i6addr_t        a;
  90                 i6addr_t        m;
  91                 int     v;
  92         } ipp;
  93         union   i6addr  ip6;
  94         uuid_t  uuid;
  95 };
  96 
  97 %token  <num>   YY_NUMBER YY_HEX
  98 %token  <str>   YY_STR
  99 %token    YY_COMMENT 
 100 %token    YY_CMP_EQ YY_CMP_NE YY_CMP_LE YY_CMP_GE YY_CMP_LT YY_CMP_GT
 101 %token    YY_RANGE_OUT YY_RANGE_IN
 102 %token  <ip6>   YY_IPV6
 103 %token  <uuid>    YY_UUID
 104 
 105 %token  IPNY_MAPBLOCK IPNY_RDR IPNY_PORT IPNY_PORTS IPNY_AUTO IPNY_RANGE
 106 %token  IPNY_MAP IPNY_BIMAP IPNY_FROM IPNY_TO IPNY_MASK IPNY_PORTMAP IPNY_ANY
 107 %token  IPNY_ROUNDROBIN IPNY_FRAG IPNY_AGE IPNY_ICMPIDMAP IPNY_PROXY
 108 %token  IPNY_TCP IPNY_UDP IPNY_TCPUDP IPNY_STICKY IPNY_MSSCLAMP IPNY_TAG
 109 %token  IPNY_TLATE IPNY_SEQUENTIAL
 110 %type   <port> portspec
 111 %type   <num> hexnumber compare range proto
 112 %type   <num> saddr daddr sobject dobject mapfrom rdrfrom dip
 113 %type   <ipa> hostname ipv4 ipaddr
 114 %type   <ipp> addr rhaddr
 115 %type   <pc> portstuff
 116 %%
 117 file:   line
 118         | assign
 119         | file line
 120         | file assign
 121         ;
 122 
 123 line:   xx rule         { while ((nat = nattop) != NULL) {