summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bpf-interface.scm21
1 files changed, 3 insertions, 18 deletions
diff --git a/bpf-interface.scm b/bpf-interface.scm
index 68c9984..0277140 100644
--- a/bpf-interface.scm
+++ b/bpf-interface.scm
@@ -9,7 +9,7 @@
(bpf-open bpf-close bpf? bpf-buffer-length bpf-flush!
bpf-interface bpf-interface-set! bpf-stats
bpf-datalink-type bpf-datalink-type-set! bpf-list-datalink-types
- bpf-read-timeout bpf-read-timeout-set! bpf-filter-set!)
+ bpf-filter-set!)
(import chicken scheme foreign)
@@ -85,7 +85,8 @@
(make-property-condition 'bpf)
(make-property-condition 'i/o)
(make-property-condition 'file))))
- (let* ((fd (condition-case (file-open fn (fx+ open/read open/write))
+ (let* ((mode (bitwise-ior open/read open/write open/nonblock))
+ (fd (condition-case (file-open fn mode)
(e (exn i/o file) (lp (fx+ i 1) fn e))))
(bpf (make-bpf fd)))
(set-finalizer! bpf bpf-close)
@@ -178,22 +179,6 @@
((foreign-lambda* unsigned-int (((c-pointer "u_int") p) (int i))
"C_return(p[i]);") (location types) i))))))
-(define (bpf-read-timeout bpf)
- (let ((tv (make-blob (foreign-value "sizeof(struct timeval)" int))))
- (ioctl bpf BIOCGRTIMEOUT tv)
- ((foreign-lambda* double (((c-pointer "struct timeval") tv))
- "C_return(tv->tv_sec + tv->tv_usec / 1000000.0);") (location tv))))
-
-(define (bpf-read-timeout-set! bpf timeout)
- (let ((tv (make-blob (foreign-value "sizeof(struct timeval)" int)))
- (timeout (max 0 timeout)))
- ((foreign-lambda* void (((c-pointer "struct timeval") tv) (double timeout))
- "double i;"
- "tv->tv_usec = (int)(modf(timeout, &i) * 1000000);"
- "tv->tv_sec = (int)timeout;") (location tv) timeout)
- (ioctl bpf BIOCSRTIMEOUT tv)
- (void)))
-
(define (bpf-stats bpf)
(let ((st (make-blob (foreign-value "sizeof(struct bpf_stat)" int))))
(ioctl bpf BIOCGSTATS st)