Thomas Vachuska | 24c849c | 2014-10-27 09:53:05 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
Thomas Vachuska | 24c849c | 2014-10-27 09:53:05 -0700 | [diff] [blame] | 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 17 | * under the License. |
Thomas Vachuska | 24c849c | 2014-10-27 09:53:05 -0700 | [diff] [blame] | 18 | */ |
| 19 | |
| 20 | |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 21 | |
| 22 | package org.onlab.packet; |
| 23 | |
| 24 | /** |
| 25 | * |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 26 | */ |
| 27 | public interface IPacket { |
| 28 | /** |
| 29 | * |
tom | 5f18cf3 | 2014-09-13 14:10:57 -0700 | [diff] [blame] | 30 | * @return the payload |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 31 | */ |
| 32 | public IPacket getPayload(); |
| 33 | |
| 34 | /** |
| 35 | * |
tom | 5f18cf3 | 2014-09-13 14:10:57 -0700 | [diff] [blame] | 36 | * @param packet new payload |
| 37 | * @return self |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 38 | */ |
| 39 | public IPacket setPayload(IPacket packet); |
| 40 | |
| 41 | /** |
| 42 | * |
tom | 5f18cf3 | 2014-09-13 14:10:57 -0700 | [diff] [blame] | 43 | * @return parent packet |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 44 | */ |
| 45 | public IPacket getParent(); |
| 46 | |
| 47 | /** |
| 48 | * |
tom | 5f18cf3 | 2014-09-13 14:10:57 -0700 | [diff] [blame] | 49 | * @param packet new parent |
| 50 | * @return self |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 51 | */ |
| 52 | public IPacket setParent(IPacket packet); |
| 53 | |
| 54 | /** |
| 55 | * Reset any checksums as needed, and call resetChecksum on all parents. |
| 56 | */ |
| 57 | public void resetChecksum(); |
| 58 | |
| 59 | /** |
| 60 | * Sets all payloads parent packet if applicable, then serializes this |
| 61 | * packet and all payloads. |
| 62 | * |
| 63 | * @return a byte[] containing this packet and payloads |
| 64 | */ |
| 65 | public byte[] serialize(); |
| 66 | |
| 67 | /** |
| 68 | * Deserializes this packet layer and all possible payloads. |
| 69 | * |
| 70 | * @param data |
| 71 | * @param offset |
| 72 | * offset to start deserializing from |
| 73 | * @param length |
| 74 | * length of the data to deserialize |
| 75 | * @return the deserialized data |
| 76 | */ |
| 77 | public IPacket deserialize(byte[] data, int offset, int length); |
| 78 | |
| 79 | /** |
| 80 | * Clone this packet and its payload packet but not its parent. |
| 81 | * |
tom | 5f18cf3 | 2014-09-13 14:10:57 -0700 | [diff] [blame] | 82 | * @return the clone |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 83 | */ |
| 84 | public Object clone(); |
| 85 | } |