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

Archive Download this file

Branches

Tags

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