All Downloads are FREE. Search and download functionalities are using the official Maven repository.

es.tid.pce.pcep.objects.ExplicitRouteObject Maven / Gradle / Ivy

The newest version!
package es.tid.pce.pcep.objects;

import java.util.LinkedList;
import java.util.logging.Logger;

import es.tid.pce.pcep.objects.subobjects.SREROSubobject;
import es.tid.rsvp.objects.subobjects.*;

/** Explicit Route Object
 * The ERO is used to encode the path of a TE LSP through the network.
 * The ERO is carried within a PCRep message to provide the computed TE
 * LSP if the path computation was successful.
 *
 * The contents of this object are identical in encoding to the contents
 * of the Resource Reservation Protocol Traffic Engineering Extensions
 * (RSVP-TE) Explicit Route Object (ERO) defined in [RFC3209],
 * [RFC3473], and [RFC3477].  That is, the object is constructed from a
 * series of sub-objects.  Any RSVP-TE ERO sub-object already defined or
 * that could be defined in the future for use in the RSVP-TE ERO is
 * acceptable in this object.
 * PCEP ERO sub-object types correspond to RSVP-TE ERO sub-object types.
 *
 * Since the explicit path is available for immediate signaling by the
 * MPLS or GMPLS control plane, the meanings of all of the sub-objects
 * and fields in this object are identical to those defined for the ERO.
 *
 * ERO Object-Class is 7.
 *
 * ERO Object-Type is 1.
 *
 * RFC 3209:
 *   0                   1                   2                   3
 *    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 *  |                                                               |
 *  //                        (Subobjects)                          //
 *  |                                                               |
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * @author Oscar Gonzalez de Dios ([email protected])
 */
public class ExplicitRouteObject extends PCEPObject{
	
	public LinkedList EROSubobjectList;
	
	//Constructors

	public ExplicitRouteObject() {
		super();
		this.setObjectClass(ObjectParameters.PCEP_OBJECT_CLASS_ERO);
		this.setOT(ObjectParameters.PCEP_OBJECT_TYPE_ERO);
		EROSubobjectList=new LinkedList();
	}
	
	/**
	 * Constructs a new ERO (Explicit Route Object) from a sequence of bytes
	 * @param bytes Sequence of bytes where the object is present
	 * @param offset Position at which the object starts
	 * @throws MalformedPCEPObjectException Thrown if the decoded object is not well formed
	 */
	public ExplicitRouteObject (byte []bytes, int offset)throws MalformedPCEPObjectException{
		super(bytes, offset);
		EROSubobjectList=new LinkedList();
		decode();
	}
	
	//Encode and Decode
	
	/**
	 * Encode Explicit Route Object
	 */
	public void encode() {
		int len=4;//The four bytes of the header
		for (int k=0; k=ObjectLength){
				fin=true;
			}
		}
		
	}
	
	//Getters and setters
	
	//FIXME: Ver si es mejor Vector o LInkedList, y A�ADIR MAS METODOS UTILES, estos son escasos.
	
	public void addEROSubobject(EROSubobject eroso){
		EROSubobjectList.add(eroso);
	}
	
	public void addEROSubobjectList(LinkedList erosovec){
		EROSubobjectList.addAll(erosovec);
	}

	public LinkedList getEROSubobjectList() {
		return EROSubobjectList;
	}

	public void setEROSubobjectList(LinkedList eROSubobjectList) {
		EROSubobjectList = eROSubobjectList;
	}
	

	public String toString(){
		StringBuffer sb=new StringBuffer(EROSubobjectList.size()*100);
		sb.append("");
		return sb.toString();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime
				* result
				+ ((EROSubobjectList == null) ? 0 : EROSubobjectList.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		ExplicitRouteObject other = (ExplicitRouteObject) obj;
		if (EROSubobjectList == null) {
			if (other.EROSubobjectList != null)
				return false;
		} else if (!EROSubobjectList.equals(other.EROSubobjectList))
			return false;

		return true;
	}
	
	


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy