blob: 64e6ac36be3838b21d878781d0981ec83371d7ca [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 *
Jonathan Hart2a655752015-04-07 16:46:33 -070067 * NOTE: This method has been deprecated and will be removed in a future
68 * release. It is now recommended to use the Deserializer function provided
69 * by the deserialize() method on each packet to deserialize them. The
70 * Deserializer functions are robust to malformed input.
71 *
Yuta HIGUCHI5c947272014-11-03 21:39:21 -080072 * @param data bytes to deserialize
alshabibc4901cd2014-09-05 16:50:40 -070073 * @param offset
74 * offset to start deserializing from
75 * @param length
76 * length of the data to deserialize
77 * @return the deserialized data
Sho SHIMIZUbe63b232015-06-30 10:57:58 -070078 * @deprecated in Cardinal Release
alshabibc4901cd2014-09-05 16:50:40 -070079 */
Jonathan Hart2a655752015-04-07 16:46:33 -070080 @Deprecated
Sho SHIMIZU3310a342015-05-13 12:14:05 -070081 IPacket deserialize(byte[] data, int offset, int length);
alshabibc4901cd2014-09-05 16:50:40 -070082
83 /**
84 * Clone this packet and its payload packet but not its parent.
85 *
tom5f18cf32014-09-13 14:10:57 -070086 * @return the clone
alshabibc4901cd2014-09-05 16:50:40 -070087 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070088 Object clone();
alshabibc4901cd2014-09-05 16:50:40 -070089}