/*
- * $Id: main.c,v 1.17.8.1 2004-01-10 08:09:12 bfernhomberg Exp $
+ * $Id: main.c,v 1.17.8.6.2.1 2005-01-31 17:01:04 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
ntohs(iface->i_addr.sat_addr.s_net),
iface->i_addr.sat_addr.s_node, strerror(errno));
}
+#ifdef linux
+ if (!(iface->i_flags & IFACE_WASALLMULTI) && (iface->i_flags & IFACE_ALLMULTI))
+ ifsetallmulti(iface->i_name, 0);
+#endif /* linux */
}
#endif /* SOPCDOFADDR */
for ( lr = zt->zt_rt; lr; lr = lr->l_next ) {
rtmp = (struct rtmptab *)lr->l_data;
if ( rtmp->rt_iprev == 0 && rtmp->rt_gate != 0 ) {
- LOG(log_error, logtype_atalkd, "%.*s has %u-%u (unused)\n",
+ LOG(log_error, logtype_atalkd, "%.*s has %u-%u (unused)",
zt->zt_len, zt->zt_name, ntohs( rtmp->rt_firstnet ),
ntohs( rtmp->rt_lastnet ));
atalkd_exit(1);
}
}
if ( lz == 0 ) {
- LOG(log_error, logtype_atalkd, "no map from %u-%u to %.*s\n",
+ LOG(log_error, logtype_atalkd, "no map from %u-%u to %.*s",
ntohs( rtmp->rt_firstnet ),
ntohs( rtmp->rt_lastnet ),
zt->zt_len, zt->zt_name );
struct sockaddr_at sat;
struct sigaction sv;
struct itimerval it;
+ sigset_t signal_set, old_set;
+
struct interface *iface;
int status;
struct atport *ap;
fd_set readfds;
- int i, mask, c;
+ int i, c;
SOCKLEN_T fromlen;
char *prog;
-;
while (( c = getopt( ac, av, "12qsdtf:P:v" )) != EOF ) {
switch ( c ) {
exit( 1 );
}
+ /*
+ * Set process name for logging
+ */
+
+ set_processname("atalkd");
+
/* do this here so that we can use ifconfig */
#ifdef __svr4__
if ( plumb() < 0 ) {
atalkd_exit( 1 );
}
+ sigemptyset( &signal_set );
+ sigaddset(&signal_set, SIGALRM);
+#if 0
+ /* don't block SIGTERM */
+ sigaddset(&signal_set, SIGTERM);
+#endif
+ sigaddset(&signal_set, SIGUSR1);
+
for (;;) {
readfds = fds;
if ( select( nfds, &readfds, NULL, NULL, NULL) < 0 ) {
LOG(log_error, logtype_atalkd, "recvfrom: %s", strerror(errno) );
continue;
}
-#ifdef DEBUG
+#ifdef DEBUG1
if ( debug ) {
printf( "packet from %u.%u on %s (%x) %d (%d)\n",
ntohs( sat.sat_addr.s_net ),
iface->i_flags, ap->ap_port, ap->ap_fd );
bprint( Packet, c );
}
-#endif /* DEBUG */
-#ifdef __svr4__
- if ( sighold( SIGALRM ) || sighold( SIGUSR1 )) {
- LOG(log_error, logtype_atalkd, "sighold: %s", strerror(errno) );
+#endif
+ if (sigprocmask(SIG_BLOCK, &signal_set, &old_set) < 0) {
+ LOG(log_error, logtype_atalkd, "sigprocmask: %s", strerror(errno) );
atalkd_exit( 1 );
}
-#else /* __svr4__ */
- mask = sigsetmask( sigmask( SIGALRM ) |
- sigmask( SIGUSR1 ));
-#endif /* __svr4__ */
+
if (( *ap->ap_packet )( ap, &sat, Packet, c ) < 0) {
LOG(log_error, logtype_atalkd, "ap->ap_packet: %s", strerror(errno));
atalkd_exit(1);
#ifdef DEBUG
consistency();
-#endif /* DEBUG */
-#ifdef __svr4__
- if ( sigrelse( SIGUSR1 ) || sigrelse( SIGALRM )) {
- LOG(log_error, logtype_atalkd, "sigrelse: %s", strerror(errno) );
+#endif
+ if (sigprocmask(SIG_SETMASK, &old_set, NULL) < 0) {
+ LOG(log_error, logtype_atalkd, "sigprocmask old set: %s", strerror(errno) );
atalkd_exit( 1 );
}
-#else /* __svr4__ */
- sigsetmask( mask );
-#endif /* __svr4__ */
+
}
}
}
/* open ports */
i = 1; /* enable broadcasts */
-#ifdef __svr4__
+#if 0
+ /* useless message, no? */
LOG(log_info, logtype_atalkd, "setsockopt incompatible w/ Solaris STREAMS module.");
#endif /* __svr4__ */
for ( ap = iface->i_ports; ap; ap = ap->ap_next ) {
nfds++;
}
+int ifsetallmulti ( iname, set )
+const char *iname;
+int set;
+{
+ int sock;
+ struct ifreq ifr;
+
+ memset(&ifr, 0, sizeof(ifr));
+
+ if (( sock = socket( AF_APPLETALK, SOCK_DGRAM, 0 )) < 0 ) {
+ return( -1 );
+ }
+
+ /* get interface config */
+ strlcpy(ifr.ifr_name, iname, sizeof(ifr.ifr_name));
+ if (ioctl(sock, SIOCGIFFLAGS, &ifr) < 0) {
+ close(sock);
+ return (-1);
+ }
+
+ /* should we set or unset IFF_ALLMULTI */
+ if (set)
+ ifr.ifr_flags |= IFF_ALLMULTI;
+ else
+ ifr.ifr_flags &= ~IFF_ALLMULTI;
+
+ /* set interface config */
+ strlcpy(ifr.ifr_name, iname, sizeof(ifr.ifr_name));
+ if (ioctl(sock, SIOCSIFFLAGS, &ifr) < 0) {
+ close(sock);
+ return -1;
+ }
+
+ close(sock);
+ return (0);
+}
+
int ifconfig( iname, cmd, sa )
const char *iname;
unsigned long cmd;