cSocketRTScheduler.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2005 Andras Varga,
00003 //                    Christian Dankbar, Irene Ruengeler, Michael Tuexen
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (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, see <http://www.gnu.org/licenses/>.
00017 //
00018 
00019 #ifndef __CSOCKETRTSCHEDULER_H__
00020 #define __CSOCKETRTSCHEDULER_H__
00021 
00022 #define WANT_WINSOCK2
00023 
00024 #include <platdep/sockets.h>
00025 #include <platdep/timeutil.h>
00026 #include "INETDefs.h"
00027 #include <omnetpp.h>
00028 
00029 // prevent pcap.h to redefine int8_t,... types on Windows
00030 #include "bsdint.h"
00031 #define HAVE_U_INT8_T
00032 #define HAVE_U_INT16_T
00033 #define HAVE_U_INT32_T
00034 #define HAVE_U_INT64_T
00035 #ifdef HAVE_PCAP
00036 #include <pcap.h>
00037 #endif
00038 #include "ExtFrame_m.h"
00039 
00040 class cSocketRTScheduler : public cScheduler
00041 {
00042     protected:
00043         int fd;
00044 
00045         virtual bool receiveWithTimeout();
00046         virtual int receiveUntil(const timeval& targetTime);
00047     public:
00051         cSocketRTScheduler();
00052 
00056         virtual ~cSocketRTScheduler();
00057 #ifdef HAVE_PCAP
00058         static std::vector<cModule *> modules;
00059         static std::vector<pcap_t *> pds;
00060         static std::vector<int> datalinks;
00061         static std::vector<int> headerLengths;
00062 #endif
00063         static timeval baseTime;
00064 
00068         virtual void startRun();
00069 
00073         virtual void endRun();
00074 
00078         virtual void executionResumed();
00079 
00085         void setInterfaceModule(cModule *mod, const char *dev, const char *filter);
00086 
00090         virtual cMessage *getNextEvent();
00091 
00095         void sendBytes(unsigned char *buf, size_t numBytes, struct sockaddr *from, socklen_t addrlen);
00096 };
00097 
00098 #endif
00099