Esempio n. 1
0
void got_packet(u_char * useless, const struct pcap_pkthdr *pheader,
                const u_char * packet)
{
    config.p_s.got_packets++;
    packetinfo pstruct = {0};
    packetinfo *pi = &pstruct;
    pi->packet = packet;
    pi->pheader = pheader;
    set_pkt_end_ptr (pi);
    config.tstamp = pi->pheader->ts; // Global
    if (config.intr_flag != 0) {
        check_interrupt();
    }
    config.inpacket = 1;
    prepare_eth(pi);
    check_vlan(pi);
    //parse_eth(pi);

    if (pi->eth_type == ETHERNET_TYPE_IP) {
        prepare_ip4(pi);
        parse_ip4(pi);
    } else if (pi->eth_type == ETHERNET_TYPE_IPV6) {
        prepare_ip6(pi);
        parse_ip6(pi);
    } else {
        config.p_s.otherl_recv++;
        //vlog(0x3, "[*] ETHERNET TYPE : %x\n",pi->eth_hdr->eth_ip_type);
    }
    config.inpacket = 0;
    return;
}
Esempio n. 2
0
void prepare_ip4ip(packetinfo *pi)
{
    packetinfo pipi;
    memset(&pipi, 0, sizeof(packetinfo));
    config.p_s.ip4ip_recv++;
    pipi.pheader = pi->pheader;
    pipi.packet = (pi->packet + pi->eth_hlen + (IP_HL(pi->ip4) * 4));
    pipi.end_ptr = pi->end_ptr;
    if (pi->ip4->ip_p == IP_PROTO_IP4) {
        prepare_ip4(&pipi);
        parse_ip4(&pipi);
    }
    else {
        prepare_ip6(&pipi);
        parse_ip6(&pipi);
    }
}
Esempio n. 3
0
void prepare_ip6ip(packetinfo *pi)
{
    packetinfo pipi;
    memset(&pipi, 0, sizeof(packetinfo));
    config.p_s.ip6ip_recv++;
    pipi.pheader = pi->pheader;
    pipi.packet = (pi->packet + pi->eth_hlen + IP6_HEADER_LEN);
    pipi.end_ptr = pi->end_ptr;
    if (pi->ip6->next == IP_PROTO_IP4) {
        prepare_ip4(&pipi);
        parse_ip4(&pipi);
    }
    else {
        prepare_ip6(&pipi);
        parse_ip6(&pipi);
    }
}
Esempio n. 4
0
void got_packet(u_char *useless, const struct pcap_pkthdr *pheader,
                const u_char *packet)
{
    config.p_s.got_packets++;
    packetinfo pstruct = {0};
    packetinfo *pi = &pstruct;
    pi->packet = packet;
    pi->pheader = pheader;
    set_pkt_end_ptr (pi);
    config.tstamp = pi->pheader->ts; /* Global */
    if (config.intr_flag != 0) {
        check_interrupt();
    }
    config.inpacket = 1;

    switch (config.linktype) {
        case DLT_RAW:
            prepare_raw(pi);
            break;
        case DLT_LINUX_SLL:
            prepare_sll(pi);
            break;
        default:
            prepare_eth(pi);
            check_vlan(pi);
            break;
    }

    switch (pi->eth_type) {
        case ETHERNET_TYPE_IP:
            prepare_ip4(pi);
            parse_ip4(pi);
            break;
        case ETHERNET_TYPE_IPV6:
            prepare_ip6(pi);
            parse_ip6(pi);
            break;
        default:
            config.p_s.otherl_recv++;
            //vlog(0x3, "[*] ETHERNET TYPE : %x\n",pi->eth_hdr->eth_ip_type);
            break;
    }

    config.inpacket = 0;
}