blob: a359e05df98026c737030f680f35a96692d59b34 [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
35import java.nio.ByteBuffer;
36
37/**
38 * This class represents an Link Local Control header that is used in Ethernet
39 * 802.3.
40 *
alshabibc4901cd2014-09-05 16:50:40 -070041 *
42 */
43public class LLC extends BasePacket {
44 private byte dsap = 0;
45 private byte ssap = 0;
46 private byte ctrl = 0;
47
48 public byte getDsap() {
49 return this.dsap;
50 }
51
52 public void setDsap(final byte dsap) {
53 this.dsap = dsap;
54 }
55
56 public byte getSsap() {
57 return this.ssap;
58 }
59
60 public void setSsap(final byte ssap) {
61 this.ssap = ssap;
62 }
63
64 public byte getCtrl() {
65 return this.ctrl;
66 }
67
68 public void setCtrl(final byte ctrl) {
69 this.ctrl = ctrl;
70 }
71
72 @Override
73 public byte[] serialize() {
74 final byte[] data = new byte[3];
75 final ByteBuffer bb = ByteBuffer.wrap(data);
76 bb.put(this.dsap);
77 bb.put(this.ssap);
78 bb.put(this.ctrl);
79 return data;
80 }
81
82 @Override
83 public IPacket deserialize(final byte[] data, final int offset,
84 final int length) {
85 final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
86 this.dsap = bb.get();
87 this.ssap = bb.get();
88 this.ctrl = bb.get();
89 return this;
90 }
91}