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

net-interface.cc

Go to the documentation of this file.
00001 /* -*-  Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
00002 /*
00003  * net-interface.cc
00004  * Copyright (C) 1997 by USC/ISI
00005  * All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms are permitted
00008  * provided that the above copyright notice and this paragraph are
00009  * duplicated in all such forms and that any documentation, advertising
00010  * materials, and other materials related to such distribution and use
00011  * acknowledge that the software was developed by the University of
00012  * Southern California, Information Sciences Institute.  The name of the
00013  * University may not be used to endorse or promote products derived from
00014  * this software without specific prior written permission.
00015  * 
00016  * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
00017  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
00018  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00019  *
00020  * Ported by Polly Huang (USC/ISI), http://www-scf.usc.edu/~bhuang
00021  */
00022 
00023 #ifndef lint
00024 static const char rcsid[] =
00025     "@(#) $Header: /nfs/jade/vint/CVSROOT/ns-2/common/net-interface.cc,v 1.12 2000/09/01 03:04:06 haoboy Exp $ (USC/ISI)";
00026 #endif
00027 
00028 #include "net-interface.h"
00029 
00030 int NetworkInterface::command(int argc, const char*const* argv) {
00031         if (argc > 1) {
00032                 if (strcmp(argv[1], "label") == 0) {
00033                         if (argc == 2) {
00034                                 Tcl::instance().resultf("%d", intf_label_);
00035                                 return TCL_OK;
00036                         }
00037                         if (argc == 3) {
00038                                 intf_label_ = atoi(argv[2]);
00039                                 return TCL_OK;
00040                         }
00041                 }
00042         }
00043         return (Connector::command(argc, argv));
00044 }
00045 
00046 void NetworkInterface::recv(Packet* p, Handler* h) {
00047         hdr_cmn* ch = hdr_cmn::access(p);
00048 #ifdef LEO_DEBUG
00049         printf("Marking to %d\n", intf_label_);
00050 #endif
00051         ch->iface() = intf_label_;
00052         ch->direction()= hdr_cmn::NONE; //direction: none
00053         send(p, h);
00054 }
00055 
00056 static class NetworkInterfaceClass : public TclClass {
00057 public:
00058         NetworkInterfaceClass() : TclClass("NetworkInterface") {}
00059         TclObject* create(int, const char*const*) {
00060                 return (new NetworkInterface);
00061         }
00062 } class_networkinterface;
00063 

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