reSIProcate/DialogUsageManager  9694
KeepAliveManager.hxx
Go to the documentation of this file.
00001 #ifndef RESIP_KEEPALIVE_MANAGER_HXX
00002 #define RESIP_KEEPALIVE_MANAGER_HXX
00003 
00004 #include <map>
00005 #include "resip/stack/Tuple.hxx"
00006 
00007 namespace resip 
00008 {
00009 
00010 class KeepAliveTimeout;
00011 class KeepAlivePongTimeout;
00012 class DialogUsageManager;
00013 
00014 class KeepAliveManager
00015 {
00016    public:
00017       // Defaults to 10000ms (10s) as specified in RFC5626 section 4.4.1 
00018       static int mKeepAlivePongTimeoutMs;  // ?slg? move to Profile setting?
00019 
00020       struct NetworkAssociationInfo
00021       {
00022             int refCount;
00023             int keepAliveInterval;  // In seconds
00024             int id;
00025             bool supportsOutbound;
00026             bool pongReceivedForLastPing;
00027       };
00028 
00029       // .slg.  We track unique Network Associations per transport transport type, transport family, 
00030       //        target ip addr, target port, and source/transport flow key
00031       //        This means that if we have two different TCP connections to the same destination, 
00032       //        each originating from a different NIC, then we will send keepalives on each separately.
00033       //        For UDP, this is not currently the case, when the transport is bound to any interface
00034       //        (ie. 0.0.0.0), as the flow key will be same regardless of the source interface used to
00035       //        send the UDP message - fixing this for UDP remains an outstanding item.
00036       typedef std::map<Tuple, NetworkAssociationInfo, Tuple::FlowKeyCompare> NetworkAssociationMap;
00037 
00038       KeepAliveManager() : mCurrentId(0) {}
00039       virtual ~KeepAliveManager() {}
00040       void setDialogUsageManager(DialogUsageManager* dum) { mDum = dum; }
00041       virtual void add(const Tuple& target, int keepAliveInterval, bool targetSupportsOutbound);
00042       virtual void remove(const Tuple& target);
00043       virtual void process(KeepAliveTimeout& timeout);
00044       virtual void process(KeepAlivePongTimeout& timeout);
00045       virtual void receivedPong(const Tuple& flow);
00046 
00047    protected:
00048       DialogUsageManager* mDum;
00049       NetworkAssociationMap mNetworkAssociations;
00050       unsigned int mCurrentId;
00051 };
00052 
00053 }
00054 
00055 
00056 #endif
00057 
00058 /* ====================================================================
00059  * The Vovida Software License, Version 1.0 
00060  * 
00061  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00062  * 
00063  * Redistribution and use in source and binary forms, with or without
00064  * modification, are permitted provided that the following conditions
00065  * are met:
00066  * 
00067  * 1. Redistributions of source code must retain the above copyright
00068  *    notice, this list of conditions and the following disclaimer.
00069  * 
00070  * 2. Redistributions in binary form must reproduce the above copyright
00071  *    notice, this list of conditions and the following disclaimer in
00072  *    the documentation and/or other materials provided with the
00073  *    distribution.
00074  * 
00075  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00076  *    and "Vovida Open Communication Application Library (VOCAL)" must
00077  *    not be used to endorse or promote products derived from this
00078  *    software without prior written permission. For written
00079  *    permission, please contact vocal@vovida.org.
00080  *
00081  * 4. Products derived from this software may not be called "VOCAL", nor
00082  *    may "VOCAL" appear in their name, without prior written
00083  *    permission of Vovida Networks, Inc.
00084  * 
00085  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00086  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00087  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00088  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00089  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00090  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00091  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00092  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00093  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00094  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00095  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00096  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00097  * DAMAGE.
00098  * 
00099  * ====================================================================
00100  * 
00101  * This software consists of voluntary contributions made by Vovida
00102  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00103  * Inc.  For more information on Vovida Networks, Inc., please see
00104  * <http://www.vovida.org/>.
00105  *
00106  */