package org.freertr.rtr; import java.util.List; import org.freertr.addr.addrIP; import org.freertr.addr.addrIPv4; import org.freertr.ip.ipCor4; import org.freertr.ip.ipCor6; import org.freertr.ip.ipFwd; import org.freertr.ip.ipRtr; import org.freertr.tab.tabGen; import org.freertr.tab.tabIndex; import org.freertr.tab.tabRoute; import org.freertr.tab.tabRouteAttr; import org.freertr.tab.tabRouteEntry; import org.freertr.user.userHelping; import org.freertr.util.bits; import org.freertr.util.cmds; /** * unicast to multicast * * @author matecsaba */ public class rtrUni2multi extends ipRtr { /** * the forwarder protocol */ public final ipFwd fwdCore; /** * route type */ protected final tabRouteAttr.routeType rouTyp; /** * router number */ protected final int rtrNum; /** * distance to give */ protected int distance; /** * create unicast to multicast process * * @param forwarder forwarder to update * @param id process id */ public rtrUni2multi(ipFwd forwarder, int id) { fwdCore = forwarder; rtrNum = id; switch (fwdCore.ipVersion) { case ipCor4.protocolVersion: rouTyp = tabRouteAttr.routeType.uni2multi4; break; case ipCor6.protocolVersion: rouTyp = tabRouteAttr.routeType.uni2multi6; break; default: rouTyp = null; break; } distance = 254; routerComputedU = new tabRoute("rx"); routerComputedM = new tabRoute("rx"); routerComputedF = new tabRoute("rx"); routerComputedI = new tabGen>(); routerCreateComputed(); fwdCore.routerAdd(this, rouTyp, id); } /** * convert to string * * @return string */ public String toString() { return "uni2multi on " + fwdCore; } /** * create computed */ public synchronized void routerCreateComputed() { tabRoute res = new tabRoute("computed"); for (int i = 0; i < routerRedistedU.size(); i++) { tabRouteEntry ntry = routerRedistedU.get(i); if (ntry == null) { continue; } ntry = ntry.copyBytes(tabRoute.addType.notyet); ntry.best.rouTyp = rouTyp; ntry.best.protoNum = rtrNum; if (distance > 0) { ntry.best.distance = distance; } res.add(tabRoute.addType.better, ntry, false, false); } routerDoAggregates(rtrBgpUtil.sfiMulticast, res, res, fwdCore.commonLabel, null, 0); if (res.preserveTime(routerComputedM)) { return; } routerComputedM = res; fwdCore.routerChg(this, false); } /** * redistribution changed */ public void routerRedistChanged() { routerCreateComputed(); } /** * others changed */ public void routerOthersChanged() { } /** * get help * * @param l list */ public void routerGetHelp(userHelping l) { l.add(null, "1 2 distance specify default distance"); l.add(null, "2 . distance"); } /** * get config * * @param l list * @param beg beginning * @param filter filter */ public void routerGetConfig(List l, String beg, int filter) { l.add(beg + "distance " + distance); } /** * configure * * @param cmd command * @return false on success, true on error */ public boolean routerConfigure(cmds cmd) { String s = cmd.word(); if (s.equals("distance")) { distance = bits.str2num(cmd.word()); return false; } return true; } /** * stop work */ public void routerCloseNow() { } /** * get neighbor count * * @return count */ public int routerNeighCount() { return 0; } /** * list neighbors * * @param tab list */ public void routerNeighList(tabRoute tab) { } /** * get interface count * * @return count */ public int routerIfaceCount() { return 0; } /** * maximum recursion depth * * @return allowed number */ public int routerRecursions() { return 1; } /** * get list of link states * * @param tab table to update * @param par parameter * @param asn asn * @param adv advertiser */ public void routerLinkStates(tabRoute tab, int par, int asn, addrIPv4 adv) { } }