Thomas Vachuska | 24c849c | 2014-10-27 09:53:05 -0700 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 2 | * Copyright 2014 Open Networking Laboratory |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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 |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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. |
Thomas Vachuska | 24c849c | 2014-10-27 09:53:05 -0700 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 18 | |
| 19 | package org.onlab.packet; |
| 20 | |
| 21 | import java.nio.ByteBuffer; |
| 22 | |
| 23 | /** |
| 24 | * This class represents an Link Local Control header that is used in Ethernet |
| 25 | * 802.3. |
| 26 | * |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 27 | * |
| 28 | */ |
| 29 | public class LLC extends BasePacket { |
| 30 | private byte dsap = 0; |
| 31 | private byte ssap = 0; |
| 32 | private byte ctrl = 0; |
| 33 | |
| 34 | public byte getDsap() { |
| 35 | return this.dsap; |
| 36 | } |
| 37 | |
| 38 | public void setDsap(final byte dsap) { |
| 39 | this.dsap = dsap; |
| 40 | } |
| 41 | |
| 42 | public byte getSsap() { |
| 43 | return this.ssap; |
| 44 | } |
| 45 | |
| 46 | public void setSsap(final byte ssap) { |
| 47 | this.ssap = ssap; |
| 48 | } |
| 49 | |
| 50 | public byte getCtrl() { |
| 51 | return this.ctrl; |
| 52 | } |
| 53 | |
| 54 | public void setCtrl(final byte ctrl) { |
| 55 | this.ctrl = ctrl; |
| 56 | } |
| 57 | |
| 58 | @Override |
| 59 | public byte[] serialize() { |
| 60 | final byte[] data = new byte[3]; |
| 61 | final ByteBuffer bb = ByteBuffer.wrap(data); |
| 62 | bb.put(this.dsap); |
| 63 | bb.put(this.ssap); |
| 64 | bb.put(this.ctrl); |
| 65 | return data; |
| 66 | } |
| 67 | |
| 68 | @Override |
| 69 | public IPacket deserialize(final byte[] data, final int offset, |
| 70 | final int length) { |
| 71 | final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); |
| 72 | this.dsap = bb.get(); |
| 73 | this.ssap = bb.get(); |
| 74 | this.ctrl = bb.get(); |
| 75 | return this; |
| 76 | } |
| 77 | } |