Vidyashree Rama
Committed by Thomas Vachuska

[Emu] [ONOS-2596] BGP Open message parsing, encoding and decoding

Change-Id: I2847849aef78314dfa8f3be0c8f34715719a15f2
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.bgpio.protocol;
18 +
19 +import java.util.LinkedList;
20 +
21 +import org.onosproject.bgpio.exceptions.BGPParseException;
22 +import org.onosproject.bgpio.types.BGPHeader;
23 +import org.onosproject.bgpio.types.BGPValueType;
24 +
25 +/**
26 + * Abstraction of an entity providing BGP Open Message.
27 + */
28 +public interface BGPOpenMsg extends BGPMessage {
29 +
30 + @Override
31 + BGPHeader getHeader();
32 +
33 + @Override
34 + BGPVersion getVersion();
35 +
36 + @Override
37 + BGPType getType();
38 +
39 + /**
40 + * Returns hold time of Open Message.
41 + *
42 + * @return hold time of Open Message
43 + */
44 + short getHoldTime();
45 +
46 + /**
47 + * Returns AS Number of Open Message.
48 + *
49 + * @return AS Number of Open Message
50 + */
51 + short getAsNumber();
52 +
53 + /**
54 + * Returns BGP Identifier of Open Message.
55 + *
56 + * @return BGP Identifier of Open Message
57 + */
58 + int getBgpId();
59 +
60 + /**
61 + * Returns capabilities of Open Message.
62 + *
63 + * @return capabilities of Open Message
64 + */
65 + LinkedList<BGPValueType> getCapabilityTlv();
66 +
67 + /**
68 + * Builder interface with get and set functions to build Open message.
69 + */
70 + interface Builder extends BGPMessage.Builder {
71 +
72 + @Override
73 + BGPOpenMsg build() throws BGPParseException;
74 +
75 + @Override
76 + BGPHeader getHeader();
77 +
78 + @Override
79 + BGPVersion getVersion();
80 +
81 + @Override
82 + BGPType getType();
83 +
84 + /**
85 + * Returns hold time of Open Message.
86 + *
87 + * @return hold time of Open Message
88 + */
89 + short getHoldTime();
90 +
91 + /**
92 + * Sets hold time in Open Message and return its builder.
93 + *
94 + * @param holdtime
95 + * hold timer value in open message
96 + * @return builder by setting hold time
97 + */
98 + Builder setHoldTime(short holdtime);
99 +
100 + /**
101 + * Returns as number of Open Message.
102 + *
103 + * @return as number of Open Message
104 + */
105 + short getAsNumber();
106 +
107 + /**
108 + * Sets AS number in Open Message and return its builder.
109 + *
110 + * @param asNumber
111 + * as number in open message
112 + * @return builder by setting asNumber
113 + */
114 + Builder setAsNumber(short asNumber);
115 +
116 + /**
117 + * Returns BGP Identifier of Open Message.
118 + *
119 + * @return BGP Identifier of Open Message
120 + */
121 + int getBgpId();
122 +
123 + /**
124 + * Sets BGP Identifier in Open Message and return its builder.
125 + *
126 + * @param bgpId
127 + * BGP Identifier in open message
128 + * @return builder by setting BGP Identifier
129 + */
130 + Builder setBgpId(int bgpId);
131 +
132 + /**
133 + * Returns capabilities of Open Message.
134 + *
135 + * @return capabilities of Open Message
136 + */
137 + LinkedList<BGPValueType> getCapabilityTlv();
138 +
139 + /**
140 + * Sets capabilities in Open Message and return its builder.
141 + *
142 + * @param capabilityTlv
143 + * capabilities in open message
144 + * @return builder by setting capabilities
145 + */
146 + Builder setCapabilityTlv(LinkedList<BGPValueType> capabilityTlv);
147 +
148 + @Override
149 + Builder setHeader(BGPHeader bgpMsgHeader);
150 + }
151 +}