Author: erodriguez Date: Fri Jan 7 22:14:40 2005 New Revision: 124634 URL: http://svn.apache.org/viewcvs?view=rev&rev=124634 Log: DHCP options base class and collection (field) class. Added: incubator/directory/dhcp/trunk/core/src/java/org/apache/dhcp/options/ incubator/directory/dhcp/trunk/core/src/java/org/apache/dhcp/options/DhcpOption.java (contents, props changed) incubator/directory/dhcp/trunk/core/src/java/org/apache/dhcp/options/OptionsField.java
Added: incubator/directory/dhcp/trunk/core/src/java/org/apache/dhcp/options/DhcpOption.java Url: http://svn.apache.org/viewcvs/incubator/directory/dhcp/trunk/core/src/java/org/apache/dhcp/options/DhcpOption.java?view=auto&rev=124634 ============================================================================== --- (empty file) +++ incubator/directory/dhcp/trunk/core/src/java/org/apache/dhcp/options/DhcpOption.java Fri Jan 7 22:14:40 2005 @@ -0,0 +1,51 @@ +/* + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.dhcp.options; + +import java.nio.ByteBuffer; + + +/** + * The Dynamic Host Configuration Protocol (DHCP) provides a framework + * for passing configuration information to hosts on a TCP/IP network. + * Configuration parameters and other control information are carried in + * tagged data items that are stored in the 'options' field of the DHCP + * message. The data items themselves are also called "options." + */ +public abstract class DhcpOption +{ + private int tag; + private int length; + + public DhcpOption( int tag, int length ) + { + this.tag = tag; + this.length = length; + } + + abstract protected void valueToByteBuffer( ByteBuffer out ); + + public void writeTo( ByteBuffer out ) + { + out.put( (byte)tag ); + out.put( (byte)length ); + + valueToByteBuffer( out ); + } +} + Added: incubator/directory/dhcp/trunk/core/src/java/org/apache/dhcp/options/OptionsField.java Url: http://svn.apache.org/viewcvs/incubator/directory/dhcp/trunk/core/src/java/org/apache/dhcp/options/OptionsField.java?view=auto&rev=124634 ============================================================================== --- (empty file) +++ incubator/directory/dhcp/trunk/core/src/java/org/apache/dhcp/options/OptionsField.java Fri Jan 7 22:14:40 2005 @@ -0,0 +1,49 @@ +/* + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.dhcp.options; + +import java.util.HashSet; +import java.util.Set; + +/** + * The Dynamic Host Configuration Protocol (DHCP) provides a framework + * for passing configuration information to hosts on a TCP/IP network. + * Configuration parameters and other control information are carried in + * tagged data items that are stored in the 'options' field of the DHCP + * message. The data items themselves are also called "options." + */ +public class OptionsField +{ + private Set options = new HashSet(); + + public void add( DhcpOption option ) + { + options.add( option ); + } + + public boolean isEmpty() + { + return options.isEmpty(); + } + + public DhcpOption[] toArray() + { + return (DhcpOption[])options.toArray(); + } +} +
