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.BGPParsingException;
6 import org.opendaylight.protocol.bgp.parser.spi.AttributeParser;
7 import org.opendaylight.protocol.bgp.parser.spi.NlriRegistry;
8 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.update.PathAttributesBuilder;
9 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.PathAttributes2;
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.PathAttributes2Builder;
12 import com.google.common.base.Preconditions;
14 final class MPUnreachAttributeParser implements AttributeParser {
15 static final int TYPE = 15;
17 private final NlriRegistry reg;
19 MPUnreachAttributeParser(final NlriRegistry reg) {
20 this.reg = Preconditions.checkNotNull(reg);
24 public void parseAttribute(final byte[] bytes, final PathAttributesBuilder builder) throws BGPDocumentedException {
26 final PathAttributes2 a = new PathAttributes2Builder().setMpUnreachNlri(reg.parseMpUnreach(bytes)).build();
27 builder.addAugmentation(PathAttributes2.class, a);
28 } catch (final BGPParsingException e) {
29 throw new BGPDocumentedException("Could not parse MP_UNREACH_NLRI: " + e.getMessage(), BGPError.OPT_ATTR_ERROR);