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