I know someone will give me a hard time for this, but here goes. I am trying to convert some C code to Java and am still learning java as I go. I am having a very difficult time figuring out how to do this conversion and learning java for that matter. Any help or pointers on where to go would be greatly appreciated.
for(d=alldevs; d; d=d->next)
{
printf("%d. %s", ++i, d->name);
if (d->description)
printf(" (%s)\n", d->description);
else
printf(" (No description available)\n");
}
if(i==0)
{
printf("\nNo interfaces found! Make sure WinPcap is installed.\n");
return -1;
}
printf("Enter the interface number (1-%d):",i);
scanf("%d", &inum);
if(inum < 1 || inum > i)
{
printf("\nInterface number out of range.\n");
/* Free the device list */
pcap_freealldevs(alldevs);
return -1;
}
/* Jump to the selected adapter */
for(d=alldevs, i=0; i< inum-1 ;d=d->next, i++);
A conversion offering:
And now the code
Note that you will have to do the “real” conversion of the rest of the program; that is writing a PCap solution in Java, or writing a JNI (Java) interface to call the PCap library routines.