Somw work to make the new slirp module compile and work with MSVC

- added container_of() macro replacement
- fixed unresolved symbol in netmod.cc
- added MSVC-style structure packing pragmas
- check for the presence of min / max macros
- enabled slirp_new for MSVC in configure script
TODO list:
- check for more updates from Qemu
- fix lots of compiler warnings
- reduce code duplication with 'vnet' module (DHCP, TFTP, ARP)
- add separate config file for slirp to make it more flexible (using the
  'script' parameter)
- update MSVC workspace files
- add SMB support on Linux
- remove slirp backend module after next Bochs release
This commit is contained in:
Volker Ruppert 2014-02-25 19:44:14 +00:00
parent 01af7f5346
commit e62076e53d
5 changed files with 26 additions and 3 deletions

View File

@ -858,7 +858,8 @@ if test "$networking" = yes; then
DEVICE_LINK_OPTS="$DEVICE_LINK_OPTS -liphlpapi"
;;
*-pc-windows* | *-pc-winnt*)
can_compile_slirp_new=0
can_compile_slirp_new=1
DEVICE_LINK_OPTS="$DEVICE_LINK_OPTS iphlpapi.lib"
;;
*)
AC_CHECK_HEADER([netinet/in.h], [ can_compile_slirp_new=1 ], [])

View File

@ -128,7 +128,7 @@ extern class bx_vde_locator_c bx_vde_match;
extern class bx_slirp_locator_c bx_slirp_match;
#endif
#if BX_NETMOD_SLIRP_NEW
extern class bx_slirp_locator_c bx_slirp_new_match;
extern class bx_slirp_new_locator_c bx_slirp_new_match;
#endif
extern class bx_vnet_locator_c bx_vnet_match;

View File

@ -30,9 +30,13 @@ typedef Bit64s ssize_t;
#endif
#ifndef container_of
#ifndef _MSC_VER
#define container_of(ptr, type, member) ({ \
const typeof(((type *) 0)->member) *__mptr = (ptr); \
(type *) ((char *) __mptr - offsetof(type, member));})
#else
#define container_of(ptr, type, member) ((type *)((char *)(ptr) -offsetof(type,member)))
#endif
#endif
#ifndef MIN

View File

@ -65,6 +65,10 @@ typedef uint32_t n_long; /* long as received from the net */
*/
#define IPVERSION 4
#if defined(_MSC_VER)
#pragma pack(push, 1)
#endif
/*
* Structure of an internet header, naked of options.
*/
@ -246,4 +250,8 @@ struct ipoption {
int8_t ipopt_list[MAX_IPOPTLEN]; /* options proper */
} GCC_ATTRIBUTE((packed));
#if defined(_MSC_VER)
#pragma pack(pop)
#endif
#endif

View File

@ -179,6 +179,10 @@ struct ethhdr {
unsigned short h_proto; /* packet type ID field */
};
#if defined(_MSC_VER)
#pragma pack(push, 1)
#endif
struct arphdr {
unsigned short ar_hrd; /* format of hardware address */
unsigned short ar_pro; /* format of protocol address */
@ -195,6 +199,10 @@ struct arphdr {
uint32_t ar_tip; /* target IP address */
} GCC_ATTRIBUTE((packed));
#if defined(_MSC_VER)
#pragma pack(pop)
#endif
#define ARP_TABLE_SIZE 16
typedef struct ArpTable {
@ -349,8 +357,10 @@ struct tcpcb *tcp_drop(struct tcpcb *tp, int err);
#define MAX_MRU 16384
#endif
#ifndef _WIN32
#ifndef min
#define min(x,y) ((x) < (y) ? (x) : (y))
#endif
#ifndef max
#define max(x,y) ((x) > (y) ? (x) : (y))
#endif