xorp

finder_server.hh

00001 // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*-
00002 // vim:set sts=4 ts=8:
00003 
00004 // Copyright (c) 2001-2011 XORP, Inc and Others
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/finder_server.hh,v 1.20 2008/10/02 21:57:20 bms Exp $
00023 
00024 #ifndef __LIBXIPC_FINDER_SERVER_HH__
00025 #define __LIBXIPC_FINDER_SERVER_HH__
00026 
00027 
00028 
00029 #include "libxorp/xlog.h"
00030 
00031 #include "finder.hh"
00032 #include "finder_constants.hh"
00033 #include "finder_tcp_messenger.hh"
00034 #include "finder_xrl_target.hh"
00035 #include "permits.hh"
00036 #include "sockutil.hh"
00037 
00044 class FinderServer {
00045 public:
00046     typedef list<FinderTcpListener*> Listeners;
00047 
00048 public:
00049 
00053     FinderServer(EventLoop& e, IPv4 default_interface, uint16_t default_port)
00054     throw (InvalidAddress, InvalidPort);
00055 
00059     ~FinderServer();
00060 
00067     bool add_binding(IPv4 addr, uint16_t port)
00068     throw (InvalidAddress, InvalidPort);
00069 
00075     bool remove_binding(IPv4 addr, uint16_t port);
00076 
00080     uint32_t connection_count() const   { return _f.messengers(); }
00081 
00082     IPv4 addr() const { return _listeners.front()->address(); }
00083     uint16_t port() const { return _listeners.front()->port(); }
00084 
00085 protected:
00086     EventLoop&      _e;
00087     Finder      _f;
00088     FinderXrlTarget _fxt;
00089     Listeners       _listeners;
00090 };
00091 
00092 #endif // __LIBXIPC_FINDER_SERVER_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations