NETWORK ATTACKS FRAMEWORK  1.0.0
A NETwork Attacks framework. Making network attacks impact evaluation easier!
NA_packet_queue_omnet.h
Go to the documentation of this file.
00001 /*****************************************************************************
00002  *
00003  * Copyright (C) 2001 Uppsala University & Ericsson AB.
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  *
00019  * Authors: Erik Nordstr�m, <erik.nordstrom@it.uu.se>
00020  *
00021  *****************************************************************************/
00022 #ifndef NA_PACKET_QUEUE_H
00023 #define NA_PACKET_QUEUE_H
00024 
00025 #ifndef NS_NO_GLOBALS
00026 
00027 #define MAX_QUEUE_LENGTH 512
00028 #define MAX_QUEUE_TIME 10000 /* Maximum time packets can be queued (ms) */
00029 #define GARBAGE_COLLECT_TIME 1000 /* Interval between running the
00030 * garbage collector (ms) */
00031 #include "NA_aodv-uu/NA_defs_aodv.h"
00032 #include "NA_aodv-uu/NA_list.h"
00033 
00034 /* Verdicts for queued packets: */
00035 enum
00036 {
00037     PQ_DROP = 0,
00038     PQ_SEND = 1,
00039     PQ_ENC_SEND = 2
00040 };
00041 #ifndef AODV_USE_STL
00042 struct q_pkt
00043 {
00044     list_t l;
00045     struct in_addr  dest_addr;
00046     struct timeval q_time;
00047     cPacket *p;
00048 };
00049 
00050 struct packet_queue
00051 {
00052     list_t head;
00053     unsigned int len;
00054     struct timer garbage_collect_timer;
00055     unsigned int length() { return len; }
00056 };
00057 #else
00058 struct q_pkt
00059 {
00060     struct in_addr  dest_addr;
00061     struct timeval q_time;
00062     cPacket *p;
00063 };
00064 
00065 struct packet_queue
00066 {
00067     std::vector<q_pkt*> pkQueue;
00068     struct timer garbage_collect_timer;
00069     unsigned int length() { return pkQueue.size(); }
00070 };
00071 
00072 #endif
00073 
00074 #endif              /* NS_NO_GLOBALS */
00075 
00076 #ifndef NS_NO_DECLARATIONS
00077 struct packet_queue PQ;
00078 void packet_queue_add(cPacket * p, struct in_addr dest_addr);
00079 void packet_queue_init();
00080 void packet_queue_destroy();
00081 int packet_queue_set_verdict(struct in_addr dest_addr, int verdict);
00082 int packet_queue_garbage_collect(void);
00083 
00084 #endif              /* NS_NO_DECLARATIONS */
00085 
00086 #endif
 All Classes Files Functions Variables Typedefs Enumerator Defines