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
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <stdint.h>
14#include <byteswap.h>
15#include <ipxe/image.h>
16#include <ipxe/deflate.h>
17
18/** zlib magic header */
20 /** Compression method and flags */
22 /** Check value */
24} __attribute__ (( packed ));
25
26/**
27 * Check that zlib magic header is valid
28 *
29 * @v magic Magic header
30 * @ret is_valid Magic header is valid
31 */
32static inline int zlib_magic_is_valid ( const union zlib_magic *magic ) {
33
34 /* Check magic value as per RFC 6713 */
35 return ( ( ( magic->cmf & 0x8f ) == 0x08 ) &&
36 ( ( be16_to_cpu ( magic->check ) % 31 ) == 0 ) );
37}
38
39extern int zlib_deflate ( enum deflate_format format, const void *data,
40 size_t len, struct image *extracted );
41
42extern struct image_type zlib_image_type __image_type ( PROBE_NORMAL );
43
44#endif /* _IPXE_ZLIB_H */
unsigned short uint16_t
Definition stdint.h:11
unsigned char uint8_t
Definition stdint.h:10
uint16_t magic
Magic signature.
Definition bzimage.h:1
DEFLATE decompression algorithm.
deflate_format
Compression formats.
Definition deflate.h:17
ring len
Length.
Definition dwmac.h:226
uint8_t data[48]
Additional event data.
Definition ena.h:11
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
Executable images.
#define PROBE_NORMAL
Normal image probe priority.
Definition image.h:156
#define __image_type(probe_order)
An executable image type.
Definition image.h:170
#define be16_to_cpu(value)
Definition byteswap.h:116
#define __attribute__(x)
Definition compiler.h:10
An executable image type.
Definition image.h:95
An executable image.
Definition image.h:24
zlib magic header
Definition zlib.h:19
uint8_t cmf
Compression method and flags.
Definition zlib.h:21
uint16_t check
Check value.
Definition zlib.h:23
int const char * format
Definition xfer.h:105
static int zlib_magic_is_valid(const union zlib_magic *magic)
Check that zlib magic header is valid.
Definition zlib.h:32
int zlib_deflate(enum deflate_format format, const void *data, size_t len, struct image *extracted)
Extract compressed data to image.
Definition zlib.c:49