00001 /* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ 00002 /* 00003 * Copyright (c) 1997 Regents of the University of California. 00004 * All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions 00008 * are met: 00009 * 1. Redistributions of source code must retain the above copyright 00010 * notice, this list of conditions and the following disclaimer. 00011 * 2. Redistributions in binary form must reproduce the above copyright 00012 * notice, this list of conditions and the following disclaimer in the 00013 * documentation and/or other materials provided with the distribution. 00014 * 3. All advertising materials mentioning features or use of this software 00015 * must display the following acknowledgement: 00016 * This product includes software developed by the Computer Systems 00017 * Engineering Group at Lawrence Berkeley Laboratory. 00018 * 4. Neither the name of the University nor of the Laboratory may be used 00019 * to endorse or promote products derived from this software without 00020 * specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 00023 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00024 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00025 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 00026 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00027 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00028 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00029 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00031 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00032 * SUCH DAMAGE. 00033 */ 00034 /* Ported from CMU/Monarch's code*/ 00035 00036 /* 00037 $Id: tora_io.cc,v 1.4 1999/10/13 22:53:11 heideman Exp $ 00038 00039 marshall TORA packets 00040 */ 00041 00042 #include <tora/tora_packet.h> 00043 #include <tora/tora.h> 00044 00045 /* ====================================================================== 00046 Outgoing Packets 00047 ====================================================================== */ 00048 void 00049 toraAgent::sendQRY(nsaddr_t id) 00050 { 00051 Packet *p = Packet::alloc(); 00052 struct hdr_cmn *ch = HDR_CMN(p); 00053 struct hdr_ip *ih = HDR_IP(p); 00054 struct hdr_tora_qry *th = HDR_TORA_QRY(p); 00055 00056 ch->uid() = uidcnt_++; 00057 ch->ptype() = PT_TORA; 00058 ch->size() = QRY_HDR_LEN; 00059 ch->iface() = -2; 00060 ch->error() = 0; 00061 ch->addr_type() = NS_AF_NONE; 00062 ch->prev_hop_ = ipaddr(); 00063 00064 ih->saddr() = ipaddr(); 00065 ih->daddr() = IP_BROADCAST; 00066 ih->sport() = RT_PORT; 00067 ih->dport() = RT_PORT; 00068 ih->ttl_ = 1; 00069 00070 th->tq_type = TORATYPE_QRY; 00071 th->tq_dst = id; 00072 00073 trace("T %.9f _%d_ tora sendQRY %d", 00074 Scheduler::instance().clock(), ipaddr(), id); 00075 00076 tora_output(p); 00077 } 00078 00079 00080 void 00081 toraAgent::sendUPD(nsaddr_t id) 00082 { 00083 Packet *p = Packet::alloc(); 00084 struct hdr_cmn *ch = HDR_CMN(p); 00085 struct hdr_ip *ih = HDR_IP(p); 00086 struct hdr_tora_upd *th = HDR_TORA_UPD(p); 00087 TORADest *td; 00088 00089 td = dst_find(id); 00090 assert(td); 00091 00092 ch->uid() = uidcnt_++; 00093 ch->ptype() = PT_TORA; 00094 ch->size() = UPD_HDR_LEN; 00095 ch->iface() = -2; 00096 ch->error() = 0; 00097 ch->addr_type() = NS_AF_NONE; 00098 ch->prev_hop_ = ipaddr(); 00099 00100 ih->saddr() = ipaddr(); 00101 ih->daddr() = IP_BROADCAST; 00102 ih->sport() = RT_PORT; 00103 ih->dport() = RT_PORT; 00104 ih->ttl_ = 1; 00105 00106 th->tu_type = TORATYPE_UPD; 00107 th->tu_dst = id; 00108 th->tu_tau = td->height.tau; 00109 th->tu_oid = td->height.oid; 00110 th->tu_r = td->height.r; 00111 th->tu_delta = td->height.delta; 00112 th->tu_id = td->height.id; 00113 00114 tora_output(p); 00115 } 00116 00117 00118 void 00119 toraAgent::sendCLR(nsaddr_t id, double tau, nsaddr_t oid) 00120 { 00121 Packet *p = Packet::alloc(); 00122 struct hdr_cmn *ch = HDR_CMN(p); 00123 struct hdr_ip *ih = HDR_IP(p); 00124 struct hdr_tora_clr *th = HDR_TORA_CLR(p); 00125 00126 ch->uid() = uidcnt_++; 00127 ch->ptype() = PT_TORA; 00128 ch->size() = CLR_HDR_LEN; 00129 ch->iface() = -2; 00130 ch->error() = 0; 00131 ch->addr_type() = NS_AF_NONE; 00132 ch->prev_hop_ = ipaddr(); 00133 00134 ih->saddr() = ipaddr(); 00135 ih->daddr() = IP_BROADCAST; 00136 ih->sport() = RT_PORT; 00137 ih->dport() = RT_PORT; 00138 ih->ttl_ = 1; 00139 00140 th->tc_type = TORATYPE_CLR; 00141 th->tc_dst = id; 00142 th->tc_tau = tau; 00143 th->tc_oid = oid; 00144 00145 tora_output(p); 00146 } 00147 00148 void 00149 toraAgent::tora_output(Packet *p) 00150 { 00151 target_->recv(p, (Handler*) 0); 00152 } 00153
1.3.3