]> git.ipfire.org Git - thirdparty/squid.git/blame - src/StoreMeta.h
Removed CVS $ markers
[thirdparty/squid.git] / src / StoreMeta.h
CommitLineData
528b2c61 1/*
528b2c61 2 *
3 * SQUID Web Proxy Cache http://www.squid-cache.org/
4 * ----------------------------------------------------------
5 *
6 * Squid is the result of efforts by numerous individuals from
7 * the Internet community; see the CONTRIBUTORS file for full
8 * details. Many organizations have provided support for Squid's
9 * development; see the SPONSORS file for full details. Squid is
10 * Copyrighted (C) 2001 by the Regents of the University of
11 * California; see the COPYRIGHT file for full details. Squid
12 * incorporates software developed and/or copyrighted by other
13 * sources; see the CREDITS file for full details.
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
26ac0430 19 *
528b2c61 20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
26ac0430 24 *
528b2c61 25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
28 *
29 */
528b2c61 30#ifndef SQUID_TYPELENGTHVALUE_H
31#define SQUID_TYPELENGTHVALUE_H
32
33class StoreEntry;
62e76326 34
e1f7507e 35// WTF?
528b2c61 36typedef class StoreMeta tlv;
62e76326 37
e1f7507e
AJ
38/**
39 \ingroup SwapStoreAPI
40 \todo AYJ: for critical lists like this we should use A=64,B=65 etc to enforce and reserve values.
41 \note NOTE! We must preserve the order of this list!
42 *
43 \section StoreSwapMeta Store "swap meta" Description
44 \par
45 * "swap meta" refers to a section of meta data stored at the beginning
46 * of an object that is stored on disk. This meta data includes information
47 * such as the object's cache key (MD5), URL, and part of the StoreEntry
48 * structure.
49 *
50 \par
51 * The meta data is stored using a TYPE-LENGTH-VALUE format. That is,
52 * each chunk of meta information consists of a TYPE identifier, a
53 * LENGTH field, and then the VALUE (which is LENGTH octets long).
54 */
55enum {
56 /**
57 * Just a placeholder for the zeroth value. It is never used on disk.
58 */
59 STORE_META_VOID,
60
61 /**
62 \deprecated
63 * This represents the case when we use the URL as the cache
64 * key, as Squid-1.1 does. Currently we don't support using
65 * a URL as a cache key, so this is not used.
66 */
67 STORE_META_KEY_URL,
68
69 /**
70 \deprecated
71 * For a brief time we considered supporting SHA (secure
72 * hash algorithm) as a cache key. Nobody liked it, and
73 * this type is not currently used.
74 */
75 STORE_META_KEY_SHA,
76
77 /**
78 * This represents the MD5 cache key that Squid currently uses.
79 * When Squid opens a disk file for reading, it can check that
80 * this MD5 matches the MD5 of the user's request. If not, then
81 * something went wrong and this is probably the wrong object.
82 */
83 STORE_META_KEY_MD5,
84
85 /**
86 * The object's URL. This also may be matched against a user's
87 * request for cache hits to make sure we got the right object.
88 */
89 STORE_META_URL,
90
91 /**
92 * This is the "standard metadata" for an object.
93 * Really its just this middle chunk of the StoreEntry structure:
94 \code
95 time_t timestamp;
96 time_t lastref;
97 time_t expires;
98 time_t lastmod;
f45dd259
AJ
99 uint64_t swap_file_sz;
100 uint16_t refcount;
101 uint16_t flags;
e1f7507e
AJ
102 \endcode
103 */
104 STORE_META_STD,
105
106 /**
107 * Reserved for future hit-metering (RFC 2227) stuff
108 */
109 STORE_META_HITMETERING,
110
111 /// \todo DOCS: document.
112 STORE_META_VALID,
113
114 /**
115 * Stores Vary request headers
116 */
117 STORE_META_VARY_HEADERS,
118
119 /**
120 * Updated version of STORE_META_STD, with support for >2GB objects.
121 * As STORE_META_STD except that the swap_file_sz is a 64-bit integer instead of 32-bit.
122 */
123 STORE_META_STD_LFS,
124
e1f7507e
AJ
125 STORE_META_OBJSIZE,
126
127 STORE_META_STOREURL, /* the store url, if different to the normal URL */
128 STORE_META_VARY_ID, /* Unique ID linking variants */
129 STORE_META_END
130};
131
132/// \ingroup SwapStoreAPI
62e76326 133class StoreMeta
134{
528b2c61 135public:
528b2c61 136 static bool validType(char);
137 static int const MaximumTLVLength;
138 static int const MinimumTLVLength;
e1f7507e 139 static StoreMeta *Factory(char type, size_t len, void const *value);
528b2c61 140 static StoreMeta **Add(StoreMeta **tail, StoreMeta *aNode);
e1f7507e 141 static void FreeList(StoreMeta **head);
62e76326 142
528b2c61 143 virtual char getType() const = 0;
144 virtual bool validLength(int) const;
145 virtual bool checkConsistency(StoreEntry *) const;
26ac0430 146 virtual ~StoreMeta() {}
62e76326 147
528b2c61 148 int length;
149 void *value;
150 tlv *next;
528b2c61 151};
152
e1f7507e 153/// \ingroup SwapStoreAPI
528b2c61 154SQUIDCEXTERN char *storeSwapMetaPack(tlv * tlv_list, int *length);
e1f7507e 155/// \ingroup SwapStoreAPI
528b2c61 156SQUIDCEXTERN tlv *storeSwapMetaBuild(StoreEntry * e);
e1f7507e 157/// \ingroup SwapStoreAPI
528b2c61 158SQUIDCEXTERN void storeSwapTLVFree(tlv * n);
159
160#endif /* SQUID_TYPELENGTHVALUE_H */