pcap_t *pc; /* pcap device */
int datalinkOffset; /* offset of ip packet from datalink packet */
-int captureDebug = 0;
+int captureDebug = 1;
unsigned int thisTimeZone;
void CaptureInit(u_int32_t sourceIP, u_int16_t sourcePort,
if (dev != NULL) {
device = dev;
} else {
- device = pcap_lookupdev(errbuf);
+ pcap_if_t *devlist;
+ /*
+ * Find the list of interfaces, and pick
+ * the first interface.
+ */
+ if (pcap_findalldevs(&devlist, errbuf) >= 0 &&
+ devlist != NULL) {
+ device = strdup(devlist->name);
+ pcap_freealldevs(devlist);
+ }
+
if (device == NULL) {
fprintf(stderr, "Can't find capture device: %s\n", errbuf);
exit(-1);
exit(-1);
}
- strncpy(source, InetAddress(sourceIP), sizeof(source) - 1);
- strncpy(target, InetAddress(targetIP), sizeof(target) - 1);
+ strlcpy(source, InetAddress(sourceIP), sizeof(source));
+ strlcpy(target, InetAddress(targetIP), sizeof(target));
/* Setup initial filter */
sprintf(filtercmds,
- "host %s and host %s and port %d\n",
- source, target, targetPort);
+ "(host %s && host %s && port %d) || icmp\n",
+ source, target, targetPort);
if (captureDebug) {
printf("datalinkOffset = %d\n", datalinkOffset);