Search in sources :

Example 51 with IPv4

use of org.onlab.packet.IPv4 in project dhcpl2relay by opencord.

the class DhcpL2RelayTestBase method constructDhcpNakPacket.

/**
 * Constructs DHCP Nak Packet.
 *
 * @return Ethernet packet
 */
Ethernet constructDhcpNakPacket(MacAddress servMac, MacAddress clientMac, String ipAddress, String dhcpClientIpAddress, VlanId clientVlan, short clientPcp) {
    Ethernet pkt = constructEthernetPacket(servMac, clientMac, ipAddress, DHCP.OPCODE_REPLY, clientMac, Ip4Address.valueOf(dhcpClientIpAddress), clientVlan, clientPcp);
    IPv4 ipv4Packet = (IPv4) pkt.getPayload();
    UDP udpPacket = (UDP) ipv4Packet.getPayload();
    DHCP dhcpPacket = (DHCP) udpPacket.getPayload();
    dhcpPacket.setOptions(constructDhcpOptions(DHCP.MsgType.DHCPNAK));
    return pkt;
}
Also used : UDP(org.onlab.packet.UDP) Ethernet(org.onlab.packet.Ethernet) IPv4(org.onlab.packet.IPv4) DHCP(org.onlab.packet.DHCP)

Example 52 with IPv4

use of org.onlab.packet.IPv4 in project dhcpl2relay by opencord.

the class DhcpL2RelayTestBase method constructDhcpAckPacket.

/**
 * Constructs DHCP Ack Packet.
 *
 * @return Ethernet packet
 */
Ethernet constructDhcpAckPacket(MacAddress servMac, MacAddress clientMac, String ipAddress, String dhcpClientIpAddress) {
    Ethernet pkt = construcEthernetPacket(servMac, clientMac, ipAddress, DHCP.OPCODE_REPLY, clientMac, Ip4Address.valueOf(dhcpClientIpAddress));
    IPv4 ipv4Packet = (IPv4) pkt.getPayload();
    UDP udpPacket = (UDP) ipv4Packet.getPayload();
    DHCP dhcpPacket = (DHCP) udpPacket.getPayload();
    dhcpPacket.setOptions(constructDhcpOptions(DHCP.MsgType.DHCPACK));
    return pkt;
}
Also used : UDP(org.onlab.packet.UDP) Ethernet(org.onlab.packet.Ethernet) IPv4(org.onlab.packet.IPv4) DHCP(org.onlab.packet.DHCP)

Example 53 with IPv4

use of org.onlab.packet.IPv4 in project dhcpl2relay by opencord.

the class DhcpL2RelayTestBase method constructDhcpDeclinePacket.

/**
 * Constructs DHCP Decline Packet.
 *
 * @return Ethernet packet
 */
Ethernet constructDhcpDeclinePacket(MacAddress clientMac) {
    Ethernet pkt = construcEthernetPacket(clientMac, MacAddress.BROADCAST, "255.255.255.255", DHCP.OPCODE_REQUEST, clientMac, Ip4Address.valueOf("0.0.0.0"));
    IPv4 ipv4Packet = (IPv4) pkt.getPayload();
    UDP udpPacket = (UDP) ipv4Packet.getPayload();
    DHCP dhcpPacket = (DHCP) udpPacket.getPayload();
    dhcpPacket.setOptions(constructDhcpOptions(DHCP.MsgType.DHCPDECLINE));
    return pkt;
}
Also used : UDP(org.onlab.packet.UDP) Ethernet(org.onlab.packet.Ethernet) IPv4(org.onlab.packet.IPv4) DHCP(org.onlab.packet.DHCP)

Example 54 with IPv4

use of org.onlab.packet.IPv4 in project aaa by opencord.

the class SamplePacketCustomizer method customizeEthernetIPHeaders.

/**
 * Customize the Ethernet header as per specific Setup or RADIUS
 * server requirements.
 *
 * @param inPkt Ethernet packet to be changed
 * @param eapPacket Incoming packet containing EAP for which this the
 *                  RADIUS message is being created
 * @return Changed Ethernet packet
 */
@Override
public Ethernet customizeEthernetIPHeaders(Ethernet inPkt, InboundPacket eapPacket) {
    String serialNo = customInfo.deviceService().getDevice(eapPacket.receivedFrom().deviceId()).serialNumber();
    log.info("SampleRadiusCustomzer customizer serial = {}", serialNo);
    if (customInfo.subscriberService() == null) {
        log.warn(SADIS_NOT_RUNNING);
        return inPkt;
    }
    SubscriberAndDeviceInformation deviceInfo = customInfo.subscriberService().get(serialNo);
    if (deviceInfo == null) {
        log.warn("No Device found with SN {}", serialNo);
        return inPkt;
    }
    MacAddress macAddress = deviceInfo.hardwareIdentifier();
    Ip4Address ipAddress = deviceInfo.ipAddress();
    if (macAddress == null || ipAddress == null) {
        log.warn("Insufficient data to Customize Ethernet IP Headers" + " : hardwareIdentifier = {}, ipAddress = {}", macAddress, ipAddress);
        return inPkt;
    }
    inPkt.setSourceMACAddress(macAddress);
    IPv4 ipv4Packet = (IPv4) inPkt.getPayload();
    ipv4Packet.setSourceAddress(ipAddress.toString());
    inPkt.setPayload(ipv4Packet);
    return inPkt;
}
Also used : IPv4(org.onlab.packet.IPv4) Ip4Address(org.onlab.packet.Ip4Address) SubscriberAndDeviceInformation(org.opencord.sadis.SubscriberAndDeviceInformation) MacAddress(org.onlab.packet.MacAddress)

Example 55 with IPv4

use of org.onlab.packet.IPv4 in project fabric-tna by stratum.

the class FabricIntProgrammable method setUpCollectorFlows.

private void setUpCollectorFlows(IntReportConfig config) {
    FlowRuleOperations.Builder ops = FlowRuleOperations.builder();
    final PiAction watchlistAction = PiAction.builder().withId(P4InfoConstants.FABRIC_INGRESS_INT_WATCHLIST_NO_REPORT_COLLECTOR).build();
    Streams.stream(flowRuleService.getFlowEntriesById(appId)).filter(entry -> entry.deviceId().equals(deviceId)).filter(entry -> entryWithActionId(entry, watchlistAction.id())).forEach(ops::remove);
    ops.newStage();
    final TrafficTreatment watchlistTreatment = DefaultTrafficTreatment.builder().piTableAction(watchlistAction).build();
    final TrafficSelector watchlistSelector = DefaultTrafficSelector.builder().matchIPDst(config.collectorIp().toIpPrefix()).matchIPProtocol(IPv4.PROTOCOL_UDP).matchUdpDst(config.collectorPort()).build();
    final FlowRule watchlistRule = DefaultFlowRule.builder().forDevice(deviceId).withSelector(buildCollectorSelector(watchlistSelector.criteria())).withTreatment(watchlistTreatment).withPriority(DEFAULT_PRIORITY + 10).forTable(P4InfoConstants.FABRIC_INGRESS_INT_WATCHLIST_WATCHLIST).fromApp(appId).makePermanent().build();
    ops.add(watchlistRule);
    flowRuleService.apply(ops.build());
}
Also used : PiTableId(org.onosproject.net.pi.model.PiTableId) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) HostLocation(org.onosproject.net.HostLocation) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) CoreService(org.onosproject.core.CoreService) PortNumber(org.onosproject.net.PortNumber) FlowEntry(org.onosproject.net.flow.FlowEntry) PiActionParam(org.onosproject.net.pi.runtime.PiActionParam) IPProtocolCriterion(org.onosproject.net.flow.criteria.IPProtocolCriterion) IntReportConfig(org.stratumproject.fabric.tna.inbandtelemetry.IntReportConfig) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) FlowRuleService(org.onosproject.net.flow.FlowRuleService) PiInstruction(org.onosproject.net.flow.instructions.PiInstruction) PiTableModel(org.onosproject.net.pi.model.PiTableModel) PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) Map(java.util.Map) ApplicationId(org.onosproject.core.ApplicationId) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) V1MODEL_RECIRC_PORT(org.stratumproject.fabric.tna.Constants.V1MODEL_RECIRC_PORT) ImmutableSet(com.google.common.collect.ImmutableSet) Ip4Address(org.onlab.packet.Ip4Address) ImmutableMap(com.google.common.collect.ImmutableMap) FabricUtils.doCareRangeMatch(org.stratumproject.fabric.tna.behaviour.FabricUtils.doCareRangeMatch) PiMatchFieldModel(org.onosproject.net.pi.model.PiMatchFieldModel) Range(com.google.common.collect.Range) Set(java.util.Set) Streams(com.google.common.collect.Streams) Constants(org.stratumproject.fabric.tna.Constants) Sets(com.google.common.collect.Sets) String.format(java.lang.String.format) Objects(java.util.Objects) List(java.util.List) BoundType(com.google.common.collect.BoundType) FlowRule(org.onosproject.net.flow.FlowRule) GroupBuckets(org.onosproject.net.group.GroupBuckets) Optional(java.util.Optional) DeviceId(org.onosproject.net.DeviceId) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) IpPrefix(org.onlab.packet.IpPrefix) Host(org.onosproject.net.Host) ImmutableByteSequence(org.onlab.util.ImmutableByteSequence) TableId(org.onosproject.net.flow.TableId) SegmentRoutingDeviceConfig(org.onosproject.segmentrouting.config.SegmentRoutingDeviceConfig) GroupBucket(org.onosproject.net.group.GroupBucket) HostService(org.onosproject.net.host.HostService) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultGroupBucket.createCloneGroupBucket(org.onosproject.net.group.DefaultGroupBucket.createCloneGroupBucket) ImmutableList(com.google.common.collect.ImmutableList) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) TcpPortCriterion(org.onosproject.net.flow.criteria.TcpPortCriterion) StreamSupport(java.util.stream.StreamSupport) Criteria(org.onosproject.net.flow.criteria.Criteria) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Criterion(org.onosproject.net.flow.criteria.Criterion) IpAddress(org.onlab.packet.IpAddress) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) FlowRuleOperations(org.onosproject.net.flow.FlowRuleOperations) UdpPortCriterion(org.onosproject.net.flow.criteria.UdpPortCriterion) GroupService(org.onosproject.net.group.GroupService) V1MODEL_INT_REPORT_MIRROR_ID(org.stratumproject.fabric.tna.Constants.V1MODEL_INT_REPORT_MIRROR_ID) PiMatchFieldId(org.onosproject.net.pi.model.PiMatchFieldId) PiAction(org.onosproject.net.pi.runtime.PiAction) IPv4(org.onlab.packet.IPv4) HexString(org.onlab.util.HexString) KRYO(org.stratumproject.fabric.tna.behaviour.FabricUtils.KRYO) IntProgrammable(org.stratumproject.fabric.tna.inbandtelemetry.IntProgrammable) Collections(java.util.Collections) PiActionId(org.onosproject.net.pi.model.PiActionId) FlowRuleOperations(org.onosproject.net.flow.FlowRuleOperations) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PiAction(org.onosproject.net.pi.runtime.PiAction)

Aggregations

IPv4 (org.onlab.packet.IPv4)54 Ethernet (org.onlab.packet.Ethernet)43 UDP (org.onlab.packet.UDP)24 DHCP (org.onlab.packet.DHCP)18 ICMP (org.onlab.packet.ICMP)17 IpAddress (org.onlab.packet.IpAddress)15 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)14 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)13 Test (org.junit.Test)12 Ip4Address (org.onlab.packet.Ip4Address)10 MacAddress (org.onlab.packet.MacAddress)10 ConnectPoint (org.onosproject.net.ConnectPoint)10 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)10 TrafficSelector (org.onosproject.net.flow.TrafficSelector)10 ByteBuffer (java.nio.ByteBuffer)8 Optional (java.util.Optional)8 Interface (org.onosproject.net.intf.Interface)8 DefaultOutboundPacket (org.onosproject.net.packet.DefaultOutboundPacket)8 DhcpOption (org.onlab.packet.dhcp.DhcpOption)7 ApplicationId (org.onosproject.core.ApplicationId)7