X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/b7a189f38294c745ae4ea6efb55891c8196e275b..c85623f918b8a6c639afc15604414f9b113bb20d:/portfwd.c diff --git a/portfwd.c b/portfwd.c index dc865f62..11437140 100644 --- a/portfwd.c +++ b/portfwd.c @@ -57,7 +57,7 @@ struct pfwd_queue { }; struct PFwdPrivate { - struct plug_function_table *fn; + const struct plug_function_table *fn; /* the above variable absolutely *must* be the first in this structure */ void *c; /* (channel) data used by ssh.c */ void *backhandle; /* instance of SSH backend itself */ @@ -70,8 +70,6 @@ struct PFwdPrivate { struct pfwd_queue *waiting; }; -void pfd_close(Socket s); - static int pfd_closing(Plug plug, char *error_msg, int error_code, int calling_back) @@ -110,9 +108,10 @@ static void pfd_sent(Plug plug, int bufsize) /* * Called when receiving a PORT OPEN from the server */ -char *pfd_newconnect(Socket *s, char *hostname, int port, void *c) +char *pfd_newconnect(Socket *s, char *hostname, int port, void *c, + const Config *cfg) { - static struct plug_function_table fn_table = { + static const struct plug_function_table fn_table = { pfd_closing, pfd_receive, pfd_sent, @@ -126,8 +125,8 @@ char *pfd_newconnect(Socket *s, char *hostname, int port, void *c) /* * Try to find host. */ - addr = name_lookup(hostname, port, &dummy_realhost); - if ((err = sk_addr_error(addr))) + addr = name_lookup(hostname, port, &dummy_realhost, cfg); + if ((err = sk_addr_error(addr)) != NULL) return err; /* @@ -140,8 +139,9 @@ char *pfd_newconnect(Socket *s, char *hostname, int port, void *c) pr->c = c; pr->backhandle = NULL; /* we shouldn't need this */ - pr->s = *s = new_connection(addr, dummy_realhost, port, 0, 1, 0, (Plug) pr); - if ((err = sk_socket_error(*s))) { + pr->s = *s = new_connection(addr, dummy_realhost, port, + 0, 1, 0, (Plug) pr, cfg); + if ((err = sk_socket_error(*s)) != NULL) { sfree(pr); return err; } @@ -157,7 +157,7 @@ char *pfd_newconnect(Socket *s, char *hostname, int port, void *c) static int pfd_accepting(Plug p, void *sock) { - static struct plug_function_table fn_table = { + static const struct plug_function_table fn_table = { pfd_closing, pfd_receive, pfd_sent, @@ -175,7 +175,7 @@ static int pfd_accepting(Plug p, void *sock) pr->backhandle = org->backhandle; pr->s = s = sk_register(sock, (Plug) pr); - if ((err = sk_socket_error(s))) { + if ((err = sk_socket_error(s)) != NULL) { sfree(pr); return err != NULL; } @@ -206,9 +206,9 @@ static int pfd_accepting(Plug p, void *sock) sets up a listener on the local machine on (srcaddr:)port */ char *pfd_addforward(char *desthost, int destport, char *srcaddr, int port, - void *backhandle) + void *backhandle, const Config *cfg) { - static struct plug_function_table fn_table = { + static const struct plug_function_table fn_table = { pfd_closing, pfd_receive, /* should not happen... */ pfd_sent, /* also should not happen */ @@ -232,8 +232,9 @@ char *pfd_addforward(char *desthost, int destport, char *srcaddr, int port, pr->waiting = NULL; pr->backhandle = backhandle; - pr->s = s = new_listener(srcaddr, port, (Plug) pr, !cfg.lport_acceptall); - if ((err = sk_socket_error(s))) { + pr->s = s = new_listener(srcaddr, port, (Plug) pr, + !cfg->lport_acceptall, cfg); + if ((err = sk_socket_error(s)) != NULL) { sfree(pr); return err; }