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