/****************************************************************************** Martian's DNS Extensions Copyright 1996, 1998, 2000 Midgard Systems and Adam "Martian" Smyth Permission is granted to freely distribute and use this file for any non-commercial application. Commercial and Government users may also use it freely, but must inform the author prior to use. Permission is granted to change this file to suit a particular application, so long as a copy of the changes is provided to the original author. If you use this, lemme know. If you think it sucks, lemme know. If you want something changed, lemme know. If something doesn't work, lemme know. The latest version of this file is available at http://www.martian.at/Code/MOO/extensions/ext-dns.c Martian martian@midgard.org *****************************************************************************/ #include "bf_register.h" #include "functions.h" #include "my-unistd.h" #include "my-in.h" #include "name_lookup.h" #include "server.h" #include "log.h" #include "my-string.h" #include "my-stdlib.h" #include "structures.h" #include "log.h" #include #include #include const char *domainname_version = "1.0a"; static package bf_nametoaddr(Var arglist, Byte next, void *vdata, Objid progr) { struct in_addr a; char *s; Var r; a.s_addr = lookup_addr_from_name(arglist.v.list[1].v.str, server_int_option("name_lookup_timeout", 5)); s = inet_ntoa(a); r.type = TYPE_STR; r.v.str = strdup(s); free_var(arglist); return make_var_pack(r); } static package bf_addrtoname(Var arglist, Byte next, void *vdata, Objid progr) { struct sockaddr_in a; char *s; Var r; a.sin_addr.s_addr = inet_addr(arglist.v.list[1].v.str); free_var(arglist); if(a.sin_addr.s_addr == -1) return make_error_pack(E_INVARG); s = lookup_name_from_addr(&a, server_int_option("name_lookup_timeout", 5)); if(!s) return make_error_pack(E_INVARG); r.type = TYPE_STR; r.v.str = strdup(s); return make_var_pack(r); } void register_DNS() { oklog("Installing Martian's DNS Extentions v%s\n", domainname_version); register_function("nametoaddr", 1, 1, bf_nametoaddr, TYPE_STR); register_function("addrtoname", 1, 1, bf_addrtoname, TYPE_STR); } /* Version 1.0a 1998/03/29 * First experimental version. Just to see how things work. */