/** * //selma */ package SSF.OS.BGP4; import java.io.*; import java.util.*; import SSF.OS.BGP4.Comm.*; import SSF.OS.BGP4.Path.*; import SSF.OS.BGP4.Util.*; // ===== class SSF.OS.BGP4.History =========================================== // public class History extends Attribute { // ......................... constants ........................... // /** The AS path attribute type code. */ public static final int TYPECODE = 10; /** The name of the attribute as a string. */ public static final String name = "History"; /** The name of the path attribute as a DML attribute. */ public static final String dmlname = "History"; /** The name of the NHI form of the path attribute as a DML attribute. */ public static final String nhidmlname = "History"; //..................member data..................................// Vector history; //of PathChageEvents public History(){ super(); history=new Vector(); } public History(PathChangeEvent pce){ super(); history=new Vector(); history.add(pce); } // ----- opt ------------------------------------------------------------- // /* See description in Attribute parent class. */ public final boolean opt() { return true; } // ----- trans ----------------------------------------------------------- // /* See description in Attribute parent class. */ public final boolean trans() { return true; } // ----- partial --------------------------------------------------------- // /* See description in Attribute parent class. */ public final boolean partial() { return false; } public Attribute copy() { History cpHistory=new History(); PathChangeEvent pce=null; for (int i=0; i 255) { // 1 or 2 octets for the attribute length field octets += 2; } else { octets++; } return octets; } public String printHistory(){ String s=""; PathChangeEvent pce=null; for (int i=0; i(2*minth)){ return true; } } } } } return false; } //------------------------------------------------------------------------// public void addHistory(PathChangeEvent pce, Route rte, RouteInfo info){ //add pce to rte's history and set info's history to the resulting history if (pce!=null){ //extract history of rte; the update History hst=null; if (rte!=null){ hst=(History)rte.pas[History.TYPECODE]; } if (rte!=null){ if (hst!=null){ hst.history.add(pce); info.route().pas[History.TYPECODE]=(History)hst.copy(); } else { hst=new History(pce); info.route().pas[History.TYPECODE]=hst; } } else { if (info.route().epsilon){ //old route was better, right now it is epsilon, and //due to link failure rte=null, therefore no carried hst avail.(=empty) //that is why it should be set to hst=new History(pce); info.route().pas[History.TYPECODE]=hst; //System.out.println("after adding pce, history of newrt="+hst.printHistory()); } } if (hst!=null) ; } } } // end class