Bug 611 - serialization of path attributes
[bgpcep.git] / bgp / parser-impl / src / main / java / org / opendaylight / protocol / bgp / parser / impl / message / update / LocalPreferenceAttributeParser.java
index 5b46f3c0b0a091897ec92425c245478193f742d7..d66b1b365253bc7cf7dfadd114369df688096265 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.protocol.bgp.parser.impl.message.update;
 
 import io.netty.buffer.ByteBuf;
-
+import org.opendaylight.protocol.bgp.parser.AttributeFlags;
 import org.opendaylight.protocol.bgp.parser.spi.AttributeParser;
 import org.opendaylight.protocol.bgp.parser.spi.AttributeSerializer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.PathAttributes;
@@ -20,6 +20,7 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
 public final class LocalPreferenceAttributeParser implements AttributeParser,AttributeSerializer {
 
     public static final int TYPE = 5;
+    public static final int LOCAL_PREFS_LENGTH = 4;
 
     @Override
     public void parseAttribute(final ByteBuf buffer, final PathAttributesBuilder builder) {
@@ -33,6 +34,10 @@ public final class LocalPreferenceAttributeParser implements AttributeParser,Att
         if (lp == null) {
             return;
         }
-        byteAggregator.writeInt(lp.getPref().shortValue());
+
+        byteAggregator.writeByte(AttributeFlags.TRANSITIVE);
+        byteAggregator.writeByte(TYPE);
+        byteAggregator.writeByte(LOCAL_PREFS_LENGTH);
+        byteAggregator.writeInt(lp.getPref().intValue());
     }
 }