|
xorp
|
00001 // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*- 00002 // vim:set sts=4 ts=8: 00003 00004 // Copyright (c) 2001-2009 XORP, Inc. 00005 // 00006 // This program is free software; you can redistribute it and/or modify 00007 // it under the terms of the GNU Lesser General Public License, Version 00008 // 2.1, June 1999 as published by the Free Software Foundation. 00009 // Redistribution and/or modification of this program under the terms of 00010 // any other version of the GNU Lesser General Public License is not 00011 // permitted. 00012 // 00013 // This program is distributed in the hope that it will be useful, but 00014 // WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, 00016 // see the GNU Lesser General Public License, Version 2.1, a copy of 00017 // which can be found in the XORP LICENSE.lgpl file. 00018 // 00019 // XORP, Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; 00020 // http://xorp.net 00021 00022 // $XORP: xorp/libxipc/test_xrl_sender.hh,v 1.9 2008/10/02 21:57:23 bms Exp $ 00023 00024 #ifndef __LIBXIPC_TEST_XRL_SENDER_HH__ 00025 #define __LIBXIPC_TEST_XRL_SENDER_HH__ 00026 00027 class TestSender { 00028 public: 00029 TestSender(EventLoop& eventloop, XrlRouter* xrl_router, 00030 size_t max_xrl_id); 00031 00032 ~TestSender(); 00033 00034 bool done() const; 00035 void print_xrl_sent() const; 00036 void print_xrl_received() const; 00037 void clear(); 00038 void start_transmission(); 00039 void start_transmission_process(); 00040 void send_batch(); 00041 00042 private: 00043 typedef void (TestSender::*CB)(const XrlError& err); 00044 00045 bool transmit_xrl_next(CB cb); 00046 void start_transmission_cb(const XrlError& xrl_error); 00047 void send_next(); 00048 void send_next_cb(const XrlError& xrl_error); 00049 void send_next_start_pipeline(); 00050 void send_next_pipeline(); 00051 void send_next_pipeline_cb(const XrlError& xrl_error); 00052 void send_single(); 00053 void send_single_cb(const XrlError& err); 00054 void end_transmission(); 00055 void end_transmission_cb(const XrlError& xrl_error); 00056 void send_batch_do(unsigned xrls); 00057 void send_batch_cb(const XrlError& xrl_error); 00058 bool send_batch_task(); 00059 00060 EventLoop& _eventloop; 00061 XrlRouter& _xrl_router; 00062 XrlTestXrlsV0p1Client _test_xrls_client; 00063 string _receiver_target; 00064 XorpTimer _start_transmission_timer; 00065 XorpTimer _end_transmission_timer; 00066 XorpTimer _try_again_timer; 00067 XorpTimer _exit_timer; 00068 size_t _max_xrl_id; 00069 size_t _next_xrl_send_id; 00070 size_t _next_xrl_recv_id; 00071 bool _sent_end_transmission; 00072 bool _done; 00073 00074 // Data to send 00075 bool _my_bool; 00076 int32_t _my_int; 00077 IPv4 _my_ipv4; 00078 IPv4Net _my_ipv4net; 00079 IPv6 _my_ipv6; 00080 IPv6Net _my_ipv6net; 00081 Mac _my_mac; 00082 string _my_string; 00083 vector<uint8_t> _my_vector; 00084 00085 // batch state 00086 XorpTask _batch_task; 00087 int _batch_sent; 00088 int _batch_remaining; 00089 int _batch_per_run; 00090 int _batch_size; 00091 unsigned _batch_got; 00092 unsigned _batch_errors; 00093 }; 00094 00095 #endif // __LIBXIPC_TEST_XRL_SENDER_HH__