DhcpHostsTable.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 (c) 2001 by Sun Microsystems, Inc.
* All rights reserved.
*/
/**
* This class provides the capabilities for managing the hosts table.
*/
public class DhcpHostsTable {
/**
* This is the handle to the host table as defined by the config file
* Access to this handle is synchronized.
*/
private DirectoryTable hostsTable;
private int addrColumn = 0;
private int cnameColumn = 0;
private int aliasesColumn = 0;
private int commentColumn = 0;
/**
* Create a new DhcpHostsTable of type resource in the specified domain
* @param resource the host resource(eg., files, dns, nisplus)
* @param domain the domain (if any) for the host resource
*/
throws BridgeException {
// Determine the local host name. Directory table url requires it.
//
try {
} catch (Throwable e) {
throw new BridgeException(
}
// Build the url.
//
} else {
}
} else {
}
try {
} catch (Throwable e) {
throw new BridgeException(
}
} // end constructor
/**
* Checks access on the host table.
* @param requestedAccess the desired access
* @return true if the desired access can be granted
*/
public synchronized boolean canAccessTable(int requestedAccess)
throws BridgeException {
try {
} catch (Throwable e) {
// No access apparently
}
} // openTable
/**
* Opens the host table.
*/
public synchronized void openTable()
throws BridgeException {
try {
} catch (Throwable e) {
throw new BridgeException(
}
} // openTable
/**
* Closes the host table.
*/
public synchronized void closeTable()
throws BridgeException {
try {
hostsTable.close();
} catch (Throwable e) {
throw new BridgeException(
}
} // closeTable
/**
* Finds a host entry by name and returns its address.
* @param name host name
* @return address of entry or null if entry does not exist.
*/
try {
} catch (Throwable e) {
// Nothing to do
}
return address;
}
/**
* Finds a host entry by address and returns its name.
* @param address host address
* @return name of entry or null if entry does not exist.
*/
try {
} catch (Throwable e) {
// Nothing to do
}
return name;
}
/**
* Add an entry to the hosts table.
* @param addr host address
* @param name host name
* @param comment comment for host entry
*/
throw new HostExistsException(addr);
}
throw new HostExistsException(name);
}
try {
} catch (Throwable e) {
throw new BridgeException(
}
} // createHostsRecord
/**
* Remove an entry from the hosts table
* @param addr host address of entry to remove
*/
throws BridgeException {
try {
} catch (DirectoryTableRowNotFoundException e) {
throw new NoHostsEntryException(addr);
} catch (Throwable e) {
throw new BridgeException(
}
} // deleteHostsRecord
/**
* Modify an entry on the hosts table.
* @param oldAddr host address of entry to modify
* @param newAddr new host address for entry
* @param name new host name
* @param comment new comment for host entry
*/
throw new HostExistsException(name);
}
try {
} catch (DirectoryTableRowNotFoundException e) {
throw new NoHostsEntryException(oldAddr);
} catch (Throwable e) {
throw new BridgeException(
}
} // modifyHostsRecord
/**
* Determines the whether or not the hosts table under a given
* name service can be managed.
* @param resource name service resource (files, dns, nisplus)
* @param domain the name service domain (ignored for files)
* @return true if the user can manage the table
*/
boolean result = false;
try {
} catch (Throwable e) {
// No access apparently
}
return (result);
} // isHostsManageable
/**
* Constructs a DhcpHostsTable as defined by the DHCP config file.
* This object is a singleton (only one will ever be created and will
* be cached).
* @param bridge the bridge object to the native library
* @return the DhcpHostsTable
*/
throws BridgeException {
if (cfgHostsTable == null) {
try {
}
} catch (Throwable e) {
throw new BridgeException(e.getMessage());
}
}
return cfgHostsTable;
} // getCfgHostsTable
} // DhcpHostsTable