aboutsummaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2021-05-06 13:17:35 +0100
committerMichael Brown <mcb30@ipxe.org>2021-05-08 15:34:19 +0100
commitd093683d93ccfac4c76e72264ec3b0d8f0017b92 (patch)
tree7e752e4ffae9a5ef8ff0341e33d69da2acc693a1 /src/include
parent5c9c8d2b9b78cf4e1f256fe6874855c1aee458f2 (diff)
downloadipxe-d093683d93ccfac4c76e72264ec3b0d8f0017b92.tar.gz
[zlib] Add support for zlib archive images
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/ipxe/errfile.h1
-rw-r--r--src/include/ipxe/zlib.h43
2 files changed, 44 insertions, 0 deletions
diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h
index 162e6b7b0..35b03fe9d 100644
--- a/src/include/ipxe/errfile.h
+++ b/src/include/ipxe/errfile.h
@@ -302,6 +302,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define ERRFILE_der ( ERRFILE_IMAGE | 0x00080000 )
#define ERRFILE_pem ( ERRFILE_IMAGE | 0x00090000 )
#define ERRFILE_archive ( ERRFILE_IMAGE | 0x000a0000 )
+#define ERRFILE_zlib ( ERRFILE_IMAGE | 0x000b0000 )
#define ERRFILE_asn1 ( ERRFILE_OTHER | 0x00000000 )
#define ERRFILE_chap ( ERRFILE_OTHER | 0x00010000 )
diff --git a/src/include/ipxe/zlib.h b/src/include/ipxe/zlib.h
new file mode 100644
index 000000000..29016c38e
--- /dev/null
+++ b/src/include/ipxe/zlib.h
@@ -0,0 +1,43 @@
+#ifndef _IPXE_ZLIB_H
+#define _IPXE_ZLIB_H
+
+/** @file
+ *
+ * zlib compressed images
+ *
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
+
+#include <stdint.h>
+#include <byteswap.h>
+#include <ipxe/image.h>
+#include <ipxe/deflate.h>
+
+/** zlib magic header */
+union zlib_magic {
+ /** Compression method and flags */
+ uint8_t cmf;
+ /** Check value */
+ uint16_t check;
+} __attribute__ (( packed ));
+
+/**
+ * Check that zlib magic header is valid
+ *
+ * @v magic Magic header
+ * @ret is_valid Magic header is valid
+ */
+static inline int zlib_magic_is_valid ( union zlib_magic *magic ) {
+
+ /* Check magic value as per RFC 6713 */
+ return ( ( ( magic->cmf & 0x8f ) == 0x08 ) &&
+ ( ( be16_to_cpu ( magic->check ) % 31 ) == 0 ) );
+}
+
+extern int zlib_deflate ( enum deflate_format format, struct deflate_chunk *in,
+ struct image *extracted );
+
+extern struct image_type zlib_image_type __image_type ( PROBE_NORMAL );
+
+#endif /* _IPXE_ZLIB_H */