Examples of Ipv4


Examples of mireka.address.parser.Ipv4Parser.Ipv4

    }

    @Test
    public void testSpelling() throws Exception {
        String address = "192.0.2.0";
        Ipv4 ipv4AST = new Ipv4Parser(new CharScanner(address)).parse();
        assertEquals(address, ipv4AST.spelling);
    }
View Full Code Here

Examples of mireka.address.parser.Ipv4Parser.Ipv4

        assertEquals(address, ipv4AST.spelling);
    }

    private void parse(String address) throws ParseException,
            UnknownHostException {
        Ipv4 ipv4AST = new Ipv4Parser(new CharScanner(address)).parse();
        assertEquals(InetAddress.getByName(address), ipv4AST.address);
    }
View Full Code Here

Examples of mireka.address.parser.Ipv4Parser.Ipv4

        addressLiteralTagScanner.finish();
        currentToken = scanner.scan();
        spelling.append(tagToken.spelling);
        switch (tagToken.kind) {
        case DIGIT:
            Ipv4 ipv4AST = parseIpv4AddressLiteral();
            accept(']');
            return new Ipv4RemotePartAST(popPosition(), popSpelling(), ipv4AST);
        case IPv6:
            accept(':');
            Ipv6 ipv6AST = parseIpv6AddressLiteral();
View Full Code Here

Examples of mireka.address.parser.Ipv4Parser.Ipv4

        }
    }

    private Ipv4 parseIpv4AddressLiteral() throws ParseException {
        scanner.pushBack(currentToken);
        Ipv4 ipv4 = new Ipv4Parser(scanner).parseLeft();
        currentToken = scanner.scan();
        spelling.append(ipv4.spelling);
        return ipv4;
    }
View Full Code Here

Examples of net.floodlightcontroller.packet.IPv4

                }
            }
        } else {
            // currently only load balance IPv4 packets - no-op for other traffic
            if (pkt instanceof IPv4) {
                IPv4 ip_pkt = (IPv4) pkt;
               
                // If match Vip and port, check pool and choose member
                int destIpAddress = ip_pkt.getDestinationAddress();
               
                if (vipIpToId.containsKey(destIpAddress)){
                    IPClient client = new IPClient();
                    client.ipAddress = ip_pkt.getSourceAddress();
                    client.nw_proto = ip_pkt.getProtocol();
                    if (ip_pkt.getPayload() instanceof TCP) {
                        TCP tcp_pkt = (TCP) ip_pkt.getPayload();
                        client.srcPort = tcp_pkt.getSourcePort();
                        client.targetPort = tcp_pkt.getDestinationPort();
                    }
                    if (ip_pkt.getPayload() instanceof UDP) {
                        UDP udp_pkt = (UDP) ip_pkt.getPayload();
                        client.srcPort = udp_pkt.getSourcePort();
                        client.targetPort = udp_pkt.getDestinationPort();
                    }
                    if (ip_pkt.getPayload() instanceof ICMP) {
                        client.srcPort = 8;
                        client.targetPort = 0;
                    }
                   
                    LBVip vip = vips.get(vipIpToId.get(destIpAddress));
View Full Code Here

Examples of net.floodlightcontroller.packet.IPv4

    public boolean matchesFlow(long switchDpid, short inPort, Ethernet packet,
            WildcardsPair wildcards) {
        IPacket pkt = packet.getPayload();

        // dl_type type
        IPv4 pkt_ip = null;

        // nw_proto types
        TCP pkt_tcp = null;
        UDP pkt_udp = null;

        // tp_src and tp_dst (tp port numbers)
        short pkt_tp_src = 0;
        short pkt_tp_dst = 0;

        // switchID matches?
        if (wildcard_dpid == false && dpid != switchDpid)
            return false;

        // in_port matches?
        if (wildcard_in_port == false && in_port != inPort)
            return false;
        if (action == FirewallRule.FirewallAction.DENY) {
            wildcards.drop &= ~OFMatch.OFPFW_IN_PORT;
        } else {
            wildcards.allow &= ~OFMatch.OFPFW_IN_PORT;
        }

        // mac address (src and dst) match?
        if (wildcard_dl_src == false
                && dl_src != packet.getSourceMAC().toLong())
            return false;
        if (action == FirewallRule.FirewallAction.DENY) {
            wildcards.drop &= ~OFMatch.OFPFW_DL_SRC;
        } else {
            wildcards.allow &= ~OFMatch.OFPFW_DL_SRC;
        }

        if (wildcard_dl_dst == false
                && dl_dst != packet.getDestinationMAC().toLong())
            return false;
        if (action == FirewallRule.FirewallAction.DENY) {
            wildcards.drop &= ~OFMatch.OFPFW_DL_DST;
        } else {
            wildcards.allow &= ~OFMatch.OFPFW_DL_DST;
        }

        // dl_type check: ARP, IP

        // if this is not an ARP rule but the pkt is ARP,
        // return false match - no need to continue protocol specific check
        if (wildcard_dl_type == false) {
            if (dl_type == Ethernet.TYPE_ARP) {
                if (packet.getEtherType() != Ethernet.TYPE_ARP)
                    return false;
                else {
                    if (action == FirewallRule.FirewallAction.DENY) {
                        wildcards.drop &= ~OFMatch.OFPFW_DL_TYPE;
                    } else {
                        wildcards.allow &= ~OFMatch.OFPFW_DL_TYPE;
                    }
                }
            } else if (dl_type == Ethernet.TYPE_IPv4) {
                if (packet.getEtherType() != Ethernet.TYPE_IPv4)
                    return false;
                else {
                    if (action == FirewallRule.FirewallAction.DENY) {
                        wildcards.drop &= ~OFMatch.OFPFW_NW_PROTO;
                    } else {
                        wildcards.allow &= ~OFMatch.OFPFW_NW_PROTO;
                    }
                    // IP packets, proceed with ip address check
                    pkt_ip = (IPv4) pkt;

                    // IP addresses (src and dst) match?
                    if (wildcard_nw_src == false
                            && this.matchIPAddress(nw_src_prefix,
                                    nw_src_maskbits, pkt_ip.getSourceAddress()) == false)
                        return false;
                    if (action == FirewallRule.FirewallAction.DENY) {
                        wildcards.drop &= ~OFMatch.OFPFW_NW_SRC_ALL;
                        wildcards.drop |= (nw_src_maskbits << OFMatch.OFPFW_NW_SRC_SHIFT);
                    } else {
                        wildcards.allow &= ~OFMatch.OFPFW_NW_SRC_ALL;
                        wildcards.allow |= (nw_src_maskbits << OFMatch.OFPFW_NW_SRC_SHIFT);
                    }

                    if (wildcard_nw_dst == false
                            && this.matchIPAddress(nw_dst_prefix,
                                    nw_dst_maskbits,
                                    pkt_ip.getDestinationAddress()) == false)
                        return false;
                    if (action == FirewallRule.FirewallAction.DENY) {
                        wildcards.drop &= ~OFMatch.OFPFW_NW_DST_ALL;
                        wildcards.drop |= (nw_dst_maskbits << OFMatch.OFPFW_NW_DST_SHIFT);
                    } else {
                        wildcards.allow &= ~OFMatch.OFPFW_NW_DST_ALL;
                        wildcards.allow |= (nw_dst_maskbits << OFMatch.OFPFW_NW_DST_SHIFT);
                    }

                    // nw_proto check
                    if (wildcard_nw_proto == false) {
                        if (nw_proto == IPv4.PROTOCOL_TCP) {
                            if (pkt_ip.getProtocol() != IPv4.PROTOCOL_TCP)
                                return false;
                            else {
                                pkt_tcp = (TCP) pkt_ip.getPayload();
                                pkt_tp_src = pkt_tcp.getSourcePort();
                                pkt_tp_dst = pkt_tcp.getDestinationPort();
                            }
                        } else if (nw_proto == IPv4.PROTOCOL_UDP) {
                            if (pkt_ip.getProtocol() != IPv4.PROTOCOL_UDP)
                                return false;
                            else {
                                pkt_udp = (UDP) pkt_ip.getPayload();
                                pkt_tp_src = pkt_udp.getSourcePort();
                                pkt_tp_dst = pkt_udp.getDestinationPort();
                            }
                        } else if (nw_proto == IPv4.PROTOCOL_ICMP) {
                            if (pkt_ip.getProtocol() != IPv4.PROTOCOL_ICMP)
                                return false;
                            else {
                                // nothing more needed for ICMP
                            }
                        }
View Full Code Here

Examples of net.floodlightcontroller.packet.IPv4

        byte l4type = 0;

        if (eth != null) {
            l3type = eth.getEtherType();
            if (eth.getPayload() instanceof IPv4) {
                IPv4 ipV4 = (IPv4)eth.getPayload();
                l4type = ipV4.getProtocol();
            }
        }
        return new CounterKeyTuple(mtype, sw.getId(), l3type, l4type);
    }
View Full Code Here

Examples of net.floodlightcontroller.packet.IPv4

        // L4 counters
        if (eth.getPayload() instanceof IPv4) {

            // resolve protocol alias
            IPv4 ipV4 = (IPv4)eth.getPayload();
            String l4name = String.format("%02x", ipV4.getProtocol());
            if (TypeAliases.l4TypeAliasMap != null &&
                TypeAliases.l4TypeAliasMap.containsKey(l4name)) {
                l4name = TypeAliases.l4TypeAliasMap.get(l4name);
            }
            else {
View Full Code Here

Examples of net.floodlightcontroller.packet.IPv4

     * @param srcDevice
     */
    private void snoopDHCPClientName(Ethernet eth, Device srcDevice) {
        if (! (eth.getPayload() instanceof IPv4) )
            return;
        IPv4 ipv4 = (IPv4) eth.getPayload();
        if (! (ipv4.getPayload() instanceof UDP) )
            return;
        UDP udp = (UDP) ipv4.getPayload();
        if (!(udp.getPayload() instanceof DHCP))
            return;
        DHCP dhcp = (DHCP) udp.getPayload();
        byte opcode = dhcp.getOpCode();
        if (opcode == DHCP.OPCODE_REQUEST) {
View Full Code Here

Examples of net.floodlightcontroller.packet.IPv4

        // Ignore zero dest mac
        if (dlAddr == 0)
            return null;

        if (eth.getPayload() instanceof IPv4) {
            IPv4 ipv4 = (IPv4) eth.getPayload();
            nwDst = ipv4.getDestinationAddress();
        }

        return new Entity(dlAddr,
                          ((vlan >= 0) ? vlan : null),
                          ((nwDst != 0) ? nwDst : null),
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.