Source: sctpassociation.h


Annotated List
Files
Globals
Hierarchy
Index
/*
 *  $Id: sctpassociation_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 Association
 *
 */

#ifndef SCTPASSOCIATION_H
#define SCTPASSOCIATION_H


#include "tdsystem.h"
#include "condition.h"
#include "internetaddress.h"
#include "sctpsocket.h"
#include "sctpchunkarrivalqueue.h"


#include <sctp.h>


namespace Coral {


/**
  * This class manages a SCTP assocation. Note: The constructor is protected,
  * a SCTP assocation can be created from an SCTP socket using associate() or
  * accept().
  *
  * @short   SCTP Association
  * @author  Thomas Dreibholz (dreibh@exp-math.uni-essen.de)
  * @version 1.0
  *
  * @see SCTPSocket
  * @see SCTPSocket#associate
  * @see SCTPSocket#accept
  */
class SCTPAssociation
{
   // ====== Friend classes =================================================
   friend class SCTPSocket;
   friend class SCTPConnectionlessSocket;
   friend class SCTPSocketMaster;


   // ====== Destructor =====================================================
   public:
   /**
     * Destructor.
     */
   ~SCTPAssociation();


   // ====== Association functions ==========================================
   /**
     * Get internal association ID.
     *
     * @return Association ID.
     */
   unsigned int getID() const;

   /**
     * Get local addresses.
     *
     * @param addressArray Reference to store NULL-terminated array of local addresses. The addresses are allocated automatically and have to be freed using deleteAddressList().
     * @return true, if addressEntries are sufficient; false otherwise.
     *
     * @see SocketAddress#deleteAddressList
     */
   bool getLocalAddresses(SocketAddress**& addressArray);

   /**
     * Get remote addresses.
     *
     * @param addressArray Reference to store NULL-terminated array of local addresses. The addresses are allocated automatically and have to be freed using deleteAddressList().
     * @return true, if addressEntries are sufficient; false otherwise.
     *
     * @see SocketAddress#deleteAddressList
     */
   bool getRemoteAddresses(SocketAddress**& addressArray);


   /**
     * @param dataBuffer Buffer to store data to.
     * @param dataBufferSize Size of data buffer; this will be overwritten with actual size of data content.
     * @param controlBuffer Buffer to store control data to.
     * @param controlBufferSize Size of control buffer; this will be overwritten with actual size of control content.
     * @param flags Flags; this will be overwritten with actual reception flags.
     * @param streamID Variable to store stream ID to.
     * @param protoID Variable to store protocol ID to.
     * @return error code (0 for success).
     */
   int receive(char*           dataBuffer,
               size_t&         dataBufferSize,
               char*           controlBuffer,
               size_t&         controlBufferSize,
               int&            flags,
               unsigned short& streamID,
               unsigned int&   protoID);

   /**
     * Send data.
     *
     * @param buffer Data to be sent.
     * @param length Length of data to be sent.
     * @param flags Flags.
     * @param streamID Stream ID.
     * @param protoID Protocol ID.
     * @return error code (0 for success).
     */
   int send(const char*          buffer,
            const size_t         length,
            const int            flags,
            const unsigned short streamID,
            const unsigned int   protoID);


   /**
     * Shutdown.
     */
   void shutdown();

   /**
     * Abort.
     */
   void abort();


   // ====== Protected data =================================================
   protected:
   SCTPAssociation(SCTPSocket*        socket,
                   const unsigned int associationID,
                   const bool         sctpWait);


   // ====== Private data ===================================================
   private:
   SCTPSocket*       Socket;
   ChunkArrivalQueue InQueue;
   Condition         EstablishCondition;
   Condition         ShutdownCompleteCondition;

   unsigned int      AssociationID;

   bool              CommunicationUpNotification;
   bool              CommunicationLostNotification;
   bool              ShutdownCompleteNotification;
   bool              IsShuttingDown;
   bool              SCTPWait;
};


}


#endif

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