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);
}
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);
}
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);
}
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);
}
});
});
}
}
}
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;
}
Aggregations