blob: 9cbba4d06be733c684ea22fc8df33b3e4088c212 [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001/**
Ray Milkey269ffb92014-04-03 14:43:30 -07002 * 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 Krishnaswamy345ee992012-12-13 20:29:48 -080017
Jonathan Hartdeda0ba2014-04-03 11:14:12 -070018package net.onrc.onos.core.packet;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080019
20/**
Ray Milkeyb41100a2014-04-10 10:42:15 -070021 * @author David Erickson (daviderickson@cs.stanford.edu).
Ray Milkey269ffb92014-04-03 14:43:30 -070022 */
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080023public interface IPacket {
24 /**
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080025 * @return
26 */
27 public IPacket getPayload();
28
29 /**
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080030 * @param packet
31 * @return
32 */
33 public IPacket setPayload(IPacket packet);
34
35 /**
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080036 * @return
37 */
38 public IPacket getParent();
39
40 /**
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080041 * @param packet
42 * @return
43 */
44 public IPacket setParent(IPacket packet);
45
46 /**
Ray Milkeyb41100a2014-04-10 10:42:15 -070047 * Reset any checksums as needed, and call resetChecksum on all parents.
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080048 */
49 public void resetChecksum();
Ray Milkey269ffb92014-04-03 14:43:30 -070050
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080051 /**
Ray Milkey269ffb92014-04-03 14:43:30 -070052 * Sets all payloads parent packet if applicable, then serializes this
Ray Milkeyb41100a2014-04-10 10:42:15 -070053 * packet and all payloads.
Ray Milkey269ffb92014-04-03 14:43:30 -070054 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080055 * @return a byte[] containing this packet and payloads
56 */
57 public byte[] serialize();
58
59 /**
Ray Milkeyb41100a2014-04-10 10:42:15 -070060 * Deserializes this packet layer and all possible payloads.
Ray Milkey269ffb92014-04-03 14:43:30 -070061 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080062 * @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 Milkey269ffb92014-04-03 14:43:30 -070068
69 /**
70 * Clone this packet and its payload packet but not its parent.
71 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080072 * @return
73 */
74 public Object clone();
75}