Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

dynalink.cc

Go to the documentation of this file.
00001 /* -*-  Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
00002 /*
00003  * Copyright (C) 1997 by USC/ISI
00004  * All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms are permitted
00007  * provided that the above copyright notice and this paragraph are
00008  * duplicated in all such forms and that any documentation, advertising
00009  * materials, and other materials related to such distribution and use
00010  * acknowledge that the software was developed by the University of
00011  * Southern California, Information Sciences Institute.  The name of the
00012  * University may not be used to endorse or promote products derived from
00013  * this software without specific prior written permission.
00014  * 
00015  * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
00016  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
00017  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00018  * 
00019  */
00020 
00021 // Other copyrights might apply to parts of this software and are so
00022 // noted when applicable.
00023 //
00024 //      Author:         Kannan Varadhan <kannan@isi.edu>
00025 //      Version Date:   Mon Jun 30 15:51:33 PDT 1997
00026 
00027 #ifndef lint
00028 static const char rcsid[] =
00029         "@(#) $Header: /nfs/jade/vint/CVSROOT/ns-2/link/dynalink.cc,v 1.9 1998/06/27 01:23:46 gnguyen Exp $ (USC/ISI)";
00030 #endif
00031 
00032 #include "connector.h"
00033 
00034 // #include "packet.h"
00035 // #include "queue.h"
00036 
00037 class DynamicLink : public Connector {
00038 public:
00039         DynamicLink() : down_(0), status_(1) { bind("status_", &status_); }
00040 protected:
00041         int command(int argc, const char*const* argv);
00042         void recv(Packet* p, Handler* h);
00043         NsObject* down_;
00044         int status_;
00045 };
00046 
00047 static class DynamicLinkClass : public TclClass {
00048 public:
00049         DynamicLinkClass() : TclClass("DynamicLink") {}
00050         TclObject* create(int, const char*const*) {
00051                 return (new DynamicLink);
00052         }
00053 } class_dynamic_link;
00054 
00055 
00056 int DynamicLink::command(int argc, const char*const* argv)
00057 {
00058         if (argc == 2) {
00059                 if (strcmp(argv[1], "status?") == 0) {
00060                         Tcl::instance().result(status_ ? "up" : "down");
00061                         return TCL_OK;
00062                 }
00063         }
00064         return Connector::command(argc, argv);
00065 }
00066 
00067 void DynamicLink::recv(Packet* p, Handler* h)
00068 {
00069         if (status_)
00070                 target_->recv(p, h);
00071         else
00072                 drop(p);
00073 }

Generated on Tue Apr 20 12:14:15 2004 for NS2.26SourcesOriginal by doxygen 1.3.3