~ubuntu-branches/debian/experimental/libtorrent/experimental

« back to all changes in this revision

Viewing changes to src/torrent/connection_manager.h

  • Committer: Bazaar Package Importer
  • Author(s): Jose Luis Rivas
  • Date: 2007-03-31 10:31:05 UTC
  • mto: (4.1.4 gutsy) (6.2.1 squeeze) (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20070331103105-jzpp1rml6ud0ff75
Tags: upstream-0.11.4
ImportĀ upstreamĀ versionĀ 0.11.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
#ifndef LIBTORRENT_CONNECTION_MANAGER_H
40
40
#define LIBTORRENT_CONNECTION_MANAGER_H
41
41
 
42
 
#include <inttypes.h>
43
42
#include <sys/socket.h>
44
43
#include <arpa/inet.h>
45
44
#include <netinet/in.h>
46
45
#include <netinet/in_systm.h>
47
46
#include <netinet/ip.h>
 
47
#include <sigc++/connection.h>
 
48
#include <sigc++/signal.h>
48
49
#include <sigc++/slot.h>
49
50
 
50
 
class sockaddr;
 
51
#include <torrent/common.h>
51
52
 
52
53
namespace torrent {
53
54
 
54
 
// Internal.
55
 
class Listen;
56
 
 
57
 
class ConnectionManager {
 
55
class LIBTORRENT_EXPORT ConnectionManager {
58
56
public:
59
57
  typedef uint32_t                              size_type;
60
58
  typedef uint16_t                              port_type;
74
72
  static const priority_type iptos_mincost     = iptos_throughput;
75
73
#endif
76
74
 
 
75
  static const uint32_t encryption_none             = 0;
 
76
  static const uint32_t encryption_allow_incoming   = (1 << 0);
 
77
  static const uint32_t encryption_try_outgoing     = (1 << 1);
 
78
  static const uint32_t encryption_require          = (1 << 2);
 
79
  static const uint32_t encryption_require_RC4      = (1 << 3);
 
80
  static const uint32_t encryption_enable_retry     = (1 << 4);
 
81
  static const uint32_t encryption_prefer_plaintext = (1 << 5);
 
82
 
 
83
  // Internal to libtorrent.
 
84
  static const uint32_t encryption_use_proxy        = (1 << 6);
 
85
 
 
86
  enum {
 
87
    handshake_incoming           = 1,
 
88
    handshake_outgoing           = 2,
 
89
    handshake_outgoing_encrypted = 3,
 
90
    handshake_outgoing_proxy     = 4,
 
91
    handshake_success            = 5,
 
92
    handshake_dropped            = 6,
 
93
    handshake_failed             = 7,
 
94
    handshake_retry_plaintext    = 8,
 
95
    handshake_retry_encrypted    = 9
 
96
  };
 
97
 
 
98
  typedef sigc::slot4<void, const sockaddr*, int, int, const HashString*>   slot_handshake_type;
 
99
  typedef sigc::signal4<void, const sockaddr*, int, int, const HashString*> signal_handshake_type;
 
100
 
77
101
  ConnectionManager();
78
102
  ~ConnectionManager();
79
103
  
101
125
  uint32_t            receive_buffer_size() const             { return m_receiveBufferSize; }
102
126
  void                set_receive_buffer_size(uint32_t s);
103
127
 
 
128
  uint32_t            encryption_options()                    { return m_encryptionOptions; }
 
129
  void                set_encryption_options(uint32_t options); 
 
130
 
104
131
  // Propably going to have to make m_bindAddress a pointer to make it
105
132
  // safe.
106
133
  //
113
140
  const sockaddr*     local_address() const                   { return m_localAddress; }
114
141
  void                set_local_address(const sockaddr* sa);
115
142
 
 
143
  const sockaddr*     proxy_address() const                   { return m_proxyAddress; }
 
144
  void                set_proxy_address(const sockaddr* sa);
 
145
 
116
146
  uint32_t            filter(const sockaddr* sa);
117
147
  void                set_filter(const slot_filter_type& s)   { m_slotFilter = s; }
118
148
 
119
149
  bool                listen_open(port_type begin, port_type end);
120
150
  void                listen_close();  
121
151
 
 
152
  signal_handshake_type& signal_handshake_log()                          { return m_signalHandshakeLog; }
 
153
  sigc::connection       set_signal_handshake_log(slot_handshake_type s) { return m_signalHandshakeLog.connect(s); }
 
154
 
122
155
  // Since trackers need our port number, it doesn't get cleared after
123
156
  // 'listen_close()'. The client may change the reported port number,
124
157
  // but do note that it gets overwritten after 'listen_open(...)'.
138
171
  priority_type       m_priority;
139
172
  uint32_t            m_sendBufferSize;
140
173
  uint32_t            m_receiveBufferSize;
 
174
  int                 m_encryptionOptions;
141
175
 
142
176
  sockaddr*           m_bindAddress;
143
177
  sockaddr*           m_localAddress;
 
178
  sockaddr*           m_proxyAddress;
144
179
 
145
180
  Listen*             m_listen;
146
181
  port_type           m_listenPort;
147
182
 
148
 
  slot_filter_type    m_slotFilter;
 
183
  slot_filter_type      m_slotFilter;
 
184
  signal_handshake_type m_signalHandshakeLog;
149
185
};
150
186
 
151
187
}