|
|
/* * $Id: sctpsocket_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 * */ #ifndef SCTPSOCKET_H #define SCTPSOCKET_H #include "tdsystem.h" #include "condition.h" #include "internetaddress.h" #include "sctpassociation.h" #include "sctpchunkarrivalqueue.h" #include <sctp.h> #include <multimap.h> namespace Coral { #define MSG_SHUTDOWN (1 << 30) #define MSG_UNORDERED (1 << 29) #define MSG_UNBUNDLED (1 << 28) /** * This class manages a SCTP socket (SCTP instance). * * @short SCTP Socket * @author Thomas Dreibholz (dreibh@exp-math.uni-essen.de) * @version 1.0 */ class SCTPSocket { // ====== Friend classes ================================================= friend class SCTPSocketMaster; friend class SCTPAssociation; // ====== Constructor/Destructor ========================================= public: /** * Constructor. * * @param hasGlobalQueue true to use a global queue for all associations; false otherwise (default). * @param sctpWait true to wait for success of sctp_shutdown() (default); false otherwise. */ SCTPSocket(const bool hasGlobalQueue = false, const bool sctpWait = true); /** * Destructor. */ ~SCTPSocket(); // ====== SCTP Socket functions ========================================== /** * Get internal instance ID. * * @return Instance ID. */ unsigned short getID() const; /** * Bind socket to local port and address(es). * * @param localPort Local port. * @param noOfInStreams Number of incoming streams. * @param noOfOutStreams Number of outgoing streams. * @param localAddressList NULL-terminated array of local addresses. */ int bind(const unsigned short localPort, const unsigned short noOfInStreams, const unsigned short noOfOutStreams, const SocketAddress** localAddressList); /** * Release socket binding. * * @see bind */ void unbind(); /** * Establish new association. * * @param noOfOutStreams Number of outgoing streams. * @param destinationAddress Destination address. * @param wait true to wait for establishment (default); false otherwise. * @return Association or NULL in case of failure. */ SCTPAssociation* associate(const unsigned short noOfOutStreams, const SocketAddress& destinationAddress, const bool wait = true); /** * Set socket to listen mode: accept new incoming assocations. * * @param backlog Maximum number of incoming connections to accept simultaneously. */ void listen(const unsigned int backlog); /** * Wait for incoming association. * * @param addressArray Reference to store NULL-terminated array of peer addresses. The addresses are allocated automatically and have to be freed using deleteAddressList(). Set NULL to skip creation of the address array. * @param wait true to wait for new association (default); false otherwise. * @return New association or NULL in case of failure. * * @see SocketAddress#deleteAddressList */ SCTPAssociation* accept(SocketAddress*** addressArray = NULL, const bool wait = true); /** * Get socket's 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); // ====== Protected data ================================================= protected: SCTPAssociation* getAssociationForAssociationID(const unsigned int assocID, const bool activeOnly = true); int getErrorCode(const unsigned int assocID); int internalReceive(ChunkArrivalQueue& queue, char* dataBuffer, size_t& dataBufferSize, char* controlBuffer, size_t& controlBufferSize, int& flags, unsigned int& assocID, unsigned short& streamID, unsigned int& protoID, AssociationStatus& status); int internalSend(const char* buffer, const size_t length, const int flags, const unsigned int assocID, const unsigned short streamID, const unsigned int protoID); struct IncomingConnection { IncomingConnection* NextConnection; SCTPAssociation* Association; AssociationStatus Status; }; IncomingConnection* ConnectionRequests; ChunkArrivalQueue GlobalQueue; multimap<unsigned int, SCTPAssociation*> SCTPAssociationList; Condition EstablishCondition; unsigned short InstanceName; unsigned short LocalPort; unsigned short NoOfInStreams; unsigned short NoOfOutStreams; unsigned int NoOfLocalAddresses; unsigned char LocalAddressList[SCTP_MAX_NUM_ADDRESSES][SCTP_MAX_IP_LEN]; bool HasGlobalQueue; bool ServerMode; bool SCTPWait; }; } #endif
Generated by: dreibh@kappes on Fri Aug 17 14:08:47 2001, using kdoc 2.0a53. |