monotone

monotone Mtn Source Tree

Root/constants.hh

1#ifndef __CONSTANTS_HH__
2#define __CONSTANTS_HH__
3
4// Copyright (C) 2002 Graydon Hoare <graydon@pobox.com>
5//
6// This program is made available under the GNU GPL version 2.0 or
7// greater. See the accompanying file COPYING for details.
8//
9// This program is distributed WITHOUT ANY WARRANTY; without even the
10// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11// PURPOSE.
12
13#include <unistd.h>
14#include <string>
15#include "numeric_vocab.hh"
16#include "vocab.hh"
17
18namespace constants
19{
20
21 // this file contains magic constants which you could, in theory, tweak.
22 // probably best not to tweak them though.
23
24 // number of bits in an RSA key we use
25 extern size_t const keylen;
26
27 // number of characters in a SHA1 id
28 static size_t const idlen = 40;
29
30 // number of characters in an encoded epoch
31 static size_t const epochlen = idlen;
32
33 // number of characters in a raw epoch
34 static size_t const epochlen_bytes = epochlen / 2;
35
36 // number of seconds in window, in which to consider CVS commits equivalent
37 // if they have otherwise compatible contents (author, changelog)
38 extern time_t const cvs_window;
39
40 // number of bytes in a password buffer. further bytes will be dropped.
41 static size_t const maxpasswd = 0xfff;
42
43 // number of bytes to use in buffers, for buffered i/o operations
44 static size_t const bufsz = 0x3ffff;
45
46 // size of a line of database traffic logging, beyond which lines will be
47 // truncated.
48 extern size_t const db_log_line_sz;
49
50 // maximum size in bytes of the database xdelta version reconstruction
51 // cache
52 extern size_t const db_version_cache_sz;
53
54 // maximum size in bytes of the write-back roster cache
55 extern size_t const db_roster_cache_sz;
56
57 // estimated number of bytes taken for a node_t and its corresponding
58 // marking_t. used to estimate the current size of the write-back roster
59 // cache
60 extern size_t const db_estimated_roster_node_sz;
61
62 // maximum number of bytes to be consumed with the delayed write cache
63 extern unsigned long const db_max_delayed_file_bytes;
64
65 // size of a line of text in the log buffer, beyond which log lines will be
66 // truncated.
67 extern size_t const log_line_sz;
68
69 // assumed width of the terminal, when we can't query for it directly
70 extern size_t const default_terminal_width;
71
72 // all the ASCII characters (bytes) which are legal in a packet
73 extern char const * const legal_packet_bytes;
74
75 // boost regex that matches the bytes in legal_packet_bytes
76 extern std::string const regex_legal_packet_bytes;
77
78 // all the ASCII characters (bytes) which are legal in an ACE string
79 extern char const * const legal_ace_bytes;
80
81 // all the ASCII characters (bytes) which are legal in a SHA1 hex id
82 extern char const * const legal_id_bytes;
83
84 // boost regex that matches the bytes in legal_id_bytes
85 extern std::string const regex_legal_id_bytes;
86
87 // all the ASCII characters (bytes) which can occur in cert names
88 extern char const * const legal_cert_name_bytes;
89
90 // boost regex that matches the bytes in legal_cert_name_bytes
91 extern std::string const regex_legal_cert_name_bytes;
92
93 // all the ASCII characters (bytes) which can occur in key names
94 extern char const * const legal_key_name_bytes;
95
96 // boost regex that matches the bytes in legal_key_name_bytes
97 extern std::string const regex_legal_key_name_bytes;
98
99 // remaining constants are related to netsync protocol
100
101 // number of bytes in the hash used in netsync
102 static size_t const merkle_hash_length_in_bytes = 20;
103
104 // number of bits of merkle prefix consumed by each level of tree
105 extern size_t const merkle_fanout_bits;
106
107 // derived from hash_length_in_bytes
108 extern size_t const merkle_hash_length_in_bits;
109
110 // derived from fanout_bits
111 extern size_t const merkle_num_tree_levels;
112
113 // derived from fanout_bits
114 extern size_t const merkle_num_slots;
115
116 // derived from fanout_bits
117 extern size_t const merkle_bitmap_length_in_bits;
118
119 // derived from fanout_bits
120 extern size_t const merkle_bitmap_length_in_bytes;
121
122 // the current netcmd/netsync protocol version
123 extern u8 const netcmd_current_protocol_version;
124
125 // minimum size of any netcmd on the wire
126 static size_t const netcmd_minsz = (1 // version
127 + 1 // cmd code
128 + 1); // smallest uleb possible
129
130
131 // largest command *payload* allowed in a netcmd
132 // in practice, this sets the size of the largest compressed file
133 static size_t const netcmd_payload_limit = 2 << 27;
134
135 // maximum size of any netcmd on the wire, including payload
136 static size_t const netcmd_maxsz = netcmd_minsz + netcmd_payload_limit;
137
138 // netsync fragments larger than this are gzipped
139 extern size_t const netcmd_minimum_bytes_to_bother_with_gzip;
140
141 // TCP port to listen on / connect to when doing netsync
142 static size_t const netsync_default_port = 4691;
143
144 // maximum number of simultaneous clients on a server
145 static size_t const netsync_connection_limit = 1024;
146
147 // number of seconds a connection can be idle before it's dropped
148 static size_t const netsync_timeout_seconds = 21600; // 6 hours
149
150 // netsync HMAC key length
151 extern size_t const netsync_session_key_length_in_bytes;
152
153 // netsync HMAC value length
154 extern size_t const netsync_hmac_value_length_in_bytes;
155
156 // how long a sha1 digest should be
157 static size_t const sha1_digest_length = 20; // 160 bits
158
159 // netsync session key default initializer
160 extern netsync_session_key const netsync_key_initializer;
161
162 // attributes
163 extern std::string const encoding_attribute;
164 extern std::string const binary_encoding;
165 extern std::string const default_encoding;
166 extern std::string const manual_merge_attribute;
167}
168
169// Local Variables:
170// mode: C++
171// fill-column: 76
172// c-file-style: "gnu"
173// indent-tabs-mode: nil
174// End:
175// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:
176
177#endif // __CONSTANTS_HH__

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status