4 * Copyright (C) 1993-2001 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
8 * $Id: addkeep.c,v 1.12 2003/12/01 01:59:42 darrenr Exp $
15 * Parses "keep state" and "keep frags" stuff on the end of a line.
17 int addkeep(cp, fp, linenum)
26 fprintf(stderr, "%d: Missing state/frag after keep\n",
31 if (!strcasecmp(**cp, "state")) {
32 fp->fr_flags |= FR_KEEPSTATE;
34 if (**cp && !strcasecmp(**cp, "limit")) {
36 fp->fr_statemax = atoi(**cp);
39 if (**cp && !strcasecmp(**cp, "scan")) {
41 if (!strcmp(**cp, "*")) {
43 fp->fr_isctag[0] = '\0';
45 strncpy(fp->fr_isctag, **cp,
46 sizeof(fp->fr_isctag));
47 fp->fr_isctag[sizeof(fp->fr_isctag)-1] = '\0';
52 fp->fr_isc = (struct ipscan *)-1;
53 } else if (!strncasecmp(**cp, "frag", 4)) {
54 fp->fr_flags |= FR_KEEPFRAG;
56 } else if (!strcasecmp(**cp, "state-age")) {
57 if (fp->fr_ip.fi_p == IPPROTO_TCP) {
58 fprintf(stderr, "%d: cannot use state-age with tcp\n",
62 if ((fp->fr_flags & FR_KEEPSTATE) == 0) {
63 fprintf(stderr, "%d: state-age with no 'keep state'\n",
69 fprintf(stderr, "%d: state-age with no arg\n",
73 fp->fr_age[0] = atoi(**cp);
74 s = strchr(**cp, '/');
77 fp->fr_age[1] = atoi(s);
79 fp->fr_age[1] = fp->fr_age[0];
81 fprintf(stderr, "%d: Unrecognised state keyword \"%s\"\n",