mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-22 06:38:37 -05:00
More preparatory work: remove the <windows.h> include from lots of
source files in which it's no longer required (it was previously required in anything that included <putty.h>, but not any more). Also moved a couple of stray bits of exposed WinSock back into winnet.c (getservbyname from ssh.c and AF_INET from proxy.c). [originally from svn r2160]
This commit is contained in:
parent
78c69239f1
commit
52bdffbfe0
1
be_all.c
1
be_all.c
@ -3,7 +3,6 @@
|
|||||||
* including ssh.
|
* including ssh.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "putty.h"
|
#include "putty.h"
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#include <windows.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
10
network.h
10
network.h
@ -76,6 +76,7 @@ void sk_cleanup(void); /* called just before program exit */
|
|||||||
|
|
||||||
SockAddr sk_namelookup(char *host, char **canonicalname);
|
SockAddr sk_namelookup(char *host, char **canonicalname);
|
||||||
void sk_getaddr(SockAddr addr, char *buf, int buflen);
|
void sk_getaddr(SockAddr addr, char *buf, int buflen);
|
||||||
|
enum { ADDRTYPE_IPV4, ADDRTYPE_IPV6 };
|
||||||
int sk_addrtype(SockAddr addr);
|
int sk_addrtype(SockAddr addr);
|
||||||
void sk_addrcopy(SockAddr addr, char *buf);
|
void sk_addrcopy(SockAddr addr, char *buf);
|
||||||
void sk_addr_free(SockAddr addr);
|
void sk_addr_free(SockAddr addr);
|
||||||
@ -143,6 +144,15 @@ char *sk_addr_error(SockAddr addr);
|
|||||||
*/
|
*/
|
||||||
void net_pending_errors(void);
|
void net_pending_errors(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Simple wrapper on getservbyname(), needed by ssh.c. Returns the
|
||||||
|
* port number, in host byte order (suitable for printf and so on).
|
||||||
|
* Returns 0 on failure. Any platform not supporting getservbyname
|
||||||
|
* can just return 0 - this function is not required to handle
|
||||||
|
* numeric port specifications.
|
||||||
|
*/
|
||||||
|
int net_service_lookup(char *service);
|
||||||
|
|
||||||
/********** SSL stuff **********/
|
/********** SSL stuff **********/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#include <windows.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
8
proxy.c
8
proxy.c
@ -5,8 +5,6 @@
|
|||||||
* code and the higher level backend.
|
* code and the higher level backend.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -155,7 +153,7 @@ static void sk_proxy_set_frozen (Socket s, int is_frozen)
|
|||||||
* so we have to check each time.
|
* so we have to check each time.
|
||||||
*/
|
*/
|
||||||
while (!ps->freeze && bufchain_size(&ps->pending_input_data) > 0) {
|
while (!ps->freeze && bufchain_size(&ps->pending_input_data) > 0) {
|
||||||
char * data;
|
void *data;
|
||||||
int len;
|
int len;
|
||||||
bufchain_prefix(&ps->pending_input_data, &data, &len);
|
bufchain_prefix(&ps->pending_input_data, &data, &len);
|
||||||
plug_receive(ps->plug, 0, data, len);
|
plug_receive(ps->plug, 0, data, len);
|
||||||
@ -641,7 +639,7 @@ int proxy_socks4_negotiate (Proxy_Socket p, int change)
|
|||||||
int length;
|
int length;
|
||||||
char * command;
|
char * command;
|
||||||
|
|
||||||
if (sk_addrtype(p->remote_addr) != AF_INET) {
|
if (sk_addrtype(p->remote_addr) != ADDRTYPE_IPV4) {
|
||||||
plug_closing(p->plug, "Proxy error: SOCKS version 4 does"
|
plug_closing(p->plug, "Proxy error: SOCKS version 4 does"
|
||||||
" not support IPv6", PROXY_ERROR_GENERAL, 0);
|
" not support IPv6", PROXY_ERROR_GENERAL, 0);
|
||||||
return 1;
|
return 1;
|
||||||
@ -931,7 +929,7 @@ int proxy_socks5_negotiate (Proxy_Socket p, int change)
|
|||||||
char command[22];
|
char command[22];
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (sk_addrtype(p->remote_addr) == AF_INET) {
|
if (sk_addrtype(p->remote_addr) == ADDRTYPE_IPV6) {
|
||||||
len = 10;
|
len = 10;
|
||||||
command[3] = 1; /* IPv4 */
|
command[3] = 1; /* IPv4 */
|
||||||
} else {
|
} else {
|
||||||
|
1
raw.c
1
raw.c
@ -1,4 +1,3 @@
|
|||||||
#include <windows.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
7
rlogin.c
7
rlogin.c
@ -1,4 +1,3 @@
|
|||||||
#include <windows.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@ -234,7 +233,7 @@ static Socket rlogin_socket(void *handle)
|
|||||||
|
|
||||||
static int rlogin_sendok(void *handle)
|
static int rlogin_sendok(void *handle)
|
||||||
{
|
{
|
||||||
Rlogin rlogin = (Rlogin) handle;
|
/* Rlogin rlogin = (Rlogin) handle; */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,7 +245,7 @@ static void rlogin_unthrottle(void *handle, int backlog)
|
|||||||
|
|
||||||
static int rlogin_ldisc(void *handle, int option)
|
static int rlogin_ldisc(void *handle, int option)
|
||||||
{
|
{
|
||||||
Rlogin rlogin = (Rlogin) handle;
|
/* Rlogin rlogin = (Rlogin) handle; */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,7 +261,7 @@ static void rlogin_provide_logctx(void *handle, void *logctx)
|
|||||||
|
|
||||||
static int rlogin_exitcode(void *handle)
|
static int rlogin_exitcode(void *handle)
|
||||||
{
|
{
|
||||||
Rlogin rlogin = (Rlogin) handle;
|
/* Rlogin rlogin = (Rlogin) handle; */
|
||||||
/* If we ever implement RSH, we'll probably need to do this properly */
|
/* If we ever implement RSH, we'll probably need to do this properly */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
44
ssh.c
44
ssh.c
@ -1,4 +1,3 @@
|
|||||||
#include <windows.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@ -3072,7 +3071,6 @@ static void ssh1_protocol(Ssh ssh, unsigned char *in, int inlen, int ispkt)
|
|||||||
int sport,dport,sserv,dserv;
|
int sport,dport,sserv,dserv;
|
||||||
char sports[256], dports[256], host[256];
|
char sports[256], dports[256], host[256];
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
struct servent *se;
|
|
||||||
|
|
||||||
ssh->rportfwds = newtree234(ssh_rportcmp_ssh1);
|
ssh->rportfwds = newtree234(ssh_rportcmp_ssh1);
|
||||||
/* Add port forwardings. */
|
/* Add port forwardings. */
|
||||||
@ -3100,10 +3098,8 @@ static void ssh1_protocol(Ssh ssh, unsigned char *in, int inlen, int ispkt)
|
|||||||
dserv = 0;
|
dserv = 0;
|
||||||
if (dport == 0) {
|
if (dport == 0) {
|
||||||
dserv = 1;
|
dserv = 1;
|
||||||
se = getservbyname(dports, NULL);
|
dport = net_service_lookup(dports);
|
||||||
if (se != NULL) {
|
if (!dport) {
|
||||||
dport = ntohs(se->s_port);
|
|
||||||
} else {
|
|
||||||
sprintf(buf,
|
sprintf(buf,
|
||||||
"Service lookup failed for destination port \"%s\"",
|
"Service lookup failed for destination port \"%s\"",
|
||||||
dports);
|
dports);
|
||||||
@ -3114,10 +3110,8 @@ static void ssh1_protocol(Ssh ssh, unsigned char *in, int inlen, int ispkt)
|
|||||||
sserv = 0;
|
sserv = 0;
|
||||||
if (sport == 0) {
|
if (sport == 0) {
|
||||||
sserv = 1;
|
sserv = 1;
|
||||||
se = getservbyname(sports, NULL);
|
sport = net_service_lookup(sports);
|
||||||
if (se != NULL) {
|
if (!sport) {
|
||||||
sport = ntohs(se->s_port);
|
|
||||||
} else {
|
|
||||||
sprintf(buf,
|
sprintf(buf,
|
||||||
"Service lookup failed for source port \"%s\"",
|
"Service lookup failed for source port \"%s\"",
|
||||||
sports);
|
sports);
|
||||||
@ -3129,10 +3123,10 @@ static void ssh1_protocol(Ssh ssh, unsigned char *in, int inlen, int ispkt)
|
|||||||
pfd_addforward(host, dport, sport, ssh);
|
pfd_addforward(host, dport, sport, ssh);
|
||||||
sprintf(buf, "Local port %.*s%.*s%d%.*s forwarding to"
|
sprintf(buf, "Local port %.*s%.*s%d%.*s forwarding to"
|
||||||
" %s:%.*s%.*s%d%.*s",
|
" %s:%.*s%.*s%d%.*s",
|
||||||
sserv ? strlen(sports) : 0, sports,
|
(int)(sserv ? strlen(sports) : 0), sports,
|
||||||
sserv, "(", sport, sserv, ")",
|
sserv, "(", sport, sserv, ")",
|
||||||
host,
|
host,
|
||||||
dserv ? strlen(dports) : 0, dports,
|
(int)(dserv ? strlen(dports) : 0), dports,
|
||||||
dserv, "(", dport, dserv, ")");
|
dserv, "(", dport, dserv, ")");
|
||||||
logevent(buf);
|
logevent(buf);
|
||||||
} else {
|
} else {
|
||||||
@ -3149,10 +3143,10 @@ static void ssh1_protocol(Ssh ssh, unsigned char *in, int inlen, int ispkt)
|
|||||||
} else {
|
} else {
|
||||||
sprintf(buf, "Requesting remote port %.*s%.*s%d%.*s"
|
sprintf(buf, "Requesting remote port %.*s%.*s%d%.*s"
|
||||||
" forward to %s:%.*s%.*s%d%.*s",
|
" forward to %s:%.*s%.*s%d%.*s",
|
||||||
sserv ? strlen(sports) : 0, sports,
|
(int)(sserv ? strlen(sports) : 0), sports,
|
||||||
sserv, "(", sport, sserv, ")",
|
sserv, "(", sport, sserv, ")",
|
||||||
host,
|
host,
|
||||||
dserv ? strlen(dports) : 0, dports,
|
(int)(dserv ? strlen(dports) : 0), dports,
|
||||||
dserv, "(", dport, dserv, ")");
|
dserv, "(", dport, dserv, ")");
|
||||||
logevent(buf);
|
logevent(buf);
|
||||||
send_packet(ssh, SSH1_CMSG_PORT_FORWARD_REQUEST,
|
send_packet(ssh, SSH1_CMSG_PORT_FORWARD_REQUEST,
|
||||||
@ -3412,7 +3406,6 @@ static void ssh1_protocol(Ssh ssh, unsigned char *in, int inlen, int ispkt)
|
|||||||
|
|
||||||
} else if (ssh->pktin.type == SSH1_MSG_CHANNEL_OPEN_FAILURE) {
|
} else if (ssh->pktin.type == SSH1_MSG_CHANNEL_OPEN_FAILURE) {
|
||||||
unsigned int remoteid = GET_32BIT(ssh->pktin.body);
|
unsigned int remoteid = GET_32BIT(ssh->pktin.body);
|
||||||
unsigned int localid = GET_32BIT(ssh->pktin.body+4);
|
|
||||||
struct ssh_channel *c;
|
struct ssh_channel *c;
|
||||||
|
|
||||||
c = find234(ssh->channels, &remoteid, ssh_channelfind);
|
c = find234(ssh->channels, &remoteid, ssh_channelfind);
|
||||||
@ -5120,7 +5113,6 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
|
|||||||
int sport,dport,sserv,dserv;
|
int sport,dport,sserv,dserv;
|
||||||
char sports[256], dports[256], host[256];
|
char sports[256], dports[256], host[256];
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
struct servent *se;
|
|
||||||
|
|
||||||
ssh->rportfwds = newtree234(ssh_rportcmp_ssh2);
|
ssh->rportfwds = newtree234(ssh_rportcmp_ssh2);
|
||||||
/* Add port forwardings. */
|
/* Add port forwardings. */
|
||||||
@ -5148,10 +5140,8 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
|
|||||||
dserv = 0;
|
dserv = 0;
|
||||||
if (dport == 0) {
|
if (dport == 0) {
|
||||||
dserv = 1;
|
dserv = 1;
|
||||||
se = getservbyname(dports, NULL);
|
dport = net_service_lookup(dports);
|
||||||
if (se != NULL) {
|
if (!dport) {
|
||||||
dport = ntohs(se->s_port);
|
|
||||||
} else {
|
|
||||||
sprintf(buf,
|
sprintf(buf,
|
||||||
"Service lookup failed for destination port \"%s\"",
|
"Service lookup failed for destination port \"%s\"",
|
||||||
dports);
|
dports);
|
||||||
@ -5162,10 +5152,8 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
|
|||||||
sserv = 0;
|
sserv = 0;
|
||||||
if (sport == 0) {
|
if (sport == 0) {
|
||||||
sserv = 1;
|
sserv = 1;
|
||||||
se = getservbyname(sports, NULL);
|
sport = net_service_lookup(sports);
|
||||||
if (se != NULL) {
|
if (!sport) {
|
||||||
sport = ntohs(se->s_port);
|
|
||||||
} else {
|
|
||||||
sprintf(buf,
|
sprintf(buf,
|
||||||
"Service lookup failed for source port \"%s\"",
|
"Service lookup failed for source port \"%s\"",
|
||||||
sports);
|
sports);
|
||||||
@ -5177,10 +5165,10 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
|
|||||||
pfd_addforward(host, dport, sport, ssh);
|
pfd_addforward(host, dport, sport, ssh);
|
||||||
sprintf(buf, "Local port %.*s%.*s%d%.*s forwarding to"
|
sprintf(buf, "Local port %.*s%.*s%d%.*s forwarding to"
|
||||||
" %s:%.*s%.*s%d%.*s",
|
" %s:%.*s%.*s%d%.*s",
|
||||||
sserv ? strlen(sports) : 0, sports,
|
(int)(sserv ? strlen(sports) : 0), sports,
|
||||||
sserv, "(", sport, sserv, ")",
|
sserv, "(", sport, sserv, ")",
|
||||||
host,
|
host,
|
||||||
dserv ? strlen(dports) : 0, dports,
|
(int)(dserv ? strlen(dports) : 0), dports,
|
||||||
dserv, "(", dport, dserv, ")");
|
dserv, "(", dport, dserv, ")");
|
||||||
logevent(buf);
|
logevent(buf);
|
||||||
} else {
|
} else {
|
||||||
@ -5198,10 +5186,10 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
|
|||||||
} else {
|
} else {
|
||||||
sprintf(buf, "Requesting remote port %.*s%.*s%d%.*s"
|
sprintf(buf, "Requesting remote port %.*s%.*s%d%.*s"
|
||||||
" forward to %s:%.*s%.*s%d%.*s",
|
" forward to %s:%.*s%.*s%d%.*s",
|
||||||
sserv ? strlen(sports) : 0, sports,
|
(int)(sserv ? strlen(sports) : 0), sports,
|
||||||
sserv, "(", sport, sserv, ")",
|
sserv, "(", sport, sserv, ")",
|
||||||
host,
|
host,
|
||||||
dserv ? strlen(dports) : 0, dports,
|
(int)(dserv ? strlen(dports) : 0), dports,
|
||||||
dserv, "(", dport, dserv, ")");
|
dserv, "(", dport, dserv, ")");
|
||||||
logevent(buf);
|
logevent(buf);
|
||||||
ssh2_pkt_init(ssh, SSH2_MSG_GLOBAL_REQUEST);
|
ssh2_pkt_init(ssh, SSH2_MSG_GLOBAL_REQUEST);
|
||||||
|
2
sshbn.c
2
sshbn.c
@ -799,6 +799,7 @@ unsigned short bignum_mod_short(Bignum number, unsigned short modulus)
|
|||||||
|
|
||||||
void diagbn(char *prefix, Bignum md)
|
void diagbn(char *prefix, Bignum md)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
int i, nibbles, morenibbles;
|
int i, nibbles, morenibbles;
|
||||||
static const char hex[] = "0123456789ABCDEF";
|
static const char hex[] = "0123456789ABCDEF";
|
||||||
|
|
||||||
@ -816,6 +817,7 @@ void diagbn(char *prefix, Bignum md)
|
|||||||
|
|
||||||
if (prefix)
|
if (prefix)
|
||||||
debug(("\n"));
|
debug(("\n"));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
2
sshdes.c
2
sshdes.c
@ -908,7 +908,7 @@ static const struct ssh2_cipher ssh_3des_ssh2 = {
|
|||||||
* only people to do so, so we sigh and implement it anyway.
|
* only people to do so, so we sigh and implement it anyway.
|
||||||
*/
|
*/
|
||||||
static const struct ssh2_cipher ssh_des_ssh2 = {
|
static const struct ssh2_cipher ssh_des_ssh2 = {
|
||||||
des3_make_context, des3_free_context, des3_iv, des_key,
|
des_make_context, des3_free_context, des3_iv, des_key,
|
||||||
des_ssh2_encrypt_blk, des_ssh2_decrypt_blk,
|
des_ssh2_encrypt_blk, des_ssh2_decrypt_blk,
|
||||||
"des-cbc",
|
"des-cbc",
|
||||||
8, 56, "single-DES"
|
8, 56, "single-DES"
|
||||||
|
5
telnet.c
5
telnet.c
@ -1,4 +1,3 @@
|
|||||||
#include <windows.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
@ -890,7 +889,7 @@ static Socket telnet_socket(void *handle)
|
|||||||
|
|
||||||
static int telnet_sendok(void *handle)
|
static int telnet_sendok(void *handle)
|
||||||
{
|
{
|
||||||
Telnet telnet = (Telnet) handle;
|
/* Telnet telnet = (Telnet) handle; */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -923,7 +922,7 @@ static void telnet_provide_logctx(void *handle, void *logctx)
|
|||||||
|
|
||||||
static int telnet_exitcode(void *handle)
|
static int telnet_exitcode(void *handle)
|
||||||
{
|
{
|
||||||
Telnet telnet = (Telnet) handle;
|
/* Telnet telnet = (Telnet) handle; */
|
||||||
/* Telnet doesn't transmit exit codes back to the client */
|
/* Telnet doesn't transmit exit codes back to the client */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -42,4 +42,7 @@ void provide_xrm_string(char *string);
|
|||||||
|
|
||||||
#define DEFAULT_CODEPAGE 0 /* FIXME: no idea how to do this */
|
#define DEFAULT_CODEPAGE 0 /* FIXME: no idea how to do this */
|
||||||
|
|
||||||
|
#define strnicmp strncasecmp
|
||||||
|
#define stricmp strcasecmp
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
12
winnet.c
12
winnet.c
@ -370,7 +370,7 @@ void sk_getaddr(SockAddr addr, char *buf, int buflen)
|
|||||||
|
|
||||||
int sk_addrtype(SockAddr addr)
|
int sk_addrtype(SockAddr addr)
|
||||||
{
|
{
|
||||||
return addr->family;
|
return (addr->family == AF_INET ? ADDRTYPE_IPV4 : ADDRTYPE_IPV6);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sk_addrcopy(SockAddr addr, char *buf)
|
void sk_addrcopy(SockAddr addr, char *buf)
|
||||||
@ -1138,3 +1138,13 @@ SOCKET next_socket(int *state)
|
|||||||
Actual_Socket s = index234(sktree, (*state)++);
|
Actual_Socket s = index234(sktree, (*state)++);
|
||||||
return s ? s->s : INVALID_SOCKET;
|
return s ? s->s : INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int net_service_lookup(char *service)
|
||||||
|
{
|
||||||
|
struct servent *se;
|
||||||
|
se = getservbyname(service, NULL);
|
||||||
|
if (se != NULL)
|
||||||
|
return ntohs(se->s_port);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user