Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 1 | /** |
| 2 | * Copyright 2011, Big Switch Networks, Inc. |
| 3 | * Originally created by David Erickson, Stanford University |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 6 | * not use this file except in compliance with the License. You may obtain |
| 7 | * a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | * License for the specific language governing permissions and limitations |
| 15 | * under the License. |
| 16 | **/ |
| 17 | |
| 18 | package net.floodlightcontroller.packet; |
| 19 | |
| 20 | /** |
| 21 | * |
| 22 | * @author David Erickson (daviderickson@cs.stanford.edu) |
| 23 | */ |
| 24 | public interface IPacket { |
| 25 | /** |
| 26 | * |
| 27 | * @return |
| 28 | */ |
| 29 | public IPacket getPayload(); |
| 30 | |
| 31 | /** |
| 32 | * |
| 33 | * @param packet |
| 34 | * @return |
| 35 | */ |
| 36 | public IPacket setPayload(IPacket packet); |
| 37 | |
| 38 | /** |
| 39 | * |
| 40 | * @return |
| 41 | */ |
| 42 | public IPacket getParent(); |
| 43 | |
| 44 | /** |
| 45 | * |
| 46 | * @param packet |
| 47 | * @return |
| 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 | * @return a byte[] containing this packet and payloads |
| 60 | */ |
| 61 | public byte[] serialize(); |
| 62 | |
| 63 | /** |
| 64 | * Deserializes this packet layer and all possible payloads |
| 65 | * @param data |
| 66 | * @param offset offset to start deserializing from |
| 67 | * @param length length of the data to deserialize |
| 68 | * @return the deserialized data |
| 69 | */ |
| 70 | public IPacket deserialize(byte[] data, int offset, int length); |
| 71 | |
| 72 | /** Clone this packet and its payload packet but not its parent. |
| 73 | * |
| 74 | * @return |
| 75 | */ |
| 76 | public Object clone(); |
| 77 | } |