00001 /* 00002 Copyright (c) 1997, 1998 Carnegie Mellon University. All Rights 00003 Reserved. 00004 00005 Permission to use, copy, modify, and distribute this 00006 software and its documentation is hereby granted (including for 00007 commercial or for-profit use), provided that both the copyright notice and this permission notice appear in all copies of the software, derivative works, or modified versions, and any portions thereof, and that both notices appear in supporting documentation, and that credit is given to Carnegie Mellon University in all publications reporting on direct or indirect use of this code or its derivatives. 00008 00009 ALL CODE, SOFTWARE, PROTOCOLS, AND ARCHITECTURES DEVELOPED BY THE CMU 00010 MONARCH PROJECT ARE EXPERIMENTAL AND ARE KNOWN TO HAVE BUGS, SOME OF 00011 WHICH MAY HAVE SERIOUS CONSEQUENCES. CARNEGIE MELLON PROVIDES THIS 00012 SOFTWARE OR OTHER INTELLECTUAL PROPERTY IN ITS ``AS IS'' CONDITION, 00013 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 00014 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00015 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 00016 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00017 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00018 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 00019 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00020 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 00021 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE OR 00022 INTELLECTUAL PROPERTY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00023 DAMAGE. 00024 00025 Carnegie Mellon encourages (but does not require) users of this 00026 software or intellectual property to return any improvements or 00027 extensions that they make, and to grant Carnegie Mellon the rights to redistribute these changes without encumbrance. 00028 00029 The AODV code developed by the CMU/MONARCH group was optimized and tuned by Samir Das and Mahesh Marina, University of Cincinnati. The work was partially done in Sun Microsystems. 00030 00031 */ 00032 00033 00034 #ifndef __aodv_rqueue_h__ 00035 #define __aodv_rqueue_h_ 00036 00037 //#include <packet.h> 00038 #include <ip.h> 00039 #include <agent.h> 00040 00041 /* 00042 * The maximum number of packets that we allow a routing protocol to buffer. 00043 */ 00044 #define AODV_RTQ_MAX_LEN 64 // packets 00045 00046 /* 00047 * The maximum period of time that a routing protocol is allowed to buffer 00048 * a packet for. 00049 */ 00050 #define AODV_RTQ_TIMEOUT 30 // seconds 00051 00052 class aodv_rqueue : public Connector { 00053 public: 00054 aodv_rqueue(); 00055 00056 void recv(Packet *, Handler*) { abort(); } 00057 00058 void enque(Packet *p); 00059 00060 inline int command(int argc, const char * const* argv) 00061 { return Connector::command(argc, argv); } 00062 00063 /* 00064 * Returns a packet from the head of the queue. 00065 */ 00066 Packet* deque(void); 00067 00068 /* 00069 * Returns a packet for destination "D". 00070 */ 00071 Packet* deque(nsaddr_t dst); 00072 /* 00073 * Finds whether a packet with destination dst exists in the queue 00074 */ 00075 char find(nsaddr_t dst); 00076 00077 private: 00078 Packet* remove_head(); 00079 void purge(void); 00080 void findPacketWithDst(nsaddr_t dst, Packet*& p, Packet*& prev); 00081 bool findAgedPacket(Packet*& p, Packet*& prev); 00082 void verifyQueue(void); 00083 00084 Packet *head_; 00085 Packet *tail_; 00086 00087 int len_; 00088 00089 int limit_; 00090 double timeout_; 00091 00092 }; 00093 00094 #endif /* __aodv_rqueue_h__ */
1.3.3