Thomas Vachuska | 24c849c | 2014-10-27 09:53:05 -0700 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 2 | * Copyright 2014 Open Networking Laboratory |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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 |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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. |
Thomas Vachuska | 24c849c | 2014-10-27 09:53:05 -0700 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 18 | |
| 19 | package org.onlab.packet; |
| 20 | |
| 21 | /** |
| 22 | * |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 23 | */ |
| 24 | public interface IPacket { |
| 25 | /** |
| 26 | * |
tom | 5f18cf3 | 2014-09-13 14:10:57 -0700 | [diff] [blame] | 27 | * @return the payload |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 28 | */ |
| 29 | public IPacket getPayload(); |
| 30 | |
| 31 | /** |
| 32 | * |
tom | 5f18cf3 | 2014-09-13 14:10:57 -0700 | [diff] [blame] | 33 | * @param packet new payload |
| 34 | * @return self |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 35 | */ |
| 36 | public IPacket setPayload(IPacket packet); |
| 37 | |
| 38 | /** |
| 39 | * |
tom | 5f18cf3 | 2014-09-13 14:10:57 -0700 | [diff] [blame] | 40 | * @return parent packet |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 41 | */ |
| 42 | public IPacket getParent(); |
| 43 | |
| 44 | /** |
| 45 | * |
tom | 5f18cf3 | 2014-09-13 14:10:57 -0700 | [diff] [blame] | 46 | * @param packet new parent |
| 47 | * @return self |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 48 | */ |
| 49 | public IPacket setParent(IPacket packet); |
| 50 | |
| 51 | /** |
| 52 | * Reset any checksums as needed, and call resetChecksum on all parents. |
| 53 | */ |
| 54 | public void resetChecksum(); |
| 55 | |
| 56 | /** |
| 57 | * Sets all payloads parent packet if applicable, then serializes this |
| 58 | * packet and all payloads. |
| 59 | * |
| 60 | * @return a byte[] containing this packet and payloads |
| 61 | */ |
| 62 | public byte[] serialize(); |
| 63 | |
| 64 | /** |
| 65 | * Deserializes this packet layer and all possible payloads. |
| 66 | * |
Yuta HIGUCHI | 5c94727 | 2014-11-03 21:39:21 -0800 | [diff] [blame] | 67 | * @param data bytes to deserialize |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 68 | * @param offset |
| 69 | * offset to start deserializing from |
| 70 | * @param length |
| 71 | * length of the data to deserialize |
| 72 | * @return the deserialized data |
| 73 | */ |
| 74 | public IPacket deserialize(byte[] data, int offset, int length); |
| 75 | |
| 76 | /** |
| 77 | * Clone this packet and its payload packet but not its parent. |
| 78 | * |
tom | 5f18cf3 | 2014-09-13 14:10:57 -0700 | [diff] [blame] | 79 | * @return the clone |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 80 | */ |
| 81 | public Object clone(); |
| 82 | } |