Print this page
8485 Remove set but unused variables in usr/src/cmd
   1 /*
   2  * Copyright (C) 1993-2001 by Darren Reed.
   3  *
   4  * See the IPFILTER.LICENCE file for details on licencing.
   5  *
   6  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
   7  * Use is subject to license terms.

   8  */
   9 
  10 #pragma ident   "%Z%%M% %I%     %E% SMI"
  11 
  12 #if !defined(lint)
  13 static const char sccsid[] = "@(#)ip_fil.c      2.41 6/5/96 (C) 1993-2000 Darren Reed";
  14 static const char rcsid[] = "@(#)$Id: ipfcomp.c,v 1.24.2.2 2004/04/28 10:34:44 darrenr Exp $";
  15 #endif
  16 
  17 #include "ipf.h"
  18 
  19 
  20 typedef struct {
  21         int c;
  22         int e;
  23         int n;
  24         int p;
  25         int s;
  26 } mc_t;
  27 
  28 
  29 static char *portcmp[] = { "*", "==", "!=", "<", ">", "<=", ">=", "**", "***" };
  30 static int count = 0;
  31 
  32 int intcmp __P((const void *, const void *));
  33 static void indent __P((FILE *, int));
  34 static void printeq __P((FILE *, char *, int, int, int));
  35 static void printipeq __P((FILE *, char *, int, int, int));
  36 static void addrule __P((FILE *, frentry_t *));


  52 #define FRC_TCP 8
  53 #define FRC_SP  9
  54 #define FRC_DP  10
  55 #define FRC_OPT 11
  56 #define FRC_SEC 12
  57 #define FRC_ATH 13
  58 #define FRC_ICT 14
  59 #define FRC_ICC 15
  60 #define FRC_MAX 16
  61 
  62 
  63 static  FILE    *cfile = NULL;
  64 
  65 /*
  66  * This is called once per filter rule being loaded to emit data structures
  67  * required.
  68  */
  69 void printc(fr)
  70 frentry_t *fr;
  71 {
  72         fripf_t *ipf;
  73         u_long *ulp;
  74         char *and;
  75         FILE *fp;
  76         int i;
  77 
  78         if (fr->fr_v != 4)
  79                 return;
  80         if ((fr->fr_type != FR_T_IPF) && (fr->fr_type != FR_T_NONE))
  81                 return;
  82         if ((fr->fr_type == FR_T_IPF) &&
  83             ((fr->fr_datype != FRI_NORMAL) || (fr->fr_satype != FRI_NORMAL)))
  84                 return;
  85         ipf = fr->fr_ipf;
  86 
  87         if (cfile == NULL)
  88                 cfile = fopen("ip_rules.c", "w");
  89         if (cfile == NULL)
  90                 return;
  91         fp = cfile;
  92         if (count == 0) {
  93                 fprintf(fp, "/*\n");
  94                 fprintf(fp, "* Copyright (C) 1993-2000 by Darren Reed.\n");
  95                 fprintf(fp, "*\n");
  96                 fprintf(fp, "* Redistribution and use in source and binary forms are permitted\n");
  97                 fprintf(fp, "* provided that this notice is preserved and due credit is given\n");
  98                 fprintf(fp, "* to the original author and the contributors.\n");
  99                 fprintf(fp, "*/\n\n");
 100 
 101                 fprintf(fp, "#include <sys/types.h>\n");
 102                 fprintf(fp, "#include <sys/time.h>\n");
 103                 fprintf(fp, "#include <sys/socket.h>\n");
 104                 fprintf(fp, "#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__sgi)\n");
 105                 fprintf(fp, "# include <sys/systm.h>\n");


   1 /*
   2  * Copyright (C) 1993-2001 by Darren Reed.
   3  *
   4  * See the IPFILTER.LICENCE file for details on licencing.
   5  *
   6  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
   7  * Use is subject to license terms.
   8  * Copyright 2017 Gary Mills
   9  */
  10 







  11 #include "ipf.h"
  12 
  13 
  14 typedef struct {
  15         int c;
  16         int e;
  17         int n;
  18         int p;
  19         int s;
  20 } mc_t;
  21 
  22 
  23 static char *portcmp[] = { "*", "==", "!=", "<", ">", "<=", ">=", "**", "***" };
  24 static int count = 0;
  25 
  26 int intcmp __P((const void *, const void *));
  27 static void indent __P((FILE *, int));
  28 static void printeq __P((FILE *, char *, int, int, int));
  29 static void printipeq __P((FILE *, char *, int, int, int));
  30 static void addrule __P((FILE *, frentry_t *));


  46 #define FRC_TCP 8
  47 #define FRC_SP  9
  48 #define FRC_DP  10
  49 #define FRC_OPT 11
  50 #define FRC_SEC 12
  51 #define FRC_ATH 13
  52 #define FRC_ICT 14
  53 #define FRC_ICC 15
  54 #define FRC_MAX 16
  55 
  56 
  57 static  FILE    *cfile = NULL;
  58 
  59 /*
  60  * This is called once per filter rule being loaded to emit data structures
  61  * required.
  62  */
  63 void printc(fr)
  64 frentry_t *fr;
  65 {

  66         u_long *ulp;
  67         char *and;
  68         FILE *fp;
  69         int i;
  70 
  71         if (fr->fr_v != 4)
  72                 return;
  73         if ((fr->fr_type != FR_T_IPF) && (fr->fr_type != FR_T_NONE))
  74                 return;
  75         if ((fr->fr_type == FR_T_IPF) &&
  76             ((fr->fr_datype != FRI_NORMAL) || (fr->fr_satype != FRI_NORMAL)))
  77                 return;

  78 
  79         if (cfile == NULL)
  80                 cfile = fopen("ip_rules.c", "w");
  81         if (cfile == NULL)
  82                 return;
  83         fp = cfile;
  84         if (count == 0) {
  85                 fprintf(fp, "/*\n");
  86                 fprintf(fp, "* Copyright (C) 1993-2000 by Darren Reed.\n");
  87                 fprintf(fp, "*\n");
  88                 fprintf(fp, "* Redistribution and use in source and binary forms are permitted\n");
  89                 fprintf(fp, "* provided that this notice is preserved and due credit is given\n");
  90                 fprintf(fp, "* to the original author and the contributors.\n");
  91                 fprintf(fp, "*/\n\n");
  92 
  93                 fprintf(fp, "#include <sys/types.h>\n");
  94                 fprintf(fp, "#include <sys/time.h>\n");
  95                 fprintf(fp, "#include <sys/socket.h>\n");
  96                 fprintf(fp, "#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__sgi)\n");
  97                 fprintf(fp, "# include <sys/systm.h>\n");