xorp

xrl_port_io.hh

00001 // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*-
00002 
00003 // Copyright (c) 2001-2011 XORP, Inc and Others
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License, Version 2, June
00007 // 1991 as published by the Free Software Foundation. Redistribution
00008 // and/or modification of this program under the terms of any other
00009 // version of the GNU General Public License is not permitted.
00010 // 
00011 // This program is distributed in the hope that it will be useful, but
00012 // WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details,
00014 // see the GNU General Public License, Version 2, a copy of which can be
00015 // found in the XORP LICENSE.gpl file.
00016 // 
00017 // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA;
00018 // http://xorp.net
00019 
00020 // $XORP: xorp/rip/xrl_port_io.hh,v 1.17 2008/10/02 21:58:18 bms Exp $
00021 
00022 #ifndef __XRL_PORT_IO_HH__
00023 #define __XRL_PORT_IO_HH__
00024 
00025 
00026 #include "libxorp/ipv4.hh"
00027 #include "libxorp/ipv6.hh"
00028 #include "libxorp/safe_callback_obj.hh"
00029 #include "libxorp/service.hh"
00030 #include "port_io.hh"
00031 
00032 class XrlError;
00033 class XrlRouter;
00034 
00035 template <typename A>
00036 class XrlPortIO
00037     : public PortIOBase<A>, public ServiceBase, public CallbackSafeObject
00038 {
00039 public:
00040     typedef A           Addr;
00041     typedef PortIOUserBase<A>   PortIOUser;
00042 public:
00043     XrlPortIO(XrlRouter&    xr,
00044           PortIOUser&   port,
00045           const string&     ifname,
00046           const string& vifname,
00047           const Addr&   addr);
00048 
00057     int startup();
00058 
00066     int shutdown();
00067 
00079     bool send(const Addr&       dst_addr,
00080           uint16_t          dst_port,
00081           const vector<uint8_t>&    rip_packet);
00082 
00086     bool pending() const;
00087 
00091     const string& socket_server() const     { return _ss; }
00092 
00093     const string& socket_id() const     { return _sid; }
00094 
00095 private:
00096     bool startup_socket();
00097 
00098     bool request_open_bind_socket();
00099     void open_bind_socket_cb(const XrlError& xe, const string* psid);
00100 
00101     bool request_ttl();
00102     void ttl_cb(const XrlError& xe);
00103 
00104     bool request_no_loop();
00105     void no_loop_cb(const XrlError& xe);
00106 
00107     bool request_socket_join();
00108     void socket_join_cb(const XrlError& xe);
00109 
00110     bool request_socket_leave();
00111     void socket_leave_cb(const XrlError& xe);
00112 
00113     void send_cb(const XrlError& xe);
00114 
00115 protected:
00116     XrlRouter&  _xr;
00117     string  _ss;            // Socket Server Target Name
00118     string  _sid;           // Unicast Socket id
00119     bool    _pending;
00120 };
00121 
00122 #endif // __XRL_PORT_IO_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations