summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/zlib.h
diff options
context:
space:
mode:
authorSimon Rettberg2021-07-22 14:36:35 +0200
committerSimon Rettberg2021-07-22 14:36:35 +0200
commitfc21afb08c7b827b3cd4a77618f36a7abdc13494 (patch)
treef7909726a1d49cb834bfa9647621b29cb15caea4 /src/include/ipxe/zlib.h
parentMerge branch 'master' into openslx (diff)
parent[cloud] Retry DHCP aggressively in AWS EC2 (diff)
downloadipxe-fc21afb08c7b827b3cd4a77618f36a7abdc13494.tar.gz
ipxe-fc21afb08c7b827b3cd4a77618f36a7abdc13494.tar.xz
ipxe-fc21afb08c7b827b3cd4a77618f36a7abdc13494.zip
Merge branch 'master' into openslx
Diffstat (limited to 'src/include/ipxe/zlib.h')
-rw-r--r--src/include/ipxe/zlib.h43
1 files changed, 43 insertions, 0 deletions
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 */