blob: 0c64c628e3d5c5c3bdc060fc792f2c65d74489b1 [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 *
41 * @author alexreimers
42 *
43 */
44public class LLC extends BasePacket {
45 private byte dsap = 0;
46 private byte ssap = 0;
47 private byte ctrl = 0;
48
49 public byte getDsap() {
50 return this.dsap;
51 }
52
53 public void setDsap(final byte dsap) {
54 this.dsap = dsap;
55 }
56
57 public byte getSsap() {
58 return this.ssap;
59 }
60
61 public void setSsap(final byte ssap) {
62 this.ssap = ssap;
63 }
64
65 public byte getCtrl() {
66 return this.ctrl;
67 }
68
69 public void setCtrl(final byte ctrl) {
70 this.ctrl = ctrl;
71 }
72
73 @Override
74 public byte[] serialize() {
75 final byte[] data = new byte[3];
76 final ByteBuffer bb = ByteBuffer.wrap(data);
77 bb.put(this.dsap);
78 bb.put(this.ssap);
79 bb.put(this.ctrl);
80 return data;
81 }
82
83 @Override
84 public IPacket deserialize(final byte[] data, final int offset,
85 final int length) {
86 final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
87 this.dsap = bb.get();
88 this.ssap = bb.get();
89 this.ctrl = bb.get();
90 return this;
91 }
92}