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