00001 /* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ 00002 /* 00003 * Copyright (c) Xerox Corporation 1997. All rights reserved. 00004 * 00005 * This program is free software; you can redistribute it and/or modify it 00006 * under the terms of the GNU General Public License as published by the 00007 * Free Software Foundation; either version 2 of the License, or (at your 00008 * option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, but 00011 * WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along 00016 * with this program; if not, write to the Free Software Foundation, Inc., 00017 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 * 00019 * Linking this file statically or dynamically with other modules is making 00020 * a combined work based on this file. Thus, the terms and conditions of 00021 * the GNU General Public License cover the whole combination. 00022 * 00023 * In addition, as a special exception, the copyright holders of this file 00024 * give you permission to combine this file with free software programs or 00025 * libraries that are released under the GNU LGPL and with code included in 00026 * the standard release of ns-2 under the Apache 2.0 license or under 00027 * otherwise-compatible licenses with advertising requirements (or modified 00028 * versions of such code, with unchanged license). You may copy and 00029 * distribute such a system following the terms of the GNU GPL for this 00030 * file and the licenses of the other code concerned, provided that you 00031 * include the source code of that other code when and as the GNU GPL 00032 * requires distribution of source code. 00033 * 00034 * Note that people who make modified versions of this file are not 00035 * obligated to grant this special exception for their modified versions; 00036 * it is their choice whether to do so. The GNU General Public License 00037 * gives permission to release a modified version without this exception; 00038 * this exception also makes it possible to release a modified version 00039 * which carries forward this exception. 00040 * 00041 * $Header: /nfs/jade/vint/CVSROOT/ns-2/tcp/saack.cc,v 1.8 2005/08/26 05:05:30 tomh Exp $ 00042 */ 00043 00044 //SignalAckClass 00045 //Null receiver agent which merely acknowledges a request 00046 00047 #include "agent.h" 00048 #include "ip.h" 00049 #include "resv.h" 00050 00051 class SAack_Agent : public Agent { 00052 public: 00053 SAack_Agent(); 00054 00055 protected: 00056 void recv(Packet *, Handler *); 00057 int command(int,const char* const*); 00058 }; 00059 00060 SAack_Agent::SAack_Agent(): Agent(PT_TCP) 00061 { 00062 } 00063 00064 static class SAackClass : public TclClass { 00065 public: 00066 SAackClass() : TclClass("Agent/SAack") {} 00067 TclObject* create(int, const char*const*) { 00068 return (new SAack_Agent()); 00069 } 00070 } class_saack; 00071 00072 00073 void SAack_Agent::recv(Packet *p, Handler *h) 00074 { 00075 hdr_cmn *ch = hdr_cmn::access(p); 00076 00077 if (ch->ptype() == PT_REQUEST) { 00078 Packet *newp =allocpkt(); 00079 hdr_cmn *newch=hdr_cmn::access(newp); 00080 newch->size()=ch->size(); 00081 // turn the packet around by swapping src and dst 00082 hdr_ip * iph = hdr_ip::access(p); 00083 hdr_ip * newiph = hdr_ip::access(newp); 00084 newiph->dst()=iph->src(); 00085 newiph->flowid()=iph->flowid(); 00086 newiph->prio()=iph->prio(); 00087 00088 hdr_resv* rv=hdr_resv::access(p); 00089 hdr_resv* newrv=hdr_resv::access(newp); 00090 newrv->decision()=rv->decision(); 00091 newrv->rate()=rv->rate(); 00092 newrv->bucket()=rv->bucket(); 00093 if (rv->decision()) 00094 newch->ptype() = PT_ACCEPT; 00095 else 00096 newch->ptype() = PT_REJECT; 00097 target_->recv(newp); 00098 Packet::free(p); 00099 return; 00100 } 00101 Agent::recv(p,h); 00102 } 00103 00104 00105 int SAack_Agent::command(int argc, const char*const* argv) 00106 { 00107 return (Agent::command(argc,argv)); 00108 00109 } 00110 00111 00112
1.4.6