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


Java IPProtocols类代码示例

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


IPProtocols类属于org.opendaylight.controller.sal.utils包,在下文中一共展示了IPProtocols类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createSampleFlowConfig

import org.opendaylight.controller.sal.utils.IPProtocols; //导入依赖的package包/类
private FlowConfig createSampleFlowConfig() throws UnknownHostException {
    ArrayList<String> actions;
    actions = createSampleActionList();
    // actions.add(ActionType.CONTROLLER.toString());
    FlowConfig flowConfig = new FlowConfig("true", "Config1", Node.fromString(Node.NodeIDType.OPENFLOW, "1"),
            "100", "0", "60", "2", "100", "0", "0x0800", "00:A0:C9:14:C8:29", "00:A0:C9:22:AB:11",
            IPProtocols.TCP.toString(), "0", "1.2.3.4", "2.2.2.2", "8080", "100", "300", "1000", actions);
    return flowConfig;

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

示例2: isIPv6

import org.opendaylight.controller.sal.utils.IPProtocols; //导入依赖的package包/类
/**
 * Returns whether this match is for an IPv6 flow
 */
public boolean isIPv6() {
    return (isPresent(MatchType.DL_TYPE)
            && ((Short) getField(MatchType.DL_TYPE).getValue())
                    .equals(EtherTypes.IPv6.shortValue())
            || isPresent(MatchType.NW_PROTO)
            && ((Byte) getField(MatchType.NW_PROTO).getValue())
                    .equals(IPProtocols.IPV6ICMP.byteValue())
            || isPresent(MatchType.NW_SRC)
            && getField(MatchType.NW_SRC).getValue() instanceof Inet6Address || isPresent(MatchType.NW_DST)
            && getField(MatchType.NW_DST).getValue() instanceof Inet6Address);
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:15,代码来源:Match.java

示例3: getSampleFlowV6

import org.opendaylight.controller.sal.utils.IPProtocols; //导入依赖的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

示例4: getSampleFlow

import org.opendaylight.controller.sal.utils.IPProtocols; //导入依赖的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

示例5: testFlip

import org.opendaylight.controller.sal.utils.IPProtocols; //导入依赖的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

示例6: getSampleFlow

import org.opendaylight.controller.sal.utils.IPProtocols; //导入依赖的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

示例7: getSampleFlowV6

import org.opendaylight.controller.sal.utils.IPProtocols; //导入依赖的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

示例8: testFullIP

import org.opendaylight.controller.sal.utils.IPProtocols; //导入依赖的package包/类
@Test
public void testFullIP() throws UnknownHostException, PacketException {
    byte[] icmpRawPayload = new byte[] { (byte) 0x38, (byte) 0x26,
            (byte) 0x9e, (byte) 0x51, (byte) 0x00, (byte) 0x00,
            (byte) 0x00, (byte) 0x00, (byte) 0x2e, (byte) 0x6a,
            (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x00,
            (byte) 0x00, (byte) 0x00, (byte) 0x10, (byte) 0x11,
            (byte) 0x12, (byte) 0x13, (byte) 0x14, (byte) 0x15,
            (byte) 0x16, (byte) 0x17, (byte) 0x18, (byte) 0x19,
            (byte) 0x1a, (byte) 0x1b, (byte) 0x1c, (byte) 0x1d,
            (byte) 0x1e, (byte) 0x1f, (byte) 0x20, (byte) 0x21,
            (byte) 0x22, (byte) 0x23, (byte) 0x24, (byte) 0x25,
            (byte) 0x26, (byte) 0x27, (byte) 0x28, (byte) 0x29,
            (byte) 0x2a, (byte) 0x2b, (byte) 0x2c, (byte) 0x2d,
            (byte) 0x2e, (byte) 0x2f, (byte) 0x30, (byte) 0x31,
            (byte) 0x32, (byte) 0x33, (byte) 0x34, (byte) 0x35,
            (byte) 0x36, (byte) 0x37 };
    ICMP icmp = new ICMP();
    icmp.setType((byte) 8);
    icmp.setCode((byte) 0);
    icmp.setIdentifier((short) 0x46f5);
    icmp.setSequenceNumber((short) 2);
    icmp.setRawPayload(icmpRawPayload);

    IPv4 ip = new IPv4();
    ip.setVersion((byte) 4);
    ip.setIdentification((short) 5);
    ip.setDiffServ((byte) 0);
    ip.setECN((byte) 0);
    ip.setTotalLength((short) 84);
    ip.setFlags((byte) 2);
    ip.setFragmentOffset((short) 0);
    ip.setTtl((byte) 64);
    ip.setProtocol(IPProtocols.ICMP.byteValue());
    ip.setDestinationAddress(InetAddress.getByName("192.168.100.100"));
    ip.setSourceAddress(InetAddress.getByName("192.168.100.101"));
    ip.setPayload(icmp);

    Ethernet eth = new Ethernet();
    eth.setDestinationMACAddress(new byte[] { (byte) 0x98, (byte) 0xfc,
            (byte) 0x11, (byte) 0x93, (byte) 0x5c, (byte) 0xb8 });
    eth.setSourceMACAddress(new byte[] { (byte) 0x00, (byte) 0x24,
            (byte) 0xd7, (byte) 0xa9, (byte) 0xa3, (byte) 0x50 });
    eth.setEtherType(EtherTypes.IPv4.shortValue());
    eth.setPayload(ip);

    byte[] stream = eth.serialize();

    Ethernet decEth = new Ethernet();
    decEth.deserialize(stream, 0, stream.length * NetUtils.NumBitsInAByte);

    IPv4 decIp = (IPv4) decEth.getPayload();
    Assert.assertFalse(decIp.isCorrupted());
    Assert.assertTrue(ip.equals(decIp));

    ICMP decIcmp = (ICMP) decIp.getPayload();
    Assert.assertFalse(decIcmp.isCorrupted());
    Assert.assertTrue(Arrays.equals(icmpRawPayload, decIcmp.getRawPayload()));
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:60,代码来源:IPv4Test.java

示例9: getSampleFlow

import org.opendaylight.controller.sal.utils.IPProtocols; //导入依赖的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,代码行数:46,代码来源:ReadService.java

示例10: getSampleFlowV6

import org.opendaylight.controller.sal.utils.IPProtocols; //导入依赖的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 };
    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 = null; // InetAddress.getByName("ffff:ffff:ffff:ffff:0:0:0:0");
                               // V6Match implementation assumes no mask is
                               // specified
    InetAddress ipMask2 = null; // 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); // V6Match does not handle
                                                  // this properly...
    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); // V6Match does not handle this
                                           // properly...
    // match.setField(MatchType.TP_DST, dst); V6Match does not handle this
    // properly...

    List<Action> actions = new ArrayList<Action>();
    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,代码行数:57,代码来源:FlowProgrammerService.java

示例11: testV6MatchToSALMatchToV6MatchConversion

import org.opendaylight.controller.sal.utils.IPProtocols; //导入依赖的package包/类
@Test
public void testV6MatchToSALMatchToV6MatchConversion()
        throws UnknownHostException {
    NodeConnector port = NodeConnectorCreator.createNodeConnector(
            (short) 24, NodeCreator.createOFNode(6l));
    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 ipMask = null;//InetAddress.getByName("ffff:ffff:ffff:ffff:0:0:0:0");
    short ethertype = EtherTypes.IPv6.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 aMatch = new Match();

    aMatch.setField(MatchType.IN_PORT, port);
    aMatch.setField(MatchType.DL_SRC, srcMac);
    aMatch.setField(MatchType.DL_DST, dstMac);
    aMatch.setField(MatchType.DL_TYPE, ethertype);
    aMatch.setField(MatchType.DL_VLAN, vlan);
    aMatch.setField(MatchType.DL_VLAN_PR, vlanPr);
    aMatch.setField(MatchType.NW_SRC, srcIP, ipMask);
    aMatch.setField(MatchType.NW_DST, dstIP, ipMask);
    aMatch.setField(MatchType.NW_TOS, tos);
    aMatch.setField(MatchType.NW_PROTO, proto);
    aMatch.setField(MatchType.TP_SRC, src);
    aMatch.setField(MatchType.TP_DST, dst);

    Assert.assertTrue(aMatch.isIPv6());

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

示例12: installLoadBalancerFlow

import org.opendaylight.controller.sal.utils.IPProtocols; //导入依赖的package包/类
private boolean installLoadBalancerFlow(Client source,
                                        VIP dest,
                                        Node sourceSwitch,
                                        String destMachineIp,
                                        byte[] destMachineMac,
                                        NodeConnector outport,
                                        int flowDirection) throws UnknownHostException{

    Match match = new Match();
    List<Action> actions = new ArrayList<Action>();

    if(flowDirection == LBConst.FORWARD_DIRECTION_LB_FLOW){
        match.setField(MatchType.DL_TYPE, EtherTypes.IPv4.shortValue());
        match.setField(MatchType.NW_SRC, InetAddress.getByName(source.getIp()));
        match.setField(MatchType.NW_DST, InetAddress.getByName(dest.getIp()));
        match.setField(MatchType.NW_PROTO, IPProtocols.getProtocolNumberByte(dest.getProtocol()));
        match.setField(MatchType.TP_SRC, source.getPort());
        match.setField(MatchType.TP_DST, dest.getPort());

        actions.add(new SetNwDst(InetAddress.getByName(destMachineIp)));
        actions.add(new SetDlDst(destMachineMac));
    }

    if(flowDirection == LBConst.REVERSE_DIRECTION_LB_FLOW){
        match.setField(MatchType.DL_TYPE, EtherTypes.IPv4.shortValue());
        match.setField(MatchType.NW_SRC, InetAddress.getByName(destMachineIp));
        match.setField(MatchType.NW_DST, InetAddress.getByName(source.getIp()));
        match.setField(MatchType.NW_PROTO, IPProtocols.getProtocolNumberByte(source.getProtocol()));
        match.setField(MatchType.TP_SRC, dest.getPort());
        match.setField(MatchType.TP_DST,source.getPort());

        actions.add(new SetNwSrc(InetAddress.getByName(dest.getIp())));
        actions.add(new SetDlSrc(destMachineMac));
    }

    actions.add(new Output(outport));

    // Make sure the priority for IP switch entries is
    // set to a level just above default drop entries

    Flow flow = new Flow(match, actions);
    flow.setIdleTimeout((short) 5);
    flow.setHardTimeout((short) 0);
    flow.setPriority(LB_IPSWITCH_PRIORITY);

    String policyName = source.getIp()+":"+source.getProtocol()+":"+source.getPort();
    String flowName =null;

    if(flowDirection == LBConst.FORWARD_DIRECTION_LB_FLOW){
        flowName = "["+policyName+":"+source.getIp() + ":"+dest.getIp()+"]";
    }

    if(flowDirection == LBConst.REVERSE_DIRECTION_LB_FLOW){

        flowName = "["+policyName+":"+dest.getIp() + ":"+source.getIp()+"]";
    }

    FlowEntry fEntry = new FlowEntry(policyName, flowName, flow, sourceSwitch);

    lbsLogger.info("Install flow entry {} on node {}",fEntry.toString(),sourceSwitch.toString());

    if(!this.ruleManager.checkFlowEntryConflict(fEntry)){
        if(this.ruleManager.installFlowEntry(fEntry).isSuccess()){
            return true;
        }else{
            lbsLogger.error("Error in installing flow entry to node : {}",sourceSwitch);
        }
    }else{
        lbsLogger.error("Conflicting flow entry exists : {}",fEntry.toString());
    }
    return false;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:73,代码来源:LoadBalancerService.java

示例13: getClientFromPacket

import org.opendaylight.controller.sal.utils.IPProtocols; //导入依赖的package包/类
/**
 * Extract the details of the source machine that sent this packet 'inPkt'
 * @param inPkt Packet that is received by the controller
 * @return  Details of the source machine in Client object.
 */
public Client getClientFromPacket(IPv4 inPkt){
    lbuLogger.info("Find client information from packet : {}",inPkt.toString());

    String ip = NetUtils.getInetAddress(inPkt.getSourceAddress()).getHostAddress();

    String protocol = IPProtocols.getProtocolName(inPkt.getProtocol());

    lbuLogger.info("client ip {} and protocl {}",ip,protocol);

    Packet tpFrame= inPkt.getPayload();

    lbuLogger.info("Get protocol layer {}",tpFrame.toString());

    short port = 0;

    if(protocol.equals(IPProtocols.TCP.toString())){
        TCP tcpFrame = (TCP)tpFrame;
        port = tcpFrame.getSourcePort();
    }else{
        UDP udpFrame = (UDP)tpFrame;
        port = udpFrame.getSourcePort();
    }

    lbuLogger.info("Found port {}",port);

    Client source = new Client(ip, protocol,port);

    lbuLogger.info("Client information : {}",source.toString());

    return source;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:37,代码来源:LBUtil.java

示例14: getVIPFromPacket

import org.opendaylight.controller.sal.utils.IPProtocols; //导入依赖的package包/类
/**
 * Extract the details of the destination machine where this packet 'inPkt' need
 * to be delivered
 * @param inPkt Packet that is received by controller for forwarding
 * @return  Details of the destination machine packet in VIP
 */
public VIP getVIPFromPacket(IPv4 inPkt){

    lbuLogger.info("Find VIP information from packet : {}",inPkt.toString());

    String ip = NetUtils.getInetAddress(inPkt.getDestinationAddress()).getHostAddress();

    String protocol = IPProtocols.getProtocolName(inPkt.getProtocol());

    Packet tpFrame= inPkt.getPayload();

    short port = 0;

    if(protocol.equals(IPProtocols.TCP.toString())){
        TCP tcpFrame = (TCP)tpFrame;
        port = tcpFrame.getDestinationPort();
    }else{

        UDP udpFrame = (UDP)tpFrame;
        port = udpFrame.getDestinationPort();
    }

    VIP dest = new VIP(null,ip, protocol,port,null);

    lbuLogger.info("VIP information : {}",dest.toString());

    return dest;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:34,代码来源:LBUtil.java


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