DhcpClientRecord.java revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* ident "%Z%%M% %I% %E% SMI"
*
* Copyright 1998-2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/**
* This class represents a record in a DHCP network table. It can also be used
* to manage an associated hosts record by setting the client name; that effect
* is not part of this class, but rather is provided by the DhcpNetMgr.
*/
/**
* Default values for class attributes.
*/
/**
* Expiration special values.
*/
private byte flags;
private Date expiration;
// Serialization id of this class
static final long serialVersionUID = 5007310554198923085L;
/**
* Constructs a basic, empty client record.
*/
public DhcpClientRecord() {
flags = 0;
expiration = null;
}
/**
* Constructs a client record with a client IP.
* @param clientIP the client IP address for the record.
*/
setDefaults();
}
/**
* Constructs a fully specified client record
* @param clientId Client's unique identifier
* @param flags Status flags for the record
* @param clientIP Client's IP address
* @param serverIP IP address of owning server
* @param expiration Lease expiration time in seconds since Unix epoch
* @param macro Configuration macro associated with this record
* @param comment User notes on this record
*/
}
/**
* Constructs a fully specified client record
* @param clientId Client's unique identifier
* @param flags Status flags for the record
* @param clientIP Client's IP address
* @param serverIP IP address of owning server
* @param expiration Lease expiration time in seconds since Unix epoch
* @param macro Configuration macro associated with this record
* @param comment User notes on this record
* @param signature Opaque signature
*/
throws ValidationException {
}
/**
* Make a copy of this record
*/
}
}
if (expiration != null) {
}
return newrec;
}
/**
* Fully specifies the defaults for a client record
*/
public void setDefaults()
throws ValidationException {
}
/**
* Retrieve the client ID
* @return Client ID as a String
*/
public String getClientId() {
return clientId;
}
/**
* Set the client ID. See dhcp_network(4) for the rules about client
* ID syntax which are implemented here.
* @param clientId Client's unique identifier
*/
// Must be even number of characters, no more than 128 characters
throw new ValidationException(msg);
}
char [] c = clientId.toCharArray();
for (int i = 0; i < c.length; ++i) {
if ((c[i] < '0' || c[i] > '9') && (c[i] < 'A' || c[i] > 'F')) {
throw new ValidationException(msg);
}
}
this.clientId = DEFAULT_CLIENT_ID;
}
}
/**
* Get the flags byte
* @return A <code>byte</code> containing the record's status flags
*/
public byte getFlags() {
return flags;
}
/**
* Get the flags as a string
* @return The flag byte converted to a String
*/
public String getFlagString() {
return getFlagString(false);
}
StringBuffer b = new StringBuffer();
if (!verbose) {
// Make sure we always have a 2-character representation.
if (flags < 10) {
}
}
else {
if (flags == 0) {
} else {
if (isPermanent()) {
}
if (isManual()) {
}
if (isUnusable()) {
}
if (isBootp()) {
}
}
}
return b.toString();
}
/**
* Test for setting of unusable flag
* @return <code>true</code> if the unusable flag is set,
* <code>false</code> if not.
*/
public boolean isUnusable() {
}
/**
* @param state <code>true</code> if address is to be unusable
*/
public void setUnusable(boolean state) {
if (state) {
} else {
}
}
/**
* Test for setting of bootp flag
* @return <code>true</code> if the bootp flag is set,
* <code>false</code> if not.
*/
public boolean isBootp() {
}
/**
* @param state <code>true</code> if address is reserved for BOOTP clients
*/
if (state) {
} else {
}
}
/**
* Test for setting of manual assignment flag
* @return <code>true</code> if address is manually assigned,
* <code>false</code> if not.
*/
public boolean isManual() {
}
/**
* @param state <code>true</code> if the address is manually assigned
*/
if (state) {
} else {
}
}
/**
* Test for setting of permanent assignment flag
* @return <code>true</code> if lease is permanent,
* <code>false</code> if dynamic
*/
public boolean isPermanent() {
}
/**
* @param state <code>true</code> if the address is permanently leased
*/
public void setPermanent(boolean state) {
if (state) {
} else {
}
}
/**
* Set the flags as a unit
* @param flags a <code>byte</code> setting for the flags
*/
} else {
this.flags = 0;
while (flagTokenizer.hasMoreTokens()) {
if (keyword.equalsIgnoreCase(
// nothing to do, default is Dynamic.
} else if (keyword.equalsIgnoreCase(
} else if (keyword.equalsIgnoreCase(
} else if (keyword.equalsIgnoreCase(
} else if (keyword.equalsIgnoreCase(
} else {
throw new ValidationException(msg);
}
}
}
}
/**
* Set the flags as a unit
* @param flags a <code>byte</code> setting for the flags
*/
}
/**
* Retrieve the client's IP address
* @return the client's IP address
*/
public IPAddress getClientIP() {
return clientIP;
}
/**
* Retrieve a string version of the client's IP address
* @return A <code>String</code> containing the dotted decimal IP address.
*/
public String getClientIPAddress() {
return "";
} else {
return clientIP.getHostAddress();
}
}
/**
* Set the client's IP address
* @param clientIP A String representation of the <code>IPAddress</code>
* to assign from this record.
*/
throw new ValidationException(msg);
}
try {
} catch (Throwable e) {
throw new ValidationException(msg);
}
}
/**
* Set the client's IP address
* @param clientIP An <code>IPAddress</code> to assign from this record.
*/
throw new ValidationException(msg);
}
}
/**
* Retrieve the IP address of the owning server.
* @return An <code>IPAddress</code> for the server controlling this record.
*/
public IPAddress getServerIP() {
return serverIP;
}
/**
* Retrieve a string version of the owning server's IP address
* @return The server's dotted decimal IP address as a <code>String</code>
*/
public String getServerIPAddress() {
return "";
} else {
return serverIP.getHostAddress();
}
}
/**
* Set the server's IP address
* @param serverIP A String representation of the <code>IPAddress</code>
* to assign from this record.
*/
throw new ValidationException(msg);
}
try {
} catch (Throwable e) {
throw new ValidationException(msg);
}
}
/**
* Assign this address to a server denoted by its IP address
* @param serverIP The <code>IPAddress</code> of the owning server.
*/
throw new ValidationException(msg);
}
}
/**
* @return The expiration time of this record's lease as a <code>Date</code>
*/
public Date getExpiration() {
return expiration;
}
/**
* @return The expiration time of this record's lease in seconds
* since the epoch, as a <code>String</code>
*/
public String getExpirationTime() {
if (expiration == null) {
return null;
}
return EXPIRATION_FOREVER;
} else {
}
}
/**
* Set the lease expiration date.
* @param expiration Lease expiration time in seconds since Unix epoch
*/
}
/**
* Set the lease expiration date.
* @param expiration The <code>Date</code> when the lease expires.
*/
this.expiration = expiration;
}
/**
* Set the lease expiration date by parsing a formatted string. Also
* provides special handling of the "0" and "-1" values.
* @param dateFormat A DateFormat used to parse the expiration date
* @param date Lease expiration in desired format.
*/
throws ValidationException {
} else {
try {
throw new ValidationException(msg);
}
}
}
/**
* @return The name of the macro used to explicitly configure this address
*/
return macro;
}
/**
* Set the name of the macro used to explicitly configure this address
*/
}
/**
* @return The descriptive comment for this record
*/
public String getComment() {
return comment;
}
/**
* Set a descriptive comment for this record
* @param comment The comment
*/
}
/**
* @return The signature for this record
*/
public String getSignature() {
return signature;
}
/**
* Set the signature for this record
* @param signature The new signature value
*/
}
/**
* Perform comparisons to another DhcpClientRecord instance. This is used
* for sorting a network table by client address.
* @param o A <code>DhcpClientRecord</code> to compare against.
* @return 0 if the objects have the same address,
* a negative number if this record has a lower IP address than the
* supplied record, a positive number if this record has a higher IP
* address than the supplied record.
*/
DhcpClientRecord r = (DhcpClientRecord)o;
return (int)(getBinaryAddress() - r.getBinaryAddress());
}
/**
* Retrieve the IP address as a number suitable for arithmetic operations.
* We use a <code>long</code> rather than an <code>int</code> in order to
* be able to treat it as an unsigned value, since all Java types are
* signed.
* @return The IP address as a <code>long</code>.
*/
public long getBinaryAddress() {
return (clientIP.getBinaryAddress());
}
/**
* @return The client's hostname
*/
public String getClientName() {
}
return clientName;
}
/**
* @param name The hostname for the client.
*/
clientName = name;
}
/**
* @return The server's hostname
*/
public String getServerName() {
}
return serverName;
}
/**
* @param name The server's hostname
*/
serverName = name;
}
}
}
if (this.expiration != null) {
}
return s;
}
}