patch-bpf_c 830 B

12345678910111213141516171819202122232425262728293031323334353637
  1. $OpenBSD: patch-bpf_c,v 1.1 2001/04/20 07:53:02 reinhard Exp $
  2. --- bpf.c.orig Mon Aug 18 23:38:20 1997
  3. +++ bpf.c Tue Apr 17 16:00:13 2001
  4. @@ -47,21 +47,26 @@ int bpf_open(char *device) {
  5. do {
  6. snprintf(file, PATH_MAX, "/dev/bpf%d", i++);
  7. - if((fd = open(file, O_RDWR)) < 0)
  8. - continue;
  9. - } while(errno == EBUSY && fd < 0);
  10. + fd = open(file, O_RDWR);
  11. + } while(fd < 0 && errno == EBUSY);
  12. - if(fd < 0)
  13. + if(fd < 0) {
  14. + perror("bpf open");
  15. return(-1);
  16. + }
  17. memset(&ifr, 0, sizeof(ifr));
  18. strncpy(ifr.ifr_name, device, 15);
  19. - if(bpf_setbuf(fd, DEFAULT_BUFLEN) < 0)
  20. + if(bpf_setbuf(fd, DEFAULT_BUFLEN) < 0) {
  21. + perror("bpf setbuf");
  22. return(-2);
  23. + }
  24. - if(ioctl(fd, BIOCSETIF, (char *) &ifr) < 0)
  25. + if(ioctl(fd, BIOCSETIF, (char *) &ifr) < 0) {
  26. + perror("bpf ioctl");
  27. return(-3);
  28. + }
  29. return(fd);
  30. }