blob: ed7f28728c3cf0c1530fe48dc93868e13b27cb28 [file] [log] [blame]
Thomas Vachuska24c849c2014-10-27 09:53:05 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2014-present Open Networking Foundation
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
alshabibc4901cd2014-09-05 16:50:40 -070017package org.onlab.packet;
18
19/**
Jian Li5fc14292015-12-04 11:30:46 -080020 * Packet Interface.
alshabibc4901cd2014-09-05 16:50:40 -070021 */
22public interface IPacket {
Jian Li5fc14292015-12-04 11:30:46 -080023
alshabibc4901cd2014-09-05 16:50:40 -070024 /**
Jian Li5fc14292015-12-04 11:30:46 -080025 * Obtain the packet payload.
alshabibc4901cd2014-09-05 16:50:40 -070026 *
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 /**
Jian Li5fc14292015-12-04 11:30:46 -080032 * Assign the packet payload.
alshabibc4901cd2014-09-05 16:50:40 -070033 *
tom5f18cf32014-09-13 14:10:57 -070034 * @param packet new payload
35 * @return self
alshabibc4901cd2014-09-05 16:50:40 -070036 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070037 IPacket setPayload(IPacket packet);
alshabibc4901cd2014-09-05 16:50:40 -070038
39 /**
Jian Li5fc14292015-12-04 11:30:46 -080040 * Obtain the parent packet.
alshabibc4901cd2014-09-05 16:50:40 -070041 *
tom5f18cf32014-09-13 14:10:57 -070042 * @return parent packet
alshabibc4901cd2014-09-05 16:50:40 -070043 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070044 IPacket getParent();
alshabibc4901cd2014-09-05 16:50:40 -070045
46 /**
Jian Li5fc14292015-12-04 11:30:46 -080047 * Configure a new parent packet.
alshabibc4901cd2014-09-05 16:50:40 -070048 *
tom5f18cf32014-09-13 14:10:57 -070049 * @param packet new parent
50 * @return self
alshabibc4901cd2014-09-05 16:50:40 -070051 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070052 IPacket setParent(IPacket packet);
alshabibc4901cd2014-09-05 16:50:40 -070053
54 /**
Jian Li5fc14292015-12-04 11:30:46 -080055 * Reset any checksum as needed, and call resetChecksum on all parents.
alshabibc4901cd2014-09-05 16:50:40 -070056 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070057 void resetChecksum();
alshabibc4901cd2014-09-05 16:50:40 -070058
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 SHIMIZU3310a342015-05-13 12:14:05 -070065 byte[] serialize();
alshabibc4901cd2014-09-05 16:50:40 -070066
alshabibc4901cd2014-09-05 16:50:40 -070067
alshabibc4901cd2014-09-05 16:50:40 -070068}