]>
Commit | Line | Data |
---|---|---|
528b2c61 | 1 | /* |
bbc27441 | 2 | * Copyright (C) 1996-2014 The Squid Software Foundation and contributors |
528b2c61 | 3 | * |
bbc27441 AJ |
4 | * Squid software is distributed under GPLv2+ license and includes |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
528b2c61 | 7 | */ |
bbc27441 | 8 | |
528b2c61 | 9 | #ifndef SQUID_TYPELENGTHVALUE_H |
10 | #define SQUID_TYPELENGTHVALUE_H | |
11 | ||
12 | class StoreEntry; | |
62e76326 | 13 | |
e1f7507e | 14 | // WTF? |
528b2c61 | 15 | typedef class StoreMeta tlv; |
62e76326 | 16 | |
e1f7507e AJ |
17 | /** |
18 | \ingroup SwapStoreAPI | |
19 | \todo AYJ: for critical lists like this we should use A=64,B=65 etc to enforce and reserve values. | |
20 | \note NOTE! We must preserve the order of this list! | |
21 | * | |
22 | \section StoreSwapMeta Store "swap meta" Description | |
23 | \par | |
24 | * "swap meta" refers to a section of meta data stored at the beginning | |
25 | * of an object that is stored on disk. This meta data includes information | |
26 | * such as the object's cache key (MD5), URL, and part of the StoreEntry | |
27 | * structure. | |
28 | * | |
29 | \par | |
30 | * The meta data is stored using a TYPE-LENGTH-VALUE format. That is, | |
31 | * each chunk of meta information consists of a TYPE identifier, a | |
32 | * LENGTH field, and then the VALUE (which is LENGTH octets long). | |
33 | */ | |
34 | enum { | |
35 | /** | |
36 | * Just a placeholder for the zeroth value. It is never used on disk. | |
37 | */ | |
38 | STORE_META_VOID, | |
39 | ||
40 | /** | |
41 | \deprecated | |
42 | * This represents the case when we use the URL as the cache | |
43 | * key, as Squid-1.1 does. Currently we don't support using | |
44 | * a URL as a cache key, so this is not used. | |
45 | */ | |
46 | STORE_META_KEY_URL, | |
47 | ||
48 | /** | |
49 | \deprecated | |
50 | * For a brief time we considered supporting SHA (secure | |
51 | * hash algorithm) as a cache key. Nobody liked it, and | |
52 | * this type is not currently used. | |
53 | */ | |
54 | STORE_META_KEY_SHA, | |
55 | ||
56 | /** | |
57 | * This represents the MD5 cache key that Squid currently uses. | |
58 | * When Squid opens a disk file for reading, it can check that | |
59 | * this MD5 matches the MD5 of the user's request. If not, then | |
60 | * something went wrong and this is probably the wrong object. | |
61 | */ | |
62 | STORE_META_KEY_MD5, | |
63 | ||
64 | /** | |
65 | * The object's URL. This also may be matched against a user's | |
66 | * request for cache hits to make sure we got the right object. | |
67 | */ | |
68 | STORE_META_URL, | |
69 | ||
70 | /** | |
71 | * This is the "standard metadata" for an object. | |
72 | * Really its just this middle chunk of the StoreEntry structure: | |
73 | \code | |
74 | time_t timestamp; | |
75 | time_t lastref; | |
76 | time_t expires; | |
77 | time_t lastmod; | |
f45dd259 AJ |
78 | uint64_t swap_file_sz; |
79 | uint16_t refcount; | |
80 | uint16_t flags; | |
e1f7507e AJ |
81 | \endcode |
82 | */ | |
83 | STORE_META_STD, | |
84 | ||
85 | /** | |
86 | * Reserved for future hit-metering (RFC 2227) stuff | |
87 | */ | |
88 | STORE_META_HITMETERING, | |
89 | ||
90 | /// \todo DOCS: document. | |
91 | STORE_META_VALID, | |
92 | ||
93 | /** | |
94 | * Stores Vary request headers | |
95 | */ | |
96 | STORE_META_VARY_HEADERS, | |
97 | ||
98 | /** | |
99 | * Updated version of STORE_META_STD, with support for >2GB objects. | |
100 | * As STORE_META_STD except that the swap_file_sz is a 64-bit integer instead of 32-bit. | |
101 | */ | |
102 | STORE_META_STD_LFS, | |
103 | ||
e1f7507e AJ |
104 | STORE_META_OBJSIZE, |
105 | ||
106 | STORE_META_STOREURL, /* the store url, if different to the normal URL */ | |
107 | STORE_META_VARY_ID, /* Unique ID linking variants */ | |
108 | STORE_META_END | |
109 | }; | |
110 | ||
111 | /// \ingroup SwapStoreAPI | |
62e76326 | 112 | class StoreMeta |
113 | { | |
528b2c61 | 114 | public: |
528b2c61 | 115 | static bool validType(char); |
116 | static int const MaximumTLVLength; | |
117 | static int const MinimumTLVLength; | |
e1f7507e | 118 | static StoreMeta *Factory(char type, size_t len, void const *value); |
528b2c61 | 119 | static StoreMeta **Add(StoreMeta **tail, StoreMeta *aNode); |
e1f7507e | 120 | static void FreeList(StoreMeta **head); |
62e76326 | 121 | |
528b2c61 | 122 | virtual char getType() const = 0; |
123 | virtual bool validLength(int) const; | |
124 | virtual bool checkConsistency(StoreEntry *) const; | |
26ac0430 | 125 | virtual ~StoreMeta() {} |
62e76326 | 126 | |
528b2c61 | 127 | int length; |
128 | void *value; | |
129 | tlv *next; | |
528b2c61 | 130 | }; |
131 | ||
e1f7507e | 132 | /// \ingroup SwapStoreAPI |
d9c252f2 | 133 | char *storeSwapMetaPack(tlv * tlv_list, int *length); |
e1f7507e | 134 | /// \ingroup SwapStoreAPI |
d9c252f2 | 135 | tlv *storeSwapMetaBuild(StoreEntry * e); |
e1f7507e | 136 | /// \ingroup SwapStoreAPI |
d9c252f2 | 137 | void storeSwapTLVFree(tlv * n); |
528b2c61 | 138 | |
139 | #endif /* SQUID_TYPELENGTHVALUE_H */ |