mirror of
https://github.com/linux-can/can-utils.git
synced 2026-11-04 07:21:13 +01:00
isobusfs: pack the protocol structures
The isobusfs protocol structures describe the message layout defined in ISO 11783-13 but were not packed. The compiler added padding bytes in front of 16/32 bit values which follow an odd number of bytes, e.g. the Read File Request (8 bytes according to C.3.5.2) had a size of 10 bytes and the count value at the wrong position. Server and client of the can-utils used the same structures and understood each other but the messages were not compatible to other ISOBUS devices. Additionally the padding bytes sent uninitialized content. Add __attribute__((__packed__)) to all protocol structures as it is already done in j1939_vehicle_position. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
This commit is contained in:
@@ -39,7 +39,7 @@ struct isobusfs_cm_fss {
|
||||
uint8_t status;
|
||||
uint8_t num_open_files;
|
||||
uint8_t reserved[5];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* C.1.3 Client Connection Maintenance
|
||||
@@ -58,7 +58,7 @@ struct isobusfs_cm_ccm {
|
||||
uint8_t fs_function;
|
||||
uint8_t version;
|
||||
uint8_t reserved[6];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* C.1.4 Get File Server Properties
|
||||
@@ -75,7 +75,7 @@ struct isobusfs_cm_ccm {
|
||||
struct isobusfs_cm_get_fs_props_req {
|
||||
uint8_t fs_function;
|
||||
uint8_t reserved[7];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/* File Server Capabilities */
|
||||
/* server support removable volumes */
|
||||
@@ -104,7 +104,7 @@ struct isobusfs_cm_get_fs_props_resp {
|
||||
uint8_t max_open_files;
|
||||
uint8_t fs_capabilities;
|
||||
uint8_t reserved[4];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
#define ISOBUSFS_VOL_MODE_PREP_TO_REMOVE BIT(1)
|
||||
#define ISOBUSFS_VOL_MODE_USED_BY_CLIENT BIT(0)
|
||||
@@ -130,7 +130,7 @@ struct isobusfs_cm_vol_stat_req {
|
||||
uint8_t volume_mode;
|
||||
__le16 name_len;
|
||||
char name[ISOBUSFS_MAX_VOLUME_NAME_LENGTH];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
enum isobusfs_vol_status {
|
||||
@@ -169,7 +169,7 @@ struct isobusfs_cm_vol_stat_res {
|
||||
uint8_t error_code;
|
||||
__le16 name_len;
|
||||
char name[ISOBUSFS_MAX_VOLUME_NAME_LENGTH];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
#endif /* ISOBUSFS_CMN_CM_H */
|
||||
|
||||
@@ -23,7 +23,7 @@ struct isobusfs_dh_get_cd_req {
|
||||
uint8_t fs_function;
|
||||
uint8_t tan;
|
||||
uint8_t reserved[6];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* C.2.2.3 Get Current Directory Response
|
||||
@@ -50,7 +50,7 @@ struct isobusfs_dh_get_cd_res {
|
||||
__le32 free_space;
|
||||
__le16 name_len;
|
||||
uint8_t name[];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* C.2.3.2 Change Current Directory Request
|
||||
@@ -71,7 +71,7 @@ struct isobusfs_dh_ccd_req {
|
||||
uint8_t tan;
|
||||
__le16 name_len;
|
||||
uint8_t name[];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* C.2.3.3 Change Current Directory Response
|
||||
@@ -101,7 +101,7 @@ struct isobusfs_dh_ccd_res {
|
||||
uint8_t tan;
|
||||
uint8_t error_code;
|
||||
uint8_t reserved[5];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
#endif /* _ISOBUSFS_CMN_DH_H */
|
||||
|
||||
+11
-11
@@ -105,7 +105,7 @@ struct isobusfs_fa_openf_req {
|
||||
uint8_t flags;
|
||||
__le16 name_len;
|
||||
uint8_t name[];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* C.3.3.3 Open File Response
|
||||
@@ -141,7 +141,7 @@ struct isobusfs_fa_openf_res {
|
||||
uint8_t handle;
|
||||
uint8_t attributes;
|
||||
uint8_t reserved[3];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/* B.17 Position mode */
|
||||
/* From the beginning of the file */
|
||||
@@ -168,7 +168,7 @@ struct isobusfs_fa_seekf_req {
|
||||
uint8_t handle;
|
||||
uint8_t position_mode;
|
||||
__le32 offset;
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* C.3.4.2 Seek File Response
|
||||
@@ -195,7 +195,7 @@ struct isobusfs_fa_seekf_res {
|
||||
uint8_t error_code;
|
||||
uint8_t reserved;
|
||||
__le32 position;
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* C.3.5.2 Read File Request
|
||||
@@ -220,7 +220,7 @@ struct isobusfs_fa_readf_req {
|
||||
uint8_t handle;
|
||||
__le16 count;
|
||||
uint8_t reserved[3];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* C.3.5.3 Read File Response (Handle-referenced file)
|
||||
@@ -250,7 +250,7 @@ struct isobusfs_read_file_response {
|
||||
uint8_t error_code;
|
||||
__le16 count;
|
||||
uint8_t data[];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* C.3.5.4 Read Directory Response (Handle-referenced directory)
|
||||
@@ -280,7 +280,7 @@ struct isobusfs_read_dir_response {
|
||||
uint8_t error_code;
|
||||
__le16 count;
|
||||
uint8_t data[];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* C.3.6.2 Write File Request
|
||||
@@ -303,7 +303,7 @@ struct isobusfs_write_file_request {
|
||||
uint8_t handle;
|
||||
__le16 count;
|
||||
uint8_t data[];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* C.3.6.3 Write File Response
|
||||
@@ -333,7 +333,7 @@ struct isobusfs_write_file_response {
|
||||
uint8_t error_code;
|
||||
__le16 count;
|
||||
uint8_t reserved[3];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* C.3.7.1 Close File Request
|
||||
@@ -354,7 +354,7 @@ struct isobusfs_close_file_request {
|
||||
uint8_t tan;
|
||||
uint8_t handle;
|
||||
uint8_t reserved[5];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* C.3.7.2 Close File Response
|
||||
@@ -378,7 +378,7 @@ struct isobusfs_close_file_res {
|
||||
uint8_t tan;
|
||||
uint8_t error_code;
|
||||
uint8_t reserved[6];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
#endif /* _LINUX_ISOBUS_FS_H */
|
||||
|
||||
+10
-10
@@ -32,7 +32,7 @@ struct isobusfs_move_file_request {
|
||||
/* Variable length data follows */
|
||||
/* uint8_t src_path[]; */
|
||||
/* uint8_t dst_path[]; */
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* C.4.2.3 Move File Response
|
||||
@@ -64,7 +64,7 @@ struct isobusfs_move_file_response {
|
||||
uint8_t tan;
|
||||
uint8_t error_code;
|
||||
uint8_t reserved[5];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* C.4.3.1 Delete File Request
|
||||
@@ -87,7 +87,7 @@ struct isobusfs_delete_file_request {
|
||||
uint8_t mode;
|
||||
__le16 path_len;
|
||||
uint8_t path[];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
/**
|
||||
@@ -118,7 +118,7 @@ struct isobusfs_delete_file_response {
|
||||
uint8_t tan;
|
||||
uint8_t error_code;
|
||||
uint8_t reserved[5];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* C.4.4.2 Get File Attributes Request
|
||||
@@ -139,7 +139,7 @@ struct isobusfs_get_file_attributes_request {
|
||||
uint8_t tan;
|
||||
__le16 pathname_len;
|
||||
uint8_t pathname[];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* C.4.4.3 Get File Attributes Response
|
||||
@@ -171,7 +171,7 @@ struct isobusfs_get_file_attributes_response {
|
||||
uint8_t error_code;
|
||||
uint8_t attributes;
|
||||
__le32 file_size;
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* C.4.5.2 Set File Attributes Request
|
||||
@@ -194,7 +194,7 @@ struct isobusfs_set_file_attributes_request {
|
||||
uint8_t attributes;
|
||||
__le16 name_length;
|
||||
uint8_t name[]; /* Variable length */
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* C.4.5.3 Set File Attributes Response
|
||||
@@ -225,7 +225,7 @@ struct isobusfs_set_file_attributes_response {
|
||||
uint8_t tan;
|
||||
uint8_t error_code;
|
||||
uint8_t reserved[5];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* C.4.6.2 Get File Date & Time Request
|
||||
@@ -246,7 +246,7 @@ struct isobusfs_get_file_date_time_request {
|
||||
uint8_t tan;
|
||||
__le16 name_length;
|
||||
uint8_t name[]; /* Variable length */
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* C.4.6.2 Get File Date & Time Response
|
||||
@@ -278,6 +278,6 @@ struct isobusfs_get_file_date_time_response {
|
||||
uint8_t error_code;
|
||||
__le16 date;
|
||||
__le16 time;
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
#endif /* _LINUX_ISOBUS_FS_H */
|
||||
|
||||
@@ -29,7 +29,7 @@ struct isobusfs_va_init_vol_req {
|
||||
uint8_t volume_flags;
|
||||
__le16 name_len;
|
||||
uint8_t name[];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* C.5.2.3 Initialize Volume Response
|
||||
@@ -62,6 +62,6 @@ struct isobusfs_va_init_vol_res {
|
||||
uint8_t tan;
|
||||
uint8_t error_code;
|
||||
uint8_t reserved[4];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
#endif /* _ISOBUSFS_CMN_VA_H */
|
||||
|
||||
Reference in New Issue
Block a user