@Test public void testAddMetaData() throws Exception { result1 = OspfUtil.addMetadata(2, packet, 1, Ip4Address.valueOf("2.2.2.2")); assertThat(result1, is(notNullValue())); }
public static byte[] addMetadata(int interfaceIndex, byte[] ospfPacket, int allDroutersValue, Ip4Address destinationIp) { byte[] packet; byte[] interfaceIndexByteVal = {(byte) interfaceIndex}; byte[] allDroutersByteVal = {(byte) allDroutersValue}; byte[] destIpAsBytes = destinationIp.toOctets(); byte[] metadata = Bytes.concat(interfaceIndexByteVal, allDroutersByteVal); metadata = Bytes.concat(metadata, destIpAsBytes); packet = Bytes.concat(ospfPacket, metadata); return packet; }
OspfUtil { public static byte[] addMetadata(int interfaceIndex, byte[] ospfPacket, int allDroutersValue, Ip4Address destinationIp) { byte[] packet; byte[] interfaceIndexByteVal = {(byte) interfaceIndex}; byte[] allDroutersByteVal = {(byte) allDroutersValue}; byte[] destIpAsBytes = destinationIp.toOctets(); byte[] metadata = Bytes.concat(interfaceIndexByteVal, allDroutersByteVal); metadata = Bytes.concat(metadata, destIpAsBytes); packet = Bytes.concat(ospfPacket, metadata); return packet; } }
OspfUtil { public static byte[] addMetadata(int interfaceIndex, byte[] ospfPacket, int allDroutersValue, Ip4Address destinationIp) { byte[] packet; byte[] interfaceIndexByteVal = {(byte) interfaceIndex}; byte[] allDroutersByteVal = {(byte) allDroutersValue}; byte[] destIpAsBytes = destinationIp.toOctets(); byte[] metadata = Bytes.concat(interfaceIndexByteVal, allDroutersByteVal); metadata = Bytes.concat(metadata, destIpAsBytes); packet = Bytes.concat(ospfPacket, metadata); return packet; } private  OspfUtil(); }
OspfUtil { public static byte[] addMetadata(int interfaceIndex, byte[] ospfPacket, int allDroutersValue, Ip4Address destinationIp) { byte[] packet; byte[] interfaceIndexByteVal = {(byte) interfaceIndex}; byte[] allDroutersByteVal = {(byte) allDroutersValue}; byte[] destIpAsBytes = destinationIp.toOctets(); byte[] metadata = Bytes.concat(interfaceIndexByteVal, allDroutersByteVal); metadata = Bytes.concat(metadata, destIpAsBytes); packet = Bytes.concat(ospfPacket, metadata); return packet; } private  OspfUtil(); static boolean sameNetwork(Ip4Address ip1, Ip4Address ip2, Ip4Address mask); static long ipAddressToLong(String ipAddress); static boolean isOpaqueEnabled(int options); static int byteToInteger(byte[] bytesToConvert); static long byteToLong(byte[] bytesToConvert); static int createRandomNumber(); static LsaHeader readLsaHeader(ChannelBuffer channelBuffer); static byte[] convertToTwoBytes(int numberToConvert); static byte[] convertToThreeBytes(int numberToConvert); static byte[] convertToFourBytes(int numberToConvert); static byte[] convertToFourBytes(long numberToConvert); static byte[] addLengthAndCheckSum(byte[] ospfPacket, int lengthBytePos1, int lengthBytePos2,
                                              int checksumBytePos1, int checksumBytePos2); static byte[] addMetadata(int interfaceIndex, byte[] ospfPacket, int allDroutersValue,
                                     Ip4Address destinationIp); }
OspfUtil { public static byte[] addMetadata(int interfaceIndex, byte[] ospfPacket, int allDroutersValue, Ip4Address destinationIp) { byte[] packet; byte[] interfaceIndexByteVal = {(byte) interfaceIndex}; byte[] allDroutersByteVal = {(byte) allDroutersValue}; byte[] destIpAsBytes = destinationIp.toOctets(); byte[] metadata = Bytes.concat(interfaceIndexByteVal, allDroutersByteVal); metadata = Bytes.concat(metadata, destIpAsBytes); packet = Bytes.concat(ospfPacket, metadata); return packet; } private  OspfUtil(); static boolean sameNetwork(Ip4Address ip1, Ip4Address ip2, Ip4Address mask); static long ipAddressToLong(String ipAddress); static boolean isOpaqueEnabled(int options); static int byteToInteger(byte[] bytesToConvert); static long byteToLong(byte[] bytesToConvert); static int createRandomNumber(); static LsaHeader readLsaHeader(ChannelBuffer channelBuffer); static byte[] convertToTwoBytes(int numberToConvert); static byte[] convertToThreeBytes(int numberToConvert); static byte[] convertToFourBytes(int numberToConvert); static byte[] convertToFourBytes(long numberToConvert); static byte[] addLengthAndCheckSum(byte[] ospfPacket, int lengthBytePos1, int lengthBytePos2,
                                              int checksumBytePos1, int checksumBytePos2); static byte[] addMetadata(int interfaceIndex, byte[] ospfPacket, int allDroutersValue,
                                     Ip4Address destinationIp); static final int OSPF_VERSION_2; static final int OSPF_VERSION; static final int PACKET_MINIMUM_LENGTH; static final int METADATA_LEN; static final int MINIMUM_FRAME_LEN; static final int OSPF_HEADER_LENGTH; static final int LSA_HEADER_LENGTH; static final int DD_HEADER_LENGTH; static final int LSREQUEST_LENGTH; static final int OSPFPACKET_LENGTH_POS1; static final int OSPFPACKET_LENGTH_POS2; static final int OSPFPACKET_CHECKSUM_POS1; static final int OSPFPACKET_CHECKSUM_POS2; static final int LSAPACKET_CHECKSUM_POS1; static final int LSAPACKET_CHECKSUM_POS2; static final Ip4Address ALL_SPF_ROUTERS; static final Ip4Address ALL_DROUTERS; static final Ip4Address DEFAULTIP; static final int RETRANSMITINTERVAL; static final int ONLY_ALL_SPF_ROUTERS; static final int JOIN_ALL_DROUTERS; static final int INITIALIZE_SET; static final int INITIALIZE_NOTSET; static final int MORE_SET; static final int MORE_NOTSET; static final int IS_MASTER; static final int NOT_MASTER; static final int NOT_ASSIGNED; static final int FOUR_BYTES; static final int FIVE_BYTES; static final int EIGHT_BYTES; static final int TWELVE_BYTES; static final int EXTERNAL_DESTINATION_LENGTH; static final String SHOST; static final int SPORT; static final int MTU; static final char CONFIG_LENGTH; static final char ROUTER_PRIORITY; static final int HELLO_PACKET_OPTIONS; }