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.rib.impl;
10 import java.util.List;
12 import org.opendaylight.protocol.bgp.concepts.BGPAddressFamily;
13 import org.opendaylight.protocol.bgp.concepts.BGPTableType;
14 import org.opendaylight.protocol.bgp.parser.BGPParameter;
15 import org.opendaylight.protocol.bgp.parser.parameter.AS4BytesCapability;
16 import org.opendaylight.protocol.bgp.parser.parameter.MultiprotocolCapability;
17 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
18 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionProposal;
19 import org.opendaylight.protocol.concepts.ASNumber;
20 import org.opendaylight.protocol.concepts.IPv4Address;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
23 import com.google.common.collect.Lists;
26 * Basic implementation of BGP Session Proposal. The values are taken from conf-bgp.
28 public final class BGPSessionProposalImpl implements BGPSessionProposal {
30 private final short holdTimer;
32 private final ASNumber as;
34 private final IPv4Address bgpId;
36 private final BGPSessionPreferences prefs;
38 public BGPSessionProposalImpl(final short holdTimer, final ASNumber as, final IPv4Address bgpId) {
39 this.holdTimer = holdTimer;
43 final BGPTableType ipv4 = new BGPTableType(BGPAddressFamily.IPv4, BgpSubsequentAddressFamily.Unicast);
44 final BGPTableType linkstate = new BGPTableType(BGPAddressFamily.LinkState, BgpSubsequentAddressFamily.Linkstate);
45 final List<BGPParameter> tlvs = Lists.newArrayList();
46 tlvs.add(new MultiprotocolCapability(ipv4));
47 tlvs.add(new MultiprotocolCapability(linkstate));
48 // final Map<BGPTableType, Boolean> tableTypes = Maps.newHashMap();
49 // tableTypes.put(ipv4, true);
50 // tableTypes.put(linkstate,true);
51 // tlvs.add(new GracefulCapability(true, 0, tableTypes));
52 tlvs.add(new AS4BytesCapability(as));
53 this.prefs = new BGPSessionPreferences(as, holdTimer, bgpId, tlvs);
57 public BGPSessionPreferences getProposal() {
62 * @return the holdTimer
64 public short getHoldTimer() {
65 return this.holdTimer;
71 public ASNumber getAs() {
78 public IPv4Address getBgpId() {