00001 // 00002 // iodev.hh : Diffusion IO Devices Include File00003 // authors : Fabio Silva00004 //00005 // Copyright (C) 2000-2002 by the University of Southern California00006 // $Id: iodev.hh,v 1.8 2005/09/13 04:53:49 tomh Exp $00007 //00008 // This program is free software; you can redistribute it and/or00009 // modify it under the terms of the GNU General Public License,00010 // version 2, as published by the Free Software Foundation.00011 //00012 // This program is distributed in the hope that it will be useful,00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the00015 // GNU General Public License for more details.00016 //00017 // You should have received a copy of the GNU General Public License along00018 // with this program; if not, write to the Free Software Foundation, Inc.,00019 // 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.00020 //00021 // Linking this file statically or dynamically with other modules is making00022 // a combined work based on this file. Thus, the terms and conditions of00023 // the GNU General Public License cover the whole combination.00024 //00025 // In addition, as a special exception, the copyright holders of this file00026 // give you permission to combine this file with free software programs or00027 // libraries that are released under the GNU LGPL and with code included in00028 // the standard release of ns-2 under the Apache 2.0 license or under00029 // otherwise-compatible licenses with advertising requirements (or modified00030 // versions of such code, with unchanged license). You may copy and00031 // distribute such a system following the terms of the GNU GPL for this00032 // file and the licenses of the other code concerned, provided that you00033 // include the source code of that other code when and as the GNU GPL00034 // requires distribution of source code.00035 //00036 // Note that people who make modified versions of this file are not00037 // obligated to grant this special exception for their modified versions;00038 // it is their choice whether to do so. The GNU General Public License00039 // gives permission to release a modified version without this exception;00040 // this exception also makes it possible to release a modified version00041 // which carries forward this exception.00042 //00043
00044 // This file defines the basic interface between diffusion device00045 // drivers and the Diffusion Core (or the Diffusion Routing Library00046 // API). It provides basic functionality to send and receive packets00047 // and also keeps track of input/output file descriptors that can be00048 // used on select().00049
00050 #ifndef _IODEV_HH_00051 #define _IODEV_HH_00052 00053 #ifdef HAVE_CONFIG_H00054 #include "config.h"00055 #endif // HAVE_CONFIG_H00056 00057 #include <list>00058
00059 #include "header.hh"00060 #include "tools.hh"00061
00062 using namespace std;
00063
00064class DiffusionIO {
00065 public:
00066 DiffusionIO();
00067
00068 virtual ~DiffusionIO(){
00069 // Nothing to do00070 };
00071
00072 virtualvoid addInFDS(fd_set *fds, int *max);
00073 virtualbool hasFD(int fd);
00074 virtualint checkInFDS(fd_set *fds);
00075 virtual DiffPacket recvPacket(int fd) = 0;
00076 virtualvoid sendPacket(DiffPacket p, int len, int dst) = 0;
00077
00078 protected:
00079 int num_out_descriptors_;
00080 int num_in_descriptors_;
00081 int max_in_descriptor_;
00082 list<int> in_fds_;
00083 list<int> out_fds_;
00084 };
00085
00086 typedeflist<DiffusionIO *>DeviceList;
00087
00088 #endif // !_IODEV_HH_