@Override public void populateMatch(Match match) { match.setField(MatchType.NW_SRC, NetUtils.getInetAddress(this.getSourceAddress())); match.setField(MatchType.NW_DST, NetUtils.getInetAddress(this.getDestinationAddress())); match.setField(MatchType.NW_PROTO, this.getProtocol()); match.setField(MatchType.NW_TOS, this.getDiffServ()); } }
private static void fillTransportLayer(Match target, TcpMatch source) { PortNumber tcpSourcePort = source.getTcpSourcePort(); if (tcpSourcePort != null) { Integer tcpSourcePortValue = tcpSourcePort.getValue(); if (tcpSourcePortValue != null) { target.setField(TP_SRC, tcpSourcePortValue.shortValue()); } } PortNumber tcpDestPort = source.getTcpDestinationPort(); if (tcpDestPort != null) { Integer tcpDestPortValue = tcpDestPort.getValue(); if (tcpDestPortValue != null) { target.setField(TP_DST, tcpDestPortValue.shortValue()); } } target.setField(NW_PROTO, TCP); }
private static void fillTransportLayer(Match target, SctpMatch source) { PortNumber sctpSourcePort = source.getSctpSourcePort(); if (sctpSourcePort != null) { Integer sctpSourcePortValue = sctpSourcePort.getValue(); if (sctpSourcePortValue != null) { target.setField(TP_SRC, sctpSourcePortValue.shortValue()); } } PortNumber sctpDestPort = source.getSctpDestinationPort(); if (sctpDestPort != null) { Integer sctpDestPortValue = sctpDestPort.getValue(); if (sctpDestPortValue != null) { target.setField(TP_DST, sctpDestPortValue.shortValue()); } } target.setField(NW_PROTO, CRUDP); }
private static void fillTransportLayer(Match target, UdpMatch source) { PortNumber udpSourcePort = source.getUdpSourcePort(); if (udpSourcePort != null) { Integer udpSourcePortValue = udpSourcePort.getValue(); if (udpSourcePortValue != null) { target.setField(TP_SRC, udpSourcePortValue.shortValue()); } } PortNumber udpDestPort = source.getUdpDestinationPort(); if (udpDestPort != null) { Integer udpDestPortValue = udpDestPort.getValue(); if (udpDestPortValue != null) { target.setField(TP_DST, udpDestPortValue.shortValue()); } } target.setField(NW_PROTO, UDP); }
private static void fillFromIpv6(Match target, Ipv6Match source) { Ipv6Prefix sourceAddress = source.getIpv6Source(); if (sourceAddress != null) { target.setField(NW_SRC, inetAddressFrom(sourceAddress), null); } Ipv6Prefix destAddress = source.getIpv6Destination(); if (destAddress != null) { target.setField(NW_DST, inetAddressFrom(destAddress), null); } }
private static void fillFromIpv4(Match target, Ipv4Match source) { Ipv4Prefix sourceAddress = source.getIpv4Source(); if (sourceAddress != null) { target.setField(NW_SRC, inetAddressFrom(sourceAddress), null); } Ipv4Prefix destAddress = source.getIpv4Destination(); if (destAddress != null) { target.setField(NW_DST, inetAddressFrom(destAddress), null); } }
match.setField(MatchType.IN_PORT, port); match.setField(MatchType.DL_SRC, srcMac); match.setField(MatchType.DL_DST, dstMac); match.setField(MatchType.DL_TYPE, ethertype); match.setField(MatchType.DL_VLAN, vlan); match.setField(MatchType.DL_VLAN_PR, vlanPr); match.setField(MatchType.NW_SRC, srcIP, ipMask); match.setField(MatchType.NW_DST, dstIP, ipMask2); match.setField(MatchType.NW_TOS, tos); match.setField(MatchType.NW_PROTO, proto); match.setField(MatchType.TP_SRC, src); match.setField(MatchType.TP_DST, dst);
private List<FlowOnNode> forwardingTableEntriesToFlows(Map<String, Integer> entries, Node node){ List<FlowOnNode> list = new ArrayList<FlowOnNode>(); for(Map.Entry<String, Integer> entry : entries.entrySet()){ Match match = new Match(); String str = entry.getKey(); short vlan = Short.parseShort(str.substring(0, str.indexOf("."))); byte[] macAddrBytes = OIDToMacAddrBytes(str.substring(str.indexOf(".") + 1)); if(macAddrBytes == null){ logger.debug("ERROR: forwardingTableEntriesToFlows(): nodeID is {}, call OIDToMacAddrBytes() fail", (Long)node.getID()); return null; } match.setField(MatchType.DL_VLAN, vlan); match.setField(MatchType.DL_DST, macAddrBytes); List<Action> actions = new ArrayList<Action>(); NodeConnector oport = NodeConnectorCreator.createNodeConnector("SNMP", Short.parseShort(entry.getValue().toString()), node); actions.add(new Output(oport)); Flow flow = new Flow(match, actions); list.add(new FlowOnNode(flow)); } return list; }
match.setField(MatchType.IN_PORT, port); match.setField(MatchType.DL_SRC, srcMac); match.setField(MatchType.DL_DST, dstMac); match.setField(MatchType.DL_TYPE, ethertype); match.setField(MatchType.DL_VLAN, vlan); match.setField(MatchType.DL_VLAN_PR, vlanPr); match.setField(MatchType.NW_SRC, srcIP, ipMask); match.setField(MatchType.NW_DST, dstIP, ipMask2); match.setField(MatchType.NW_TOS, tos); match.setField(MatchType.NW_PROTO, proto); match.setField(MatchType.TP_SRC, src); match.setField(MatchType.TP_DST, dst);
private static void fillFromArp(Match target, ArpMatch source) { Ipv4Prefix sourceAddress = source.getArpSourceTransportAddress(); if (sourceAddress != null) { target.setField(NW_SRC, inetAddressFrom(sourceAddress), null); } Ipv4Prefix destAddress = source.getArpTargetTransportAddress(); if (destAddress != null) { target.setField(NW_DST, inetAddressFrom(destAddress), null); } ArpSourceHardwareAddress sourceHwAddress = source.getArpSourceHardwareAddress(); if (sourceHwAddress != null) { target.setField(DL_SRC, bytesFrom(sourceHwAddress.getAddress())); } ArpTargetHardwareAddress targetHwAddress = source.getArpTargetHardwareAddress(); if (targetHwAddress != null) { target.setField(DL_DST, bytesFrom(targetHwAddress.getAddress())); } target.setField(DL_TYPE, ETHERNET_ARP); }
/** * @param target * @param inPort */ private static void fillFrom(Match target, NodeConnectorId inPort) { if (inPort != null) { String inPortValue = inPort.getValue(); if (inPortValue != null) { try { target.setField(MatchType.IN_PORT, NodeMapping.toADNodeConnector(inPort, NodeMapping.toAdNodeId(inPort))); } catch (ConstructionException e) { LOG.warn("nodeConnector construction failed", e); } } } }
private static void fillFrom(Match target, VlanMatch vlanMatch) { if (vlanMatch != null) { VlanId vlanId = vlanMatch.getVlanId(); if (vlanId != null) { if (Boolean.TRUE.equals(vlanId.isVlanIdPresent())) { org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId vlanIdInner = vlanId .getVlanId(); if (vlanIdInner != null) { Integer vlanValue = vlanIdInner.getValue(); if (vlanValue != null) { target.setField(DL_VLAN, vlanValue.shortValue()); } } } else { target.setField(DL_VLAN, MatchType.DL_VLAN_NONE); } } VlanPcp vlanPcp = vlanMatch.getVlanPcp(); if (vlanPcp != null) { Short vlanPcpValue = vlanPcp.getValue(); if (vlanPcpValue != null) { target.setField(DL_VLAN_PR, vlanPcpValue.byteValue()); } } } }
private static void fillFrom(Match target, IpMatch ipMatch) { if (ipMatch != null) { Short ipProtocol = ipMatch.getIpProtocol(); if (ipProtocol != null && target.getField(NW_PROTO) == null) { target.setField(NW_PROTO, ipProtocol.byteValue()); } Dscp dscp = ipMatch.getIpDscp(); if (dscp != null) { Short dscpValue = dscp.getValue(); if (dscpValue != null) { target.setField(NW_TOS, dscpValue.byteValue()); } } } }
private static void fillFrom(Match target, EthernetMatch source) { if (source == null) return; EthernetType ethType = source.getEthernetType(); if (ethType != null) { EtherType ethInnerType = ethType.getType(); if (ethInnerType != null && target.getField(DL_TYPE) == null) { Long value = ethInnerType.getValue(); target.setField(DL_TYPE, value.shortValue()); } } MacAddressFilter ethSource = source.getEthernetSource(); if (ethSource != null) { target.setField(DL_SRC, bytesFrom(ethSource.getAddress())); } MacAddressFilter ethDest = source.getEthernetDestination(); if (ethDest != null) { target.setField(DL_DST, bytesFrom(ethDest.getAddress())); } }
public void _modifyflow(CommandInterpreter ci) throws UnknownHostException { Node node = null; String nodeId = ci.nextArgument(); if (nodeId == null) { ci.print("Node id not specified"); return; } try { node = new Node(NodeIDType.OPENFLOW, Long.valueOf(nodeId)); } catch (NumberFormatException e) { logger.error("",e); } catch (ConstructionException e) { logger.error("",e); } Flow flowA = getSampleFlow(node); Flow flowB = getSampleFlow(node); Match matchB = flowB.getMatch(); matchB.setField(MatchType.NW_DST, InetAddress.getByName("190.190.190.190")); flowB.setMatch(matchB); ci.println(this.modifyFlow(node, flowA, flowB)); }
/** * Returns a reversed version of this match * For example, in the reversed version the network source and destination * addresses will be exchanged. Non symmetric match field will not be * copied over into the reversed match version, like input port. * * @return */ public Match reverse() { // Copy over all fields Match reverse = this.clone(); // Flip symmetric fields for (Map.Entry<MatchType, MatchType> entry : Match.reversableMatches.entrySet()) { MatchType from = entry.getKey(); MatchType to = entry.getValue(); if (this.isPresent(from)) { reverse.setField(to, this.getField(from).getValue(), this.getField(from).getMask()); if (!this.isPresent(to)) { reverse.clearField(from); } } } // Reset asymmetric fields reverse.clearField(MatchType.IN_PORT); return reverse; }