Source: sctpsocketmaster.h


Annotated List
Files
Globals
Hierarchy
Index
/*
 *  $Id: sctpsocketmaster_h.html,v 1.2 2001/08/17 12:07:32 dreibh Exp $
 *
 * SCTP implementation according to RFC 2960.
 * Copyright (C) 1999-2001 by Thomas Dreibholz
 *
 * Realized in co-operation between Siemens AG
 * and University of Essen, Institute of Computer Networking Technology.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * There are two mailinglists available at www.sctp.de which should be used for
 * any discussion related to this implementation.
 *
 * Contact: discussion@sctp.de
 *          dreibh@exp-math.uni-essen.de
 *
 * Purpose: SCTP Socket Master
 *
 */

#ifndef SCTPSOCKETMASTER_H
#define SCTPSOCKETMASTER_H


#include "tdsystem.h"
#include "thread.h"
#include "sctpsocket.h"
#include "sctpchunkarrivalqueue.h"


#include <sctp.h>
#include <multimap.h>
#include <set.h>


namespace Coral {


/**
  * This class manages the interaction between the SCTP Socket class and the
  * userland SCTP implementation. It is implemented as a singleton and
  * automatically instantiated at program startup.
  *
  * @short   SCTP Socket Master
  * @author  Thomas Dreibholz (dreibh@exp-math.uni-essen.de)
  * @version 1.0
  */
class SCTPSocketMaster : public Thread
{
   // ====== Friend classes =================================================
   friend class SCTPSocket;
   friend class SCTPConnectionlessSocket;
   friend class SCTPAssociation;


   // ====== Constructor/Destructor =========================================
   public:
   /**
     * Constructor.
     */
   SCTPSocketMaster();

   /**
     * Destructor.
     */
   ~SCTPSocketMaster();


   // ====== Lock/unlock ====================================================
   /**
     * Lock the SCTP implementation for exclusive access. This includes
     * Thread's critical section lock.
     */
   inline void lock();

   /**
     * Unlock the SCTP implementation. This includes
     * Thread's critical section lock.
     */
   inline void unlock();


   // ====== Public data ====================================================
   public:
   /**
     * Result of sctp_initLibrary() call. If not 0, the SCTP initialization
     * failed.
     */
   static int InitializationResult;


   // ====== Protected data =================================================
   protected:
   static SCTPSocketMaster                       MasterInstance;
   static cardinal                               LockLevel;
   static SCTP_ulpCallbacks                      SCTPCallbacks;
   static multimap<unsigned short, SCTPSocket*>  SCTPSocketList;
   static set<unsigned short>                    ClosingSockets;
   static multimap<unsigned int, unsigned short> ClosingAssociations;
   static card64                                 LastGarbageCollection;
   static cardinal                               OldCancelState;


   static SCTPSocket* getSocketForAssociationID(const unsigned int assocID);
   static void delayedDeleteAssociation(const unsigned short instanceID,
                                        const unsigned int assocID);
   static void delayedDeleteSocket(const unsigned short instanceID);


   // ====== Private data ===================================================
   private:
   void run();
   static void lock(void* data);
   static void unlock(void* data);

   static void clearAssociationStatus(AssociationStatus& status);
   static bool getAssociationStatus(const unsigned int assocID,
                                    const unsigned int streamID,
                                    AssociationStatus& status);

   static void dataArriveNotif(unsigned int assocID,
                               unsigned int streamID,
                               unsigned int len,
                               unsigned int protoID,
                               unsigned int unordered,
                               void*        ulpDataPtr);
   static void networkStatusChangeNotif(unsigned int   assocID,
                                        short          destAddrIndex,
                                        unsigned short newState,
                                        void*          ulpDataPtr);
   static void* communicationUpNotif(unsigned int   assocID,
                                     unsigned short status,
                                     int            noOfDestinations,
                                     unsigned short noOfInStreams,
                                     unsigned short noOfOutStreams,
                                     void*          dummy);
   static void communicationLostNotif(unsigned int   assocID,
                                      unsigned short status,
                                      void*          ulpDataPtr);
   static void communicationErrorNotif(unsigned int   assocID,
                                       unsigned short status,
                                       void*          dummy);
   static void sendFailureNotif(unsigned int   assocID,
                                unsigned char* unsent_data,
                                unsigned int   dataLength,
                                unsigned int*  context,
                                void*          dummy);
   static void restartNotif(unsigned int assocID, void* ulpDataPtr);
   static void shutdownCompleteNotif(unsigned int assocID, void* ulpDataPtr);

   static bool associationGarbageCollection(const unsigned int assocID,
                                            const bool         sendAbort);
   static void socketGarbageCollection();
};


}


#include "sctpsocketmaster.icc"


#endif

Generated by: dreibh@kappes on Fri Aug 17 14:08:47 2001, using kdoc 2.0a53.