00001 // -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- 00002 00003 /* 00004 * addr-params.h 00005 * Copyright (C) 2000 by the University of Southern California 00006 * $Id: addr-params.h,v 1.4 2005/08/25 18:58:12 johnh Exp $ 00007 * 00008 * This program is free software; you can redistribute it and/or 00009 * 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 of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License along 00018 * 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 * 00022 * The copyright of this module includes the following 00023 * linking-with-specific-other-licenses addition: 00024 * 00025 * In addition, as a special exception, the copyright holders of 00026 * this module give you permission to combine (via static or 00027 * dynamic linking) this module with free software programs or 00028 * libraries that are released under the GNU LGPL and with code 00029 * included in the standard release of ns-2 under the Apache 2.0 00030 * license or under otherwise-compatible licenses with advertising 00031 * requirements (or modified versions of such code, with unchanged 00032 * license). You may copy and distribute such a system following the 00033 * terms of the GNU GPL for this module and the licenses of the 00034 * other code concerned, provided that you include the source code of 00035 * that other code when and as the GNU GPL requires distribution of 00036 * source code. 00037 * 00038 * Note that people who make modified versions of this module 00039 * are not obligated to grant this special exception for their 00040 * modified versions; it is their choice whether to do so. The GNU 00041 * General Public License gives permission to release a modified 00042 * version without this exception; this exception also makes it 00043 * possible to release a modified version which carries forward this 00044 * exception. 00045 * 00046 */ 00047 // 00048 // Address parameters. Singleton class 00049 // 00050 // $Header: /cvsroot/nsnam/ns-2/routing/addr-params.h,v 1.4 2005/08/25 18:58:12 johnh Exp $ 00051 00052 #ifndef ns_addr_params_h 00053 #define ns_addr_params_h 00054 00055 #include <tclcl.h> 00056 00057 class AddrParamsClass : public TclClass{ 00058 public: 00059 // XXX Default hlevel_ to 1. 00060 AddrParamsClass() : TclClass("AddrParams"), 00061 hlevel_(1), NodeMask_(NULL), 00062 NodeShift_(NULL) { 00063 instance_ = this; 00064 } 00065 virtual TclObject* create(int, const char*const*) { 00066 Tcl::instance().add_errorf("Cannot create instance of " 00067 "AddrParamsClass"); 00068 return NULL; 00069 } 00070 virtual void bind(); 00071 virtual int method(int ac, const char*const* av); 00072 00073 static inline AddrParamsClass& instance() { return *instance_; } 00074 00075 inline int mcast_shift() { return McastShift_; } 00076 inline int mcast_mask() { return McastMask_; } 00077 inline int port_shift() { return PortShift_; } 00078 inline int port_mask() { return PortMask_; } 00079 inline int node_shift(int n) { return NodeShift_[n]; } 00080 inline int node_mask(int n) { return NodeMask_[n]; } 00081 inline int hlevel() { return hlevel_; } 00082 inline int nodebits() { return nodebits_; } 00083 00084 private: 00085 int McastShift_; 00086 int McastMask_; 00087 int PortShift_; 00088 int PortMask_; 00089 int hlevel_; 00090 int *NodeMask_; 00091 int *NodeShift_; 00092 int nodebits_; 00093 static AddrParamsClass *instance_; 00094 }; 00095 00096 #endif // ns_addr_params_h