• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/emulate/tap.h

00001 /*
00002  * Copyright (c) 1997, 1998 The Regents of the University of California.
00003  * All rights reserved.
00004  * 
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 3. All advertising materials mentioning features or use of this software
00014  *    must display the following acknowledgement:
00015  *      This product includes software developed by the MASH Research
00016  *      Group at the University of California, Berkeley.
00017  * 4. Neither the name of the University nor of the Research Group may be used
00018  *    to endorse or promote products derived from this software without
00019  *    specific prior written permission.
00020  * 
00021  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00022  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00023  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00024  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00025  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00026  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00027  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00028  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00029  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00030  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00031  * SUCH DAMAGE.
00032  *
00033  * @(#) $Header: /cvsroot/nsnam/ns-2/emulate/tap.h,v 1.2 2002/09/23 23:25:05 alefiyah Exp $ (ISI) 
00034  */
00035 
00036 
00037 #ifndef tap_h
00038 #define tap_h
00039 
00040 #include "tclcl.h"
00041 #include "net.h"
00042 #include "packet.h"
00043 #include "agent.h"
00044 
00045 
00046 #define TAPDEBUG 1 
00047 #ifdef TAPDEBUG
00048 #define TDEBUG(x) { if (TAPDEBUG) fprintf(stderr, (x)); }
00049 #define TDEBUG2(x,y) { if (TAPDEBUG) fprintf(stderr, (x), (y)); }
00050 #define TDEBUG3(x,y,z) { if (TAPDEBUG) fprintf(stderr, (x), (y), (z)); }
00051 #define TDEBUG4(w,x,y,z) { if (TAPDEBUG) fprintf(stderr, (w), (x), (y), (z)); }
00052 #define TDEBUG5(v,w,x,y,z) { if (TAPDEBUG) fprintf(stderr, (v), (w), (x), (y), (z)); }
00053 #else
00054 #define TDEBUG(x) { }
00055 #define TDEBUG2(x,y) { }
00056 #define TDEBUG3(x,y,z) { }
00057 #define TDEBUG4(w,x,y,z) { }
00058 #define TDEBUG5(v,w,x,y,z) { }
00059 #endif
00060 
00061 #include <errno.h>
00062 
00063 class TapAgent : public Agent, public IOHandler {
00064 public:
00065         TapAgent();
00066         int command(int, const char*const*);
00067         void recv(Packet* p, Handler*); /* sim->live net */  
00068 private:
00069         virtual int sendpkt(Packet *);
00070         virtual void recvpkt();
00071 protected:
00072         int maxpkt_;            /* max size allocated to recv a pkt */
00073         void dispatch(int);     /* invoked via scheduler on I/O event */
00074         int linknet();          /* establish I/O handler */
00075         Network* net_;          /* live network object */
00076         double now() { return Scheduler::instance().clock(); }
00077 };
00078 
00079 
00080 
00081 #endif /* tap_h */
00082 
00083 
00084 
00085 
00086 

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