Ethereal-dev: Re: [Ethereal-dev] [PATCH] Wish list item 17 (packet generator)

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Lanfranco Salinari <lanfranco.salinari@xxxxxxxxxxxxx>
Date: Wed, 03 Sep 2003 21:58:30 +0200
Greg Morris wrote:
I tried to check this out but it will not build on Windows. It requires specific Linux libs... Maybe someone else might have the time to investigate. Greg

>>> Lanfranco Salinari <lanfranco.salinari@xxxxxxxxxxxxx> 9/2/2003 1:54:03 PM >>>
Hello,
I post this patch again, hoping that someone notices it.
I think that a packet generator would be a useful feature for ethereal,
so I hope someone will give me his opinion about the patch and the
work that remains to be done, as I have no experience with GTK.
Best regards,

Lanfranco

Thank you very much for your interest, Greg.
I understand that this code can run only on Linux, but I think that
the dependency is due only to the network functions.
Maybe you can try to replace the print_buffer() function with this one:

static void
print_buffer(GtkWidget *widget _U_, gpointer data)
{
    struct PacketGenData *PGdata = (struct PacketGenData *)data;
    GtkHex *byte_view = GTK_HEX(PGdata->hex);
    GtkCombo *if_combo = GTK_COMBO(PGdata->interf);
    GtkEntry *if_entry = GTK_ENTRY(if_combo->entry);
    gchar *if_name;
    unsigned int i;

#if 1
    for (i=0; i<byte_view->data_size; i++) {
	printf ("%02x ", (byte_view->data)[i]);
	if (i%16 == 15)
	    printf ("\n");
    }
    printf ("\n");
#endif
    if_name = gtk_entry_get_text(if_entry);

#ifdef 1
    printf ("Interface = %s\n", if_name);
#endif

    if (strcmp(if_name,"")) {

#if 0
	send_packet (byte_view->data, byte_view->data_size, if_name);
#endif
    }
    else {
	simple_dialog(ESD_TYPE_WARN, NULL, "No interface selected");
    }
    return;
}

In this way you will not send the packet on the network, but you will
print it on the console. I think that in this way you can make an idea of how the packet generator works. Writing packets directly at link layer in a portable way is one of the big problems of this code, perhaps it could be done using pcap libs,
and using the file descriptor returned by it for writing, (as suggested
by R.W.Stevens), but I hope someone more expert than me can give an opinion on how to do this.
Best regards,

Lanfranco