+/*----- Drop filter -------------------------------------------------------*/
+
+typedef struct drop {
+ unsigned p_drop;
+} drop;
+
+static void dodrop(filter *f, const octet *buf, size_t sz)
+{
+ drop *d = f->state;
+
+ if (!RND(d->p_drop))
+ puts("drop packet");
+ else
+ PASS(f->next, buf, sz);
+}
+
+static void adddrop(filter *f, unsigned ac, char **av)
+{
+ drop *d;
+ if (ac > 1)
+ die(1, "syntax: filt:drop[:P-DROP]");
+ d = CREATE(drop);
+ if (ac > 0)
+ d->p_drop = atoi(av[0]);
+ else
+ d->p_drop = 5;
+ f->state = d;
+ f->func = dodrop;
+}
+