slirp: fix packed structs on MSVC
This commit is contained in:
@@ -71,6 +71,9 @@ typedef uint32_t n_long; /* long as received from the net */
|
|||||||
/*
|
/*
|
||||||
* Structure of an internet header, naked of options.
|
* Structure of an internet header, naked of options.
|
||||||
*/
|
*/
|
||||||
|
#if defined(_MSC_VER) && !defined (__clang__)
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
#endif
|
||||||
struct ip {
|
struct ip {
|
||||||
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
||||||
uint8_t ip_v : 4, /* version */
|
uint8_t ip_v : 4, /* version */
|
||||||
@@ -91,6 +94,9 @@ struct ip {
|
|||||||
uint16_t ip_sum; /* checksum */
|
uint16_t ip_sum; /* checksum */
|
||||||
struct in_addr ip_src, ip_dst; /* source and dest address */
|
struct in_addr ip_src, ip_dst; /* source and dest address */
|
||||||
} SLIRP_PACKED;
|
} SLIRP_PACKED;
|
||||||
|
#if defined(_MSC_VER) && !defined (__clang__)
|
||||||
|
#pragma pack(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define IP_MAXPACKET 65535 /* maximum packet size */
|
#define IP_MAXPACKET 65535 /* maximum packet size */
|
||||||
|
|
||||||
@@ -134,6 +140,9 @@ struct ip {
|
|||||||
/*
|
/*
|
||||||
* Time stamp option structure.
|
* Time stamp option structure.
|
||||||
*/
|
*/
|
||||||
|
#if defined(_MSC_VER) && !defined (__clang__)
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
#endif
|
||||||
struct ip_timestamp {
|
struct ip_timestamp {
|
||||||
uint8_t ipt_code; /* IPOPT_TS */
|
uint8_t ipt_code; /* IPOPT_TS */
|
||||||
uint8_t ipt_len; /* size of structure (variable) */
|
uint8_t ipt_len; /* size of structure (variable) */
|
||||||
@@ -153,6 +162,9 @@ struct ip_timestamp {
|
|||||||
} ipt_ta[1];
|
} ipt_ta[1];
|
||||||
} ipt_timestamp;
|
} ipt_timestamp;
|
||||||
} SLIRP_PACKED;
|
} SLIRP_PACKED;
|
||||||
|
#if defined(_MSC_VER) && !defined (__clang__)
|
||||||
|
#pragma pack(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* flag bits for ipt_flg */
|
/* flag bits for ipt_flg */
|
||||||
#define IPOPT_TS_TSONLY 0 /* timestamps only */
|
#define IPOPT_TS_TSONLY 0 /* timestamps only */
|
||||||
@@ -178,6 +190,9 @@ struct ip_timestamp {
|
|||||||
|
|
||||||
#define IP_MSS 576 /* default maximum segment size */
|
#define IP_MSS 576 /* default maximum segment size */
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && !defined (__clang__)
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
#endif
|
||||||
#if GLIB_SIZEOF_VOID_P == 4
|
#if GLIB_SIZEOF_VOID_P == 4
|
||||||
struct mbuf_ptr {
|
struct mbuf_ptr {
|
||||||
struct mbuf *mptr;
|
struct mbuf *mptr;
|
||||||
@@ -188,6 +203,9 @@ struct mbuf_ptr {
|
|||||||
struct mbuf *mptr;
|
struct mbuf *mptr;
|
||||||
} SLIRP_PACKED;
|
} SLIRP_PACKED;
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(_MSC_VER) && !defined (__clang__)
|
||||||
|
#pragma pack(pop)
|
||||||
|
#endif
|
||||||
struct qlink {
|
struct qlink {
|
||||||
void *next, *prev;
|
void *next, *prev;
|
||||||
};
|
};
|
||||||
@@ -195,6 +213,9 @@ struct qlink {
|
|||||||
/*
|
/*
|
||||||
* Overlay for ip header used by other protocols (tcp, udp).
|
* Overlay for ip header used by other protocols (tcp, udp).
|
||||||
*/
|
*/
|
||||||
|
#if defined(_MSC_VER) && !defined (__clang__)
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
#endif
|
||||||
struct ipovly {
|
struct ipovly {
|
||||||
struct mbuf_ptr ih_mbuf; /* backpointer to mbuf */
|
struct mbuf_ptr ih_mbuf; /* backpointer to mbuf */
|
||||||
uint8_t ih_x1; /* (unused) */
|
uint8_t ih_x1; /* (unused) */
|
||||||
@@ -203,6 +224,9 @@ struct ipovly {
|
|||||||
struct in_addr ih_src; /* source internet address */
|
struct in_addr ih_src; /* source internet address */
|
||||||
struct in_addr ih_dst; /* destination internet address */
|
struct in_addr ih_dst; /* destination internet address */
|
||||||
} SLIRP_PACKED;
|
} SLIRP_PACKED;
|
||||||
|
#if defined(_MSC_VER) && !defined (__clang__)
|
||||||
|
#pragma pack(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ip reassembly queue structure. Each fragment
|
* Ip reassembly queue structure. Each fragment
|
||||||
|
@@ -115,6 +115,9 @@ G_STATIC_ASSERT(sizeof(struct icmp6) == 40);
|
|||||||
/*
|
/*
|
||||||
* NDP Options
|
* NDP Options
|
||||||
*/
|
*/
|
||||||
|
#if defined(_MSC_VER) && !defined (__clang__)
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
#endif
|
||||||
struct ndpopt {
|
struct ndpopt {
|
||||||
uint8_t ndpopt_type; /* Option type */
|
uint8_t ndpopt_type; /* Option type */
|
||||||
uint8_t ndpopt_len; /* /!\ In units of 8 octets */
|
uint8_t ndpopt_len; /* /!\ In units of 8 octets */
|
||||||
@@ -142,6 +145,9 @@ struct ndpopt {
|
|||||||
#define ndpopt_rdnss ndpopt_body.rdnss
|
#define ndpopt_rdnss ndpopt_body.rdnss
|
||||||
} ndpopt_body;
|
} ndpopt_body;
|
||||||
} SLIRP_PACKED;
|
} SLIRP_PACKED;
|
||||||
|
#if defined(_MSC_VER) && !defined (__clang__)
|
||||||
|
#pragma pack(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* NDP options type */
|
/* NDP options type */
|
||||||
#define NDPOPT_LINKLAYER_SOURCE 1 /* Source Link-Layer Address */
|
#define NDPOPT_LINKLAYER_SOURCE 1 /* Source Link-Layer Address */
|
||||||
|
@@ -75,6 +75,9 @@ struct ethhdr {
|
|||||||
unsigned short h_proto; /* packet type ID field */
|
unsigned short h_proto; /* packet type ID field */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && !defined (__clang__)
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
#endif
|
||||||
struct slirp_arphdr {
|
struct slirp_arphdr {
|
||||||
unsigned short ar_hrd; /* format of hardware address */
|
unsigned short ar_hrd; /* format of hardware address */
|
||||||
unsigned short ar_pro; /* format of protocol address */
|
unsigned short ar_pro; /* format of protocol address */
|
||||||
@@ -90,6 +93,9 @@ struct slirp_arphdr {
|
|||||||
unsigned char ar_tha[ETH_ALEN]; /* target hardware address */
|
unsigned char ar_tha[ETH_ALEN]; /* target hardware address */
|
||||||
uint32_t ar_tip; /* target IP address */
|
uint32_t ar_tip; /* target IP address */
|
||||||
} SLIRP_PACKED;
|
} SLIRP_PACKED;
|
||||||
|
#if defined(_MSC_VER) && !defined (__clang__)
|
||||||
|
#pragma pack(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ARP_TABLE_SIZE 16
|
#define ARP_TABLE_SIZE 16
|
||||||
|
|
||||||
|
@@ -20,6 +20,9 @@
|
|||||||
#define TFTP_FILENAME_MAX 512
|
#define TFTP_FILENAME_MAX 512
|
||||||
#define TFTP_BLOCKSIZE_MAX 1428
|
#define TFTP_BLOCKSIZE_MAX 1428
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && !defined (__clang__)
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
#endif
|
||||||
struct tftp_t {
|
struct tftp_t {
|
||||||
struct udphdr udp;
|
struct udphdr udp;
|
||||||
uint16_t tp_op;
|
uint16_t tp_op;
|
||||||
@@ -35,6 +38,9 @@ struct tftp_t {
|
|||||||
char tp_buf[TFTP_BLOCKSIZE_MAX + 2];
|
char tp_buf[TFTP_BLOCKSIZE_MAX + 2];
|
||||||
} x;
|
} x;
|
||||||
} SLIRP_PACKED;
|
} SLIRP_PACKED;
|
||||||
|
#if defined(_MSC_VER) && !defined (__clang__)
|
||||||
|
#pragma pack(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
struct tftp_session {
|
struct tftp_session {
|
||||||
Slirp *slirp;
|
Slirp *slirp;
|
||||||
|
@@ -46,8 +46,10 @@
|
|||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__))
|
#if defined(_MSC_VER) && !defined(__clang__)
|
||||||
#define SLIRP_PACKED __attribute__((gcc_struct, packed))
|
#define SLIRP_PACKED
|
||||||
|
#elif defined(_WIN32) && (defined(__x86_64__) || defined(__i386__))
|
||||||
|
#define SLIRP_PACKED __attribute__((gcc_struct, packed))
|
||||||
#else
|
#else
|
||||||
#define SLIRP_PACKED __attribute__((packed))
|
#define SLIRP_PACKED __attribute__((packed))
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user