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


Java IpProtocol类代码示例

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


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

示例1: FirewallRule

import org.projectfloodlight.openflow.types.IpProtocol; //导入依赖的package包/类
/**
 * The default rule is to match on anything.
 */
public FirewallRule() {
    this.dpid = DatapathId.NONE;
    this.in_port = OFPort.ANY; 
    this.dl_src = MacAddress.NONE;
    this.dl_dst = MacAddress.NONE;
    this.dl_type = EthType.NONE;
    this.nw_src_prefix_and_mask = IPv4AddressWithMask.NONE;
    this.nw_dst_prefix_and_mask = IPv4AddressWithMask.NONE;
    this.nw_proto = IpProtocol.NONE;
    this.tp_src = TransportPort.NONE;
    this.tp_dst = TransportPort.NONE;
    this.any_dpid = true; 
    this.any_in_port = true; 
    this.any_dl_src = true; 
    this.any_dl_dst = true; 
    this.any_dl_type = true; 
    this.any_nw_src = true; 
    this.any_nw_dst = true; 
    this.any_nw_proto = true; 
    this.any_tp_src = true; 
    this.any_tp_dst = true;
    this.priority = 0; 
    this.action = FirewallAction.ALLOW; 
    this.ruleid = 0; 
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:29,代码来源:FirewallRule.java

示例2: testSerializeWithoutPayload

import org.projectfloodlight.openflow.types.IpProtocol; //导入依赖的package包/类
@Test
public void testSerializeWithoutPayload() {
    byte[] expected = new byte[] {
            0x64, 0x2B, 0x16, (byte) 0x95, 0x00, 0x00,
            0x11, (byte) 0xE1, (byte) 0xFE, (byte) 0x80,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x7A, (byte) 0xC5, (byte) 0xFF, (byte) 0xFE,
            0x2E, 0x77, 0x35, (byte) 0xFE, (byte) 0x80,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x77, 0x5D, (byte) 0xFF, (byte) 0xFE,
            (byte) 0xC2, 0x30, (byte) 0xFD
    };
    IPv6 packet = (new IPv6())
        .setTrafficClass((byte) 0x42)
        .setFlowLabel(0xB1695)
        .setPayloadLength((short) 0)
        .setNextHeader(IpProtocol.of((short) 0x11))
        .setHopLimit((byte) 0xE1)
        .setSourceAddress(IPv6Address.of("fe80::7a:c5ff:fe2e:7735"))
        .setDestinationAddress(IPv6Address.of("fe80::77:5dff:fec2:30fd"));
    byte[] actual = packet.serialize();
    assertTrue(Arrays.equals(expected, actual));
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:24,代码来源:IPv6Test.java

示例3: testRuleDeletion

import org.projectfloodlight.openflow.types.IpProtocol; //导入依赖的package包/类
@Test
public void testRuleDeletion() throws Exception {
    // add TCP rule
    FirewallRule rule = new FirewallRule();
    rule.nw_proto = IpProtocol.TCP;
    rule.any_nw_proto = false;
    rule.priority = 1;
    firewall.addRule(rule);
    int rid = rule.ruleid;

    List<Map<String, Object>> rulesFromStorage = firewall.getStorageRules();
    assertEquals(1, rulesFromStorage.size());
    assertEquals(Integer.parseInt((String)rulesFromStorage.get(0).get("ruleid")), rid);

    // delete rule
    firewall.deleteRule(rid);
    rulesFromStorage = firewall.getStorageRules();
    assertEquals(0, rulesFromStorage.size());
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:20,代码来源:FirewallTest.java

示例4: testFirewallDisabled

import org.projectfloodlight.openflow.types.IpProtocol; //导入依赖的package包/类
@Test
public void testFirewallDisabled() throws Exception {
    // firewall isn't enabled by default
    // so, it shouldn't make any decision

    // add TCP rule
    FirewallRule rule = new FirewallRule();
    rule.nw_proto = IpProtocol.TCP;
    rule.any_nw_proto = false;
    rule.priority = 1;
    firewall.addRule(rule);

    this.setPacketIn(tcpPacket);
    firewall.receive(sw, this.packetIn, cntx);
    verify(sw);

    assertEquals(1, firewall.rules.size());

    IRoutingDecision decision = IRoutingDecision.rtStore.get(cntx, IRoutingDecision.CONTEXT_DECISION);
    assertNull(decision);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:22,代码来源:FirewallTest.java

示例5: FirewallRule

import org.projectfloodlight.openflow.types.IpProtocol; //导入依赖的package包/类
/**
 * The default rule is to match on anything.
 */
public FirewallRule() {
    this.dpid = DatapathId.NONE;
    this.in_port = OFPort.ANY;
    this.dl_src = MacAddress.NONE;
    this.dl_dst = MacAddress.NONE;
    this.dl_type = EthType.NONE;
    this.nw_src_prefix_and_mask = IPv4AddressWithMask.NONE;
    this.nw_dst_prefix_and_mask = IPv4AddressWithMask.NONE;
    this.nw_proto = IpProtocol.NONE;
    this.tp_src = TransportPort.NONE;
    this.tp_dst = TransportPort.NONE;
    this.any_dpid = true;
    this.any_in_port = true;
    this.any_dl_src = true;
    this.any_dl_dst = true;
    this.any_dl_type = true;
    this.any_nw_src = true;
    this.any_nw_dst = true;
    this.any_nw_proto = true;
    this.any_tp_src = true;
    this.any_tp_dst = true;
    this.priority = 0;
    this.action = FirewallAction.ALLOW;
    this.ruleid = 0;
}
 
开发者ID:zhenshengcai,项目名称:floodlight-hardware,代码行数:29,代码来源:FirewallRule.java

示例6: FlowRecord

import org.projectfloodlight.openflow.types.IpProtocol; //导入依赖的package包/类
public FlowRecord(IPv6Address srcAddr, IPv6Address dstAddr, TransportPort srcPort, TransportPort dstPort, IpProtocol prot, byte tos, int input, int pkts, int octs, long first, long last, byte tcpflags, int drops, int type, long timestamp) {
    this.srcAddr = srcAddr;
    this.dstAddr = dstAddr;
    this.srcPort = srcPort;
    this.dstPort = dstPort;
    this.prot = prot;
    this.tos = tos;
    this.input = input;
    this.pkts = pkts;
    this.octs = octs;
    this.first = first;
    this.last = last;
    this.tcpflags = tcpflags;
    this.drops = drops;
    this.type = type;
    this.timestamp = timestamp;
}
 
开发者ID:zhenshengcai,项目名称:floodlight-hardware,代码行数:18,代码来源:FlowRecord.java

示例7: FlowPersistence

import org.projectfloodlight.openflow.types.IpProtocol; //导入依赖的package包/类
public FlowPersistence(IPv6Address srcAddr, IPv6Address dstAddr, TransportPort srcPort, TransportPort dstPort, IpProtocol prot, byte tos, int input, int pkts, int octs, long first, long last, byte tcpflags, int drops, int type, long timestamp) {
    this.srcAddr = srcAddr;
    this.dstAddr = dstAddr;
    this.srcPort = srcPort;
    this.dstPort = dstPort;
    this.prot = prot;
    this.tos = tos;
    this.input = input;
    this.pkts = pkts;
    this.octs = octs;
    this.first = first;
    this.last = last;
    this.tcpflags = tcpflags;
    this.drops = drops;
    this.type = type;
    this.timestamp = timestamp;
}
 
开发者ID:zhenshengcai,项目名称:floodlight-hardware,代码行数:18,代码来源:FlowPersistence.java

示例8: main

import org.projectfloodlight.openflow.types.IpProtocol; //导入依赖的package包/类
public static void main(String []args){
    IPv6Address srcAddr = IPv6Address.of(11L, 11L);
    IPv6Address dstAddr = IPv6Address.of(12L,12L);
    TransportPort srcPort = TransportPort.of(11);
    TransportPort dstPort = TransportPort.of(12);
    //int prot = 67;
    IpProtocol prot = IpProtocol.of((byte)67);
    byte tos = 1;
    int input= 1 ;
    int pkts=1212;
    int octs=123123;
    long first=System.currentTimeMillis();
    long last= System.currentTimeMillis();
    byte tcpflags= 11;
    int drops= 1223;
    int type =2;//因为何种原因而不再活跃
    long timestamp= System.currentTimeMillis();//
    FlowPersistence f = new FlowPersistence(srcAddr,dstAddr,srcPort,dstPort,prot,tos,input,pkts
    ,octs,first,last,tcpflags,drops,type,timestamp);
    FlowStatisticsDAO fsDAO = new FlowStatisticsDAOImpl();
    fsDAO.insertFlow(f);




}
 
开发者ID:zhenshengcai,项目名称:floodlight-hardware,代码行数:27,代码来源:FlowStatisticsDAOImpl.java

示例9: getPacket

import org.projectfloodlight.openflow.types.IpProtocol; //导入依赖的package包/类
protected IPacket getPacket() {
    UDP udp = new UDP()
            .setDestinationPort(
                    TransportPort.of(PathVerificationService.VERIFICATION_PACKET_UDP_PORT))
            .setSourcePort(
                    TransportPort.of(PathVerificationService.VERIFICATION_PACKET_UDP_PORT));

    VerificationPacket verificationPacket = new VerificationPacket()
            .setChassisId(new LLDPTLV().setType((byte) 1).setLength((short) 7)
                    .setValue(new byte[] {0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}))
            .setPortId(new LLDPTLV().setType((byte) 2).setLength((short) 3)
                    .setValue(new byte[] {0x02, 0x00, 0x01}))
            .setTtl(new LLDPTLV().setType((byte) 3).setLength((short) 2)
                    .setValue(new byte[] {0x00, 0x78}));

    udp.setPayload(new Data(verificationPacket.serialize()));

    IPv4 ip = new IPv4()
            .setSourceAddress("192.168.0.1")
            .setDestinationAddress(PathVerificationService.VERIFICATION_PACKET_IP_DST)
            .setProtocol(IpProtocol.UDP);

    Ethernet eth = new Ethernet()
            .setDestinationMACAddress("AA:BB:CC:DD:EE:FF")
            .setSourceMACAddress("11:22:33:44:55:66")
            .setEtherType(EthType.IPv4);

    eth.setPayload(ip);
    ip.setPayload(udp);

    return eth;
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:33,代码来源:PathVerificationPacketInTest.java

示例10: isICMP

import org.projectfloodlight.openflow.types.IpProtocol; //导入依赖的package包/类
@Override
public boolean isICMP(FPContext cntx) {
	FloodlightContext flCntx = cntx.getFlowContext();
	
	Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	if(eth.getEtherType() == EthType.IPv4)
	{	
		IPv4 ipv4 = (IPv4) eth.getPayload();
		return (ipv4.getProtocol() == IpProtocol.ICMP);
	}
	else
	{
		return false;
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:16,代码来源:FP_LibFloodlight.java

示例11: isTCP

import org.projectfloodlight.openflow.types.IpProtocol; //导入依赖的package包/类
@Override
public boolean isTCP(FPContext cntx) {
	FloodlightContext flCntx = cntx.getFlowContext();
	
	Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	if(eth.getEtherType() == EthType.IPv4)
	{	
		IPv4 ipv4 = (IPv4) eth.getPayload();
		return (ipv4.getProtocol() == IpProtocol.TCP);
	}
	else
	{
		return false;
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:16,代码来源:FP_LibFloodlight.java

示例12: isUDP

import org.projectfloodlight.openflow.types.IpProtocol; //导入依赖的package包/类
@Override
public boolean isUDP(FPContext cntx) {
	FloodlightContext flCntx = cntx.getFlowContext();
	
	Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	if(eth.getEtherType() == EthType.IPv4)
	{	
		IPv4 ipv4 = (IPv4) eth.getPayload();
		return (ipv4.getProtocol() == IpProtocol.UDP);
	}
	else
	{
		return false;
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:16,代码来源:FP_LibFloodlight.java

示例13: IPv6

import org.projectfloodlight.openflow.types.IpProtocol; //导入依赖的package包/类
public IPv6() {
	super();
	this.version = 6;
	nextHeader = IpProtocol.NONE;
	sourceAddress = IPv6Address.NONE;
	destinationAddress = IPv6Address.NONE;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:8,代码来源:IPv6.java

示例14: IPv4

import org.projectfloodlight.openflow.types.IpProtocol; //导入依赖的package包/类
/**
 * Default constructor that sets the version to 4.
 */
public IPv4() {
    super();
    this.version = 4;
    isTruncated = false;
    isFragment = false;
    protocol = IpProtocol.NONE;
    sourceAddress = IPv4Address.NONE;
    destinationAddress = IPv4Address.NONE;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:13,代码来源:IPv4.java

示例15: switchAdded

import org.projectfloodlight.openflow.types.IpProtocol; //导入依赖的package包/类
@Override
public void switchAdded(DatapathId dpid) {
	/* Insert static flows on all ports of the switch to redirect
	 * DHCP client --> DHCP DHCPServer traffic to the controller.
	 * DHCP client's operate on UDP port 67
	 */
	IOFSwitch sw = switchService.getSwitch(dpid);
	
	//fix concurrency flaw
	if (sw == null){
		return;
	}
	
	OFFlowAdd.Builder flow = sw.getOFFactory().buildFlowAdd();
	Match.Builder match = sw.getOFFactory().buildMatch();
	ArrayList<OFAction> actionList = new ArrayList<OFAction>();
	OFActionOutput.Builder action = sw.getOFFactory().actions().buildOutput();
	for (OFPortDesc port : sw.getPorts()) {
		match.setExact(MatchField.IN_PORT, port.getPortNo());
		match.setExact(MatchField.ETH_TYPE, EthType.IPv4);
		match.setExact(MatchField.IP_PROTO, IpProtocol.UDP);
		match.setExact(MatchField.UDP_SRC, UDP.DHCP_CLIENT_PORT);
		action.setMaxLen(0xffFFffFF);
		action.setPort(OFPort.CONTROLLER);
		actionList.add(action.build());
		
		flow.setBufferId(OFBufferId.NO_BUFFER);
		flow.setHardTimeout(0);
		flow.setIdleTimeout(0);
		flow.setOutPort(OFPort.CONTROLLER);
		flow.setActions(actionList);
		flow.setMatch(match.build());
		flow.setPriority(32767);
		sfp.addFlow("dhcp-port---" + port.getPortNo().getPortNumber() + "---(" + port.getName() + ")", flow.build(), sw.getId());
	}		
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:37,代码来源:DHCPSwitchFlowSetter.java


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