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 // all the ASCII characters (bytes) which are legal in an ACE string
62 extern char const * const legal_ace_bytes;
63
64 // all the ASCII characters (bytes) which are legal in a SHA1 hex id
65 extern char const * const legal_id_bytes;
66
67 // all the ASCII characters (bytes) which can occur in cert names
68 extern char const * const legal_cert_name_bytes;
69
70 // all the ASCII characters (bytes) which can occur in key names
71 extern char const * const legal_key_name_bytes;
72
73 // all the ASCII characters (bytes) which are illegal in a (file|local)_path
74 extern char const * const illegal_path_bytes;
75
76 // how many revisions back to verify the sanity of revisions before allowing
77 // them into the database
78 extern int const verify_depth;
79
80 // remaining constants are related to netsync protocol
81
82 // number of bytes in the hash used in netsync
83 static size_t const merkle_hash_length_in_bytes = 20;
84
85 // number of bits of merkle prefix consumed by each level of tree
86 extern size_t const merkle_fanout_bits;
87
88 // derived from hash_length_in_bytes
89 extern size_t const merkle_hash_length_in_bits;
90
91 // derived from fanout_bits
92 extern size_t const merkle_num_tree_levels;
93
94 // derived from fanout_bits
95 extern size_t const merkle_num_slots;
96
97 // derived from fanout_bits
98 extern size_t const merkle_bitmap_length_in_bits;
99
100 // derived from fanout_bits
101 extern size_t const merkle_bitmap_length_in_bytes;
102
103 // the current netcmd/netsync protocol version
104 extern u8 const netcmd_current_protocol_version;
105
106 // minimum size of any netcmd on the wire
107 static size_t const netcmd_minsz = (1 // version
108 + 1 // cmd code
109 + 1 // smallest uleb possible
110 + 4); // adler32
111
112
113 // largest command *payload* allowed in a netcmd
114 static size_t const netcmd_payload_limit = 2 << 27;
115
116 // maximum size of any netcmd on the wire, including payload
117 static size_t const netcmd_maxsz = netcmd_minsz + netcmd_payload_limit;
118
119 // netsync fragments larger than this are gzipped
120 extern size_t const netcmd_minimum_bytes_to_bother_with_gzip;
121
122 // TCP port to listen on / connect to when doing netsync
123 static size_t const netsync_default_port = 5253;
124
125 // maximum number of simultaneous clients on a server
126 static size_t const netsync_connection_limit = 1024;
127
128 // number of seconds a connection can be idle before it's dropped
129 static size_t const netsync_timeout_seconds = 21600; // 6 hours
130
131 // netsync HMAC key length
132 extern size_t const netsync_session_key_length_in_bytes;
133
134 // netsync HMAC value length
135 extern size_t const netsync_hmac_value_length_in_bytes;
136
137 // how long a sha1 digest should be
138 static size_t const sha1_digest_length = 20; // 160 bits
139
140 // netsync session key default initializer
141 extern std::string const & netsync_key_initializer;
142
143 // maximum path depth to allow (as a recursion limit)
144 static size_t const max_path_depth = 300;
145}
146
147#endif // __CONSTANTS_HH__

Archive Download this file

Branches

Tags

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