iPXE
zlib.h
Go to the documentation of this file.
1 #ifndef _IPXE_ZLIB_H
2 #define _IPXE_ZLIB_H
3 
4 /** @file
5  *
6  * zlib compressed images
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <stdint.h>
13 #include <byteswap.h>
14 #include <ipxe/image.h>
15 #include <ipxe/deflate.h>
16 
17 /** zlib magic header */
18 union zlib_magic {
19  /** Compression method and flags */
21  /** Check value */
23 } __attribute__ (( packed ));
24 
25 /**
26  * Check that zlib magic header is valid
27  *
28  * @v magic Magic header
29  * @ret is_valid Magic header is valid
30  */
31 static inline int zlib_magic_is_valid ( union zlib_magic *magic ) {
32 
33  /* Check magic value as per RFC 6713 */
34  return ( ( ( magic->cmf & 0x8f ) == 0x08 ) &&
35  ( ( be16_to_cpu ( magic->check ) % 31 ) == 0 ) );
36 }
37 
38 extern int zlib_deflate ( enum deflate_format format, struct deflate_chunk *in,
39  struct image *extracted );
40 
41 extern struct image_type zlib_image_type __image_type ( PROBE_NORMAL );
42 
43 #endif /* _IPXE_ZLIB_H */
#define __attribute__(x)
Definition: compiler.h:10
unsigned short uint16_t
Definition: stdint.h:11
__be32 in[4]
Definition: CIB_PRM.h:35
An executable image type.
Definition: image.h:76
uint32_t magic
Magic signature.
Definition: fdt.h:12
#define PROBE_NORMAL
Normal image probe priority.
Definition: image.h:137
An executable image.
Definition: image.h:24
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
A chunk of data.
Definition: deflate.h:241
Executable images.
#define be16_to_cpu(value)
Definition: byteswap.h:115
deflate_format
Compression formats.
Definition: deflate.h:17
zlib magic header
Definition: zlib.h:18
static int zlib_magic_is_valid(union zlib_magic *magic)
Check that zlib magic header is valid.
Definition: zlib.h:31
unsigned char uint8_t
Definition: stdint.h:10
uint8_t cmf
Compression method and flags.
Definition: zlib.h:20
uint16_t check
Check value.
Definition: zlib.h:22
DEFLATE decompression algorithm.
int zlib_deflate(enum deflate_format format, struct deflate_chunk *in, struct image *extracted)
Extract compressed data to image.
Definition: zlib.c:48
int const char * format
Definition: xfer.h:104
struct image_type zlib_image_type __image_type(PROBE_NORMAL)