along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: net.c,v 1.35.4.71 2000/11/15 01:06:10 zarq Exp $
+ $Id: net.c,v 1.35.4.75 2000/11/16 17:54:27 zarq Exp $
*/
#include "config.h"
-#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
-/* SunOS really wants sys/socket.h BEFORE net/if.h */
-#include <sys/socket.h>
-#include <net/if.h>
#include <netdb.h>
#include <netinet/in.h>
#include <stdio.h>
#include <syslog.h>
#include <unistd.h>
#include <sys/ioctl.h>
+/* SunOS really wants sys/socket.h BEFORE net/if.h,
+ and FreeBSD wants these lines below the rest. */
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#include <net/if.h>
#ifdef HAVE_OPENSSL_RAND_H
# include <openssl/rand.h>
#include "conf.h"
#include "connlist.h"
+#include "list.h"
#include "meta.h"
#include "net.h"
#include "netutl.h"
+#include "process.h"
#include "protocol.h"
#include "subnet.h"
subnet_t mymac;
-/*
- Execute the given script.
- This function doesn't really belong here.
-*/
-int execute_script(const char *name)
-{
- char *scriptname;
- pid_t pid;
- char *s;
-
- if((pid = fork()) < 0)
- {
- syslog(LOG_ERR, _("System call `%s' failed: %m"),
- "fork");
- return -1;
- }
-
- if(pid)
- {
- return 0;
- }
-
- /* Child here */
-
- if(netname)
- {
- asprintf(&s, "NETNAME=%s", netname);
- putenv(s); /* Don't free s! see man 3 putenv */
- }
-#ifdef HAVE_UNSETENV
- else
- {
- unsetenv("NETNAME");
- }
-#endif
-
- chdir(confbase); /* This cannot fail since we already read config files from this directory. */
-
- asprintf(&scriptname, "%s/%s", confbase, name);
- execl(scriptname, NULL);
-
- /* No return on success */
-
- if(errno != ENOENT) /* Ignore if the file does not exist */
- syslog(LOG_WARNING, _("Error executing `%s': %m"), scriptname);
-
- /* No need to free things */
-
- exit(0);
-}
-
int xsend(conn_list_t *cl, vpn_packet_t *inpkt)
{
vpn_packet_t outpkt;
myself->status.active = 1;
syslog(LOG_NOTICE, _("Ready: listening on port %hd"), myself->port);
+
+ child_pids = list_new();
cp
return 0;
}
cp
p = new_conn_list();
- if(getpeername(sfd, &ci, &len) < 0)
+ if(getpeername(sfd, (struct sockaddr *) &ci, (socklen_t *) &len) < 0)
{
syslog(LOG_ERR, _("System call `%s' failed: %m"),
"getpeername");
if(FD_ISSET(tap_fd, &fset))
handle_tap_input();
}
+
+ check_children();
}
cp
}