#include <iptables.h>
#include <linux/netfilter_ipv4/ip_conntrack.h>
#include <linux/netfilter_ipv4/ip_conntrack_tuple.h>
-#include <linux/netfilter_ipv4/ipt_conntrack.h>
+/* For 64bit kernel / 32bit userspace */
+#include "../include/linux/netfilter_ipv4/ipt_conntrack.h"
#ifndef IPT_CONNTRACK_STATE_UNTRACKED
#define IPT_CONNTRACK_STATE_UNTRACKED (1 << (IP_CT_NUMBER + 3))
exit_error(PARAMETER_PROBLEM, "Bad ctstatus `%s'", arg);
}
-
+#ifdef KERNEL_64_USERSPACE_32
+static unsigned long long
+parse_expire(const char *s)
+{
+ unsigned long long len;
+
+ if (string_to_number_ll(s, 0, 0, &len) == -1)
+ exit_error(PARAMETER_PROBLEM, "expire value invalid: `%s'\n", s);
+ else
+ return len;
+}
+#else
static unsigned long
parse_expire(const char *s)
{
unsigned int len;
- if (string_to_number(s, 0, 0xFFFFFFFF, &len) == -1)
+ if (string_to_number(s, 0, 0, &len) == -1)
exit_error(PARAMETER_PROBLEM, "expire value invalid: `%s'\n", s);
else
return len;
}
+#endif
/* If a single value is provided, min and max are both set to the value */
static void
cp++;
sinfo->expires_min = buffer[0] ? parse_expire(buffer) : 0;
- sinfo->expires_max = cp[0] ? parse_expire(cp) : 0xFFFFFFFF;
+ sinfo->expires_max = cp[0] ? parse_expire(cp) : -1;
}
free(buffer);
if (sinfo->expires_min > sinfo->expires_max)
exit_error(PARAMETER_PROBLEM,
+#ifdef KERNEL_64_USERSPACE_32
+ "expire min. range value `%llu' greater than max. "
+ "range value `%llu'", sinfo->expires_min, sinfo->expires_max);
+#else
"expire min. range value `%lu' greater than max. "
"range value `%lu'", sinfo->expires_min, sinfo->expires_max);
-
+#endif
}
/* Function which parses command options; returns true if it
if (sinfo->invflags & IPT_CONNTRACK_EXPIRES)
printf("! ");
+#ifdef KERNEL_64_USERSPACE_32
+ if (sinfo->expires_max == sinfo->expires_min)
+ printf("%llu ", sinfo->expires_min);
+ else
+ printf("%llu:%llu ", sinfo->expires_min, sinfo->expires_max);
+#else
if (sinfo->expires_max == sinfo->expires_min)
printf("%lu ", sinfo->expires_min);
else
printf("%lu:%lu ", sinfo->expires_min, sinfo->expires_max);
+#endif
}
}
#define IPT_CONNTRACK_STATE_SNAT (1 << (IP_CT_NUMBER + 1))
#define IPT_CONNTRACK_STATE_DNAT (1 << (IP_CT_NUMBER + 2))
+#define IPT_CONNTRACK_STATE_UNTRACKED (1 << (IP_CT_NUMBER + 3))
/* flags, invflags: */
#define IPT_CONNTRACK_STATE 0x01
struct ip_conntrack_tuple tuple[IP_CT_DIR_MAX];
struct in_addr sipmsk[IP_CT_DIR_MAX], dipmsk[IP_CT_DIR_MAX];
+#ifdef KERNEL_64_USERSPACE_32
+ unsigned long long expires_min, expires_max;
+#else
unsigned long expires_min, expires_max;
+#endif
/* Flags word */
u_int8_t flags;
u_int8_t invflags;
};
#endif /*_IPT_CONNTRACK_H*/
-
--- /dev/null
+#ifndef _IPT_RATE_H
+#define _IPT_RATE_H
+
+/* timings are in milliseconds. */
+#define IPT_LIMIT_SCALE 10000
+
+/* 1/10,000 sec period => max of 10,000/sec. Min rate is then 429490
+ seconds, or one every 59 hours. */
+struct ipt_rateinfo {
+ u_int32_t avg; /* Average secs between packets * scale */
+ u_int32_t burst; /* Period multiplier for upper limit. */
+
+#ifdef KERNEL_64_USERSPACE_32
+ u_int64_t prev;
+ u_int64_t placeholder;
+#else
+ /* Used internally by the kernel */
+ unsigned long prev;
+ /* Ugly, ugly fucker. */
+ struct ipt_rateinfo *master;
+#endif
+
+ u_int32_t credit;
+ u_int32_t credit_cap, cost;
+};
+#endif /*_IPT_RATE_H*/
--- /dev/null
+#ifndef _IP6T_RATE_H
+#define _IP6T_RATE_H
+
+/* timings are in milliseconds. */
+#define IP6T_LIMIT_SCALE 10000
+
+/* 1/10,000 sec period => max of 10,000/sec. Min rate is then 429490
+ seconds, or one every 59 hours. */
+struct ip6t_rateinfo {
+ u_int32_t avg; /* Average secs between packets * scale */
+ u_int32_t burst; /* Period multiplier for upper limit. */
+
+#ifdef KERNEL_64_USERSPACE_32
+ u_int64_t prev;
+ u_int64_t placeholder;
+#else
+ /* Used internally by the kernel */
+ unsigned long prev;
+ /* Ugly, ugly fucker. */
+ struct ip6t_rateinfo *master;
+#endif
+ u_int32_t credit;
+ u_int32_t credit_cap, cost;
+};
+#endif /*_IPT_RATE_H*/