Explorar o código

convert some packed structs to use the macros from misc/packed.h

ambrop7 %!s(int64=13) %!d(string=hai) anos
pai
achega
d8d1abf532
Modificáronse 3 ficheiros con 33 adicións e 9 borrados
  1. 5 1
      misc/arp_proto.h
  2. 23 7
      misc/dhcp_proto.h
  3. 5 1
      protocol/requestproto.h

+ 5 - 1
misc/arp_proto.h

@@ -36,11 +36,14 @@
 
 #include <stdint.h>
 
+#include <misc/packed.h>
+
 #define ARP_HARDWARE_TYPE_ETHERNET 1
 
 #define ARP_OPCODE_REQUEST 1
 #define ARP_OPCODE_REPLY 2
 
+B_START_PACKED
 struct arp_packet {
     uint16_t hardware_type;
     uint16_t protocol_type;
@@ -51,6 +54,7 @@ struct arp_packet {
     uint32_t sender_ip;
     uint8_t target_mac[6];
     uint32_t target_ip;
-} __attribute__((packed));
+} B_PACKED;
+B_END_PACKED
 
 #endif

+ 23 - 7
misc/dhcp_proto.h

@@ -36,6 +36,8 @@
 
 #include <stdint.h>
 
+#include <misc/packed.h>
+
 #define DHCP_OP_BOOTREQUEST 1
 #define DHCP_OP_BOOTREPLY 2
 
@@ -69,6 +71,7 @@
 #define DHCP_MESSAGE_TYPE_NAK 6
 #define DHCP_MESSAGE_TYPE_RELEASE 7
 
+B_START_PACKED
 struct dhcp_header {
     uint8_t op;
     uint8_t htype;
@@ -85,31 +88,44 @@ struct dhcp_header {
     uint8_t sname[64];
     uint8_t file[128];
     uint32_t magic;
-} __attribute__((packed));
+} B_PACKED;
+B_END_PACKED
 
+B_START_PACKED
 struct dhcp_option_header {
     uint8_t type;
     uint8_t len;
-} __attribute__((packed));
+} B_PACKED;
+B_END_PACKED
 
+B_START_PACKED
 struct dhcp_option_dhcp_message_type {
     uint8_t type;
-} __attribute__((packed));
+} B_PACKED;
+B_END_PACKED
 
+B_START_PACKED
 struct dhcp_option_maximum_message_size {
     uint16_t size;
-} __attribute__((packed));
+} B_PACKED;
+B_END_PACKED
 
+B_START_PACKED
 struct dhcp_option_dhcp_server_identifier {
     uint32_t id;
-} __attribute__((packed));
+} B_PACKED;
+B_END_PACKED
 
+B_START_PACKED
 struct dhcp_option_time {
     uint32_t time;
-} __attribute__((packed));
+} B_PACKED;
+B_END_PACKED
 
+B_START_PACKED
 struct dhcp_option_addr {
     uint32_t addr;
-} __attribute__((packed));
+} B_PACKED;
+B_END_PACKED
 
 #endif

+ 5 - 1
protocol/requestproto.h

@@ -32,15 +32,19 @@
 
 #include <stdint.h>
 
+#include <misc/packed.h>
+
 #define REQUESTPROTO_TYPE_CLIENT_REQUEST 1
 #define REQUESTPROTO_TYPE_CLIENT_ABORT 2
 #define REQUESTPROTO_TYPE_SERVER_REPLY 3
 #define REQUESTPROTO_TYPE_SERVER_FINISHED 4
 #define REQUESTPROTO_TYPE_SERVER_ERROR 5
 
+B_START_PACKED
 struct requestproto_header {
     uint32_t request_id;
     uint32_t type;
-} __attribute__((packed));
+} B_PACKED;
+B_END_PACKED
 
 #endif