blob: 55d18e5cc359c059a5e06bf9fd7a3c12ac823667 [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
Yuta HIGUCHIaa132f52014-06-26 10:18:39 -070020// CHECKSTYLE IGNORE WriteTag FOR NEXT 2 LINES
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080021/**
Ray Milkeyb41100a2014-04-10 10:42:15 -070022 * @author David Erickson (daviderickson@cs.stanford.edu).
Ray Milkey269ffb92014-04-03 14:43:30 -070023 */
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080024public interface IPacket {
25 /**
Jonathan Hart99ff20a2014-06-15 16:53:00 -070026 * Gets the payload of the packet.
27 *
28 * @return the payload of the packet
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080029 */
30 public IPacket getPayload();
31
32 /**
Jonathan Hart99ff20a2014-06-15 16:53:00 -070033 * Sets the payload of the packet.
34 *
35 * @param packet the inner packet to set as the payload
36 * @return this IPacket
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080037 */
38 public IPacket setPayload(IPacket packet);
39
40 /**
Jonathan Hart99ff20a2014-06-15 16:53:00 -070041 * Gets the parent (outer) packet.
42 *
43 * @return the parent packet
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080044 */
45 public IPacket getParent();
46
47 /**
Jonathan Hart99ff20a2014-06-15 16:53:00 -070048 * Sets the parent (outer) packet.
49 *
50 * @param packet the parent packet
51 * @return this IPacket
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080052 */
53 public IPacket setParent(IPacket packet);
54
55 /**
Ray Milkeyb41100a2014-04-10 10:42:15 -070056 * Reset any checksums as needed, and call resetChecksum on all parents.
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080057 */
58 public void resetChecksum();
Ray Milkey269ffb92014-04-03 14:43:30 -070059
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080060 /**
Ray Milkey269ffb92014-04-03 14:43:30 -070061 * Sets all payloads parent packet if applicable, then serializes this
Ray Milkeyb41100a2014-04-10 10:42:15 -070062 * packet and all payloads.
Ray Milkey269ffb92014-04-03 14:43:30 -070063 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080064 * @return a byte[] containing this packet and payloads
65 */
66 public byte[] serialize();
67
68 /**
Ray Milkeyb41100a2014-04-10 10:42:15 -070069 * Deserializes this packet layer and all possible payloads.
Ray Milkey269ffb92014-04-03 14:43:30 -070070 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080071 * @param data
72 * @param offset offset to start deserializing from
73 * @param length length of the data to deserialize
74 * @return the deserialized data
75 */
76 public IPacket deserialize(byte[] data, int offset, int length);
Ray Milkey269ffb92014-04-03 14:43:30 -070077
78 /**
79 * Clone this packet and its payload packet but not its parent.
80 *
Jonathan Hart99ff20a2014-06-15 16:53:00 -070081 * @return a cloned copy of this packet
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080082 */
83 public Object clone();
84}