Search in sources :

Example 41 with Ip4Address

use of org.onlab.packet.Ip4Address in project onos by opennetworkinglab.

the class IPv4AddressTlv method read.

/**
 * Reads the channel buffer and returns object of IPv4AddressTlv.
 *
 * @param cb channelBuffer
 * @param type address type
 * @return object of IPv4AddressTlv
 * @throws BgpParseException while parsing IPv4AddressTlv
 */
public static IPv4AddressTlv read(ChannelBuffer cb, short type) throws BgpParseException {
    InetAddress ipAddress = Validation.toInetAddress(LENGTH, cb);
    if (ipAddress.isMulticastAddress()) {
        throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null);
    }
    Ip4Address address = Ip4Address.valueOf(ipAddress);
    return IPv4AddressTlv.of(address, type);
}
Also used : BgpParseException(org.onosproject.bgpio.exceptions.BgpParseException) Ip4Address(org.onlab.packet.Ip4Address) InetAddress(java.net.InetAddress)

Example 42 with Ip4Address

use of org.onlab.packet.Ip4Address in project onos by opennetworkinglab.

the class OspfPseudonode method read.

/**
 * Reads the channel buffer and returns object of OSPFPseudonode.
 *
 * @param cb ChannelBuffer
 * @return object of OSPFPseudonode
 */
public static OspfPseudonode read(ChannelBuffer cb) {
    int routerID = cb.readInt();
    Ip4Address drInterface = Ip4Address.valueOf(cb.readInt());
    return OspfPseudonode.of(routerID, drInterface);
}
Also used : Ip4Address(org.onlab.packet.Ip4Address)

Example 43 with Ip4Address

use of org.onlab.packet.Ip4Address in project onos by opennetworkinglab.

the class BgpAttrRouterIdV4 method read.

/**
 * Reads the IPv4 Router-ID.
 *
 * @param cb ChannelBuffer
 * @param sType tag type
 * @return object of BgpAttrRouterIdV4
 * @throws BgpParseException while parsing BgpAttrRouterIdV4
 */
public static BgpAttrRouterIdV4 read(ChannelBuffer cb, short sType) throws BgpParseException {
    short lsAttrLength = cb.readShort();
    if ((lsAttrLength != 4) || (cb.readableBytes() < lsAttrLength)) {
        Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR, lsAttrLength);
    }
    byte[] ipBytes = new byte[lsAttrLength];
    cb.readBytes(ipBytes, 0, lsAttrLength);
    Ip4Address ip4RouterId = Ip4Address.valueOf(ipBytes);
    return BgpAttrRouterIdV4.of(ip4RouterId, sType);
}
Also used : Ip4Address(org.onlab.packet.Ip4Address)

Example 44 with Ip4Address

use of org.onlab.packet.Ip4Address in project up4 by omec-project.

the class Up4DeviceManager method apply.

@Override
public void apply(UpfEntity entity) throws UpfProgrammableException {
    switch(entity.type()) {
        case SESSION_DOWNLINK:
            UpfSessionDownlink sessDl = (UpfSessionDownlink) entity;
            if (sessDl.needsBuffering()) {
                // Override tunnel peer id with the DBUF
                entity = convertToBuffering(sessDl);
                up4Store.learnBufferingUe(sessDl.ueAddress());
            }
            break;
        case TERMINATION_UPLINK:
            UpfTerminationUplink termUl = (UpfTerminationUplink) entity;
            if (isMaxUeSet() && termUl.counterId() >= getMaxUe() * 2) {
                throw new UpfProgrammableException("Counter cell index referenced by uplink UPF termination " + "rule above max supported UE value.", UpfProgrammableException.Type.ENTITY_OUT_OF_RANGE, UpfEntityType.TERMINATION_UPLINK);
            }
            break;
        case TERMINATION_DOWNLINK:
            UpfTerminationDownlink termDl = (UpfTerminationDownlink) entity;
            if (isMaxUeSet() && termDl.counterId() >= getMaxUe() * 2) {
                throw new UpfProgrammableException("Counter cell index referenced by downlink UPF termination " + "rule above max supported UE value.", UpfProgrammableException.Type.ENTITY_OUT_OF_RANGE, UpfEntityType.TERMINATION_DOWNLINK);
            }
            break;
        case INTERFACE:
            UpfInterface intf = (UpfInterface) entity;
            if (intf.isDbufReceiver()) {
                throw new UpfProgrammableException("Cannot apply the DBUF interface entry!");
            }
            break;
        case TUNNEL_PEER:
            UpfGtpTunnelPeer tunnelPeer = (UpfGtpTunnelPeer) entity;
            if (tunnelPeer.tunPeerId() == DBUF_TUNNEL_ID) {
                throw new UpfProgrammableException("Cannot apply the DBUF GTP Tunnel Peer");
            }
            break;
        case COUNTER:
            applyUpfCounter((UpfCounter) entity);
        default:
            break;
    }
    getLeaderUpfProgrammable().apply(entity);
    // Drain from DBUF if necessary
    if (entity.type().equals(SESSION_DOWNLINK)) {
        UpfSessionDownlink sess = (UpfSessionDownlink) entity;
        if (!sess.needsBuffering() && up4Store.forgetBufferingUe(sess.ueAddress())) {
            // TODO: Should we wait for rules to be installed on all devices before
            // triggering drain?
            // When a fwd FAR is changed to buff FAR,
            // both session_downlink & downlink_termination rules are updated.
            // If the drain action starts immediately right after applying session_downlink,
            // the downlink_termination rule may not be updated,
            // thus, the TEID may wrong in such case.
            // Run the outbound rpc in a forked context so it doesn't cancel if it was called
            // by an inbound rpc that completes faster than the drain call
            Ip4Address ueAddr = sess.ueAddress();
            Context ctx = Context.current().fork();
            ctx.run(() -> {
                if (dbufClient == null) {
                    log.error("Cannot start dbuf drain for {}, dbufClient is null", ueAddr);
                    return;
                }
                if (config == null || config.dbufDrainAddr() == null) {
                    log.error("Cannot start dbuf drain for {}, dbufDrainAddr is null", ueAddr);
                    return;
                }
                log.info("Started dbuf drain for {}", ueAddr);
                dbufClient.drain(ueAddr, config.dbufDrainAddr(), GTP_PORT).whenComplete((result, ex) -> {
                    if (ex != null) {
                        log.error("Exception while draining dbuf for {}: {}", ueAddr, ex);
                    } else if (result) {
                        log.info("Dbuf drain completed for {}", ueAddr);
                    } else {
                        log.warn("Unknown error while draining dbuf for {}", ueAddr);
                    }
                });
            });
        }
    }
}
Also used : ComponentContext(org.osgi.service.component.ComponentContext) Context(io.grpc.Context) UpfProgrammableException(org.onosproject.net.behaviour.upf.UpfProgrammableException) UpfTerminationDownlink(org.onosproject.net.behaviour.upf.UpfTerminationDownlink) Ip4Address(org.onlab.packet.Ip4Address) UpfSessionDownlink(org.onosproject.net.behaviour.upf.UpfSessionDownlink) UpfInterface(org.onosproject.net.behaviour.upf.UpfInterface) UpfGtpTunnelPeer(org.onosproject.net.behaviour.upf.UpfGtpTunnelPeer) UpfTerminationUplink(org.onosproject.net.behaviour.upf.UpfTerminationUplink)

Example 45 with Ip4Address

use of org.onlab.packet.Ip4Address in project up4 by omec-project.

the class FlowsStatsCommand method sumCountersPerSession.

private Map<Ip4Address, UpfCounter> sumCountersPerSession(Map<Ip4Address, Set<UpfCounter>> countersPerSession) {
    Map<Ip4Address, UpfCounter> sumCountersSession = Maps.newHashMap();
    countersPerSession.forEach((ueSession, upfCounters) -> {
        UpfCounter result = null;
        for (UpfCounter upfCounter : upfCounters) {
            if (result == null) {
                result = upfCounter;
            } else {
                result = sumUpfCounters(result, upfCounter);
            }
        }
        sumCountersSession.put(ueSession, result);
    });
    return sumCountersSession;
}
Also used : Ip4Address(org.onlab.packet.Ip4Address) UpfCounter(org.onosproject.net.behaviour.upf.UpfCounter)

Aggregations

Ip4Address (org.onlab.packet.Ip4Address)98 Test (org.junit.Test)29 Ip4Prefix (org.onlab.packet.Ip4Prefix)20 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)15 MacAddress (org.onlab.packet.MacAddress)15 ArrayList (java.util.ArrayList)14 Ip6Address (org.onlab.packet.Ip6Address)14 IpAddress (org.onlab.packet.IpAddress)13 LinkedList (java.util.LinkedList)12 Ethernet (org.onlab.packet.Ethernet)12 ProtocolType (org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4.ProtocolType)12 BgpPathAttributes (org.onosproject.bgpio.protocol.ver4.BgpPathAttributes)12 AsPath (org.onosproject.bgpio.types.AsPath)12 BgpHeader (org.onosproject.bgpio.types.BgpHeader)12 BgpValueType (org.onosproject.bgpio.types.BgpValueType)12 LinkStateAttributes (org.onosproject.bgpio.types.LinkStateAttributes)12 Med (org.onosproject.bgpio.types.Med)12 MpReachNlri (org.onosproject.bgpio.types.MpReachNlri)12 Origin (org.onosproject.bgpio.types.Origin)12 OriginType (org.onosproject.bgpio.types.Origin.OriginType)12