alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * Copyright 2014 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 | * Copyright 2011, Big Switch Networks, Inc. |
| 18 | * Originally created by David Erickson, Stanford University |
| 19 | * |
| 20 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 21 | * not use this file except in compliance with the License. You may obtain |
| 22 | * a copy of the License at |
| 23 | * |
| 24 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 25 | * |
| 26 | * Unless required by applicable law or agreed to in writing, software |
| 27 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 28 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 29 | * License for the specific language governing permissions and limitations |
| 30 | * under the License. |
| 31 | **/ |
| 32 | |
| 33 | package org.onlab.packet; |
| 34 | |
| 35 | /** |
| 36 | * |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 37 | */ |
| 38 | public interface IPacket { |
| 39 | /** |
| 40 | * |
tom | 5f18cf3 | 2014-09-13 14:10:57 -0700 | [diff] [blame] | 41 | * @return the payload |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 42 | */ |
| 43 | public IPacket getPayload(); |
| 44 | |
| 45 | /** |
| 46 | * |
tom | 5f18cf3 | 2014-09-13 14:10:57 -0700 | [diff] [blame] | 47 | * @param packet new payload |
| 48 | * @return self |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 49 | */ |
| 50 | public IPacket setPayload(IPacket packet); |
| 51 | |
| 52 | /** |
| 53 | * |
tom | 5f18cf3 | 2014-09-13 14:10:57 -0700 | [diff] [blame] | 54 | * @return parent packet |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 55 | */ |
| 56 | public IPacket getParent(); |
| 57 | |
| 58 | /** |
| 59 | * |
tom | 5f18cf3 | 2014-09-13 14:10:57 -0700 | [diff] [blame] | 60 | * @param packet new parent |
| 61 | * @return self |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 62 | */ |
| 63 | public IPacket setParent(IPacket packet); |
| 64 | |
| 65 | /** |
| 66 | * Reset any checksums as needed, and call resetChecksum on all parents. |
| 67 | */ |
| 68 | public void resetChecksum(); |
| 69 | |
| 70 | /** |
| 71 | * Sets all payloads parent packet if applicable, then serializes this |
| 72 | * packet and all payloads. |
| 73 | * |
| 74 | * @return a byte[] containing this packet and payloads |
| 75 | */ |
| 76 | public byte[] serialize(); |
| 77 | |
| 78 | /** |
| 79 | * Deserializes this packet layer and all possible payloads. |
| 80 | * |
| 81 | * @param data |
| 82 | * @param offset |
| 83 | * offset to start deserializing from |
| 84 | * @param length |
| 85 | * length of the data to deserialize |
| 86 | * @return the deserialized data |
| 87 | */ |
| 88 | public IPacket deserialize(byte[] data, int offset, int length); |
| 89 | |
| 90 | /** |
| 91 | * Clone this packet and its payload packet but not its parent. |
| 92 | * |
tom | 5f18cf3 | 2014-09-13 14:10:57 -0700 | [diff] [blame] | 93 | * @return the clone |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 94 | */ |
| 95 | public Object clone(); |
| 96 | } |