projects
/
u
/
mdw
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add input-focus support for System 7, where the Control Manager can't do
[u/mdw/putty]
/
portfwd.c
diff --git
a/portfwd.c
b/portfwd.c
index
a153d08
..
00c6cfc
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>
@@
-58,7
+57,7
@@
struct pfwd_queue {
};
struct PFwdPrivate {
};
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 */
/* 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 */
@@
-71,8
+70,6
@@
struct PFwdPrivate {
struct pfwd_queue *waiting;
};
struct pfwd_queue *waiting;
};
-void pfd_close(Socket s);
-
static int pfd_closing(Plug plug, char *error_msg, int error_code,
int calling_back)
static int pfd_closing(Plug plug, char *error_msg, int error_code,
int calling_back)
@@
-111,9
+108,10
@@
static void pfd_sent(Plug plug, int bufsize)
/*
* Called when receiving a PORT OPEN from the server
*/
/*
* 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,
pfd_closing,
pfd_receive,
pfd_sent,
@@
-127,22
+125,23
@@
char *pfd_newconnect(Socket *s, char *hostname, int port, void *c)
/*
* Try to find host.
*/
/*
* Try to find host.
*/
- addr =
sk_namelookup(hostname, &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;
/*
* Open socket.
*/
return err;
/*
* Open socket.
*/
- pr =
(struct PFwdPrivate *) smalloc(sizeof(struct PFwdPrivate)
);
+ pr =
snew(struct PFwdPrivate
);
pr->fn = &fn_table;
pr->throttled = pr->throttle_override = 0;
pr->ready = 1;
pr->c = c;
pr->backhandle = NULL; /* we shouldn't need this */
pr->fn = &fn_table;
pr->throttled = pr->throttle_override = 0;
pr->ready = 1;
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;
}
sfree(pr);
return err;
}
@@
-158,7
+157,7
@@
char *pfd_newconnect(Socket *s, char *hostname, int port, void *c)
static int pfd_accepting(Plug p, void *sock)
{
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,
pfd_closing,
pfd_receive,
pfd_sent,
@@
-169,14
+168,14
@@
static int pfd_accepting(Plug p, void *sock)
char *err;
org = (struct PFwdPrivate *)p;
char *err;
org = (struct PFwdPrivate *)p;
- pr =
(struct PFwdPrivate *) smalloc(sizeof(struct PFwdPrivate)
);
+ pr =
snew(struct PFwdPrivate
);
pr->fn = &fn_table;
pr->c = NULL;
pr->backhandle = org->backhandle;
pr->s = s = sk_register(sock, (Plug) pr);
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))) {
+ if ((err = sk_socket_error(s))
!= NULL
) {
sfree(pr);
return err != NULL;
}
sfree(pr);
return err != NULL;
}
@@
-204,11
+203,12
@@
static int pfd_accepting(Plug p, void *sock)
/* Add a new forwarding from port -> desthost:destport
/* Add a new forwarding from port -> desthost:destport
- sets up a listener on the local machine on port
+ sets up a listener on the local machine on
(srcaddr:)
port
*/
*/
-char *pfd_addforward(char *desthost, int destport, int port, void *backhandle)
+char *pfd_addforward(char *desthost, int destport, char *srcaddr, int port,
+ 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 */
pfd_closing,
pfd_receive, /* should not happen... */
pfd_sent, /* also should not happen */
@@
-222,7
+222,7
@@
char *pfd_addforward(char *desthost, int destport, int port, void *backhandle)
/*
* Open socket.
*/
/*
* Open socket.
*/
- pr =
(struct PFwdPrivate *) smalloc(sizeof(struct PFwdPrivate)
);
+ pr =
snew(struct PFwdPrivate
);
pr->fn = &fn_table;
pr->c = NULL;
strcpy(pr->hostname, desthost);
pr->fn = &fn_table;
pr->c = NULL;
strcpy(pr->hostname, desthost);
@@
-232,8
+232,9
@@
char *pfd_addforward(char *desthost, int destport, int port, void *backhandle)
pr->waiting = NULL;
pr->backhandle = backhandle;
pr->waiting = NULL;
pr->backhandle = backhandle;
- pr->s = s = new_listener(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;
}
sfree(pr);
return err;
}