/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* A NetHooks provider that converts sockets from the TCP to SDP protocol prior
* to binding or connecting.
*/
// maximum port
// indicates if SDP is enabled and the rules for when the protocol is used
private final boolean enabled;
// logging for debug purposes
public SdpProvider() {
// if this property is not defined then there is nothing to do.
new GetPropertyAction("com.sun.sdp.conf"));
this.enabled = false;
return;
}
// load configuration file
try {
} catch (IOException e) {
}
}
// check if debugging is enabled
new GetPropertyAction("com.sun.sdp.debug"));
try {
} catch (IOException ignore) { }
}
}
}
// supported actions
private static enum Action {
BIND,
}
// a rule for matching a bind or connect request
private static interface Rule {
}
// rule to match port[-end]
private final int portStart;
private final int portEnd;
}
return action;
}
}
}
// rule to match address[/prefix] port[-end]
private final byte[] addressAsBytes;
private final int prefixByteCount;
private final byte mask;
{
}
return false;
// same address type?
return false;
// check bytes
for (int i=0; i<prefixByteCount; i++) {
if (candidate[i] != addressAsBytes[i])
return false;
}
// check remaining bits
return false;
}
}
// parses port:[-end]
try {
int[] result = new int[2];
if (pos < 0) {
} else {
}
return result;
} catch (NumberFormatException e) {
return new int[0];
}
}
}
// loads rules from the given file
// Each non-blank/non-comment line must have the format:
// ("bind" | "connect") 1*LWSP-char (hostname | ipaddress["/" prefix])
// 1*LWSP-char ("*" | port) [ "-" ("*" | port) ]
throws IOException
{
try {
while (scanner.hasNextLine()) {
// skip blank lines and comments
continue;
// must have 3 fields
if (s.length != 3) {
continue;
}
// first field is the action ("bind" or "connect")
action = a;
break;
}
}
continue;
}
// * port[-end]
continue;
}
// match all addresses
continue;
}
// hostname | ipaddress[/prefix]
try {
if (pos < 0) {
// hostname or ipaddress (no prefix)
int prefix =
}
} else {
int prefix = -1;
try {
if (address instanceof Inet4Address) {
// must be 1-31
} else {
// must be 1-128
}
} catch (NumberFormatException e) {
}
if (prefix > 0) {
} else {
continue;
}
}
} catch (UnknownHostException uhe) {
continue;
}
}
return result;
} finally {
}
}
// converts unbound TCP socket to a SDP socket if it matches the rules
int port)
throws IOException
{
boolean matched = false;
matched = true;
break;
}
}
if (matched) {
} else {
}
}
}
int port)
throws IOException
{
if (enabled)
}
int port)
throws IOException
{
if (enabled)
}
}