~ubuntu-branches/ubuntu/precise/amule-adunanza/precise

« back to all changes in this revision

Viewing changes to src/AdunanzA.h

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-02-18 21:16:23 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100218211623-gptwe60zx1knfkmu
Tags: 2010.1+2.2.6-0ubuntu1
* New upstream release (LP: #524697)
  - Drop manpages_spelling_fixes.diff fixed by upstream
  - Drop cryptopp-reference.diff fixed by upstream
  - Bump Standards-Version no changes required
  - Update install files (amule -> amuleadunanza)
  - debian/rules: amule.xpm -> amuleadunanza.xpm
  - Add README.Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#ifdef HAVE_CONFIG_H
29
29
        #include "config.h"                     //   VERSION
30
30
#endif
 
31
 
 
32
 
31
33
#include <queue>   // Mr Hyde
32
34
#include "Types.h" // Mr Hyde
33
35
 
34
 
#include <wx/string.h>
 
36
 
 
37
 
 
38
//////////////////////////////////////////////////////////////////////////////////////
 
39
//
 
40
#define ADU_MOD_NAME _T("AdunanzA")
 
41
 
 
42
#define ADU_VER_MAJ   2010 
 
43
#define ADU_VER_MIN   1
 
44
 
 
45
// IMPOSTARE LA SEG. ADU_BETA_MAJ A 0 PER LE VERSIONI RILASCIATE UFFICIALMENTE 
 
46
#define ADU_BETA_MAJ 0
 
47
#define ADU_BETA_MIN
 
48
//
 
49
//////////////////////////////////////////////////////////////////////////////////////
 
50
 
 
51
 
35
52
 
36
53
#define V(M, m) _T(#M) _T(".") _T(#m)
37
54
#define _V(M, m) V(M,m)
38
55
 
39
 
#define B(n, l) _T(#n) _T(l)
 
56
// Per il momento lascio perdere _T(l)
 
57
// #define B(n, l) _T(#n) _T(l)
 
58
#define B(n, l) _T(#n)
 
59
 
40
60
#define _B(n, l) B(n, l)
41
61
 
42
 
#define ADU_VER_MAJ   3
43
 
#define ADU_VER_MIN   14
44
62
 
45
63
#define ADU_VER_RL _V(ADU_VER_MAJ, ADU_VER_MIN)
46
64
 
47
 
#define ADU_BETA_MAJ 3
48
 
#define ADU_BETA_MIN ""
49
 
 
50
65
#if ADU_BETA_MAJ > 0
51
66
        #define ADU_VER ADU_VER_RL _T("b") _B(ADU_BETA_MAJ, ADU_BETA_MIN)
52
67
#else
53
68
        #define ADU_VER ADU_VER_RL
54
69
#endif
55
70
 
56
 
#define ADU_MOD_NAME _T("AdunanzA")
57
71
#define ADU_MOD ADU_MOD_NAME _T(" ") ADU_VER
58
72
 
 
73
// Mr Hyde: uso la seg. per avere "aMuleAdunanzA" invece di "aMule" come nome
 
74
// di directory (es: directory per preferenze diventa ~/.aMuleAdunanzA)
 
75
#define ADU_APPNAME "aMuleAdunanzA"
 
76
#define AMULE_ADUNANZA_DIR ADU_APPNAME
59
77
 
60
78
// Mr Hyde: usata per gestione lingue
61
 
// (deve corrispondere al file .pot e ai file .gmo generati)
 
79
// deve corrispondere:
 
80
// - al file .pot e ai file .gmo generati
 
81
// - al primo argomento della macro AC_INIT (o meglio, al lowercase del primo argomento di AC_INIT, vedi file "configure.in")
62
82
#if !defined(PACKAGE_ADUNANZA)
63
 
#define PACKAGE_ADUNANZA "adunanza"
 
83
#define PACKAGE_ADUNANZA "amuleadunanza"
64
84
#endif
65
85
 
66
86
// Mr Hyde: rimosse le define di MOD_VERSION_LONG perche' definite in src/include/common/ClientVersion.h
82
102
// Definizione default del numero di slots
83
103
#define ADUNANZA_DEF_UPSL       8
84
104
// Definizione default banda Adu
85
 
//#define ADUNANZA_BAND_PERC    85
 
105
#define ADUNANZA_BAND_PERC  (85) // Mr Hyde allineamento 3.16, ripartitore banda
 
106
#define ADUNANZA_DEF_BW_EXT  (6) // Mr Hyde allineamento 3.16, ripartitore banda
 
107
 
 
108
const uint32 ADU_MAX_RATIO_KADU_DOWN(3145728); // 3 mega * 1024 KB in mega * 1024 byte in KB
 
109
const uint32 ADUNANZA_MIN_BW_TROLLER(2);
 
110
 
 
111
const bool ADUNANZA_UP_EXT_CHECK(false); // il default per abilitare le impostazioni CUSTOM del ripartitore di banda deve essere false (ovvero: custom DISABILITATO) 
 
112
 
 
113
const unsigned int ADU_EXT_FULL_WAIT_TIME(480); // 8 minuti
 
114
 
86
115
// Definizione connessione automatica
87
116
#define ADUNANZA_AUTO_CONN      1
88
117
// Definizione forzature upload/dl ext 1:1 - Disabilitato di default
94
123
#define ADU_GET_B(v) ((v) & 0x7f)
95
124
 
96
125
// ADU URLS
97
 
#define ADURM_URL              "http://update.adunanza.net/3-15/adu_remote.conf"
 
126
#define ADURM_URL              "http://update.adunanza.net/3-16/adu_remote.conf"
98
127
 
99
128
// Mr Hyde: cambiato su richiesta di Hammon
100
129
#define ADU_SRV_URL            "http://update.adunanza.net/servers.met"
124
153
// notare che l'URL scritto in questo modo NON rispetta il draft per gli URL IRC
125
154
// (dovrebbe avere il carattere "#" dato come %23, ci sto studiando)
126
155
//
127
 
//#define ADU_IRCHELP_URL        "irc://chat.adunanza.net:6667/La_Stalla"
128
 
#define ADU_IRCHELP_URL        "irc://chat.adunanza.net:6667/#La_Stalla"
 
156
// Mr Hyde, 20100125, cambiato l'indirizzo su richiesta di Hammon
 
157
#define ADU_IRCHELP_URL        "irc://chat.adunanza.net:6667/#Linux"
129
158
 
130
159
// Mr Hyde: per default programma IRC (da sistemare per MAC)
131
160
#define ADU_DEFAULT_IRC       "xchat"
132
 
#define ADU_DEFAULT_IRC_FLAGS "--url irc://chat.adunanza.net:6667/#La_Stalla"
 
161
// Mr Hyde, 20100125, cambiato l'indirizzo su richiesta di Hammon
 
162
#define ADU_DEFAULT_IRC_FLAGS "--url irc://chat.adunanza.net:6667/#Linux"
 
163
 
 
164
// Mr Hyde: per pagina da associare a F1
 
165
// Mr Hyde, 20100125, cambiato l'indirizzo su richiesta di Hammon
 
166
#define ADU_WIKI_URL           "http://aduteca.adunanza.net/Amule_AdunanzA"
 
167
 
 
168
// Aggiunto test porte
 
169
#define ADU_PORTTEST_BASE_URL       "http://adutest.adunanza.net/emule_testport/adutest.php?tcp=%d&udp=%d"
133
170
 
134
171
/*
135
172
MAN Milano........................   1.0.0.0/8
176
213
#define MAN_REGGIO_EMILIA 42
177
214
#define MAN_CAGLIARI      51
178
215
 
 
216
class wxString;
 
217
 
179
218
// Funzioni esportate
180
 
extern bool     AduIsFastWebIP(uint32 ip);
181
 
extern bool     AduIsFastWebIP(const wxString& wxip);
182
 
extern bool     AduIsFastWebLANIP(uint32 ip);
183
 
extern bool     AduIsFiber(uint32 ip);
184
 
extern uint32   AduGetTypeBand();
185
 
extern uint32   AduGetMaxUploadSlots(void);
186
 
//extern float  AduGetPercBandwidth(void);
187
 
extern void     AduStartConnection(void);
188
 
extern void     AduUpdate(char *url);
189
 
// KAdu
190
 
extern bool     AduIsValidKaduAddress( uint32 host );
191
 
 
192
 
extern float   calcolaStima( float input_avail, uint32& firstPublish, uint32 publishInterval, uint32 pubkRTK, bool sameIP, uint32 now );
193
 
extern float   normalizzaStima( float avail, uint32 from, uint32 to );
 
219
 
 
220
 
 
221
class CAdunanzAUtilities {
 
222
        public:
 
223
                static inline bool AduIsFastWebLANIP(uint32 ip)
 
224
                {
 
225
                        switch (ip & 0xff) {
 
226
                                case MAN_ROMA:
 
227
                                case MAN_MILANO:
 
228
                                case MAN_MILANO_H_NORD:
 
229
                                case MAN_MILANO_H_SUD:
 
230
                                case MAN_GENOVA:
 
231
                                case MAN_TRIVENETO:
 
232
                                case MAN_BARI:
 
233
                                case MAN_BOLOGNA:
 
234
                                case MAN_NAPOLI:
 
235
                                case MAN_TORINO:
 
236
                                case MAN_REGGIO_EMILIA:
 
237
                                case MAN_TOSCANA:
 
238
                                case MAN_PIEMONTE:
 
239
                                case MAN_VENETO:
 
240
                                case MAN_GROSSETO:
 
241
                                case MAN_SICILIA:
 
242
                                case MAN_ANCONA:
 
243
                                case MAN_CAGLIARI:
 
244
                                case FASTWEB_ROUTERS:
 
245
                                        return true;
 
246
                                default:
 
247
                                        return false;
 
248
                        }
 
249
                }
 
250
 
 
251
 
 
252
                static bool AduIsFastWebIP(uint32 ip)
 
253
                {
 
254
                        if (CAdunanzAUtilities::AduIsFastWebLANIP(ip)) 
 
255
                                return true;
 
256
                        
 
257
                        // match rapido: (ip & mask) == netid
 
258
 
 
259
                        // netid 213.140.0.0/19                 - netid (hex) 0x00008cd5 / mask 0x00e0ffff
 
260
                        if ((ip & 0x00e0ffff) == 0x00008cd5 ||
 
261
                        // netid 213.156.32.0/19                - netid (hex) 0x00209cd5 / mask 0x00e0ffff
 
262
                                        (ip & 0x00e0ffff) == 0x00209cd5 ||
 
263
                        // netid 62.101.64.0/18                 - netid (hex) 0x0040653e / mask 0x00c0ffff
 
264
                                        (ip & 0x00c0ffff) == 0x0040653e ||
 
265
                        // netid 81.208.0.0/17                  -       netid (hex) 0x0000d051 / mask 0x0080ffff
 
266
                                        (ip & 0x0080ffff) == 0x0000d051 ||
 
267
                        // netid 83.103.0.0/17                  - netid (hex) 0x00006753 / mask 0x0080ffff
 
268
                                        (ip & 0x0080ffff) == 0x00006753 ||
 
269
                        // netid 85.18.0.0/16       - netid (hex) 0x00001255 / mask 0x0000ffff
 
270
                                        (ip & 0x0000ffff) == 0x00001255 ||
 
271
                        // netid 89.96.0.0/15       - netid (hex) 0x00006059 / mask 0x0000f7ff
 
272
                                        (ip & 0x0000f7ff) == 0x00006059 ||
 
273
                        // netid 93.32.0.0/11       - netid (hex) 0x0000205d / mask 0x0000e0ff  // Allineamento 3.15b74
 
274
                                        (ip & 0x0000e0ff) == 0x0000205d)
 
275
                                        return true;
 
276
 
 
277
 
 
278
                        return false;
 
279
                }
 
280
                static bool AduIsFastWebIP(const wxString& ipv4string);
 
281
 
 
282
                static bool     AduIsFiber(uint32 ip);
 
283
                static uint32   AduGetTypeBand();
 
284
                //extern float  AduGetPercBandwidth();
 
285
                static void     AduStartConnection();
 
286
                static void     AduUpdate(char *url);
 
287
                // KAdu
 
288
                static bool     AduIsValidKaduAddress( uint32 host );
 
289
 
 
290
 
 
291
#ifndef CLIENT_GUI
 
292
                static uint32 getAllowedUploadDataRate();
 
293
 
 
294
                static float calcolaStima( float input_avail, uint32& firstPublish, uint32 publishInterval, uint32 pubkRTK, bool sameIP, uint32 now );
 
295
                static float normalizzaStima( float avail, uint32 from, uint32 to );
 
296
 
 
297
                static int AduQ();
 
298
                static int ExtQ();
 
299
                static bool AduDebt();
 
300
 
 
301
                static int OLDSetSlots();
 
302
                static int SetSlots();
 
303
                static int TotSlots();
 
304
#if 0           
 
305
                static int ExtSlots();
 
306
#endif
 
307
                
 
308
                static uint32 AduNextClient(int fix = 0);
 
309
                static bool AduMaxTrans();
 
310
                static uint32 AduGetMaxUploadSlots();
 
311
 
 
312
                static void CalcolaRatio(bool bAtMomentNotUsed);
 
313
#endif
 
314
};
194
315
 
195
316
 
196
317
class CAduUploadSlotsManager
244
365
 
245
366
                uint32 next() const;
246
367
 
247
 
                // uint32 nextAndConsume() ;
248
 
 
249
368
                void update(CClientPtrList& uploadingList);
250
369
 
251
 
                void consume(CUpDownClient* pClient);
252
370
};
253
371
 
254
372
 
255
373
 
256
374
 
257
 
// Mr Hyde: NON PIU' USATE BEGIN
258
 
// extern bool  IsAduServer(uint32 CurServer);
259
 
// extern void* AduGetNextAduServer(int value, int& num);
260
 
// Mr Hyde: NON PIU' USATE END
261
 
 
262
 
 
263
 
 
264
 
#ifndef CLIENT_GUI
265
 
uint32 AduNextClient(int fix = 0);
266
 
bool AduMaxTrans(void);
267
 
#endif
268
 
 
269
 
#endif
 
375
#endif
 
376
 
270
377