BUG-3888 : fix comparing ASnumbers
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / BGPServerSessionNegotiator.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
9 package org.opendaylight.protocol.bgp.rib.impl;
10
11 import io.netty.channel.Channel;
12 import io.netty.util.concurrent.Promise;
13 import org.opendaylight.protocol.bgp.parser.AsNumberUtil;
14 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry;
15 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
16 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionValidator;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.Open;
20
21 /**
22  * Server negotiator. Validates established connections using BGPServerSessionValidator
23  */
24 public final class BGPServerSessionNegotiator extends AbstractBGPSessionNegotiator {
25
26     public BGPServerSessionNegotiator(final Promise<BGPSessionImpl> promise, final Channel channel,
27             final BGPPeerRegistry registry, final BGPSessionValidator sessionValidator) {
28         super(promise, channel, registry, sessionValidator);
29     }
30
31     @Override
32     protected Ipv4Address getSourceId(final Open openMsg, final BGPSessionPreferences preferences) {
33         return preferences.getBgpId();
34     }
35
36     @Override
37     protected Ipv4Address getDestinationId(final Open openMsg, final BGPSessionPreferences preferences) {
38         return openMsg.getBgpIdentifier();
39     }
40
41     @Override
42     protected AsNumber getAsNumber(final Open openMsg, final BGPSessionPreferences preferences) {
43         return AsNumberUtil.advertizedAsNumber(openMsg);
44     }
45 }