001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020 021 package org.apache.directory.server.dhcp.options; 022 023 /** 024 * The Dynamic Host Configuration Protocol (DHCP) provides a framework for 025 * passing configuration information to hosts on a TCP/IP network. Configuration 026 * parameters and other control information are carried in tagged data items 027 * that are stored in the 'options' field of the DHCP message. The data items 028 * themselves are also called "options." 029 * 030 * This abstract base class is for options that carry an unsigned short value 031 * (16 bit). 032 * 033 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 034 * @version $Rev: 551805 $, $Date: 2007-06-29 00:57:04 -0500 (Fr, 29 Jun 2007) $ 035 */ 036 public abstract class ShortOption extends DhcpOption { 037 /** 038 * The short value (represented as an int because of the unsignedness). 039 */ 040 private int shortValue; 041 042 /* 043 * @see org.apache.directory.server.dhcp.options.DhcpOption#setData(byte[]) 044 */ 045 public void setData(byte[] data) { 046 shortValue = (data[0] & 0xff) << 8 | (data[1] & 0xff); 047 } 048 049 /* 050 * @see org.apache.directory.server.dhcp.options.DhcpOption#getData() 051 */ 052 public byte[] getData() { 053 return new byte[]{(byte) (shortValue >> 8 & 0xff), 054 (byte) (shortValue & 0xff)}; 055 } 056 057 public int getShortValue() { 058 return shortValue; 059 } 060 061 public void setShortValue(int shortValue) { 062 this.shortValue = shortValue; 063 } 064 }