Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes Network Protocols #62

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ public final class ObjectParameters {
/**
* 38 Path Protection Association Group TLV [RFC8745]
*/
public static final int PCEP_TLV_PATH_PROT_ASSOCIATION_GROUP=39;
public static final int PCEP_TLV_PATH_PROT_ASSOCIATION_GROUP=38;

/**
* 39 IPV4-ADDRESS [RFC8779, Section 2.5.2.1]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package es.tid.pce.pcep.objects.tlvs;


import java.util.Objects;

import es.tid.pce.pcep.objects.MalformedPCEPObjectException;
import es.tid.pce.pcep.objects.ObjectParameters;
import es.tid.protocol.commons.ByteHandler;

public class PathProtectionAssociationTLV extends PCEPTLV{
/*
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type = 39 | Length = 4 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Data |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Figure 1: Path Protection Association TLV Format
*/

private long data;


public PathProtectionAssociationTLV() {
this.setTLVType(ObjectParameters.PCEP_TLV_PATH_PROT_ASSOCIATION_GROUP);
}

public PathProtectionAssociationTLV(byte[] bytes, int offset) throws MalformedPCEPObjectException
{
super(bytes,offset);
decode();
}

public long getData() {
return data;
}

public void setData(long data) {
this.data = data;
}

@Override
public void encode() {
log.debug("Encoding PathProtectionAssociation TLV");
this.setTLVValueLength(4);

this.tlv_bytes = new byte[this.getTotalTLVLength()];
this.encodeHeader();
int offset = 4;

ByteHandler.encode4bytesLong(data, this.tlv_bytes, offset);


}

public void decode() throws MalformedPCEPObjectException {
log.debug("Decoding SymbolicPathName TLV");
int offset=4;//Position of the next subobject
try {
this.data = ByteHandler.decode4bytesLong(this.tlv_bytes, offset);
}catch (Exception e)
{
log.error("Exception occurred, Possibly TLV size is not what expected");
throw new MalformedPCEPObjectException();
}



}

@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + Objects.hash(data);
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;
PathProtectionAssociationTLV other = (PathProtectionAssociationTLV) obj;
return data == other.data;
}

@Override
public String toString() {
return "PathProtectionAssociationTLV [data=" + data + "]";
}



}