1 ;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp -*-
3 ;; Copyright (C) 2006, 2007 Stelian Ionescu
5 ;; This code is free software; you can redistribute it and/or
6 ;; modify it under the terms of the version 2.1 of
7 ;; the GNU Lesser General Public License as published by
8 ;; the Free Software Foundation, as clarified by the
9 ;; preamble found here:
10 ;; http://opensource.franz.com/preamble.html
12 ;; This program is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU Lesser General
18 ;; Public License along with this library; if not, write to the
19 ;; Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20 ;; Boston, MA 02110-1301, USA
22 (in-package :net.sockets
)
24 (defvar *hosts-file
* "/etc/hosts")
26 (defgeneric dns-lookup-host
(host &key ipv6
))
28 (defmethod dns-lookup-host ((host string
) &key
(ipv6 *ipv6
*))
29 (or (search-etc-hosts-name *hosts-file
* host ipv6
)
30 (dns-query host
:type
:a
)))
32 (defun dns-lookup-host-ip (vector ipv6
)
33 (or (search-etc-hosts-ip *hosts-file
* vector ipv6
)
34 (dns-query vector
:type
:ptr
)))
36 (defmethod dns-lookup-host ((host ipv4addr
) &key
(ipv6 *ipv6
*))
37 (dns-lookup-host-ip (name host
) ipv6
))
39 (defmethod dns-lookup-host ((host ipv6addr
) &key
(ipv6 *ipv6
*))
40 (dns-lookup-host-ip (name host
) ipv6
))
42 (defmethod dns-lookup-host (host &key
(ipv6 *ipv6
*))
44 (simple-array (dns-lookup-host-ip host ipv6
))))