monotone

monotone Mtn Source Tree

Root/constants.hh

1#ifndef __CONSTANTS_HH__
2#define __CONSTANTS_HH__
3
4// copyright (C) 2002, 2003 graydon hoare <graydon@pobox.com>
5// all rights reserved.
6// licensed to the public under the terms of the GNU GPL (>= 2)
7// see the file COPYING for details
8
9#include <unistd.h>
10#include <string>
11#include "numeric_vocab.hh"
12
13namespace constants
14{
15
16 // this file contains magic constants which you could, in theory, tweak.
17 // probably best not to tweak them though.
18
19 // block size in bytes for "automate stdio" output
20 extern size_t const automate_stdio_size;
21
22 // number of bits in an RSA key we use
23 extern size_t const keylen;
24
25 // number of characters in a SHA1 id
26 static size_t const idlen = 40;
27
28 // number of characters in an encoded epoch
29 static size_t const epochlen = idlen;
30
31 // number of characters in a raw epoch
32 static size_t const epochlen_bytes = epochlen / 2;
33
34 // number of seconds in window, in which to consider CVS commits equivalent
35 // if they have otherwise compatible contents (author, changelog)
36 extern time_t const cvs_window;
37
38 // number of bytes in a password buffer. further bytes will be dropped.
39 static size_t const maxpasswd = 0xfff;
40
41 // number of bytes to use in buffers, for buffered i/o operations
42 static size_t const bufsz = 0x3ffff;
43
44 // size of a line of database traffic logging, beyond which lines will be
45 // truncated.
46 extern size_t const db_log_line_sz;
47
48 // size in bytes of the database xdelta version reconstruction cache
49 extern size_t const db_version_cache_sz;
50
51 // size of a line of text in the log buffer, beyond which log lines will be
52 // truncated.
53 extern size_t const log_line_sz;
54
55 // assumed width of the terminal, when we can't query for it directly
56 extern size_t const default_terminal_width;
57
58 // all the ASCII characters (bytes) which are legal in a packet
59 extern char const * const legal_packet_bytes;
60
61 // boost regex that matches the bytes in legal_packet_bytes
62 extern std::string const regex_legal_packet_bytes;
63
64 // all the ASCII characters (bytes) which are legal in an ACE string
65 extern char const * const legal_ace_bytes;
66
67 // all the ASCII characters (bytes) which are legal in a SHA1 hex id
68 extern char const * const legal_id_bytes;
69
70 // boost regex that matches the bytes in legal_id_bytes
71 extern std::string const regex_legal_id_bytes;
72
73 // all the ASCII characters (bytes) which can occur in cert names
74 extern char const * const legal_cert_name_bytes;
75
76 // boost regex that matches the bytes in legal_cert_name_bytes
77 extern std::string const regex_legal_cert_name_bytes;
78
79 // all the ASCII characters (bytes) which can occur in key names
80 extern char const * const legal_key_name_bytes;
81
82 // boost regex that matches the bytes in legal_key_name_bytes
83 extern std::string const regex_legal_key_name_bytes;
84
85 // all the ASCII characters (bytes) which are illegal in a (file|local)_path
86 extern char const * const illegal_path_bytes;
87
88 // how many revisions back to verify the sanity of revisions before allowing
89 // them into the database
90 extern int const verify_depth;
91
92 // remaining constants are related to netsync protocol
93
94 // number of bytes in the hash used in netsync
95 static size_t const merkle_hash_length_in_bytes = 20;
96
97 // number of bits of merkle prefix consumed by each level of tree
98 extern size_t const merkle_fanout_bits;
99
100 // derived from hash_length_in_bytes
101 extern size_t const merkle_hash_length_in_bits;
102
103 // derived from fanout_bits
104 extern size_t const merkle_num_tree_levels;
105
106 // derived from fanout_bits
107 extern size_t const merkle_num_slots;
108
109 // derived from fanout_bits
110 extern size_t const merkle_bitmap_length_in_bits;
111
112 // derived from fanout_bits
113 extern size_t const merkle_bitmap_length_in_bytes;
114
115 // the current netcmd/netsync protocol version
116 extern u8 const netcmd_current_protocol_version;
117
118 // minimum size of any netcmd on the wire
119 static size_t const netcmd_minsz = (1 // version
120 + 1 // cmd code
121 + 1 // smallest uleb possible
122 + 4); // adler32
123
124
125 // largest command *payload* allowed in a netcmd
126 static size_t const netcmd_payload_limit = 2 << 27;
127
128 // maximum size of any netcmd on the wire, including payload
129 static size_t const netcmd_maxsz = netcmd_minsz + netcmd_payload_limit;
130
131 // netsync fragments larger than this are gzipped
132 extern size_t const netcmd_minimum_bytes_to_bother_with_gzip;
133
134 // TCP port to listen on / connect to when doing netsync
135 static size_t const netsync_default_port = 5253;
136
137 // maximum number of simultaneous clients on a server
138 static size_t const netsync_connection_limit = 1024;
139
140 // number of seconds a connection can be idle before it's dropped
141 static size_t const netsync_timeout_seconds = 21600; // 6 hours
142
143 // netsync HMAC key length
144 extern size_t const netsync_session_key_length_in_bytes;
145
146 // netsync HMAC value length
147 extern size_t const netsync_hmac_value_length_in_bytes;
148
149 // how long a sha1 digest should be
150 static size_t const sha1_digest_length = 20; // 160 bits
151
152 // netsync session key default initializer
153 extern std::string const & netsync_key_initializer;
154
155 // maximum path depth to allow (as a recursion limit)
156 static size_t const max_path_depth = 300;
157}
158
159#endif // __CONSTANTS_HH__

Archive Download this file

Branches

Tags

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