Lines Matching defs:fp
75 FILE *fp;
91 fp = cfile;
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");
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");
106 fprintf(fp, "#endif\n");
107 fprintf(fp, "#include <sys/errno.h>\n");
108 fprintf(fp, "#include <sys/param.h>\n");
109 fprintf(fp,
111 fprintf(fp, "# include <sys/mbuf.h>\n");
112 fprintf(fp, "#endif\n");
113 fprintf(fp,
115 fprintf(fp, "# include <sys/sockio.h>\n");
116 fprintf(fp, "#else\n");
117 fprintf(fp, "# include <sys/ioctl.h>\n");
118 fprintf(fp, "#endif /* FreeBSD */\n");
119 fprintf(fp, "#include <net/if.h>\n");
120 fprintf(fp, "#include <netinet/in.h>\n");
121 fprintf(fp, "#include <netinet/in_systm.h>\n");
122 fprintf(fp, "#include <netinet/ip.h>\n");
123 fprintf(fp, "#include <netinet/tcp.h>\n");
124 fprintf(fp, "#include \"netinet/ip_compat.h\"\n");
125 fprintf(fp, "#include \"netinet/ip_fil.h\"\n\n");
126 fprintf(fp, "#include \"netinet/ip_rules.h\"\n\n");
127 fprintf(fp, "#ifndef _KERNEL\n");
128 fprintf(fp, "# include <string.h>\n");
129 fprintf(fp, "#endif /* _KERNEL */\n");
130 fprintf(fp, "\n");
131 fprintf(fp, "#ifdef IPFILTER_COMPILED\n");
134 addrule(fp, fr);
142 fprintf(fp, "%s%#lx", and, *ulp++);
145 fprintf(fp, "\n};\n");
150 fflush(fp);
157 static void addrule(fp, fr)
158 FILE *fp;
208 fprintf(fp, "\
216 fprintf(fp, "%s%#lx", and, *ulp++);
219 fprintf(fp, "\n};\n");
222 fprintf(fp, "\nstatic u_long %s_rule_%s_%d[] = {\n",
262 static void indent(fp, in)
263 FILE *fp;
267 fputc('\t', fp);
270 static void printeq(fp, var, m, max, v)
271 FILE *fp;
276 fprintf(fp, "%s == %#x) {\n", var, v);
278 fprintf(fp, "(%s & %#x) == %#x) {\n", var, m, v);
287 static void printipeq(fp, var, fl, m, v)
288 FILE *fp;
293 fprintf(fp, "%s ", var);
295 fprintf(fp, "(%s & %#x) ", var, m);
296 fprintf(fp, "%c", fl ? '!' : '=');
297 fprintf(fp, "= %#x) {\n", v);
452 static FILE *fp = NULL;
464 if (fp == NULL)
465 fp = cfile;
466 if (fp == NULL)
470 indent(fp, sin);
471 fprintf(fp, "}\n");
474 fprintf(fp, "\treturn fr;\n}\n");
491 indent(fp, sin);
492 fprintf(fp, "}\n");
495 fprintf(fp, "\treturn fr;\n}\n");
517 fprintf(fp, "\nfrentry_t *ipf_rules_in_%s[%d] = {",
523 fprintf(fp, "\n\t");
525 fprintf(fp,
529 fprintf(fp, ", ");
532 fprintf(fp, "\n};\n");
536 fprintf(fp, "\nfrentry_t *ipf_rules_out_%s[%d] = {",
542 fprintf(fp, "\n\t");
544 fprintf(fp,
548 fprintf(fp, ", ");
551 fprintf(fp, "\n};\n");
552 fp = NULL;
568 fprintf(fp, "\nfrentry_t *ipfrule_match_%s_%s(fin, passp)\n",
570 fprintf(fp, "fr_info_t *fin;\n");
571 fprintf(fp, "u_32_t *passp;\n");
572 fprintf(fp, "{\n");
573 fprintf(fp, "\tfrentry_t *fr = NULL;\n");
585 fprintf(fp, "\tu_32_t src = ntohl(%s);\n",
588 fprintf(fp, "\tu_32_t dst = ntohl(%s);\n",
698 fprintf(fp, "\n");
729 indent(fp, j);
730 fprintf(fp, "}\n");
746 indent(fp, in);
747 fprintf(fp, "if (fin->fin_ifp == ");
748 fprintf(fp, "ipf_rules_%s_%s[%d]->fr_ifa) {\n",
755 indent(fp, in);
756 fprintf(fp, "if (fin->fin_v == %d) {\n",
763 indent(fp, in);
764 fprintf(fp, "if (");
765 printeq(fp, "fin->fin_flx",
773 indent(fp, in);
774 fprintf(fp, "if (fin->fin_p == %d) {\n",
781 indent(fp, in);
782 fprintf(fp, "if (");
783 printeq(fp, "fin->fin_ttl",
791 indent(fp, in);
792 fprintf(fp, "if (fin->fin_tos");
793 printeq(fp, "fin->fin_tos",
801 indent(fp, in);
802 fprintf(fp, "if (");
803 printeq(fp, "fin->fin_tcpf", fr->fr_tcpfm,
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] < %d) || ",
823 fprintf(fp, "(fin->fin_data[0] > %d)",
825 fprintf(fp, ") {\n");
828 indent(fp, in);
829 fprintf(fp, "if (fin->fin_data[0] %s %d)",
831 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] < %d) || ",
850 fprintf(fp, "(fin->fin_data[1] > %d)",
852 fprintf(fp, ") {\n");
855 indent(fp, in);
856 fprintf(fp, "if (fin->fin_data[1] %s %d)",
858 fprintf(fp, " {\n");
869 indent(fp, in);
870 fprintf(fp, "if (");
871 printipeq(fp, "src",
884 indent(fp, in);
885 fprintf(fp, "if (");
886 printipeq(fp, "dst",
894 indent(fp, in);
895 fprintf(fp, "if (");
896 printeq(fp, "fin->fin_fi.fi_optmsk",
904 indent(fp, in);
905 fprintf(fp, "if (");
906 printeq(fp, "fin->fin_fi.fi_secmsk",
914 indent(fp, in);
915 fprintf(fp, "if (");
916 printeq(fp, "fin->fin_fi.fi_authmsk",
924 indent(fp, in);
925 fprintf(fp, "if (");
926 printeq(fp, "fin->fin_data[0]",
934 indent(fp, in);
935 fprintf(fp, "if (");
936 printeq(fp, "fin->fin_data[0]",
946 indent(fp, in);
948 fprintf(fp, "return (frentry_t *)&%s_rule_%s_%d;\n",
952 fprintf(fp, "fr = (frentry_t *)&%s_rule_%s_%d;\n",
1245 static void printhooks(fp, in, out, grp)
1246 FILE *fp;
1272 fprintf(fp, "static frentry_t ipfrule_%s_%s;\n", instr, group);
1274 fprintf(fp, "\
1277 fprintf(fp, "\
1280 frentry_t *fp;\n");
1283 fprintf(fp, "\
1286 fprintf(fp, "\n");
1290 fprintf(fp, "\
1295 fprintf(fp, "\
1298 fp = ipf_rules_%s_%s[i];\n\
1299 fp->fr_next = NULL;\n", instr, group, instr, group);
1301 fprintf(fp, "\
1303 if (strncmp(fp->fr_group,\n\
1306 fp->fr_next = ipf_rules_%s_%s[j];\n\
1310 fprintf(fp, "\
1312 if (fp->fr_grhead != 0) {\n\
1313 fg = fr_addgroup(fp->fr_grhead, fp, FR_INQUE,\n\
1316 fp->fr_grp = &fg->fg_start;\n\
1318 fprintf(fp, "\
1321 fp = &ipfrule_%s_%s;\n", instr, group);
1322 fprintf(fp, "\
1323 bzero((char *)fp, sizeof(*fp));\n\
1324 fp->fr_type = FR_T_CALLFUNC|FR_T_BUILTIN;\n\
1325 fp->fr_flags = FR_%sQUE|FR_NOMATCH;\n\
1326 fp->fr_data = (void *)ipf_rules_%s_%s[0];\n",
1328 fprintf(fp, "\
1329 fp->fr_dsize = sizeof(ipf_rules_%s_%s[0]);\n",
1332 fprintf(fp, "\
1333 fp->fr_v = 4;\n\
1334 fp->fr_func = (ipfunc_t)ipfrule_match_%s_%s;\n\
1335 err = frrequest(IPL_LOGIPF, SIOCADDFR, (caddr_t)fp, fr_active, 0);\n",
1337 fprintf(fp, "\treturn err;\n}\n");
1339 fprintf(fp, "\n\n\
1341 fprintf(fp, "\
1344 frentry_t *fp;\n\
1349 fprintf(fp, "\
1353 fprintf(fp, "\
1357 fprintf(fp, "\
1360 fp = ipf_rules_%s_%s[i];\n\
1361 if (fp->fr_ref > 1) {\n\
1371 fprintf(fp, "\
1376 fprintf(fp, "\treturn err;\n}\n");