--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.parser.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.protocol.bgp.linkstate.LinkstateAttributeParser;
+import org.opendaylight.protocol.bgp.parser.impl.message.BGPKeepAliveMessageParser;
+import org.opendaylight.protocol.bgp.parser.impl.message.BGPNotificationMessageParser;
+import org.opendaylight.protocol.bgp.parser.impl.message.BGPOpenMessageParser;
+import org.opendaylight.protocol.bgp.parser.impl.message.BGPUpdateMessageParser;
+import org.opendaylight.protocol.bgp.parser.impl.message.open.As4CapabilityHandler;
+import org.opendaylight.protocol.bgp.parser.impl.message.open.CapabilityParameterParser;
+import org.opendaylight.protocol.bgp.parser.impl.message.open.MultiProtocolCapabilityHandler;
+import org.opendaylight.protocol.bgp.parser.impl.message.update.AS4AggregatorAttributeParser;
+import org.opendaylight.protocol.bgp.parser.impl.message.update.AS4PathAttributeParser;
+import org.opendaylight.protocol.bgp.parser.impl.message.update.AggregatorAttributeParser;
+import org.opendaylight.protocol.bgp.parser.impl.message.update.AsPathAttributeParser;
+import org.opendaylight.protocol.bgp.parser.impl.message.update.AtomicAggregateAttributeParser;
+import org.opendaylight.protocol.bgp.parser.impl.message.update.ClusterIdAttributeParser;
+import org.opendaylight.protocol.bgp.parser.impl.message.update.CommunitiesAttributeParser;
+import org.opendaylight.protocol.bgp.parser.impl.message.update.ExtendedCommunitiesAttributeParser;
+import org.opendaylight.protocol.bgp.parser.impl.message.update.Ipv4NlriParser;
+import org.opendaylight.protocol.bgp.parser.impl.message.update.Ipv6NlriParser;
+import org.opendaylight.protocol.bgp.parser.impl.message.update.LinkstateNlriParser;
+import org.opendaylight.protocol.bgp.parser.impl.message.update.LocalPreferenceAttributeParser;
+import org.opendaylight.protocol.bgp.parser.impl.message.update.MPReachAttributeParser;
+import org.opendaylight.protocol.bgp.parser.impl.message.update.MPUnreachAttributeParser;
+import org.opendaylight.protocol.bgp.parser.impl.message.update.MultiExitDiscriminatorAttributeParser;
+import org.opendaylight.protocol.bgp.parser.impl.message.update.NextHopAttributeParser;
+import org.opendaylight.protocol.bgp.parser.impl.message.update.OriginAttributeParser;
+import org.opendaylight.protocol.bgp.parser.impl.message.update.OriginatorIdAttributeParser;
+import org.opendaylight.protocol.bgp.parser.spi.AddressFamilyRegistry;
+import org.opendaylight.protocol.bgp.parser.spi.AttributeRegistry;
+import org.opendaylight.protocol.bgp.parser.spi.CapabilityRegistry;
+import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
+import org.opendaylight.protocol.bgp.parser.spi.NlriRegistry;
+import org.opendaylight.protocol.bgp.parser.spi.ParameterRegistry;
+import org.opendaylight.protocol.bgp.parser.spi.ProviderActivator;
+import org.opendaylight.protocol.bgp.parser.spi.ProviderContext;
+import org.opendaylight.protocol.bgp.parser.spi.SubsequentAddressFamilyRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateSubsequentAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.Keepalive;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.Notify;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.Open;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.BgpParameters;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.bgp.parameters.c.parameters.CAs4Bytes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.open.bgp.parameters.c.parameters.CMultiprotocol;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.MplsLabeledVpnSubsequentAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Preconditions;
+
+public final class ActivatorImpl implements ProviderActivator {
+ private static final Logger logger = LoggerFactory.getLogger(ActivatorImpl.class);
+ private List<AutoCloseable> registrations;
+
+ @Override
+ public synchronized void start(final ProviderContext context) {
+ Preconditions.checkState(registrations == null);
+ final List<AutoCloseable> regs = new ArrayList<>();
+
+ final AddressFamilyRegistry afiReg = context.getAddressFamilyRegistry();
+ regs.add(afiReg.registerAddressFamily(Ipv4AddressFamily.class, 1));
+ regs.add(afiReg.registerAddressFamily(Ipv6AddressFamily.class, 2));
+ regs.add(afiReg.registerAddressFamily(LinkstateAddressFamily.class, 16388));
+
+ final SubsequentAddressFamilyRegistry safiReg = context.getSubsequentAddressFamilyRegistry();
+ regs.add(safiReg.registerSubsequentAddressFamily(UnicastSubsequentAddressFamily.class, 1));
+ regs.add(safiReg.registerSubsequentAddressFamily(LinkstateSubsequentAddressFamily.class, 71));
+ regs.add(safiReg.registerSubsequentAddressFamily(MplsLabeledVpnSubsequentAddressFamily.class, 128));
+
+ final NlriRegistry nlriReg = context.getNlriRegistry();
+ regs.add(nlriReg.registerNlriParser(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class,
+ new Ipv4NlriParser()));
+ regs.add(nlriReg.registerNlriParser(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class,
+ new Ipv6NlriParser()));
+ regs.add(nlriReg.registerNlriParser(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class,
+ new LinkstateNlriParser(false)));
+ regs.add(nlriReg.registerNlriParser(LinkstateAddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class,
+ new LinkstateNlriParser(true)));
+
+ final AttributeRegistry attrReg = context.getAttributeRegistry();
+ regs.add(attrReg.registerAttributeParser(OriginAttributeParser.TYPE, new OriginAttributeParser()));
+ regs.add(attrReg.registerAttributeParser(AsPathAttributeParser.TYPE, new AsPathAttributeParser()));
+ regs.add(attrReg.registerAttributeParser(NextHopAttributeParser.TYPE, new NextHopAttributeParser()));
+ regs.add(attrReg.registerAttributeParser(MultiExitDiscriminatorAttributeParser.TYPE,
+ new MultiExitDiscriminatorAttributeParser()));
+ regs.add(attrReg.registerAttributeParser(LocalPreferenceAttributeParser.TYPE, new LocalPreferenceAttributeParser()));
+ regs.add(attrReg.registerAttributeParser(AtomicAggregateAttributeParser.TYPE, new AtomicAggregateAttributeParser()));
+ regs.add(attrReg.registerAttributeParser(AggregatorAttributeParser.TYPE, new AggregatorAttributeParser()));
+ regs.add(attrReg.registerAttributeParser(CommunitiesAttributeParser.TYPE, new CommunitiesAttributeParser()));
+ regs.add(attrReg.registerAttributeParser(OriginatorIdAttributeParser.TYPE, new OriginatorIdAttributeParser()));
+ regs.add(attrReg.registerAttributeParser(ClusterIdAttributeParser.TYPE, new ClusterIdAttributeParser()));
+ regs.add(attrReg.registerAttributeParser(MPReachAttributeParser.TYPE, new MPReachAttributeParser(nlriReg)));
+ regs.add(attrReg.registerAttributeParser(MPUnreachAttributeParser.TYPE, new MPUnreachAttributeParser(nlriReg)));
+ regs.add(attrReg.registerAttributeParser(ExtendedCommunitiesAttributeParser.TYPE, new ExtendedCommunitiesAttributeParser()));
+ regs.add(attrReg.registerAttributeParser(AS4AggregatorAttributeParser.TYPE, new AS4AggregatorAttributeParser()));
+ regs.add(attrReg.registerAttributeParser(AS4PathAttributeParser.TYPE, new AS4PathAttributeParser()));
+ regs.add(attrReg.registerAttributeParser(LinkstateAttributeParser.TYPE, new LinkstateAttributeParser()));
+
+ final CapabilityRegistry capReg = context.getCapabilityRegistry();
+ final MultiProtocolCapabilityHandler multi = new MultiProtocolCapabilityHandler(afiReg, safiReg);
+ regs.add(capReg.registerCapabilityParser(MultiProtocolCapabilityHandler.CODE, multi));
+ regs.add(capReg.registerCapabilitySerializer(CMultiprotocol.class, multi));
+
+ final As4CapabilityHandler as4 = new As4CapabilityHandler();
+ regs.add(capReg.registerCapabilityParser(As4CapabilityHandler.CODE, as4));
+ regs.add(capReg.registerCapabilitySerializer(CAs4Bytes.class, as4));
+
+ final ParameterRegistry paramReg = context.getParameterRegistry();
+ final CapabilityParameterParser cpp = new CapabilityParameterParser(capReg);
+ regs.add(paramReg.registerParameterParser(CapabilityParameterParser.TYPE, cpp));
+ regs.add(paramReg.registerParameterSerializer(BgpParameters.class, cpp));
+
+ final MessageRegistry msgReg = context.getMessageRegistry();
+ final BGPOpenMessageParser omp = new BGPOpenMessageParser(paramReg);
+ regs.add(msgReg.registerMessageParser(BGPOpenMessageParser.TYPE, omp));
+ regs.add(msgReg.registerMessageSerializer(Open.class, omp));
+
+ final BGPUpdateMessageParser ump = new BGPUpdateMessageParser(attrReg);
+ regs.add(msgReg.registerMessageParser(BGPUpdateMessageParser.TYPE, ump));
+ // Serialization of Update message is not supported
+ // regs.add(msgReg.registerMessageSerializer(Update.class, ump));
+
+ final BGPNotificationMessageParser nmp = new BGPNotificationMessageParser();
+ regs.add(msgReg.registerMessageParser(BGPNotificationMessageParser.TYPE, nmp));
+ regs.add(msgReg.registerMessageSerializer(Notify.class, nmp));
+
+ final BGPKeepAliveMessageParser kamp = new BGPKeepAliveMessageParser();
+ regs.add(msgReg.registerMessageParser(BGPKeepAliveMessageParser.TYPE, kamp));
+ regs.add(msgReg.registerMessageSerializer(Keepalive.class, kamp));
+
+ registrations = regs;
+ }
+
+ @Override
+ public synchronized void stop() {
+ Preconditions.checkState(registrations != null);
+
+ for (AutoCloseable r : registrations) {
+ try {
+ r.close();
+ } catch (Exception e) {
+ logger.warn("Failed to close registration", e);
+ }
+ }
+
+ registrations = null;
+ }
+}
package org.opendaylight.protocol.bgp.parser.impl;
import org.opendaylight.protocol.bgp.parser.spi.AddressFamilyRegistry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily;
import com.google.common.base.Preconditions;
public final class SimpleAddressFamilyRegistry implements AddressFamilyRegistry {
private static final class Holder {
- private static final AddressFamilyRegistry INSTANCE;
-
- static {
- final AddressFamilyRegistry reg = new SimpleAddressFamilyRegistry();
-
- reg.registerAddressFamily(Ipv4AddressFamily.class, 1);
- reg.registerAddressFamily(Ipv6AddressFamily.class, 2);
- reg.registerAddressFamily(LinkstateAddressFamily.class, 16388);
-
- INSTANCE = reg;
- }
+ private static final AddressFamilyRegistry INSTANCE = new SimpleAddressFamilyRegistry();
}
private final SimpleFamilyRegistry<AddressFamily, Integer> registry = new SimpleFamilyRegistry<>();
package org.opendaylight.protocol.bgp.parser.impl;
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
-import org.opendaylight.protocol.bgp.parser.impl.message.BGPKeepAliveMessageParser;
-import org.opendaylight.protocol.bgp.parser.impl.message.BGPNotificationMessageParser;
-import org.opendaylight.protocol.bgp.parser.impl.message.BGPOpenMessageParser;
-import org.opendaylight.protocol.bgp.parser.impl.message.BGPUpdateMessageParser;
import org.opendaylight.protocol.bgp.parser.spi.MessageParser;
import org.opendaylight.protocol.bgp.parser.spi.MessageSerializer;
import org.opendaylight.protocol.concepts.HandlerRegistry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.Keepalive;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.Notify;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.Open;
import org.opendaylight.yangtools.yang.binding.DataContainer;
import org.opendaylight.yangtools.yang.binding.Notification;
private static final SimpleBGPMessageFactory INSTANCE;
static {
- final SimpleBGPMessageFactory reg = new SimpleBGPMessageFactory();
+ final SimpleBGPMessageFactory f = new SimpleBGPMessageFactory();
- reg.registerMessageParser(BGPOpenMessageParser.TYPE, BGPOpenMessageParser.PARSER);
- reg.registerMessageSerializer(Open.class, BGPOpenMessageParser.SERIALIZER);
- reg.registerMessageParser(BGPUpdateMessageParser.TYPE, BGPUpdateMessageParser.PARSER);
- // Serialization of Update message is not supported
- reg.registerMessageParser(BGPNotificationMessageParser.TYPE, BGPNotificationMessageParser.PARSER);
- reg.registerMessageSerializer(Notify.class, BGPNotificationMessageParser.SERIALIZER);
- reg.registerMessageParser(BGPKeepAliveMessageParser.TYPE, BGPKeepAliveMessageParser.PARSER);
- reg.registerMessageSerializer(Keepalive.class, BGPKeepAliveMessageParser.SERIALIZER);
-
- INSTANCE = reg;
+ // Wrong order, but needed for circular dep.
+ INSTANCE = f;
+ try {
+ new ActivatorImpl().start(SingletonProviderContext.getInstance());
+ } catch (Exception e) {
+ throw new ExceptionInInitializerError(e);
+ }
}
}
package org.opendaylight.protocol.bgp.parser.impl;
import org.opendaylight.protocol.bgp.parser.spi.SubsequentAddressFamilyRegistry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateSubsequentAddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.MplsLabeledVpnSubsequentAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.SubsequentAddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
import com.google.common.base.Preconditions;
public final class SimpleSubsequentAddressFamilyRegistry implements SubsequentAddressFamilyRegistry {
private static final class Holder {
- private static final SubsequentAddressFamilyRegistry INSTANCE;
-
- static {
- final SimpleSubsequentAddressFamilyRegistry reg = new SimpleSubsequentAddressFamilyRegistry();
-
- reg.registerSubsequentAddressFamily(UnicastSubsequentAddressFamily.class, 1);
- reg.registerSubsequentAddressFamily(LinkstateSubsequentAddressFamily.class, 71);
- reg.registerSubsequentAddressFamily(MplsLabeledVpnSubsequentAddressFamily.class, 128);
-
- INSTANCE = reg;
- }
+ private static final SubsequentAddressFamilyRegistry INSTANCE =
+ new SimpleSubsequentAddressFamilyRegistry();
}
private final SimpleFamilyRegistry<SubsequentAddressFamily, Integer> registry = new SimpleFamilyRegistry<>();
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.parser.impl;
+
+import org.opendaylight.protocol.bgp.parser.impl.message.open.SimpleCapabilityRegistry;
+import org.opendaylight.protocol.bgp.parser.impl.message.open.SimpleParameterRegistry;
+import org.opendaylight.protocol.bgp.parser.impl.message.update.SimpleAttributeRegistry;
+import org.opendaylight.protocol.bgp.parser.impl.message.update.SimpleNlriRegistry;
+import org.opendaylight.protocol.bgp.parser.spi.AddressFamilyRegistry;
+import org.opendaylight.protocol.bgp.parser.spi.AttributeRegistry;
+import org.opendaylight.protocol.bgp.parser.spi.CapabilityRegistry;
+import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
+import org.opendaylight.protocol.bgp.parser.spi.NlriRegistry;
+import org.opendaylight.protocol.bgp.parser.spi.ParameterRegistry;
+import org.opendaylight.protocol.bgp.parser.spi.ProviderContext;
+import org.opendaylight.protocol.bgp.parser.spi.SubsequentAddressFamilyRegistry;
+
+public final class SingletonProviderContext implements ProviderContext {
+ private static final class Holder {
+ private static final ProviderContext INSTANCE = new SingletonProviderContext();
+ }
+
+ private SingletonProviderContext() {
+
+ }
+
+ public static ProviderContext getInstance() {
+ return Holder.INSTANCE;
+ }
+
+ @Override
+ public AddressFamilyRegistry getAddressFamilyRegistry() {
+ return SimpleAddressFamilyRegistry.getInstance();
+ }
+
+ @Override
+ public AttributeRegistry getAttributeRegistry() {
+ return SimpleAttributeRegistry.getInstance();
+ }
+
+ @Override
+ public CapabilityRegistry getCapabilityRegistry() {
+ return SimpleCapabilityRegistry.getInstance();
+ }
+
+ @Override
+ public MessageRegistry getMessageRegistry() {
+ return SimpleBGPMessageFactory.getInstance();
+ }
+
+ @Override
+ public NlriRegistry getNlriRegistry() {
+ return SimpleNlriRegistry.getInstance();
+ }
+
+ @Override
+ public ParameterRegistry getParameterRegistry() {
+ return SimpleParameterRegistry.getInstance();
+ }
+
+ @Override
+ public SubsequentAddressFamilyRegistry getSubsequentAddressFamilyRegistry() {
+ return SimpleSubsequentAddressFamilyRegistry.getInstance();
+ }
+}
public class BGPKeepAliveMessageParser implements MessageParser, MessageSerializer {
public static final int TYPE = 4;
- public static final MessageParser PARSER;
- public static final MessageSerializer SERIALIZER;
private static final Keepalive msg = new KeepaliveBuilder().build();
private static final byte[] bytes = MessageUtil.formatMessage(TYPE, new byte[0]);
-
- static {
- final BGPKeepAliveMessageParser p = new BGPKeepAliveMessageParser();
- PARSER = p;
- SERIALIZER = p;
- }
-
- private BGPKeepAliveMessageParser() {
-
- }
-
@Override
public Keepalive parseMessageBody(final byte[] body, final int messageLength) throws BGPDocumentedException {
if (body.length != 0) {
*/
public final class BGPNotificationMessageParser implements MessageParser, MessageSerializer {
public static final int TYPE = 3;
- public static final MessageParser PARSER;
- public static final MessageSerializer SERIALIZER;
-
- static {
- final BGPNotificationMessageParser p = new BGPNotificationMessageParser();
- PARSER = p;
- SERIALIZER = p;
- }
private static final Logger logger = LoggerFactory.getLogger(BGPNotificationMessageParser.class);
private static final int ERROR_SIZE = 2; // bytes
- private BGPNotificationMessageParser() {
-
- }
-
/**
* Serializes BGP Notification message.
*
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.BGPError;
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
-import org.opendaylight.protocol.bgp.parser.impl.message.open.SimpleParameterRegistry;
import org.opendaylight.protocol.bgp.parser.spi.MessageParser;
import org.opendaylight.protocol.bgp.parser.spi.MessageSerializer;
import org.opendaylight.protocol.bgp.parser.spi.MessageUtil;
*/
public final class BGPOpenMessageParser implements MessageParser, MessageSerializer {
public static final int TYPE = 1;
- public static final MessageParser PARSER;
- public static final MessageSerializer SERIALIZER;
-
- static {
- final BGPOpenMessageParser p = new BGPOpenMessageParser(SimpleParameterRegistry.getInstance());
- PARSER = p;
- SERIALIZER = p;
- }
private static final Logger logger = LoggerFactory.getLogger(BGPOpenMessageParser.class);
private final ParameterRegistry reg;
- private BGPOpenMessageParser(final ParameterRegistry reg) {
+ public BGPOpenMessageParser(final ParameterRegistry reg) {
this.reg = Preconditions.checkNotNull(reg);
}
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.BGPError;
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
-import org.opendaylight.protocol.bgp.parser.impl.message.update.SimpleAttributeRegistry;
import org.opendaylight.protocol.bgp.parser.spi.AttributeRegistry;
import org.opendaylight.protocol.bgp.parser.spi.MessageParser;
import org.opendaylight.protocol.concepts.Ipv4Util;
*/
public class BGPUpdateMessageParser implements MessageParser {
public static final int TYPE = 2;
- public static final BGPUpdateMessageParser PARSER = new BGPUpdateMessageParser(SimpleAttributeRegistry.getInstance());
private static Logger logger = LoggerFactory.getLogger(BGPUpdateMessageParser.class);
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.bgp.parameters.c.parameters.CAs4BytesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.bgp.parameters.c.parameters.c.as4.bytes.As4BytesCapabilityBuilder;
-final class As4CapabilityHandler implements CapabilityParser, CapabilitySerializer {
- static final int CODE = 65;
+public final class As4CapabilityHandler implements CapabilityParser, CapabilitySerializer {
+ public static final int CODE = 65;
@Override
public CParameters parseCapability(final byte[] bytes) throws BGPDocumentedException, BGPParsingException {
import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedBytes;
-final class MultiProtocolCapabilityHandler implements CapabilityParser, CapabilitySerializer {
- static final int CODE = 1;
+public final class MultiProtocolCapabilityHandler implements CapabilityParser, CapabilitySerializer {
+ public static final int CODE = 1;
private static final int AFI_SIZE = 2; // bytes
private static final int SAFI_SIZE = 1; // bytes
private final AddressFamilyRegistry afiReg;
private final SubsequentAddressFamilyRegistry safiReg;
- MultiProtocolCapabilityHandler(final AddressFamilyRegistry afiReg, final SubsequentAddressFamilyRegistry safiReg) {
+ public MultiProtocolCapabilityHandler(final AddressFamilyRegistry afiReg, final SubsequentAddressFamilyRegistry safiReg) {
this.afiReg = Preconditions.checkNotNull(afiReg);
this.safiReg = Preconditions.checkNotNull(safiReg);
}
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
-import org.opendaylight.protocol.bgp.parser.impl.SimpleAddressFamilyRegistry;
-import org.opendaylight.protocol.bgp.parser.impl.SimpleSubsequentAddressFamilyRegistry;
import org.opendaylight.protocol.bgp.parser.spi.CapabilityParser;
import org.opendaylight.protocol.bgp.parser.spi.CapabilityRegistry;
import org.opendaylight.protocol.bgp.parser.spi.CapabilitySerializer;
import org.opendaylight.protocol.concepts.HandlerRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.bgp.parameters.CParameters;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.open.bgp.parameters.c.parameters.CAs4Bytes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.open.bgp.parameters.c.parameters.CMultiprotocol;
import org.opendaylight.yangtools.yang.binding.DataContainer;
import com.google.common.base.Preconditions;
public final class SimpleCapabilityRegistry implements CapabilityRegistry {
private static final class Holder {
- private static final CapabilityRegistry INSTANCE;
-
- static {
- final CapabilityRegistry reg = new SimpleCapabilityRegistry();
-
- final MultiProtocolCapabilityHandler multi =
- new MultiProtocolCapabilityHandler(SimpleAddressFamilyRegistry.getInstance(),
- SimpleSubsequentAddressFamilyRegistry.getInstance());
- reg.registerCapabilityParser(MultiProtocolCapabilityHandler.CODE, multi);
- reg.registerCapabilitySerializer(CMultiprotocol.class, multi);
-
- final As4CapabilityHandler as4 = new As4CapabilityHandler();
- reg.registerCapabilityParser(As4CapabilityHandler.CODE, as4);
- reg.registerCapabilitySerializer(CAs4Bytes.class, as4);
-
- INSTANCE = reg;
- }
+ private static final CapabilityRegistry INSTANCE = new SimpleCapabilityRegistry();
}
private final HandlerRegistry<DataContainer, CapabilityParser, CapabilitySerializer> handlers = new HandlerRegistry<>();
public final class SimpleParameterRegistry implements ParameterRegistry {
private static final class Holder {
- private static final ParameterRegistry INSTANCE;
-
- static {
- final ParameterRegistry reg = new SimpleParameterRegistry();
-
- final CapabilityParameterParser cpp = new CapabilityParameterParser(SimpleCapabilityRegistry.getInstance());
- reg.registerParameterParser(CapabilityParameterParser.TYPE, cpp);
- reg.registerParameterSerializer(BgpParameters.class, cpp);
-
- INSTANCE = reg;
- }
+ private static final ParameterRegistry INSTANCE = new SimpleParameterRegistry();
}
private final HandlerRegistry<DataContainer, ParameterParser, ParameterSerializer> handlers = new HandlerRegistry<>();
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.protocol.bgp.parser.impl.message.update;
import org.opendaylight.protocol.bgp.parser.spi.AttributeParser;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.update.PathAttributesBuilder;
-final class AS4AggregatorAttributeParser implements AttributeParser {
- static final int TYPE = 17;
+public final class AS4AggregatorAttributeParser implements AttributeParser {
+ public static final int TYPE = 17;
@Override
public void parseAttribute(final byte[] bytes, final PathAttributesBuilder builder) {
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.protocol.bgp.parser.impl.message.update;
import org.opendaylight.protocol.bgp.parser.spi.AttributeParser;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.update.PathAttributesBuilder;
-final class AS4PathAttributeParser implements AttributeParser {
- static final int TYPE = 18;
+public final class AS4PathAttributeParser implements AttributeParser {
+ public static final int TYPE = 18;
@Override
public void parseAttribute(final byte[] bytes, final PathAttributesBuilder builder) {
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.protocol.bgp.parser.impl.message.update;
import org.opendaylight.protocol.bgp.parser.spi.AttributeParser;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.path.attributes.AggregatorBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.update.PathAttributesBuilder;
-final class AggregatorAttributeParser implements AttributeParser {
- static final int TYPE = 7;
+public final class AggregatorAttributeParser implements AttributeParser {
+ public static final int TYPE = 7;
/**
* Parse AGGREGATOR from bytes
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.protocol.bgp.parser.impl.message.update;
import java.util.List;
import com.google.common.collect.Lists;
import com.google.common.primitives.UnsignedBytes;
-final class AsPathAttributeParser implements AttributeParser {
- static final int TYPE = 2;
+public final class AsPathAttributeParser implements AttributeParser {
+ public static final int TYPE = 2;
/**
* Parses AS_PATH from bytes.
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.protocol.bgp.parser.impl.message.update;
import org.opendaylight.protocol.bgp.parser.spi.AttributeParser;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.path.attributes.AtomicAggregateBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.update.PathAttributesBuilder;
-final class AtomicAggregateAttributeParser implements AttributeParser {
- static final int TYPE = 6;
+public final class AtomicAggregateAttributeParser implements AttributeParser {
+ public static final int TYPE = 6;
@Override
public void parseAttribute(final byte[] bytes, final PathAttributesBuilder builder) {
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.protocol.bgp.parser.impl.message.update;
import java.util.List;
import com.google.common.collect.Lists;
-final class ClusterIdAttributeParser implements AttributeParser {
- static final int TYPE = 10;
+public final class ClusterIdAttributeParser implements AttributeParser {
+ public static final int TYPE = 10;
@Override
public void parseAttribute(final byte[] bytes, final PathAttributesBuilder builder) {
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.protocol.bgp.parser.impl.message.update;
import java.util.List;
import com.google.common.collect.Lists;
-final class CommunitiesAttributeParser implements AttributeParser {
- static final int TYPE = 8;
+public final class CommunitiesAttributeParser implements AttributeParser {
+ public static final int TYPE = 8;
@Override
public void parseAttribute(final byte[] bytes, final PathAttributesBuilder builder) throws BGPDocumentedException {
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.protocol.bgp.parser.impl.message.update;
import java.util.List;
import com.google.common.collect.Lists;
-final class ExtendedCommunitiesAttributeParser implements AttributeParser {
- static final int TYPE = 16;
+public final class ExtendedCommunitiesAttributeParser implements AttributeParser {
+ public static final int TYPE = 16;
@Override
public void parseAttribute(final byte[] bytes, final PathAttributesBuilder builder) throws BGPDocumentedException {
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.destination.destination.type.DestinationIpv4;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.destination.destination.type.DestinationIpv4Builder;
-final class Ipv4NlriParser extends IpNlriParser {
+public final class Ipv4NlriParser extends IpNlriParser {
@Override
protected DestinationIpv4 parseNlri(final byte[] nlri) {
return new DestinationIpv4Builder().setIpv4Prefixes(Ipv4Util.prefixListForBytes(nlri)).build();
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.destination.destination.type.DestinationIpv6;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.destination.destination.type.DestinationIpv6Builder;
-final class Ipv6NlriParser extends IpNlriParser {
+public final class Ipv6NlriParser extends IpNlriParser {
@Override
protected DestinationIpv6 parseNlri(final byte[] nlri) {
return new DestinationIpv6Builder().setIpv6Prefixes(Ipv6Util.prefixListForBytes(nlri)).build();
import com.google.common.primitives.UnsignedBytes;
-final class LinkstateNlriParser implements NlriParser {
+public final class LinkstateNlriParser implements NlriParser {
private static final Logger logger = LoggerFactory.getLogger(LinkstateNlriParser.class);
private static final int ROUTE_DISTINGUISHER_LENGTH = 8;
private static final int PROTOCOL_ID_LENGTH = 1;
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.protocol.bgp.parser.impl.message.update;
import org.opendaylight.protocol.bgp.parser.spi.AttributeParser;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.path.attributes.LocalPrefBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.update.PathAttributesBuilder;
-final class LocalPreferenceAttributeParser implements AttributeParser {
- static final int TYPE = 5;
+public final class LocalPreferenceAttributeParser implements AttributeParser {
+ public static final int TYPE = 5;
@Override
public void parseAttribute(final byte[] bytes, final PathAttributesBuilder builder) {
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.protocol.bgp.parser.impl.message.update;
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import com.google.common.base.Preconditions;
-final class MPReachAttributeParser implements AttributeParser {
- static final int TYPE = 14;
+public final class MPReachAttributeParser implements AttributeParser {
+ public static final int TYPE = 14;
private final NlriRegistry reg;
- MPReachAttributeParser(final NlriRegistry reg) {
+ public MPReachAttributeParser(final NlriRegistry reg) {
this.reg = Preconditions.checkNotNull(reg);
}
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.protocol.bgp.parser.impl.message.update;
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import com.google.common.base.Preconditions;
-final class MPUnreachAttributeParser implements AttributeParser {
- static final int TYPE = 15;
+public final class MPUnreachAttributeParser implements AttributeParser {
+ public static final int TYPE = 15;
private final NlriRegistry reg;
- MPUnreachAttributeParser(final NlriRegistry reg) {
+ public MPUnreachAttributeParser(final NlriRegistry reg) {
this.reg = Preconditions.checkNotNull(reg);
}
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.protocol.bgp.parser.impl.message.update;
import org.opendaylight.protocol.bgp.parser.spi.AttributeParser;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.path.attributes.MultiExitDiscBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.update.PathAttributesBuilder;
-final class MultiExitDiscriminatorAttributeParser implements AttributeParser {
- static final int TYPE = 4;
+public final class MultiExitDiscriminatorAttributeParser implements AttributeParser {
+ public static final int TYPE = 4;
@Override
public void parseAttribute(final byte[] bytes, final PathAttributesBuilder builder) {
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.protocol.bgp.parser.impl.message.update;
import org.opendaylight.protocol.bgp.parser.spi.AttributeParser;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.CIpv4NextHopBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.c.ipv4.next.hop.Ipv4NextHopBuilder;
-final class NextHopAttributeParser implements AttributeParser {
- static final int TYPE = 3;
+public final class NextHopAttributeParser implements AttributeParser {
+ public static final int TYPE = 3;
@Override
public void parseAttribute(final byte[] bytes, final PathAttributesBuilder builder) {
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.protocol.bgp.parser.impl.message.update;
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import com.google.common.primitives.UnsignedBytes;
-final class OriginAttributeParser implements AttributeParser {
- static final int TYPE = 1;
+public final class OriginAttributeParser implements AttributeParser {
+ public static final int TYPE = 1;
@Override
public void parseAttribute(final byte[] bytes, final PathAttributesBuilder builder) throws BGPDocumentedException {
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.protocol.bgp.parser.impl.message.update;
import org.opendaylight.protocol.bgp.parser.spi.AttributeParser;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.update.PathAttributesBuilder;
-final class OriginatorIdAttributeParser implements AttributeParser {
- static final int TYPE = 9;
+public final class OriginatorIdAttributeParser implements AttributeParser {
+ public static final int TYPE = 9;
@Override
public void parseAttribute(final byte[] bytes, final PathAttributesBuilder builder) {
*/
package org.opendaylight.protocol.bgp.parser.impl.message.update;
-import org.opendaylight.protocol.bgp.linkstate.LinkstateAttributeParser;
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.BGPError;
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
public final class SimpleAttributeRegistry implements AttributeRegistry {
private static final class Holder {
- private static final AttributeRegistry INSTANCE;
-
- static {
- final AttributeRegistry reg = new SimpleAttributeRegistry();
-
- reg.registerAttributeParser(OriginAttributeParser.TYPE, new OriginAttributeParser());
- reg.registerAttributeParser(AsPathAttributeParser.TYPE, new AsPathAttributeParser());
- reg.registerAttributeParser(NextHopAttributeParser.TYPE, new NextHopAttributeParser());
- reg.registerAttributeParser(MultiExitDiscriminatorAttributeParser.TYPE, new MultiExitDiscriminatorAttributeParser());
- reg.registerAttributeParser(LocalPreferenceAttributeParser.TYPE, new LocalPreferenceAttributeParser());
- reg.registerAttributeParser(AtomicAggregateAttributeParser.TYPE, new AtomicAggregateAttributeParser());
- reg.registerAttributeParser(AggregatorAttributeParser.TYPE, new AggregatorAttributeParser());
- reg.registerAttributeParser(CommunitiesAttributeParser.TYPE, new CommunitiesAttributeParser());
- reg.registerAttributeParser(OriginatorIdAttributeParser.TYPE, new OriginatorIdAttributeParser());
- reg.registerAttributeParser(ClusterIdAttributeParser.TYPE, new ClusterIdAttributeParser());
- reg.registerAttributeParser(MPReachAttributeParser.TYPE, new MPReachAttributeParser(SimpleNlriRegistry.getInstance()));
- reg.registerAttributeParser(MPUnreachAttributeParser.TYPE, new MPUnreachAttributeParser(SimpleNlriRegistry.getInstance()));
- reg.registerAttributeParser(ExtendedCommunitiesAttributeParser.TYPE, new ExtendedCommunitiesAttributeParser());
- reg.registerAttributeParser(AS4AggregatorAttributeParser.TYPE, new AS4AggregatorAttributeParser());
- reg.registerAttributeParser(AS4PathAttributeParser.TYPE, new AS4PathAttributeParser());
- reg.registerAttributeParser(LinkstateAttributeParser.TYPE, new LinkstateAttributeParser());
-
- INSTANCE = reg;
- }
+ private static final AttributeRegistry INSTANCE = new SimpleAttributeRegistry();
}
private SimpleAttributeRegistry() {
import org.opendaylight.protocol.bgp.parser.spi.SubsequentAddressFamilyRegistry;
import org.opendaylight.protocol.concepts.AbstractRegistration;
import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateAddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateSubsequentAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.BgpTableType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.update.path.attributes.MpReachNlri;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.update.path.attributes.MpReachNlriBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.update.path.attributes.MpUnreachNlri;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130918.update.path.attributes.MpUnreachNlriBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.MplsLabeledVpnSubsequentAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.SubsequentAddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedBytes;
public final class SimpleNlriRegistry implements NlriRegistry {
private static final class Holder {
- private static final NlriRegistry INSTANCE;
-
- static {
- final NlriRegistry reg = new SimpleNlriRegistry(SimpleAddressFamilyRegistry.getInstance(),
- SimpleSubsequentAddressFamilyRegistry.getInstance());
-
- final NlriParser ipv4 = new Ipv4NlriParser();
- reg.registerNlriParser(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class, ipv4);
-
- final NlriParser ipv6 = new Ipv6NlriParser();
- reg.registerNlriParser(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class, ipv6);
-
- reg.registerNlriParser(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class, new LinkstateNlriParser(false));
- reg.registerNlriParser(LinkstateAddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class, new LinkstateNlriParser(true));
-
- INSTANCE = reg;
- }
+ private static final NlriRegistry INSTANCE =
+ new SimpleNlriRegistry(SimpleAddressFamilyRegistry.getInstance(),
+ SimpleSubsequentAddressFamilyRegistry.getInstance());
}
private final ConcurrentMap<BgpTableType, NlriParser> handlers = new ConcurrentHashMap<>();
final NlriParser parser = handlers.get(createKey(builder.getAfi(), builder.getSafi()));
parser.parseNlri(ByteArray.subByte(bytes, 3, bytes.length - 3), builder);
- // builder.setWithdrawnRoutes(routes);
return builder.build();
}
import org.opendaylight.protocol.bgp.parser.BGPMessageFactory;
import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
import org.opendaylight.protocol.bgp.parser.impl.message.BGPUpdateMessageParser;
+import org.opendaylight.protocol.bgp.parser.impl.message.update.SimpleAttributeRegistry;
+import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
import org.opendaylight.protocol.bgp.parser.spi.MessageUtil;
import org.opendaylight.protocol.concepts.IGPMetric;
import org.opendaylight.protocol.concepts.IPv4;
private static int MAX_SIZE = 300;
- private final BGPUpdateMessageParser updateParser = BGPUpdateMessageParser.PARSER;
+ private static MessageRegistry reg;
+
+ private static BGPUpdateMessageParser updateParser;
@BeforeClass
public static void setUp() throws Exception {
+ reg = SimpleBGPMessageFactory.getInstance();
+ updateParser = new BGPUpdateMessageParser(SimpleAttributeRegistry.getInstance());
for (int i = 1; i <= COUNTER; i++) {
final String name = "/up" + i + ".bin";
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
+import org.junit.Before;
import org.junit.Test;
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
*/
public class PathAttributeParserTest {
+ @Before
+ public void setUp() {
+ // Activates everything
+ SimpleBGPMessageFactory.getInstance();
+ }
+
@Test
public void testOriginParser() {
try {
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.parser.spi;
+
+public interface ProviderActivator {
+ public void start(ProviderContext context);
+ public void stop();
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.parser.spi;
+
+public interface ProviderContext {
+ public AddressFamilyRegistry getAddressFamilyRegistry();
+ public AttributeRegistry getAttributeRegistry();
+ public CapabilityRegistry getCapabilityRegistry();
+ public MessageRegistry getMessageRegistry();
+ public NlriRegistry getNlriRegistry();
+ public ParameterRegistry getParameterRegistry();
+ public SubsequentAddressFamilyRegistry getSubsequentAddressFamilyRegistry();
+}