2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.protocol.bgp.testtool;
10 import io.netty.util.HashedWheelTimer;
12 import java.io.IOException;
13 import java.net.InetSocketAddress;
15 import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
16 import org.opendaylight.protocol.bgp.parser.impl.BGPMessageFactory;
17 import org.opendaylight.protocol.bgp.rib.impl.BGPSessionNegotiatorFactory;
18 import org.opendaylight.protocol.bgp.rib.impl.BGPSessionProposalImpl;
19 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
20 import org.opendaylight.protocol.concepts.ASNumber;
21 import org.opendaylight.protocol.concepts.IPv4;
22 import org.opendaylight.protocol.framework.DispatcherImpl;
23 import org.opendaylight.protocol.framework.SessionListenerFactory;
25 public class BGPSpeakerMock {
27 DispatcherImpl dispatcher = new DispatcherImpl();
29 public static void main(final String[] args) throws IOException {
31 final BGPSpeakerMock m = new BGPSpeakerMock();
33 final BGPSessionPreferences prefs = new BGPSessionProposalImpl((short) 90, new ASNumber(25), IPv4.FAMILY.addressForString("127.0.0.2")).getProposal();
35 final SessionListenerFactory<BGPSessionListener> f = new SessionListenerFactory<BGPSessionListener>() {
37 public BGPSessionListener getSessionListener() {
38 return new SpeakerSessionListener(m.dispatcher);
42 m.dispatcher.createServer(new InetSocketAddress("127.0.0.2", 12345), f,
43 new BGPSessionNegotiatorFactory(new HashedWheelTimer(), prefs), new BGPMessageFactory());