Merge "Do not redefine dependencies from odlparent"
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / BGPClientSessionNegotiator.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.protocol.bgp.rib.impl;
9
10 import io.netty.channel.Channel;
11 import io.netty.util.concurrent.Promise;
12 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry;
13 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
14 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionValidator;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.Open;
18
19 /**
20  * Client negotiator. Validates established connections using BGPClientSessionValidator
21  */
22 public final class BGPClientSessionNegotiator extends AbstractBGPSessionNegotiator {
23
24     public BGPClientSessionNegotiator(final Promise<BGPSessionImpl> promise, final Channel channel,
25             final BGPPeerRegistry registry, final BGPSessionValidator sessionValidator) {
26         super(promise, channel, registry, sessionValidator);
27     }
28
29     @Override
30     protected Ipv4Address getDestinationId(final Open openMsg, final BGPSessionPreferences preferences) {
31         return preferences.getBgpId();
32     }
33
34     @Override
35     protected Ipv4Address getSourceId(final Open openMsg, final BGPSessionPreferences preferences) {
36         return openMsg.getBgpIdentifier();
37     }
38
39     @Override
40     protected AsNumber getAsNumber(Open openMsg, BGPSessionPreferences preferences) {
41         return preferences.getMyAs();
42     }
43 }