📄 macedon_connection.h
字号:
//Copyright (c) 2004, Charles Killian, Adolfo Rodriguez, Dejan Kostic, Sooraj Bhat, and Amin Vahdat//All rights reserved.////Redistribution and use in source and binary forms, with or without//modification, are permitted provided that the following conditions are met://// * Redistributions of source code must retain the above copyright// notice, this list of conditions and the following disclaimer.// * Redistributions in binary form must reproduce the above copyright// notice, this list of conditions and the following disclaimer in// the documentation and/or other materials provided with the// distribution.// * Neither the names of Duke University nor The University of// California, San Diego, nor the names of its contributors// may be used to endorse or promote products derived from// this software without specific prior written permission.////THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"//AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE//IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE//DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE//FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL//DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR//SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,//OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE//USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.#ifndef __macedon_connection#define __macedon_connection// Adolfo Rodriguez// transport-independent macedon "connection", one per neighbor#include <sys/types.h>#include <netinet/in.h> #include <sys/socket.h>#include "bandwidth_time_filter.h"#include "bandwidth_filter.h"#define NEW_BW_FILTERclass macedon_transport;class macedon_connection;class macedon_transport_work{public: macedon_transport_work ( ); virtual ~macedon_transport_work ( ); macedon_connection *neighbor; unsigned char * stuff; int tot_size; unsigned char * running_buffer; int running_size;};class macedon_transport_send_work : public macedon_transport_work{ public: macedon_transport_send_work ( ); ~macedon_transport_send_work ( ); class macedon_transport_send_work *next; };class macedon_transport_recv_work : public macedon_transport_work{ public: macedon_transport_recv_work ( ); ~macedon_transport_recv_work ( ); int field_bytes; // the following two fields must remain in order always int header_size; int data_size;};enum MACEDON_CONNECTION_STATUS{ MACEDON_CONNECTION_STATUS_preconnecting, MACEDON_CONNECTION_STATUS_connecting, MACEDON_CONNECTION_STATUS_connected, MACEDON_CONNECTION_STATUS_disconnecting, MACEDON_CONNECTION_STATUS_disconnected,};class macedon_connection{ public: macedon_connection (int destination, int index, int port, macedon_transport *intrans); virtual ~macedon_connection( ); inline int macedon_connection::get_destination () { return neigh_socket_address.sin_addr.s_addr; } int close_descriptor (); void queue_back(macedon_transport_send_work *); void queue_front(macedon_transport_send_work *); macedon_transport_send_work *pop_front(); macedon_transport *trans; class macedon_connection *next; MACEDON_CONNECTION_STATUS status; int index; int descriptor; double time_last_used; double time_connect_initiated; int virtual_time_initiated; struct sockaddr_in neigh_socket_address; int send_queue_items; macedon_transport_send_work * send_queue; macedon_transport_send_work * send_queue_last; macedon_transport_recv_work *recv_in_progress; // statistics int items_sent; int items_received; int items_rejected; int items_queued; int bytes_sent; int bytes_received;#ifdef NEW_BW_FILTER bandwidth_time_filter bandwidth; void set_filter(const bandwidth_time_filter& filter); bandwidth_time_filter& get_filter();#else bandwidth_filter bandwidth; void set_filter(const bandwidth_filter& filter); bandwidth_filter& get_filter();#endif};#endif //__macedon_connection
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -