Switched BGPMessage concept to yangtools.binding.Notification.
[bgpcep.git] / bgp / parser-api / src / main / java / org / opendaylight / protocol / bgp / parser / message / BGPOpenMessage.java
1 /*
2  * Copyright (c) 2013 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.parser.message;
9
10 import java.util.List;
11
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;
16
17 /**
18  * Representation of BGPOpen message.
19  * 
20  * @see <a href="http://tools.ietf.org/html/rfc4271#section-4.2">BGP Open Message</a>
21  */
22 public final class BGPOpenMessage implements Notification {
23
24         /**
25          * Current BGP version.
26          */
27         public static final int BGP_VERSION = 4;
28
29         private final AsNumber myAS;
30
31         private final short holdTime;
32
33         private final IPv4Address bgpId;
34
35         private final List<BGPParameter> optParams;
36
37         /**
38          * Creates BGPOpen message.
39          * 
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
44          */
45         public BGPOpenMessage(final AsNumber myAS, final short holdTime, final IPv4Address bgpId, final List<BGPParameter> optParams) {
46                 super();
47                 this.myAS = myAS;
48                 this.holdTime = holdTime;
49                 this.bgpId = bgpId;
50                 this.optParams = optParams;
51         }
52
53         /**
54          * Returns the AS number of the BGP speaker.
55          * 
56          * @return myAS
57          */
58         public AsNumber getMyAS() {
59                 return this.myAS;
60         }
61
62         /**
63          * Returns the value of the Hold timer.
64          * 
65          * @return the holdTime
66          */
67         public short getHoldTime() {
68                 return this.holdTime;
69         }
70
71         /**
72          * Returns BGP identifier of the speaker (his IP address).
73          * 
74          * @return the bgpId
75          */
76         public IPv4Address getBgpId() {
77                 return this.bgpId;
78         }
79
80         /**
81          * Returns optional parameters in form of TLVs.
82          * 
83          * @return the optParams
84          */
85         public List<BGPParameter> getOptParams() {
86                 return this.optParams;
87         }
88
89         @Override
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);
100                 builder.append("]");
101                 return builder.toString();
102         }
103 }