1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
4 * This file is part of Evergreen.
6 * Evergreen is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published
8 * by the Free Software Foundation, either version 2 of the License,
9 * or (at your option) any later version.
11 * Evergreen is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Evergreen. If not, see <http://www.gnu.org/licenses/>.
19 * This Source Code Form is derived from code that was originally
20 * subject to the terms of the Mozilla Public License, v. 2.0 and
21 * included in Evergreen. You may, therefore, use this Source Code
22 * Form under the terms of the Mozilla Public License 2.0. This
23 * licensing option does not affect the larger Evergreen project, only
24 * the Source Code Forms bearing this exception are affected. If a
25 * copy of the MPL was not distributed with this file, You can obtain
26 * one at http://mozilla.org/MPL/2.0/.
29 #ifndef MAR_PRIVATE_H__
30 #define MAR_PRIVATE_H__
34 #define BLOCKSIZE 4096
35 #define ROUND_UP(n, incr) (((n) / (incr) + 1) * (incr))
40 /* The signature block comes directly after the header block
42 #define SIGNATURE_BLOCK_OFFSET 16
44 /* Make sure the file is less than 500MB. We do this to protect against
46 #define MAX_SIZE_OF_MAR_FILE ((int64_t)524288000)
48 /* The maximum size of any signature supported by current and future
49 implementations of the signmar program. */
50 #define MAX_SIGNATURE_LENGTH 2048
52 /* Each additional block has a unique ID.
53 The product information block has an ID of 1. */
54 #define PRODUCT_INFO_BLOCK_ID 1
56 #define MAR_ITEM_SIZE(namelen) (3*sizeof(uint32_t) + (namelen) + 1)
58 /* Product Information Block (PIB) constants */
59 #define PIB_MAX_MAR_CHANNEL_ID_SIZE 63
60 #define PIB_MAX_PRODUCT_VERSION_SIZE 31
62 /* The mar program is compiled as a host bin so we don't have access to NSPR at
63 runtime. For that reason we use ntohl, htonl, and define HOST_TO_NETWORK64
64 instead of the NSPR equivalents. */
67 #define ftello _ftelli64
68 #define fseeko _fseeki64
70 #define _FILE_OFFSET_BITS 64
71 #include <netinet/in.h>
77 #define HOST_TO_NETWORK64(x) ( \
78 ((((uint64_t) x) & 0xFF) << 56) | \
79 ((((uint64_t) x) >> 8) & 0xFF) << 48) | \
80 (((((uint64_t) x) >> 16) & 0xFF) << 40) | \
81 (((((uint64_t) x) >> 24) & 0xFF) << 32) | \
82 (((((uint64_t) x) >> 32) & 0xFF) << 24) | \
83 (((((uint64_t) x) >> 40) & 0xFF) << 16) | \
84 (((((uint64_t) x) >> 48) & 0xFF) << 8) | \
85 (((uint64_t) x) >> 56)
86 #define NETWORK_TO_HOST64 HOST_TO_NETWORK64
88 #endif /* MAR_PRIVATE_H__ */