protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageWriter.java
/**
     * Writes an OSPF Message to byte array.
     *
     * @param ospfMessage    OSPF Message instance
     * @param interfaceState interface state
     * @return message as byte array
     */
Writes an OSPF Message to byte array.
@param ospfMessage    OSPF Message instance
@param interfaceState interface state
@return message as byte array
Writes an OSPF Message to byte array . @param ospfMessage OSPF Message instance @param interfaceState interface state @return message as byte array
private byte[] writeMessageToBytes(OspfMessage ospfMessage, int interfaceIndex, int interfaceState) {
        byte[] ospfMessageAsByte = ospfMessage.asBytes();
        ospfMessageAsByte = OspfUtil.addLengthAndCheckSum(ospfMessageAsByte, OspfUtil.OSPFPACKET_LENGTH_POS1,
                                                          OspfUtil.OSPFPACKET_LENGTH_POS2,
                                                          OspfUtil.OSPFPACKET_CHECKSUM_POS1,
                                                          OspfUtil.OSPFPACKET_CHECKSUM_POS2);
        if (interfaceState == OspfParameters.DR || interfaceState == OspfParameters.BDR) {
            ospfMessageAsByte = OspfUtil.addMetadata(interfaceIndex, ospfMessageAsByte, OspfUtil.JOIN_ALL_DROUTERS,
                                                     ospfMessage.destinationIp());
        } else {
            ospfMessageAsByte = OspfUtil.addMetadata(interfaceIndex, ospfMessageAsByte, OspfUtil.ONLY_ALL_SPF_ROUTERS,
                                                     ospfMessage.destinationIp());
        }
        return ospfMessageAsByte;
    }
private byte [ ] writeMessageToBytes ( OspfMessage ospfMessage , int interfaceIndex , int interfaceState ) { byte [ ] ospfMessageAsByte = ospfMessage . asBytes ( ) ; ospfMessageAsByte = OspfUtil . addLengthAndCheckSum ( ospfMessageAsByte , OspfUtil . OSPFPACKET_LENGTH_POS1 , OspfUtil . OSPFPACKET_LENGTH_POS2 , OspfUtil . OSPFPACKET_CHECKSUM_POS1 , OspfUtil . OSPFPACKET_CHECKSUM_POS2 ) ; if ( interfaceState == OspfParameters . DR || interfaceState == OspfParameters . BDR ) { ospfMessageAsByte = OspfUtil . addMetadata ( interfaceIndex , ospfMessageAsByte , OspfUtil . JOIN_ALL_DROUTERS , ospfMessage . destinationIp ( ) ) ; } else { ospfMessageAsByte = OspfUtil . addMetadata ( interfaceIndex , ospfMessageAsByte , OspfUtil . ONLY_ALL_SPF_ROUTERS , ospfMessage . destinationIp ( ) ) ; } return ospfMessageAsByte ; }
Writes an OSPF Message to byte array.
Writes an OSPF Message to byte array .
//Add the length and checksum in byte array at length position 2 & 3 and Checksum position //Add Interface State Info and destination IP as metadata