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.parser.message;
10 import java.util.List;
12 import org.opendaylight.protocol.bgp.parser.BGPParameter;
13 import org.opendaylight.protocol.concepts.IPv4Address;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
15 import org.opendaylight.yangtools.yang.binding.Notification;
18 * Representation of BGPOpen message.
20 * @see <a href="http://tools.ietf.org/html/rfc4271#section-4.2">BGP Open Message</a>
22 public final class BGPOpenMessage implements Notification {
25 * Current BGP version.
27 public static final int BGP_VERSION = 4;
29 private final AsNumber myAS;
31 private final short holdTime;
33 private final IPv4Address bgpId;
35 private final List<BGPParameter> optParams;
38 * Creates BGPOpen message.
40 * @param myAS ASNumber of the BGP speaker
41 * @param holdTime proposed value of the Hold Timer
42 * @param bgpId IPv4 Address of the BGP speaker
43 * @param optParams List of optional parameters
45 public BGPOpenMessage(final AsNumber myAS, final short holdTime, final IPv4Address bgpId, final List<BGPParameter> optParams) {
48 this.holdTime = holdTime;
50 this.optParams = optParams;
54 * Returns the AS number of the BGP speaker.
58 public AsNumber getMyAS() {
63 * Returns the value of the Hold timer.
65 * @return the holdTime
67 public short getHoldTime() {
72 * Returns BGP identifier of the speaker (his IP address).
76 public IPv4Address getBgpId() {
81 * Returns optional parameters in form of TLVs.
83 * @return the optParams
85 public List<BGPParameter> getOptParams() {
86 return this.optParams;
90 public String toString() {
91 final StringBuilder builder = new StringBuilder();
92 builder.append("BGPOpenMessage [myAS=");
93 builder.append(this.myAS);
94 builder.append(", holdTime=");
95 builder.append(this.holdTime);
96 builder.append(", bgpId=");
97 builder.append(this.bgpId);
98 builder.append(", optParams=");
99 builder.append(this.optParams);
101 return builder.toString();