blob: f02c30797a97acd79a997096bfa23d3659956509 [file] [log] [blame]
Thomas Vachuska24c849c2014-10-27 09:53:05 -07001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
alshabibc4901cd2014-09-05 16:50:40 -07009 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
Thomas Vachuska24c849c2014-10-27 09:53:05 -070012 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
alshabibc4901cd2014-09-05 16:50:40 -070017 * under the License.
Thomas Vachuska24c849c2014-10-27 09:53:05 -070018 */
19
20
alshabibc4901cd2014-09-05 16:50:40 -070021
22package org.onlab.packet;
23
24/**
25 *
alshabibc4901cd2014-09-05 16:50:40 -070026 */
27public interface IPacket {
28 /**
29 *
tom5f18cf32014-09-13 14:10:57 -070030 * @return the payload
alshabibc4901cd2014-09-05 16:50:40 -070031 */
32 public IPacket getPayload();
33
34 /**
35 *
tom5f18cf32014-09-13 14:10:57 -070036 * @param packet new payload
37 * @return self
alshabibc4901cd2014-09-05 16:50:40 -070038 */
39 public IPacket setPayload(IPacket packet);
40
41 /**
42 *
tom5f18cf32014-09-13 14:10:57 -070043 * @return parent packet
alshabibc4901cd2014-09-05 16:50:40 -070044 */
45 public IPacket getParent();
46
47 /**
48 *
tom5f18cf32014-09-13 14:10:57 -070049 * @param packet new parent
50 * @return self
alshabibc4901cd2014-09-05 16:50:40 -070051 */
52 public IPacket setParent(IPacket packet);
53
54 /**
55 * Reset any checksums as needed, and call resetChecksum on all parents.
56 */
57 public void resetChecksum();
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 */
65 public byte[] serialize();
66
67 /**
68 * Deserializes this packet layer and all possible payloads.
69 *
70 * @param data
71 * @param offset
72 * offset to start deserializing from
73 * @param length
74 * length of the data to deserialize
75 * @return the deserialized data
76 */
77 public IPacket deserialize(byte[] data, int offset, int length);
78
79 /**
80 * Clone this packet and its payload packet but not its parent.
81 *
tom5f18cf32014-09-13 14:10:57 -070082 * @return the clone
alshabibc4901cd2014-09-05 16:50:40 -070083 */
84 public Object clone();
85}