blob: 6e2f2a0234c28cc16018494d3a4d0c02fe48d3fc [file] [log] [blame]
Thomas Vachuska24c849c2014-10-27 09:53:05 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
alshabibc4901cd2014-09-05 16:50:40 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
alshabibc4901cd2014-09-05 16:50:40 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
Thomas Vachuska24c849c2014-10-27 09:53:05 -070015 */
16
17
alshabibc4901cd2014-09-05 16:50:40 -070018
19package org.onlab.packet;
20
21/**
22 *
alshabibc4901cd2014-09-05 16:50:40 -070023 */
24public interface IPacket {
25 /**
26 *
tom5f18cf32014-09-13 14:10:57 -070027 * @return the payload
alshabibc4901cd2014-09-05 16:50:40 -070028 */
29 public IPacket getPayload();
30
31 /**
32 *
tom5f18cf32014-09-13 14:10:57 -070033 * @param packet new payload
34 * @return self
alshabibc4901cd2014-09-05 16:50:40 -070035 */
36 public IPacket setPayload(IPacket packet);
37
38 /**
39 *
tom5f18cf32014-09-13 14:10:57 -070040 * @return parent packet
alshabibc4901cd2014-09-05 16:50:40 -070041 */
42 public IPacket getParent();
43
44 /**
45 *
tom5f18cf32014-09-13 14:10:57 -070046 * @param packet new parent
47 * @return self
alshabibc4901cd2014-09-05 16:50:40 -070048 */
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 *
60 * @return a byte[] containing this packet and payloads
61 */
62 public byte[] serialize();
63
64 /**
65 * Deserializes this packet layer and all possible payloads.
66 *
Yuta HIGUCHI5c947272014-11-03 21:39:21 -080067 * @param data bytes to deserialize
alshabibc4901cd2014-09-05 16:50:40 -070068 * @param offset
69 * offset to start deserializing from
70 * @param length
71 * length of the data to deserialize
72 * @return the deserialized data
73 */
74 public IPacket deserialize(byte[] data, int offset, int length);
75
76 /**
77 * Clone this packet and its payload packet but not its parent.
78 *
tom5f18cf32014-09-13 14:10:57 -070079 * @return the clone
alshabibc4901cd2014-09-05 16:50:40 -070080 */
81 public Object clone();
82}