org.onosproject.net.PortNumber Maven / Gradle / Ivy
/*
* Copyright 2014-present Open Networking 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.onosproject.net;
import com.google.common.base.Objects;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.primitives.UnsignedLongs;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Representation of a port number.
*/
public final class PortNumber {
public static final PortNumber P0 = portNumber(0);
// TODO: revisit the max and the logical port value assignments
static final long MAX_NUMBER = (2L * Integer.MAX_VALUE) + 1;
static final long IN_PORT_NUMBER = -8L;
static final long TABLE_NUMBER = -7L;
static final long NORMAL_NUMBER = -6L;
static final long FLOOD_NUMBER = -5L;
static final long ALL_NUMBER = -4L;
static final long CONTROLLER_NUMBER = -3L;
static final long LOCAL_NUMBER = -2L;
static final long ANY_NUMBER = -1L;
public static final long NO_DISPLAY_NUMBER = -1L;
/**
* Logical PortNumbers.
*/
public enum Logical {
IN_PORT(IN_PORT_NUMBER),
TABLE(TABLE_NUMBER),
NORMAL(NORMAL_NUMBER),
FLOOD(FLOOD_NUMBER),
ALL(ALL_NUMBER),
LOCAL(LOCAL_NUMBER),
CONTROLLER(CONTROLLER_NUMBER),
ANY(ANY_NUMBER);
private final long number;
private final PortNumber instance;
public long number() {
return number;
}
/**
* PortNumber instance for the logical port.
*
* @return {@link PortNumber}
*/
public PortNumber instance() {
return instance;
}
Logical(long number) {
this.number = number;
this.instance = new PortNumber(number);
}
}
public static final PortNumber IN_PORT = new PortNumber(IN_PORT_NUMBER);
public static final PortNumber TABLE = new PortNumber(TABLE_NUMBER);
public static final PortNumber NORMAL = new PortNumber(NORMAL_NUMBER);
public static final PortNumber FLOOD = new PortNumber(FLOOD_NUMBER);
public static final PortNumber ALL = new PortNumber(ALL_NUMBER);
public static final PortNumber LOCAL = new PortNumber(LOCAL_NUMBER);
public static final PortNumber CONTROLLER = new PortNumber(CONTROLLER_NUMBER);
public static final PortNumber ANY = new PortNumber(ANY_NUMBER);
// lazily populated Logical port number to PortNumber
static final Supplier
© 2015 - 2025 Weber Informatics LLC | Privacy Policy