Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 1 | /** |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 2 | * Copyright 2011, Big Switch Networks, Inc. |
| 3 | * Originally created by David Erickson, Stanford University |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 6 | * not use this file except in compliance with the License. You may obtain |
| 7 | * a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | * License for the specific language governing permissions and limitations |
| 15 | * under the License. |
| 16 | **/ |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 17 | |
Jonathan Hart | deda0ba | 2014-04-03 11:14:12 -0700 | [diff] [blame] | 18 | package net.onrc.onos.core.packet; |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 19 | |
| 20 | import java.nio.ByteBuffer; |
| 21 | |
| 22 | /** |
| 23 | * This class represents an Link Local Control |
| 24 | * header that is used in Ethernet 802.3. |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 25 | * |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 26 | * @author alexreimers |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 27 | */ |
| 28 | public class LLC extends BasePacket { |
| 29 | private byte dsap = 0; |
| 30 | private byte ssap = 0; |
| 31 | private byte ctrl = 0; |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 32 | |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 33 | public byte getDsap() { |
| 34 | return dsap; |
| 35 | } |
| 36 | |
| 37 | public void setDsap(byte dsap) { |
| 38 | this.dsap = dsap; |
| 39 | } |
| 40 | |
| 41 | public byte getSsap() { |
| 42 | return ssap; |
| 43 | } |
| 44 | |
| 45 | public void setSsap(byte ssap) { |
| 46 | this.ssap = ssap; |
| 47 | } |
| 48 | |
| 49 | public byte getCtrl() { |
| 50 | return ctrl; |
| 51 | } |
| 52 | |
| 53 | public void setCtrl(byte ctrl) { |
| 54 | this.ctrl = ctrl; |
| 55 | } |
| 56 | |
| 57 | @Override |
| 58 | public byte[] serialize() { |
| 59 | byte[] data = new byte[3]; |
| 60 | ByteBuffer bb = ByteBuffer.wrap(data); |
| 61 | bb.put(dsap); |
| 62 | bb.put(ssap); |
| 63 | bb.put(ctrl); |
| 64 | return data; |
| 65 | } |
| 66 | |
| 67 | @Override |
| 68 | public IPacket deserialize(byte[] data, int offset, int length) { |
| 69 | ByteBuffer bb = ByteBuffer.wrap(data, offset, length); |
| 70 | dsap = bb.get(); |
| 71 | ssap = bb.get(); |
| 72 | ctrl = bb.get(); |
| 73 | return this; |
| 74 | } |
| 75 | } |