Skip to content

Commit

Permalink
Improved error messages when interface is a file or directory - appne…
Browse files Browse the repository at this point in the history
  • Loading branch information
fklassen committed Mar 22, 2014
1 parent e590431 commit 3523dfb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ $Id$

xx/xx/xxxx Version 4.0.4
- Number of packets inaccurate when using --netmap method (#76)
- Improved error messages when interface is a file (#74)
- Missing interfaces with --listnics option (#67)
- Compile issue with netmap v10 and debugging (#66)
- Bad values with --stats and -t options (#65)
Expand Down
33 changes: 29 additions & 4 deletions src/common/sendpacket.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ sendpacket(sendpacket_t *sp, const u_char *data, size_t len, struct pcap_pkthdr
break;

default:
errx(1, "Unsupported sp->handle_type = %d", sp->handle_type);
errx(-1, "Unsupported sp->handle_type = %d", sp->handle_type);
} /* end case */

if (retcode < 0) {
Expand Down Expand Up @@ -568,8 +568,33 @@ sendpacket_open(const char *device, char *errbuf, tcpr_dir_t direction,
sp = sendpacket_open_khial(device, errbuf);

} else {
errx(1, "%s is not a valid Tcpreplay character device",
device);
switch (sdata.st_mode & S_IFMT) {
case S_IFBLK:
errx(-1, "\"%s\" is a block device and is not a valid Tcpreplay device",
device);
break;
break;
case S_IFDIR:
errx(-1, "\"%s\" is a directory and is not a valid Tcpreplay device",
device);
break;
case S_IFIFO:
errx(-1, "\"%s\" is a FIFO and is not a valid Tcpreplay device",
device);
break;
case S_IFLNK:
errx(-1, "\"%s\" is a symbolic link and is not a valid Tcpreplay device",
device);
break;
case S_IFREG:
errx(-1, "\"%s\" is a file and is not a valid Tcpreplay device",
device);
break;
default:
errx(-1, "\"%s\" is not a valid Tcpreplay device",
device);
break;
}
}
} else {
#ifdef HAVE_NETMAP
Expand All @@ -594,7 +619,7 @@ sendpacket_open(const char *device, char *errbuf, tcpr_dir_t direction,
sp->open = 1;
sp->cache_dir = direction;
} else {
errx(1, "failed to open device %s", device);
errx(-1, "failed to open device %s", device);
}
return sp;
}
Expand Down

0 comments on commit 3523dfb

Please sign in to comment.