Source: sctpchunkarrivalqueue.h
|
|
|
|
/*
* $Id: sctpchunkarrivalqueue_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: Chunk Arrival Queue
*
*/
#ifndef CHUNKARRIVALQUEUE_H
#define CHUNKARRIVALQUEUE_H
#include "tdsystem.h"
#include "condition.h"
#include "sctp.h"
namespace Coral {
/**
* Association status.
*
* @short Association Status
* @author Thomas Dreibholz (dreibh@exp-math.uni-essen.de)
* @version 1.0
*/
struct AssociationStatus
{
/**
* Association ID.
*/
unsigned int AssocID;
/**
* Stream ID.
*/
unsigned short StreamID;
/**
* Remote port.
*/
unsigned short RemotePort;
/**
* Number of remote addresses.
*/
unsigned short RemoteAddresses;
/**
* Remote addresses.
*/
char RemoteAddress[SCTP_MAX_NUM_ADDRESSES][SCTP_MAX_IP_LEN];
/**
* SCTP Association Status.
*/
SCTP_Association_Status Status;
/**
* SCTP Path Status for each remote address.
*/
SCTP_Path_Status PathStatus[SCTP_MAX_NUM_ADDRESSES];
};
/**
* Association control data.
*
* @short Association Control Data
* @author Thomas Dreibholz (dreibh@exp-math.uni-essen.de)
* @version 1.0
*/
struct AssociationControlData
{
/**
* Control data types.
*/
enum AssociationControlDataType {
ACDT_Unknown = 0,
ACDT_CommunicationUp = 1,
ACDT_Restart = 2,
ACDT_NetworkStatusChange = 3,
ACDT_CommunicationError = 4,
ACDT_SendFailure = 5,
ACDT_CommunicationLost = 6,
ACDT_ShutdownComplete = 7
};
/**
* Type of control data.
*/
unsigned int Type;
};
/**
* This class is a queue for SCTP Data Arrive notification data.
*
* @short Chunk Arrival Queue
* @author Thomas Dreibholz (dreibh@exp-math.uni-essen.de)
* @version 1.0
*/
class ChunkArrivalQueue
{
// ====== Constructor/Destructor =========================================
public:
/**
* Constructor.
*/
ChunkArrivalQueue();
/**
* Destructor.
*/
~ChunkArrivalQueue();
// ====== Queuing functions ==============================================
/**
* Add chunk to tail of queue. Note: The controlData pointer itself is
* stored. No copy will be made!
*
* @param assocID Association ID.
* @param streamID Stream ID.
* @param protoID Protocol ID.
* @param length Length of chunk.
* @param unordered Unordered flag.
* @param controlData Pointer to control data.
* @param controlDataLength Length of control data.
* @param status Association status.
* @return true, if add was successful; false otherwise (out of memory).
*/
bool addChunk(const unsigned int assocID,
const unsigned short streamID,
const unsigned int protoID,
const size_t length,
const unsigned int unordered,
AssociationControlData* controlData,
const size_t controlDataLength,
const AssociationStatus& status);
/**
* Add chunk to top of queue. Note: The controlData pointer itself is
* stored. No copy will be made!
*
* @param assocID Association ID.
* @param streamID Stream ID.
* @param protoID Protocol ID.
* @param length Length of chunk.
* @param unordered Unordered flag.
* @param controlData Pointer to control data.
* @param controlDataLength Length of control data.
* @param status Association status.
* @return true, if push was successful; false otherwise (out of memory).
*/
bool pushChunk(const unsigned int assocID,
const unsigned short streamID,
const unsigned int protoID,
const size_t length,
const unsigned int unordered,
AssociationControlData* controlData,
const size_t controlDataLength,
const AssociationStatus& status);
/**
* Get chunk from top of queue and remove it. Note: The control data
* has to be freed by the user of this function!
*
* @param assocID Reference to store Association ID.
* @param streamID Reference to store Stream ID.
* @param protoID Reference to store Protocol ID.
* @param length Reference to store Length of chunk.
* @param unordered Reference to store Unordered flag.
* @param controlData Reference to store Pointer to control data.
* @param controlDataLength Reference to store Length of control data.
* @param status Reference to store Association status.
* @return true, if get was successful; false otherwise (queue is empty).
*/
bool getChunk(unsigned int& assocID,
unsigned short& streamID,
unsigned int& protoID,
size_t& length,
unsigned int& unordered,
AssociationControlData*& controlData,
size_t& controlDataLength,
AssociationStatus& status);
/**
* Wait for new chunk.
*/
void waitForChunk();
/**
* Signalize, that new chunk has arrived.
*/
void signal();
/**
* Flush queue.
*/
void flush();
// ====== Private data ===================================================
private:
struct Chunk
{
Chunk* NextChunk;
unsigned int AssociationID;
unsigned short StreamID;
unsigned int ProtoID;
unsigned int Unordered;
size_t Length;
size_t ControlDataLength;
AssociationControlData* ControlData;
AssociationStatus Status;
};
Chunk* FirstChunk;
Chunk* LastChunk;
Condition DataArriveCondition;
};
}
#endif
Generated by: dreibh@kappes on Fri Aug 17 14:08:47 2001, using kdoc 2.0a53. |