From 58ed3abb983a400bb71c4ca48d95d39397af5acf Mon Sep 17 00:00:00 2001 From: Stelian Ionescu Date: Mon, 16 Apr 2012 13:57:40 +0200 Subject: [PATCH] Fix LIST-NETWORK-INTERFACES --- src/sockets/iface.lisp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/sockets/iface.lisp b/src/sockets/iface.lisp index d8771f8..c3be37c 100644 --- a/src/sockets/iface.lisp +++ b/src/sockets/iface.lisp @@ -24,18 +24,14 @@ (defun list-network-interfaces () "Returns a list of network interfaces currently available." (let ((ifptr (null-pointer))) - (macrolet ((%if-slot-value (slot index) - `(foreign-slot-value - (mem-aref ifptr 'if-nameindex ,index) - 'if-nameindex ,slot))) - (unwind-protect - (progn - (setf ifptr (%if-nameindex)) - (loop :for i :from 0 - :for name := (%if-slot-value 'name i) - :for index := (%if-slot-value 'index i) + (unwind-protect + (progn + (setf ifptr (%if-nameindex)) + (loop :for p := ifptr :then (inc-pointer p (isys:sizeof '(:struct if-nameindex))) + :for name := (foreign-slot-value p '(:struct if-nameindex) 'name) + :for index := (foreign-slot-value p '(:struct if-nameindex) 'index) :while (plusp index) :collect (make-interface name index))) - (unless (null-pointer-p ifptr) (%if-freenameindex ifptr)))))) + (unless (null-pointer-p ifptr) (%if-freenameindex ifptr))))) (defun get-interface-by-index (index) (with-foreign-object (buffer :uint8 ifnamesize) -- 2.11.4.GIT