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

ctrMcast.cc

Go to the documentation of this file.
00001 /* -*-  Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
00002 /*
00003  * ctrMcast.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  * Contributed by Polly Huang (USC/ISI), http://www-scf.usc.edu/~bhuang
00021  * 
00022  */
00023 
00024 #ifndef lint
00025 static const char rcsid[] =
00026     "@(#) $Header: /nfs/jade/vint/CVSROOT/ns-2/mcast/ctrMcast.cc,v 1.9 2000/09/01 03:04:05 haoboy Exp $ (USC/ISI)";
00027 #endif
00028 
00029 #include "agent.h"
00030 #include "ip.h"
00031 #include "ctrMcast.h"
00032 
00033 int hdr_CtrMcast::offset_;
00034 
00035 static class CtrMcastHeaderClass : public PacketHeaderClass {
00036 public:
00037         CtrMcastHeaderClass() : PacketHeaderClass("PacketHeader/CtrMcast",
00038                                                   sizeof(hdr_CtrMcast)) {
00039                 bind_offset(&hdr_CtrMcast::offset_);
00040         } 
00041 } class_CtrMcast_hdr;
00042 
00043 
00044 class CtrMcastEncap : public Agent {
00045 public:
00046         CtrMcastEncap() : Agent(PT_CtrMcast_Encap) {}
00047         int command(int argc, const char*const* argv);
00048         void recv(Packet* p, Handler*);
00049 };
00050 
00051 class CtrMcastDecap : public Agent {
00052 public:
00053         CtrMcastDecap() : Agent(PT_CtrMcast_Decap) {}
00054         int command(int argc, const char*const* argv);
00055         void recv(Packet* p, Handler*);
00056 };
00057 
00058 static class CtrMcastEncapclass : public TclClass {
00059 public:
00060         CtrMcastEncapclass() : TclClass("Agent/CtrMcast/Encap") {}
00061         TclObject* create(int, const char*const*) {
00062                 return (new CtrMcastEncap);
00063         }
00064 } class_CtrMcastEncap;
00065 
00066 static class CtrMcastDecapclass : public TclClass {
00067 public:
00068         CtrMcastDecapclass() : TclClass("Agent/CtrMcast/Decap") {}
00069         TclObject* create(int, const char*const*) {
00070                 return (new CtrMcastDecap);
00071         }
00072 } class_CtrMcastDecap;
00073 
00074 
00075 int CtrMcastEncap::command(int argc, const char*const* argv)
00076 {
00077         return Agent::command(argc, argv);
00078 }
00079 
00080 int CtrMcastDecap::command(int argc, const char*const* argv)
00081 {
00082         return Agent::command(argc, argv);
00083 }
00084 
00085 void CtrMcastEncap::recv(Packet* p, Handler*)
00086 {
00087         hdr_CtrMcast* ch = hdr_CtrMcast::access(p);
00088         hdr_ip* ih = hdr_ip::access(p);
00089 
00090         ch->src() = ih->saddr();
00091         ch->group() = ih->daddr();
00092         ch->flowid() = ih->flowid();
00093         ih->saddr() = addr();
00094         ih->sport() = port();
00095         ih->daddr() = daddr();
00096         ih->dport() = dport();
00097         ih->flowid() = fid_;
00098 
00099         target_->recv(p);
00100 }
00101 
00102 void CtrMcastDecap::recv(Packet* p, Handler*)
00103 {
00104         hdr_CtrMcast* ch = hdr_CtrMcast::access(p);
00105         hdr_ip* ih = hdr_ip::access(p);
00106 
00107         ih->saddr() = ch->src();
00108         ih->daddr() = ch->group();
00109         ih->flowid() = ch->flowid();
00110 
00111         target_->recv(p);
00112 }

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