~mdw
/
sgt
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Another signal-handling refinement from RJK: the SIGCHLD handler
[sgt/putty]
/
portfwd.c
diff --git
a/portfwd.c
b/portfwd.c
index
4335398
..
16f001a
100644
(file)
--- a/
portfwd.c
+++ b/
portfwd.c
@@
-1,4
+1,3
@@
-#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
@@
-61,6
+60,8
@@
struct PFwdPrivate {
struct plug_function_table *fn;
/* the above variable absolutely *must* be the first in this structure */
void *c; /* (channel) data used by ssh.c */
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 */
+ /* Note that backhandle need not be filled in if c is non-NULL */
Socket s;
char hostname[128];
int throttled, throttle_override;
Socket s;
char hostname[128];
int throttled, throttle_override;
@@
-137,8
+138,9
@@
char *pfd_newconnect(Socket *s, char *hostname, int port, void *c)
pr->throttled = pr->throttle_override = 0;
pr->ready = 1;
pr->c = c;
pr->throttled = pr->throttle_override = 0;
pr->ready = 1;
pr->c = c;
+ pr->backhandle = NULL; /* we shouldn't need this */
- pr->s = *s =
sk_new(addr, port, 0, 1
, (Plug) pr);
+ pr->s = *s =
new_connection(addr, dummy_realhost, port, 0, 1, 0
, (Plug) pr);
if ((err = sk_socket_error(*s))) {
sfree(pr);
return err;
if ((err = sk_socket_error(*s))) {
sfree(pr);
return err;
@@
-153,9
+155,8
@@
char *pfd_newconnect(Socket *s, char *hostname, int port, void *c)
called when someone connects to the local port
*/
called when someone connects to the local port
*/
-static int pfd_accepting(Plug p,
struct sockaddr *addr,
void *sock)
+static int pfd_accepting(Plug p, void *sock)
{
{
- /* for now always accept this socket */
static struct plug_function_table fn_table = {
pfd_closing,
pfd_receive,
static struct plug_function_table fn_table = {
pfd_closing,
pfd_receive,
@@
-163,18
+164,15
@@
static int pfd_accepting(Plug p, struct sockaddr *addr, void *sock)
NULL
};
struct PFwdPrivate *pr, *org;
NULL
};
struct PFwdPrivate *pr, *org;
- struct sockaddr_in *sin = (struct sockaddr_in *)addr;
Socket s;
char *err;
Socket s;
char *err;
- if (ntohl(sin->sin_addr.s_addr) != 0x7F000001 && !cfg.lport_acceptall)
- return 1; /* denied */
-
org = (struct PFwdPrivate *)p;
pr = (struct PFwdPrivate *) smalloc(sizeof(struct PFwdPrivate));
pr->fn = &fn_table;
pr->c = NULL;
org = (struct PFwdPrivate *)p;
pr = (struct PFwdPrivate *) smalloc(sizeof(struct PFwdPrivate));
pr->fn = &fn_table;
pr->c = NULL;
+ pr->backhandle = org->backhandle;
pr->s = s = sk_register(sock, (Plug) pr);
if ((err = sk_socket_error(s))) {
pr->s = s = sk_register(sock, (Plug) pr);
if ((err = sk_socket_error(s))) {
@@
-182,7
+180,7
@@
static int pfd_accepting(Plug p, struct sockaddr *addr, void *sock)
return err != NULL;
}
return err != NULL;
}
- pr->c = new_sock_channel(s);
+ pr->c = new_sock_channel(
org->backhandle,
s);
strcpy(pr->hostname, org->hostname);
pr->port = org->port;
strcpy(pr->hostname, org->hostname);
pr->port = org->port;
@@
-205,9
+203,9
@@
static int pfd_accepting(Plug p, struct sockaddr *addr, void *sock)
/* Add a new forwarding from port -> desthost:destport
/* Add a new forwarding from port -> desthost:destport
- sets up a listen
n
er on the local machine on port
+ sets up a listener on the local machine on port
*/
*/
-char *pfd_addforward(char *desthost, int destport, int port)
+char *pfd_addforward(char *desthost, int destport, int port
, void *backhandle
)
{
static struct plug_function_table fn_table = {
pfd_closing,
{
static struct plug_function_table fn_table = {
pfd_closing,
@@
-231,8
+229,9
@@
char *pfd_addforward(char *desthost, int destport, int port)
pr->throttled = pr->throttle_override = 0;
pr->ready = 0;
pr->waiting = NULL;
pr->throttled = pr->throttle_override = 0;
pr->ready = 0;
pr->waiting = NULL;
+ pr->backhandle = backhandle;
- pr->s = s =
sk_newlistenner(port, (Plug) pr
);
+ pr->s = s =
new_listener(port, (Plug) pr, !cfg.lport_acceptall
);
if ((err = sk_socket_error(s))) {
sfree(pr);
return err;
if ((err = sk_socket_error(s))) {
sfree(pr);
return err;