Sfoglia il codice sorgente

Fix endianness of dhcp device id structure.

tags/v0.9.3
Michael Brown 19 anni fa
parent
commit
e02c699a05
1 ha cambiato i file con 8 aggiunte e 5 eliminazioni
  1. 8
    5
      src/core/nic.c

+ 8
- 5
src/core/nic.c Vedi File

@@ -916,11 +916,14 @@ static int bootp(void)
916 916
 	unsigned char *bp_vend;
917 917
 
918 918
 #ifndef	NO_DHCP_SUPPORT
919
-	dhcp_machine_info[4] = dev.devid.bus_type;
920
-	dhcp_machine_info[5] = dev.devid.vendor_id & 0xff;
921
-	dhcp_machine_info[6] = ((dev.devid.vendor_id) >> 8) & 0xff;
922
-	dhcp_machine_info[7] = dev.devid.device_id & 0xff;
923
-	dhcp_machine_info[8] = ((dev.devid.device_id) >> 8) & 0xff;
919
+	struct {
920
+		uint8_t bus_type;
921
+		uint16_t vendor_id;
922
+		uint16_t device_id;
923
+	} __attribute__((packed)) *dhcp_dev_id = (void*)&dhcp_machine_info[4];
924
+	dhcp_dev_id->bus_type = dev.devid.bus_type;
925
+	dhcp_dev_id->vendor_id = htons ( dev.devid.vendor_id );
926
+	dhcp_dev_id->device_id = htons ( dev.devid.device_id );
924 927
 #endif	/* NO_DHCP_SUPPORT */
925 928
 	memset(&ip, 0, sizeof(struct bootpip_t));
926 929
 	ip.bp.bp_op = BOOTP_REQUEST;

Loading…
Annulla
Salva