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

parentnode.cc

Go to the documentation of this file.
00001 // -*-  Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*-
00002 //
00003 // Time-stamp: <2000-09-15 12:52:53 haoboy>
00004 //
00005 // Copyright (c) 2000 by the University of Southern California
00006 // All rights reserved.
00007 //
00008 // Permission to use, copy, modify, and distribute this software and its
00009 // documentation in source and binary forms for non-commercial purposes
00010 // and without fee is hereby granted, provided that the above copyright
00011 // notice appear in all copies and that both the copyright notice and
00012 // this permission notice appear in supporting documentation. and that
00013 // any documentation, advertising materials, and other materials related
00014 // to such distribution and use acknowledge that the software was
00015 // developed by the University of Southern California, Information
00016 // Sciences Institute.  The name of the University may not be used to
00017 // endorse or promote products derived from this software without
00018 // specific prior written permission.
00019 //
00020 // THE UNIVERSITY OF SOUTHERN CALIFORNIA makes no representations about
00021 // the suitability of this software for any purpose.  THIS SOFTWARE IS
00022 // PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
00023 // INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
00024 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00025 //
00026 // Other copyrights might apply to parts of this software and are so
00027 // noted when applicable.
00028 //
00029 #include "parentnode.h"
00030 
00031 class BcastAddressClassifier;
00032 
00033 static class LanNodeClass : public TclClass {
00034 public:
00035         LanNodeClass() : TclClass("LanNode") {}
00036         TclObject* create(int, const char*const*) {
00037                 return (new LanNode);
00038         }
00039 } class_lan_node;
00040 
00041 static class AbsLanNodeClass : public TclClass {
00042 public:
00043         AbsLanNodeClass() : TclClass("AbsLanNode") {}
00044         TclObject* create(int, const char*const*) {
00045                 return (new AbsLanNode);
00046         }
00047 } class_abslan_node;
00048 
00049 static class BroadcastNodeClass : public TclClass {
00050 public:
00051         BroadcastNodeClass() : TclClass("Node/Broadcast") {}
00052         TclObject* create(int, const char*const*) {
00053                 return (new BroadcastNode);
00054         }
00055 } class_broadcast_node;
00056 
00057 int LanNode::command(int argc, const char*const* argv) {
00058   if (argc == 3) {
00059     if (strcmp(argv[1], "addr") == 0) {
00060       address_ = Address::instance().str2addr(argv[2]);
00061       return TCL_OK;
00062     } else if (strcmp(argv[1], "nodeid") == 0) {
00063       nodeid_ = atoi(argv[2]);
00064       return TCL_OK;
00065     }
00066   }
00067   return ParentNode::command(argc,argv);
00068 }
00069 
00070 int AbsLanNode::command(int argc, const char*const* argv) {
00071   if (argc == 3) {
00072     if (strcmp(argv[1], "addr") == 0) {
00073       address_ = Address::instance().str2addr(argv[2]);
00074       return TCL_OK;
00075     } else if (strcmp(argv[1], "nodeid") == 0) {
00076       nodeid_ = Address::instance().str2addr(argv[2]);
00077       return TCL_OK;
00078     }
00079   }
00080   return ParentNode::command(argc,argv);
00081 }
00082 
00083 int BroadcastNode::command(int argc, const char*const* argv) {
00084   Tcl& tcl = Tcl::instance();
00085   if (argc == 3) {
00086     if (strcmp(argv[1], "addr") == 0) {
00087       address_ = Address::instance().str2addr(argv[2]);
00088       return TCL_OK;
00089     } 
00090     else if (strcmp(argv[1], "nodeid") == 0) {
00091       nodeid_ = Address::instance().str2addr(argv[2]);
00092       return TCL_OK;
00093     } 
00094     else if (strcmp(argv[1], "attach-classifier") == 0) {
00095       classifier_ = (BcastAddressClassifier*)(TclObject::lookup(argv[2]));
00096       if (classifier_ == NULL) {
00097         tcl.add_errorf("Wrong object name %s",argv[2]);
00098         return TCL_ERROR;
00099       }
00100       return TCL_OK;
00101     }
00102   }
00103   return ParentNode::command(argc,argv);
00104 }
00105 
00106 void BroadcastNode::add_route(char *dst, NsObject *target) {
00107   classifier_->do_install(dst,target);
00108 }
00109 
00110 void BroadcastNode::delete_route(char *dst, NsObject *nullagent) {
00111   classifier_->do_install(dst, nullagent); 
00112 }

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