/*----- Licensing notice --------------------------------------------------*
*
- * This file is part of the `fw' port forwarder.
+ * This file is part of the `fwd' port forwarder.
*
- * `fw' is free software; you can redistribute it and/or modify
+ * `fwd' is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
- * `fw' is distributed in the hope that it will be useful,
+ * `fwd' is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with `fw'; if not, write to the Free Software Foundation,
+ * along with `fwd'; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#include "fw.h"
+#include "fwd.h"
/*----- Data structures ---------------------------------------------------*/
{
ssept *ee = (ssept *)e;
- if (ee->s->o.opt == SOCKOPT_LIMIT) {
+ if ((ee->s->s.f&SF_ACTIVE) && ee->s->o.opt == SOCKOPT_LIMIT) {
ee->s->o.conn++;
if (ee->s->o.conn == 1)
ss_listen(ee->s);
e->e.in = e->e.out = r;
e->e.f &= ~EPF_PENDING;
if (e->e.other)
- endpt_join(&e->e, e->e.other);
+ endpt_join(&e->e, e->e.other, 0);
}
}
(void)(conf_prefix(sc, "socket") || conf_prefix(sc, "sk"));
ss = CREATE(ssource);
ss->s.ops = &ssource_ops;
+ ss->s.ref = 1;
+ ss->s.f = 0;
ss->s.desc = 0;
ss->t = 0;
ss->a = getaddr(sc, ADDR_SRC);
close(ss->r.fd);
if (ss->a->ops->unbind)
ss->a->ops->unbind(ss->a);
- ssource_destroy(&ss->s);
+ source_dec(&ss->s);
acceptp = 0;
break;
}
/* --- Let everything else happen --- */
- endpt_join(&e->e, ee);
+ endpt_join(&e->e, ee, ss->s.desc);
}
}
close(fd);
fail_0:
ss->o.conn = 0;
- ssource_destroy(&ss->s);
+ source_dec(&ss->s);
}
/* --- @attach@ --- */
int fd;
int opt = 1;
- ss->t = t;
+ ss->t = t; target_inc(t);
/* --- Initialize the description string --- */
fw_inc();
}
-/* --- @destroy@ --- */
+/* --- @shutdown@ --- */
-static void ssource_destroy(source *s)
+static void ssource_shutdown(source *s)
{
ssource *ss = (ssource *)s;
ss->a->ops->freesrcopts(ss->ao);
else
DESTROY(ss->ao);
- xfree(ss->s.desc);
ss->a->ops->destroy(ss->a);
- ss->t->ops->destroy(ss->t);
source_remove(&ss->s);
+ target_dec(ss->t);
+ fw_dec();
+}
+
+/* --- @destroy@ --- */
+
+static void ssource_destroy(source *s)
+{
+ ssource *ss = (ssource *)s;
+
+ xfree(ss->s.desc);
DESTROY(ss);
fw_dec();
}
source_ops ssource_ops = {
"socket",
- ssource_option, ssource_read, ssource_attach, ssource_destroy
+ ssource_option, ssource_read, ssource_attach, ssource_shutdown, ssource_destroy
};
/*----- Target definition -------------------------------------------------*/
(void)(conf_prefix(sc, "socket") || conf_prefix(sc, "sk"));
st = CREATE(starget);
st->t.ops = &starget_ops;
+ st->t.ref = 1;
st->a = getaddr(sc, ADDR_DEST);
if (st->a->ops->inittargopts)
st->ao = st->a->ops->inittargopts();