/*
+ * $Id: dsi_tcp.c,v 1.6 2002-01-04 04:45:48 sibaz Exp $
+ *
* Copyright (c) 1997, 1998 Adrian Sun (asun@zoology.washington.edu)
* All rights reserved. See COPYRIGHT.
*
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif
+#endif /* HAVE_CONFIG_H */
#define USE_TCP_NODELAY
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
#include <errno.h>
+#ifdef HAVE_NETDB_H
#include <netdb.h>
+#endif /* HAVE_NETDB_H */
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
-#endif
+#endif /* HAVE_STDINT_H */
#include <sys/ioctl.h>
+#ifdef TRU64
+#include <sys/mbuf.h>
+#include <net/route.h>
+#endif /* TRU64 */
#include <net/if.h>
#include <netinet/tcp.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <signal.h>
-#include <syslog.h>
+#include <atalk/logger.h>
#ifdef __svr4__
#include <sys/sockio.h>
-#endif
+#endif /* __svr4__ */
#ifdef TCPWRAP
#include <tcpd.h>
-int allow_severity = LOG_INFO;
-int deny_severity = LOG_WARNING;
-#endif
+int allow_severity = log_info;
+int deny_severity = log_warning;
+#endif /* TCPWRAP */
#include <atalk/dsi.h>
#include <atalk/compat.h>
#ifndef DSI_TCPMAXPEND
#define DSI_TCPMAXPEND 20 /* max # of pending connections */
-#endif
+#endif /* DSI_TCPMAXPEND */
#ifndef DSI_TCPTIMEOUT
#define DSI_TCPTIMEOUT 120 /* timeout in seconds for connections */
-#endif
+#endif /* ! DSI_TCPTIMEOUT */
/* FIXME/SOCKLEN_T: socklen_t is a unix98 feature. */
#ifndef SOCKLEN_T
#define SOCKLEN_T unsigned int
-#endif
+#endif /* ! SOCKLEN_T */
static void dsi_tcp_close(DSI *dsi)
{
/* alarm handler for tcp_open */
static void timeout_handler()
{
- syslog(LOG_ERR, "dsi_tcp_open: connection timed out");
+ LOG(log_error, logtype_default, "dsi_tcp_open: connection timed out");
exit(1);
}
request_init(&req, RQ_DAEMON, dsi->program, RQ_FILE, dsi->socket, NULL);
fromhost(&req);
if (!hosts_access(&req)) {
- syslog(deny_severity, "refused connect from %s", eval_client(&req));
+ LOG(deny_severity, "refused connect from %s", eval_client(&req));
close(dsi->socket);
errno = ECONNREFUSED;
dsi->socket = -1;
}
}
-#endif
+#endif /* TCPWRAP */
if (dsi->socket < 0)
return -1;
newact.sa_handler = timeout_handler;
if ((sigaction(SIGALRM, &newact, &oldact) < 0) ||
(setitimer(ITIMER_REAL, &timer, NULL) < 0)) {
- syslog(LOG_ERR, "dsi_tcp_open: %m");
+ LOG(log_error, logtype_default, "dsi_tcp_open: %s", strerror(errno));
exit(1);
}
/* read in the first two bytes */
dsi_stream_read(dsi, block, 2);
if ((block[0] > DSIFL_MAX) || (block[1] > DSIFUNC_MAX)) {
- syslog(LOG_ERR, "dsi_tcp_open: invalid header");
+ LOG(log_error, logtype_default, "dsi_tcp_open: invalid header");
exit(1);
}
if (len > 0)
stored += len;
else {
- syslog(LOG_ERR, "dsi_tcp_open: stream_read: %m");
+ LOG(log_error, logtype_default, "dsi_tcp_open: stream_read: %s", strerror(errno));
exit(1);
}
}
if (len > 0)
stored += len;
else {
- syslog(LOG_ERR, "dsi_tcp_open: stream_read: %m");
+ LOG(log_error, logtype_default, "dsi_tcp_open: stream_read: %s", strerror(errno));
exit(1);
}
}
/* restore signal */
sigaction(SIGALRM, &oldact, NULL);
- syslog(LOG_INFO,"ASIP session:%u(%d) from %s:%u(%d)",
+ LOG(log_info, logtype_default,"ASIP session:%u(%d) from %s:%u(%d)",
ntohs(dsi->server.sin_port), dsi->serversock,
inet_ntoa(dsi->client.sin_addr), ntohs(dsi->client.sin_port),
dsi->socket);
if (!address)
dsi->server.sin_addr.s_addr = htonl(INADDR_ANY);
else if (inet_aton(address, &dsi->server.sin_addr) == 0) {
- syslog(LOG_INFO, "dsi_tcp: invalid address (%s)", address);
+ LOG(log_info, logtype_default, "dsi_tcp: invalid address (%s)", address);
return 0;
}
#ifdef SO_REUSEADDR
port = 1;
setsockopt(dsi->serversock, SOL_SOCKET, SO_REUSEADDR, &port, sizeof(port));
-#endif
+#endif /* SO_REUSEADDR */
#ifdef USE_TCP_NODELAY
#ifndef SOL_TCP
#define SOL_TCP IPPROTO_TCP
-#endif
+#endif /* ! SOL_TCP */
port = 1;
setsockopt(dsi->serversock, SOL_TCP, TCP_NODELAY, &port, sizeof(port));
-#endif
+#endif /* USE_TCP_NODELAY */
/* now, bind the socket and set it up for listening */
if ((bind(dsi->serversock, (struct sockaddr *) &dsi->server,
#ifndef IFF_SLAVE
#define IFF_SLAVE 0
-#endif
+#endif /* ! IFF_SLAVE */
if (ioctl(dsi->serversock, SIOCGIFFLAGS, &ifr) < 0)
continue;
dsi->server.sin_addr.s_addr =
((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr;
- syslog(LOG_INFO, "dsi_tcp: Can't resolve hostname (%s).\n"
+ LOG(log_info, logtype_default, "dsi_tcp: Can't resolve hostname (%s).\n"
"%s on interface %s will be used instead.", hostname,
inet_ntoa(dsi->server.sin_addr), ifr.ifr_name);
goto iflist_done;
}
- syslog(LOG_INFO, "dsi_tcp (Chooser will not select afp/tcp)\n\
+ LOG(log_info, logtype_default, "dsi_tcp (Chooser will not select afp/tcp)\n\
Check to make sure %s is in /etc/hosts and the correct domain is in\n\
-/etc/resolv.conf: %m", hostname);
+/etc/resolv.conf: %s", hostname, strerror(errno));
iflist_done:
if (start)