blob: 829492fedf8f964e9cf60f31396125900664e502 [file] [log] [blame]
alshabibc4901cd2014-09-05 16:50:40 -07001/*******************************************************************************
2 * Copyright 2014 Open Networking Laboratory
3 *
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
7 *
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.
15 ******************************************************************************/
16/**
17 * Copyright 2011, Big Switch Networks, Inc.
18 * Originally created by David Erickson, Stanford University
19 *
20 * Licensed under the Apache License, Version 2.0 (the "License"); you may
21 * not use this file except in compliance with the License. You may obtain
22 * a copy of the License at
23 *
24 * http://www.apache.org/licenses/LICENSE-2.0
25 *
26 * Unless required by applicable law or agreed to in writing, software
27 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
28 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
29 * License for the specific language governing permissions and limitations
30 * under the License.
31 **/
32
33package org.onlab.packet;
34
35/**
36 *
alshabibc4901cd2014-09-05 16:50:40 -070037 */
38public interface IPacket {
39 /**
40 *
tom5f18cf32014-09-13 14:10:57 -070041 * @return the payload
alshabibc4901cd2014-09-05 16:50:40 -070042 */
43 public IPacket getPayload();
44
45 /**
46 *
tom5f18cf32014-09-13 14:10:57 -070047 * @param packet new payload
48 * @return self
alshabibc4901cd2014-09-05 16:50:40 -070049 */
50 public IPacket setPayload(IPacket packet);
51
52 /**
53 *
tom5f18cf32014-09-13 14:10:57 -070054 * @return parent packet
alshabibc4901cd2014-09-05 16:50:40 -070055 */
56 public IPacket getParent();
57
58 /**
59 *
tom5f18cf32014-09-13 14:10:57 -070060 * @param packet new parent
61 * @return self
alshabibc4901cd2014-09-05 16:50:40 -070062 */
63 public IPacket setParent(IPacket packet);
64
65 /**
66 * Reset any checksums as needed, and call resetChecksum on all parents.
67 */
68 public void resetChecksum();
69
70 /**
71 * Sets all payloads parent packet if applicable, then serializes this
72 * packet and all payloads.
73 *
74 * @return a byte[] containing this packet and payloads
75 */
76 public byte[] serialize();
77
78 /**
79 * Deserializes this packet layer and all possible payloads.
80 *
81 * @param data
82 * @param offset
83 * offset to start deserializing from
84 * @param length
85 * length of the data to deserialize
86 * @return the deserialized data
87 */
88 public IPacket deserialize(byte[] data, int offset, int length);
89
90 /**
91 * Clone this packet and its payload packet but not its parent.
92 *
tom5f18cf32014-09-13 14:10:57 -070093 * @return the clone
alshabibc4901cd2014-09-05 16:50:40 -070094 */
95 public Object clone();
96}