Thomas Vachuska | 24c849c | 2014-10-27 09:53:05 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Laboratory |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 4 | * 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 | ||||
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 8 | * 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 Vachuska | 24c849c | 2014-10-27 09:53:05 -0700 | [diff] [blame] | 15 | */ |
16 | |||||
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 17 | package org.onlab.packet; |
18 | |||||
19 | /** | ||||
Jian Li | 5fc1429 | 2015-12-04 11:30:46 -0800 | [diff] [blame] | 20 | * Packet Interface. |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 21 | */ |
22 | public interface IPacket { | ||||
Jian Li | 5fc1429 | 2015-12-04 11:30:46 -0800 | [diff] [blame] | 23 | |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 24 | /** |
Jian Li | 5fc1429 | 2015-12-04 11:30:46 -0800 | [diff] [blame] | 25 | * Obtain the packet payload. |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 26 | * |
tom | 5f18cf3 | 2014-09-13 14:10:57 -0700 | [diff] [blame] | 27 | * @return the payload |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 28 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 29 | IPacket getPayload(); |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 30 | |
31 | /** | ||||
Jian Li | 5fc1429 | 2015-12-04 11:30:46 -0800 | [diff] [blame] | 32 | * Assign the packet payload. |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 33 | * |
tom | 5f18cf3 | 2014-09-13 14:10:57 -0700 | [diff] [blame] | 34 | * @param packet new payload |
35 | * @return self | ||||
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 36 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 37 | IPacket setPayload(IPacket packet); |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 38 | |
39 | /** | ||||
Jian Li | 5fc1429 | 2015-12-04 11:30:46 -0800 | [diff] [blame] | 40 | * Obtain the parent packet. |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 41 | * |
tom | 5f18cf3 | 2014-09-13 14:10:57 -0700 | [diff] [blame] | 42 | * @return parent packet |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 43 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 44 | IPacket getParent(); |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 45 | |
46 | /** | ||||
Jian Li | 5fc1429 | 2015-12-04 11:30:46 -0800 | [diff] [blame] | 47 | * Configure a new parent packet. |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 48 | * |
tom | 5f18cf3 | 2014-09-13 14:10:57 -0700 | [diff] [blame] | 49 | * @param packet new parent |
50 | * @return self | ||||
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 51 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 52 | IPacket setParent(IPacket packet); |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 53 | |
54 | /** | ||||
Jian Li | 5fc1429 | 2015-12-04 11:30:46 -0800 | [diff] [blame] | 55 | * Reset any checksum as needed, and call resetChecksum on all parents. |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 56 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 57 | void resetChecksum(); |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 58 | |
59 | /** | ||||
60 | * Sets all payloads parent packet if applicable, then serializes this | ||||
61 | * packet and all payloads. | ||||
62 | * | ||||
63 | * @return a byte[] containing this packet and payloads | ||||
64 | */ | ||||
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 65 | byte[] serialize(); |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 66 | |
67 | /** | ||||
Jian Li | 5fc1429 | 2015-12-04 11:30:46 -0800 | [diff] [blame] | 68 | * Deserialize this packet layer and all possible payloads. |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 69 | * |
Jonathan Hart | 2a65575 | 2015-04-07 16:46:33 -0700 | [diff] [blame] | 70 | * NOTE: This method has been deprecated and will be removed in a future |
71 | * release. It is now recommended to use the Deserializer function provided | ||||
72 | * by the deserialize() method on each packet to deserialize them. The | ||||
73 | * Deserializer functions are robust to malformed input. | ||||
74 | * | ||||
Yuta HIGUCHI | 5c94727 | 2014-11-03 21:39:21 -0800 | [diff] [blame] | 75 | * @param data bytes to deserialize |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 76 | * @param offset |
77 | * offset to start deserializing from | ||||
78 | * @param length | ||||
79 | * length of the data to deserialize | ||||
80 | * @return the deserialized data | ||||
Sho SHIMIZU | be63b23 | 2015-06-30 10:57:58 -0700 | [diff] [blame] | 81 | * @deprecated in Cardinal Release |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 82 | */ |
Jonathan Hart | 2a65575 | 2015-04-07 16:46:33 -0700 | [diff] [blame] | 83 | @Deprecated |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 84 | IPacket deserialize(byte[] data, int offset, int length); |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 85 | |
86 | /** | ||||
87 | * Clone this packet and its payload packet but not its parent. | ||||
88 | * | ||||
tom | 5f18cf3 | 2014-09-13 14:10:57 -0700 | [diff] [blame] | 89 | * @return the clone |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 90 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 91 | Object clone(); |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 92 | } |