From 2059a5f629122270d7d9362e66d0f44d86780448 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 14 May 2022 16:16:00 +0200 Subject: Separate out SLIRP_PACKED to SLIRP_PACKED_BEGIN/END Since msvc provides the support through push/pop pragmas. --- src/ip6_icmp.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/ip6_icmp.h') 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 @@ G_STATIC_ASSERT(sizeof(struct icmp6) == 40); /* * 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 @@ struct ndpopt { 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 */ -- cgit v1.1 From 1d71fdaf6b556546c6867bf7c6cdb0618a782e37 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 14 May 2022 16:36:28 +0200 Subject: Fix bitfields order for MSVC It uses a saner strictly "from low to high bit" rule. --- src/ip6_icmp.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/ip6_icmp.h') diff --git a/src/ip6_icmp.h b/src/ip6_icmp.h index 76517b3..9ae6266 100644 --- a/src/ip6_icmp.h +++ b/src/ip6_icmp.h @@ -35,7 +35,7 @@ struct ndp_rs { /* Router Solicitation Message */ struct ndp_ra { /* Router Advertisement Message */ uint8_t chl; /* Cur Hop Limit */ -#if G_BYTE_ORDER == G_BIG_ENDIAN +#if (G_BYTE_ORDER == G_BIG_ENDIAN) && !defined(_MSC_VER) uint8_t M : 1, O : 1, reserved : 6; #else uint8_t reserved : 6, O : 1, M : 1; @@ -55,14 +55,16 @@ struct ndp_ns { /* Neighbor Solicitation Message */ G_STATIC_ASSERT(sizeof(struct ndp_ns) == 20); struct ndp_na { /* Neighbor Advertisement Message */ -#if G_BYTE_ORDER == G_BIG_ENDIAN - uint32_t R : 1, /* Router Flag */ +#if (G_BYTE_ORDER == G_BIG_ENDIAN) && !defined(_MSC_VER) + uint8_t R : 1, /* Router Flag */ S : 1, /* Solicited Flag */ O : 1, /* Override Flag */ - reserved_hi : 5, reserved_lo : 24; + reserved_1 : 5 #else - uint32_t reserved_hi : 5, O : 1, S : 1, R : 1, reserved_lo : 24; + uint8_t reserved_1 : 5, O : 1, S : 1, R : 1; #endif + uint8_t reserved_2; + uint16_t reserved_3; struct in6_addr target; /* Target Address */ }; @@ -125,7 +127,7 @@ struct ndpopt { SLIRP_PACKED_BEGIN struct prefixinfo { /* Prefix Information */ uint8_t prefix_length; -#if G_BYTE_ORDER == G_BIG_ENDIAN +#if (G_BYTE_ORDER == G_BIG_ENDIAN) && !defined(_MSC_VER) uint8_t L : 1, A : 1, reserved1 : 6; #else uint8_t reserved1 : 6, A : 1, L : 1; -- cgit v1.1