summaryrefslogtreecommitdiff
path: root/contrib/idn/mdnkit/mdnsproxy
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/idn/mdnkit/mdnsproxy')
-rw-r--r--contrib/idn/mdnkit/mdnsproxy/Makefile.in154
-rw-r--r--contrib/idn/mdnkit/mdnsproxy/acl.c388
-rw-r--r--contrib/idn/mdnkit/mdnsproxy/logging.c584
-rw-r--r--contrib/idn/mdnkit/mdnsproxy/make.wnt128
-rw-r--r--contrib/idn/mdnkit/mdnsproxy/mdnsproxy.8.in314
-rw-r--r--contrib/idn/mdnkit/mdnsproxy/mdnsproxy.conf.sample149
-rw-r--r--contrib/idn/mdnkit/mdnsproxy/mdnsproxy.def3
-rw-r--r--contrib/idn/mdnkit/mdnsproxy/mdnsproxy.h211
-rw-r--r--contrib/idn/mdnkit/mdnsproxy/message.c627
-rw-r--r--contrib/idn/mdnkit/mdnsproxy/os2main.c166
-rw-r--r--contrib/idn/mdnkit/mdnsproxy/proxycnf.c944
-rw-r--r--contrib/idn/mdnkit/mdnsproxy/proxycnf.h151
-rw-r--r--contrib/idn/mdnkit/mdnsproxy/server.c1457
-rw-r--r--contrib/idn/mdnkit/mdnsproxy/translate.c291
-rw-r--r--contrib/idn/mdnkit/mdnsproxy/unxmain.c325
-rw-r--r--contrib/idn/mdnkit/mdnsproxy/winmain.c178
-rw-r--r--contrib/idn/mdnkit/mdnsproxy/winserv.c451
-rw-r--r--contrib/idn/mdnkit/mdnsproxy/winserv.h72
18 files changed, 0 insertions, 6593 deletions
diff --git a/contrib/idn/mdnkit/mdnsproxy/Makefile.in b/contrib/idn/mdnkit/mdnsproxy/Makefile.in
deleted file mode 100644
index d01d58b9..00000000
--- a/contrib/idn/mdnkit/mdnsproxy/Makefile.in
+++ /dev/null
@@ -1,154 +0,0 @@
-# $Id: Makefile.in,v 1.1.2.1 2002/02/08 12:14:47 marka Exp $
-# Makefile for mDNS Proxy Server
-#
-# Copyright (c) 2000 Japan Network Information Center. All rights reserved.
-#
-# By using this file, you agree to the terms and conditions set forth bellow.
-#
-# LICENSE TERMS AND CONDITIONS
-#
-# The following License Terms and Conditions apply, unless a different
-# license is obtained from Japan Network Information Center ("JPNIC"),
-# a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
-# Chiyoda-ku, Tokyo 101-0047, Japan.
-#
-# 1. Use, Modification and Redistribution (including distribution of any
-# modified or derived work) in source and/or binary forms is permitted
-# under this License Terms and Conditions.
-#
-# 2. Redistribution of source code must retain the copyright notices as they
-# appear in each source code file, this License Terms and Conditions.
-#
-# 3. Redistribution in binary form must reproduce the Copyright Notice,
-# this License Terms and Conditions, in the documentation and/or other
-# materials provided with the distribution. For the purposes of binary
-# distribution the "Copyright Notice" refers to the following language:
-# "Copyright (c) Japan Network Information Center. All rights reserved."
-#
-# 4. Neither the name of JPNIC may be used to endorse or promote products
-# derived from this Software without specific prior written approval of
-# JPNIC.
-#
-# 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-# ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
-#
-# 6. Indemnification by Licensee
-# Any person or entities using and/or redistributing this Software under
-# this License Terms and Conditions shall defend indemnify and hold
-# harmless JPNIC from and against any and all judgements damages,
-# expenses, settlement liabilities, cost and other liabilities of any
-# kind as a result of use and redistribution of this Software or any
-# claim, suite, action, litigation or proceeding by any third party
-# arising out of or relates to this License Terms and Conditions.
-#
-# 7. Governing Law, Jurisdiction and Venue
-# This License Terms and Conditions shall be governed by and and
-# construed in accordance with the law of Japan. Any person or entities
-# using and/or redistributing this Software under this License Terms and
-# Conditions hereby agrees and consent to the personal and exclusive
-# jurisdiction and venue of Tokyo District Court of Japan.
-
-top_builddir = ..
-
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-sbindir = @sbindir@
-sysconfdir = @sysconfdir@
-localstatedir = @localstatedir@
-logdir = @logdir@
-mandir = @mandir@
-
-CC = @CC@
-PURIFY = purify
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_DATA = @INSTALL_DATA@
-MKINSTALLDIRS = @top_srcdir@/mkinstalldirs
-SHELL = @SHELL@
-LIBTOOL = @LIBTOOL@
-
-ICONVINC = @ICONVINC@
-ICONVLIB = @ICONVLIB@
-MDNLIB = ../lib/libmdn.la
-
-OPTS =
-INCS = -I$(srcdir)/../include -I../include $(ICONVINC)
-DEFS = -DUNIX -DCONFIG_PATH="\"$(sysconfdir)\"" -DLOGDIR="\"$(logdir)\""
-CFLAGS = $(OPTS) $(INCS) $(DEFS) @CFLAGS@
-LDFLAGS = $(OPTS) @LDFLAGS@
-LIBS = @LIBS@
-
-#
-# Files to build mDNS Proxy
-#
-
-SRCS = unxmain.c server.c message.c logging.c proxycnf.c translate.c acl.c
-OBJS = unxmain.o server.o message.o logging.o proxycnf.o translate.o acl.o
-
-#
-# Target to build
-#
-
-TARGETS = mdnsproxy mdnsproxy.8
-
-all : $(TARGETS)
-
-mdnsproxy : $(OBJS) $(MDNLIB)
- $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ \
- $(OBJS) $(MDNLIB) $(ICONVLIB) $(LIBS)
-
-mdnsproxy.purify : $(OBJS) $(MDNLIB)
- $(LIBTOOL) --mode=link $(PURIFY) $(CC) $(LDFLAGS) -o $@ \
- $(OBJS) $(MDNLIB) $(ICONVLIB) $(LIBS)
-
-#
-# Installation
-#
-
-install: install-program install-config install-man
-
-install-program: mdnsproxy
- $(MKINSTALLDIRS) $(sbindir)
- $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) mdnsproxy $(sbindir)
-
-# Do not overwrite existing configuration file.
-install-config:
- $(MKINSTALLDIRS) $(sysconfdir)
- echo installing sample configuration file.
- $(INSTALL_DATA) $(srcdir)/mdnsproxy.conf.sample $(sysconfdir)/
-
-install-man: mdnsproxy.8
- $(MKINSTALLDIRS) $(mandir)/man8
- $(INSTALL_DATA) mdnsproxy.8 $(mandir)/man8
-
-mdnsproxy.8: mdnsproxy.8.in
- sed -e 's%[@]sysconfdir[@]%$(sysconfdir)%' \
- -e 's%[@]logdir[@]%$(logdir)%' $(srcdir)/mdnsproxy.8.in > $@
-
-clean:
- rm -f $(TARGETS) *.o core *.core *~
- rm -fr .libs/
-
-#
-# Dependecnies
-#
-
-unxmain.o : unxmain.c mdnsproxy.h
-server.o : server.c mdnsproxy.h
-message.o : message.c mdnsproxy.h
-logging.o : logging.c mdnsproxy.h
-proxycnf.o : proxycnf.c mdnsproxy.h proxycnf.h
-acl.o : acl.c mdnsproxy.h
diff --git a/contrib/idn/mdnkit/mdnsproxy/acl.c b/contrib/idn/mdnkit/mdnsproxy/acl.c
deleted file mode 100644
index cd5fa3e2..00000000
--- a/contrib/idn/mdnkit/mdnsproxy/acl.c
+++ /dev/null
@@ -1,388 +0,0 @@
-/*
- * acl.c - managing access control list.
- */
-
-/*
- * Copyright (c) 2000 Japan Network Information Center. All rights reserved.
- *
- * By using this file, you agree to the terms and conditions set forth bellow.
- *
- * LICENSE TERMS AND CONDITIONS
- *
- * The following License Terms and Conditions apply, unless a different
- * license is obtained from Japan Network Information Center ("JPNIC"),
- * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
- * Chiyoda-ku, Tokyo 101-0047, Japan.
- *
- * 1. Use, Modification and Redistribution (including distribution of any
- * modified or derived work) in source and/or binary forms is permitted
- * under this License Terms and Conditions.
- *
- * 2. Redistribution of source code must retain the copyright notices as they
- * appear in each source code file, this License Terms and Conditions.
- *
- * 3. Redistribution in binary form must reproduce the Copyright Notice,
- * this License Terms and Conditions, in the documentation and/or other
- * materials provided with the distribution. For the purposes of binary
- * distribution the "Copyright Notice" refers to the following language:
- * "Copyright (c) Japan Network Information Center. All rights reserved."
- *
- * 4. Neither the name of JPNIC may be used to endorse or promote products
- * derived from this Software without specific prior written approval of
- * JPNIC.
- *
- * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * 6. Indemnification by Licensee
- * Any person or entities using and/or redistributing this Software under
- * this License Terms and Conditions shall defend indemnify and hold
- * harmless JPNIC from and against any and all judgements damages,
- * expenses, settlement liabilities, cost and other liabilities of any
- * kind as a result of use and redistribution of this Software or any
- * claim, suite, action, litigation or proceeding by any third party
- * arising out of or relates to this License Terms and Conditions.
- *
- * 7. Governing Law, Jurisdiction and Venue
- * This License Terms and Conditions shall be governed by and and
- * construed in accordance with the law of Japan. Any person or entities
- * using and/or redistributing this Software under this License Terms and
- * Conditions hereby agrees and consent to the personal and exclusive
- * jurisdiction and venue of Tokyo District Court of Japan.
- */
-
-#ifndef lint
-static char *rcsid = "$Id: acl.c,v 1.1.2.1 2002/02/08 12:14:48 marka Exp $";
-#endif
-
-#include <config.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#ifdef WIN32
-#include <windows.h>
-#include <winsock.h>
-#else /* for normal systems */
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#endif
-
-#include "mdnsproxy.h"
-
-#ifdef TEST
-#undef WARN
-#define WARN printf
-#endif
-
-/*
- * Entry in an access control list.
- */
-typedef struct _acl acl_t;
-struct _acl {
- struct in_addr address; /* IP address */
- struct in_addr netmask; /* net mask */
- acl_t *next; /* pointer to a next entry */
-};
-
-/*
- * Access control list.
- */
-static acl_t *acl = NULL;
-
-
-/*
- * Internal functions.
- */
-static BOOL
-acl_parse_address(const char *pattern, struct in_addr *address,
- struct in_addr *netmask, int lineNo);
-
-/*
- * Initialize the access control list `acl'.
- */
-int
-acl_initialize(void)
-{
- struct in_addr address;
- struct in_addr netmask;
- config_ctx_t config_ctx;
- acl_t *new_entry;
- acl_t *last_entry;
- int value_count;
- char **values;
- int lineNo;
- int i;
-
- TRACE("acl_initialize()\n");
-
- acl = NULL;
- last_entry = NULL;
-
- config_ctx = config_query_open(KW_ALLOW_ACCESS, &value_count, &values,
- &lineNo);
-
- while (config_ctx != NULL) {
- if (value_count < 2) {
- WARN("acl_initialize - wrong # of args for \"%s\", line %d\n",
- KW_ALLOW_ACCESS, lineNo);
- return FALSE;
- }
-
- for (i = 1; i < value_count; i++) {
- if (!acl_parse_address(values[i], &address, &netmask, lineNo))
- return FALSE;
-
- new_entry = (acl_t *)malloc(sizeof(acl_t));
- if (new_entry == NULL) {
- WARN("acl_initialize - cannot allocate memory\n");
- return FALSE;
- }
- new_entry->address.s_addr = address.s_addr;
- new_entry->netmask.s_addr = netmask.s_addr;
- new_entry->next = NULL;
-
- if (last_entry == NULL)
- acl = new_entry;
- else
- last_entry->next = new_entry;
- last_entry = new_entry;
- }
- config_ctx = config_query_more(config_ctx, &value_count, &values,
- &lineNo);
- }
-
- return TRUE;
-}
-
-/*
- * netmask length to netmask conversion table.
- */
-static const unsigned long netmasks_by_mask_length[] = {
- 0x00000000UL, 0x80000000UL, 0xc0000000UL, 0xe0000000UL, /* 0.. 3 */
- 0xf0000000UL, 0xf8000000UL, 0xfc000000UL, 0xfe000000UL, /* 4.. 7 */
- 0xff000000UL, 0xff800000UL, 0xffc00000UL, 0xffe00000UL, /* 8..12 */
- 0xfff00000UL, 0xfff80000UL, 0xfffc0000UL, 0xfffe0000UL, /* 13..15 */
- 0xffff0000UL, 0xffff8000UL, 0xffffc000UL, 0xffffe000UL, /* 16..19 */
- 0xfffff000UL, 0xfffff800UL, 0xfffffc00UL, 0xfffffe00UL, /* 20..23 */
- 0xffffff00UL, 0xffffff80UL, 0xffffffc0UL, 0xffffffe0UL, /* 24..27 */
- 0xfffffff0UL, 0xfffffff8UL, 0xfffffffcUL, 0xfffffffeUL, /* 28..31 */
- 0xffffffffUL, /* 32 */
-};
-
-/*
- * Parse an ACL address pattern (e.g. 192.168.100/24), and put the result
- * into `address' and `netmask'. It returns TRUE upon success.
- *
- * We accepts the following address patterns:
- *
- * octet.octet.octet.octet
- * octet.octet.octet.octet/netmask
- * octet.octet.octet/netmask
- * octet.octet/netmask
- * octet/netmask
- *
- * Ommited octets are regarded as `0'.
- */
-static BOOL
-acl_parse_address(const char *pattern, struct in_addr *address,
- struct in_addr *netmask, int lineNo)
-{
- unsigned int octets[4];
- int netmask_length;
- int digit_count;
- int octet_count;
- const char *p = pattern;
-
- octets[1] = 0;
- octets[2] = 0;
- octets[3] = 0;
- netmask_length = 32;
-
- /*
- * Parse an dot noted IP address.
- */
- octet_count = 0;
- while (octet_count < 4) {
- octets[octet_count] = 0;
- if (*p == '0' && '0' <= *(p + 1) && *(p + 1) <= '9') {
- WARN("acl_parse_address - invalid address \"%.100s\", line %d\n",
- pattern, lineNo);
- return FALSE;
- }
- for (digit_count = 0; '0' <= *p && *p <= '9'; p++, digit_count++)
- octets[octet_count] = octets[octet_count] * 10 + (*p - '0');
- if (digit_count == 0 || digit_count > 3 || octets[octet_count] > 255) {
- WARN("acl_parse_address - invalid address \"%.100s\", line %d\n",
- pattern, lineNo);
- return FALSE;
- }
-
- octet_count++;
- if (*p != '.')
- break;
- p++;
- }
-
- if (*p == '\0' && octet_count != 4) {
- WARN("acl_parse_address - malformed address \"%.100s\", line %d\n",
- pattern, lineNo);
- return FALSE;
- }
-
- /*
- * Parse an optional netmask length preceded by `/'.
- */
- if (*p == '/') {
- netmask_length = 0;
- p++;
- if (*p == '0' && '0' <= *(p + 1) && *(p + 1) <= '9') {
- WARN("acl_parse_address - invalid netmask length \"%.100s\", "
- "line %d\n", pattern, lineNo);
- return FALSE;
- }
- for (digit_count = 0; '0' <= *p && *p <= '9'; p++, digit_count++)
- netmask_length = netmask_length * 10 + (*p - '0');
- if (digit_count == 0 || digit_count > 2 || netmask_length > 32) {
- WARN("acl_parse_address - invalid netmask length \"%.100s\", "
- "line %d\n", pattern, lineNo);
- return FALSE;
- }
- }
-
- if (*p != '\0') {
- WARN("acl_parse_address - invalid address \"%.100s\", line %d\n",
- pattern, lineNo);
- return FALSE;
- }
-
- /*
- * Put the result into `address' and `netmask'.
- */
- address->s_addr = htonl((octets[0] << 24) + (octets[1] << 16)
- + (octets[2] << 8) + octets[3]);
- netmask->s_addr = htonl(netmasks_by_mask_length[netmask_length]);
-
- /*
- * Check address/netmask mismatch. (e.g. 192.168.10.8/16)
- */
- if ((address->s_addr & netmask->s_addr) != address->s_addr) {
- WARN("acl_parse_address - address/netmask mismatch \"%.100s\", "
- "line %d\n", pattern, lineNo);
- return FALSE;
- }
-
- return TRUE;
-}
-
-/*
- * Return TRUE if access from `address' is permitted or not.
- * Note that we returns TRUE if no access control pattern is registered.
- */
-BOOL
-acl_test(struct sockaddr *address)
-{
- acl_t *acl_entry;
- struct in_addr inet_address;
-
- if (acl == NULL)
- return TRUE;
-
- inet_address.s_addr = ((struct sockaddr_in *)address)->sin_addr.s_addr;
-
- for (acl_entry = acl; acl_entry != NULL; acl_entry = acl_entry->next) {
- if ((inet_address.s_addr & acl_entry->netmask.s_addr)
- == acl_entry->address.s_addr) {
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-/*
- * Finalize the access control list `acl'.
- */
-void
-acl_finalize(void)
-{
- acl_t *acl_entry;
- acl_t *saved_next;
-
- acl_entry = acl;
- while (acl_entry != NULL) {
- saved_next = acl_entry->next;
- free(acl_entry);
- acl_entry = saved_next;
- }
-
- acl = NULL;
-}
-
-
-/*
- * main for test.
- * `proxycnf.o' and `logging.o' are reuqired to build this test program.
- */
-#ifdef TEST
-
-#include <string.h>
-
-int
-main(int argc, char *argv[])
-{
- char line[512];
- char *newline;
- struct sockaddr_in address;
-
- printf("ACL allow/deny test program\n");
- fflush(stdout);
-
- if (config_load(argc, argv) != TRUE) {
- printf("failed to load configurations\n");
- return 1 ;
- }
- printf("loaded configuration.\n");
-
- if (!acl_initialize()) {
- printf("failed to initialize ACL\n");
- return 1;
- }
-
- for (;;) {
- printf("input address> ");
- fflush(stdout);
- if (fgets(line, 512, stdin) == NULL)
- break;
-
- newline = strpbrk(line, "\r\n");
- if (newline != NULL)
- *newline = '\0';
-
- if (!inet_aton(line, &address.sin_addr)) {
- printf("invalid address\n");
- continue;
- }
-
- if (acl_test((struct sockaddr *)&address))
- printf("access from %s is allowed.\n", line);
- else
- printf("access from %s is denied.\n", line);
- }
-
- acl_finalize();
-
- return 0;
-}
-
-#endif /* TEST */
diff --git a/contrib/idn/mdnkit/mdnsproxy/logging.c b/contrib/idn/mdnkit/mdnsproxy/logging.c
deleted file mode 100644
index 160294d7..00000000
--- a/contrib/idn/mdnkit/mdnsproxy/logging.c
+++ /dev/null
@@ -1,584 +0,0 @@
-/*
- * logging.c - logging support
- */
-
-/*
- * Copyright (c) 2000 Japan Network Information Center. All rights reserved.
- *
- * By using this file, you agree to the terms and conditions set forth bellow.
- *
- * LICENSE TERMS AND CONDITIONS
- *
- * The following License Terms and Conditions apply, unless a different
- * license is obtained from Japan Network Information Center ("JPNIC"),
- * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
- * Chiyoda-ku, Tokyo 101-0047, Japan.
- *
- * 1. Use, Modification and Redistribution (including distribution of any
- * modified or derived work) in source and/or binary forms is permitted
- * under this License Terms and Conditions.
- *
- * 2. Redistribution of source code must retain the copyright notices as they
- * appear in each source code file, this License Terms and Conditions.
- *
- * 3. Redistribution in binary form must reproduce the Copyright Notice,
- * this License Terms and Conditions, in the documentation and/or other
- * materials provided with the distribution. For the purposes of binary
- * distribution the "Copyright Notice" refers to the following language:
- * "Copyright (c) Japan Network Information Center. All rights reserved."
- *
- * 4. Neither the name of JPNIC may be used to endorse or promote products
- * derived from this Software without specific prior written approval of
- * JPNIC.
- *
- * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * 6. Indemnification by Licensee
- * Any person or entities using and/or redistributing this Software under
- * this License Terms and Conditions shall defend indemnify and hold
- * harmless JPNIC from and against any and all judgements damages,
- * expenses, settlement liabilities, cost and other liabilities of any
- * kind as a result of use and redistribution of this Software or any
- * claim, suite, action, litigation or proceeding by any third party
- * arising out of or relates to this License Terms and Conditions.
- *
- * 7. Governing Law, Jurisdiction and Venue
- * This License Terms and Conditions shall be governed by and and
- * construed in accordance with the law of Japan. Any person or entities
- * using and/or redistributing this Software under this License Terms and
- * Conditions hereby agrees and consent to the personal and exclusive
- * jurisdiction and venue of Tokyo District Court of Japan.
- */
-
-#ifndef lint
-static char *rcsid = "$Id: logging.c,v 1.1.2.1 2002/02/08 12:14:49 marka Exp $";
-#endif
-
-#include <config.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
-#include <time.h>
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_SYSLOG
-#include <syslog.h>
-#endif
-
-#include <mdn/log.h>
-#include <mdn/version.h>
-
-#include "mdnsproxy.h"
-
-#define DEFAULT_LOGFILE "mdnsproxy.log"
-
-#ifdef DEBUG
-#define DEFAULT_LOG_LEVEL LOGLEVEL_TRACE
-#else
-#define DEFAULT_LOG_LEVEL LOGLEVEL_WARN
-#endif
-
-#ifndef LOGDIR
-#define LOGDIR "/var/mdnsproxy"
-#endif
-
-/*
- * Logging Control Variables
- */
-
-static char logFname[256] = { 0 } ;
-static FILE *logFptr = NULL ;
-static int logMode = LOGMODE_FILE;
-static int logFacility;
-static int logLevel = DEFAULT_LOG_LEVEL ;
-static int timeToTurnOver = 0 ;
-
-/*
- * log_default_path -- get default log file pathname
- */
-
-static void log_default_path(void)
-{
-#ifdef UNIX
- sprintf(logFname, "%s/%s", LOGDIR, DEFAULT_LOGFILE) ;
-#endif
-#if defined(WIN32) || defined(OS2)
- {
- char *env;
- if ((env = getenv("TEMP")) == NULL)
- env = getenv("TMP");
- if (env != NULL &&
- strlen(env) + strlen(DEFAULT_LOGFILE) + 1 < sizeof(logFname)) {
- (void)strcpy(logFname, env);
- (void)strcat(logFname, "\\");
- (void)strcat(logFname, DEFAULT_LOGFILE);
- }
- }
-#endif
-} const char *name;
-
-
-/*
- * log_setlevel - set log level
- */
-void log_setlevel(int level)
-{
- logLevel = level;
-}
-
-/*
- * log_strtolevel - string to log level
- */
-int log_strtolevel(char *s)
-{
- if ('0' <= s[0] && s[0] <= '9') {
- return atoi(s) ;
- } else if (!strcmp(s, "none")) {
- return LOGLEVEL_NONE;
- } else if (!strcmp(s, "fatal")) {
- return LOGLEVEL_FATAL;
- } else if (!strcmp(s, "warn") || !strcmp(s, "warning")) {
- return LOGLEVEL_WARN;
- } else if (!strcmp(s, "trace")) {
- return LOGLEVEL_TRACE;
- } else {
- return -1;
- }
-}
-
-typedef struct {
- const char *name;
- int value;
-} syslog_facility_t;
-
-static const syslog_facility_t facility_table[] = {
-#ifdef LOG_AUTH
- {"auth", LOG_AUTH},
-#endif
-#ifdef LOG_AUTHPRIV
- {"authpriv", LOG_AUTHPRIV},
-#endif
-#ifdef LOG_CRON
- {"cron", LOG_CRON},
-#endif
-#ifdef LOG_DAEMON
- {"daemon", LOG_DAEMON},
-#endif
-#ifdef LOG_FTP
- {"ftp", LOG_FTP},
-#endif
-#ifdef LOG_KERN
- {"kern", LOG_KERN},
-#endif
-#ifdef LOG_LOCAL0
- {"local0", LOG_LOCAL0},
-#endif
-#ifdef LOG_LOCAL1
- {"local1", LOG_LOCAL1},
-#endif
-#ifdef LOG_LOCAL2
- {"local2", LOG_LOCAL2},
-#endif
-#ifdef LOG_LOCAL3
- {"local3", LOG_LOCAL3},
-#endif
-#ifdef LOG_LOCAL4
- {"local4", LOG_LOCAL4},
-#endif
-#ifdef LOG_LOCAL5
- {"local5", LOG_LOCAL5},
-#endif
-#ifdef LOG_LOCAL6
- {"local6", LOG_LOCAL6},
-#endif
-#ifdef LOG_LOCAL7
- {"local7", LOG_LOCAL7},
-#endif
-#ifdef LOG_LPR
- {"lpr", LOG_LPR},
-#endif
-#ifdef LOG_MAIL
- {"mail", LOG_MAIL},
-#endif
-#ifdef LOG_NEWS
- {"news", LOG_NEWS},
-#endif
-#ifdef LOG_SYSLOG
- {"syslog", LOG_SYSLOG},
-#endif
-#ifdef LOG_USER
- {"user", LOG_USER},
-#endif
-#ifdef LOG_UUCP
- {"uucp", LOG_UUCP},
-#endif
- {NULL, 0}
-};
-
-/*
- * log_strtofacility - string to log facility
- */
-static int log_strtofacility(char *name, int *value)
-{
- const syslog_facility_t *p;
-
- for (p = facility_table; p->name != NULL; p++) {
- if (strcmp(name, p->name) == 0) {
- *value = p->value;
- return 1;
- }
- }
-
- return 0;
-}
-
-/*
- * log_terminate - terminate logging
- */
-
-void log_terminate(void)
-{
- if (logMode == LOGMODE_FILE && logFptr != NULL) {
- fclose(logFptr) ;
- logFptr = NULL ;
- }
-}
-
-/*
- * log_turnover_request - request turning over log
- * this function is intended for calling from singnal handler.
- */
-
-void log_turnover_request(void)
-{
- timeToTurnOver = 1;
-}
-
-/*
- * log_turnover - turn over log if requested
- */
-
-void log_turnover(void)
-{
- if (timeToTurnOver && logMode == LOGMODE_FILE) {
- timeToTurnOver = 0;
- log_trace_printf("--- log file turned over\n");
- log_terminate() ;
- logFptr = fopen(logFname, "a") ;
- }
-}
-
-/*
- * libmdn_logproc - log hander for libmdn
- * output message to a regular log file.
- */
-static void
-libmdn_logproc(int level, const char *message)
-{
- char buff[512] ;
- char *newline;
- time_t t;
-
- if (logMode == LOGMODE_SYSLOG) {
-#ifdef HAVE_SYSLOG
- switch (level) {
- case mdn_log_level_fatal:
- syslog(LOG_ERR, "[FATAL] %s", message);
- break;
- case mdn_log_level_error:
- syslog(LOG_ERR, "[ERROR] %s", message);
- break;
- case mdn_log_level_warning:
- syslog(LOG_WARNING, "[WARNING] %s", message);
- break;
- case mdn_log_level_info:
- syslog(LOG_INFO, "[INFO] %s", message);
- break;
- case mdn_log_level_trace:
- syslog(LOG_DEBUG, "[TRACE] %s", message);
- break;
- case mdn_log_level_dump:
- syslog(LOG_DEBUG, "[DUMP] %s", message);
- break;
- default:
- syslog(LOG_NOTICE, "[LEVEL%d] %s", level, message);
- break;
- }
-#endif /* HAVE_SYSLOG */
-
- } else if (logMode == LOGMODE_STDERR) {
- fputs(message, logFptr) ;
- fflush(logFptr) ;
-
- } else if (logFptr != NULL) {
- t = time(NULL);
- strcpy(buff, ctime(&t));
- newline = strchr(buff, '\n');
- if (newline != NULL)
- *newline = '\0';
-
- fputs(buff, logFptr);
- fprintf(logFptr, " [%d]: ", (int)getpid());
- fputs(message, logFptr) ;
- fflush(logFptr) ;
- }
-}
-
-/*
- * libmdn_string_to_loglevel - convert log level name to value.
- */
-
-static int
-libmdn_string_to_loglevel(char *s)
-{
- if ('0' <= s[0] && s[0] <= '9')
- return atoi(s);
- else if (!strcmp(s, "fatal"))
- return mdn_log_level_fatal;
- else if (!strcmp(s, "error"))
- return mdn_log_level_error;
- else if (!strcmp(s, "warning"))
- return mdn_log_level_warning;
- else if (!strcmp(s, "info"))
- return mdn_log_level_info;
- else if (!strcmp(s, "trace"))
- return mdn_log_level_trace;
- else if (!strcmp(s, "dump"))
- return mdn_log_level_dump;
- else
- return -1;
-}
-
-/*
- * log_vprintf - as name describes
- */
-
-static void log_vprintf(int level, char *fmt, va_list arg_ptr)
-{
- char buff[512] ;
- char *newline;
- time_t t;
-
- if (logLevel < level) {
- return;
- }
-
- /*
- * format message
- */
-
- if (logMode == LOGMODE_SYSLOG) {
- vsprintf(buff, fmt, arg_ptr) ;
-
-#ifdef HAVE_SYSLOG
- switch (level) {
- case LOGLEVEL_FATAL:
- syslog(LOG_ERR, buff);
- break;
- case LOGLEVEL_WARN:
- syslog(LOG_WARNING, buff);
- break;
- case LOGLEVEL_TRACE:
- syslog(LOG_DEBUG, buff);
- break;
- }
-#endif /* HAVE_SYSLOG */
-
- } else if (logMode == LOGMODE_STDERR) {
- vfprintf(logFptr, fmt, arg_ptr) ;
- fflush(logFptr) ;
-
- } else if (logFptr != NULL) {
- t = time(NULL);
- strcpy(buff, ctime(&t));
- newline = strchr(buff, '\n');
- if (newline != NULL)
- *newline = '\0';
-
- fputs(buff, logFptr);
- fprintf(logFptr, " [%d]: ", (int)getpid());
- vfprintf(logFptr, fmt, arg_ptr);
- fflush(logFptr) ;
- }
-
-#ifdef WIN32 /* For NT, having trouble with */
- fclose(logFptr) ; /* reading open'd logging file */
- logFptr = NULL ; /* so, close and re-open it */
-#endif
-}
-
-/*
- * log_fatal_printf, log_warn_printf, log_trace_printf - write out
- * fatal/warning/trace log to the log file
- */
-
-void log_fatal_printf(char *fmt, ...)
-{
- va_list arg_ptr ;
-
- va_start(arg_ptr, fmt) ;
- log_vprintf(LOGLEVEL_FATAL, fmt, arg_ptr) ;
- va_end(arg_ptr) ;
-}
-
-void log_warn_printf(char *fmt, ...)
-{
- va_list arg_ptr ;
-
- va_start(arg_ptr, fmt) ;
- log_vprintf(LOGLEVEL_WARN, fmt, arg_ptr) ;
- va_end(arg_ptr) ;
-}
-
-void log_trace_printf(char *fmt, ...)
-{
- va_list arg_ptr ;
-
- va_start(arg_ptr, fmt) ;
- log_vprintf(LOGLEVEL_TRACE, fmt, arg_ptr) ;
- va_end(arg_ptr) ;
-}
-
-/*
- * log_configure - configure logging (must be called after 'config_load')
- */
-
-BOOL log_configure(int ac, char *av[])
-{
- int i, nArgs ;
- char **aArgs ;
- char *fn = NULL ;
- int lineNo;
-
- log_default_path();
-
-#ifdef HAVE_SYSLOG
- logFacility = LOG_DAEMON;
-#endif
-
- for (i = 1 ; i < ac ; i++) {
- if (strcmp(av[i], CMDOPT_LOGFILE) == 0) {
- fn = av[i+=1] ;
- }
- }
- if (fn != NULL) {
- if (strlen(fn) + 1 > sizeof(logFname)) {
- fprintf(stderr,
- "log_configure - too long log file name \"%.100s...\"\n",
- fn);
- return FALSE;
- }
- strcpy(logFname, fn) ;
-
- } else if (config_query_value(KW_LOG_FILE, &nArgs, &aArgs, &lineNo)) {
- if (nArgs != 2) {
- fprintf(stderr,
- "log_configure - wrong # of args for \"%s\", line %d\n",
- KW_LOG_FILE, lineNo);
- return FALSE;
- }
- strcpy(logFname, aArgs[1]) ;
- }
-
- if (config_query_value(KW_LOG_LEVEL, &nArgs, &aArgs, &lineNo) == TRUE) {
- int level ;
-
- if (nArgs != 2) {
- fprintf(stderr,
- "log_configure - wrong # of args for \"%s\", line %d\n",
- KW_LOG_LEVEL, lineNo);
- return FALSE;
- }
- if ((level = log_strtolevel(aArgs[1])) < 0) {
- fprintf(stderr,
- "log_configure - invalid log level \"%.100s\", line %d\n",
- aArgs[1], lineNo);
- return FALSE;
- }
- log_setlevel(level);
- }
-
- if (config_query_value(KW_MDN_LOG_LEVEL, &nArgs, &aArgs, &lineNo)) {
- int level;
-
- if (nArgs != 2) {
- fprintf(stderr,
- "wrong # of args for \"%s\", line %d\n", KW_MDN_LOG_LEVEL,
- lineNo);
- return FALSE;
- }
- if ((level = libmdn_string_to_loglevel(aArgs[1])) < 0) {
- fprintf(stderr,
- "unknown mdn log level \"%.100s\", line %d\n", aArgs[1],
- lineNo);
- return FALSE;
- }
- mdn_log_setlevel(level);
- }
-
-#ifdef HAVE_SYSLOG
- if (config_query_value(KW_SYSLOG_FACILITY, &nArgs, &aArgs, &lineNo)
- == TRUE) {
- if (nArgs != 2) {
- fprintf(stderr,
- "log_configure - wrong # of args for \"%s\", line %d\n",
- KW_LOG_LEVEL, lineNo);
- return FALSE;
- } else if (!log_strtofacility(aArgs[1], &logFacility)) {
- fprintf(stderr,
- "log_configure - unknown syslog facility \"%.100s\", "
- "line %d\n", aArgs[1], lineNo);
- return FALSE;
- }
- }
-#endif /* HAVE_SYSLOG */
-
- if (*logFname == '\0') {
- fprintf(stderr, "log_configure - no logging file specified\n");
- return FALSE;
- }
-
- if (strcmp(logFname, "syslog") == 0) {
-#ifdef HAVE_SYSLOG
- logMode = LOGMODE_SYSLOG;
- logFptr = NULL;
- openlog("mdnsproxy", LOG_NDELAY | LOG_PID, logFacility);
- syslog(LOG_NOTICE, "** mdnsproxy version %s", mdn_version_getstring());
-#else /* not HAVE_SYSLOG */
- fprintf(stderr, "log_configure - syslog is unavailable\n");
- return FALSE;
-#endif /* not HAVE_SYSLOG */
- } else if (strcmp(logFname, "stderr") == 0) {
- logMode = LOGMODE_STDERR;
- logFptr = stderr;
- } else {
- logMode = LOGMODE_FILE;
- logFptr = fopen(logFname, "a") ;
- if (logFptr == NULL) {
- fprintf(stderr,
- "log_configure - cannot open, the log file\"%.100s\"\n",
- logFname);
- return FALSE;
- }
- fprintf(stderr, "** mdnsproxy version %s\n", mdn_version_getstring());
- }
-
- mdn_log_setproc(libmdn_logproc);
-
- return TRUE;
-}
diff --git a/contrib/idn/mdnkit/mdnsproxy/make.wnt b/contrib/idn/mdnkit/mdnsproxy/make.wnt
deleted file mode 100644
index 958be5b8..00000000
--- a/contrib/idn/mdnkit/mdnsproxy/make.wnt
+++ /dev/null
@@ -1,128 +0,0 @@
-#
-# Makefile for mDNS Proxy Server, WINNT version
-#
-# $Id: make.wnt,v 1.1.2.1 2002/02/08 12:14:50 marka Exp $
-#
-# Copyright (c) 2000 Japan Network Information Center. All rights reserved.
-#
-# By using this file, you agree to the terms and conditions set forth bellow.
-#
-# LICENSE TERMS AND CONDITIONS
-#
-# The following License Terms and Conditions apply, unless a different
-# license is obtained from Japan Network Information Center ("JPNIC"),
-# a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
-# Chiyoda-ku, Tokyo 101-0047, Japan.
-#
-# 1. Use, Modification and Redistribution (including distribution of any
-# modified or derived work) in source and/or binary forms is permitted
-# under this License Terms and Conditions.
-#
-# 2. Redistribution of source code must retain the copyright notices as they
-# appear in each source code file, this License Terms and Conditions.
-#
-# 3. Redistribution in binary form must reproduce the Copyright Notice,
-# this License Terms and Conditions, in the documentation and/or other
-# materials provided with the distribution. For the purposes of binary
-# distribution the "Copyright Notice" refers to the following language:
-# "Copyright (c) Japan Network Information Center. All rights reserved."
-#
-# 4. Neither the name of JPNIC may be used to endorse or promote products
-# derived from this Software without specific prior written approval of
-# JPNIC.
-#
-# 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-# ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
-#
-# 6. Indemnification by Licensee
-# Any person or entities using and/or redistributing this Software under
-# this License Terms and Conditions shall defend indemnify and hold
-# harmless JPNIC from and against any and all judgements damages,
-# expenses, settlement liabilities, cost and other liabilities of any
-# kind as a result of use and redistribution of this Software or any
-# claim, suite, action, litigation or proceeding by any third party
-# arising out of or relates to this License Terms and Conditions.
-#
-# 7. Governing Law, Jurisdiction and Venue
-# This License Terms and Conditions shall be governed by and and
-# construed in accordance with the law of Japan. Any person or entities
-# using and/or redistributing this Software under this License Terms and
-# Conditions hereby agrees and consent to the personal and exclusive
-# jurisdiction and venue of Tokyo District Court of Japan.
-#
-
-!include <ntwin32.mak>
-
-ICONVDIR = ..\win
-MDNDIR = ..\lib
-BINDIR = ..\..\bin\win
-
-INCDIR = ..\include
-LIBS = $(MDNDIR)\libmdn.lib $(ICONVDIR)\iconv.lib
-SYSLIBS = $(conlibsdll)
-
-#
-# Files to build mDNS Proxy
-#
-
-HDRS = mdnsproxy.h winserv.h
-
-SRCS = winmain.c winserv.c server.c message.c translate.c \
- logging.c proxycnf.c acl.c
-OBJS = winmain.obj winserv.obj server.obj message.obj translate.obj \
- logging.obj proxycnf.obj acl.obj
-
-#
-# Target to build
-#
-
-TARGETS = mdnsproxy.exe $(ICONVDIR)\iconv.dll
-
-all : $(TARGETS)
-
-install : $(TARGETS)
- copy mdnsproxy.exe $(BINDIR)
- copy $(ICONVDIR)\iconv.dll $(BINDIR)
-
-mdnsproxy.exe : $(OBJS) $(LIBS)
- $(link) $(conflags) -out:mdnsproxy.exe $(OBJS) $(LIBS) $(SYSLIBS)
-
-clean:
- del *.exe *.obj *.lib core *.core *~
-
-#
-# Dependecnies
-#
-
-winmain.obj : winmain.c $(HDRS)
- $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -DDEBUG $*.c
-
-winserv.obj : winserv.c $(HDRS)
- $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -DDEBUG $*.c
-
-server.obj : server.c $(HDRS)
- $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -DDEBUG $*.c
-
-message.obj : message.c $(HDRS)
- $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -DDEBUG $*.c
-
-translate.obj : translate.c $(HDRS)
- $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -DDEBUG $*.c
-
-logging.obj : logging.c $(HDRS)
- $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -DDEBUG $*.c
-
-proxycnf.obj : proxycnf.c $(HDRS)
- $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -DDEBUG $*.c
-
-acl.obj : acl.c $(HDRS)
- $(cc) $(cflags) $(cvarsdll) -I$(INCDIR) -DDEBUG $*.c
diff --git a/contrib/idn/mdnkit/mdnsproxy/mdnsproxy.8.in b/contrib/idn/mdnkit/mdnsproxy/mdnsproxy.8.in
deleted file mode 100644
index c163e52c..00000000
--- a/contrib/idn/mdnkit/mdnsproxy/mdnsproxy.8.in
+++ /dev/null
@@ -1,314 +0,0 @@
-.\" $Id: mdnsproxy.8.in,v 1.1.2.1 2002/02/08 12:14:52 marka Exp $
-.\"
-.\" Copyright (c) 2000 Japan Network Information Center. All rights reserved.
-.\"
-.\" By using this file, you agree to the terms and conditions set forth bellow.
-.\"
-.\" LICENSE TERMS AND CONDITIONS
-.\"
-.\" The following License Terms and Conditions apply, unless a different
-.\" license is obtained from Japan Network Information Center ("JPNIC"),
-.\" a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
-.\" Chiyoda-ku, Tokyo 101-0047, Japan.
-.\"
-.\" 1. Use, Modification and Redistribution (including distribution of any
-.\" modified or derived work) in source and/or binary forms is permitted
-.\" under this License Terms and Conditions.
-.\"
-.\" 2. Redistribution of source code must retain the copyright notices as they
-.\" appear in each source code file, this License Terms and Conditions.
-.\"
-.\" 3. Redistribution in binary form must reproduce the Copyright Notice,
-.\" this License Terms and Conditions, in the documentation and/or other
-.\" materials provided with the distribution. For the purposes of binary
-.\" distribution the "Copyright Notice" refers to the following language:
-.\" "Copyright (c) Japan Network Information Center. All rights reserved."
-.\"
-.\" 4. Neither the name of JPNIC may be used to endorse or promote products
-.\" derived from this Software without specific prior written approval of
-.\" JPNIC.
-.\"
-.\" 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
-.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-.\" PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
-.\"
-.\" 6. Indemnification by Licensee
-.\" Any person or entities using and/or redistributing this Software under
-.\" this License Terms and Conditions shall defend indemnify and hold
-.\" harmless JPNIC from and against any and all judgements damages,
-.\" expenses, settlement liabilities, cost and other liabilities of any
-.\" kind as a result of use and redistribution of this Software or any
-.\" claim, suite, action, litigation or proceeding by any third party
-.\" arising out of or relates to this License Terms and Conditions.
-.\"
-.\" 7. Governing Law, Jurisdiction and Venue
-.\" This License Terms and Conditions shall be governed by and and
-.\" construed in accordance with the law of Japan. Any person or entities
-.\" using and/or redistributing this Software under this License Terms and
-.\" Conditions hereby agrees and consent to the personal and exclusive
-.\" jurisdiction and venue of Tokyo District Court of Japan.
-.TH DNSPROXY 8
-.SH NAME
-mdnsproxy \- DNS proxy server for multi-lingual DNS
-
-.SH SYNOPSIS
-.B mdnsproxy
-[ \-daemon ] [ \-config <config\-file> ] [ \-logfile <log\-file> ]
-.br
-.B mdnsproxy
-\-version
-
-.SH DESCRIPTION
-.B mdnsproxy
-resides between application (resolver) and DNS server.
-.PP
-It accepts DNS requests from application (resolver) and converting
-domain names in those requests into DNS server's acceptable encoding,
-and forward those converted requests. It also accepts responses from
-DNS server and converting domain names in those resopnses into
-application's acceptable encoding and forward those responses to
-applications.
-
-.SH OPTIONS
-.TP
-.B \-daemon
-Run mdnsproxy as daemon. Otherwise, mdnsproxy will run as normal
-console program.
-.TP
-.B \-config <config\-file>
-Specifies configuration file (see later). If not specified,
-mdnsproxy uses default configuration file.
-See
-.B FILES
-section for default configuration file.
-.TP
-.B \-logfile <log\-file>
-Specifies logging file. If not specified.
-mdnsproxy uses default logging file.
-See
-.B FILES
-section for default configuration file.
-.TP
-.B \-version
-Prints version information to standard error and quits.
-
-.SH CONFIGURATION
-Configuration file is simple text file which defines several
-configuration data.
-.IP "listen <address>"
-.RS
-Defines listening port (both TCP and UDP). <address> is one of
-.RS
-.PP
-<IP address>:<port number>
-.br
-:<port number>
-.br
-<IP address>
-.PP
-.RE
-If omitted, mdnsproxy uses default value shown below.
-.RS
-.PP
-IP Address INADDR_ANY (0.0.0.0)
-.br
-port number 53
-.PP
-.RE
-.RE
-.IP "forward <address> [ bind4compat ]"
-.RS
-Defines forwarding server's address. Format is same as 'listen'.
-.PP
-example:
-.RS
-forward 10.1.2.3
-.RE
-.PP
-If "bind4compat" was given, mdnsproxy uses above listen port
-as forwading UDP's source address. If not given, mdnsproxy uses
-port > 1024 as forwading UDP's source.
-.RE
-.IP "client-encoding <Encoding>"
-.RS
-Defines client side character encoding scheme.
-.PP
-example:
-.RS
-.nf
-client-encoding\ \ EUC-JP
-.fi
-.RE
-.RE
-.IP "mdn-conf-file <path>"
-.RS
-Specifies configuration file for libmdn, the library responsible for most
-of the MDN processing for mdnsproxy.
-If the entry is ommitted, mdnsproxy reads "@sysconfdir@/mdn.conf".
-.RE
-.IP "log-file <path>"
-.RS
-Defines log file name. It may be overridden with command line
-option '-logfile <path>'. If no log file given, mdnsproxy writes
-log data into "@logdir@/mdnsproxy.log".
-Sending SIGHUP causes mdnsproxy to close the log file and then reopen it.
-.PP
-If <path> is set to ``syslog'', mdnsproxy outputs log messages with
-syslog.
-If <path> is set to ``stderr'', mdnsproxy outputs messages to standard
-error.
-.RE
-.IP "log-level <Level>"
-.RS
-Sets the log level. Available levels are ``none'' (no logging at all),
-``fatal'' (only logs fatal errors), ``warn'' (also logs warning messages)
-and ``trace'' (also includes trace level messages). The default level is
-``warn''. Please note that if you set the level to ``trace'', the size of
-the log file grows quickly.
-.PP
-If mdnsproxy is configured to output log messages with syslog (see the
-description of the ``log-file'' entry), ``fatal'' messages are output
-with ``err'' priority, ``warning'' messages with ``warning'' and ``trace''
-messages with ``debug''.
-.RE
-.IP "mdn-log-level <Number>"
-.RS
-Specifies the logging level for libmdn.
-Unless you are debugging mDNkit, you should keep this entry unspecified.
-.RE
-.IP "syslog-facility <Facility>"
-.RS
-Specifies the syslog facility to be assigned to log messages output by
-mdnsproxy. The entry is ignored unless the `log-file' entry is set to
-``syslog''. If the entry is not specified, ``daemon'' will be used.
-
-.RE
-.IP "user-id <Name-or-ID>"
-.RS
-Defines a user ID in which mdnsproxy operates.
-Dnsproxy tries to change the user ID of its process to the specified one,
-soon after initialization.
-.PP
-example:
-.RS
-.nf
-user-id\ \ nobody
-user-id\ \ 9999
-.fi
-.RE
-.PP
-It is strongly recommended to use this option for security reasons.
-.RE
-.IP "group-id <Name-or-ID>"
-.RS
-Defines a group ID in which mdnsproxy operates.
-Dnsproxy tries to change the group ID of its process to the specified one,
-soon after initialization.
-.PP
-example:
-.RS
-.nf
-group-id\ \ nobody
-group-id\ \ 9999
-.fi
-.RE
-.RE
-.IP "root-directory <Directory>"
-.RS
-Defines the pathname of the root directory for the mdnsproxy process.
-Dnsproxy performs chroot() to set the specified directory as the
-root directory for the process after initialization.
-.PP
-example:
-.RS
-.nf
-root-directory /var/mdnsproxy
-.fi
-.RE
-.RE
-.IP "allow-access <Address> ..."
-.RS
-Specifies which hosts are allowed to access to the server.
-<Address> is an IP address (in dotted numeric form) or IP prefix
-(IP address followed by a slash and netmask).
-.PP
-example:
-.RS
-.nf
-allow-access 192.168.100.1
-allow-access 192.168.10.0/24
-.fi
-.RE
-.PP
-You can specify one or more <Address>. The server rejects accesses
-from clients not matched to any <Address>.
-You can also define allow-access several times.
-.PP
-.RS
-.nf
-allow-access 192.168.100.1
-allow-access 192.168.100.2
-.fi
-.RE
-.PP
-This is equivarent to:
-.PP
-.RS
-.nf
-allow-access 192.168.100.1 192.168.100.2
-.fi
-.RE
-.PP
-If no entry is specified, the server allows to access from all hosts.
-.RE
-.IP "log-on-denied <Flag>"
-.RS
-is used to tell mdnsproxy whether or not to log denied access.
-<Flag> is either "yes" or "no".
-If "yes" is specified, the server records denied access.
-The default value is "no".
-.RE
-.RE
-
-.SH NOTES
-Some applications locally mangles domain names. In those cases,
-mdnsproxy cannot works correctly.
-.PP
-For 'nslookup', it generally reject non-ascii domain names.
-You need 8bit through patched version of nslookup.
-.PP
-For UNIX resolver generally rejects domain names using non-ascii characters.
-You need 8bit through patched version of resolver.
-.PP
-For Windows, NS works well with mdnsproxy. For IE, turn off "use UTF-8"
-setting, and generally works. But for IE, embedded URL's in page will
-converted by IE (to page's original encoding),
-and they conflict with mdnsproxy.
-
-.SH FILES
-.PD 0
-.TP
-.B @sysconfdir@/mdnsproxy.conf
-Default configuration file for mdnsproxy.
-.TP
-.B @sysconfdir@/mdn.conf
-Default configuration file for libmdn.
-.TP
-.B @logdir@/mdnsproxy.log
-Default logging file.
-.PD
-
-.SH SLL ALSO
-.BR named(8),
-.BR syslogd(8),
-.BR syslog.conf(5),
-.BR libmdn(3),
-.BR iconv(3)
diff --git a/contrib/idn/mdnkit/mdnsproxy/mdnsproxy.conf.sample b/contrib/idn/mdnkit/mdnsproxy/mdnsproxy.conf.sample
deleted file mode 100644
index 411796c1..00000000
--- a/contrib/idn/mdnkit/mdnsproxy/mdnsproxy.conf.sample
+++ /dev/null
@@ -1,149 +0,0 @@
-# $Id: mdnsproxy.conf.sample,v 1.1.2.1 2002/02/08 12:14:53 marka Exp $
-#
-# Sample mdnsproxy configuration file 'mdnsproxy.conf'.
-#
-
-#
-# 'listen' entry specifies the mdnsproxy's listening port.
-# The default is to use address 0.0.0.0 (INADDR_ANY) and port 53.
-#
-# syntax)
-# listen [<IP address>][:<port number>]
-#
-# ex) listen 127.0.0.1 -- only accept loopback connections
-# listen :1053 -- port number can be specified
-# listen 127.0.0.1:1053 -- combination of above
-#
-#listen 127.0.0.1
-
-#
-# 'forward' entry specifies the name server's port to which mdnsproxy
-# forwards requests. This entry MUST be specified.
-#
-# Normally mdnsproxy uses unspecified local port number for sending
-# queries to the server, but if 'bind4compat' option is specified,
-# mdnsproxy uses the same port number as the listening port specified
-# by the 'listen' entry.
-#
-# syntax)
-# forward <IP address>[:<port number>] [bind4compat]
-#
-# ex) forward 10.0.0.2 -- forward 10.0.0.2 port 53
-# forward 10.0.0.2:1053 -- port number can be specified
-# forward 10.0.0.2 bind4compat -- use fixed port number.
-forward xxx.xxx.xxx.xxx
-
-#
-# 'client-encoding' entry specifies the codeset (encoding) of domain
-# names in the messages sent by the clients.
-#
-# syntax)
-# client-encoding <encoding>
-#
-#client-encoding EUC-JP
-client-encoding Shift_JIS
-
-#
-# 'mdn-conf-file' entry specifies the pathname of configuration file for
-# libmdn, the library responsible for most of the MDN processing for
-# mdnsproxy. If it is not specified, mdnsproxy reads default configuration
-# file.
-#
-# syntax)
-# mdn-conf-file <pathname>
-#
-#mdn-conf-file /usr/local/etc/mdn.conf
-
-#
-# 'log-file' entry specifies the pathname of the log file. If the string
-# `syslog' is given, mdnsproxy will record its events with syslog. If
-# `stderr' is given, mdnsproxy will record events to standard error.
-# If the entry is not specified, default log file will be used.
-#
-# syntax)
-# log-file (<pathname> | syslog | stderr)
-#
-#log-file /var/log/mdnsproxy.log
-
-#
-# 'log-level' entry specifies the logging level for mdnsproxy.
-# Valid levels are 'none' (no logging at all, not recommended),
-# 'fatal' (only logs fatal errors), 'warn' (also logs warning messages)
-# and 'trace' (also includes trace messages). The default level is 'warn'.
-# 'trace' level is useful for debugging mdnsproxy itself, but it makes
-# the log file grow rather quickly.
-#
-# syntax)
-# log-level <level>
-#
-log-level warn
-
-#
-# 'mdn-log-level' entry specifies the logging level for libmdn.
-# Unless you are debugging mDNkit, you should keep this entry unspecified.
-#
-# syntax)
-# mdn-log-level <level>
-#
-#mdn-log-level 1
-
-#
-# 'syslog-facility' entry specifies the syslog facility to be assigned to
-# log messages output by mdnsproxy. The entry is ignored unless the
-# `log-file' entry is set to `syslog'. If the entry is not specified,
-# `daemon' will be used.
-#
-# syntax)
-# syslog-facility <facility>
-#
-#syslog-facility daemon
-
-#
-# 'user-id' entry and 'group-id' entry specify the user/group ID
-# in which privilege mdnsproxy operates. mdnsproxy tries to switch
-# to the specified user/group after initialization process is finished.
-#
-# syntax)
-# user-id <name-or-number>
-# group-id <name-or-number>
-#
-# ex) user-id nobody -- specify by name,
-# group-id 1000 -- or by number
-#
-user-id nobody
-#group-id nobody
-
-#
-# 'root-directory' entry specifies the root directory of mdnsproxy
-# process. mdnsproxy performs chroot() to this directory after
-# initialization. Note that chroot() is allowed only for super-users.
-#
-# syntax)
-# root-directory <path>
-#
-root-directory /var/mdnsproxy
-
-#
-# `allow-access' entry specifies which hosts are allowed to access to the
-# server. Defining multiple entries are also permitted. If it is not
-# specified, the server allows to acceess from all hosts.
-#
-# syntax)
-# allow-access <IP address> | <IP prefix>
-#
-# ex) allow-access 127.0.0.1
-# -- allow access from the host 127.0.0.1
-# allow-access 192.168.100.0/24
-# -- allow access from hosts on the network 192.168.100.0/24.
-#
-#allow-access xxx.xxx.xxx.xxx
-
-#
-# `log-on-denied' entry specifies whether or not to log denied access.
-# If it is not specified, the server doesn't record denied access.
-#
-# syntax)
-# log-on-denied <yes>
-# log-on-denied <no>
-#
-#log-on-denied no
diff --git a/contrib/idn/mdnkit/mdnsproxy/mdnsproxy.def b/contrib/idn/mdnkit/mdnsproxy/mdnsproxy.def
deleted file mode 100644
index abdcb93e..00000000
--- a/contrib/idn/mdnkit/mdnsproxy/mdnsproxy.def
+++ /dev/null
@@ -1,3 +0,0 @@
-NAME dnsproxy WINDOWCOMPAT NEWFILES
-EXETYPE OS2
-STACKSIZE 32768
diff --git a/contrib/idn/mdnkit/mdnsproxy/mdnsproxy.h b/contrib/idn/mdnkit/mdnsproxy/mdnsproxy.h
deleted file mode 100644
index 7877b402..00000000
--- a/contrib/idn/mdnkit/mdnsproxy/mdnsproxy.h
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * dnsproxy.h - mDNS Proxy, Common Definitions
- */
-
-/*
- * Copyright (c) 2000 Japan Network Information Center. All rights reserved.
- *
- * By using this file, you agree to the terms and conditions set forth bellow.
- *
- * LICENSE TERMS AND CONDITIONS
- *
- * The following License Terms and Conditions apply, unless a different
- * license is obtained from Japan Network Information Center ("JPNIC"),
- * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
- * Chiyoda-ku, Tokyo 101-0047, Japan.
- *
- * 1. Use, Modification and Redistribution (including distribution of any
- * modified or derived work) in source and/or binary forms is permitted
- * under this License Terms and Conditions.
- *
- * 2. Redistribution of source code must retain the copyright notices as they
- * appear in each source code file, this License Terms and Conditions.
- *
- * 3. Redistribution in binary form must reproduce the Copyright Notice,
- * this License Terms and Conditions, in the documentation and/or other
- * materials provided with the distribution. For the purposes of binary
- * distribution the "Copyright Notice" refers to the following language:
- * "Copyright (c) Japan Network Information Center. All rights reserved."
- *
- * 4. Neither the name of JPNIC may be used to endorse or promote products
- * derived from this Software without specific prior written approval of
- * JPNIC.
- *
- * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * 6. Indemnification by Licensee
- * Any person or entities using and/or redistributing this Software under
- * this License Terms and Conditions shall defend indemnify and hold
- * harmless JPNIC from and against any and all judgements damages,
- * expenses, settlement liabilities, cost and other liabilities of any
- * kind as a result of use and redistribution of this Software or any
- * claim, suite, action, litigation or proceeding by any third party
- * arising out of or relates to this License Terms and Conditions.
- *
- * 7. Governing Law, Jurisdiction and Venue
- * This License Terms and Conditions shall be governed by and and
- * construed in accordance with the law of Japan. Any person or entities
- * using and/or redistributing this Software under this License Terms and
- * Conditions hereby agrees and consent to the personal and exclusive
- * jurisdiction and venue of Tokyo District Court of Japan.
- */
-
-/* $Id: mdnsproxy.h,v 1.1.2.1 2002/02/08 12:14:54 marka Exp $ */
-
-#ifndef DNSPROXY_H
-#define DNSPROXY_H 1
-
-#include <stdio.h>
-
-#ifdef WIN32
-#include <windows.h>
-#include <winsock.h>
-#else /* for normal systems */
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#endif
-
-#include "proxycnf.h"
-
-/*
- * Redefine TRUE and FALSE.
- */
-#undef TRUE
-#undef FALSE
-#define TRUE 1
-#define FALSE 0
-
-/*
- * Macro for Error Logging
- */
-
-enum {
- LOGMODE_FILE = 0,
- LOGMODE_SYSLOG = 1,
- LOGMODE_STDERR = 2
-};
-
-enum {
- LOGLEVEL_NONE = 0,
- LOGLEVEL_FATAL = 1,
- LOGLEVEL_WARN = 2,
- LOGLEVEL_TRACE = 3
-};
-
-BOOL log_configure(int ac, char *av[]) ;
-void log_terminate(void) ;
-void log_turnover_request(void) ;
-void log_turnover(void) ;
-void log_setlevel(int level) ;
-int log_strtolevel(char *s) ;
-void log_fatal_printf(char *fmt, ...) ;
-void log_warn_printf(char *fmt, ...) ;
-void log_trace_printf(char *fmt, ...) ;
-
-#define TRACE log_trace_printf
-#define WARN log_warn_printf
-#define FATAL log_fatal_printf
-
-/*
- * Server's Control Entries
- */
-
-BOOL server_init(int ac, char *av[]) ;
-void server_stop(void) ;
-void server_loop(void) ;
-void server_done(void) ;
-
-/*
- * Server calls following callback when received message
- */
-
-void notify_message(struct sockaddr *from, int proto,
- u_char *msg, int len) ;
-
-void notify_timer(void) ;
-
-/*
- * To send messages, call following entires in server module
- */
-
-void server_forward(struct sockaddr *to, int proto,
- u_char *msg, int len) ;
-void server_response(struct sockaddr *to, int proto,
- u_char *msg, int len) ;
-
-/*
- * load/dump/dispose configuration data
- */
-
-BOOL config_load(int ac, char *av[]) ;
-void config_free(void) ;
-void config_dump(FILE *ofp) ;
-
-/*
- * query configuration data
- */
-
-BOOL config_query_value(char *key, int *count, char ***array, int *lineNo) ;
-BOOL config_query_listen(struct sockaddr *addr) ;
-BOOL config_query_forward(struct sockaddr *addr) ;
-BOOL config_query_restrict(BOOL *src_restrict) ;
-BOOL config_query_log_on_denied(BOOL *flag) ;
-
-/*
- * Message (domain name) translation
- */
-
-typedef struct translation_context {
- struct sockaddr *client; /* address family/IP address/port */
- int protocol; /* IPPROTO_TCP or IPPROTO_UDP */
- unsigned int old_id; /* original message ID */
- unsigned int new_id; /* new message ID */
-} translation_context_t;
-
-BOOL translate_initialize(void) ;
-void translate_finish(void) ;
-int translate_request(translation_context_t *ctx,
- const char *msg, size_t msglen,
- char *translated, size_t bufsize, size_t *translatedlenp) ;
-int translate_reply(translation_context_t *ctx,
- const char *msg, size_t msglen,
- char *translated, size_t bufsize, size_t *translatedlenp) ;
-
-/*
- * query configuration having multiple entries (with same key)
- *
- * ctx = config_query_open(key, ...) ;
- * while (ctx != NULL) {
- * ctx = config_query_more(ctx, ...) ;
- * }
- * config_query_close(ctx) ;
- */
-
-typedef void *config_ctx_t ; /* opaque pointer to lookup context */
-
-config_ctx_t config_query_open(char *key, int *count, char ***array,
- int *lineNo) ;
-config_ctx_t config_query_more(config_ctx_t ctx, int *count, char ***array,
- int *lineNo) ;
-void config_query_close(config_ctx_t ctx) ;
-
-/*
- * managing access control list.
- */
-int acl_initialize(void);
-BOOL acl_test(struct sockaddr *address);
-void acl_finalize(void);
-
-#endif /* DNSPROXY_H */
diff --git a/contrib/idn/mdnkit/mdnsproxy/message.c b/contrib/idn/mdnkit/mdnsproxy/message.c
deleted file mode 100644
index f17ecbc8..00000000
--- a/contrib/idn/mdnkit/mdnsproxy/message.c
+++ /dev/null
@@ -1,627 +0,0 @@
-/*
- * message.c - mDNS Proxy, message handling
- *
- * message will passed with callback 'notify_message'.
- * this module parse received message and forward request,
- * or reply to originator
- */
-
-/*
- * Copyright (c) 2000 Japan Network Information Center. All rights reserved.
- *
- * By using this file, you agree to the terms and conditions set forth bellow.
- *
- * LICENSE TERMS AND CONDITIONS
- *
- * The following License Terms and Conditions apply, unless a different
- * license is obtained from Japan Network Information Center ("JPNIC"),
- * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
- * Chiyoda-ku, Tokyo 101-0047, Japan.
- *
- * 1. Use, Modification and Redistribution (including distribution of any
- * modified or derived work) in source and/or binary forms is permitted
- * under this License Terms and Conditions.
- *
- * 2. Redistribution of source code must retain the copyright notices as they
- * appear in each source code file, this License Terms and Conditions.
- *
- * 3. Redistribution in binary form must reproduce the Copyright Notice,
- * this License Terms and Conditions, in the documentation and/or other
- * materials provided with the distribution. For the purposes of binary
- * distribution the "Copyright Notice" refers to the following language:
- * "Copyright (c) Japan Network Information Center. All rights reserved."
- *
- * 4. Neither the name of JPNIC may be used to endorse or promote products
- * derived from this Software without specific prior written approval of
- * JPNIC.
- *
- * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * 6. Indemnification by Licensee
- * Any person or entities using and/or redistributing this Software under
- * this License Terms and Conditions shall defend indemnify and hold
- * harmless JPNIC from and against any and all judgements damages,
- * expenses, settlement liabilities, cost and other liabilities of any
- * kind as a result of use and redistribution of this Software or any
- * claim, suite, action, litigation or proceeding by any third party
- * arising out of or relates to this License Terms and Conditions.
- *
- * 7. Governing Law, Jurisdiction and Venue
- * This License Terms and Conditions shall be governed by and and
- * construed in accordance with the law of Japan. Any person or entities
- * using and/or redistributing this Software under this License Terms and
- * Conditions hereby agrees and consent to the personal and exclusive
- * jurisdiction and venue of Tokyo District Court of Japan.
- */
-
-#ifndef lint
-static char *rcsid = "$Id: message.c,v 1.1.2.1 2002/02/08 12:14:55 marka Exp $";
-#endif
-
-#include <config.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-
-#ifdef WIN32
-#include <windows.h>
-#include <winsock.h>
-#else /* for normal systems */
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#endif
-
-#include "mdnsproxy.h"
-
-/*
- * address handling utilities
- *
- * addrEq check same addresses
- * addrFmt format address, port & protocol
- *
- * these functions are same with those in 'server.c'.
- * may be put in another 'utility' module.
- */
-
-static BOOL addrEq(struct sockaddr *a1, struct sockaddr *a2)
-{
- struct sockaddr_in *ip1 = (struct sockaddr_in *) a1 ;
- struct sockaddr_in *ip2 = (struct sockaddr_in *) a2 ;
-
- if (ip1->sin_addr.s_addr != ip2->sin_addr.s_addr) {
- return FALSE ;
- }
- if (ip1->sin_port != ip2->sin_port) {
- return FALSE ;
- }
- return TRUE ;
-}
-
-static u_char fmtbuff[64] ;
-
-static u_char *addrFmt(struct sockaddr *addr, int proto)
-{
- struct sockaddr_in *iaddr = (struct sockaddr_in *) addr ;
- u_char *ap ;
- u_char *pp ;
-
- ap = (u_char *) &iaddr->sin_addr ;
- pp = (u_char *) &iaddr->sin_port ;
-
- sprintf(fmtbuff, "%s:%d.%d.%d.%d:%d",
- (proto == SOCK_STREAM ? "TCP" : "UDP"),
- (ap[0] & 0xff), (ap[1] & 0xff), (ap[2] & 0xff), (ap[3] & 0xff),
- ((pp[0] & 0xff) * 256 + (pp[1] & 0xff)) ) ;
-
- return fmtbuff ;
-}
-
-/*
- * Managing Message ID
- */
-
-static u_short msgidLast = 0xffff ;
-static u_short msgidMap[4096] = { 0 } ;
-
-#define ID_INDEX(x) (((x) & 0xfff0) >> 4)
-#define ID_MASK(x) (1 << ((x) & 0x000f))
-
-#define ID_CHECK(x) (msgidMap[ID_INDEX((x))] & ID_MASK((x)))
-#define ID_USEIT(x) (msgidMap[ID_INDEX((x))] |= ID_MASK((x)))
-#define ID_CLEAR(x) (msgidMap[ID_INDEX((x))] &= ~ID_MASK((x)))
-
-static BOOL idAlloc(u_short *id)
-{
- u_short newid ;
-
- for (newid = (msgidLast + 1) & 0xffff ;
- newid != msgidLast ;
- newid = (newid + 1) & 0xffff) {
- if (ID_CHECK(newid) == 0) {
- ID_USEIT(newid) ;
- msgidLast = newid ;
- *id = newid ;
- return TRUE ;
- }
- }
- WARN("idAlloc - no more ID\n") ;
- return FALSE ;
-}
-
-static void idFree(u_short id)
-{
- if (ID_CHECK(id) == 0) {
- WARN("idAlloc - %04x is not in use\n", id) ;
- return ;
- }
- ID_CLEAR(id) ;
-}
-
-/*
- * Message Managements
- *
- * Request from client is identified with its ID word. It is unique
- * on one client, but proxy accepts requests from multiple clients,
- * proxy cannot distinguish request with ID only, and cannot forward
- * request with such ID word.
- *
- * So, proxy will identify requests with combination of address, port,
- * (which identified client) and ID word. Then forwarding request,
- * proxy allocate unique ID, and change request's ID with new one.
- *
- * Response from DNS server will identified with newly allocated ID.
- * For responding such response to originator, replace response's
- * ID with original one, and send response to marked address/port.
- */
-
-typedef struct _MSG *MSGPTR ;
-
-typedef struct _MSG {
- MSGPTR prev ;
- MSGPTR next ;
- time_t last ;
- struct sockaddr from ;
- int proto ;
- u_short orgId ;
- u_short newId ;
- translation_context_t trctx ;
-} MSGREC ;
-
-static MSGREC listMsg = { 0 } ;
-
-/*
- * searchReq - search request in message list, search on original ID
- */
-
-static MSGPTR searchReq(u_short id, int proto, struct sockaddr *addr)
-{
- MSGPTR p ;
-
- if (listMsg.prev == NULL || listMsg.next == NULL) {
- listMsg.prev = &listMsg ;
- listMsg.next = &listMsg ;
- }
- for (p = listMsg.next ; p != &listMsg ; p = p->next) {
- if (p->orgId != id || p->proto != proto) {
- continue ;
- }
- if (addrEq(&p->from, addr) != TRUE) {
- continue ;
- }
- p->last = time(NULL) ;
- return p ;
- }
- return NULL ;
-}
-
-/*
- * searchOrg - search original request matching to new ID
- */
-
-static MSGPTR searchOrg(u_short id, int proto)
-{
- MSGPTR p ;
-
- if (listMsg.prev == NULL || listMsg.next == NULL) {
- listMsg.prev = &listMsg ;
- listMsg.next = &listMsg ;
- }
- for (p = listMsg.next ; p != &listMsg ; p = p->next) {
- if (p->newId != id || p->proto != proto) {
- continue ;
- }
- p->last = time(NULL) ;
- return p ;
- }
- return NULL ;
-}
-
-/*
- * createReq - create new message record for new request
- *
- * it also allocate new ID for this request, used for
- * forwarding this request
- */
-
-static MSGPTR createReq(u_short id, int proto, struct sockaddr *addr)
-{
- u_short newid ;
- MSGPTR pMsg, prev, next ;
-
- if (listMsg.prev == NULL || listMsg.next == NULL) {
- listMsg.prev = &listMsg ;
- listMsg.next = &listMsg ;
- }
-
- if (idAlloc(&newid) != TRUE) {
- WARN("createReq - no more ID\n") ;
- return NULL ;
- }
- if ((pMsg = (MSGPTR) malloc(sizeof(MSGREC))) == NULL) {
- WARN("createReq - cannot allocate message record\n") ;
- idFree(newid) ;
- return NULL ;
- }
-
- memset(pMsg, 0, sizeof(MSGREC)) ;
-
- memcpy(&pMsg->from, addr, sizeof(struct sockaddr)) ;
- pMsg->proto = proto ;
- pMsg->orgId = id ;
- pMsg->newId = newid ;
- pMsg->last = time(NULL) ;
-
- pMsg->trctx.client = &pMsg->from ;
- pMsg->trctx.protocol = pMsg->proto ;
- pMsg->trctx.old_id = pMsg->orgId ;
- pMsg->trctx.new_id = pMsg->newId ;
-
- prev = listMsg.prev ;
- next = prev->next ;
-
- prev->next = pMsg ;
- next->prev = pMsg ;
- pMsg->prev = prev ;
- pMsg->next = next ;
-
- return pMsg ;
-}
-
-/*
- * disposeReq - dispose message record
- */
-
-static void disposeReq(MSGPTR pMsg)
-{
- MSGPTR p ;
-
- if (listMsg.prev == NULL || listMsg.next == NULL) {
- listMsg.prev = &listMsg ;
- listMsg.next = &listMsg ;
- }
-
- for (p = listMsg.next ; p != &listMsg ; p = p->next) {
- if (p == pMsg) {
- break ;
- }
- }
- if (p == pMsg) { /* safe to unlink it */
- pMsg->prev->next = pMsg->next ;
- pMsg->next->prev = pMsg->prev ;
- }
- idFree(pMsg->newId) ;
- free(pMsg) ;
-}
-
-/*
- * messageForward - forward the request
- */
-
-static void errorOnRequest(MSGPTR pMsg, u_char *msg, int len, size_t err)
-{
- u_short errmsg[6] ;
- u_short flags ;
- u_short *ps ;
-
- TRACE("errorOnRequest %d\n", err) ;
-
- ps = (u_short *) msg ;
- flags = ntohs(ps[1]) ;
- flags = ((flags & 0x7fff) | 0x8000) ; /* QR to response */
- flags = ((flags & 0xfff8) | (err & 0x0007)) ; /* set RCODE */
-
- memset(errmsg, 0, sizeof(errmsg)) ;
- errmsg[0] = htons(pMsg->orgId) ;
- errmsg[1] = htons(flags) ;
-
- server_response(&pMsg->from, pMsg->proto, (u_char *) errmsg, sizeof(errmsg)) ;
-}
-
-static void messageForward(MSGPTR pMsg, u_char *msg, int len)
-{
- u_short *p ;
- u_char buff[1024] ;
- u_char *bbase ;
- size_t bleng ;
- size_t cleng = 0 ; /* avoid un-expected length on xlate error */
- size_t cstat = 0 ; /* avoid un-expected status on xlate error */
-
- TRACE("messageForward - %04x -> %04x\n", pMsg->orgId, pMsg->newId) ;
-
- /*
- * prepare conversion buffer
- */
-
- if (len < sizeof(buff) / 2) {
- bbase = buff ;
- bleng = sizeof(buff) ;
- } else {
- bbase = malloc(len * 2) ;
- bleng = len * 2 ;
- }
- if (bbase == NULL) {
- WARN("messageForward - cannot prepare conversion buffer\n") ;
- return ;
- }
-
- /*
- * translate message (domain names)
- */
-
- TRACE("messageForward - translate request\n") ;
-
- cstat = translate_request(&pMsg->trctx, msg, len, bbase, bleng, &cleng) ;
-
- TRACE("messageForward - translated status %d length %d\n", cstat, cleng) ;
-
- if (cstat != 0) { /* error on conversion */
- WARN("messageForward - translation error %d\n", cstat) ;
- errorOnRequest(pMsg, msg, len, cstat) ;
- return ;
- }
- if (pMsg->proto == SOCK_DGRAM && cleng > 512) {
- WARN("messageForward - translation overflow %d\n", cleng) ;
- errorOnRequest(pMsg, msg, len, 2) ;
- return ;
- }
-
- /*
- * forward the request
- */
-
- p = (u_short *) bbase ;
- p[0] = htons(pMsg->newId) ;
-
- server_forward(NULL, pMsg->proto, bbase, cleng) ;
-
- /*
- * cleanup buffer
- */
-
- if (bbase != buff) {
- free(bbase) ;
- }
-}
-
-/*
- * messageResponse - response to originating client
- */
-
-static void errorOnResponse(MSGPTR pMsg, u_char *msg, int len, size_t err)
-{
- u_short errmsg[6] ;
- u_short flags ;
- u_short *ps ;
-
- TRACE("errorOnResponse %d\n", err) ;
-
- ps = (u_short *) msg ;
- flags = ntohs(ps[1]) ;
- flags = ((flags & 0x7fff) | 0x8000) ; /* QR to response */
- flags = ((flags & 0xfff8) | (err & 0x0007)) ; /* set RCODE */
-
- memset(errmsg, 0, sizeof(errmsg)) ;
- errmsg[0] = htons(pMsg->orgId) ;
- errmsg[1] = htons(flags) ;
-
- server_response(&pMsg->from, pMsg->proto, (u_char *) errmsg, sizeof(errmsg)) ;
-}
-
-static void messageResponse(MSGPTR pMsg, u_char *msg, int len)
-{
- u_short *p ;
- u_char buff[1024] ;
- u_char *bbase ;
- size_t bleng ;
- size_t cleng ;
- size_t cstat ;
-
- TRACE("messageResponse - %04x <- %04x\n", pMsg->orgId, pMsg->newId) ;
-
- /*
- * prepare conversion buffer
- */
-
- if (len < sizeof(buff) / 2) {
- bbase = buff ;
- bleng = sizeof(buff) ;
- } else {
- bbase = malloc(len * 2) ;
- bleng = len * 2 ;
- }
- if (bbase == NULL) {
- WARN("messageResponse - cannot prepare conversion buffer\n") ;
- return ;
- }
-
- /*
- * translate message (domain names)
- */
-
- TRACE("messageResponse - translate response\n") ;
-
- cstat = translate_reply(&pMsg->trctx, msg, len, bbase, bleng, &cleng) ;
-
- TRACE("messageResponse - translated status %d length %d\n", cstat, cleng) ;
-
- if (cstat != 0) { /* error on conversion */
- WARN("messageResponse - translation error %d\n", cstat) ;
- errorOnResponse(pMsg, msg, len, cstat) ;
- return ;
- }
- if (pMsg->proto == SOCK_DGRAM && cleng > 512) {
- WARN("messageResponse - translation overflow %d\n", cleng) ;
- errorOnResponse(pMsg, msg, len, 2) ;
- return ;
- }
-
- /*
- * reply back to requester
- */
-
- p = (u_short *) bbase ;
- p[0] = htons(pMsg->orgId) ;
-
- server_response(&pMsg->from, pMsg->proto, bbase, cleng) ;
-
- /*
- * cleanup buffer
- */
-
- if (bbase != buff) {
- free(bbase) ;
- }
-}
-
-/*
- * notify_message - callback from server loop
- */
-
-void notify_message(struct sockaddr *from, int proto, u_char *msg, int len)
-{
- u_short *p = (u_short *) msg ;
- u_short msgid, flags ;
- MSGPTR pMsg ;
-#ifdef DEBUG
- char logbuf[256] ;
-#endif
-
- msgid = ntohs(p[0]) ;
- flags = ntohs(p[1]) ;
-
-#ifdef DEBUG
- if ((flags & 0x8000) == 0) {
- sprintf(logbuf, "Request %04x (%04x) from %s, %d bytes",
- msgid, flags, addrFmt(from, proto), len) ;
- } else {
- sprintf(logbuf, "Response %04x (%04x) from %s %d bytes",
- msgid, flags, addrFmt(from, proto), len) ;
- }
- TRACE("%s\n", logbuf) ;
-
- strcpy(logbuf, " ") ;
-
- switch ((flags & 0x7800) >> 11) {
- case 0 : strcat(logbuf, "QUERY ") ; break ;
- case 1 : strcat(logbuf, "IQUERY ") ; break ;
- case 2 : strcat(logbuf, "STATUS ") ; break ;
- default : strcat(logbuf, "UNKNOWN") ; break ;
- }
- if ((flags & 0x0400) != 0) {
- strcat(logbuf, ",AA") ;
- }
- if ((flags & 0x0200) != 0) {
- strcat(logbuf, ",TC") ;
- }
- if ((flags & 0x0100) != 0) {
- strcat(logbuf, ",RD") ;
- }
- if ((flags & 0x0080) != 0) {
- strcat(logbuf, ",RA") ;
- }
- switch (flags & 0x00f) {
- case 0 : strcat(logbuf, ",No Error ") ; break ;
- case 1 : strcat(logbuf, ",Format Error ") ; break ;
- case 2 : strcat(logbuf, ",Server Failure ") ; break ;
- case 3 : strcat(logbuf, ",Name Error ") ; break ;
- case 4 : strcat(logbuf, ",Not Implemented") ; break ;
- case 5 : strcat(logbuf, ",Refused ") ; break ;
- default : strcat(logbuf, ",Unknown Error ") ; break ;
- }
- TRACE("%s\n", logbuf) ;
-#endif
-
- if ((flags & 0x8000) == 0) { /* request from client */
-
- if ((pMsg = searchReq(msgid, proto, from)) == NULL) {
- pMsg = createReq(msgid, proto, from) ;
- }
- if (pMsg == NULL) {
- WARN("notify_message - cannot create message record\n") ;
- return ;
- }
- messageForward(pMsg, msg, len) ;
-
- } else { /* response from server */
-
- if ((pMsg = searchOrg(msgid, proto)) == NULL) {
- WARN("notify_message - no corresponding request\n") ;
- return ;
- }
- messageResponse(pMsg, msg, len) ;
- disposeReq(pMsg);
- }
-}
-
-/*
- * notify_timer - timer callback
- */
-
-static time_t timeLastCheck = 0 ;
-static time_t timeInterval = 60 ;
-static time_t timeTimeout = (60 * 10) ;
-
-void notify_timer(void)
-{
- time_t t = time(NULL) ;
- MSGPTR p, np ;
-#ifdef DEBUG
- int ndiscarded = 0;
-#endif
-
- if (listMsg.prev == NULL || listMsg.next == NULL) {
- listMsg.prev = &listMsg ;
- listMsg.next = &listMsg ;
- }
-
- if ((t - timeLastCheck) < timeInterval) {
- return ;
- }
- for (p = listMsg.next ; p != &listMsg ; p = np) {
- np = p->next ;
- if ((t - p->last) > timeTimeout) {
- disposeReq(p) ;
-#ifdef DEBUG
- ndiscarded++;
-#endif
- }
- }
-#ifdef DEBUG
- TRACE("notify_timer: %d discarded\n", ndiscarded);
-#endif
- timeLastCheck = t;
-}
diff --git a/contrib/idn/mdnkit/mdnsproxy/os2main.c b/contrib/idn/mdnkit/mdnsproxy/os2main.c
deleted file mode 100644
index fe0733e9..00000000
--- a/contrib/idn/mdnkit/mdnsproxy/os2main.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * os2main.c - mDNS Proxy, entry for OS2
- *
- * For OS/2, there are no daemon, nor service. Simply
- * start server program with
- *
- * RUN in config.sys
- * START in startup.cmd
- * put server program (object) into startup folder
- */
-
-/*
- * Copyright (c) 2000 Japan Network Information Center. All rights reserved.
- *
- * By using this file, you agree to the terms and conditions set forth bellow.
- *
- * LICENSE TERMS AND CONDITIONS
- *
- * The following License Terms and Conditions apply, unless a different
- * license is obtained from Japan Network Information Center ("JPNIC"),
- * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
- * Chiyoda-ku, Tokyo 101-0047, Japan.
- *
- * 1. Use, Modification and Redistribution (including distribution of any
- * modified or derived work) in source and/or binary forms is permitted
- * under this License Terms and Conditions.
- *
- * 2. Redistribution of source code must retain the copyright notices as they
- * appear in each source code file, this License Terms and Conditions.
- *
- * 3. Redistribution in binary form must reproduce the Copyright Notice,
- * this License Terms and Conditions, in the documentation and/or other
- * materials provided with the distribution. For the purposes of binary
- * distribution the "Copyright Notice" refers to the following language:
- * "Copyright (c) Japan Network Information Center. All rights reserved."
- *
- * 4. Neither the name of JPNIC may be used to endorse or promote products
- * derived from this Software without specific prior written approval of
- * JPNIC.
- *
- * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * 6. Indemnification by Licensee
- * Any person or entities using and/or redistributing this Software under
- * this License Terms and Conditions shall defend indemnify and hold
- * harmless JPNIC from and against any and all judgements damages,
- * expenses, settlement liabilities, cost and other liabilities of any
- * kind as a result of use and redistribution of this Software or any
- * claim, suite, action, litigation or proceeding by any third party
- * arising out of or relates to this License Terms and Conditions.
- *
- * 7. Governing Law, Jurisdiction and Venue
- * This License Terms and Conditions shall be governed by and and
- * construed in accordance with the law of Japan. Any person or entities
- * using and/or redistributing this Software under this License Terms and
- * Conditions hereby agrees and consent to the personal and exclusive
- * jurisdiction and venue of Tokyo District Court of Japan.
- */
-
-#ifndef lint
-static char *rcsid = "$Id: os2main.c,v 1.1.2.1 2002/02/08 12:14:56 marka Exp $";
-#endif
-
-#ifdef OS2
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-
-#include "mdnsproxy.h" /* Common definitions for mDNS proxy */
-
-/*
- * signal handler to catch signal to terminate server
- */
-
-static void handler(int signo)
-{
- server_stop() ;
- signal(signo, SIG_DFL) ;
-}
-
-/*
- * main - entry of os2 version
- */
-
-int main(int ac, char *av[])
-{
- int i, pid ;
-
- for (i = 1 ; i < ac ; i++) {
- if (strcmp(av[i], "-daemon") == 0) {
- as_daemon = TRUE ;
- } else if (strcmp(av[i], "-conf") == 0) {
- if (i + 1 == ac) {
- fprintf(stderr, "missing argument to \"%s\"\n", av[i]) ;
- return 1 ;
- }
- } else if (strcmp(av[i], "-logfile") == 0) {
- if (i + 1 == ac) {
- fprintf(stderr, "missing argument to \"%s\"\n", av[i]) ;
- return 1 ;
- }
- } else if (av[i][0] == '-' && av[i][1] != '\0') {
- fprintf(stderr, "unknown option \"%s\"\n", av[i]) ;
- return 1 ;
- } else {
- fprintf(stderr, "too many arguments\n");
- return 1 ;
- }
- }
-
- if (config_load(ac, av) != TRUE) {
- printf("cannot load configurations\n") ;
- return 1 ;
- }
-
- if (log_configure(ac, av) != TRUE) {
- printf("cannot logging\n") ;
- return 1 ;
- }
-
- if (server_init(ac, av) != TRUE) {
- printf("cannot initialize server\n") ;
- log_terminate() ;
- return 1 ;
- }
-
- signal(SIGINT, handler) ;
- signal(SIGKILL, handler) ;
- signal(SIGTERM, handler) ;
- signal(SIGBREAK, handler) ;
-
-#ifdef DEBUG
- printf("Service Started\n") ;
-#endif
-
- server_loop() ;
-
-#ifdef DEBUG
- printf("Service Termiating...\n") ;
-#endif
-
- server_done() ;
-
- log_terminate() ;
-
-#ifdef DEBUG
- printf("Service Terminated\n") ;
-#endif
-
- return 0 ;
-}
-
-#endif /* OS2 */
-
diff --git a/contrib/idn/mdnkit/mdnsproxy/proxycnf.c b/contrib/idn/mdnkit/mdnsproxy/proxycnf.c
deleted file mode 100644
index 7dd346c3..00000000
--- a/contrib/idn/mdnkit/mdnsproxy/proxycnf.c
+++ /dev/null
@@ -1,944 +0,0 @@
-/*
- * proxycnf.c - mDNS Proxy, configuration
- */
-
-/*
- * Copyright (c) 2000 Japan Network Information Center. All rights reserved.
- *
- * By using this file, you agree to the terms and conditions set forth bellow.
- *
- * LICENSE TERMS AND CONDITIONS
- *
- * The following License Terms and Conditions apply, unless a different
- * license is obtained from Japan Network Information Center ("JPNIC"),
- * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
- * Chiyoda-ku, Tokyo 101-0047, Japan.
- *
- * 1. Use, Modification and Redistribution (including distribution of any
- * modified or derived work) in source and/or binary forms is permitted
- * under this License Terms and Conditions.
- *
- * 2. Redistribution of source code must retain the copyright notices as they
- * appear in each source code file, this License Terms and Conditions.
- *
- * 3. Redistribution in binary form must reproduce the Copyright Notice,
- * this License Terms and Conditions, in the documentation and/or other
- * materials provided with the distribution. For the purposes of binary
- * distribution the "Copyright Notice" refers to the following language:
- * "Copyright (c) Japan Network Information Center. All rights reserved."
- *
- * 4. Neither the name of JPNIC may be used to endorse or promote products
- * derived from this Software without specific prior written approval of
- * JPNIC.
- *
- * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * 6. Indemnification by Licensee
- * Any person or entities using and/or redistributing this Software under
- * this License Terms and Conditions shall defend indemnify and hold
- * harmless JPNIC from and against any and all judgements damages,
- * expenses, settlement liabilities, cost and other liabilities of any
- * kind as a result of use and redistribution of this Software or any
- * claim, suite, action, litigation or proceeding by any third party
- * arising out of or relates to this License Terms and Conditions.
- *
- * 7. Governing Law, Jurisdiction and Venue
- * This License Terms and Conditions shall be governed by and and
- * construed in accordance with the law of Japan. Any person or entities
- * using and/or redistributing this Software under this License Terms and
- * Conditions hereby agrees and consent to the personal and exclusive
- * jurisdiction and venue of Tokyo District Court of Japan.
- */
-
-#ifndef lint
-static char *rcsid = "$Id: proxycnf.c,v 1.1.2.1 2002/02/08 12:14:57 marka Exp $";
-#endif
-
-#include <config.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
-
-#ifdef WIN32
-#include <windows.h>
-#include <winsock.h>
-#else /* for normal systems */
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#endif
-
-#include "mdnsproxy.h" /* Common definitions for mDNS proxy */
-
-/*
- * Note that logging macros (FATAL, WARN and TRACE) cannot be used
- * until logging file is configured, i.e. log_configure() is called.
- * Be careful.
- */
-
-/*
- * default config file (path & basename), depend on MACHINE
- */
-
-#ifndef CONFIG_PATH
-#warning "no \"CONFIG_PATH\", use "\"./\" as default"
-#define CONFIG_PATH "./"
-#endif
-#ifndef CONFIG_FILE
-#warning "no \"CONFIG_FILE\", use "mdnsproxy.ini" as default"
-#define CONFIG_FILE "mdnsproxy.ini"
-#endif
-#ifndef CONFIG_HOME
-#warning "no \"CONFIG_HOME\", use "\"./\" as default"
-#define CONFIG_HOME "./"
-#endif
-
-static u_char *confFile = CONFIG_FILE ;
-
-static u_char *confPath[] = {
-#if defined(DEBUG) && !defined(UNIX)
- "./",
- CONFIG_HOME,
-#endif
- CONFIG_PATH,
- NULL
-} ;
-
-static u_char *confCommands[] = {
- KW_LISTEN,
- KW_FORWARD,
- KW_CLIENT_ENCODING,
- KW_MDN_CONF_FILE,
- KW_LOG_FILE,
- KW_LOG_LEVEL,
- KW_MDN_LOG_LEVEL,
- KW_SYSLOG_FACILITY,
- KW_USER_ID,
- KW_GROUP_ID,
- KW_ROOT_DIRECTORY,
- KW_ALLOW_ACCESS,
- KW_LOG_ON_DENIED,
- NULL
-};
-
-static u_char *confObsoleteCommands[] = {
- KW_CLIENT_TRANSLATION,
- KW_ALTERNATE_ENCODING,
- KW_NORMALIZE,
- KW_SERVER_TRANSLATION,
- KW_ENCODING_ALIAS_FILE,
- NULL
-};
-
-static u_char *expandName(u_char *name, u_char *buff)
-{
-#ifndef UNIX
- int inEnv = FALSE ;
- u_char *bp, *ep ;
- u_char env[512] ;
-
- for (bp = buff, ep = env ; *name != '\0' ; name++) {
- if (inEnv == FALSE) {
- if (*name == '$') {
- inEnv = TRUE ;
- ep = env ;
- } else {
- *bp++ = *name ;
- *bp = '\0' ;
- }
- } else {
- if (*name == '(') {
- /* skip this */
- } else if (*name != ')') {
- *ep++ = *name ;
- *ep = '\0' ;
- } else if ((ep = getenv(env)) == NULL) {
- return NULL ;
- } else {
- while (*ep != '\0') {
- *bp++ = *ep++ ;
- }
- *bp = '\0' ;
- inEnv = FALSE ;
- }
- }
- }
-#else /* UNIX */
- strcpy(buff, name);
-#endif /* UNIX */
-
- return buff ;
-}
-
-static FILE *openConfig(u_char *fname)
-{
- int i ;
- FILE *fp = NULL ;
- u_char path[512] ;
- u_char name[512] ;
-
- /*
- * if coinfiguration file specified, open it
- */
-
- if (fname != NULL) {
- if (expandName(fname, name) == NULL) {
- return NULL ;
- }
- if ((fp = fopen(name, "r")) == NULL) {
- return NULL ;
- }
- return fp ;
- }
-
- /*
- * otherwise, look for configuration file in search path
- */
-
- for (i = 0 ; confPath[i] != NULL ; i++) {
-
- if (expandName(confPath[i], path) == NULL) {
- continue ;
- }
-
- sprintf(name, "%s%s", path, confFile) ;
-
- if ((fp = fopen(name, "r")) != NULL) {
- return fp ;
- }
- }
- return NULL ;
-}
-
-/*
- * configuration data in file consists of
- *
- * key value ...
- *
- * lines. This module hold them as following list.
- */
-
-typedef struct _CONF *CNFPTR ;
-
-typedef struct _CONF {
- int lineNo ;
- CNFPTR prev ;
- CNFPTR next ;
- u_char *key ; /* really, buffer for key & val */
- int nVal ;
- u_char *aVal[1] ; /* really, follows 'nVal' entries */
-} CNFREC ;
-
-static CNFREC confList = { 0 } ;
-
-static void disposeData(void)
-{
- CNFPTR p ;
-
- if (confList.prev == NULL || confList.next == NULL) {
- return ;
- }
- while ((p = confList.next) != &confList) {
- confList.next = p->next ;
- free(p->key) ;
- free(p) ;
- }
-}
-
-static u_char *getString(u_char *p, CNFPTR pCnf)
-{
- /*
- * mark start of value string
- */
-
- pCnf->aVal[pCnf->nVal++] = p ;
-
- /*
- * look for end of string, any space
- */
-
- for ( ; *p != '\0' ; p++) {
- if (isspace(*p)) {
- break ;
- }
- }
- if (*p != '\0') {
- *p++ = '\0' ;
- }
- return p ;
-}
-
-static u_char *getQuoted(u_char *p, CNFPTR pCnf)
-{
- if (*p != '"') { /* Oh, something wrong !! */
- return p ;
- }
- p++ ; /* skip leading '"' */
-
- /*
- * mark start of value string
- */
-
- pCnf->aVal[pCnf->nVal++] = p ;
-
- /*
- * look for terminating '"', may be escaped with '\'
- */
-
- while (*p != '\0' && *p != '\n' && *p != '\r') {
- if (*p == '"') {
- break ;
- } else if (*p == '\\') { /* quoted pair */
- p += 2 ;
- } else {
- p += 1 ;
- }
- }
- if (*p != '\0') {
- *p++ = '\0' ;
- }
- return p ;
-}
-
-static BOOL findCommand(u_char *name)
-{
- u_char **cmd;
-
- for (cmd = (u_char **)confCommands; *cmd != NULL; cmd++) {
- if (strcmp(*cmd, name) == 0)
- return TRUE;
- }
-
- return FALSE;
-}
-
-static BOOL findObsoleteCommand(u_char *name)
-{
- u_char **cmd;
-
- for (cmd = (u_char **)confObsoleteCommands; *cmd != NULL; cmd++) {
- if (strcmp(*cmd, name) == 0)
- return TRUE;
- }
-
- return FALSE;
-}
-
-static BOOL appendData(u_char *line, int lineNo)
-{
- int len ;
- u_char *pStr, *p ;
- CNFPTR pCnf, pNew ;
- CNFPTR prev, next ;
-
- /*
- * list is not initialized, initialize it
- */
-
- if (confList.prev == NULL || confList.next == NULL) {
- confList.prev = &confList ;
- confList.next = &confList ;
- }
-
- /*
- * prepare buffers
- */
-
- len = strlen(line) ;
-
- pCnf = (CNFPTR) malloc(sizeof(CNFREC) + sizeof(u_char *) * len) ;
- pStr = malloc(len + 2) ;
-
- if (pStr == NULL || pCnf == NULL) {
- fprintf(stderr, "appendData - cannot allocate memory\n") ;
- if (pStr != NULL) free(pStr) ;
- if (pCnf != NULL) free(pCnf) ;
- return FALSE ;
- }
-
- memset(pCnf, 0, sizeof(CNFREC)) ;
-
- for (p = pStr ; *line != '\0' ; ) {
- if (*line == '\n' || *line == '\r') {
- break ;
- }
- *p++ = *line++ ;
- }
- *p = '\0' ;
-
- /*
- * parse line (save results into pCnf)
- *
- * term may be string or quoted-string
- */
-
- for (p = pStr ; *p != '\0' ; ) {
- if (isspace(*p)) {
- p += 1 ;
- } else if (*p == '#') {
- break ;
- } else if (*p == '"') {
- p = getQuoted(p, pCnf) ;
- } else {
- p = getString(p, pCnf) ;
- }
- }
-
- /*
- * if no term found, skip the line
- */
-
- if (pCnf->nVal == 0) {
- free(pStr) ;
- free(pCnf) ;
- return TRUE ;
- }
-
- if (findObsoleteCommand(pStr)) {
- fprintf(stderr, "appendData - obsolete command \"%.100s\", line %d\n",
- pStr, lineNo) ;
- return FALSE;
- }
- if (!findCommand(pStr)) {
- fprintf(stderr, "appendData - unknown command \"%.100s\", line %d\n",
- pStr, lineNo) ;
- return FALSE;
- }
-
- /*
- * create resulting CNF record
- */
-
- pNew = (CNFPTR) malloc(sizeof(CNFREC) + sizeof(u_char *) * pCnf->nVal) ;
-
- if (pNew == NULL) {
- fprintf(stderr, "appendData - cannot allocate memory\n") ;
- free(pStr) ;
- free(pCnf) ;
- return FALSE ;
- }
-
- memset(pNew, 0, sizeof(CNFREC)) ;
-
- pNew->lineNo = lineNo;
- pNew->key = pStr ;
- pNew->nVal = pCnf->nVal ;
- memcpy(pNew->aVal, pCnf->aVal, sizeof(u_char *) * pCnf->nVal) ;
-
- free(pCnf) ;
-
- /*
- * link to list
- */
-
- prev = confList.prev ;
- next = prev->next ;
- pNew->prev = confList.prev ;
- pNew->next = &confList ;
- prev->next = pNew ;
- next->prev = pNew ;
-
- return TRUE ;
-}
-
-/*
- * config_load - load mDNS Proxy configuration data
- */
-
-BOOL config_load(int ac, char *av[])
-{
- int i ;
- u_char *conf ;
- FILE *fp ;
- u_char line[512] ;
- int lineNo ;
-
- /*
- * check if alternate config file specified
- */
-
- for (i = 1, conf = CONFIG_PATH "/" CONFIG_FILE ; i < ac ; i++) {
- if (strcmp(av[i], "-config") == 0) {
- if ((i + 1) < ac) {
- conf = av[i+=1] ;
- }
- }
- }
-
- /*
- * open configuration file
- */
-
- if ((fp = openConfig(conf)) == NULL) {
- fprintf(stderr, "config_load - cannot open the configuration file, "
- "%s, \"%.100s\"\n", strerror(errno), conf) ;
- return FALSE ;
- }
-
- /*
- * read and parse configuration data (per line)
- */
- lineNo = 0;
- while (fgets(line, 512, fp) != NULL) {
- lineNo++;
- if (appendData(line, lineNo) != TRUE) {
- fprintf(stderr, "config_load - error in \"%s\"\n", conf) ;
- fclose(fp) ;
- return FALSE ;
- }
- }
-
- fclose(fp) ;
- return TRUE ;
-}
-
-/*
- * config_dump - dump contents of mDNS Proxy configuration data
- */
-
-static BOOL haveSpace(u_char *str)
-{
- for ( ; *str != '\0' ; str++) {
- if (isspace(*str)) {
- return TRUE ;
- }
- }
- return FALSE ;
-}
-
-void config_dump(FILE *ofp)
-{
- CNFPTR p ;
- int i ;
-
- if (confList.next == NULL || confList.prev == NULL) {
- return ;
- }
- for (p = confList.next ; p != &confList ; p = p->next) {
- if (haveSpace(p->key)) {
- fprintf(ofp, "<%s>", p->key) ;
- } else {
- fprintf(ofp, "<%s>", p->key) ;
- }
- for (i = 0 ; i < p->nVal ; i++) {
- if (haveSpace(p->aVal[i])) {
- fprintf(ofp, " \"%s\"", p->aVal[i]) ;
- } else {
- fprintf(ofp, " %s", p->aVal[i]) ;
- }
- }
- fprintf(ofp, "\n") ;
- }
-}
-
-/*
- * config_free - dispose mDNS configuration data
- */
-
-void config_free(void)
-{
- disposeData() ;
-}
-
-/*
- * config_query_value - query configuration data
- *
- * this is generic interface to access configuration data
- * but note, this function cannot work with multiple
- * configuration data, such as client-translation
- */
-
-BOOL config_query_value(char *key, int *count, char ***array, int *lineNo)
-{
- CNFPTR p ;
-
- for (p = confList.next ; p != &confList ; p = p->next) {
- if (strcmp(p->key, key) != 0) {
- continue ;
- }
- *count = p->nVal ;
- *array = (char **) p->aVal ;
- *lineNo = p->lineNo;
- return TRUE ;
- }
- return FALSE ;
-}
-
-/*
- * config_query_listen, config_query_forward
- *
- * queries sockaddr (really sockaddr_in) of proxy to listen,
- * and DNS server to which proxy forwards the requests.
- * These function set
- *
- * addr->sin_family <- AF_INET
- * addr->sin_addr <- specified/default
- * addr->sin_port <- specified/default
- *
- * for 'listen' address, both sin_addr/sin_port have default values,
- * but for 'forward' address, there is no default for 'sin_addr',
- * and result error on such case.
- *
- * NOTE: for DNS proxy, both listen/forward address should be
- * specified with xx.xx.xx.xx notation, never be host name
- */
-
-#define DEFAULT_ADDR INADDR_ANY
-#define DEFAULT_PORT 53
-
-static CNFPTR queryData(u_char *key)
-{
- CNFPTR p ;
-
- for (p = confList.next ; p != &confList ; p = p->next) {
- if (strcmp(p->key, key) == 0) {
- return p ;
- }
- }
- return NULL ;
-}
-
-/*
- * Parse `host:port'. Either `host' or `port' can be omitted.
- */
-static BOOL getHostPort(u_char *arg, struct sockaddr_in *iaddr, int lineNo)
-{
- unsigned int octets[4];
- unsigned short port;
- int digit_count;
- int octet_count;
- const char *p = arg;
-
- octets[0] = (DEFAULT_ADDR >> 24) & 0xff;
- octets[1] = (DEFAULT_ADDR >> 16) & 0xff;
- octets[2] = (DEFAULT_ADDR >> 8) & 0xff;
- octets[3] = (DEFAULT_ADDR) & 0xff;
- port = DEFAULT_PORT;
-
- /*
- * Parse an dot noted IP address.
- */
- if ('0' <= *p && *p <= '9') {
- octet_count = 0;
- while (octet_count < 4) {
- octets[octet_count] = 0;
- if (*p == '0' && '0' <= *(p + 1) && *(p + 1) <= '9') {
- WARN("getHostPort - invalid address \"%.100s\", line %d\n",
- arg, lineNo);
- return FALSE;
- }
- for (digit_count = 0; '0' <= *p && *p <= '9'; p++, digit_count++)
- octets[octet_count] = octets[octet_count] * 10 + (*p - '0');
- if (digit_count == 0 || digit_count > 3 ||
- octets[octet_count] > 255) {
- WARN("getHostPort - invalid address \"%.100s\" line %d\n",
- arg, lineNo);
- return FALSE;
- }
- octet_count++;
-
- if (octet_count != 4) {
- if (*p != '.') {
- WARN("getHostPort - malformed address \"%.100s\", "
- "line %d\n", arg, lineNo);
- return FALSE;
- }
- p++;
- }
- }
- }
-
- /*
- * Parse an optional port number preceded by `:'.
- */
- if (*p == ':') {
- port = 0;
- p++;
- if (*p == '0' && '0' <= *(p + 1) && *(p + 1) <= '9') {
- WARN("getHostPort - invalid port number \"%.100s\", line %d\n",
- arg, lineNo);
- return FALSE;
- }
- for (digit_count = 0; '0' <= *p && *p <= '9'; p++, digit_count++)
- port = port * 10 + (*p - '0');
- if (digit_count == 0 && *p == '\0') {
- port = DEFAULT_PORT;
- } else if (digit_count == 0 || digit_count > 5 || port == 0 ||
- port > 65535) {
- WARN("getHostPort - invalid port number \"%.100s\", line %d\n",
- arg, lineNo);
- return FALSE;
- }
- }
-
- if (*p != '\0') {
- WARN("getHostPort - invalid address \"%.100s\", line %d\n",
- arg, lineNo);
- return FALSE;
- }
-
- /*
- * Put the result into `address' and `port'.
- */
- iaddr->sin_addr.s_addr = htonl((octets[0] << 24) + (octets[1] << 16)
- + (octets[2] << 8) + octets[3]);
- iaddr->sin_port = htons(port);
-
- return TRUE;
-}
-
-/*
- * Parse `host:port'. `port' can be omitted.
- */
-static BOOL getHostPort2(u_char *arg, struct sockaddr_in *iaddr,
- int lineNo)
-{
- if (*arg == ':') {
- WARN("getHostPort2 - missing host name \"%.100s\", line %d\n",
- arg, lineNo);
- return FALSE;
- }
-
- return getHostPort(arg, iaddr, lineNo);
-}
-
-BOOL config_query_listen(struct sockaddr *addr)
-{
- CNFPTR pListen ;
- struct sockaddr_in *iaddr ;
-
- memset(addr, 0, sizeof(struct sockaddr)) ;
- iaddr = (struct sockaddr_in *) addr ;
-
- if ((pListen = queryData(KW_LISTEN)) == NULL) {
- iaddr->sin_addr.s_addr = htonl(DEFAULT_ADDR) ;
- iaddr->sin_port = htons(DEFAULT_PORT) ;
- return TRUE ;
- }
- if (pListen->nVal != 2) {
- WARN("config_query_listen - wrong # of args for \"%s\", line %d\n",
- KW_LISTEN, pListen->lineNo) ;
- return FALSE ;
- }
-
- if (!getHostPort(pListen->aVal[1], iaddr, pListen->lineNo)) {
- return FALSE;
- }
-
- iaddr->sin_family = AF_INET ;
-
- return TRUE ;
-}
-
-BOOL config_query_forward(struct sockaddr *addr)
-{
- CNFPTR pForward ;
- struct sockaddr_in *iaddr ;
-
- memset(addr, 0, sizeof(struct sockaddr)) ;
- iaddr = (struct sockaddr_in *) addr ;
- iaddr->sin_family = AF_INET ;
-
- if ((pForward = queryData(KW_FORWARD)) == NULL) {
- WARN("config_query_forward - \"%s\" not found in the configuration "
- "file\n", KW_FORWARD) ;
- return FALSE ;
- }
- if (pForward->nVal != 2 && pForward->nVal != 3) {
- WARN("config_query_forward - wrong # of args for \"%s\", line %d\n",
- KW_FORWARD, pForward->lineNo) ;
- return FALSE ;
- }
-
- if (!getHostPort2(pForward->aVal[1], iaddr, pForward->lineNo)) {
- return FALSE ;
- }
-
- iaddr->sin_family = AF_INET ;
-
- return TRUE ;
-}
-
-/*
- * config_query_restrict - query 'source-restrict' flag
- */
-
-BOOL config_query_restrict(BOOL *src_restrict)
-{
- CNFPTR pForward ;
-
- if ((pForward = queryData(KW_FORWARD)) == NULL) {
- *src_restrict = FALSE ;
- } else if (pForward->nVal < 3) {
- *src_restrict = FALSE ;
- } else if (strcmp(pForward->aVal[2], "bind4compat") != 0) {
- *src_restrict = FALSE ;
- } else {
- *src_restrict = TRUE ;
- }
- return TRUE ;
-}
-
-/*
- * config_query_log_on_denied - query 'log-on-denied' flag
- */
-
-BOOL config_query_log_on_denied(BOOL *flag)
-{
- CNFPTR pForward ;
-
- if ((pForward = queryData("log-on-denied")) == NULL) {
- *flag = FALSE ;
- return TRUE ;
- }
- if (pForward->nVal != 2)
- return FALSE ;
-
- if (strcmp(pForward->aVal[1], "yes") == 0)
- *flag = TRUE ;
- else if (strcmp(pForward->aVal[1], "no") == 0)
- *flag = FALSE ;
- else
- return FALSE ;
-
- return TRUE;
-}
-
-/*
- * config_query_open, config_query_more, config_query_close
- *
- * this is generic interface to access configuration data
- * for multiple entires for same key value.
- */
-
-config_ctx_t config_query_open(char *key, int *count, char ***array,
- int *lineNo)
-{
- CNFPTR p ;
-
- for (p = confList.next ; p != &confList ; p = p->next) {
- if (strcmp(p->key, key) != 0) {
- continue ;
- }
- *count = p->nVal ;
- *array = (char **) p->aVal ;
- *lineNo = p->lineNo;
- return (config_ctx_t) p ;
- }
- return NULL ;
-}
-
-config_ctx_t config_query_more(config_ctx_t ctx, int *count, char ***array,
- int *lineNo)
-{
- CNFPTR p = (CNFPTR) ctx ;
- CNFPTR np ;
-
- for (np = p->next ; np != &confList ; np = np->next) {
- if (strcmp(np->key, p->key) != 0) {
- continue ;
- }
- *count = np->nVal ;
- *array = (char **) np->aVal ;
- *lineNo = np->lineNo;
- return (config_ctx_t) np ;
- }
- return NULL ;
-}
-
-void config_query_close(config_ctx_t ctx)
-{
- /* nothing to do */
-}
-
-#ifdef TEST
-/*
- * test driver for 'config' module
- */
-
-static void dumpaddr(u_char *str, struct sockaddr *addr)
-{
- u_char *p ;
- struct sockaddr_in *iaddr = (struct sockaddr_in *) addr ;
-
- printf("%s ", str) ;
-
- p = (u_char *) &iaddr->sin_addr ;
- printf("address %d.%d.%d.%d",
- (p[0] & 0xff), (p[1] & 0xff), (p[2] & 0xff), (p[3] & 0xff)) ;
-
- p = (u_char *) &iaddr->sin_port ;
- printf(" port %d", ((p[0] & 0xff) * 256 + (p[1] & 0xff))) ;
-
- printf("\n") ;
-}
-
-static void dumpvalue(char *key, int count, char **array)
-{
- int i ;
-
- for (i = 0 ; i < count ; i++) {
- printf("%s ", array[i]) ;
- }
- printf("\n") ; fflush(stdout) ;
-}
-
-int main(int ac, char *av[])
-{
- int stat ;
- struct sockaddr addr ;
- int count ;
- char **array ;
- config_ctx_t ctx ;
- int lineNo;
-
- if ((stat = config_load(ac, av)) != TRUE) {
- printf("config_load failed %d\n", stat) ;
- return 1 ;
- }
- config_dump(stdout) ;
-
- if (config_query_value(KW_LISTEN, &count, &array, &lineNo) == TRUE) {
- dumpvalue("listen", count, array) ;
- }
- if (config_query_value(KW_FORWARD, &count, &array, &lineNo) == TRUE) {
- dumpvalue("forward", count, array) ;
- }
-
- ctx = config_query_open("client-translation", &count, &array, &lineNo) ;
- while (ctx != NULL) {
- dumpvalue("client-translation", count, array) ;
- ctx = config_query_more(ctx, &count, &array, &lineNo) ;
- }
- config_query_close(ctx) ;
-
- if (config_query_listen(&addr) != TRUE) {
- printf("no \"listen\" data\n") ;
- } else {
- dumpaddr("listen", &addr) ;
- }
-
- if (config_query_forward(&addr) != TRUE) {
- printf("no \"forward\" data\n") ;
- } else {
- dumpaddr("forward", &addr) ;
- }
-
- config_free() ;
- return 0 ;
-}
-#endif /* TEST */
diff --git a/contrib/idn/mdnkit/mdnsproxy/proxycnf.h b/contrib/idn/mdnkit/mdnsproxy/proxycnf.h
deleted file mode 100644
index 7390098e..00000000
--- a/contrib/idn/mdnkit/mdnsproxy/proxycnf.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * proxycnf.h - mDNS Proxy, Configure Proxy Server
- */
-
-/*
- * Copyright (c) 2000 Japan Network Information Center. All rights reserved.
- *
- * By using this file, you agree to the terms and conditions set forth bellow.
- *
- * LICENSE TERMS AND CONDITIONS
- *
- * The following License Terms and Conditions apply, unless a different
- * license is obtained from Japan Network Information Center ("JPNIC"),
- * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
- * Chiyoda-ku, Tokyo 101-0047, Japan.
- *
- * 1. Use, Modification and Redistribution (including distribution of any
- * modified or derived work) in source and/or binary forms is permitted
- * under this License Terms and Conditions.
- *
- * 2. Redistribution of source code must retain the copyright notices as they
- * appear in each source code file, this License Terms and Conditions.
- *
- * 3. Redistribution in binary form must reproduce the Copyright Notice,
- * this License Terms and Conditions, in the documentation and/or other
- * materials provided with the distribution. For the purposes of binary
- * distribution the "Copyright Notice" refers to the following language:
- * "Copyright (c) Japan Network Information Center. All rights reserved."
- *
- * 4. Neither the name of JPNIC may be used to endorse or promote products
- * derived from this Software without specific prior written approval of
- * JPNIC.
- *
- * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * 6. Indemnification by Licensee
- * Any person or entities using and/or redistributing this Software under
- * this License Terms and Conditions shall defend indemnify and hold
- * harmless JPNIC from and against any and all judgements damages,
- * expenses, settlement liabilities, cost and other liabilities of any
- * kind as a result of use and redistribution of this Software or any
- * claim, suite, action, litigation or proceeding by any third party
- * arising out of or relates to this License Terms and Conditions.
- *
- * 7. Governing Law, Jurisdiction and Venue
- * This License Terms and Conditions shall be governed by and and
- * construed in accordance with the law of Japan. Any person or entities
- * using and/or redistributing this Software under this License Terms and
- * Conditions hereby agrees and consent to the personal and exclusive
- * jurisdiction and venue of Tokyo District Court of Japan.
- */
-
-/* $Id: proxycnf.h,v 1.1.2.1 2002/02/08 12:14:59 marka Exp $ */
-
-#ifndef PROXYCNF_H
-#define PROXYCNF_H 1
-
-/*
- * CONFIG_PATH
- * where configuration file placed
- */
-
-#ifndef CONFIG_PATH
-#ifdef UNIX
-#define CONFIG_PATH "/usr/local/etc/"
-#endif
-#ifdef WIN32
-#define CONFIG_PATH "$(SystemRoot)/"
-#endif
-#ifdef OS2
-#define CONFIG_PATH "$(ETC)/"
-#endif
-#endif /* CONFIG_PATH */
-
-/*
- * CONFIG_FILE
- * name of configuration file
- */
-
-#ifndef CONFIG_FILE
-#ifdef UNIX
-#define CONFIG_FILE "mdnsproxy.conf"
-#endif
-#ifdef WIN32
-#define CONFIG_FILE "mdnsproxy.cnf"
-#endif
-#ifdef OS2
-#define CONFIG_FILE "mdnsproxy.cnf"
-#endif
-#endif /* CONFIG_FILE */
-
-/*
- * CONFIG_HOME
- * debugging support, $HOME environment name
- */
-
-#ifndef CONFIG_HOME
-#ifdef UNIX
-#define CONFIG_HOME "$(HOME)/"
-#endif
-#ifdef WIN32
-#define CONFIG_HOME "$(HOMEPATH)/"
-#endif
-#ifdef OS2
-#define CONFIG_HOME "$(HOME)/"
-#endif
-#endif /* CONFIG_HOME */
-
-/*
- * Commands used in configuration file
- */
-#define KW_LISTEN "listen"
-#define KW_FORWARD "forward"
-#define KW_CLIENT_ENCODING "client-encoding"
-#define KW_MDN_CONF_FILE "mdn-conf-file"
-#define KW_LOG_FILE "log-file"
-#define KW_LOG_LEVEL "log-level"
-#define KW_MDN_LOG_LEVEL "mdn-log-level"
-#define KW_USER_ID "user-id"
-#define KW_GROUP_ID "group-id"
-#define KW_ROOT_DIRECTORY "root-directory"
-#define KW_ALLOW_ACCESS "allow-access"
-#define KW_LOG_ON_DENIED "log-on-denied"
-#define KW_SYSLOG_FACILITY "syslog-facility"
-
-/* The following commands are obsoleted. */
-#define KW_CLIENT_TRANSLATION "client-translation"
-#define KW_ALTERNATE_ENCODING "alternate-encoding"
-#define KW_NORMALIZE "normalize"
-#define KW_SERVER_TRANSLATION "server-translation"
-#define KW_ENCODING_ALIAS_FILE "encoding-alias-file"
-
-/*
- * Command line options.
- */
-#define CMDOPT_LOGFILE "-logfile"
-#define CMDOPT_DAEMON "-daemon"
-#define CMDOPT_CONFIG "-config"
-#define CMDOPT_VERSION "-version"
-
-#endif /* PROXYCNF_H */
diff --git a/contrib/idn/mdnkit/mdnsproxy/server.c b/contrib/idn/mdnkit/mdnsproxy/server.c
deleted file mode 100644
index 844d1227..00000000
--- a/contrib/idn/mdnkit/mdnsproxy/server.c
+++ /dev/null
@@ -1,1457 +0,0 @@
-/*
- * server.c - mDNS Proxy, proxy server core
- */
-
-/*
- * Copyright (c) 2000 Japan Network Information Center. All rights reserved.
- *
- * By using this file, you agree to the terms and conditions set forth bellow.
- *
- * LICENSE TERMS AND CONDITIONS
- *
- * The following License Terms and Conditions apply, unless a different
- * license is obtained from Japan Network Information Center ("JPNIC"),
- * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
- * Chiyoda-ku, Tokyo 101-0047, Japan.
- *
- * 1. Use, Modification and Redistribution (including distribution of any
- * modified or derived work) in source and/or binary forms is permitted
- * under this License Terms and Conditions.
- *
- * 2. Redistribution of source code must retain the copyright notices as they
- * appear in each source code file, this License Terms and Conditions.
- *
- * 3. Redistribution in binary form must reproduce the Copyright Notice,
- * this License Terms and Conditions, in the documentation and/or other
- * materials provided with the distribution. For the purposes of binary
- * distribution the "Copyright Notice" refers to the following language:
- * "Copyright (c) Japan Network Information Center. All rights reserved."
- *
- * 4. Neither the name of JPNIC may be used to endorse or promote products
- * derived from this Software without specific prior written approval of
- * JPNIC.
- *
- * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * 6. Indemnification by Licensee
- * Any person or entities using and/or redistributing this Software under
- * this License Terms and Conditions shall defend indemnify and hold
- * harmless JPNIC from and against any and all judgements damages,
- * expenses, settlement liabilities, cost and other liabilities of any
- * kind as a result of use and redistribution of this Software or any
- * claim, suite, action, litigation or proceeding by any third party
- * arising out of or relates to this License Terms and Conditions.
- *
- * 7. Governing Law, Jurisdiction and Venue
- * This License Terms and Conditions shall be governed by and and
- * construed in accordance with the law of Japan. Any person or entities
- * using and/or redistributing this Software under this License Terms and
- * Conditions hereby agrees and consent to the personal and exclusive
- * jurisdiction and venue of Tokyo District Court of Japan.
- */
-
-#ifndef lint
-static char *rcsid = "$Id: server.c,v 1.1.2.1 2002/02/08 12:15:00 marka Exp $";
-#endif
-
-#include <config.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef WIN32
-#include <windows.h>
-#include <winsock.h>
-#else /* for normal systems */
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
-#include <netinet/in.h>
-#include <errno.h>
-#endif
-
-#include "mdnsproxy.h"
-
-#ifdef WIN32
-#define close(s) closesocket(s)
-#define EWOULDBLOCK WSAEWOULDBLOCK
-#endif
-
-#ifndef max
-#define max(x, y) ((x) > (y) ? (x) : (y))
-#endif
-
-/*
- * Status of receiving data or accept a TCP connection.
- */
-#define SUCCESS 0 /* succeeded */
-#define FAILURE 1 /* failed */
-#define DENIED 2 /* denied */
-
-/*
- * send buffer for TCP
- * hold sending data when sending socket blocked
- */
-
-typedef struct _SNDBUF {
- struct _SNDBUF *prev ;
- struct _SNDBUF *next ;
- int leng ; /* data length in the buffer */
- int sent ; /* data have been sent */
- int size ; /* size of this bufefr */
- u_char buff[1] ; /* 'size' array follows */
-} SNDREC, *SNDPTR ;
-
-/*
- * recv buffer for TCP
- * hold incomplete message
- */
-
-typedef struct _RCVBUF {
- int stat ; /* what data receiving now */
- int leng ; /* length of the message */
- int recv ; /* message have been received */
- int size ; /* size of this buffer */
- u_char *buff ; /* points 'size' array of char */
-} RCVREC, *RCVPTR ;
-
-#define RCV_STAT_LEN1 0 /* waiting 1st byte of length */
-#define RCV_STAT_LEN2 1 /* waiting 2nd byte of length */
-#define RCV_STAT_DATA 2 /* waiting message data */
-
-/*
- * transport control block
- * is used to handle pending recv/send data of the socket
- */
-
-typedef struct _NETREC {
- struct _NETREC *prev ;
- struct _NETREC *next ;
- int sock ; /* socket to do network I/O */
- int proto ; /* TCP or UDP */
- int type ; /* see below */
- struct sockaddr peer ; /* peer of this transoport */
- SNDREC send ; /* pending send data (TPC) */
- RCVREC recv ; /* pending recv message */
-} NETREC, *NETPTR ;
-
-#define NET_LISTEN 1 /* is proxy's listening socket */
-#define NET_CLIENT 2 /* is connection from client */
-#define NET_SERVER 3 /* is transport to server */
-
-static NETREC listNet = { 0 } ; /* list of transports */
-
-/*
- * allocate/dispose buffer for SND/RCV buffer managements
- * simply mapped to malloc/free, but may be
- * re-maped to spceific function if speed required
- */
-
-#define xalloc(x) malloc((x))
-#define xfree(p) free((p))
-
-/*
- * Whether to log denied access from client.
- */
-static int logOnDenied = 0;
-
-/*
- * transientError - utility for handling "soft" errors
- */
-
-static BOOL transientError(int eno)
-{
- if (
-#ifdef EAGAIN
- eno == EAGAIN ||
-#endif
-#ifdef EWOULDBLOCK
- eno == EWOULDBLOCK ||
-#endif
-#ifdef EINTR
- eno == EINTR ||
-#endif
- eno == 0)
- return TRUE ;
- else
- return FALSE ;
-}
-
-/*
- * addrEq, addrFmt - utilities for handling address
- */
-
-static BOOL addrEq(struct sockaddr *a1, struct sockaddr *a2)
-{
- struct sockaddr_in *ip1 = (struct sockaddr_in *) a1 ;
- struct sockaddr_in *ip2 = (struct sockaddr_in *) a2 ;
-
- if (ip1->sin_addr.s_addr != ip2->sin_addr.s_addr) {
- return FALSE ;
- }
- if (ip1->sin_port != ip2->sin_port) {
- return FALSE ;
- }
- return TRUE ;
-}
-
-static u_char fmtbuff[64] ;
-
-static u_char *addrFmt(struct sockaddr *addr, int proto)
-{
- struct sockaddr_in *iaddr = (struct sockaddr_in *) addr ;
- u_char *ap ;
- u_char *pp ;
-
- ap = (u_char *) &iaddr->sin_addr ;
- pp = (u_char *) &iaddr->sin_port ;
-
- sprintf(fmtbuff, "%s:%d.%d.%d.%d:%d",
- (proto == SOCK_STREAM ? "TCP" : "UDP"),
- (ap[0] & 0xff), (ap[1] & 0xff), (ap[2] & 0xff), (ap[3] & 0xff),
- ((pp[0] & 0xff) * 256 + (pp[1] & 0xff)) ) ;
-
- return fmtbuff ;
-}
-
-/*
- * netCreate, netDispose - create/dispose transport control block
- */
-
-#define SZRCVBUF 1024
-
-static NETPTR netCreate(int sock, struct sockaddr *peer, int proto, int type)
-{
- NETPTR pNet, prev, next ;
- u_char *pBuf ;
-
- if (listNet.prev == NULL || listNet.next == NULL) {
- WARN("netCreate - transport list is not initialized\n") ;
- listNet.prev = &listNet ;
- listNet.next = &listNet ;
- }
-
- pNet = (NETPTR) xalloc(sizeof(NETREC)) ;
- pBuf = (u_char *) xalloc(SZRCVBUF) ;
-
- if (pNet == NULL || pBuf == NULL) {
- WARN("netCreate - cannot allocate buffer\n") ;
- if (pNet != NULL) xfree(pNet) ;
- if (pBuf != NULL) xfree(pBuf) ;
- return NULL ;
- }
- memset(pNet, 0, sizeof(NETREC)) ;
-
- pNet->sock = sock ;
- pNet->proto = proto ;
- pNet->type = type ;
-
- if (peer != NULL) {
- memcpy(&pNet->peer, peer, sizeof(struct sockaddr)) ;
- }
-
- pNet->send.prev = &pNet->send ;
- pNet->send.next = &pNet->send ;
- pNet->recv.stat = RCV_STAT_LEN1 ;
- pNet->recv.leng = 0 ;
- pNet->recv.recv = 0 ;
- pNet->recv.size = SZRCVBUF ;
- pNet->recv.buff = pBuf ;
-
- prev = listNet.prev ;
- next = prev->next ;
-
- prev->next = pNet ;
- next->prev = pNet ;
- pNet->prev = prev ;
- pNet->next = next ;
-
- return pNet ;
-}
-
-static void netDispose(NETPTR pNet)
-{
- NETPTR p ;
- SNDPTR pSnd ;
-
- if (listNet.prev == NULL || listNet.next == NULL) {
- WARN("netDispose - transport list is not initialized\n") ;
- listNet.prev = &listNet ;
- listNet.next = &listNet ;
- }
-
- /*
- * unlink from transport list
- */
-
- for (p = listNet.next ; p != &listNet ; p = p->next) {
- if (p == pNet) {
- break ;
- }
- }
- if (p == pNet) { /* safe to unlink it */
- pNet->prev->next = pNet->next ;
- pNet->next->prev = pNet->prev ;
- }
-
- /*
- * dispose control block resources
- */
-
- if (pNet->send.prev == NULL || pNet->send.next == NULL) {
- WARN("netDispose - un-initialized SNDREC\n") ;
- pNet->send.prev = &pNet->send ;
- pNet->send.next = &pNet->send ;
- }
- while ((pSnd = pNet->send.next) != &pNet->send) {
- pSnd->prev->next = pSnd->next ;
- pSnd->next->prev = pSnd->prev ;
- xfree(pSnd) ;
- }
- if (pNet->recv.buff != NULL) {
- xfree(pNet->recv.buff) ;
- }
- close(pNet->sock) ;
- xfree(pNet) ;
-}
-
-/*
- * netExpand - expand receive buffer
- */
-
-static BOOL netExpand(NETPTR p)
-{
- int len ;
- u_char *np ;
-
- if (p->recv.size > p->recv.leng) {
- return TRUE ;
- }
-
- len = 1024 * ((p->recv.leng + 1023) / 1024) ;
-
- TRACE("netExpand %d -> %d\n", p->recv.size, len) ;
-
- if ((np = xalloc(len)) == NULL) {
- WARN("netExpand - cannot allocate memory\n") ;
- return FALSE ;
- }
- if (p->recv.recv > 0) {
- memcpy(np, p->recv.buff, p->recv.recv) ;
- }
- xfree(p->recv.buff) ;
- p->recv.buff = np ;
- p->recv.size = len ;
-
- return TRUE ;
-}
-
-/*
- * tcpSend, tcpQueue, tcpFlush - send message over stream socket
- *
- * tcpSend - send message over TCP socket
- * tcpQueue - en-queue message if stream blocked
- * tcpFlush - flush pending messages
- */
-
-static int tcpSend(int sock, u_char *msg, int len)
-{
- int n, cnt = 0 ;
-
- while (len > 0) {
- if ((n = send(sock, msg, len, 0)) > 0) {
- msg += n ;
- len -= n ;
- cnt += n ;
- continue ;
- }
- if (!transientError(errno)) {
- WARN("tcpSend - send error %d\n", errno) ;
- return -1 ;
- }
- break ;
- }
- return cnt ;
-}
-
-static BOOL tcpQueue(NETPTR p, u_char *msg, int len)
-{
- SNDPTR sp, prev, next ;
-
- if ((sp = (SNDPTR) xalloc(sizeof(SNDREC) + len)) == NULL) {
- WARN("tcpQueue - cannot allocate buffer\n") ;
- return FALSE ;
- }
-
- sp->sent = 0 ;
- sp->leng = len ;
- sp->size = len ;
- memcpy(sp->buff, msg, len) ;
-
- prev = p->send.prev ;
- next = prev->next ;
- prev->next = sp ;
- next->prev = sp ;
- sp->next = next ;
- sp->prev = prev ;
-
- return TRUE ;
-}
-
-static BOOL tcpFlush(NETPTR p)
-{
- SNDPTR sp ;
- int n, len ;
-
- if (p->proto != SOCK_STREAM) {
- WARN("tcpFlush - flushing on non-stream socket\n") ;
- return FALSE ;
- }
- if (p->send.prev == NULL || p->send.prev == NULL) {
- WARN("tcpFlush - send buffer is not initialized\n") ;
- p->send.prev = &p->send ;
- p->send.next = &p->send ;
- }
-
- while ((sp = p->send.next) != &p->send) {
-
- /*
- * try to send data
- */
-
- if ((len = sp->leng - sp->sent) > 0) {
- if ((n = tcpSend(p->sock, &sp->buff[sp->sent], len)) < 0) {
- WARN("tcpFlush - send error %d\n", errno) ;
- return FALSE ;
- }
- if (n == 0) {
- TRACE("tcpFlush - blocked\n") ;
- return TRUE ;
- }
- sp->sent += n ;
- }
-
- /*
- * if no more data in send buffer, unlink and free
- */
-
- if ((len = sp->leng - sp->sent) <= 0) {
- sp->prev->next = sp->next ;
- sp->next->prev = sp->prev ;
- xfree(sp) ;
- }
- }
- return TRUE ;
-}
-
-/*
- * Server Control Variables
- */
-
-static BOOL servActive = FALSE ;
-
-static NETPTR listenTcp = NULL ; /* proxy's listening socket */
-static NETPTR listenUdp = NULL ; /* proxy's listening socket */
-
-static struct sockaddr serverDefaultAddr = { 0 } ;
-static BOOL serverRestrictPort = FALSE ;
-
-/*
- * server_done - finalize server
- *
- * is also used when 'server_init' failed in initialization sequence
- *
- * using module level utilities
- *
- * netDispose dispose transport control block
- */
-
-void server_done(void)
-{
- NETPTR p ;
-
- if (listNet.prev == NULL || listNet.next == NULL) {
- listNet.prev = &listNet ;
- listNet.next = &listNet ;
- }
- while ((p = listNet.next) != &listNet) {
- netDispose(p) ;
- }
-}
-
-/*
- * server_init - initialize server
- *
- * using sub-functions
- *
- * initTcp create socket to listening TCP connection
- * initUdp create socket to listening UDP message
- *
- * and also using module level utilities
- *
- * netCreate create transport control block
- *
- * also use 'server_done' to cleanup resources
- */
-
-static NETPTR initTcp(void)
-{
- NETPTR p ;
- int sock ;
- int one = 1 ;
- struct sockaddr addr ;
-
- if (config_query_listen(&addr) != TRUE) {
- WARN("initTcp - no listen address\n") ;
- return NULL ;
- }
-
- if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- WARN("initTcp - cannot create TCP socket\n") ;
- return NULL ;
- }
-
- setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)) ;
-
- if (bind(sock, &addr, sizeof(addr)) < 0) {
- WARN("initTcp - cannot bind TCP socket\n") ;
- close(sock) ;
- return NULL ;
- }
- if (listen(sock, 5) < 0) {
- WARN("initTcp - cannot listen on TCP socket\n") ;
- close(sock) ;
- return NULL ;
- }
- if ((p = netCreate(sock, &addr, SOCK_STREAM, NET_LISTEN)) == NULL) {
- WARN("initTcp - cannot create control block\n") ;
- close(sock) ;
- return NULL ;
- }
- return p ;
-}
-
-static NETPTR initUdp(void)
-{
- NETPTR p ;
- int sock ;
- int one = 1 ;
- struct sockaddr addr ;
-
- if (config_query_listen(&addr) != TRUE) {
- WARN("initUdp - no listen address\n") ;
- return NULL ;
- }
-
- if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
- WARN("initUdp - cannot create UDP socket\n") ;
- return NULL ;
- }
-
- setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)) ;
-
- if (bind(sock, &addr, sizeof(addr)) < 0) {
- WARN("initUdp - cannot bind UDP socket\n") ;
- close(sock) ;
- return NULL ;
- }
- if ((p = netCreate(sock, &addr, SOCK_DGRAM, NET_LISTEN)) == NULL) {
- WARN("initUdp - cannot create control block\n") ;
- close(sock) ;
- return NULL ;
- }
- return p ;
-}
-
-/*
- * server_init - initialize proxy server
- */
-
-BOOL server_init(int ac, char *av[])
-{
- /*
- * initialize transport list
- */
-
- listNet.prev = &listNet ;
- listNet.next = &listNet ;
-
- /*
- * setup transports
- */
-
- listenTcp = initTcp() ;
- listenUdp = initUdp() ;
-
- if (listenTcp == NULL || listenUdp == NULL) {
- WARN("server_init - cannot create proxy's listening port\n") ;
- server_done() ;
- return FALSE ;
- }
-
- if (config_query_forward(&serverDefaultAddr) != TRUE) {
- WARN("server_init - no DNS server address\n") ;
- server_done() ;
- return FALSE ;
- }
- if (config_query_restrict(&serverRestrictPort) != TRUE) {
- WARN("server_init - cannot query 'serverRestrictPort' flag\n") ;
- server_done() ;
- return FALSE ;
- }
- if (config_query_log_on_denied(&logOnDenied) != TRUE) {
- WARN("syntax error at log-on-denied line\n") ;
- server_done() ;
- return FALSE ;
- }
-
- /*
- * initialize translator
- */
-
- if (translate_initialize() != TRUE) {
- WARN("server_init - translation configuration failed\n") ;
- server_done() ;
- return FALSE ;
- }
-
- /*
- * initialize ACL.
- */
-
- if (acl_initialize() != TRUE) {
- WARN("server_init - access list configuration failed\n") ;
- server_done() ;
- return FALSE ;
- }
-
- /*
- * now server is ready, turn on active flags now
- */
-
- servActive = TRUE ;
-
- return TRUE ;
-}
-
-/*
- * server_stop - request to stop server
- *
- * simply turn off 'servActive' control flag.
- * then 'server_loop' terminate
- */
-
-void server_stop(void)
-{
- servActive = FALSE ;
-}
-
-/*
- * server_loop - proxy server's message loop
- *
- * using sub-funcstions
- *
- * setRdFds listup sockets to check read ready
- * setWtFds listup sockets to check write ready
- * sockAccept accept connection from client
- * sockRecvTcp receive message over TCP
- * sockRecvUdp receive message over UDP
- * sockDispatch dispatch on ready sockets
- * sockValidate validate sockets
- * timerDispatch entry of timer processing
- *
- * and also using module level utilities
- *
- * netCreate create transport control block
- * netDispose dispose transport control block
- * tcpFlush send pending message
- * addrFmt formatting address (& proto)
- */
-
-/*
- * setRdFds, setWtFds - listup socket to check if ready
- */
-
-static int setRdFds(fd_set *rfds)
-{
- int maxfd = 0 ;
- NETPTR p ;
-
- /*
- * listup sockets to check read ready
- */
-
- if (listNet.prev == NULL || listNet.next == NULL) {
- WARN("setRdFds - listNet is not initialized\n") ;
- listNet.prev = &listNet ;
- listNet.next = &listNet ;
- }
- for (p = listNet.next ; p != &listNet ; p = p->next) {
- FD_SET(p->sock, rfds) ;
- maxfd = max(maxfd, p->sock) ;
- }
- return maxfd ;
-}
-
-static int setWtFds(fd_set *wfds)
-{
- int maxfd = 0 ;
- NETPTR p ;
-
- /*
- * listup sockets to check read ready
- */
-
- if (listNet.prev == NULL || listNet.next == NULL) {
- WARN("setRdFds - listNet is not initialized\n") ;
- listNet.prev = &listNet ;
- listNet.next = &listNet ;
- }
- for (p = listNet.next ; p != &listNet ; p = p->next) {
- if (p->send.prev == NULL || p->send.next == NULL) {
- WARN("setWtFds - send buffer is not initialized\n") ;
- p->send.prev = &p->send ;
- p->send.next = &p->send ;
- }
- if (p->send.next != &p->send) {
- FD_SET(p->sock, wfds) ;
- maxfd = max(maxfd, p->sock) ;
- }
- }
- return maxfd ;
-}
-
-/*
- * sockAccept - accept connection from client
- */
-
-static int sockAccept(NETPTR p)
-{
- NETPTR np ;
- int ns, addrlen ;
- struct sockaddr addr ;
- struct sockaddr peer ;
-
- memset(&addr, 0, sizeof(addr)) ;
- memset(&peer, 0, sizeof(peer)) ;
-
- addrlen = sizeof(addr) ;
-
- if ((ns = accept(p->sock, &addr, &addrlen)) < 0) {
- WARN("sockAccept - cannot accept connection %d\n", errno) ;
- return FAILURE ;
- }
-
- addrlen = sizeof(peer) ;
- getpeername(ns, &peer, &addrlen) ;
-
- if (!acl_test(&peer)) {
- if (logOnDenied) {
- WARN("sockAccept - deny access from %s\n",
- addrFmt(&peer, SOCK_STREAM));
- }
- shutdown(ns, 2) ;
- close(ns) ;
- return DENIED ;
- }
-
- if ((np = netCreate(ns, &peer, SOCK_STREAM, NET_CLIENT)) == NULL) {
- WARN("sockAccept - cannot create control block\n") ;
- close(ns) ;
- return FAILURE ;
- }
-
- TRACE("sockAccept - accept connection from %s on socket %d\n", addrFmt(&peer, SOCK_STREAM), ns) ;
-
- return SUCCESS ;
-}
-
-/*
- * sockRecvTcp, sockRecvUdp - receive message
- *
- * when message complete, call 'notify_message' to
- * notify message arrival.
- */
-
-static int sockRecvTcp(NETPTR p)
-{
- int n, len ;
- u_char buff[2] ;
- u_char *bp ;
-
- /*
- * validate transport
- */
-
- if (p == NULL || p->proto != SOCK_STREAM) {
- WARN("sockRecvTcp - bad parameter\n") ;
- return FAILURE ;
- }
- if (p->recv.buff == NULL || p->recv.size == 0) {
- WARN("sockRecvTcp - no receiver buffer\n") ;
- return FAILURE ;
- }
-
- /*
- * when receiving message over TCP, constuct state machine with
- * RCVBUF's status.
- */
-
- if (p->recv.stat == RCV_STAT_LEN1) {
- if ((n = recv(p->sock, buff, 2, 0)) <= 0) {
- if (errno == EWOULDBLOCK) {
- return SUCCESS ;
- }
- WARN("sockRecvTcp - recv error %d on socket %d, STAT_LEN1\n", errno, p->sock) ;
- return FAILURE ;
- }
- if (n == 1) {
- p->recv.leng = ((int) (buff[0] & 0xff)) * 256 ;
- p->recv.stat = RCV_STAT_LEN2 ;
- return SUCCESS ; /* blocked, try later */
- }
- p->recv.leng = ((int) (buff[0] & 0xff)) * 256 + ((int) (buff[1] & 0xff)) ;
- p->recv.stat = RCV_STAT_DATA ;
- /* then fall through */
- }
-
- if (p->recv.stat == RCV_STAT_LEN2) {
- if ((n = recv(p->sock, buff, 1, 0)) <= 0) {
- if (errno == EWOULDBLOCK) {
- return SUCCESS ;
- }
- WARN("sockRecvTcp - recv error %d on socket %d, STAT_LEN2\n", errno, p->sock) ;
- return FAILURE ;
- }
- p->recv.leng += ((int) (buff[0] & 0xff)) ;
- p->recv.stat = RCV_STAT_DATA ;
- /* then fall through */
- }
-
- if (p->recv.stat == RCV_STAT_DATA) {
- if (p->recv.size < p->recv.leng) {
- if (netExpand(p) != TRUE) {
- WARN("sockRecvTcp - cannot expand recv buffer\n") ;
- return FAILURE ;
- }
- }
-
- bp = &p->recv.buff[p->recv.recv] ;
- len = p->recv.leng - p->recv.recv ;
-
- if ((n = recv(p->sock, bp, len, 0)) <= 0) {
- if (errno == EWOULDBLOCK) {
- return SUCCESS ;
- }
- WARN("sockRecvTcp - recv error %d on socket %d, "
- "STAT_DATA %d (%d/%d)\n",
- errno, p->sock, len, p->recv.recv, p->recv.leng) ;
- return FAILURE ;
- }
- if ((p->recv.recv += n) < p->recv.leng) {
- return SUCCESS ; /* still in-complete */
- }
-
- /*
- * message complete, notify it
- */
-
- notify_message(&p->peer, SOCK_STREAM, p->recv.buff, p->recv.leng) ;
-
- /*
- * reset recv buffer
- */
-
- p->recv.stat = RCV_STAT_LEN1 ;
- p->recv.leng = 0 ;
- p->recv.recv = 0 ;
-
- return SUCCESS ;
- }
- WARN("sockRecvTcp - something wrong\n") ;
- return FAILURE ;
-}
-
-static int sockRecvUdp(NETPTR p)
-{
- int n, fromlen ;
- struct sockaddr fromaddr ;
-
- /*
- * validate transport
- */
-
- if (p == NULL || p->proto != SOCK_DGRAM) {
- WARN("sockRecvUdp - bad parameter\n") ;
- return FAILURE ;
- }
- if (p->recv.buff == NULL || p->recv.size == 0) {
- WARN("sockRecvUdp - no receiver buffer\n") ;
- return FAILURE ;
- }
-
- /*
- * receive over UDP
- */
-
- fromlen = sizeof(fromaddr) ;
-
- n = recvfrom(p->sock, p->recv.buff, p->recv.size, 0, &fromaddr, &fromlen) ;
-
- if (n == 0) {
- WARN("sockRecvUdp - no data\n") ;
- return SUCCESS ;
- } else if (n < 0) {
- if (transientError(errno))
- return SUCCESS ;
- switch (errno) {
-#ifdef ECONNREFUSED
- case ECONNREFUSED:
-#endif
-#ifdef ENETUNREACH
- case ENETUNREACH:
-#endif
-#ifdef EHOSTUNREACH
- case EHOSTUNREACH:
-#endif
- WARN("sockRecvUdp - recv error %d (ignored)\n", errno) ;
- return SUCCESS ;
- default:
- WARN("sockRecvUdp - recv error %d\n", errno) ;
- return FAILURE ;
- }
- }
-
- if (!addrEq(&fromaddr, &serverDefaultAddr) && !acl_test(&fromaddr)) {
- if (logOnDenied) {
- WARN("sockRecvUdp - deny access from %s\n",
- addrFmt(&fromaddr, SOCK_DGRAM));
- }
- return DENIED ;
- }
-
- /*
- * notify message arrival
- */
-
- notify_message(&fromaddr, SOCK_DGRAM, p->recv.buff, n) ;
-
- return SUCCESS ;
-}
-
-/*
- * sockDispatch - process on ready sockets
- */
-
-static void sockDispatch(int nfds, fd_set *rfds, fd_set *wfds)
-{
- NETPTR p, np ;
- int stat ;
-
- /*
- * process on ready sockets
- */
-
- if (listNet.prev == NULL || listNet.next == NULL) {
- WARN("sockDispatch - listNet is not initialized\n") ;
- listNet.prev = &listNet ;
- listNet.next = &listNet ;
- }
- for (p = listNet.next ; p != &listNet ; p = np) {
-
- np = p->next ;
- stat = SUCCESS ; /* assume no problem */
-
- /*
- * if receiving socket ready, then
- *
- * LISTEN TCP accept connection
- * LISTEN UDP receive message
- * CLIENT receive message
- * SERVER receive message
- */
-
- if (FD_ISSET(p->sock, rfds)) {
- if (p->type != NET_LISTEN) {
- if (p->proto == SOCK_STREAM) {
- stat = sockRecvTcp(p) ;
- } else {
- stat = sockRecvUdp(p) ;
- }
- } else if (p->proto == SOCK_DGRAM) {
- stat = sockRecvUdp(p) ;
- } else { /* connect request on listening TCP socket */
- stat = sockAccept(p) ;
- }
- }
-
- /*
- * if send socket ready, then send pending message
- *
- * don't check transport type, protocol, but
- * this happens only for TCP socket to CLIENT/SERVER
- */
-
- if (stat == SUCCESS && FD_ISSET(p->sock, wfds)) {
- tcpFlush(p) ;
- }
-
- /*
- * if something wrong on socket, dispose it
- */
-
- if (stat == FAILURE) {
- if (p->type == NET_LISTEN || p->proto == SOCK_DGRAM) {
- WARN("sockDispatch - error on listening socket\n") ;
- server_stop() ;
- } else {
- WARN("sockDispatch - error on socket %d\n", p->sock) ;
- }
- netDispose(p) ;
- }
- }
-}
-
-/*
- * sockValidate - validate socket when select error
- */
-
-static void sockValidate(int nfds, fd_set *rfds, fd_set *wfds)
-{
- NETPTR p, np ;
- fd_set fds ;
- struct timeval tm ;
-
- TRACE("sockValidate\n") ;
-
- FD_ZERO(&fds) ;
- tm.tv_sec = 0 ;
- tm.tv_usec = 0 ;
-
- if (listNet.prev == NULL || listNet.next == NULL) {
- WARN("sockValidate - listNet is not initialized\n") ;
- listNet.prev = &listNet ;
- listNet.next = &listNet ;
- }
-
- for (p = listNet.next ; p != &listNet ; p = np) {
-
- np = p->next ;
-
- /*
- * check if socket is still available
- */
-
- FD_SET(p->sock, &fds) ;
-
- if (!FD_ISSET(p->sock, rfds) && !FD_ISSET(p->sock, wfds)) {
- FD_CLR(p->sock, &fds) ;
- continue ;
- }
- if (select(p->sock + 1, &fds, NULL, NULL, &tm) >= 0) {
- FD_CLR(p->sock, &fds) ;
- continue ;
- }
- FD_CLR(p->sock, &fds) ;
-
- /*
- * something wrong on socket
- */
-
- if (p->type == NET_LISTEN) {
- WARN("sockValidate - closed listening socket\n") ;
- server_stop() ;
- } else {
- WARN("sockValidate - closed socket %d\n", p->sock) ;
- }
- netDispose(p) ;
- }
-}
-
-/*
- * timerDispatch - entry of timer processing
- */
-
-static time_t timeLast = 0 ; /* last time of timer process */
-static time_t timeWait = 10 ; /* wait till next timer process */
-
-static void timerDispatch(void)
-{
- time_t t = time(NULL) ;
-
- /*
- * do timer process every 'timeWait' interval
- */
-
- if ((t - timeLast) < timeWait) {
- return ;
- }
-
- /*
- * call timer processes here
- */
-
- notify_timer() ;
-
- /*
- * update timer
- */
-
- timeLast = t ;
-}
-
-/*
- * server_loop - proxy's main, select loop
- */
-
-void server_loop(void)
-{
- struct timeval tm ;
- fd_set rfds, wfds ;
- int maxrfd, maxwfd ;
- int n, nfds ;
-
- while (servActive) {
-
- FD_ZERO(&rfds) ;
- FD_ZERO(&wfds) ;
-
- maxrfd = setRdFds(&rfds) ;
- maxwfd = setWtFds(&wfds) ;
- nfds = max(maxrfd, maxwfd) + 1 ;
-
- tm.tv_sec = 10 ;
- tm.tv_usec = 0 ;
-
- if (maxwfd == 0) {
- n = select(nfds, &rfds, NULL, NULL, &tm) ;
- } else {
- n = select(nfds, &rfds, &wfds, NULL, &tm) ;
- }
-
- if (n > 0) {
- sockDispatch(nfds, &rfds, &wfds) ;
- } else if (n < 0) {
- if (!transientError(errno)) {
- sockValidate(nfds, &rfds, &wfds) ;
- }
- }
- timerDispatch() ;
-#ifdef DEBUG
- fflush(stdout) ;
- fflush(stderr) ;
-#endif
- log_turnover();
- }
-}
-
-/*
- * Server's entries for send message (forward or response)
- *
- * server_forward forward request to DNS server
- * server_response send back response to client
- *
- * using sub-functions,
- *
- * openTcp open TCP connection to the upstream server
- * openUdp open UDP transport to the upstream server
- * getServer get transport to the upstream server
- * getClient get transport to responding client
- * sendTcp send message via TCP
- * sendUdp send message via UDP
- *
- * and also using module level utilities,
- *
- * netCreate create transport control block
- * tcpSend send message over TCP socket
- * tcpQueue enqueue if TCP blocked
- * addrEq check if addresses are same
- * addrFmt formatting address (& proto)
- */
-
-/*
- * openTcp, openUdp - create TCP/UDP transport to DNS server
- */
-
-static NETPTR openTcp(struct sockaddr *to)
-{
- int sock ;
- NETPTR p ;
-
- TRACE("openTcp - creating transport to %s\n", addrFmt(to, SOCK_STREAM)) ;
-
- if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- WARN("openTcp - cannote create socket %d\n", errno) ;
- return NULL ;
- }
- if (connect(sock, to, sizeof(struct sockaddr)) < 0) {
- WARN("openTcp - cannot connect to server %d\n", errno) ;
- close(sock) ;
- return NULL ;
- }
- if ((p = netCreate(sock, to, SOCK_STREAM, NET_SERVER)) == NULL) {
- WARN("openTcp - cannot create control block\n") ;
- close(sock) ;
- return NULL ;
- }
- return p ;
-}
-
-static NETPTR openUdp(struct sockaddr *to)
-{
- int sock ;
- NETPTR p ;
- struct sockaddr_in saddr ; /* source port */
-
- TRACE("openUdp - creating transport to %s\n", addrFmt(to, SOCK_DGRAM)) ;
-
- memset(&saddr, 0, sizeof(saddr)) ;
- saddr.sin_family = AF_INET ;
- saddr.sin_addr.s_addr = htonl(INADDR_ANY) ;
- saddr.sin_port = htons(0) ;
-
- if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
- WARN("openUdp - cannote create socket %d\n", errno) ;
- return NULL ;
- }
- if (bind(sock, (struct sockaddr *) &saddr, sizeof(saddr)) < 0) {
- WARN("openUdp - cannot bind source port\n") ;
- close(sock) ;
- return NULL ;
- }
- if (connect(sock, to, sizeof(struct sockaddr)) < 0) {
- WARN("openUdp - cannot connect to server\n") ;
- close(sock) ;
- return NULL ;
- }
- if ((p = netCreate(sock, to, SOCK_DGRAM, NET_SERVER)) == NULL) {
- WARN("openUdp - cannot create control block\n") ;
- close(sock) ;
- return NULL ;
- }
- return p ;
-}
-
-/*
- * getServer - search/create transport to the DNS server
- */
-
-static NETPTR getServer(struct sockaddr *to, int proto)
-{
- NETPTR p ;
-
- /*
- * if proxy should use DNS port to communicate DNS server,
- * use proxy's listen port to forward request to the server
- */
-
- if (proto == SOCK_DGRAM && serverRestrictPort) {
- return listenUdp ;
- }
-
- /*
- * search transport to specified DNS server
- */
-
- if (listNet.prev == NULL || listNet.next == NULL) {
- WARN("getServer - listNet is not initialized\n") ;
- listNet.prev = &listNet ;
- listNet.next = &listNet ;
- }
- for (p = listNet.next ; p != &listNet ; p = p->next) {
- if (p->proto != proto || p->type != NET_SERVER) {
- continue ;
- }
- if (addrEq(&p->peer, to)) {
- return p ;
- }
- }
-
- /*
- * if not exist, create new one
- */
-
- if (proto == SOCK_STREAM) {
- p = openTcp(to) ;
- } else {
- p = openUdp(to) ;
- }
- return p ;
-}
-
-/*
- * getClient - search transport to the client
- */
-
-static NETPTR getClient(struct sockaddr *to, int proto)
-{
- NETPTR p ;
-
- /*
- * for response using UDP, use proxy's UDP socket
- */
-
- if (proto == SOCK_DGRAM) {
- return listenUdp ;
- }
-
- /*
- * otherwise (TCP), use existing transport to the client
- */
-
- if (listNet.prev == NULL || listNet.next == NULL) {
- WARN("getClient - listNet is not initialized\n") ;
- listNet.prev = &listNet ;
- listNet.next = &listNet ;
- }
- for (p = listNet.next ; p != &listNet ; p = p->next) {
- if (p->proto != proto || p->type != NET_CLIENT) {
- continue ;
- }
- if (addrEq(&p->peer, to)) {
- return p ;
- }
- }
- return NULL ;
-}
-
-/*
- * sendTcp, sendUdp - send message over TCP/UDP
- */
-
-static void sendTcp(NETPTR p, u_char *msg, int len)
-{
- int n ;
- u_char buff[1024] ;
- u_char *bp ;
-
- /*
- * insert 2 bytes message length field before the message
- */
-
- if (len < (1024 - 2)) {
- bp = buff ;
- } else {
- bp = malloc(len + 2) ;
- }
- if (bp == NULL) {
- WARN("sendTcp - cannot alocate send buffer\n") ;
- return ;
- }
- bp[0] = len / 256 ;
- bp[1] = len % 256 ;
- memcpy(&bp[2], msg, len) ;
- len += 2 ;
-
- /*
- * if there is pending data, enqueue sending message
- */
-
- if (p->send.prev == NULL || p->send.next == NULL) {
- WARN("sendTcp - send buffer is not initialized\n") ;
- p->send.prev = &p->send ;
- p->send.next = &p->send ;
- }
- if (p->send.next != &p->send) {
- tcpQueue(p, bp, len) ;
- if (bp != buff) free(bp) ;
- return ;
- }
-
- /*
- * then, try to send message
- */
-
- if ((n = tcpSend(p->sock, bp, len)) < 0) {
- WARN("sendTcp - cannot send message\n") ;
- if (bp != buff) free(bp) ;
- return ;
- }
- if (n != len) {
- tcpQueue(p, (bp + n), (len - n)) ;
- }
- if (bp != buff) free(bp) ;
-}
-
-static void sendUdp(NETPTR p, u_char *msg, int len, struct sockaddr *to)
-{
- int n ;
-
- if (p->type == NET_SERVER) { /* target is binded */
- n = send(p->sock, msg, len, 0) ;
- } else { /* need to specify target */
- n = sendto(p->sock, msg, len, 0, to, sizeof(struct sockaddr)) ;
- }
- if (n < 0) {
- if (!transientError(errno)) {
- WARN("sendUdp - cannot send message %d\n", errno) ;
- }
- return ;
- }
- if (n != len) {
- WARN("sendUdp - cannot send entire message %d/%d\n", n, len) ;
- return ;
- }
-}
-
-/*
- * server_forward - forward request to the DNS server
- */
-
-void server_forward(struct sockaddr *to, int proto, u_char *msg, int len)
-{
- NETPTR p ;
-
- if (to == NULL) {
- to = &serverDefaultAddr ;
- }
- if ((p = getServer(to, proto)) == NULL) {
- WARN("server_forward - no transport to server %s\n",
- addrFmt(to, proto)) ;
- return ;
- }
- if (proto == SOCK_STREAM) {
- sendTcp(p, msg, len) ;
- } else {
- sendUdp(p, msg, len, to) ;
- }
-}
-
-/*
- * server_response - response to client
- */
-
-void server_response(struct sockaddr *to, int proto, u_char *msg, int len)
-{
- NETPTR p ;
-
- if ((p = getClient(to, proto)) == NULL) {
- WARN("server_response - no transport to client %s\n",
- addrFmt(to, proto)) ;
- return ;
- }
- if (proto == SOCK_STREAM) {
- sendTcp(p, msg, len) ;
- } else {
- sendUdp(p, msg, len, to) ;
- }
-}
diff --git a/contrib/idn/mdnkit/mdnsproxy/translate.c b/contrib/idn/mdnkit/mdnsproxy/translate.c
deleted file mode 100644
index 3d8bba58..00000000
--- a/contrib/idn/mdnkit/mdnsproxy/translate.c
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * Copyright (c) 2000 Japan Network Information Center. All rights reserved.
- *
- * By using this file, you agree to the terms and conditions set forth bellow.
- *
- * LICENSE TERMS AND CONDITIONS
- *
- * The following License Terms and Conditions apply, unless a different
- * license is obtained from Japan Network Information Center ("JPNIC"),
- * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
- * Chiyoda-ku, Tokyo 101-0047, Japan.
- *
- * 1. Use, Modification and Redistribution (including distribution of any
- * modified or derived work) in source and/or binary forms is permitted
- * under this License Terms and Conditions.
- *
- * 2. Redistribution of source code must retain the copyright notices as they
- * appear in each source code file, this License Terms and Conditions.
- *
- * 3. Redistribution in binary form must reproduce the Copyright Notice,
- * this License Terms and Conditions, in the documentation and/or other
- * materials provided with the distribution. For the purposes of binary
- * distribution the "Copyright Notice" refers to the following language:
- * "Copyright (c) Japan Network Information Center. All rights reserved."
- *
- * 4. Neither the name of JPNIC may be used to endorse or promote products
- * derived from this Software without specific prior written approval of
- * JPNIC.
- *
- * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * 6. Indemnification by Licensee
- * Any person or entities using and/or redistributing this Software under
- * this License Terms and Conditions shall defend indemnify and hold
- * harmless JPNIC from and against any and all judgements damages,
- * expenses, settlement liabilities, cost and other liabilities of any
- * kind as a result of use and redistribution of this Software or any
- * claim, suite, action, litigation or proceeding by any third party
- * arising out of or relates to this License Terms and Conditions.
- *
- * 7. Governing Law, Jurisdiction and Venue
- * This License Terms and Conditions shall be governed by and and
- * construed in accordance with the law of Japan. Any person or entities
- * using and/or redistributing this Software under this License Terms and
- * Conditions hereby agrees and consent to the personal and exclusive
- * jurisdiction and venue of Tokyo District Court of Japan.
- */
-
-#ifndef lint
-static char *rcsid = "$Id: translate.c,v 1.1.2.1 2002/02/08 12:15:01 marka Exp $";
-#endif
-
-#include <config.h>
-
-#include <stddef.h>
-#include <stdarg.h>
-#include <stdlib.h>
-
-#ifdef WIN32
-#include <windows.h>
-#include <winsock.h>
-#else /* for normal systems */
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#endif
-
-#include <mdn/result.h>
-#include <mdn/log.h>
-#include <mdn/converter.h>
-#include <mdn/normalizer.h>
-#include <mdn/msgtrans.h>
-
-#include "mdnsproxy.h"
-
-/*
- * DNS message rcode.
- */
-enum {
- RCODE_NO_ERROR = 0,
- RCODE_FORMAT_ERROR = 1,
- RCODE_SERVER_FAILURE = 2,
- RCODE_NAME_ERROR = 3,
- RCODE_NOT_IMPLEMENTED = 4,
- RCODE_REFUSED = 5
-};
-
-mdn_converter_t client_converter;
-mdn_resconf_t resconf;
-
-static int result_to_rcode(mdn_result_t r);
-static char *address_to_string(struct sockaddr *sa);
-static void mdnerror(int code, char *fmt, ...);
-
-
-BOOL
-translate_initialize(void)
-{
- mdn_result_t r;
- char *mdn_conf_file;
- int ac;
- char **av;
- int lineNo;
-
- TRACE("translate_initialize()\n");
-
- /*
- * Initialize the resconf module.
- */
- mdn_resconf_initialize();
- mdn_converter_initialize();
-
- /*
- * Create a resconf module.
- */
- if (!config_query_value(KW_MDN_CONF_FILE, &ac, &av, &lineNo)) {
- mdn_conf_file = mdn_resconf_defaultfile();
- } else {
- if (ac != 2) {
- WARN("wrong # of args for \"%s\", line %d\n", KW_MDN_CONF_FILE,
- lineNo);
- return FALSE;
- }
- mdn_conf_file = av[1];
- }
-
- if ((r = mdn_resconf_create(&resconf)) != mdn_success) {
- mdnerror(r, "mdn conf file");
- return FALSE;
- }
- if ((r = mdn_resconf_loadfile(resconf, mdn_conf_file)) != mdn_success) {
- mdnerror(r, "mdn conf file %s", mdn_conf_file);
- return FALSE;
- }
-
- /*
- * Create a converter for local encoding.
- */
- if (!config_query_value(KW_CLIENT_ENCODING, &ac, &av, &lineNo)) {
- WARN("\"%s\" not found in the configuration file\n",
- KW_CLIENT_ENCODING);
- return FALSE;
- }
- if (ac != 2) {
- WARN("wrong # of args for \"%s\", line %d\n", KW_CLIENT_ENCODING,
- lineNo);
- return FALSE;
- }
- if ((r = mdn_converter_create(av[1], &client_converter, 0))
- != mdn_success) {
- mdnerror(r, "client encoding %s", av[1]);
- return FALSE;
- }
-
- mdn_resconf_setlocalconverter(resconf, client_converter);
-
- return TRUE;
-}
-
-void
-translate_finish(void)
-{
- mdn_converter_destroy(client_converter);
- mdn_resconf_destroy(resconf);
-}
-
-int
-translate_request(translation_context_t *ctx,
- const char *msg, size_t msglen,
- char *translated, size_t bufsize, size_t *translatedlenp)
-{
- mdn_result_t r;
-
- TRACE("translate_request()\n");
-
- r = mdn_msgtrans_translate(resconf, msg, msglen,
- translated, bufsize, translatedlenp);
-
- if (r != mdn_success) {
- mdnerror(r, "translating request message from %s(%s)",
- address_to_string(ctx->client),
- ctx->protocol == SOCK_STREAM ? "tcp" : "udp");
- }
-
- return result_to_rcode(r);
-}
-
-int
-translate_reply(translation_context_t *ctx,
- const char *msg, size_t msglen,
- char *translated, size_t bufsize, size_t *translatedlenp)
-{
- mdn_result_t r;
-
- TRACE("translate_reply()\n");
-
- r = mdn_msgtrans_translate(resconf, msg, msglen,
- translated, bufsize, translatedlenp);
-
- if (r != mdn_success) {
- mdnerror(r, "translating reply message from %s",
- address_to_string(ctx->client));
- }
-
- return result_to_rcode(r);
-}
-
-static int
-result_to_rcode(mdn_result_t r)
-{
- int rcode;
-
- switch (r) {
- case mdn_success:
- rcode = RCODE_NO_ERROR;
- break;
- case mdn_buffer_overflow:
- case mdn_nomemory:
- rcode = RCODE_SERVER_FAILURE;
- break;
- case mdn_invalid_message:
- case mdn_invalid_encoding:
- rcode = RCODE_FORMAT_ERROR;
- break;
- default:
- rcode = RCODE_SERVER_FAILURE;
- break;
- }
- return rcode;
-}
-
-static char *
-address_to_string(struct sockaddr *sa)
-{
- static char tmp[200];
-
- switch (sa->sa_family) {
- case AF_INET:
- {
- struct sockaddr_in *sin = (struct sockaddr_in *)sa;
-
- sprintf(tmp, "%s/%d", inet_ntoa(sin->sin_addr),
- ntohs(sin->sin_port));
- break;
- }
-#if 0
-#ifdef AF_INET6
- case AF_INET6:
- {
- char buf[INET6_ADDRSTRLEN];
-
- struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa;
-
- sprintf(tmp, "%s/%d",
- inet_ntop(AF_INET6, &sin6->sin6_addr, buf, sizeof(buf)),
- ntohs(sin6->sin6_port));
- break;
- }
-#endif
-#endif
- default:
- sprintf(tmp, "unknown address family %d", sa->sa_family);
- break;
- }
- return tmp;
-}
-
-static void
-mdnerror(int code, char *fmt, ...)
-{
- char buf[1024];
- va_list args;
-
- va_start(args, fmt);
- vsprintf(buf, fmt, args);
- va_end(args);
-
- sprintf(buf + strlen(buf), ": %s", mdn_result_tostring(code));
- WARN("%s\n", buf);
-}
diff --git a/contrib/idn/mdnkit/mdnsproxy/unxmain.c b/contrib/idn/mdnkit/mdnsproxy/unxmain.c
deleted file mode 100644
index d16d381b..00000000
--- a/contrib/idn/mdnkit/mdnsproxy/unxmain.c
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * unxmain.c - mDNS Proxy, entry for UNIX
- */
-
-/*
- * Copyright (c) 2000 Japan Network Information Center. All rights reserved.
- *
- * By using this file, you agree to the terms and conditions set forth bellow.
- *
- * LICENSE TERMS AND CONDITIONS
- *
- * The following License Terms and Conditions apply, unless a different
- * license is obtained from Japan Network Information Center ("JPNIC"),
- * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
- * Chiyoda-ku, Tokyo 101-0047, Japan.
- *
- * 1. Use, Modification and Redistribution (including distribution of any
- * modified or derived work) in source and/or binary forms is permitted
- * under this License Terms and Conditions.
- *
- * 2. Redistribution of source code must retain the copyright notices as they
- * appear in each source code file, this License Terms and Conditions.
- *
- * 3. Redistribution in binary form must reproduce the Copyright Notice,
- * this License Terms and Conditions, in the documentation and/or other
- * materials provided with the distribution. For the purposes of binary
- * distribution the "Copyright Notice" refers to the following language:
- * "Copyright (c) Japan Network Information Center. All rights reserved."
- *
- * 4. Neither the name of JPNIC may be used to endorse or promote products
- * derived from this Software without specific prior written approval of
- * JPNIC.
- *
- * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * 6. Indemnification by Licensee
- * Any person or entities using and/or redistributing this Software under
- * this License Terms and Conditions shall defend indemnify and hold
- * harmless JPNIC from and against any and all judgements damages,
- * expenses, settlement liabilities, cost and other liabilities of any
- * kind as a result of use and redistribution of this Software or any
- * claim, suite, action, litigation or proceeding by any third party
- * arising out of or relates to this License Terms and Conditions.
- *
- * 7. Governing Law, Jurisdiction and Venue
- * This License Terms and Conditions shall be governed by and and
- * construed in accordance with the law of Japan. Any person or entities
- * using and/or redistributing this Software under this License Terms and
- * Conditions hereby agrees and consent to the personal and exclusive
- * jurisdiction and venue of Tokyo District Court of Japan.
- */
-
-#ifndef lint
-static char *rcsid = "$Id: unxmain.c,v 1.1.2.1 2002/02/08 12:15:03 marka Exp $";
-#endif
-
-#ifdef UNIX
-
-#include <config.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-#include <ctype.h>
-#include <errno.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <sys/types.h>
-#include <pwd.h>
-#include <grp.h>
-#include "mdnsproxy.h" /* Common definitions for mDNS proxy */
-#include <mdn/version.h>
-
-static uid_t uid;
-static gid_t gid;
-static char *root_dir;
-static BOOL uid_specified = FALSE;
-static BOOL gid_specified = FALSE;
-
-/*
- * signal handler to catch signal to terminate server
- */
-
-static void handler(int signo)
-{
- server_stop() ;
- signal(signo, SIG_DFL) ;
-}
-
-/*
- * signal handler to turn over the log file
- */
-
-static void hup_handler(int signo)
-{
- log_turnover_request();
- signal(signo, hup_handler) ;
-}
-
-/*
- * Set root directory.
- */
-
-static void change_root(void)
-{
- int err;
-
- if (root_dir != NULL && chroot(root_dir) < 0) {
- err = errno;
- FATAL("cannot change root directory: %s\n", strerror(err));
- exit(1);
- }
-}
-
-/*
- * Set user/group ID.
- */
-
-static void set_id(void)
-{
- int err;
-
- if (gid_specified && setgid(gid) < 0) {
- err = errno;
- FATAL("cannot set group ID: %s\n", strerror(err));
- exit(1);
- }
-
- if (uid_specified && setuid(uid) < 0) {
- err = errno;
- FATAL("cannot set user ID: %s\n", strerror(err));
- exit(1);
- }
-}
-
-/*
- * Load configuration parameter related to security.
- */
-
-static void get_security_conf(void)
-{
- int ac;
- char **av;
- int lineNo;
-
- if (config_query_value(KW_ROOT_DIRECTORY, &ac, &av, &lineNo)) {
- if (ac != 2) {
- WARN("wrong # of args for \"%s\", line %d\n", KW_ROOT_DIRECTORY,
- lineNo);
- exit(1);
- }
- root_dir = malloc(strlen(av[1]) + 1);
- if (root_dir == NULL) {
- FATAL("malloc failed\n");
- exit(1);
- }
- (void)strcpy(root_dir, av[1]);
- }
-
- if (config_query_value(KW_USER_ID, &ac, &av, &lineNo)) {
- struct passwd *pwd;
-
- if (ac != 2) {
- WARN("wrong # of args for \"%s\", line %d\n", KW_USER_ID, lineNo);
- exit(1);
- } else if ((pwd = getpwnam(av[1])) != NULL) {
- uid = pwd->pw_uid;
- uid_specified = TRUE;
- } else if (isdigit((unsigned char)(av[1][0]))) {
- uid = atoi(av[1]);
- uid_specified = TRUE;
- } else {
- FATAL("unknown user \"%.100s\", line %d\n", av[1], lineNo);
- exit(1);
- }
- }
-
- if (config_query_value(KW_GROUP_ID, &ac, &av, &lineNo)) {
- struct group *gr;
-
- if (ac != 2) {
- WARN("wrong # of args for \"%s\", line %d\n", KW_GROUP_ID, lineNo);
- exit(1);
- } else if ((gr = getgrnam(av[1])) != NULL) {
- gid = gr->gr_gid;
- gid_specified = TRUE;
- } else if (isdigit((unsigned char)(av[1][0]))) {
- gid = atoi(av[1]);
- gid_specified = TRUE;
- } else {
- FATAL("unknown group \"%.100s\", line %d\n", av[1], lineNo);
- exit(1);
- }
- }
-}
-
-/*
- * print_version - print version information to stderr.
- */
-
-static void print_version(void)
-{
- fprintf(stderr, "mdnsproxy (mDNkit) version: %s\n"
- "library version: %s\n",
- MDNKIT_VERSION,
- mdn_version_getstring());
-}
-
-/*
- * main - entry of UNIX version
- */
-
-int main(int ac, char *av[])
-{
- int i, pid ;
- BOOL as_daemon = FALSE ;
-
- i = 1;
- while (i < ac) {
- if (strcmp(av[i], CMDOPT_DAEMON) == 0) {
- as_daemon = TRUE ;
- i++;
- } else if (strcmp(av[i], CMDOPT_CONFIG) == 0) {
- if (i + 1 == ac) {
- fprintf(stderr, "missing argument to \"%s\"\n", av[i]) ;
- return 1 ;
- }
- i += 2;
- } else if (strcmp(av[i], CMDOPT_LOGFILE) == 0) {
- if (i + 1 == ac) {
- fprintf(stderr, "missing argument to \"%s\"\n", av[i]) ;
- return 1 ;
- }
- i += 2;
- } else if (strcmp(av[i], CMDOPT_VERSION) == 0) {
- print_version();
- return 0;
- } else if (av[i][0] == '-' && av[i][1] != '\0') {
- fprintf(stderr, "unknown option \"%s\"\n", av[i]) ;
- return 1 ;
- } else {
- fprintf(stderr, "too many arguments\n");
- return 1 ;
- }
- }
-
- if (config_load(ac, av) != TRUE) {
- fprintf(stderr, "cannot load configuration\n") ;
- return 1 ;
- }
- if (log_configure(ac, av) != TRUE) {
- fprintf(stderr, "cannot logging\n") ;
- return 1 ;
- }
-
- get_security_conf();
-
- if (server_init(ac, av) != TRUE) {
- fprintf(stderr, "cannot initialize server\n") ;
- log_terminate() ;
- return 1 ;
- }
-
- if (as_daemon) {
- switch (pid = fork()) {
- case -1 :
- fprintf(stderr, "cannot start daemon, %s\n", strerror(errno)) ;
- server_done() ;
- log_terminate() ;
- return 2 ;
- case 0 : /* children, as daemon */
- setsid() ;
- close(0) ;
- close(1) ;
- break ;
- default :
- fprintf(stderr, "start daemon PID %d\n", pid) ;
- return 0 ;
- }
- }
-
- /*
- * Change root directory/user ID/group ID if specified.
- */
- change_root();
- set_id();
-
- signal(SIGHUP, hup_handler) ;
- signal(SIGINT, handler) ;
- signal(SIGKILL, handler) ;
- signal(SIGTERM, handler) ;
-
-#ifdef DEBUG
- fprintf(stderr, "Service Started\n") ;
-#endif
-
- server_loop() ;
-
-#ifdef DEBUG
- fprintf(stderr, "Service Terminating...\n") ;
-#endif
-
- server_done() ;
-
- log_terminate() ;
-
-#ifdef DEBUG
- fprintf(stderr, "Service Terminated\n") ;
-#endif
-
- return 0 ;
-}
-#endif /* UNIX */
diff --git a/contrib/idn/mdnkit/mdnsproxy/winmain.c b/contrib/idn/mdnkit/mdnsproxy/winmain.c
deleted file mode 100644
index c350721d..00000000
--- a/contrib/idn/mdnkit/mdnsproxy/winmain.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * winmain.c - mDNS Proxy, entry for WIN32
- *
- * Windows version works as
- *
- * Service Program, as mDNS Proxy Server
- * Service Configuration Program, Install/Remove mDNS Proxy
- *
- * or simply as
- *
- * Application Program, for debugging
- *
- * with single executable, switched with first option
- *
- * -service as Service Program
- * -install as Configuration, install serivce
- * -remove as Configuration, remove service
- *
- * Otherwise, it runs as simple console apllication.
- */
-
-/*
- * Copyright (c) 2000 Japan Network Information Center. All rights reserved.
- *
- * By using this file, you agree to the terms and conditions set forth bellow.
- *
- * LICENSE TERMS AND CONDITIONS
- *
- * The following License Terms and Conditions apply, unless a different
- * license is obtained from Japan Network Information Center ("JPNIC"),
- * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
- * Chiyoda-ku, Tokyo 101-0047, Japan.
- *
- * 1. Use, Modification and Redistribution (including distribution of any
- * modified or derived work) in source and/or binary forms is permitted
- * under this License Terms and Conditions.
- *
- * 2. Redistribution of source code must retain the copyright notices as they
- * appear in each source code file, this License Terms and Conditions.
- *
- * 3. Redistribution in binary form must reproduce the Copyright Notice,
- * this License Terms and Conditions, in the documentation and/or other
- * materials provided with the distribution. For the purposes of binary
- * distribution the "Copyright Notice" refers to the following language:
- * "Copyright (c) Japan Network Information Center. All rights reserved."
- *
- * 4. Neither the name of JPNIC may be used to endorse or promote products
- * derived from this Software without specific prior written approval of
- * JPNIC.
- *
- * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * 6. Indemnification by Licensee
- * Any person or entities using and/or redistributing this Software under
- * this License Terms and Conditions shall defend indemnify and hold
- * harmless JPNIC from and against any and all judgements damages,
- * expenses, settlement liabilities, cost and other liabilities of any
- * kind as a result of use and redistribution of this Software or any
- * claim, suite, action, litigation or proceeding by any third party
- * arising out of or relates to this License Terms and Conditions.
- *
- * 7. Governing Law, Jurisdiction and Venue
- * This License Terms and Conditions shall be governed by and and
- * construed in accordance with the law of Japan. Any person or entities
- * using and/or redistributing this Software under this License Terms and
- * Conditions hereby agrees and consent to the personal and exclusive
- * jurisdiction and venue of Tokyo District Court of Japan.
- */
-
-#ifndef lint
-static char *rcsid = "$Id: winmain.c,v 1.1.2.1 2002/02/08 12:15:04 marka Exp $";
-#endif
-
-#ifdef WIN32
-
-#include <windows.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-
-#include "mdnsproxy.h" /* Common definitions for mDNS proxy */
-#include "winserv.h" /* WIN32 Service Related Functions */
-
-/*
- * signal handler to catch signal to terminate server
- */
-
-static void handler(int signo)
-{
- server_stop() ;
- signal(signo, SIG_DFL) ;
-}
-
-/*
- * main - entry of windows version
- */
-
-int main(int ac, char *av[])
-{
- WORD version = MAKEWORD(2, 0) ;
- WSADATA wsaData ;
-
- /*
- * check 1st option
- */
-
- if (ac >= 2) {
- if (strcmp(av[1], "-service") == 0) {
- serviceRun(ac, av) ;
- return 0 ;
- }
- if (strcmp(av[1], "-install") == 0) {
- serviceInstall(ac, av) ;
- return 0 ;
- }
- if (strcmp(av[1], "-remove") == 0) {
- serviceRemove(ac, av) ;
- return 0 ;
- }
- }
-
- /*
- * otherwise run as normal application
- */
-
- if (config_load(ac, av) != TRUE) {
- printf("cannot load configration\n") ;
- return 1 ;
- }
-
- if (log_configure(ac, av) != TRUE) {
- printf("cannot logging\n") ;
- return 1 ;
- }
-
- if (WSAStartup(version, &wsaData) != 0) {
- printf("cannot startup WinSock\n") ;
- return FALSE ;
- }
- if (server_init(ac, av) != TRUE) {
- printf("cannot initialize server\n") ;
- WSACleanup() ;
- return 1 ;
- }
-
- signal(SIGINT, handler) ;
- signal(SIGTERM, handler) ;
- signal(SIGBREAK, handler) ;
-
- printf("Service Started\n") ;
-
- server_loop() ;
-
- printf("Service Termiating...\n") ;
-
- server_done() ;
-
- printf("Service Terminated\n") ;
-
- WSACleanup() ;
-
- log_terminate() ;
-
- return 0 ;
-}
-
-#endif /* WIN32 */
diff --git a/contrib/idn/mdnkit/mdnsproxy/winserv.c b/contrib/idn/mdnkit/mdnsproxy/winserv.c
deleted file mode 100644
index 7f116f98..00000000
--- a/contrib/idn/mdnkit/mdnsproxy/winserv.c
+++ /dev/null
@@ -1,451 +0,0 @@
-/*
- * winserv.c - mDNS Proxy, WIN32 Service Specific Functions
- */
-
-/*
- * Copyright (c) 2000 Japan Network Information Center. All rights reserved.
- *
- * By using this file, you agree to the terms and conditions set forth bellow.
- *
- * LICENSE TERMS AND CONDITIONS
- *
- * The following License Terms and Conditions apply, unless a different
- * license is obtained from Japan Network Information Center ("JPNIC"),
- * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
- * Chiyoda-ku, Tokyo 101-0047, Japan.
- *
- * 1. Use, Modification and Redistribution (including distribution of any
- * modified or derived work) in source and/or binary forms is permitted
- * under this License Terms and Conditions.
- *
- * 2. Redistribution of source code must retain the copyright notices as they
- * appear in each source code file, this License Terms and Conditions.
- *
- * 3. Redistribution in binary form must reproduce the Copyright Notice,
- * this License Terms and Conditions, in the documentation and/or other
- * materials provided with the distribution. For the purposes of binary
- * distribution the "Copyright Notice" refers to the following language:
- * "Copyright (c) Japan Network Information Center. All rights reserved."
- *
- * 4. Neither the name of JPNIC may be used to endorse or promote products
- * derived from this Software without specific prior written approval of
- * JPNIC.
- *
- * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * 6. Indemnification by Licensee
- * Any person or entities using and/or redistributing this Software under
- * this License Terms and Conditions shall defend indemnify and hold
- * harmless JPNIC from and against any and all judgements damages,
- * expenses, settlement liabilities, cost and other liabilities of any
- * kind as a result of use and redistribution of this Software or any
- * claim, suite, action, litigation or proceeding by any third party
- * arising out of or relates to this License Terms and Conditions.
- *
- * 7. Governing Law, Jurisdiction and Venue
- * This License Terms and Conditions shall be governed by and and
- * construed in accordance with the law of Japan. Any person or entities
- * using and/or redistributing this Software under this License Terms and
- * Conditions hereby agrees and consent to the personal and exclusive
- * jurisdiction and venue of Tokyo District Court of Japan.
- */
-
-#ifndef lint
-static char *rcsid = "$Id: winserv.c,v 1.1.2.1 2002/02/08 12:15:06 marka Exp $";
-#endif
-
-#ifdef WIN32
-
-#include <windows.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <tchar.h>
-
-#include "mdnsproxy.h" /* Common definitions for mDNS proxy */
-#include "winserv.h" /* Windows's Service Specific */
-
-/*
- * Parameters for WIN32 Service
- */
-
-#define SERVICENAME "mdnsproxy"
-#define DISPLAYNAME "mDNS Proxy"
-
-static UCHAR pathService[1024] ;
-
-/*
- * getFileName - get fullpath and split it
- */
-
-static UCHAR p_ful[256] ;
-static UCHAR p_drv[256] ;
-static UCHAR p_dir[256] ;
-static UCHAR p_nam[256] ;
-static UCHAR p_ext[256] ;
-
-static void getFileName(void)
-{
- GetModuleFileName(NULL, p_ful, 256) ;
- _splitpath(p_ful, p_drv, p_dir, p_nam, p_ext) ;
-}
-
-/*
- * Service management Varibales
- */
-
-SERVICE_STATUS_HANDLE ServiceStatusHandle = 0 ;
-SERVICE_STATUS ServiceStatusRecord = { 0 } ;
-int ServiceErrorCode = 0 ;
-
-void serviceLogTrace(PUCHAR msg)
-{
- char msgbuff[256] ;
- HANDLE hEventSrc ;
- char *strings[2] ;
-
- ServiceErrorCode = GetLastError() ;
-
- sprintf(msgbuff, "%s trace: %d", SERVICENAME, ServiceErrorCode) ;
- strings[0] = msgbuff ;
- strings[1] = msg ;
-
- hEventSrc = RegisterEventSource(NULL, TEXT(SERVICENAME)) ;
-
- if (hEventSrc != NULL) {
- ReportEvent(
- hEventSrc,
- EVENTLOG_INFORMATION_TYPE,
- 0,
- 0,
- NULL,
- 2,
- 0,
- (const char **) strings,
- NULL) ;
- DeregisterEventSource(hEventSrc) ;
- }
- /* TRACE("%s %s\n", msgbuff, msg) ; */
-}
-
-void serviceLogError(PUCHAR msg)
-{
- char msgbuff[256] ;
- HANDLE hEventSrc ;
- char *strings[2] ;
-
- ServiceErrorCode = GetLastError() ;
-
- sprintf(msgbuff, "%s error: %d", SERVICENAME, ServiceErrorCode) ;
- strings[0] = msgbuff ;
- strings[1] = msg ;
-
- hEventSrc = RegisterEventSource(NULL, TEXT(SERVICENAME)) ;
-
- if (hEventSrc != NULL) {
- ReportEvent(
- hEventSrc,
- EVENTLOG_ERROR_TYPE,
- 0,
- 0,
- NULL,
- 2,
- 0,
- (const char **) strings,
- NULL) ;
- DeregisterEventSource(hEventSrc) ;
- }
- /* FATAL("%s %s\n", msgbuff, msg) ; */
-}
-
-/*
- * serviceReport - report service status
- */
-
-VOID serviceReport(DWORD state, DWORD exitcode, DWORD waithint)
-{
- static DWORD checkpoint = 1 ;
-
- if (state == SERVICE_START_PENDING) {
- ServiceStatusRecord.dwControlsAccepted = 0 ;
- } else {
- ServiceStatusRecord.dwControlsAccepted = SERVICE_ACCEPT_STOP ;
- }
- ServiceStatusRecord.dwCurrentState = state ;
- ServiceStatusRecord.dwWin32ExitCode = exitcode ;
- ServiceStatusRecord.dwWaitHint = waithint ;
-
- if (state == SERVICE_RUNNING || state == SERVICE_STOPPED) {
- ServiceStatusRecord.dwCheckPoint = 0 ;
- } else {
- ServiceStatusRecord.dwCheckPoint = checkpoint++ ;
- }
-
- SetServiceStatus(ServiceStatusHandle, &ServiceStatusRecord) ;
-}
-
-/*
- * ServiceCtrl - service control handler
- */
-
-VOID ServiceCtrl(DWORD opcode)
-{
- switch (opcode) {
-
- case SERVICE_CONTROL_STOP :
- serviceLogTrace("ServiceCtrl STOP") ;
- ServiceStatusRecord.dwCurrentState = SERVICE_STOP_PENDING ;
- /* nofity later, so set status only */
- server_stop() ; /* stop server loop */
- break ;
-
- case SERVICE_CONTROL_INTERROGATE :
- /* query, report later */
- serviceLogTrace("ServiceCtrl INTERROGATE") ;
- break ;
-
- default :
- break ;
- }
- serviceReport(ServiceStatusRecord.dwCurrentState, NO_ERROR, 0) ;
-}
-
-/*
- * ServiceMain - as name describes
- */
-
-static UCHAR cmdline[1024] ;
-
-VOID ServiceMain(DWORD dwArgc, LPTSTR *lpszArgv)
-{
- WORD version = MAKEWORD(2, 0) ;
- WSADATA wsaData ;
-
- /*
- * initialize service status
- */
-
- ServiceStatusRecord.dwServiceType = SERVICE_WIN32 | SERVICE_INTERACTIVE_PROCESS ;
- ServiceStatusRecord.dwServiceSpecificExitCode = 0 ;
-
- /*
- * register Service Control Handler
- */
-
- ServiceStatusHandle = RegisterServiceCtrlHandler(
- TEXT(SERVICENAME),
- (LPHANDLER_FUNCTION) ServiceCtrl) ;
- if (ServiceStatusHandle == (SERVICE_STATUS_HANDLE) 0) {
- serviceLogError("RegisterServiceCtrlHandler failed") ;
- return ;
- }
-
- serviceReport(SERVICE_START_PENDING, NO_ERROR, (30 * 1000)) ;
-
- /*
- * Initialize & Run service
- */
-
- serviceLogTrace("start initializing") ;
-
- if (config_load((int) dwArgc, (char **) lpszArgv) != TRUE) {
- serviceLogError("cannot initialize server") ;
- serviceReport(SERVICE_STOPPED, 0, 0) ;
- return ;
- }
-
- if (log_configure((int) dwArgc, (char **) lpszArgv) != TRUE) {
- serviceLogError("cannot logging") ;
- serviceReport(SERVICE_STOPPED, 0, 0) ;
- return ;
- }
-
- if (WSAStartup(version, &wsaData) != 0) {
- serviceLogError("cannot initialize WinSock") ;
- serviceReport(SERVICE_STOPPED, 0, 0) ;
- return ;
- }
- if (server_init((int) dwArgc, (char **) lpszArgv) != TRUE) {
- serviceLogError("cannot initialize server") ;
- serviceReport(SERVICE_STOPPED, 0, 0) ;
- WSACleanup() ;
- return ;
- }
-
- serviceReport(SERVICE_RUNNING, NO_ERROR, 0) ;
-
- serviceLogTrace("initialization done, running now") ;
-
- server_loop() ; /* do service here */
-
- serviceLogTrace("service loop finished, closing") ;
-
- serviceReport(SERVICE_STOP_PENDING, NO_ERROR, (10 * 1000)) ;
-
- server_done() ; /* cleaup */
- WSACleanup() ;
-
- serviceLogTrace("service finised") ;
-
- serviceReport(SERVICE_STOPPED, NO_ERROR, 0) ;
-
- log_terminate() ;
-}
-
-/*
- * serviceRun - run Service
- */
-
-static SERVICE_TABLE_ENTRY ServiceTable[] = {
- { TEXT(SERVICENAME), (LPSERVICE_MAIN_FUNCTION) ServiceMain } ,
- { NULL, NULL }
-} ;
-
-void serviceRun(int ac, char *av[])
-{
- serviceLogTrace("serviceRun - start") ;
-
- if (StartServiceCtrlDispatcher(ServiceTable) == 0) {
- serviceLogError("StartServiceCtrlDispatcher failed") ;
- }
-}
-
-/*
- * serviceInstall - install service
- */
-
-void serviceInstall(int ac, char *av[])
-{
- SC_HANDLE hSCManager = NULL ;
- SC_HANDLE hService = NULL ;
-
- getFileName() ;
-
-#ifdef DEBUG
- printf("Install Service %s \"%s\"\n", SERVICENAME, p_ful) ;
-#endif
-
- /*
- * open Service Manager
- */
-
- hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS) ;
-
- if (hSCManager == NULL) {
- printf("cannot open SCManager %d\n", GetLastError()) ;
- return ;
- }
-
-#ifdef DEBUG
- printf("open SCManager\n") ; fflush(stdout) ;
-#endif
-
- /*
- * prepare service path (exe path with arguments)
- */
-
- sprintf(pathService, "\"%s\" -service", p_ful) ;
-
-#ifdef DEBUG
- printf("Installing %s\n", pathService) ;
-#endif
-
- /*
- * create service entry
- */
-
- hService = CreateService(
- hSCManager, /* SCManager database */
- TEXT(SERVICENAME), /* name of service */
- TEXT(DISPLAYNAME), /* its display name */
- SERVICE_ALL_ACCESS, /* desired access */
- SERVICE_WIN32_OWN_PROCESS, /* service type */
- SERVICE_DEMAND_START, /* start type */
- SERVICE_ERROR_IGNORE, /* error control type */
- TEXT(pathService), /* service image */
- NULL, /* no load order */
- NULL, /* no tag identifier */
- NULL, /* no dependencies */
- NULL, /* LocalSystem account */
- NULL) ; /* no password */
-
- CloseServiceHandle(hSCManager) ;
-
- if (hService == NULL) {
- printf("cannot create service %d\n", GetLastError()) ;
- return ;
- }
-
- CloseServiceHandle(hSCManager) ;
-
- printf("Installed Service %s\n", pathService) ;
-}
-
-/*
- * serviceRemove - remove service
- */
-
-void serviceRemove(int ac, char *av[])
-{
- SC_HANDLE hSCManager = NULL ;
- SC_HANDLE hService = NULL ;
-
- getFileName() ;
-
-#ifdef DEBUG
- printf("Removing Service %s\n", SERVICENAME) ;
-#endif
-
- /*
- * open Service Manager
- */
-
- hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS) ;
-
- if (hSCManager == NULL) {
- printf("cannot open SCManager %d\n", GetLastError()) ;
- return ;
- }
-
-#ifdef DEBUG
- printf("open SCManager\n") ; fflush(stdout) ;
-#endif
-
- /*
- * delete service
- */
-
- hService = OpenService(
- hSCManager, /* SCManager database */
- TEXT(SERVICENAME), /* name of service */
- DELETE) ; /* type of access */
-
- if (hService == NULL) {
- printf("cannot open service %s %d\n", SERVICENAME, GetLastError()) ;
- CloseServiceHandle(hSCManager) ;
- return ;
- }
- if (DeleteService(hService) == 0) {
- printf("cannot remove service %s %d\n", SERVICENAME, GetLastError()) ;
- CloseServiceHandle(hService) ;
- CloseServiceHandle(hSCManager) ;
- return ;
- }
-
- CloseServiceHandle(hService) ;
- CloseServiceHandle(hSCManager) ;
-
- printf("Removed Service %s\n", SERVICENAME) ;
-}
-
-#endif /* WIN32 */
diff --git a/contrib/idn/mdnkit/mdnsproxy/winserv.h b/contrib/idn/mdnkit/mdnsproxy/winserv.h
deleted file mode 100644
index a8f9ef42..00000000
--- a/contrib/idn/mdnkit/mdnsproxy/winserv.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * winserv.h - mDNS Proxy, WIN32 Service Specific Functions
- */
-
-/*
- * Copyright (c) 2000 Japan Network Information Center. All rights reserved.
- *
- * By using this file, you agree to the terms and conditions set forth bellow.
- *
- * LICENSE TERMS AND CONDITIONS
- *
- * The following License Terms and Conditions apply, unless a different
- * license is obtained from Japan Network Information Center ("JPNIC"),
- * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
- * Chiyoda-ku, Tokyo 101-0047, Japan.
- *
- * 1. Use, Modification and Redistribution (including distribution of any
- * modified or derived work) in source and/or binary forms is permitted
- * under this License Terms and Conditions.
- *
- * 2. Redistribution of source code must retain the copyright notices as they
- * appear in each source code file, this License Terms and Conditions.
- *
- * 3. Redistribution in binary form must reproduce the Copyright Notice,
- * this License Terms and Conditions, in the documentation and/or other
- * materials provided with the distribution. For the purposes of binary
- * distribution the "Copyright Notice" refers to the following language:
- * "Copyright (c) Japan Network Information Center. All rights reserved."
- *
- * 4. Neither the name of JPNIC may be used to endorse or promote products
- * derived from this Software without specific prior written approval of
- * JPNIC.
- *
- * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * 6. Indemnification by Licensee
- * Any person or entities using and/or redistributing this Software under
- * this License Terms and Conditions shall defend indemnify and hold
- * harmless JPNIC from and against any and all judgements damages,
- * expenses, settlement liabilities, cost and other liabilities of any
- * kind as a result of use and redistribution of this Software or any
- * claim, suite, action, litigation or proceeding by any third party
- * arising out of or relates to this License Terms and Conditions.
- *
- * 7. Governing Law, Jurisdiction and Venue
- * This License Terms and Conditions shall be governed by and and
- * construed in accordance with the law of Japan. Any person or entities
- * using and/or redistributing this Software under this License Terms and
- * Conditions hereby agrees and consent to the personal and exclusive
- * jurisdiction and venue of Tokyo District Court of Japan.
- */
-
-/* $Id: winserv.h,v 1.1.2.1 2002/02/08 12:15:08 marka Exp $ */
-
-#ifndef WINSERV_H
-#define WINSERV_H 1
-
-void serviceRun(int ac, char *av[]) ;
-void serviceInstall(int ac, char *av[]) ;
-void serviceRemove(int ac, char *av[]) ;
-
-#endif /* WINSERV_H */