Andrew Geissler | bffdb3e | 2020-08-21 16:13:29 -0500 | [diff] [blame] | 1 | From 702dd20f43d9ca7e0bcb917e8acfec3f1acdcb5c Mon Sep 17 00:00:00 2001 |
| 2 | From: Aaron Conole <aconole@redhat.com> |
| 3 | Date: Mon, 3 Aug 2020 15:14:50 -0400 |
| 4 | Subject: [PATCH 3/9] lldp: add packed struct definition |
| 5 | |
| 6 | Signed-off-by: Aaron Conole <aconole@redhat.com> |
| 7 | --- |
| 8 | include/lldp.h | 6 ++++++ |
| 9 | lldp/l2_packet.h | 5 ++--- |
| 10 | 2 files changed, 8 insertions(+), 3 deletions(-) |
| 11 | |
| 12 | diff --git a/include/lldp.h b/include/lldp.h |
| 13 | index fb5ee93..de6a4ad 100644 |
| 14 | --- a/include/lldp.h |
| 15 | +++ b/include/lldp.h |
| 16 | @@ -255,5 +255,11 @@ enum { |
| 17 | #define LLDP_EVB_DEFAULT_RTE 15 |
| 18 | #define LLDP_EVB_DEFAULT_MAX_RTE 31 |
| 19 | |
| 20 | +#ifndef _MSC_VER |
| 21 | +#define STRUCT_PACKED(STRUCT) STRUCT __attribute__((__packed__)) |
| 22 | +#else |
| 23 | +#define STRUCT_PACKED(STRUCT) __pragma(pack(push, 1)) STRUCT __pragma(pack(pop)) |
| 24 | +#endif |
| 25 | + |
| 26 | void somethingChangedLocal(const char *ifname, int type); |
| 27 | #endif /* _LLDP_H */ |
| 28 | diff --git a/lldp/l2_packet.h b/lldp/l2_packet.h |
| 29 | index 607b8a3..831958c 100644 |
| 30 | --- a/lldp/l2_packet.h |
| 31 | +++ b/lldp/l2_packet.h |
| 32 | @@ -58,12 +58,11 @@ |
| 33 | */ |
| 34 | struct l2_packet_data; |
| 35 | |
| 36 | - |
| 37 | -struct l2_ethhdr { |
| 38 | +STRUCT_PACKED(struct l2_ethhdr { |
| 39 | u8 h_dest[ETH_ALEN]; |
| 40 | u8 h_source[ETH_ALEN]; |
| 41 | u16 h_proto; |
| 42 | -} STRUCT_PACKED; |
| 43 | +}); |
| 44 | |
| 45 | /** |
| 46 | * l2_packet_init - Initialize l2_packet interface |
| 47 | -- |
| 48 | 2.28.0 |
| 49 | |