1 package org.opendaylight.protocol.bgp.parser.impl.message.update;
3 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
4 import org.opendaylight.protocol.bgp.parser.BGPError;
5 import org.opendaylight.protocol.bgp.parser.spi.AttributeParser;
6 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.path.attributes.OriginBuilder;
7 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.update.PathAttributesBuilder;
8 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpOrigin;
10 import com.google.common.primitives.UnsignedBytes;
12 final class OriginAttributeParser implements AttributeParser {
13 static final int TYPE = 1;
16 public void parseAttribute(final byte[] bytes, final PathAttributesBuilder builder) throws BGPDocumentedException {
17 final BgpOrigin borigin = BgpOrigin.forValue(UnsignedBytes.toInt(bytes[0]));
18 if (borigin == null) {
19 throw new BGPDocumentedException("Unknown Origin type.", BGPError.ORIGIN_ATTR_NOT_VALID, new byte[] { (byte) 0x01, (byte) 0x01, bytes[0] });
22 builder.setOrigin(new OriginBuilder().setValue(borigin).build());