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

Archive Download this file

Branches

Tags

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