diff options
author | Andreas Schneider <mail@cynapses.org> | 2009-12-01 16:15:54 +0100 |
---|---|---|
committer | Andreas Schneider <mail@cynapses.org> | 2009-12-02 00:23:00 +0100 |
commit | e5bf645010f74408060ced7d0c327a5f65823d1b (patch) | |
tree | 686a8752ae1c11490cd16853eb290a48653ad4e1 | |
parent | d1c6fa9261963dbaf54a85f99ba9c09bfc8029bf (diff) | |
download | libssh-e5bf645010f74408060ced7d0c327a5f65823d1b.tar.gz libssh-e5bf645010f74408060ced7d0c327a5f65823d1b.tar.xz libssh-e5bf645010f74408060ced7d0c327a5f65823d1b.zip |
Fixed uint* to work on Windows.
Thanks to Patrick Spendrin.
-rw-r--r-- | include/libssh/libssh.h | 4 | ||||
-rw-r--r-- | include/libssh/pcap.h | 4 | ||||
-rw-r--r-- | libssh/pcap.c | 38 |
3 files changed, 25 insertions, 21 deletions
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h index a17e90a2..b8462209 100644 --- a/include/libssh/libssh.h +++ b/include/libssh/libssh.h @@ -50,6 +50,7 @@ #ifdef _MSC_VER /* Visual Studio hasn't inttypes.h so it doesn't know uint32_t */ + typedef int int32_t; typedef unsigned int uint32_t; typedef unsigned short uint16_t; typedef unsigned char uint8_t; @@ -62,6 +63,9 @@ #ifdef _WIN32 #include <winsock2.h> + #ifndef socklen_t + #define socklen_t int + #endif #else /* _WIN32 */ #include <sys/select.h> /* for fd_set * */ #include <netdb.h> diff --git a/include/libssh/pcap.h b/include/libssh/pcap.h index 831a5647..2026f470 100644 --- a/include/libssh/pcap.h +++ b/include/libssh/pcap.h @@ -7,7 +7,7 @@ #ifdef WITH_PCAP 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); 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); 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 */ diff --git a/libssh/pcap.c b/libssh/pcap.c index 2da0087e..76bbafa4 100644 --- a/libssh/pcap.c +++ b/libssh/pcap.c @@ -46,13 +46,13 @@ * Just for information. */ struct pcap_hdr_s { - u_int32_t magic_number; /* magic number */ - u_int16_t version_major; /* major version number */ - u_int16_t version_minor; /* minor version number */ + uint32_t magic_number; /* magic number */ + uint16_t version_major; /* major version number */ + uint16_t version_minor; /* minor version number */ int32_t thiszone; /* GMT to local correction */ - u_int32_t sigfigs; /* accuracy of timestamps */ - u_int32_t snaplen; /* max length of captured packets, in octets */ - u_int32_t network; /* data link type */ + uint32_t sigfigs; /* accuracy of timestamps */ + uint32_t snaplen; /* max length of captured packets, in octets */ + uint32_t network; /* data link type */ }; #define PCAP_MAGIC 0xa1b2c3d4 @@ -73,10 +73,10 @@ struct pcap_hdr_s { * Just for information. */ struct pcaprec_hdr_s { - u_int32_t ts_sec; /* timestamp seconds */ - u_int32_t ts_usec; /* timestamp microseconds */ - u_int32_t incl_len; /* number of octets of packet saved in file */ - u_int32_t orig_len; /* actual length of packet */ + uint32_t ts_sec; /* timestamp seconds */ + uint32_t ts_usec; /* timestamp microseconds */ + uint32_t incl_len; /* number of octets of packet saved in file */ + uint32_t orig_len; /* actual length of packet */ }; /** @private @@ -92,12 +92,12 @@ struct ssh_pcap_context_struct { /* All of these informations are useful to generate * the dummy IP and TCP packets */ - u_int32_t ipsource; - u_int32_t ipdest; - u_int16_t portsource; - u_int16_t portdest; - u_int32_t outsequence; - u_int32_t insequence; + uint32_t ipsource; + uint32_t ipdest; + uint16_t portsource; + uint16_t portdest; + uint32_t outsequence; + uint32_t insequence; }; /** @private @@ -106,7 +106,7 @@ struct ssh_pcap_context_struct { */ struct ssh_pcap_file_struct { 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 * 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(); struct timeval now; int err; @@ -282,7 +282,7 @@ static int ssh_pcap_context_connect(ssh_pcap_context ctx){ * @returns SSH_ERROR an error happened. */ 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; int err; if(ctx==NULL || ctx->file ==NULL) |