blob: cb48f88ebc6c0e5acefccfa6bba2a629e13d8c69 [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001/**
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
Jonathan Hart96892d12014-03-26 20:21:29 -070018package net.onrc.onos.packet;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080019
20/**
21*
22* @author David Erickson (daviderickson@cs.stanford.edu)
23*/
24public 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}