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.BGPMessage;
13 import org.opendaylight.protocol.bgp.parser.BGPParameter;
14 import org.opendaylight.protocol.concepts.IPv4Address;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
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 BGPMessage {
24 private static final long serialVersionUID = -3507481736478860117L;
27 * Current BGP version.
29 public static final int BGP_VERSION = 4;
31 private final AsNumber myAS;
33 private final short holdTime;
35 private final IPv4Address bgpId;
37 private final List<BGPParameter> optParams;
40 * Creates BGPOpen message.
42 * @param myAS ASNumber of the BGP speaker
43 * @param holdTime proposed value of the Hold Timer
44 * @param bgpId IPv4 Address of the BGP speaker
45 * @param optParams List of optional parameters
47 public BGPOpenMessage(final AsNumber myAS, final short holdTime, final IPv4Address bgpId, final List<BGPParameter> optParams) {
50 this.holdTime = holdTime;
52 this.optParams = optParams;
56 * Returns the AS number of the BGP speaker.
60 public AsNumber getMyAS() {
65 * Returns the value of the Hold timer.
67 * @return the holdTime
69 public short getHoldTime() {
74 * Returns BGP identifier of the speaker (his IP address).
78 public IPv4Address getBgpId() {
83 * Returns optional parameters in form of TLVs.
85 * @return the optParams
87 public List<BGPParameter> getOptParams() {
88 return this.optParams;
92 public String toString() {
93 final StringBuilder builder = new StringBuilder();
94 builder.append("BGPOpenMessage [myAS=");
95 builder.append(this.myAS);
96 builder.append(", holdTime=");
97 builder.append(this.holdTime);
98 builder.append(", bgpId=");
99 builder.append(this.bgpId);
100 builder.append(", optParams=");
101 builder.append(this.optParams);
103 return builder.toString();