• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/queue/priqueue.h

00001 
00002 /* -*-  Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
00003 /*
00004  * Copyright (c) 1997 Regents of the University of California.
00005  * All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions
00009  * are met:
00010  * 1. Redistributions of source code must retain the above copyright
00011  *    notice, this list of conditions and the following disclaimer.
00012  * 2. Redistributions in binary form must reproduce the above copyright
00013  *    notice, this list of conditions and the following disclaimer in the
00014  *    documentation and/or other materials provided with the distribution.
00015  * 3. All advertising materials mentioning features or use of this software
00016  *    must display the following acknowledgement:
00017  *      This product includes software developed by the Computer Systems
00018  *      Engineering Group at Lawrence Berkeley Laboratory.
00019  * 4. Neither the name of the University nor of the Laboratory may be used
00020  *    to endorse or promote products derived from this software without
00021  *    specific prior written permission.
00022  *
00023  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00024  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00025  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00026  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00027  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00028  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00029  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00030  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00032  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00033  * SUCH DAMAGE.
00034  */
00035 /* Ported from CMU/Monarch's code, nov'98 -Padma.*/
00036 /* -*- c++ -*-
00037    priqueue.h
00038    
00039    A simple priority queue with a remove packet function
00040 */
00041 #ifndef _priqueue_h
00042 #define _priqueue_h
00043 
00044 #include "object.h"
00045 #include "queue.h"
00046 #include "drop-tail.h"
00047 #include "packet.h"
00048 #include "lib/bsd-list.h"
00049 
00050 class PriQueue;
00051 typedef int (*PacketFilter)(Packet *, void *);
00052 
00053 LIST_HEAD(PriQueue_List, PriQueue);
00054 
00055 class PriQueue : public DropTail {
00056 public:
00057         PriQueue();
00058 
00059         int     command(int argc, const char*const* argv);
00060         void    recv(Packet *p, Handler *h);
00061 
00062         void    recvHighPriority(Packet *, Handler *);
00063         // insert packet at front of queue
00064 
00065         void filter(PacketFilter filter, void * data);
00066         // apply filter to each packet in queue, 
00067         // - if filter returns 0 leave packet in queue
00068         // - if filter returns 1 remove packet from queue
00069 
00070         Packet* filter(nsaddr_t id);
00071 
00072         void    Terminate(void);
00073 private:
00074         int Prefer_Routing_Protocols;
00075  
00076         /*
00077          * A global list of Interface Queues.  I use this list to iterate
00078          * over all of the queues at the end of the simulation and flush
00079          * their contents. - josh
00080          */
00081 public:
00082         LIST_ENTRY(PriQueue) link;
00083         static struct PriQueue_List prhead;
00084 };
00085 
00086 #endif /* !_priqueue_h */

Generated on Tue Aug 10 2010 16:16:08 for ns-2.33 by  doxygen 1.7.1