From: Christian Grothoff Date: Wed, 21 Dec 2011 09:40:15 +0000 (+0000) Subject: fixing 2012: network structure alignment now forced to be correct even on W32 using... X-Git-Tag: initial-import-from-subversion-38251~15550 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c4f0fe3ea5a5ca3ce1f7dfecef719da631e4c6ac;p=oweals%2Fgnunet.git fixing 2012: network structure alignment now forced to be correct even on W32 using #pragma pack from gcc 4.x --- diff --git a/src/arm/arm.h b/src/arm/arm.h index 615079b7c..4b9da6fab 100644 --- a/src/arm/arm.h +++ b/src/arm/arm.h @@ -33,6 +33,7 @@ */ #define DEBUG_ARM GNUNET_EXTRA_LOGGING +GNUNET_NETWORK_STRUCT_BEGIN /** * Reply from ARM to client. @@ -50,6 +51,6 @@ struct GNUNET_ARM_ResultMessage */ uint32_t status; }; - +GNUNET_NETWORK_STRUCT_END #endif diff --git a/src/ats-test/test_transport_ats_multiple_peers.c b/src/ats-test/test_transport_ats_multiple_peers.c index 51b813725..e9d0baf25 100644 --- a/src/ats-test/test_transport_ats_multiple_peers.c +++ b/src/ats-test/test_transport_ats_multiple_peers.c @@ -68,11 +68,14 @@ struct TEST_result uint64_t state; }; +GNUNET_NETWORK_STRUCT_BEGIN + struct TestMessage { struct GNUNET_MessageHeader header; uint32_t num; }; +GNUNET_NETWORK_STRUCT_END static int count; diff --git a/src/ats/ats.h b/src/ats/ats.h index 5b9fa8696..30ca29580 100644 --- a/src/ats/ats.h +++ b/src/ats/ats.h @@ -39,6 +39,7 @@ enum StartFlag START_FLAG_PERFORMANCE_NO_PIC = 2 }; +GNUNET_NETWORK_STRUCT_BEGIN struct ClientStartMessage { @@ -214,7 +215,6 @@ struct ReservationResultMessage struct GNUNET_TIME_RelativeNBO res_delay; }; - struct PreferenceInformation { @@ -236,6 +236,7 @@ struct ChangePreferenceMessage /* followed by 'num_preferences' * struct PreferenceInformation values */ }; +GNUNET_NETWORK_STRUCT_END diff --git a/src/chat/chat.h b/src/chat/chat.h index 9a52a2d75..5df7773a7 100644 --- a/src/chat/chat.h +++ b/src/chat/chat.h @@ -41,6 +41,8 @@ * Client-service messages */ +GNUNET_NETWORK_STRUCT_BEGIN + /** * Notification sent by service to client indicating that we've received a chat * message. After this struct, the remaining bytes are the actual text message. @@ -476,6 +478,7 @@ struct P2PConfirmationReceiptMessage GNUNET_HashCode content; }; +GNUNET_NETWORK_STRUCT_END #endif diff --git a/src/core/core.h b/src/core/core.h index b76528a8e..4942ad054 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -50,6 +50,8 @@ #define GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND 64 +GNUNET_NETWORK_STRUCT_BEGIN + /** * Message transmitted core clients to gnunet-service-core * to start the interaction. This header is followed by @@ -373,6 +375,6 @@ struct ConnectMessage struct GNUNET_PeerIdentity peer; }; - +GNUNET_NETWORK_STRUCT_END #endif /* end of core.h */ diff --git a/src/core/gnunet-service-core_kx.c b/src/core/gnunet-service-core_kx.c index 63dd6b7ee..38a5af9a4 100644 --- a/src/core/gnunet-service-core_kx.c +++ b/src/core/gnunet-service-core_kx.c @@ -62,6 +62,8 @@ #define MAX_SET_KEY_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) +GNUNET_NETWORK_STRUCT_BEGIN + /** * We're sending an (encrypted) PING to the other peer to check if he * can decrypt. The other peer should respond with a PONG with the @@ -213,7 +215,7 @@ struct EncryptedMessage struct GNUNET_TIME_AbsoluteNBO timestamp; }; - +GNUNET_NETWORK_STRUCT_END /** * Number of bytes (at the beginning) of "struct EncryptedMessage" * that are NOT encrypted. diff --git a/src/datastore/datastore.h b/src/datastore/datastore.h index 563b7486c..1126027f8 100644 --- a/src/datastore/datastore.h +++ b/src/datastore/datastore.h @@ -31,6 +31,8 @@ #include "gnunet_util_lib.h" +GNUNET_NETWORK_STRUCT_BEGIN + /** * Message from datastore service informing client about * the current size of the datastore. @@ -254,7 +256,7 @@ struct DataMessage GNUNET_HashCode key GNUNET_PACKED; }; - +GNUNET_NETWORK_STRUCT_END diff --git a/src/dht/dht.h b/src/dht/dht.h index 2a6717788..c9fdd3479 100644 --- a/src/dht/dht.h +++ b/src/dht/dht.h @@ -34,6 +34,8 @@ #define DHT_BLOOM_SIZE 128 +GNUNET_NETWORK_STRUCT_BEGIN + /** * Message which indicates the DHT should cancel outstanding * requests and discard any state. @@ -191,6 +193,6 @@ struct GNUNET_DHT_ClientPutMessage /* DATA copied to end of this message */ }; - +GNUNET_NETWORK_STRUCT_END #endif diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c index 9ebf16400..907de9950 100644 --- a/src/dht/gnunet-service-dht_neighbours.c +++ b/src/dht/gnunet-service-dht_neighbours.c @@ -90,6 +90,8 @@ #define GET_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 2) +GNUNET_NETWORK_STRUCT_BEGIN + /** * P2P PUT message */ @@ -246,7 +248,7 @@ struct PeerGetMessage /* result bloomfilter */ }; - +GNUNET_NETWORK_STRUCT_END /** * Linked list of messages to send to a particular other peer. diff --git a/src/dv/dv.h b/src/dv/dv.h index 5690cf6cc..0d42505bc 100644 --- a/src/dv/dv.h +++ b/src/dv/dv.h @@ -44,6 +44,8 @@ typedef void (*GNUNET_DV_MessageReceivedHandler) (void *cls, char *sender_address, size_t sender_address_len); +GNUNET_NETWORK_STRUCT_BEGIN + /** * DV Message, contains a message that was received * via DV for this peer! Internal. @@ -255,7 +257,7 @@ typedef struct uint32_t peer_id GNUNET_PACKED; } p2p_dv_MESSAGE_Disconnect; - +GNUNET_NETWORK_STRUCT_END struct GNUNET_DV_Handle * GNUNET_DV_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, diff --git a/src/dv/test_transport_api_dv.c b/src/dv/test_transport_api_dv.c index 942ee07c0..2e4962964 100644 --- a/src/dv/test_transport_api_dv.c +++ b/src/dv/test_transport_api_dv.c @@ -108,6 +108,8 @@ struct GNUNET_CONTAINER_MultiHashMap *peer_daemon_hash; #define MTYPE 12345 +GNUNET_NETWORK_STRUCT_BEGIN + struct GNUNET_TestMessage { /** @@ -120,6 +122,7 @@ struct GNUNET_TestMessage */ uint32_t uid; }; +GNUNET_NETWORK_STRUCT_END struct PeerContext { diff --git a/src/fragmentation/fragmentation.h b/src/fragmentation/fragmentation.h index 3469dd27e..2f3ea67bb 100644 --- a/src/fragmentation/fragmentation.h +++ b/src/fragmentation/fragmentation.h @@ -27,6 +27,8 @@ #include "platform.h" #include "gnunet_fragmentation_lib.h" +GNUNET_NETWORK_STRUCT_BEGIN + /** * Header for a message fragment. Followed by the * original message. @@ -82,6 +84,6 @@ struct FragmentAcknowledgement uint64_t bits; }; - +GNUNET_NETWORK_STRUCT_END #endif diff --git a/src/fs/fs.h b/src/fs/fs.h index 90d32f4a7..cd39522bc 100644 --- a/src/fs/fs.h +++ b/src/fs/fs.h @@ -64,6 +64,8 @@ struct ContentHashKey }; +GNUNET_NETWORK_STRUCT_BEGIN + /** * Message sent from a GNUnet (fs) publishing activity to the * gnunet-fs-service to initiate indexing of a file. The service is @@ -288,7 +290,7 @@ struct PutMessage /* this is followed by the actual encrypted content */ }; - +GNUNET_NETWORK_STRUCT_END #endif diff --git a/src/fs/gnunet-service-fs.h b/src/fs/gnunet-service-fs.h index 5a275c5ff..c669dcc7a 100644 --- a/src/fs/gnunet-service-fs.h +++ b/src/fs/gnunet-service-fs.h @@ -82,6 +82,8 @@ #define GET_MESSAGE_BIT_TRANSMIT_TO 4 +GNUNET_NETWORK_STRUCT_BEGIN + /** * Message sent between peers asking for FS-content. */ @@ -161,7 +163,7 @@ struct MigrationStopMessage struct GNUNET_TIME_RelativeNBO duration; }; - +GNUNET_NETWORK_STRUCT_END /** * A connected peer. diff --git a/src/hello/hello.c b/src/hello/hello.c index f7d34233c..7aa974008 100644 --- a/src/hello/hello.c +++ b/src/hello/hello.c @@ -28,6 +28,8 @@ #include "gnunet_protocols.h" #include "gnunet_util_lib.h" +GNUNET_NETWORK_STRUCT_BEGIN + /** * A HELLO message is used to exchange information about * transports with other peers. This struct is always @@ -59,7 +61,7 @@ struct GNUNET_HELLO_Message struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded publicKey; }; - +GNUNET_NETWORK_STRUCT_END /** * Copy the given address information into diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c index b10f124d4..0eedb56b1 100644 --- a/src/hostlist/gnunet-daemon-hostlist.c +++ b/src/hostlist/gnunet-daemon-hostlist.c @@ -99,6 +99,8 @@ static GNUNET_CORE_ConnectEventHandler client_ch; */ static GNUNET_CORE_DisconnectEventHandler client_dh; +GNUNET_NETWORK_STRUCT_BEGIN + /** * A HOSTLIST_ADV message is used to exchange information about * hostlist advertisements. This struct is always @@ -123,7 +125,7 @@ struct GNUNET_HOSTLIST_ADV_Message */ uint32_t reserved GNUNET_PACKED; }; - +GNUNET_NETWORK_STRUCT_END static struct GNUNET_PeerIdentity me; diff --git a/src/include/block_dns.h b/src/include/block_dns.h index 1c01754de..21dcc7acb 100644 --- a/src/include/block_dns.h +++ b/src/include/block_dns.h @@ -13,6 +13,7 @@ enum GNUNET_DNS_ServiceTypes GNUNET_DNS_SERVICE_TYPE_TCP = 2 }; +GNUNET_NETWORK_STRUCT_BEGIN /** * This is the structure describing an dns-record such as www.gnunet. @@ -57,5 +58,6 @@ struct GNUNET_DNS_Record */ uint32_t service_type GNUNET_PACKED; }; +GNUNET_NETWORK_STRUCT_END #endif diff --git a/src/include/block_fs.h b/src/include/block_fs.h index 9dc22e57f..aae741e60 100644 --- a/src/include/block_fs.h +++ b/src/include/block_fs.h @@ -139,6 +139,8 @@ struct NBlock }; +GNUNET_NETWORK_STRUCT_BEGIN + /** * @brief index block (indexing a DBlock that * can be obtained directly from reading @@ -160,6 +162,6 @@ struct OnDemandBlock uint64_t offset GNUNET_PACKED; }; - +GNUNET_NETWORK_STRUCT_END #endif diff --git a/src/include/gnunet_ats_service.h b/src/include/gnunet_ats_service.h index 898857af8..88cab0d9b 100644 --- a/src/include/gnunet_ats_service.h +++ b/src/include/gnunet_ats_service.h @@ -403,6 +403,8 @@ enum GNUNET_ATS_Property }; +GNUNET_NETWORK_STRUCT_BEGIN + /** * struct used to communicate the transport's properties like cost and * quality of service as well as high-level constraints on resource @@ -433,7 +435,7 @@ struct GNUNET_ATS_Information */ uint32_t value GNUNET_PACKED; }; - +GNUNET_NETWORK_STRUCT_END /* ******************************** Scheduling API ***************************** */ diff --git a/src/include/gnunet_bandwidth_lib.h b/src/include/gnunet_bandwidth_lib.h index 75f71b32c..fabe47bea 100644 --- a/src/include/gnunet_bandwidth_lib.h +++ b/src/include/gnunet_bandwidth_lib.h @@ -38,6 +38,8 @@ extern "C" #include "gnunet_common.h" #include "gnunet_time_lib.h" +GNUNET_NETWORK_STRUCT_BEGIN + /** * 32-bit bandwidth used for network exchange by GNUnet, in bytes per second. */ @@ -48,7 +50,7 @@ struct GNUNET_BANDWIDTH_Value32NBO */ uint32_t value__ GNUNET_PACKED; }; - +GNUNET_NETWORK_STRUCT_END /** * Struct to track available bandwidth. Combines a time stamp with a diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index 665697a97..134543c46 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h @@ -116,9 +116,37 @@ */ #define GNUNET_UNUSED __attribute__((unused)) +#if __GNUC__ > 3 +/** + * gcc 4.x-ism to pack structures even on W32 (to be used before structs) + */ +#define GNUNET_NETWORK_STRUCT_BEGIN \ + _Pragma("pack(push)") \ + _Pragma("pack(1)") + +/** + * gcc 4.x-ism to pack structures even on W32 (to be used after structs) + */ +#define GNUNET_NETWORK_STRUCT_END _Pragma("pack(pop)") +#else +#ifdef MINGW +#error gcc 4.x or higher required on W32 systems +#endif +/** + * Good luck, GNUNET_PACKED should suffice, but this won't work on W32 + */ +#define GNUNET_NETWORK_STRUCT_BEGIN + +/** + * Good luck, GNUNET_PACKED should suffice, but this won't work on W32 + */ +#define GNUNET_NETWORK_STRUCT_END +#endif /* ************************ super-general types *********************** */ +GNUNET_NETWORK_STRUCT_BEGIN + /** * Header for all communications. */ @@ -137,7 +165,7 @@ struct GNUNET_MessageHeader uint16_t type GNUNET_PACKED; }; - +GNUNET_NETWORK_STRUCT_END /** * @brief 512-bit hashcode @@ -149,6 +177,8 @@ typedef struct GNUNET_HashCode; +GNUNET_NETWORK_STRUCT_BEGIN + /** * The identity of the host (basically the SHA-512 hashcode of * it's public key). @@ -157,7 +187,7 @@ struct GNUNET_PeerIdentity { GNUNET_HashCode hashPubKey GNUNET_PACKED; }; - +GNUNET_NETWORK_STRUCT_END /** * Function called with a filename. diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index 53137c179..76806d432 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h @@ -121,6 +121,8 @@ struct GNUNET_CRYPTO_RsaSignature }; +GNUNET_NETWORK_STRUCT_BEGIN + /** * @brief header of what an RSA signature signs * this must be followed by "size - 8" bytes of @@ -197,7 +199,7 @@ struct GNUNET_CRYPTO_AesSessionKey */ uint32_t crc32 GNUNET_PACKED; }; - +GNUNET_NETWORK_STRUCT_END /** * @brief IV for sym cipher diff --git a/src/include/gnunet_time_lib.h b/src/include/gnunet_time_lib.h index f8afdae41..7090c33a1 100644 --- a/src/include/gnunet_time_lib.h +++ b/src/include/gnunet_time_lib.h @@ -61,6 +61,7 @@ struct GNUNET_TIME_Relative uint64_t rel_value; }; +GNUNET_NETWORK_STRUCT_BEGIN /** * Time for relative time used by GNUnet, in milliseconds and in network byte order. @@ -84,7 +85,7 @@ struct GNUNET_TIME_AbsoluteNBO */ uint64_t abs_value__ GNUNET_PACKED; }; - +GNUNET_NETWORK_STRUCT_END /** * Relative time zero. diff --git a/src/mesh/mesh.h b/src/mesh/mesh.h index fcddb2eb9..d8fc404e1 100644 --- a/src/mesh/mesh.h +++ b/src/mesh/mesh.h @@ -85,6 +85,8 @@ /************************** MESSAGES ******************************/ /******************************************************************************/ +GNUNET_NETWORK_STRUCT_BEGIN + /** * Message for a client to register to the service */ @@ -209,7 +211,7 @@ struct GNUNET_MESH_ConnectPeerByType */ GNUNET_MESH_ApplicationType type GNUNET_PACKED; }; - +GNUNET_NETWORK_STRUCT_END /******************************************************************************/ /************************ ENUMERATIONS ****************************/ diff --git a/src/mesh/mesh_protocol.h b/src/mesh/mesh_protocol.h index b6c7f1b24..885f1f344 100644 --- a/src/mesh/mesh_protocol.h +++ b/src/mesh/mesh_protocol.h @@ -39,6 +39,8 @@ extern "C" /******************** MESH NETWORK MESSAGES **************************/ /******************************************************************************/ +GNUNET_NETWORK_STRUCT_BEGIN + /** * Message for mesh path management */ @@ -276,6 +278,7 @@ struct GNUNET_MESH_SpeedNotify uint32_t speed_min; }; +GNUNET_NETWORK_STRUCT_END #if 0 /* keep Emacsens' auto-indent happy */ { diff --git a/src/nat/nat.h b/src/nat/nat.h index a32fe0908..efab3a7a7 100644 --- a/src/nat/nat.h +++ b/src/nat/nat.h @@ -30,6 +30,8 @@ #define DEBUG_NAT GNUNET_EXTRA_LOGGING +GNUNET_NETWORK_STRUCT_BEGIN + /** * Request to test NAT traversal. */ @@ -61,5 +63,6 @@ struct GNUNET_NAT_TestMessage int32_t is_tcp; }; +GNUNET_NETWORK_STRUCT_END #endif diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index 7c3f14273..d37ecd941 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c @@ -128,6 +128,8 @@ struct NSEPeerEntry }; +GNUNET_NETWORK_STRUCT_BEGIN + /** * Network size estimate reply; sent when "this" * peer's timer has run out before receiving a @@ -178,7 +180,7 @@ struct GNUNET_NSE_FloodMessage */ struct GNUNET_CRYPTO_RsaSignature signature; }; - +GNUNET_NETWORK_STRUCT_END /** * Handle to our current configuration. diff --git a/src/nse/nse.h b/src/nse/nse.h index 91b629657..2123e3996 100644 --- a/src/nse/nse.h +++ b/src/nse/nse.h @@ -35,6 +35,8 @@ */ #define DEBUG_NSE GNUNET_EXTRA_LOGGING +GNUNET_NETWORK_STRUCT_BEGIN + /** * Network size estimate sent from the service * to clients. Contains the current size estimate @@ -71,6 +73,6 @@ struct GNUNET_NSE_ClientMessage */ double std_deviation GNUNET_PACKED; }; - +GNUNET_NETWORK_STRUCT_END #endif diff --git a/src/peerinfo/peerinfo.h b/src/peerinfo/peerinfo.h index 992dde782..bf5677477 100644 --- a/src/peerinfo/peerinfo.h +++ b/src/peerinfo/peerinfo.h @@ -29,6 +29,8 @@ #define DEBUG_PEERINFO GNUNET_EXTRA_LOGGING +GNUNET_NETWORK_STRUCT_BEGIN + /** * Message requesting a listing of all known peers, * possibly restricted to the specified peer identity. @@ -81,6 +83,6 @@ struct InfoMessage struct GNUNET_PeerIdentity peer; }; - +GNUNET_NETWORK_STRUCT_END /* end of peerinfo.h */ diff --git a/src/statistics/statistics.h b/src/statistics/statistics.h index a65dff147..3fcac275a 100644 --- a/src/statistics/statistics.h +++ b/src/statistics/statistics.h @@ -29,6 +29,8 @@ #define DEBUG_STATISTICS GNUNET_EXTRA_LOGGING +GNUNET_NETWORK_STRUCT_BEGIN + /** * Statistics message. Contains how long the system is up * and one value. @@ -128,6 +130,6 @@ struct GNUNET_STATISTICS_WatchValueMessage uint64_t value GNUNET_PACKED; }; - +GNUNET_NETWORK_STRUCT_END #endif diff --git a/src/testing/test_testing_large_topology.c b/src/testing/test_testing_large_topology.c index 08b1df5b9..e966ca137 100644 --- a/src/testing/test_testing_large_topology.c +++ b/src/testing/test_testing_large_topology.c @@ -107,6 +107,8 @@ static char *test_directory; #define MTYPE 12345 +GNUNET_NETWORK_STRUCT_BEGIN + struct GNUNET_TestMessage { /** @@ -119,6 +121,7 @@ struct GNUNET_TestMessage */ uint32_t uid; }; +GNUNET_NETWORK_STRUCT_END struct TestMessageContext { diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c index f60ac3a1a..7d0c0da5f 100644 --- a/src/testing/test_testing_topology.c +++ b/src/testing/test_testing_topology.c @@ -115,6 +115,8 @@ static char *test_directory; #define MTYPE 12345 +GNUNET_NETWORK_STRUCT_BEGIN + struct GNUNET_TestMessage { /** @@ -127,6 +129,7 @@ struct GNUNET_TestMessage */ uint32_t uid; }; +GNUNET_NETWORK_STRUCT_END struct TestMessageContext { diff --git a/src/testing/test_testing_topology_blacklist.c b/src/testing/test_testing_topology_blacklist.c index d45d1bbb4..095c5b2a2 100644 --- a/src/testing/test_testing_topology_blacklist.c +++ b/src/testing/test_testing_topology_blacklist.c @@ -85,6 +85,8 @@ static char *test_directory; #define MTYPE 12345 +GNUNET_NETWORK_STRUCT_BEGIN + struct GNUNET_TestMessage { /** @@ -97,7 +99,7 @@ struct GNUNET_TestMessage */ uint32_t uid; }; - +GNUNET_NETWORK_STRUCT_END /** * Check whether peers successfully shut down. diff --git a/src/testing/test_testing_topology_churn.c b/src/testing/test_testing_topology_churn.c index 5a348642c..36120893b 100644 --- a/src/testing/test_testing_topology_churn.c +++ b/src/testing/test_testing_topology_churn.c @@ -59,6 +59,8 @@ static char *test_directory; #define MTYPE 12345 +GNUNET_NETWORK_STRUCT_BEGIN + struct GNUNET_TestMessage { /** @@ -71,6 +73,7 @@ struct GNUNET_TestMessage */ uint32_t uid; }; +GNUNET_NETWORK_STRUCT_END /** * Check whether peers successfully shut down. diff --git a/src/transport/gnunet-helper-transport-wlan.c b/src/transport/gnunet-helper-transport-wlan.c index fcdd9d520..72314beb2 100644 --- a/src/transport/gnunet-helper-transport-wlan.c +++ b/src/transport/gnunet-helper-transport-wlan.c @@ -328,6 +328,7 @@ struct SendBuffer char buf[MAXLINE * 2]; }; +GNUNET_NETWORK_STRUCT_BEGIN /** * generic definitions for IEEE 802.11 frames @@ -343,7 +344,7 @@ struct ieee80211_frame /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */ /* see below */ } GNUNET_PACKED; - +GNUNET_NETWORK_STRUCT_END /** * struct for storing the information of the hardware diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index aaeefe8d4..5c749d717 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c @@ -69,6 +69,8 @@ */ struct NeighbourMapEntry; +GNUNET_NETWORK_STRUCT_BEGIN + /** * Message a peer sends to another to indicate its * preference for communicating via a particular @@ -133,7 +135,7 @@ struct SessionDisconnectMessage struct GNUNET_CRYPTO_RsaSignature signature; }; - +GNUNET_NETWORK_STRUCT_END /** * For each neighbour we keep a list of messages diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index 559589576..17fc5edc6 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c @@ -92,6 +92,8 @@ #define PONG_PRIORITY 4 +GNUNET_NETWORK_STRUCT_BEGIN + /** * Message used to ask a peer to validate receipt (to check an address * from a HELLO). Followed by the address we are trying to validate, @@ -166,7 +168,7 @@ struct TransportPongMessage uint32_t addrlen GNUNET_PACKED; }; - +GNUNET_NETWORK_STRUCT_END /** * Information about an address under validation diff --git a/src/transport/gnunet-transport-wlan-sender.c b/src/transport/gnunet-transport-wlan-sender.c index 2096afaee..9f06b63b4 100644 --- a/src/transport/gnunet-transport-wlan-sender.c +++ b/src/transport/gnunet-transport-wlan-sender.c @@ -46,6 +46,7 @@ #define IEEE80211_FC0_TYPE_CTL 0x04 #define IEEE80211_FC0_TYPE_DATA 0x08 +GNUNET_NETWORK_STRUCT_BEGIN /* * generic definitions for IEEE 802.11 frames @@ -60,7 +61,7 @@ struct ieee80211_frame u_int8_t i_seq[2]; u_int8_t llc[4]; } GNUNET_PACKED; - +GNUNET_NETWORK_STRUCT_END /** * function to fill the radiotap header diff --git a/src/transport/plugin_transport_http.h b/src/transport/plugin_transport_http.h index 84a92c284..9e16e93c8 100644 --- a/src/transport/plugin_transport_http.h +++ b/src/transport/plugin_transport_http.h @@ -260,6 +260,8 @@ struct Plugin }; +GNUNET_NETWORK_STRUCT_BEGIN + /** * IPv4 addresses */ @@ -291,7 +293,7 @@ struct IPv6HttpAddress */ uint16_t u6_port GNUNET_PACKED; }; - +GNUNET_NETWORK_STRUCT_END /** * Session handle for connections. diff --git a/src/transport/plugin_transport_smtp.c b/src/transport/plugin_transport_smtp.c index fa11a9b6d..b589e1177 100644 --- a/src/transport/plugin_transport_smtp.c +++ b/src/transport/plugin_transport_smtp.c @@ -72,6 +72,8 @@ typedef struct } EmailAddress; +GNUNET_NETWORK_STRUCT_BEGIN + /** * Encapsulation of a GNUnet message in the SMTP mail body (before * base64 encoding). @@ -86,6 +88,7 @@ typedef struct GNUNET_PeerIdentity sender; } SMTPMessage; +GNUNET_NETWORK_STRUCT_END /* *********** globals ************* */ diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 1024b8008..e79440e5e 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -43,6 +43,8 @@ #define DEBUG_TCP_NAT GNUNET_EXTRA_LOGGING +GNUNET_NETWORK_STRUCT_BEGIN + /** * Initial handshake message for a session. */ @@ -78,7 +80,7 @@ struct TCP_NAT_ProbeMessage struct GNUNET_PeerIdentity clientIdentity; }; - +GNUNET_NETWORK_STRUCT_END /** * Context for sending a NAT probe via TCP. @@ -118,6 +120,8 @@ struct TCPProbeContext }; +GNUNET_NETWORK_STRUCT_BEGIN + /** * Network format for IPv4 addresses. */ @@ -152,7 +156,7 @@ struct IPv6TcpAddress uint16_t t6_port GNUNET_PACKED; }; - +GNUNET_NETWORK_STRUCT_END /** * Encapsulation of all of the state of the plugin. diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 04ec108aa..165455856 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c @@ -70,6 +70,8 @@ #define UDP_MAX_SENDER_ADDRESSES_WITH_DEFRAG 128 +GNUNET_NETWORK_STRUCT_BEGIN + /** * UDP Message-Packet header (after defragmentation). */ @@ -92,7 +94,6 @@ struct UDPMessage }; - /** * UDP ACK Message-Packet header (after defragmentation). */ @@ -162,7 +163,7 @@ struct IPv6UdpAddress */ uint16_t u6_port GNUNET_PACKED; }; - +GNUNET_NETWORK_STRUCT_END /* Forward definition */ struct Plugin; diff --git a/src/transport/plugin_transport_udp_new.c b/src/transport/plugin_transport_udp_new.c index 7eb4cbe87..e6b7fe18f 100644 --- a/src/transport/plugin_transport_udp_new.c +++ b/src/transport/plugin_transport_udp_new.c @@ -70,6 +70,8 @@ #define UDP_MAX_SENDER_ADDRESSES_WITH_DEFRAG 128 +GNUNET_NETWORK_STRUCT_BEGIN + /** * UDP Message-Packet header (after defragmentation). */ @@ -148,7 +150,7 @@ struct IPv6UdpAddress */ uint16_t u6_port GNUNET_PACKED; }; - +GNUNET_NETWORK_STRUCT_END /* Forward definition */ struct Plugin; diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c index 5f6c967f2..aebfeb883 100644 --- a/src/transport/plugin_transport_unix.c +++ b/src/transport/plugin_transport_unix.c @@ -64,6 +64,8 @@ */ #define UNIX_NAT_DEFAULT_PORT 22086 +GNUNET_NETWORK_STRUCT_BEGIN + /** * UNIX Message-Packet header. */ @@ -131,6 +133,7 @@ struct IPv6UdpAddress */ uint16_t u6_port GNUNET_PACKED; }; +GNUNET_NETWORK_STRUCT_END /* Forward definition */ struct Plugin; diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index 4c4e9f1ab..d121ec9be 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c @@ -120,6 +120,8 @@ #define IEEE80211_FC0_TYPE_CTL 0x04 #define IEEE80211_FC0_TYPE_DATA 0x08 +GNUNET_NETWORK_STRUCT_BEGIN + /* * generic definitions for IEEE 802.11 frames */ @@ -133,6 +135,7 @@ struct ieee80211_frame u_int8_t i_seq[2]; u_int8_t llc[4]; } GNUNET_PACKED; +GNUNET_NETWORK_STRUCT_END /** * Encapsulation of all of the state of the plugin. @@ -361,6 +364,8 @@ struct Plugin_Session_pair }; +GNUNET_NETWORK_STRUCT_BEGIN + /** * Header for messages which need fragmentation */ @@ -388,7 +393,7 @@ struct WlanHeader // followed by payload }; - +GNUNET_NETWORK_STRUCT_END /** * Information kept for each message that is yet to diff --git a/src/transport/plugin_transport_wlan.h b/src/transport/plugin_transport_wlan.h index 35b23fd44..b0b8b966a 100644 --- a/src/transport/plugin_transport_wlan.h +++ b/src/transport/plugin_transport_wlan.h @@ -43,6 +43,8 @@ struct MacAddress }; +GNUNET_NETWORK_STRUCT_BEGIN + /** * Format of a WLAN Control Message. */ @@ -58,7 +60,7 @@ struct GNUNET_TRANSPORT_WLAN_HelperControlMessage */ struct MacAddress mac; }; - +GNUNET_NETWORK_STRUCT_END /** * GNUnet bssid diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c index 1742dd0d3..5d9cfff19 100644 --- a/src/transport/test_quota_compliance.c +++ b/src/transport/test_quota_compliance.c @@ -104,11 +104,14 @@ static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; #define MTYPE 12345 +GNUNET_NETWORK_STRUCT_BEGIN + struct TestMessage { struct GNUNET_MessageHeader header; uint32_t num; }; +GNUNET_NETWORK_STRUCT_END static int msg_scheduled; static int msg_sent; diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c index 15fc4f6b9..ac360a3ea 100644 --- a/src/transport/test_transport_api_reliability.c +++ b/src/transport/test_transport_api_reliability.c @@ -97,11 +97,14 @@ static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; #define MTYPE 12345 +GNUNET_NETWORK_STRUCT_BEGIN + struct TestMessage { struct GNUNET_MessageHeader header; uint32_t num; }; +GNUNET_NETWORK_STRUCT_END static int msg_scheduled; static int msg_sent; diff --git a/src/transport/test_transport_api_unreliability.c b/src/transport/test_transport_api_unreliability.c index e52b20f7c..2120f7044 100644 --- a/src/transport/test_transport_api_unreliability.c +++ b/src/transport/test_transport_api_unreliability.c @@ -93,11 +93,14 @@ struct GNUNET_TRANSPORT_TESTING_handle *tth; #define MTYPE 12345 +GNUNET_NETWORK_STRUCT_BEGIN + struct TestMessage { struct GNUNET_MessageHeader header; uint32_t num; }; +GNUNET_NETWORK_STRUCT_END static char *test_name; diff --git a/src/transport/test_transport_api_unreliability_constant.c b/src/transport/test_transport_api_unreliability_constant.c index 414bca7c8..3770ebfdb 100644 --- a/src/transport/test_transport_api_unreliability_constant.c +++ b/src/transport/test_transport_api_unreliability_constant.c @@ -97,11 +97,14 @@ static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; #define MSG_SIZE 10000 +GNUNET_NETWORK_STRUCT_BEGIN + struct TestMessage { struct GNUNET_MessageHeader header; uint32_t num; }; +GNUNET_NETWORK_STRUCT_END static char *test_name; diff --git a/src/transport/transport.h b/src/transport/transport.h index d2792b92d..ff6818813 100644 --- a/src/transport/transport.h +++ b/src/transport/transport.h @@ -61,6 +61,8 @@ */ #define CONNECTED_LATENCY_EVALUATION_MAX_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1) +GNUNET_NETWORK_STRUCT_BEGIN + /** * Message from the transport service to the library * asking to check if both processes agree about this @@ -430,7 +432,7 @@ struct BlacklistMessage struct GNUNET_PeerIdentity peer; }; - +GNUNET_NETWORK_STRUCT_END /* end of transport.h */ #endif diff --git a/src/util/crypto_ksk.c b/src/util/crypto_ksk.c index 60639a709..0f5a29507 100644 --- a/src/util/crypto_ksk.c +++ b/src/util/crypto_ksk.c @@ -463,6 +463,7 @@ generate_kblock_key (KBlock_secret_key *sk, unsigned int nbits, gcry_mpi_release (g); } +GNUNET_NETWORK_STRUCT_BEGIN /** * Internal representation of the private key. @@ -482,7 +483,7 @@ struct KskRsaPrivateKeyBinaryEncoded uint16_t sizedmq1 GNUNET_PACKED; /* in big-endian! */ /* followed by the actual values */ }; - +GNUNET_NETWORK_STRUCT_END /** * Deterministically (!) create a hostkey using only the diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c index d29566ac8..418fe833b 100644 --- a/src/util/crypto_rsa.c +++ b/src/util/crypto_rsa.c @@ -53,6 +53,8 @@ struct GNUNET_CRYPTO_RsaPrivateKey }; +GNUNET_NETWORK_STRUCT_BEGIN + /** * GNUnet mandates a certain format for the encoding * of private RSA key information that is provided @@ -75,7 +77,7 @@ struct RsaPrivateKeyBinaryEncoded uint16_t sizedmq1 GNUNET_PACKED; /* in big-endian! */ /* followed by the actual values */ }; - +GNUNET_NETWORK_STRUCT_END #define HOSTKEY_LEN 2048 diff --git a/src/util/resolver.h b/src/util/resolver.h index 57cb68650..eca753a55 100644 --- a/src/util/resolver.h +++ b/src/util/resolver.h @@ -29,6 +29,8 @@ #define DEBUG_RESOLVER GNUNET_EXTRA_LOGGING +GNUNET_NETWORK_STRUCT_BEGIN + /** * Request for the resolver. Followed by either * the "struct sockaddr" or the 0-terminated hostname. @@ -59,5 +61,6 @@ struct GNUNET_RESOLVER_GetMessage int32_t domain GNUNET_PACKED; }; +GNUNET_NETWORK_STRUCT_END #endif diff --git a/src/vpn/gnunet-service-dns-p.h b/src/vpn/gnunet-service-dns-p.h index 0519b1f84..632145ae2 100644 --- a/src/vpn/gnunet-service-dns-p.h +++ b/src/vpn/gnunet-service-dns-p.h @@ -3,6 +3,8 @@ #include "gnunet_common.h" +GNUNET_NETWORK_STRUCT_BEGIN + struct query_packet { struct GNUNET_MessageHeader hdr; @@ -109,5 +111,6 @@ struct answer_packet_list struct GNUNET_SERVER_Client *client; struct answer_packet pkt; }; +GNUNET_NETWORK_STRUCT_END #endif diff --git a/src/vpn/gnunet-service-dns.c b/src/vpn/gnunet-service-dns.c index 6ef621c26..12d0a93cf 100644 --- a/src/vpn/gnunet-service-dns.c +++ b/src/vpn/gnunet-service-dns.c @@ -287,12 +287,15 @@ send_answer (void *cls, size_t size, void *buf) return len; } +GNUNET_NETWORK_STRUCT_BEGIN + struct tunnel_cls { struct GNUNET_MESH_Tunnel *tunnel GNUNET_PACKED; struct GNUNET_MessageHeader hdr; struct dns_pkt dns; }; +GNUNET_NETWORK_STRUCT_END struct tunnel_cls *remote_pending[UINT16_MAX]; diff --git a/src/vpn/gnunet-vpn-packet.h b/src/vpn/gnunet-vpn-packet.h index e2082f9a1..9cbbf1bb2 100644 --- a/src/vpn/gnunet-vpn-packet.h +++ b/src/vpn/gnunet-vpn-packet.h @@ -4,6 +4,8 @@ #include "platform.h" #include "gnunet_common.h" +GNUNET_NETWORK_STRUCT_BEGIN + // Headers struct pkt_tun { @@ -100,6 +102,7 @@ struct dns_static uint16_t nscount GNUNET_PACKED; // number of authority-records uint16_t arcount GNUNET_PACKED; // number of additional records }; +GNUNET_NETWORK_STRUCT_END struct dns_pkt { @@ -156,6 +159,8 @@ struct udp_dns struct dns_pkt data; }; +GNUNET_NETWORK_STRUCT_BEGIN + // Complete Packets struct tun_pkt { @@ -246,5 +251,6 @@ struct ip_icmp struct ip_hdr ip_hdr; struct icmp_hdr icmp_hdr; }; +GNUNET_NETWORK_STRUCT_END #endif