sock->pcap = pcap_open_live(interface, BUFSIZ, 1, 1, buf);
if (!sock->pcap) {
- fprintf(stderr, "%s\n", buf);
+ fprintf(stderr, "%s.\n", buf);
goto cleanup_malloc;
}
sock->timeout.tv_usec = (msec % 1000) * 1000;
return 0;
}
+
+int ethsock_list_all(void)
+{
+ pcap_if_t *devs, *dev;
+ uint8_t hwaddr[8];
+ char errbuf[PCAP_ERRBUF_SIZE];
+
+ if (pcap_findalldevs(&devs, errbuf) != 0) {
+ fprintf(stderr, "%s.\n", errbuf);
+ return -1;
+ }
+
+ for (dev = devs; dev; dev = dev->next) {
+ get_hwaddr(hwaddr, dev->name);
+ printf("%02x:%02x:%02x:%02x:%02x:%02x %s",
+ hwaddr[0], hwaddr[1], hwaddr[2],
+ hwaddr[3], hwaddr[4], hwaddr[5],
+ dev->name);
+
+ if (dev->description) {
+ printf(" (%s)\n", dev->description);
+ } else {
+ printf("\n");
+ }
+ }
+
+ return 0;
+}
ssize_t ethsock_recv(struct ethsock *sock, void *buf, size_t len);
int ethsock_set_timeout(struct ethsock *sock, unsigned msec);
uint8_t *ethsock_get_hwaddr(struct ethsock *sock);
+int ethsock_list_all(void);
" -T <timeout> Time to wait after successfull TFTP upload\n"
" -p <port> Port to use for TFTP upload\n"
" -V Print version and exit\n"
+ " -L List network interfaces\n"
" -h Show this screen\n"
"\n"
"Example:\n"
opterr = 0;
- while ((c = getopt(argc, argv, "a:f:i:m:M:p:t:T:hV")) != -1) {
+ while ((c = getopt(argc, argv, "a:f:i:m:M:p:t:T:hLV")) != -1) {
max = 0x7fffffff;
switch (c) {
case 'a':
case 'V':
printf("nmrp-flash v%s\n", NMRPD_VERSION);
return 0;
+ case 'L':
+ return ethsock_list_all();
case 'h':
usage(stdout);
return 0;