void update_grid_from_edit(int edit_iItem, int edit_iSubItem)
{
    TCHAR buf[64];
    t_stream* pt_stream=g_apt_streams[edit_iItem];
    t_ether_packet *pt_eth_hdr = (void *)pt_stream->data;
    t_ip_hdr *iph=eth_data(pt_eth_hdr);
    t_ipv6_hdr *ip6h=(void *)iph;
    int type = eth_type(pt_eth_hdr);

    GetWindowText(hwnd_dynamic_edit, buf, sizeof(buf));
    ShowWindow (hwnd_dynamic_edit, 0);
    ListView_SetItemText(hwnd_lv, edit_iItem, edit_iSubItem, buf);
    if (edit_iSubItem==3)
    {
        strcpy(pt_stream->name, buf);
        return;
    }

    if (edit_iSubItem==7)
    {
        pt_stream->len = atoi(buf);
        goto exit;
    }

    if (type!=ETH_P_IP && type!=ETH_P_IPV6)
    {
        if (edit_iSubItem==4)
        {
            mac_str2n(pt_stream->eth_packet.src, buf);
        }
        else if (edit_iSubItem==5)
        {
            mac_str2n(pt_stream->eth_packet.dst, buf);
        }
        return;
    }

    if (edit_iSubItem==4)
    {
        if (type==ETH_P_IP)
            ip_str2n(&(iph->saddr), buf);
        else
            ip6_str2n(ip6h->saddr, buf);
    }
    else if (edit_iSubItem==5)
    {
        if (type==ETH_P_IP)
            ip_str2n(&(iph->daddr), buf);
        else
            ip6_str2n(ip6h->daddr, buf);

    }

exit:
    update_stream(pt_stream);
}
Exemple #2
0
Tins::SNAP::SNAP(const uint8_t *buffer, uint32_t total_sz) 
{
    if(total_sz < sizeof(_snap))
        throw malformed_packet();
    std::memcpy(&_snap, buffer, sizeof(_snap));
    buffer += sizeof(_snap);
    total_sz -= sizeof(_snap);
    if(total_sz) {
        inner_pdu(
            Internals::pdu_from_flag(
                (Constants::Ethernet::e)eth_type(), 
                buffer, 
                total_sz
            )
        );
    }
}