Fixed uint* to work on Windows.

Thanks to Patrick Spendrin.
This commit is contained in:
Andreas Schneider
2009-12-01 16:15:54 +01:00
parent 96afa4530c
commit 48b719cf68
7 changed files with 30 additions and 26 deletions

View File

@@ -169,9 +169,9 @@ typedef int (*ssh_packet_callback) (ssh_session session, uint8_t type, ssh_buffe
struct ssh_packet_callbacks_struct { struct ssh_packet_callbacks_struct {
/** Index of the first packet type being handled */ /** Index of the first packet type being handled */
u_int8_t start; uint8_t start;
/** Number of packets being handled by this callback struct */ /** Number of packets being handled by this callback struct */
u_int8_t n_callbacks; uint8_t n_callbacks;
/** A pointer to n_callbacks packet callbacks */ /** A pointer to n_callbacks packet callbacks */
ssh_packet_callback *callbacks; ssh_packet_callback *callbacks;
void *user; void *user;

View File

@@ -50,6 +50,7 @@
#ifdef _MSC_VER #ifdef _MSC_VER
/* Visual Studio hasn't inttypes.h so it doesn't know uint32_t */ /* Visual Studio hasn't inttypes.h so it doesn't know uint32_t */
typedef int int32_t;
typedef unsigned int uint32_t; typedef unsigned int uint32_t;
typedef unsigned short uint16_t; typedef unsigned short uint16_t;
typedef unsigned char uint8_t; typedef unsigned char uint8_t;
@@ -62,6 +63,9 @@
#ifdef _WIN32 #ifdef _WIN32
#include <winsock2.h> #include <winsock2.h>
#ifndef socklen_t
#define socklen_t int
#endif
#else /* _WIN32 */ #else /* _WIN32 */
#include <sys/select.h> /* for fd_set * */ #include <sys/select.h> /* for fd_set * */
#include <netdb.h> #include <netdb.h>

View File

@@ -7,7 +7,7 @@
#ifdef WITH_PCAP #ifdef WITH_PCAP
typedef struct ssh_pcap_context_struct* ssh_pcap_context; typedef struct ssh_pcap_context_struct* ssh_pcap_context;
int ssh_pcap_file_write_packet(ssh_pcap_file pcap, ssh_buffer packet, u_int32_t original_len); int ssh_pcap_file_write_packet(ssh_pcap_file pcap, ssh_buffer packet, uint32_t original_len);
ssh_pcap_context ssh_pcap_context_new(ssh_session session); ssh_pcap_context ssh_pcap_context_new(ssh_session session);
void ssh_pcap_context_free(ssh_pcap_context ctx); void ssh_pcap_context_free(ssh_pcap_context ctx);
@@ -18,7 +18,7 @@ enum ssh_pcap_direction{
}; };
void ssh_pcap_context_set_file(ssh_pcap_context, ssh_pcap_file); void ssh_pcap_context_set_file(ssh_pcap_context, ssh_pcap_file);
int ssh_pcap_context_write(ssh_pcap_context,enum ssh_pcap_direction direction, void *data, int ssh_pcap_context_write(ssh_pcap_context,enum ssh_pcap_direction direction, void *data,
u_int32_t len, u_int32_t origlen); uint32_t len, uint32_t origlen);
#endif /* WITH_PCAP */ #endif /* WITH_PCAP */

View File

@@ -143,7 +143,7 @@ int ssh_packet_socket_callback(const void *data, size_t len, void *user);
void ssh_packet_register_socket_callback(ssh_session session, struct socket *s); void ssh_packet_register_socket_callback(ssh_session session, struct socket *s);
void ssh_packet_set_callbacks(ssh_session session, ssh_packet_callbacks callbacks); void ssh_packet_set_callbacks(ssh_session session, ssh_packet_callbacks callbacks);
void ssh_packet_set_default_callbacks(ssh_session session); void ssh_packet_set_default_callbacks(ssh_session session);
void ssh_packet_process(ssh_session session, u_int8_t type); void ssh_packet_process(ssh_session session, uint8_t type);
/* connect.c */ /* connect.c */
int ssh_regex_init(void); int ssh_regex_init(void);
void ssh_regex_finalize(void); void ssh_regex_finalize(void);

View File

@@ -309,7 +309,7 @@ void ssh_packet_set_default_callbacks(ssh_session session){
* @brief dispatch the call of packet handlers callbacks for a received packet * @brief dispatch the call of packet handlers callbacks for a received packet
* @param type type of packet * @param type type of packet
*/ */
void ssh_packet_process(ssh_session session, u_int8_t type){ void ssh_packet_process(ssh_session session, uint8_t type){
struct ssh_iterator *i; struct ssh_iterator *i;
int r; int r;
ssh_packet_callbacks cb; ssh_packet_callbacks cb;

View File

@@ -46,13 +46,13 @@
* Just for information. * Just for information.
*/ */
struct pcap_hdr_s { struct pcap_hdr_s {
u_int32_t magic_number; /* magic number */ uint32_t magic_number; /* magic number */
u_int16_t version_major; /* major version number */ uint16_t version_major; /* major version number */
u_int16_t version_minor; /* minor version number */ uint16_t version_minor; /* minor version number */
int32_t thiszone; /* GMT to local correction */ int32_t thiszone; /* GMT to local correction */
u_int32_t sigfigs; /* accuracy of timestamps */ uint32_t sigfigs; /* accuracy of timestamps */
u_int32_t snaplen; /* max length of captured packets, in octets */ uint32_t snaplen; /* max length of captured packets, in octets */
u_int32_t network; /* data link type */ uint32_t network; /* data link type */
}; };
#define PCAP_MAGIC 0xa1b2c3d4 #define PCAP_MAGIC 0xa1b2c3d4
@@ -73,10 +73,10 @@ struct pcap_hdr_s {
* Just for information. * Just for information.
*/ */
struct pcaprec_hdr_s { struct pcaprec_hdr_s {
u_int32_t ts_sec; /* timestamp seconds */ uint32_t ts_sec; /* timestamp seconds */
u_int32_t ts_usec; /* timestamp microseconds */ uint32_t ts_usec; /* timestamp microseconds */
u_int32_t incl_len; /* number of octets of packet saved in file */ uint32_t incl_len; /* number of octets of packet saved in file */
u_int32_t orig_len; /* actual length of packet */ uint32_t orig_len; /* actual length of packet */
}; };
/** @private /** @private
@@ -92,12 +92,12 @@ struct ssh_pcap_context_struct {
/* All of these informations are useful to generate /* All of these informations are useful to generate
* the dummy IP and TCP packets * the dummy IP and TCP packets
*/ */
u_int32_t ipsource; uint32_t ipsource;
u_int32_t ipdest; uint32_t ipdest;
u_int16_t portsource; uint16_t portsource;
u_int16_t portdest; uint16_t portdest;
u_int32_t outsequence; uint32_t outsequence;
u_int32_t insequence; uint32_t insequence;
}; };
/** @private /** @private
@@ -106,7 +106,7 @@ struct ssh_pcap_context_struct {
*/ */
struct ssh_pcap_file_struct { struct ssh_pcap_file_struct {
FILE *output; FILE *output;
u_int16_t ipsequence; uint16_t ipsequence;
}; };
/** /**
@@ -136,7 +136,7 @@ static int ssh_pcap_file_write(ssh_pcap_file pcap, ssh_buffer packet){
* @brief prepends a packet with the pcap header and writes packet * @brief prepends a packet with the pcap header and writes packet
* on file * on file
*/ */
int ssh_pcap_file_write_packet(ssh_pcap_file pcap, ssh_buffer packet, u_int32_t original_len){ int ssh_pcap_file_write_packet(ssh_pcap_file pcap, ssh_buffer packet, uint32_t original_len){
ssh_buffer header=buffer_new(); ssh_buffer header=buffer_new();
struct timeval now; struct timeval now;
int err; int err;
@@ -282,7 +282,7 @@ static int ssh_pcap_context_connect(ssh_pcap_context ctx){
* @returns SSH_ERROR an error happened. * @returns SSH_ERROR an error happened.
*/ */
int ssh_pcap_context_write(ssh_pcap_context ctx,enum ssh_pcap_direction direction int ssh_pcap_context_write(ssh_pcap_context ctx,enum ssh_pcap_direction direction
, void *data, u_int32_t len, u_int32_t origlen){ , void *data, uint32_t len, uint32_t origlen){
ssh_buffer ip; ssh_buffer ip;
int err; int err;
if(ctx==NULL || ctx->file ==NULL) if(ctx==NULL || ctx->file ==NULL)

View File

@@ -370,7 +370,7 @@ int ssh_get_version(ssh_session session) {
* @brief handles a SSH_DISCONNECT packet * @brief handles a SSH_DISCONNECT packet
*/ */
SSH_PACKET_CALLBACK(ssh_packet_disconnect_callback){ SSH_PACKET_CALLBACK(ssh_packet_disconnect_callback){
u_int32_t code; uint32_t code;
char *error; char *error;
ssh_string error_s; ssh_string error_s;
(void)user; (void)user;