aboutsummaryrefslogtreecommitdiffstats
path: root/src/include/ipxe
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2021-05-06 18:38:37 +0100
committerMichael Brown <mcb30@ipxe.org>2021-05-08 15:34:19 +0100
commit866fa1ce7639c93de8905cf16ab79b8086990728 (patch)
tree69c4c77fd2c7c90732fd4f75e433223126330ff7 /src/include/ipxe
parentd093683d93ccfac4c76e72264ec3b0d8f0017b92 (diff)
downloadipxe-imgextract.tar.gz
[gzip] Add support for gzip archive imagesimgextract
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe')
-rw-r--r--src/include/ipxe/errfile.h1
-rw-r--r--src/include/ipxe/gzip.h71
2 files changed, 72 insertions, 0 deletions
diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h
index 35b03fe9d..90c91cdb9 100644
--- a/src/include/ipxe/errfile.h
+++ b/src/include/ipxe/errfile.h
@@ -303,6 +303,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define ERRFILE_pem ( ERRFILE_IMAGE | 0x00090000 )
#define ERRFILE_archive ( ERRFILE_IMAGE | 0x000a0000 )
#define ERRFILE_zlib ( ERRFILE_IMAGE | 0x000b0000 )
+#define ERRFILE_gzip ( ERRFILE_IMAGE | 0x000c0000 )
#define ERRFILE_asn1 ( ERRFILE_OTHER | 0x00000000 )
#define ERRFILE_chap ( ERRFILE_OTHER | 0x00010000 )
diff --git a/src/include/ipxe/gzip.h b/src/include/ipxe/gzip.h
new file mode 100644
index 000000000..c8cf64147
--- /dev/null
+++ b/src/include/ipxe/gzip.h
@@ -0,0 +1,71 @@
+#ifndef _IPXE_GZIP_H
+#define _IPXE_GZIP_H
+
+/** @file
+ *
+ * gzip compressed images
+ *
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
+
+#include <stdint.h>
+#include <ipxe/image.h>
+
+/** gzip header */
+struct gzip_header {
+ /** Magic ID */
+ uint16_t magic;
+ /** Compression method */
+ uint8_t method;
+ /** Flags */
+ uint8_t flags;
+ /** Modification time */
+ uint32_t mtime;
+ /** Extra flags */
+ uint8_t extra;
+ /** Operating system */
+ uint8_t os;
+} __attribute__ (( packed ));
+
+/** Magic ID */
+#define GZIP_MAGIC 0x1f8b
+
+/** Compression method */
+#define GZIP_METHOD_DEFLATE 0x08
+
+/** CRC header is present */
+#define GZIP_FL_HCRC 0x02
+
+/** Extra header is present */
+#define GZIP_FL_EXTRA 0x04
+
+/** File name is present */
+#define GZIP_FL_NAME 0x08
+
+/** File comment is present */
+#define GZIP_FL_COMMENT 0x10
+
+/** gzip extra header */
+struct gzip_extra_header {
+ /** Extra header length (excluding this field) */
+ uint16_t len;
+} __attribute__ (( packed ));
+
+/** gzip CRC header */
+struct gzip_crc_header {
+ /** CRC-16 */
+ uint16_t crc;
+} __attribute__ (( packed ));
+
+/** gzip footer */
+struct gzip_footer {
+ /** CRC-32 */
+ uint32_t crc;
+ /** Uncompressed size (modulo 2^32) */
+ uint32_t len;
+} __attribute__ (( packed ));
+
+extern struct image_type gzip_image_type __image_type ( PROBE_NORMAL );
+
+#endif /* _IPXE_GZIP_H */