package com.opensource.diacoder;

public class DiameterHeader {

	int version;
	int messageLength;
	boolean isRequest;
	boolean isProxiable;
	boolean isError;
	boolean isRetransmitted;
	int commandCode;
	int applicationId;
	int hopByHopId;
	int endToEndId;
	
	public DiameterHeader() {
		
	}
	
	public DiameterHeader(byte[] input){
		version = input[0];
		messageLength = (input[1] << 16) + (input[2] << 8) + input[3];

		isRequest = (input[4] & 0x80) > 0;
		isProxiable = (input[4] & 0x40) > 0;
		isError = (input[4] & 0x20) > 0;
		isRetransmitted = (input[4] & 0x10) > 0;
		commandCode = input[5] << 16 | input[6] << 8 | input [7];
		applicationId = input[8] << 24 | input[9] << 16 | input[10] << 8 | input [11];
		hopByHopId =  input[12] << 24 | input[13] << 16 | input[14] << 8 | input [15];
		endToEndId =  input[16] << 24 | input[17] << 16 | input[18] << 8 | input [19];
		
	}

	public int getVersion() {
		return version;
	}

	public int getMessageLength() {
		return messageLength;
	}

	public boolean isRequest() {
		return isRequest;
	}

	public boolean isProxiable() {
		return isProxiable;
	}

	public boolean isError() {
		return isError;
	}

	public boolean isRetransmitted() {
		return isRetransmitted;
	}

	public int getCommandCode() {
		return commandCode;
	}

	public int getApplicationId(){
		return applicationId;
	}
	public int getHopByHopId() {
		return hopByHopId;
	}

	public int getEndToEndId() {
		return endToEndId;
	}

}

@@ -666,16 +666,17 @@
 4 %7C 
+(
 input%5B9%5D
  %3C%3C 
@@ -671,16 +671,24 @@
 input%5B9%5D
+ & 0xFF)
  %3C%3C 16 %7C
@@ -684,24 +684,25 @@
 FF) %3C%3C 16 %7C 
+(
 input%5B10%5D %3C%3C
@@ -698,16 +698,24 @@
 nput%5B10%5D
+ & 0xFF)
  %3C%3C 8 %7C 
@@ -756,24 +756,25 @@
 12%5D %3C%3C 24 %7C 
+(
 input%5B13%5D %3C%3C
@@ -770,16 +770,24 @@
 nput%5B13%5D
+ & 0xFF)
  %3C%3C 16 %7C
@@ -783,24 +783,25 @@
 FF) %3C%3C 16 %7C 
+(
 input%5B14%5D %3C%3C
@@ -797,16 +797,24 @@
 nput%5B14%5D
+ & 0xFF)
  %3C%3C 8 %7C 
@@ -859,16 +859,17 @@
 %3C%3C 24 %7C 
+(
 input%5B17
@@ -869,16 +869,24 @@
 nput%5B17%5D
+ & 0xFF)
  %3C%3C 16 %7C
@@ -882,24 +882,25 @@
 FF) %3C%3C 16 %7C 
+(
 input%5B18%5D %3C%3C
@@ -896,16 +896,24 @@
 nput%5B18%5D
+ & 0xFF)
  %3C%3C 8 %7C 

fix test