X-Git-Url: https://git.distorted.org.uk/~mdw/fwd/blobdiff_plain/0ac54f22a766f068db98e1caecbc913cb0cfd191..a9bd543ab4ebe415bca9d6f27b90f16ddac79bc0:/socket.c diff --git a/socket.c b/socket.c index 5f1a731..53ac666 100644 --- a/socket.c +++ b/socket.c @@ -1,13 +1,11 @@ /* -*-c-*- * - * $Id: socket.c,v 1.10 2003/11/25 14:08:23 mdw Exp $ - * * Socket source and target definitions * * (c) 1999 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of the `fw' port forwarder. * @@ -15,90 +13,18 @@ * 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, * 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, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: socket.c,v $ - * Revision 1.10 2003/11/25 14:08:23 mdw - * Debianization. Socket target options. Internet binding. - * - * Revision 1.9 2002/02/23 00:08:00 mdw - * Fix stupid bugs from the listen(2) change. - * - * Revision 1.8 2002/02/22 23:44:44 mdw - * Call @xfree@ rather than @free@. Add option to change the listen(2) - * parameter. - * - * Revision 1.7 2001/06/22 19:37:00 mdw - * New @conn_init@ interface. - * - * Revision 1.6 2001/02/03 20:30:03 mdw - * Support re-reading config files on SIGHUP. - * - * Revision 1.5 2000/03/23 23:20:42 mdw - * Remove listener even if connection option isn't SOCKOPT_LIMITED. - * - * Revision 1.4 1999/12/22 15:44:25 mdw - * Fix log message. - * - * Revision 1.3 1999/10/22 22:48:36 mdw - * New connection options: unlimited concurrent connections, and one-shot - * listening sockets. - * - * Revision 1.2 1999/07/27 18:30:53 mdw - * Various minor portability fixes. - * - * Revision 1.1 1999/07/26 23:33:32 mdw - * New sources and targets. - * - */ - -/*----- Header files ------------------------------------------------------*/ - -#include "config.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "addr.h" -#include "conf.h" -#include "endpt.h" #include "fw.h" -#include "scan.h" -#include "socket.h" -#include "target.h" - -#include "inet.h" -#include "un.h" /*----- Data structures ---------------------------------------------------*/ @@ -409,9 +335,10 @@ static source *ssource_read(scanner *sc) ss->a = getaddr(sc, ADDR_SRC); if (ss->a->ops->initsrcopts) ss->ao = ss->a->ops->initsrcopts(); - else + else { ss->ao = CREATE(addr_opts); - *ss->ao = gsao; + *ss->ao = gsao; + } ss->o = ssgo; return (&ss->s); } @@ -576,6 +503,11 @@ static void ssource_attach(source *s, scanner *sc, target *t) dstr_destroy(&d); } + /* --- Confirm the address --- */ + + if (ss->a->ops->confirm) + ss->a->ops->confirm(ss->a, ADDR_SRC, ss->ao); + /* --- Initialize the socket for listening --- */ if ((fd = ss->a->ops->bind(ss->a, ss->ao)) < 0) @@ -665,9 +597,10 @@ static target *starget_read(scanner *sc) st->a = getaddr(sc, ADDR_DEST); if (st->a->ops->inittargopts) st->ao = st->a->ops->inittargopts(); - else + else { st->ao = CREATE(addr_opts); - *st->ao = gtao; + *st->ao = gtao; + } dstr_puts(&d, "socket."); st->a->ops->print(st->a, ADDR_DEST, &d); st->t.desc = xstrdup(d.buf); @@ -675,15 +608,17 @@ static target *starget_read(scanner *sc) return (&st->t); } -/* --- @create@ --- * - * - * Arguments: @target *t@ = pointer to target - * @const char *desc@ = description of connection - * - * Returns: Pointer to a created endpoint. - * - * Use: Generates a target endpoint for communication. - */ +/* --- @confirm@ --- */ + +static void starget_confirm(target *t) +{ + starget *st = (starget *)t; + + if (st->a->ops->confirm) + st->a->ops->confirm(st->a, ADDR_DEST, st->ao); +} + +/* --- @create@ --- */ static endpt *starget_create(target *t, const char *desc) { @@ -722,7 +657,8 @@ static void starget_destroy(target *t) target_ops starget_ops = { "socket", - starget_option, starget_read, starget_create, starget_destroy + starget_option, starget_read, starget_confirm, + starget_create, starget_destroy }; /*----- That's all, folks -------------------------------------------------*/