@Test public void testDecodeUpdate() throws Exception { UpdateMessage message = (UpdateMessage) MessageFactory.decodeUpdate( new byte[] {16, 13, 5, 32, -64, -88, 0, 1, 16, 14, 17, -128, 32, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 16, 16, 4, -64, -88, 0, 1, 16, 17, 2, 78, 32, 16, 11, 5, 30, 10, 10, 10, 10, 16, 12, 9, 64, 32, 1, 0, 0, 0, 0, 0, 0}); Ipv4AddPrefixAttribute ipv4AddPrefixAttribute = (Ipv4AddPrefixAttribute) AttributeList.get(message.getAttribute(), AttributeType.Ipv4AddPrefix); assertTrue(ipv4AddPrefixAttribute.getIpv4AddPrefixAttributes() .getIpPrefix() .contains(IpPrefixBuilder.getDefaultInstance("10.10.10.10/30"))); Ipv6AddPrefixAttribute ipv6AddPrefixAttribute = (Ipv6AddPrefixAttribute) AttributeList.get(message.getAttribute(), AttributeType.Ipv6AddPrefix); assertTrue(ipv6AddPrefixAttribute.getIpv6AddPrefixAttributes() .getIpPrefix() .contains(IpPrefixBuilder.getDefaultInstance("2001:0:0:0:0:0:0:0/64"))); Ipv4DeletePrefixAttribute ipv4DeletePrefixAttribute = (Ipv4DeletePrefixAttribute) AttributeList.get(message.getAttribute(), AttributeType.Ipv4DeletePrefix); assertTrue(ipv4DeletePrefixAttribute.getIpv4DeletePrefixAttributes() .getIpPrefix() .contains(IpPrefixBuilder.getDefaultInstance("192.168.0.1/32"))); Ipv6DeletePrefixAttribute ipv6DeletePrefixAttribute = (Ipv6DeletePrefixAttribute) AttributeList.get(message.getAttribute(), AttributeType.Ipv6DeletePrefix); assertTrue(ipv6DeletePrefixAttribute.getIpv6DeletePrefixAttributes() .getIpPrefix() .contains(IpPrefixBuilder.getDefaultInstance("2002:0:0:0:0:0:0:1/128"))); }
public static Notification decodeUpdate(byte[] payload) throws AttributeLengthException, AddressLengthException, UnknownNodeIdException, UnknownPrefixException, TlvNotFoundException, UnknownHostException, AttributeVariantException { UpdateMessageBuilder messageBuilder = new UpdateMessageBuilder(); messageBuilder.setType(MessageType.Update); messageBuilder.setLength(MESSAGE_HEADER_LENGTH_LENGTH + MESSAGE_HEADER_TYPE_LENGTH + payload.length); messageBuilder.setPayload(payload); messageBuilder.setAttribute(AttributeList.decode(payload)); return messageBuilder.build(); }
MessageFactory { public static Notification decodeUpdate(byte[] payload) throws AttributeLengthException, AddressLengthException, UnknownNodeIdException, UnknownPrefixException, TlvNotFoundException, UnknownHostException, AttributeVariantException { UpdateMessageBuilder messageBuilder = new UpdateMessageBuilder(); messageBuilder.setType(MessageType.Update); messageBuilder.setLength(MESSAGE_HEADER_LENGTH_LENGTH + MESSAGE_HEADER_TYPE_LENGTH + payload.length); messageBuilder.setPayload(payload); messageBuilder.setAttribute(AttributeList.decode(payload)); return messageBuilder.build(); } }
MessageFactory { public static Notification decodeUpdate(byte[] payload) throws AttributeLengthException, AddressLengthException, UnknownNodeIdException, UnknownPrefixException, TlvNotFoundException, UnknownHostException, AttributeVariantException { UpdateMessageBuilder messageBuilder = new UpdateMessageBuilder(); messageBuilder.setType(MessageType.Update); messageBuilder.setLength(MESSAGE_HEADER_LENGTH_LENGTH + MESSAGE_HEADER_TYPE_LENGTH + payload.length); messageBuilder.setPayload(payload); messageBuilder.setAttribute(AttributeList.decode(payload)); return messageBuilder.build(); }  }
MessageFactory { public static Notification decodeUpdate(byte[] payload) throws AttributeLengthException, AddressLengthException, UnknownNodeIdException, UnknownPrefixException, TlvNotFoundException, UnknownHostException, AttributeVariantException { UpdateMessageBuilder messageBuilder = new UpdateMessageBuilder(); messageBuilder.setType(MessageType.Update); messageBuilder.setLength(MESSAGE_HEADER_LENGTH_LENGTH + MESSAGE_HEADER_TYPE_LENGTH + payload.length); messageBuilder.setPayload(payload); messageBuilder.setAttribute(AttributeList.decode(payload)); return messageBuilder.build(); }  static ByteBuf createError(ErrorCode errorCode, ErrorSubCode errorSubCode, byte[] data); static ByteBuf createKeepalive(); static ByteBuf createOpen(Version version, ConnectionMode nodeMode, NodeId nodeID, int holdTimeMinAcceptable); static ByteBuf createOpen(Version version, ConnectionMode nodeMode, NodeId nodeID, int holdTimeMin,
            int holdTimeMax); static ByteBuf createOpenResp(Version version, ConnectionMode nodeMode, NodeId nodeID); static ByteBuf createOpenResp(Version version, ConnectionMode nodeMode, NodeId nodeID,
            int holdTimeMinAcceptable); static ByteBuf createOpenResp(Version version, ConnectionMode nodeMode, NodeId nodeID, int holdTimeMin,
            int holdTimeMax); static ByteBuf createPurgeAll(); static ByteBuf createUpdate(List<R> deleteBindings,
            List<T> addBindings, NodeId nodeId, List<CapabilityType> capabilities, SxpBindingFilter bindingFilter); static Notification decodeErrorMessage(byte[] payload); static Notification decodeKeepalive(byte[] payload); static Notification decodeOpen(byte[] payload); static Notification decodeOpenResp(byte[] payload); static Version extractVersion(final byte[] payload); static Notification decodePurgeAll(byte[] payload); static Notification decodeUpdate(byte[] payload); static Notification parse(Version version, ByteBuf request); static String toString(byte[] message); static String toString(ByteBuf message); static String toString(Notification message); static List<CapabilityType> decodeCapabilities(OpenMessage message); }
MessageFactory { public static Notification decodeUpdate(byte[] payload) throws AttributeLengthException, AddressLengthException, UnknownNodeIdException, UnknownPrefixException, TlvNotFoundException, UnknownHostException, AttributeVariantException { UpdateMessageBuilder messageBuilder = new UpdateMessageBuilder(); messageBuilder.setType(MessageType.Update); messageBuilder.setLength(MESSAGE_HEADER_LENGTH_LENGTH + MESSAGE_HEADER_TYPE_LENGTH + payload.length); messageBuilder.setPayload(payload); messageBuilder.setAttribute(AttributeList.decode(payload)); return messageBuilder.build(); }  static ByteBuf createError(ErrorCode errorCode, ErrorSubCode errorSubCode, byte[] data); static ByteBuf createKeepalive(); static ByteBuf createOpen(Version version, ConnectionMode nodeMode, NodeId nodeID, int holdTimeMinAcceptable); static ByteBuf createOpen(Version version, ConnectionMode nodeMode, NodeId nodeID, int holdTimeMin,
            int holdTimeMax); static ByteBuf createOpenResp(Version version, ConnectionMode nodeMode, NodeId nodeID); static ByteBuf createOpenResp(Version version, ConnectionMode nodeMode, NodeId nodeID,
            int holdTimeMinAcceptable); static ByteBuf createOpenResp(Version version, ConnectionMode nodeMode, NodeId nodeID, int holdTimeMin,
            int holdTimeMax); static ByteBuf createPurgeAll(); static ByteBuf createUpdate(List<R> deleteBindings,
            List<T> addBindings, NodeId nodeId, List<CapabilityType> capabilities, SxpBindingFilter bindingFilter); static Notification decodeErrorMessage(byte[] payload); static Notification decodeKeepalive(byte[] payload); static Notification decodeOpen(byte[] payload); static Notification decodeOpenResp(byte[] payload); static Version extractVersion(final byte[] payload); static Notification decodePurgeAll(byte[] payload); static Notification decodeUpdate(byte[] payload); static Notification parse(Version version, ByteBuf request); static String toString(byte[] message); static String toString(ByteBuf message); static String toString(Notification message); static List<CapabilityType> decodeCapabilities(OpenMessage message);  }