Thomas Vachuska | 24c849c | 2014-10-27 09:53:05 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Foundation |
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 | |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 67 | |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 68 | } |