3 ms·
It even does Common Lisp: Admittedly, this is ultimately from Rosetta Code, but it's somewhat modified: https://rosettacode.org/wiki/MAC_vendor_lookup#Common_
by msla 4y ago
It even does Common Lisp:
Admittedly, this is ultimately from Rosetta Code, but it's somewhat modified:
https://rosettacode.org/wiki/MAC_vendor_lookup#Common_Lisp https://rosettacode.org/wiki/MAC_vendor_lookup#Common_Lisp
But I fed it this code:
(defun mac-lookup (mac)
(check-type mac string "A MAC address as a string")
(multiple-value-bind (vendor status)
(drakma:http-request (format nil "http://api.macvendors.com/~a" mac))
(if (= 200 status)
(format t "~a~C~a~%" mac #\Tab vendor)
(if (= 429 status)
(format *error-output* "error: Too many requests at ~a~%" mac)
(format *error-output* "error: ~a~%" mac)))))
And it got this out of it:
https://whatdoesthiscodedo.com/g/5ae8501 https://whatdoesthiscodedo.com/g/5ae8501
This code defines a function named "mac-lookup" that takes a MAC address as a string argument. It then checks the type of the argument to ensure it is a string.
The function then sends an HTTP request to the API at http://api.macvendors.com http://api.macvendors.com with the provided MAC address appended to the URL. The response is stored in two variables, vendor and status, using the multiple-value-bind function.
If the status code of the response is 200, the function outputs the MAC address, a tab character, and the vendor name to the console.
If the status code is 429, which indicates too many requests have been made, the function outputs an error message to the error-output stream indicating that there were too many requests made for the provided MAC address.
Otherwise, if any other status code is received, the function outputs a generic error message to the error-output stream indicating that there was an error for the provided MAC address.