summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/gzip.h
blob: c8cf6414741a9b70a00a9b51e3ee3cea12b5e132 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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 */