blob: ac6ae6098f6221e1c39527f29f21d08990f766a1 [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 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070029 IPacket getPayload();
alshabibc4901cd2014-09-05 16:50:40 -070030
31 /**
32 *
tom5f18cf32014-09-13 14:10:57 -070033 * @param packet new payload
34 * @return self
alshabibc4901cd2014-09-05 16:50:40 -070035 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070036 IPacket setPayload(IPacket packet);
alshabibc4901cd2014-09-05 16:50:40 -070037
38 /**
39 *
tom5f18cf32014-09-13 14:10:57 -070040 * @return parent packet
alshabibc4901cd2014-09-05 16:50:40 -070041 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070042 IPacket getParent();
alshabibc4901cd2014-09-05 16:50:40 -070043
44 /**
45 *
tom5f18cf32014-09-13 14:10:57 -070046 * @param packet new parent
47 * @return self
alshabibc4901cd2014-09-05 16:50:40 -070048 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070049 IPacket setParent(IPacket packet);
alshabibc4901cd2014-09-05 16:50:40 -070050
51 /**
52 * Reset any checksums as needed, and call resetChecksum on all parents.
53 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070054 void resetChecksum();
alshabibc4901cd2014-09-05 16:50:40 -070055
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 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070062 byte[] serialize();
alshabibc4901cd2014-09-05 16:50:40 -070063
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 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070074 IPacket deserialize(byte[] data, int offset, int length);
alshabibc4901cd2014-09-05 16:50:40 -070075
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 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070081 Object clone();
alshabibc4901cd2014-09-05 16:50:40 -070082}