Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 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 org.jboss.netty.buffer.ChannelBuffer; |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 20 | import org.onosproject.bgpio.exceptions.BgpParseException; |
| 21 | import org.onosproject.bgpio.types.BgpHeader; |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 22 | |
| 23 | /** |
| 24 | * Abstraction of an entity providing BGP Messages. |
| 25 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 26 | public interface BgpMessage extends Writeable { |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 27 | /** |
| 28 | * Returns BGP Header of BGP Message. |
| 29 | * |
| 30 | * @return BGP Header of BGP Message |
| 31 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 32 | BgpHeader getHeader(); |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 33 | |
| 34 | /** |
| 35 | * Returns version of BGP Message. |
| 36 | * |
| 37 | * @return version of BGP Message |
| 38 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 39 | BgpVersion getVersion(); |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 40 | |
| 41 | /** |
| 42 | * Returns BGP Type of BGP Message. |
| 43 | * |
| 44 | * @return BGP Type of BGP Message |
| 45 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 46 | BgpType getType(); |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 47 | |
| 48 | @Override |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 49 | void writeTo(ChannelBuffer cb) throws BgpParseException; |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 50 | |
| 51 | /** |
| 52 | * Builder interface with get and set functions to build BGP Message. |
| 53 | */ |
| 54 | interface Builder { |
| 55 | /** |
| 56 | * Builds BGP Message. |
| 57 | * |
| 58 | * @return BGP Message |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 59 | * @throws BgpParseException while building bgp message |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 60 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 61 | BgpMessage build() throws BgpParseException; |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 62 | |
| 63 | /** |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 64 | * Sets BgpHeader and return its builder. |
| 65 | * |
| 66 | * @param bgpMsgHeader BGP Message Header |
| 67 | * @return builder by setting BGP message header |
| 68 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 69 | Builder setHeader(BgpHeader bgpMsgHeader); |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 70 | } |
| 71 | } |