当前位置: 首页>>代码示例>>Java>>正文


Java NodeConnectorCreator.createOFNodeConnector方法代码示例

本文整理汇总了Java中org.opendaylight.controller.sal.utils.NodeConnectorCreator.createOFNodeConnector方法的典型用法代码示例。如果您正苦于以下问题:Java NodeConnectorCreator.createOFNodeConnector方法的具体用法?Java NodeConnectorCreator.createOFNodeConnector怎么用?Java NodeConnectorCreator.createOFNodeConnector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.opendaylight.controller.sal.utils.NodeConnectorCreator的用法示例。


在下文中一共展示了NodeConnectorCreator.createOFNodeConnector方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNodeConnectorsFromString

import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入方法依赖的package包/类
private void getNodeConnectorsFromString(String codedNodeConnectors,
        Set<NodeConnector> sp) {
    if (codedNodeConnectors == null) {
        return;
    }
    if (sp == null) {
        return;
    }
    // codedNodeConnectors = xx:xx:xx:xx:xx:xx:xx:xx/a,b,c-m,r-t,y
    String pieces[] = codedNodeConnectors.split("/");
    for (Short port : getPortList(pieces[1])) {
        Node n = Node.fromString(pieces[0]);
        if (n == null) {
            continue;
        }
        NodeConnector p = NodeConnectorCreator.createOFNodeConnector(port,
                n);
        if (p == null) {
            continue;
        }
        sp.add(p);
    }
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:24,代码来源:SubnetConfig.java

示例2: filterPortListPerContainer

import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入方法依赖的package包/类
/**
 * Filters a list of OFStatistics elements based on the container
 *
 * @param container
 * @param nodeId
 * @param list
 * @return
 */
public List<OFStatistics> filterPortListPerContainer(String container, long switchId, List<OFStatistics> list) {
    if (list == null) {
        return null;
    }

    // Create new filtered list of flows
    List<OFStatistics> newList = new ArrayList<OFStatistics>();

    for (OFStatistics stat : list) {
        OFPortStatisticsReply target = (OFPortStatisticsReply) stat;
        NodeConnector nc = NodeConnectorCreator.createOFNodeConnector(
                target.getPortNumber(), NodeCreator.createOFNode(switchId));
        if (containerOwnsNodeConnector(container, nc)) {
            newList.add(target);
        }
    }

    return newList;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:28,代码来源:ReadServiceFilter.java

示例3: StaticRoute

import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入方法依赖的package包/类
/**
 * Create a static route object from the StaticRouteConfig.
 * @param: config: StaticRouteConfig
 */
public StaticRoute(StaticRouteConfig config) {
    networkAddress = config.getStaticRouteIP();
    mask = StaticRoute.getV4AddressMaskFromDecimal(config
            .getStaticRouteMask());
    type = NextHopType.fromString(config.getNextHopType());
    nextHopAddress = config.getNextHopIP();
    Map<Long, Short> switchPort = config.getNextHopSwitchPorts();
    if ((switchPort != null) && (switchPort.size() == 1)) {
        node = NodeCreator.createOFNode((Long) switchPort.keySet()
                .toArray()[0]);
        port = NodeConnectorCreator.createOFNodeConnector(
                (Short) switchPort.values().toArray()[0], node);
    }
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:19,代码来源:StaticRoute.java

示例4: testSwitchAddRemovePort

import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入方法依赖的package包/类
@Test
public void testSwitchAddRemovePort() {
    Node node = NodeCreator.createOFNode(((long) 10));

    NodeConnector nc0 = NodeConnectorCreator.createOFNodeConnector(
            (short) 20, node);
    NodeConnector nc1 = NodeConnectorCreator.createOFNodeConnector(
            (short) 30, node);
    NodeConnector nc4 = NodeConnectorCreator.createOFNodeConnector(
            (short) 60, node);
    NodeConnector nc5 = NodeConnectorCreator.createOFNodeConnector(
            (short) 70, node);
    ArrayList<NodeConnector> portList = new ArrayList<NodeConnector>();

    portList.add(nc4);
    portList.add(nc5);

    Set<NodeConnector> ncSet = new HashSet<NodeConnector>();
    ncSet.add(nc0);
    ncSet.add(nc1);

    Switch sw = new Switch(node);
    sw.setNodeConnectors(ncSet);
    sw.removeNodeConnector(nc0);
    Assert.assertFalse(ncSet.contains(nc0));

    sw.removeSpanPorts(portList);
    Assert.assertTrue(sw.getSpanPorts().isEmpty());

}
 
开发者ID:lbchen,项目名称:ODL,代码行数:31,代码来源:SwitchTest.java

示例5: testMatchSetGet

import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入方法依赖的package包/类
@Test
public void testMatchSetGet() {
    Match x = new Match();
    short val = 2346;
    NodeConnector inPort = NodeConnectorCreator.createOFNodeConnector(val, NodeCreator.createOFNode(1l));
    x.setField(MatchType.IN_PORT, inPort);
    Assert.assertTrue(((NodeConnector) x.getField(MatchType.IN_PORT).getValue()).equals(inPort));
    Assert.assertTrue((Short) ((NodeConnector) x.getField(MatchType.IN_PORT).getValue()).getID() == val);
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:10,代码来源:MatchTest.java

示例6: testMatchMask

import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入方法依赖的package包/类
@Test
public void testMatchMask() {
    Match x = new Match();
    NodeConnector inPort = NodeConnectorCreator.createOFNodeConnector((short) 6, NodeCreator.createOFNode(3l));
    x.setField(MatchType.IN_PORT, inPort);
    x.setField(MatchType.DL_VLAN, (short) 28, (short) 0xfff);
    Assert.assertFalse(x.getMatches() == 0);
    Assert.assertTrue(x.getMatches() == (MatchType.IN_PORT.getIndex() | MatchType.DL_VLAN.getIndex()));
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:10,代码来源:MatchTest.java

示例7: addDiscovery

import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入方法依赖的package包/类
private void addDiscovery(Node node) {
    Map<Long, ISwitch> switches = controller.getSwitches();
    ISwitch sw = switches.get(node.getID());
    List<OFPhysicalPort> ports = sw.getEnabledPorts();
    if (ports == null) {
        return;
    }
    for (OFPhysicalPort port : ports) {
        NodeConnector nodeConnector = NodeConnectorCreator.createOFNodeConnector(port.getPortNumber(), node);
        if (!readyListHi.contains(nodeConnector)) {
            readyListHi.add(nodeConnector);
        }
    }
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:15,代码来源:DiscoveryService.java

示例8: testHostFind

import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入方法依赖的package包/类
@Test
public void testHostFind() throws UnknownHostException {

    assertNotNull(this.invtoryListener);

    // create one node and two node connectors
    Node node1 = NodeCreator.createOFNode(1L);
    NodeConnector nc1_1 = NodeConnectorCreator.createOFNodeConnector(
            (short) 1, node1);
    NodeConnector nc1_2 = NodeConnectorCreator.createOFNodeConnector(
            (short) 2, node1);

    // test addStaticHost(), put into inactive host DB if not verifiable
    Status st = this.hosttracker.addStaticHost("192.168.0.8",
            "11:22:33:44:55:66", nc1_1, "0");
    st = this.hosttracker.addStaticHost("192.168.0.13",
            "11:22:33:44:55:77", nc1_2, "0");

    HostNodeConnector hnc_1 = this.hosttracker.hostFind(InetAddress
            .getByName("192.168.0.8"));
    assertNull(hnc_1);

    this.invtoryListener.notifyNodeConnector(nc1_1, UpdateType.ADDED, null);

    hnc_1 = this.hosttracker.hostFind(InetAddress.getByName("192.168.0.8"));
    assertNotNull(hnc_1);

}
 
开发者ID:lbchen,项目名称:ODL,代码行数:29,代码来源:HostTrackerIT.java

示例9: testSwitchCreation

import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入方法依赖的package包/类
@Test
public void testSwitchCreation() {

    Node node = NodeCreator.createOFNode(((long) 10));
    Node node2 = NodeCreator.createOFNode(((long) 11));
    NodeConnector nc0 = NodeConnectorCreator.createOFNodeConnector(
            (short) 20, node);
    NodeConnector nc1 = NodeConnectorCreator.createOFNodeConnector(
            (short) 30, node);
    NodeConnector nc2 = NodeConnectorCreator.createOFNodeConnector(
            (short) 40, node);
    NodeConnector nc3 = NodeConnectorCreator.createOFNodeConnector(
            (short) 50, node);
    NodeConnector nc4 = NodeConnectorCreator.createOFNodeConnector(
            (short) 60, node);
    NodeConnector nc5 = NodeConnectorCreator.createOFNodeConnector(
            (short) 70, node);

    Set<NodeConnector> ncSet = new HashSet<NodeConnector>();
    ArrayList<NodeConnector> portList = new ArrayList<NodeConnector>();

    Switch sw = new Switch(node);
    Switch sw2 = new Switch(node);
    Assert.assertTrue(sw.equals(sw2));
    sw2.setNode(node2);
    Assert.assertTrue(sw2.getNode().equals(node2));
    Assert.assertFalse(sw.equals(sw2));

    ncSet.add(nc0);
    ncSet.add(nc1);
    ncSet.add(nc2);
    sw.addNodeConnector(nc3);
    try {
        sw.addNodeConnector(nc3);
    } catch (Exception e) {
        fail("Attempted to add duplicate NodeConnector to set");
    }

    portList.add(nc4);
    portList.add(nc5);

    sw.setNodeConnectors(ncSet);
    sw.addSpanPorts(portList);

    sw.setDataLayerAddress(null);
    Assert.assertNull(sw.getDataLayerAddress());
    byte[] dlAddress = { (byte) 0x01, (byte) 0x02, (byte) 0x03,
            (byte) 0x04, (byte) 0x05, (byte) 0x06 };
    sw.setDataLayerAddress(dlAddress);

    Node resultNode = sw.getNode();
    Set<NodeConnector> resultncSet = sw.getNodeConnectors();
    byte[] resultdlAddress = sw.getDataLayerAddress();
    ArrayList<NodeConnector> resultSpanPort = (ArrayList<NodeConnector>) sw
            .getSpanPorts();

    Assert.assertEquals(node, resultNode);
    for (int i = 0; i < dlAddress.length; i++)
        Assert.assertEquals(dlAddress[i], resultdlAddress[i]);

    Assert.assertTrue(ncSet.equals(resultncSet));

    for (int i = 0; i < portList.size(); i++)
        Assert.assertEquals(portList.get(i), resultSpanPort.get(i));
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:66,代码来源:SwitchTest.java

示例10: testSubnet

import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入方法依赖的package包/类
@Test
public void testSubnet() throws Exception {
    InetAddress ipaddr = InetAddress.getByName("100.0.0.1");
    Subnet subnet = new Subnet(ipaddr, (short) 24, (short) 5);
    Assert.assertTrue(subnet.equals(subnet));
    Assert.assertFalse(subnet.equals(null));
    Assert.assertFalse(subnet.equals(ipaddr));
    Subnet subnet2 = new Subnet(ipaddr, (short) 24, (short) 5);
    Inet6Address ipv6 = (Inet6Address) Inet6Address
            .getByName("1111::2222:3333:4444:5555:6666");
    Subnet subnet3 = new Subnet(ipv6, (short) 24, (short) 5);
    Assert.assertTrue(subnet.equals(subnet2));
    Assert.assertFalse(subnet.isMutualExclusive(subnet2));
    Assert.assertTrue(subnet.isMutualExclusive(subnet3));
    InetAddress subnetAddr = InetAddress.getByName("200.0.0.100");

    Assert.assertTrue(subnet.isFlatLayer2() == true);

    Set<NodeConnector> ncSet = new HashSet<NodeConnector>();
    Node node = NodeCreator.createOFNode(((long) 10));
    NodeConnector nc0 = NodeConnectorCreator.createOFNodeConnector(
            (short) 20, node);
    NodeConnector nc1 = NodeConnectorCreator.createOFNodeConnector(
            (short) 30, node);
    NodeConnector nc2 = NodeConnectorCreator.createOFNodeConnector(
            (short) 40, node);

    ncSet.add(nc0);
    ncSet.add(nc1);
    ncSet.add(nc2);

    Assert.assertTrue(subnet.hasNodeConnector(nc0));
    Assert.assertFalse(subnet.hasNodeConnector(null));
    subnet.addNodeConnectors(ncSet);
    Assert.assertTrue(subnet.hasNodeConnector(nc0));

    Set<NodeConnector> resultncSet = subnet.getNodeConnectors();
    Assert.assertEquals(resultncSet, ncSet);
    subnet.addNodeConnectors(null);
    Assert.assertEquals(subnet.getNodeConnectors(), ncSet);

    subnet.deleteNodeConnectors(null);
    Assert.assertEquals(subnet.getNodeConnectors(), ncSet);

    Set<NodeConnector> ncSet2 = new HashSet<NodeConnector>();
    ncSet2.add(nc0);
    subnet.deleteNodeConnectors(ncSet2);
    Assert.assertFalse(subnet.getNodeConnectors().contains(nc0));
    Assert.assertFalse(subnet.hasNodeConnector(nc0));
    Assert.assertTrue(subnet.getNodeConnectors().contains(nc1));
    Assert.assertTrue(subnet.getNodeConnectors().contains(nc2));

    subnet.deleteNodeConnectors(ncSet2);

    subnet.setNetworkAddress(subnetAddr);
    Assert.assertTrue(subnet.isMutualExclusive(subnet2));
    Assert.assertTrue(subnet.getNetworkAddress().equals(subnetAddr));

    subnet.setSubnetMaskLength((short) 16);
    Assert.assertTrue(subnet.getSubnetMaskLength() == 16);

    subnet.setVlan((short) 100);
    Assert.assertTrue(subnet.getVlan() == 100);

    Assert.assertTrue(subnet.isFlatLayer2() == false);

}
 
开发者ID:lbchen,项目名称:ODL,代码行数:68,代码来源:SubnetTest.java

示例11: getSampleFlowV6

import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入方法依赖的package包/类
private Flow getSampleFlowV6(Node node) throws UnknownHostException {
    NodeConnector port = NodeConnectorCreator.createOFNodeConnector((short) 24, node);
    NodeConnector oport = NodeConnectorCreator.createOFNodeConnector((short) 30, node);
    byte srcMac[] = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9a, (byte) 0xbc };
    byte dstMac[] = { (byte) 0x1a, (byte) 0x2b, (byte) 0x3c, (byte) 0x4d, (byte) 0x5e, (byte) 0x6f };
    byte newMac[] = { (byte) 0x11, (byte) 0xaa, (byte) 0xbb, (byte) 0x34, (byte) 0x9a, (byte) 0xee };
    InetAddress srcIP = InetAddress.getByName("2001:420:281:1004:407a:57f4:4d15:c355");
    InetAddress dstIP = InetAddress.getByName("2001:420:281:1004:e123:e688:d655:a1b0");
    InetAddress ipMask = InetAddress.getByName("ffff:ffff:ffff:ffff:0:0:0:0");
    InetAddress ipMask2 = InetAddress.getByName("ffff:ffff:ffff:ffff:ffff:ffff:ffff:0");
    InetAddress newIP = InetAddress.getByName("2056:650::a1b0");
    short ethertype = EtherTypes.IPv6.shortValue();
    short vlan = (short) 27;
    byte vlanPr = (byte) 3;
    Byte tos = 4;
    byte proto = IPProtocols.UDP.byteValue();
    short src = (short) 5500;
    short dst = 80;

    /*
     * Create a SAL Flow aFlow
     */
    Match match = new Match();
    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);

    List<Action> actions = new ArrayList<Action>();
    actions.add(new Controller());
    actions.add(new SetVlanId(5));
    actions.add(new SetDlDst(newMac));
    actions.add(new SetNwDst(newIP));
    actions.add(new Output(oport));
    actions.add(new PopVlan());
    actions.add(new Flood());

    Flow flow = new Flow(match, actions);
    flow.setPriority((short) 300);
    flow.setHardTimeout((short) 240);

    return flow;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:52,代码来源:frmTest.java

示例12: getSampleFlow

import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入方法依赖的package包/类
private Flow getSampleFlow(Node node) throws UnknownHostException {
    NodeConnector port = NodeConnectorCreator.createOFNodeConnector((short) 24, node);
    NodeConnector oport = NodeConnectorCreator.createOFNodeConnector((short) 30, node);
    byte srcMac[] = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9a, (byte) 0xbc };
    byte dstMac[] = { (byte) 0x1a, (byte) 0x2b, (byte) 0x3c, (byte) 0x4d, (byte) 0x5e, (byte) 0x6f };
    InetAddress srcIP = InetAddress.getByName("172.28.30.50");
    InetAddress dstIP = InetAddress.getByName("171.71.9.52");
    InetAddress ipMask = InetAddress.getByName("255.255.255.0");
    InetAddress ipMask2 = InetAddress.getByName("255.0.0.0");
    short ethertype = EtherTypes.IPv4.shortValue();
    short vlan = (short) 27;
    byte vlanPr = 3;
    Byte tos = 4;
    byte proto = IPProtocols.TCP.byteValue();
    short src = (short) 55000;
    short dst = 80;

    /*
     * Create a SAL Flow aFlow
     */
    Match match = new Match();
    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);

    List<Action> actions = new ArrayList<Action>();
    actions.add(new Output(oport));
    actions.add(new PopVlan());
    actions.add(new Flood());
    actions.add(new Controller());
    return new Flow(match, actions);
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:42,代码来源:ForwardingRulesManager.java

示例13: testFlip

import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入方法依赖的package包/类
@Test
public void testFlip() throws Exception {
    Node node = NodeCreator.createOFNode(7l);
    NodeConnector port = NodeConnectorCreator.createOFNodeConnector((short) 24, node);
    byte srcMac[] = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9a, (byte) 0xbc };
    byte dstMac[] = { (byte) 0x1a, (byte) 0x2b, (byte) 0x3c, (byte) 0x4d, (byte) 0x5e, (byte) 0x6f };
    InetAddress srcIP = InetAddress.getByName("2001:420:281:1004:407a:57f4:4d15:c355");
    InetAddress dstIP = InetAddress.getByName("2001:420:281:1004:e123:e688:d655:a1b0");
    InetAddress ipMasks = InetAddress.getByName("ffff:ffff:ffff:ffff:0:0:0:0");
    InetAddress ipMaskd = InetAddress.getByName("ffff:ffff:ffff:ffff:ffff:ffff:ffff:0");
    short ethertype = EtherTypes.IPv6.shortValue();
    short vlan = (short) 27;
    byte vlanPr = (byte) 3;
    Byte tos = 4;
    byte proto = IPProtocols.UDP.byteValue();
    short src = (short) 5500;
    short dst = 80;

    /*
     * Create a SAL Flow aFlow
     */
    Match match = new Match();
    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, ipMasks);
    match.setField(MatchType.NW_DST, dstIP, ipMaskd);
    match.setField(MatchType.NW_TOS, tos);
    match.setField(MatchType.NW_PROTO, proto);
    match.setField(MatchType.TP_SRC, src);
    match.setField(MatchType.TP_DST, dst);

    Match flipped = match.reverse();

    Assert.assertTrue(match.getField(MatchType.DL_TYPE).equals(flipped.getField(MatchType.DL_TYPE)));
    Assert.assertTrue(match.getField(MatchType.DL_VLAN).equals(flipped.getField(MatchType.DL_VLAN)));

    Assert.assertTrue(match.getField(MatchType.DL_DST).getValue()
            .equals(flipped.getField(MatchType.DL_SRC).getValue()));
    Assert.assertTrue(match.getField(MatchType.DL_DST).getMask() == flipped.getField(MatchType.DL_SRC).getMask());

    Assert.assertTrue(match.getField(MatchType.NW_DST).getValue()
            .equals(flipped.getField(MatchType.NW_SRC).getValue()));
    Assert.assertTrue(match.getField(MatchType.NW_DST).getMask() == flipped.getField(MatchType.NW_SRC).getMask());

    Assert.assertTrue(match.getField(MatchType.TP_DST).getValue()
            .equals(flipped.getField(MatchType.TP_SRC).getValue()));
    Assert.assertTrue(match.getField(MatchType.TP_DST).getMask() == flipped.getField(MatchType.TP_SRC).getMask());

    Match flipflip = flipped.reverse().reverse();
    Assert.assertTrue(flipflip.equals(flipped));

}
 
开发者ID:lbchen,项目名称:ODL,代码行数:57,代码来源:MatchTest.java

示例14: getSampleFlow

import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入方法依赖的package包/类
private Flow getSampleFlow(Node node) throws UnknownHostException {
    NodeConnector port = NodeConnectorCreator.createOFNodeConnector(
            (short) 24, node);
    NodeConnector oport = NodeConnectorCreator.createOFNodeConnector(
            (short) 30, node);
    byte srcMac[] = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78,
            (byte) 0x9a, (byte) 0xbc };
    byte dstMac[] = { (byte) 0x1a, (byte) 0x2b, (byte) 0x3c, (byte) 0x4d,
            (byte) 0x5e, (byte) 0x6f };
    InetAddress srcIP = InetAddress.getByName("172.28.30.50");
    InetAddress dstIP = InetAddress.getByName("171.71.9.52");
    InetAddress newIP = InetAddress.getByName("200.200.100.1");
    InetAddress ipMask = InetAddress.getByName("255.255.255.0");
    InetAddress ipMask2 = InetAddress.getByName("255.240.0.0");
    short ethertype = EtherTypes.IPv4.shortValue();
    short vlan = (short) 27;
    byte vlanPr = 3;
    Byte tos = 4;
    byte proto = IPProtocols.TCP.byteValue();
    short src = (short) 55000;
    short dst = 80;

    /*
     * Create a SAL Flow aFlow
     */
    Match match = new Match();
    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);

    List<Action> actions = new ArrayList<Action>();
    actions.add(new SetNwDst(newIP));
    actions.add(new Output(oport));
    actions.add(new PopVlan());
    actions.add(new Flood());
    actions.add(new Controller());

    Flow flow = new Flow(match, actions);
    flow.setPriority((short) 100);
    flow.setHardTimeout((short) 360);

    return flow;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:53,代码来源:FlowTest.java

示例15: getSampleFlowV6

import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入方法依赖的package包/类
private Flow getSampleFlowV6(Node node) throws UnknownHostException {
    NodeConnector port = NodeConnectorCreator.createOFNodeConnector(
            (short) 24, node);
    NodeConnector oport = NodeConnectorCreator.createOFNodeConnector(
            (short) 30, node);
    byte srcMac[] = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78,
            (byte) 0x9a, (byte) 0xbc };
    byte dstMac[] = { (byte) 0x1a, (byte) 0x2b, (byte) 0x3c, (byte) 0x4d,
            (byte) 0x5e, (byte) 0x6f };
    byte newMac[] = { (byte) 0x11, (byte) 0xaa, (byte) 0xbb, (byte) 0x34,
            (byte) 0x9a, (byte) 0xee };
    InetAddress srcIP = InetAddress
            .getByName("2001:420:281:1004:407a:57f4:4d15:c355");
    InetAddress dstIP = InetAddress
            .getByName("2001:420:281:1004:e123:e688:d655:a1b0");
    InetAddress ipMask = InetAddress
            .getByName("ffff:ffff:ffff:ffff:0:0:0:0");
    InetAddress ipMask2 = InetAddress
            .getByName("ffff:ffff:ffff:ffff:ffff:ffff:ffff:0");
    InetAddress newIP = InetAddress.getByName("2056:650::a1b0");
    short ethertype = EtherTypes.IPv6.shortValue();
    short vlan = (short) 27;
    byte vlanPr = (byte) 3;
    Byte tos = 4;
    byte proto = IPProtocols.UDP.byteValue();
    short src = (short) 5500;
    short dst = 80;

    /*
     * Create a SAL Flow aFlow
     */
    Match match = new Match();
    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);

    List<Action> actions = new ArrayList<Action>();
    actions.add(new Controller());
    actions.add(new SetVlanId(5));
    actions.add(new SetDlDst(newMac));
    actions.add(new SetNwDst(newIP));
    actions.add(new Output(oport));
    actions.add(new PopVlan());
    actions.add(new Flood());

    actions.add(new Controller());

    Flow flow = new Flow(match, actions);
    flow.setPriority((short) 300);
    flow.setHardTimeout((short) 240);

    return flow;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:63,代码来源:FlowTest.java


注:本文中的org.opendaylight.controller.sal.utils.NodeConnectorCreator.createOFNodeConnector方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。