/*
    NetQueue.h, Copyright  (c) by Boris Lutz, Claudio Jeker
    Swiss Federal Institute of Technology,
    Computer Engineering and Networks Laboratory.
 
    TOPSY -- A Teachable Operating System.
             Implementation of a tiny and simple
             micro kernel for teaching purposes.
 
    For further information, please visit http://www.tik.ee.ethz.ch/~topsy
 
    This software is provided under the terms of the GNU General Public 
    Licence. A full copy of the GNU GPL is provided in the file COPYING 
    found in the development root of Topsy.
*/
/*
	
    File:                  $Source: /home/ruf/cvs_Topsy/cvs/Topsy/Net/NetQueue.h,v $
    Author(s):             
    Affiliation:           ETH Zuerich, TIK
    Version:               $Revision: 2922 $
    Creation Date:         
    Last Date of Change:   $Date: 2007-03-19 17:48:52 +0100 (Mon, 19 Mär 2007) $      by: $Author: baderma $
 
 
*/


#ifndef _NETQUEUE_H_
#define _NETQUEUE_H_

#include "Error.h"
#include "NetBuf.h"
#include "NetAttr.h"


/* return values */
#define NETQ_FAILED 0
#define NETQ_OK 1

/* queue option types */
#define TYPE_DGRAM 1
#define TYPE_STREAM 2

/* bit masks for read / write type */
#define OOB_DATA  0x4
#define DONT_SEEK 0x8

/* type declarations */
typedef struct NetQueueElemDesc_t* NetQueueElem;

typedef struct NetQueueElemDesc_t
{
  NetBuf		data;
  union {
    NetBuf		oobData;
    NetAttrs	metaData;
  } ext;
  NetQueueElem next;
  NetQueueElem prev;
}
NetQueueElemDesc;

typedef struct NetQueueDesc_t
{
  int			options;
  NetQueueElem first;
  NetQueueElem last;
}
NetQueueDesc;
typedef NetQueueDesc* NetQueue;

/* function prototypes */
NetQueue netQueueNew (int options);
void netQueueFree (NetQueue my);
Error netQueueAdd (NetQueue my, NetBuf data, NetBuf ext);
int netQueueIsEmpty (NetQueue my);
Error netQueuePeek(NetQueue my, NetBuf *data, NetBuf *ext);
Error netQueueGet (NetQueue my, NetBuf *data, NetBuf *ext);
Error netQueueRead (NetQueue my, char* buf, unsigned int *len,
                    NetBuf *ext, int type);


#endif
