Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 1 | /** |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 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 | **/ |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 17 | |
Jonathan Hart | deda0ba | 2014-04-03 11:14:12 -0700 | [diff] [blame] | 18 | package net.onrc.onos.core.packet; |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 19 | |
| 20 | /** |
Ray Milkey | b41100a | 2014-04-10 10:42:15 -0700 | [diff] [blame] | 21 | * @author David Erickson (daviderickson@cs.stanford.edu). |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 22 | */ |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 23 | public interface IPacket { |
| 24 | /** |
Jonathan Hart | 99ff20a | 2014-06-15 16:53:00 -0700 | [diff] [blame^] | 25 | * Gets the payload of the packet. |
| 26 | * |
| 27 | * @return the payload of the packet |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 28 | */ |
| 29 | public IPacket getPayload(); |
| 30 | |
| 31 | /** |
Jonathan Hart | 99ff20a | 2014-06-15 16:53:00 -0700 | [diff] [blame^] | 32 | * Sets the payload of the packet. |
| 33 | * |
| 34 | * @param packet the inner packet to set as the payload |
| 35 | * @return this IPacket |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 36 | */ |
| 37 | public IPacket setPayload(IPacket packet); |
| 38 | |
| 39 | /** |
Jonathan Hart | 99ff20a | 2014-06-15 16:53:00 -0700 | [diff] [blame^] | 40 | * Gets the parent (outer) packet. |
| 41 | * |
| 42 | * @return the parent packet |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 43 | */ |
| 44 | public IPacket getParent(); |
| 45 | |
| 46 | /** |
Jonathan Hart | 99ff20a | 2014-06-15 16:53:00 -0700 | [diff] [blame^] | 47 | * Sets the parent (outer) packet. |
| 48 | * |
| 49 | * @param packet the parent packet |
| 50 | * @return this IPacket |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 51 | */ |
| 52 | public IPacket setParent(IPacket packet); |
| 53 | |
| 54 | /** |
Ray Milkey | b41100a | 2014-04-10 10:42:15 -0700 | [diff] [blame] | 55 | * Reset any checksums as needed, and call resetChecksum on all parents. |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 56 | */ |
| 57 | public void resetChecksum(); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 58 | |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 59 | /** |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 60 | * Sets all payloads parent packet if applicable, then serializes this |
Ray Milkey | b41100a | 2014-04-10 10:42:15 -0700 | [diff] [blame] | 61 | * packet and all payloads. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 62 | * |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 63 | * @return a byte[] containing this packet and payloads |
| 64 | */ |
| 65 | public byte[] serialize(); |
| 66 | |
| 67 | /** |
Ray Milkey | b41100a | 2014-04-10 10:42:15 -0700 | [diff] [blame] | 68 | * Deserializes this packet layer and all possible payloads. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 69 | * |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 70 | * @param data |
| 71 | * @param offset offset to start deserializing from |
| 72 | * @param length length of the data to deserialize |
| 73 | * @return the deserialized data |
| 74 | */ |
| 75 | public IPacket deserialize(byte[] data, int offset, int length); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 76 | |
| 77 | /** |
| 78 | * Clone this packet and its payload packet but not its parent. |
| 79 | * |
Jonathan Hart | 99ff20a | 2014-06-15 16:53:00 -0700 | [diff] [blame^] | 80 | * @return a cloned copy of this packet |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 81 | */ |
| 82 | public Object clone(); |
| 83 | } |