/*
* 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.
*/
/**
* MembershipKey implementation.
*/
class MembershipKeyImpl
extends MembershipKey
{
// true when key is valid
private volatile boolean valid = true;
// lock used when creating or accessing blockedSet
// set of source addresses that are blocked
{
}
/**
* MembershipKey will additional context for IPv4 membership
*/
private final int groupAddress;
private final int interfAddress;
private final int sourceAddress;
int groupAddress,
int interfAddress,
int sourceAddress)
{
this.groupAddress = groupAddress;
this.interfAddress = interfAddress;
this.sourceAddress = sourceAddress;
}
int groupAddress() {
return groupAddress;
}
int interfaceAddress() {
return interfAddress;
}
int source() {
return sourceAddress;
}
}
/**
* MembershipKey will additional context for IPv6 membership
*/
private final byte[] groupAddress;
private final int index;
private final byte[] sourceAddress;
byte[] groupAddress,
int index,
byte[] sourceAddress)
{
this.groupAddress = groupAddress;
this.sourceAddress = sourceAddress;
}
byte[] groupAddress() {
return groupAddress;
}
int index() {
return index;
}
byte[] source() {
return sourceAddress;
}
}
public boolean isValid() {
return valid;
}
// package-private
void invalidate() {
valid = false;
}
public void drop() {
// delegate to channel
}
return ch;
}
return group;
}
return interf;
}
return source;
}
throws IOException
{
throw new IllegalStateException("key is source-specific");
synchronized (stateLock) {
// already blocked, nothing to do
return this;
}
// created blocked set if required and add source address
if (blockedSet == null)
}
return this;
}
synchronized (stateLock) {
throw new IllegalStateException("not blocked");
}
return this;
}
}
}
}