Separate out SLIRP_PACKED to SLIRP_PACKED_BEGIN/END

Since msvc provides the support through push/pop pragmas.
diff --git a/src/ip.h b/src/ip.h
index e5d4aa8..2daa344 100644
--- a/src/ip.h
+++ b/src/ip.h
@@ -71,6 +71,7 @@
 /*
  * Structure of an internet header, naked of options.
  */
+SLIRP_PACKED_BEGIN
 struct ip {
 #if G_BYTE_ORDER == G_BIG_ENDIAN
     uint8_t ip_v : 4, /* version */
@@ -90,7 +91,7 @@
     uint8_t ip_p; /* protocol */
     uint16_t ip_sum; /* checksum */
     struct in_addr ip_src, ip_dst; /* source and dest address */
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 #define IP_MAXPACKET 65535 /* maximum packet size */
 
@@ -134,6 +135,7 @@
 /*
  * Time stamp option structure.
  */
+SLIRP_PACKED_BEGIN
 struct ip_timestamp {
     uint8_t ipt_code; /* IPOPT_TS */
     uint8_t ipt_len; /* size of structure (variable) */
@@ -152,7 +154,7 @@
             n_long ipt_time;
         } ipt_ta[1];
     } ipt_timestamp;
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* flag bits for ipt_flg */
 #define IPOPT_TS_TSONLY 0 /* timestamps only */
@@ -179,14 +181,16 @@
 #define IP_MSS 576 /* default maximum segment size */
 
 #if GLIB_SIZEOF_VOID_P == 4
+SLIRP_PACKED_BEGIN
 struct mbuf_ptr {
     struct mbuf *mptr;
     uint32_t dummy;
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 #else
+SLIRP_PACKED_BEGIN
 struct mbuf_ptr {
     struct mbuf *mptr;
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 #endif
 struct qlink {
     void *next, *prev;
@@ -195,6 +199,7 @@
 /*
  * Overlay for ip header used by other protocols (tcp, udp).
  */
+SLIRP_PACKED_BEGIN
 struct ipovly {
     struct mbuf_ptr ih_mbuf; /* backpointer to mbuf */
     uint8_t ih_x1; /* (unused) */
@@ -202,7 +207,7 @@
     uint16_t ih_len; /* protocol length */
     struct in_addr ih_src; /* source internet address */
     struct in_addr ih_dst; /* destination internet address */
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /*
  * Ip reassembly queue structure.  Each fragment
diff --git a/src/ip6_icmp.h b/src/ip6_icmp.h
index 9f378f1..76517b3 100644
--- a/src/ip6_icmp.h
+++ b/src/ip6_icmp.h
@@ -115,13 +115,15 @@
 /*
  * NDP Options
  */
+SLIRP_PACKED_BEGIN
 struct ndpopt {
     uint8_t ndpopt_type; /* Option type */
     uint8_t ndpopt_len; /* /!\ In units of 8 octets */
     union {
         unsigned char linklayer_addr[6]; /* Source/Target Link-layer */
 #define ndpopt_linklayer ndpopt_body.linklayer_addr
-        struct prefixinfo { /* Prefix Information */
+        SLIRP_PACKED_BEGIN
+            struct prefixinfo { /* Prefix Information */
             uint8_t prefix_length;
 #if G_BYTE_ORDER == G_BIG_ENDIAN
             uint8_t L : 1, A : 1, reserved1 : 6;
@@ -132,16 +134,17 @@
             uint32_t pref_lt; /* Preferred Lifetime */
             uint32_t reserved2;
             struct in6_addr prefix;
-        } SLIRP_PACKED prefixinfo;
+        } SLIRP_PACKED_END prefixinfo;
 #define ndpopt_prefixinfo ndpopt_body.prefixinfo
-        struct rdnss {
+        SLIRP_PACKED_BEGIN
+            struct rdnss {
             uint16_t reserved;
             uint32_t lifetime;
             struct in6_addr addr;
-        } SLIRP_PACKED rdnss;
+        } SLIRP_PACKED_END rdnss;
 #define ndpopt_rdnss ndpopt_body.rdnss
     } ndpopt_body;
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* NDP options type */
 #define NDPOPT_LINKLAYER_SOURCE 1 /* Source Link-Layer Address */
diff --git a/src/main.h b/src/main.h
index 35ac58d..2e7f21a 100644
--- a/src/main.h
+++ b/src/main.h
@@ -6,6 +6,8 @@
 #ifndef SLIRP_MAIN_H
 #define SLIRP_MAIN_H
 
+#include "libslirp.h"
+
 extern unsigned curtime;
 extern struct in_addr loopback_addr;
 extern unsigned long loopback_mask;
diff --git a/src/ncsi-pkt.h b/src/ncsi-pkt.h
index 9dd167c..27bedf6 100644
--- a/src/ncsi-pkt.h
+++ b/src/ncsi-pkt.h
@@ -40,6 +40,7 @@
 #define __be32 uint32_t
 #define __be16 uint16_t
 
+SLIRP_PACKED_BEGIN
 struct ncsi_pkt_hdr {
     unsigned char mc_id; /* Management controller ID */
     unsigned char revision; /* NCSI version - 0x01      */
@@ -49,64 +50,73 @@
     unsigned char channel; /* Network controller ID    */
     __be16 length; /* Payload length           */
     __be32 reserved1[2]; /* Reserved                 */
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
+SLIRP_PACKED_BEGIN
 struct ncsi_cmd_pkt_hdr {
     struct ncsi_pkt_hdr common; /* Common NCSI packet header */
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
+SLIRP_PACKED_BEGIN
 struct ncsi_rsp_pkt_hdr {
     struct ncsi_pkt_hdr common; /* Common NCSI packet header */
     __be16 code; /* Response code             */
     __be16 reason; /* Response reason           */
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
+SLIRP_PACKED_BEGIN
 struct ncsi_aen_pkt_hdr {
     struct ncsi_pkt_hdr common; /* Common NCSI packet header */
     unsigned char reserved2[3]; /* Reserved                  */
     unsigned char type; /* AEN packet type           */
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* NCSI common command packet */
+SLIRP_PACKED_BEGIN
 struct ncsi_cmd_pkt {
     struct ncsi_cmd_pkt_hdr cmd; /* Command header */
     __be32 checksum; /* Checksum       */
     unsigned char pad[26];
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
+SLIRP_PACKED_BEGIN
 struct ncsi_rsp_pkt {
     struct ncsi_rsp_pkt_hdr rsp; /* Response header */
     __be32 checksum; /* Checksum        */
     unsigned char pad[22];
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* Select Package */
+SLIRP_PACKED_BEGIN
 struct ncsi_cmd_sp_pkt {
     struct ncsi_cmd_pkt_hdr cmd; /* Command header */
     unsigned char reserved[3]; /* Reserved       */
     unsigned char hw_arbitration; /* HW arbitration */
     __be32 checksum; /* Checksum       */
     unsigned char pad[22];
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* Disable Channel */
+SLIRP_PACKED_BEGIN
 struct ncsi_cmd_dc_pkt {
     struct ncsi_cmd_pkt_hdr cmd; /* Command header  */
     unsigned char reserved[3]; /* Reserved        */
     unsigned char ald; /* Allow link down */
     __be32 checksum; /* Checksum        */
     unsigned char pad[22];
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* Reset Channel */
+SLIRP_PACKED_BEGIN
 struct ncsi_cmd_rc_pkt {
     struct ncsi_cmd_pkt_hdr cmd; /* Command header */
     __be32 reserved; /* Reserved       */
     __be32 checksum; /* Checksum       */
     unsigned char pad[22];
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* AEN Enable */
+SLIRP_PACKED_BEGIN
 struct ncsi_cmd_ae_pkt {
     struct ncsi_cmd_pkt_hdr cmd; /* Command header   */
     unsigned char reserved[3]; /* Reserved         */
@@ -114,18 +124,20 @@
     __be32 mode; /* AEN working mode */
     __be32 checksum; /* Checksum         */
     unsigned char pad[18];
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* Set Link */
+SLIRP_PACKED_BEGIN
 struct ncsi_cmd_sl_pkt {
     struct ncsi_cmd_pkt_hdr cmd; /* Command header    */
     __be32 mode; /* Link working mode */
     __be32 oem_mode; /* OEM link mode     */
     __be32 checksum; /* Checksum          */
     unsigned char pad[18];
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* Set VLAN Filter */
+SLIRP_PACKED_BEGIN
 struct ncsi_cmd_svf_pkt {
     struct ncsi_cmd_pkt_hdr cmd; /* Command header    */
     __be16 reserved; /* Reserved          */
@@ -135,18 +147,20 @@
     unsigned char enable; /* Enable or disable */
     __be32 checksum; /* Checksum          */
     unsigned char pad[14];
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* Enable VLAN */
+SLIRP_PACKED_BEGIN
 struct ncsi_cmd_ev_pkt {
     struct ncsi_cmd_pkt_hdr cmd; /* Command header   */
     unsigned char reserved[3]; /* Reserved         */
     unsigned char mode; /* VLAN filter mode */
     __be32 checksum; /* Checksum         */
     unsigned char pad[22];
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* Set MAC Address */
+SLIRP_PACKED_BEGIN
 struct ncsi_cmd_sma_pkt {
     struct ncsi_cmd_pkt_hdr cmd; /* Command header          */
     unsigned char mac[6]; /* MAC address             */
@@ -154,57 +168,64 @@
     unsigned char at_e; /* Addr type and operation */
     __be32 checksum; /* Checksum                */
     unsigned char pad[18];
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* Enable Broadcast Filter */
+SLIRP_PACKED_BEGIN
 struct ncsi_cmd_ebf_pkt {
     struct ncsi_cmd_pkt_hdr cmd; /* Command header */
     __be32 mode; /* Filter mode    */
     __be32 checksum; /* Checksum       */
     unsigned char pad[22];
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* Enable Global Multicast Filter */
+SLIRP_PACKED_BEGIN
 struct ncsi_cmd_egmf_pkt {
     struct ncsi_cmd_pkt_hdr cmd; /* Command header */
     __be32 mode; /* Global MC mode */
     __be32 checksum; /* Checksum       */
     unsigned char pad[22];
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* Set NCSI Flow Control */
+SLIRP_PACKED_BEGIN
 struct ncsi_cmd_snfc_pkt {
     struct ncsi_cmd_pkt_hdr cmd; /* Command header    */
     unsigned char reserved[3]; /* Reserved          */
     unsigned char mode; /* Flow control mode */
     __be32 checksum; /* Checksum          */
     unsigned char pad[22];
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* OEM Request Command as per NCSI Specification */
+SLIRP_PACKED_BEGIN
 struct ncsi_cmd_oem_pkt {
     struct ncsi_cmd_pkt_hdr cmd; /* Command header    */
     __be32 mfr_id; /* Manufacture ID    */
     unsigned char data[]; /* OEM Payload Data  */
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* OEM Response Packet as per NCSI Specification */
+SLIRP_PACKED_BEGIN
 struct ncsi_rsp_oem_pkt {
     struct ncsi_rsp_pkt_hdr rsp; /* Command header    */
     __be32 mfr_id; /* Manufacture ID    */
     unsigned char data[]; /* Payload data      */
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* Mellanox Response Data */
+SLIRP_PACKED_BEGIN
 struct ncsi_rsp_oem_mlx_pkt {
     unsigned char cmd_rev; /* Command Revision  */
     unsigned char cmd; /* Command ID        */
     unsigned char param; /* Parameter         */
     unsigned char optional; /* Optional data     */
     unsigned char data[]; /* Data              */
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* Get Link Status */
+SLIRP_PACKED_BEGIN
 struct ncsi_rsp_gls_pkt {
     struct ncsi_rsp_pkt_hdr rsp; /* Response header   */
     __be32 status; /* Link status       */
@@ -212,9 +233,10 @@
     __be32 oem_status; /* OEM link status   */
     __be32 checksum;
     unsigned char pad[10];
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* Get Version ID */
+SLIRP_PACKED_BEGIN
 struct ncsi_rsp_gvi_pkt {
     struct ncsi_rsp_pkt_hdr rsp; /* Response header */
     __be32 ncsi_version; /* NCSI version    */
@@ -225,9 +247,10 @@
     __be16 pci_ids[4]; /* PCI IDs         */
     __be32 mf_id; /* Manufacture ID  */
     __be32 checksum;
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* Get Capabilities */
+SLIRP_PACKED_BEGIN
 struct ncsi_rsp_gc_pkt {
     struct ncsi_rsp_pkt_hdr rsp; /* Response header   */
     __be32 cap; /* Capabilities      */
@@ -243,9 +266,10 @@
     unsigned char vlan_mode; /* VLAN mode         */
     unsigned char channel_cnt; /* Channel count     */
     __be32 checksum; /* Checksum          */
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* Get Parameters */
+SLIRP_PACKED_BEGIN
 struct ncsi_rsp_gp_pkt {
     struct ncsi_rsp_pkt_hdr rsp; /* Response header       */
     unsigned char mac_cnt; /* Number of MAC addr    */
@@ -264,9 +288,10 @@
     unsigned char mac[6]; /* Supported MAC addr    */
     __be16 vlan; /* Supported VLAN tags   */
     __be32 checksum; /* Checksum              */
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* Get Controller Packet Statistics */
+SLIRP_PACKED_BEGIN
 struct ncsi_rsp_gcps_pkt {
     struct ncsi_rsp_pkt_hdr rsp; /* Response header            */
     __be32 cnt_hi; /* Counter cleared            */
@@ -311,9 +336,10 @@
     __be32 rx_runt_pkts; /* Rx error runt packets      */
     __be32 rx_jabber_pkts; /* Rx error jabber packets    */
     __be32 checksum; /* Checksum                   */
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* Get NCSI Statistics */
+SLIRP_PACKED_BEGIN
 struct ncsi_rsp_gns_pkt {
     struct ncsi_rsp_pkt_hdr rsp; /* Response header         */
     __be32 rx_cmds; /* Rx NCSI commands        */
@@ -324,9 +350,10 @@
     __be32 tx_pkts; /* Tx NCSI packets         */
     __be32 tx_aen_pkts; /* Tx AEN packets          */
     __be32 checksum; /* Checksum                */
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* Get NCSI Pass-through Statistics */
+SLIRP_PACKED_BEGIN
 struct ncsi_rsp_gnpts_pkt {
     struct ncsi_rsp_pkt_hdr rsp; /* Response header     */
     __be32 tx_pkts; /* Tx packets          */
@@ -339,45 +366,50 @@
     __be32 rx_us_err; /* Rx undersize errors */
     __be32 rx_os_err; /* Rx oversize errors  */
     __be32 checksum; /* Checksum            */
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* Get package status */
+SLIRP_PACKED_BEGIN
 struct ncsi_rsp_gps_pkt {
     struct ncsi_rsp_pkt_hdr rsp; /* Response header             */
     __be32 status; /* Hardware arbitration status */
     __be32 checksum;
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* Get package UUID */
+SLIRP_PACKED_BEGIN
 struct ncsi_rsp_gpuuid_pkt {
     struct ncsi_rsp_pkt_hdr rsp; /* Response header */
     unsigned char uuid[16]; /* UUID            */
     __be32 checksum;
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* AEN: Link State Change */
+SLIRP_PACKED_BEGIN
 struct ncsi_aen_lsc_pkt {
     struct ncsi_aen_pkt_hdr aen; /* AEN header      */
     __be32 status; /* Link status     */
     __be32 oem_status; /* OEM link status */
     __be32 checksum; /* Checksum        */
     unsigned char pad[14];
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* AEN: Configuration Required */
+SLIRP_PACKED_BEGIN
 struct ncsi_aen_cr_pkt {
     struct ncsi_aen_pkt_hdr aen; /* AEN header */
     __be32 checksum; /* Checksum   */
     unsigned char pad[22];
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* AEN: Host Network Controller Driver Status Change */
+SLIRP_PACKED_BEGIN
 struct ncsi_aen_hncdsc_pkt {
     struct ncsi_aen_pkt_hdr aen; /* AEN header */
     __be32 status; /* Status     */
     __be32 checksum; /* Checksum   */
     unsigned char pad[18];
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 /* NCSI packet revision */
 #define NCSI_PKT_REVISION 0x01
diff --git a/src/slirp.h b/src/slirp.h
index e413867..1fe7293 100644
--- a/src/slirp.h
+++ b/src/slirp.h
@@ -67,6 +67,7 @@
     unsigned short h_proto; /* packet type ID field */
 };
 
+SLIRP_PACKED_BEGIN
 struct slirp_arphdr {
     unsigned short ar_hrd; /* format of hardware address */
     unsigned short ar_pro; /* format of protocol address */
@@ -81,7 +82,7 @@
     uint32_t ar_sip; /* sender IP address       */
     uint8_t ar_tha[ETH_ALEN]; /* target hardware address */
     uint32_t ar_tip; /* target IP address       */
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 #define ARP_TABLE_SIZE 16
 
diff --git a/src/tftp.h b/src/tftp.h
index cafab03..ccbe208 100644
--- a/src/tftp.h
+++ b/src/tftp.h
@@ -20,11 +20,13 @@
 #define TFTP_FILENAME_MAX 512
 #define TFTP_BLOCKSIZE_MAX 1428
 
+SLIRP_PACKED_BEGIN
 struct tftphdr {
     struct udphdr udp;
     uint16_t tp_op;
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
+SLIRP_PACKED_BEGIN
 struct tftp_t {
     struct tftphdr hdr;
     union {
@@ -38,7 +40,7 @@
         } tp_error;
         char tp_buf[TFTP_BLOCKSIZE_MAX + 2];
     } x;
-} SLIRP_PACKED;
+} SLIRP_PACKED_END;
 
 struct tftp_session {
     Slirp *slirp;
diff --git a/src/util.h b/src/util.h
index 9f73b41..7d96770 100644
--- a/src/util.h
+++ b/src/util.h
@@ -47,10 +47,16 @@
 
 #include "libslirp.h"
 
+#ifdef __GNUC__
+#define SLIRP_PACKED_BEGIN
 #if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__))
-#define SLIRP_PACKED __attribute__((gcc_struct, packed))
+#define SLIRP_PACKED_END __attribute__((gcc_struct, packed))
 #else
-#define SLIRP_PACKED __attribute__((packed))
+#define SLIRP_PACKED_END __attribute__((packed))
+#endif
+#elif defined(_MSC_VER)
+#define SLIRP_PACKED_BEGIN __pragma(pack(push, 1))
+#define SLIRP_PACKED_END __pragma(pack(pop))
 #endif
 
 #ifndef DIV_ROUND_UP