package org.opendaylight.protocol.bgp.testtool;
import io.netty.channel.nio.NioEventLoopGroup;
-import io.netty.util.HashedWheelTimer;
import io.netty.util.concurrent.GlobalEventExecutor;
import java.net.InetAddress;
import java.net.InetSocketAddress;
+import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;
-import org.opendaylight.protocol.bgp.parser.impl.BGPActivator;
import org.opendaylight.protocol.bgp.parser.spi.pojo.ServiceLoaderBGPExtensionProviderContext;
import org.opendaylight.protocol.bgp.rib.impl.BGPDispatcherImpl;
import org.opendaylight.protocol.bgp.rib.impl.BGPSessionProposalImpl;
import org.opendaylight.protocol.bgp.rib.impl.StrictBGPPeerRegistry;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
-import org.opendaylight.protocol.bgp.rib.impl.spi.ReusableBGPPeer;
+import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
import org.opendaylight.protocol.framework.NeverReconnectStrategy;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.LinkstateAddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev131125.LinkstateSubsequentAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.LinkstateAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.LinkstateSubsequentAddressFamily;
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.SubsequentAddressFamily;
private static final Logger LOG = LoggerFactory.getLogger(Main.class);
private static final String USAGE = "DESCRIPTION:\n"
- + "\tCreates a server with given parameters. As long as it runs, it accepts connections " + "from PCCs.\n" + "USAGE:\n"
- + "\t-a, --address\n" + "\t\tthe ip address to which is this server bound.\n"
- + "\t\tFormat: x.x.x.x:y where y is port number.\n\n"
- + "\t\tThis IP address will appear in BGP Open message as BGP Identifier of the server.\n" +
+ + "\tCreates a server with given parameters. As long as it runs, it accepts connections " + "from PCCs.\n" + "USAGE:\n"
+ + "\t-a, --address\n" + "\t\tthe ip address to which is this server bound.\n"
+ + "\t\tFormat: x.x.x.x:y where y is port number.\n\n"
+ + "\t\tThis IP address will appear in BGP Open message as BGP Identifier of the server.\n" +
"\t-as\n" + "\t\t value of AS in the initial open message\n\n" +
private static final int RECONNECT_MILLIS = 5000;
- private Main() throws Exception {
- BGPActivator bgpActivator = new BGPActivator();
- bgpActivator.start(ServiceLoaderBGPExtensionProviderContext.getSingletonInstance());
- this.dispatcher = new BGPDispatcherImpl(ServiceLoaderBGPExtensionProviderContext.getSingletonInstance().getMessageRegistry(), new HashedWheelTimer(), new NioEventLoopGroup(), new NioEventLoopGroup());
+ private Main() {
+ this.dispatcher = new BGPDispatcherImpl(ServiceLoaderBGPExtensionProviderContext.getSingletonInstance().getMessageRegistry(), new NioEventLoopGroup(), new NioEventLoopGroup());
}
- public static void main(final String[] args) throws Exception {
+ public static void main(final String[] args) throws UnknownHostException {
if (args.length == 0 || (args.length == 1 && args[0].equalsIgnoreCase("--help"))) {
LOG.info(Main.USAGE);
return;
while (i < args.length) {
if (args[i].equalsIgnoreCase("-a") || args[i].equalsIgnoreCase("--address")) {
final String[] ip = args[i + 1].split(":");
- address = new InetSocketAddress(InetAddress.getByName(ip[0]), Integer.valueOf(ip[1]));
+ address = new InetSocketAddress(InetAddress.getByName(ip[0]), Integer.parseInt(ip[1]));
i++;
} else if (args[i].equalsIgnoreCase("-h") || args[i].equalsIgnoreCase("--holdtimer")) {
holdTimerValue = Short.valueOf(args[i + 1]);
final Main m = new Main();
- final ReusableBGPPeer sessionListener = new TestingListener();
+ final BGPSessionListener sessionListener = new TestingListener();
final Map<Class<? extends AddressFamily>, Class<? extends SubsequentAddressFamily>> tables = new HashMap<>();
tables.put(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
tables.put(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class);
- final BGPSessionProposalImpl prop = new BGPSessionProposalImpl(holdTimerValue, as, new Ipv4Address("25.25.25.2"), tables);
+ final BGPSessionProposalImpl prop = new BGPSessionProposalImpl(holdTimerValue, as, new Ipv4Address("25.25.25.2"), tables, as);
final BGPSessionPreferences proposal = prop.getProposal();
final StrictBGPPeerRegistry strictBGPPeerRegistry = new StrictBGPPeerRegistry();
strictBGPPeerRegistry.addPeer(StrictBGPPeerRegistry.getIpAddress(address), sessionListener, proposal);
- m.dispatcher.createClient(addr, as, strictBGPPeerRegistry,
- new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, RECONNECT_MILLIS));
+ m.dispatcher.createClient(addr, strictBGPPeerRegistry,
+ new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, RECONNECT_MILLIS));
}
}