Lines Matching refs:fp

68 	FILE *fp;
83 fp = cfile;
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");
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");
98 fprintf(fp, "#endif\n");
99 fprintf(fp, "#include <sys/errno.h>\n");
100 fprintf(fp, "#include <sys/param.h>\n");
101 fprintf(fp,
103 fprintf(fp, "# include <sys/mbuf.h>\n");
104 fprintf(fp, "#endif\n");
105 fprintf(fp,
107 fprintf(fp, "# include <sys/sockio.h>\n");
108 fprintf(fp, "#else\n");
109 fprintf(fp, "# include <sys/ioctl.h>\n");
110 fprintf(fp, "#endif /* FreeBSD */\n");
111 fprintf(fp, "#include <net/if.h>\n");
112 fprintf(fp, "#include <netinet/in.h>\n");
113 fprintf(fp, "#include <netinet/in_systm.h>\n");
114 fprintf(fp, "#include <netinet/ip.h>\n");
115 fprintf(fp, "#include <netinet/tcp.h>\n");
116 fprintf(fp, "#include \"netinet/ip_compat.h\"\n");
117 fprintf(fp, "#include \"netinet/ip_fil.h\"\n\n");
118 fprintf(fp, "#include \"netinet/ip_rules.h\"\n\n");
119 fprintf(fp, "#ifndef _KERNEL\n");
120 fprintf(fp, "# include <string.h>\n");
121 fprintf(fp, "#endif /* _KERNEL */\n");
122 fprintf(fp, "\n");
123 fprintf(fp, "#ifdef IPFILTER_COMPILED\n");
126 addrule(fp, fr);
134 fprintf(fp, "%s%#lx", and, *ulp++);
137 fprintf(fp, "\n};\n");
142 fflush(fp);
149 static void addrule(fp, fr)
150 FILE *fp;
200 fprintf(fp, "\
208 fprintf(fp, "%s%#lx", and, *ulp++);
211 fprintf(fp, "\n};\n");
214 fprintf(fp, "\nstatic u_long %s_rule_%s_%d[] = {\n",
254 static void indent(fp, in)
255 FILE *fp;
259 fputc('\t', fp);
262 static void printeq(fp, var, m, max, v)
263 FILE *fp;
268 fprintf(fp, "%s == %#x) {\n", var, v);
270 fprintf(fp, "(%s & %#x) == %#x) {\n", var, m, v);
279 static void printipeq(fp, var, fl, m, v)
280 FILE *fp;
285 fprintf(fp, "%s ", var);
287 fprintf(fp, "(%s & %#x) ", var, m);
288 fprintf(fp, "%c", fl ? '!' : '=');
289 fprintf(fp, "= %#x) {\n", v);
444 static FILE *fp = NULL;
456 if (fp == NULL)
457 fp = cfile;
458 if (fp == NULL)
462 indent(fp, sin);
463 fprintf(fp, "}\n");
466 fprintf(fp, "\treturn fr;\n}\n");
483 indent(fp, sin);
484 fprintf(fp, "}\n");
487 fprintf(fp, "\treturn fr;\n}\n");
509 fprintf(fp, "\nfrentry_t *ipf_rules_in_%s[%d] = {",
515 fprintf(fp, "\n\t");
517 fprintf(fp,
521 fprintf(fp, ", ");
524 fprintf(fp, "\n};\n");
528 fprintf(fp, "\nfrentry_t *ipf_rules_out_%s[%d] = {",
534 fprintf(fp, "\n\t");
536 fprintf(fp,
540 fprintf(fp, ", ");
543 fprintf(fp, "\n};\n");
544 fp = NULL;
560 fprintf(fp, "\nfrentry_t *ipfrule_match_%s_%s(fin, passp)\n",
562 fprintf(fp, "fr_info_t *fin;\n");
563 fprintf(fp, "u_32_t *passp;\n");
564 fprintf(fp, "{\n");
565 fprintf(fp, "\tfrentry_t *fr = NULL;\n");
577 fprintf(fp, "\tu_32_t src = ntohl(%s);\n",
580 fprintf(fp, "\tu_32_t dst = ntohl(%s);\n",
690 fprintf(fp, "\n");
721 indent(fp, j);
722 fprintf(fp, "}\n");
738 indent(fp, in);
739 fprintf(fp, "if (fin->fin_ifp == ");
740 fprintf(fp, "ipf_rules_%s_%s[%d]->fr_ifa) {\n",
747 indent(fp, in);
748 fprintf(fp, "if (fin->fin_v == %d) {\n",
755 indent(fp, in);
756 fprintf(fp, "if (");
757 printeq(fp, "fin->fin_flx",
765 indent(fp, in);
766 fprintf(fp, "if (fin->fin_p == %d) {\n",
773 indent(fp, in);
774 fprintf(fp, "if (");
775 printeq(fp, "fin->fin_ttl",
783 indent(fp, in);
784 fprintf(fp, "if (fin->fin_tos");
785 printeq(fp, "fin->fin_tos",
793 indent(fp, in);
794 fprintf(fp, "if (");
795 printeq(fp, "fin->fin_tcpf", fr->fr_tcpfm,
804 indent(fp, in);
805 fprintf(fp, "if ((fin->fin_data[0] > %d) && ",
807 fprintf(fp, "(fin->fin_data[0] < %d)",
809 fprintf(fp, ") {\n");
812 indent(fp, in);
813 fprintf(fp, "if ((fin->fin_data[0] < %d) || ",
815 fprintf(fp, "(fin->fin_data[0] > %d)",
817 fprintf(fp, ") {\n");
820 indent(fp, in);
821 fprintf(fp, "if (fin->fin_data[0] %s %d)",
823 fprintf(fp, " {\n");
831 indent(fp, in);
832 fprintf(fp, "if ((fin->fin_data[1] > %d) && ",
834 fprintf(fp, "(fin->fin_data[1] < %d)",
836 fprintf(fp, ") {\n");
839 indent(fp, in);
840 fprintf(fp, "if ((fin->fin_data[1] < %d) || ",
842 fprintf(fp, "(fin->fin_data[1] > %d)",
844 fprintf(fp, ") {\n");
847 indent(fp, in);
848 fprintf(fp, "if (fin->fin_data[1] %s %d)",
850 fprintf(fp, " {\n");
861 indent(fp, in);
862 fprintf(fp, "if (");
863 printipeq(fp, "src",
876 indent(fp, in);
877 fprintf(fp, "if (");
878 printipeq(fp, "dst",
886 indent(fp, in);
887 fprintf(fp, "if (");
888 printeq(fp, "fin->fin_fi.fi_optmsk",
896 indent(fp, in);
897 fprintf(fp, "if (");
898 printeq(fp, "fin->fin_fi.fi_secmsk",
906 indent(fp, in);
907 fprintf(fp, "if (");
908 printeq(fp, "fin->fin_fi.fi_authmsk",
916 indent(fp, in);
917 fprintf(fp, "if (");
918 printeq(fp, "fin->fin_data[0]",
926 indent(fp, in);
927 fprintf(fp, "if (");
928 printeq(fp, "fin->fin_data[0]",
938 indent(fp, in);
940 fprintf(fp, "return (frentry_t *)&%s_rule_%s_%d;\n",
944 fprintf(fp, "fr = (frentry_t *)&%s_rule_%s_%d;\n",
1237 static void printhooks(fp, in, out, grp)
1238 FILE *fp;
1264 fprintf(fp, "static frentry_t ipfrule_%s_%s;\n", instr, group);
1266 fprintf(fp, "\
1269 fprintf(fp, "\
1272 frentry_t *fp;\n");
1275 fprintf(fp, "\
1278 fprintf(fp, "\n");
1282 fprintf(fp, "\
1287 fprintf(fp, "\
1290 fp = ipf_rules_%s_%s[i];\n\
1291 fp->fr_next = NULL;\n", instr, group, instr, group);
1293 fprintf(fp, "\
1295 if (strncmp(fp->fr_group,\n\
1298 fp->fr_next = ipf_rules_%s_%s[j];\n\
1302 fprintf(fp, "\
1304 if (fp->fr_grhead != 0) {\n\
1305 fg = fr_addgroup(fp->fr_grhead, fp, FR_INQUE,\n\
1308 fp->fr_grp = &fg->fg_start;\n\
1310 fprintf(fp, "\
1313 fp = &ipfrule_%s_%s;\n", instr, group);
1314 fprintf(fp, "\
1315 bzero((char *)fp, sizeof(*fp));\n\
1316 fp->fr_type = FR_T_CALLFUNC|FR_T_BUILTIN;\n\
1317 fp->fr_flags = FR_%sQUE|FR_NOMATCH;\n\
1318 fp->fr_data = (void *)ipf_rules_%s_%s[0];\n",
1320 fprintf(fp, "\
1321 fp->fr_dsize = sizeof(ipf_rules_%s_%s[0]);\n",
1324 fprintf(fp, "\
1325 fp->fr_v = 4;\n\
1326 fp->fr_func = (ipfunc_t)ipfrule_match_%s_%s;\n\
1327 err = frrequest(IPL_LOGIPF, SIOCADDFR, (caddr_t)fp, fr_active, 0);\n",
1329 fprintf(fp, "\treturn err;\n}\n");
1331 fprintf(fp, "\n\n\
1333 fprintf(fp, "\
1336 frentry_t *fp;\n\
1341 fprintf(fp, "\
1345 fprintf(fp, "\
1349 fprintf(fp, "\
1352 fp = ipf_rules_%s_%s[i];\n\
1353 if (fp->fr_ref > 1) {\n\
1363 fprintf(fp, "\
1368 fprintf(fp, "\treturn err;\n}\n");