Ejemplo n.º 1
0
void init6(int argc, char *argv[])
{
	struct lac6 *lac;
//    struct in6_addr listenaddr;
    struct utsname uts;
//    char ipaddr[16];
//    char ipaddrStr[INET6_ADDRSTRLEN];
    init_args (argc,argv);
    srand( time(NULL) );
    rand_source = 0;
    //RY: required only when IP_ALLOCATION is defined
	//init_addr ();

	if (init_config6 ())
	{
		l2tp_log (LOG_CRIT, "%s: Unable to load config file\n", __FUNCTION__);
		exit (1);
	}

	//inet_pton(AF_INET6, "1002:0:0:0:0:0:12", gconfig.ipaddr.listenaddr6);
//	inet_pton(AF_INET6, "2001::12", gconfig.ipaddr.listenaddr6);
//	inet_ntop(AF_INET6, gconfig.ipaddr.listenaddr6, ipaddrStr, sizeof(ipaddrStr));
	if (uname (&uts)<0)
	{
		l2tp_log (LOG_CRIT, "%s : Unable to determine host system\n",
			__FUNCTION__);
		exit (1);
	}
    init_tunnel_list6 (&tunnels6);
    if (init_network ())
        exit (1);

    if (gconfig.daemon)
//        daemonize (); //RY: commented for debugging

    consider_pidfile();

    signal (SIGTERM, &death_handler6);
    signal (SIGINT, &death_handler6);
    signal (SIGCHLD, &child_handler6);
    signal (SIGUSR1, &status_handler6);
    signal (SIGHUP, &null_handler);
    init_scheduler ();

    unlink(gconfig.controlfile);
    mkfifo (gconfig.controlfile, 0600);

    open_controlfd();
    /*l2tp_log (LOG_INFO, "xl2tpd version " SERVER_VERSION " started on %s PID:%d\n",
         hostname, getpid ());*/
    printf( "xl2tpd version " SERVER_VERSION " started on %s PID:%d\n",
         hostname, getpid ());
    printf(
         "Written by Mark Spencer, Copyright (C) 1998, Adtran, Inc.\n");
    printf( "Forked by Scott Balmos and David Stipp, (C) 2001\n");
    printf( "Inherited by Jeff McAdams, (C) 2002\n");
    printf( "Forked again by Xelerance (www.xelerance.com) (C) 2006\n");

    printf( "Listening on IP address %s, port %d\n", IPADDY6(gconfig.ipaddr.listenaddr6)
              , gconfig.port);	//printing IP addr on screen
    lac = laclist6;
    while (lac)
    {
        if (lac->autodial)
        {
#ifdef DEBUG_MAGIC
            l2tp_log (LOG_DEBUG, "%s: Autodialing '%s'\n", __FUNCTION__,
                 lac->entname[0] ? lac->entname : "(unnamed)");
#endif
            lac->active = -1;
            switch_io = 1;      /* If we're a LAC, autodials will be ICRQ's */
            magic_lac_dial6 (lac);
        }
        lac = lac->next;
    }
}
Ejemplo n.º 2
0
void init (int argc,char *argv[])
{
    struct lac *lac;
    struct in_addr listenaddr;
    struct utsname uts;

    init_args (argc,argv);
    srand( time(NULL) );
    rand_source = 0;
    init_addr ();
    if (init_config ())
    {
        l2tp_log (LOG_CRIT, "%s: Unable to load config file\n", __FUNCTION__);
        exit (1);
    }
    if (uname (&uts)<0)
    {
        l2tp_log (LOG_CRIT, "%s : Unable to determine host system\n",
             __FUNCTION__);
        exit (1);
    }
    init_tunnel_list (&tunnels);
    if (init_network ())
        exit (1);

    if (gconfig.daemon)
        daemonize ();

    consider_pidfile();

    signal (SIGTERM, &sigterm_handler);
    signal (SIGINT, &sigint_handler);
    signal (SIGCHLD, &sigchld_handler);
    signal (SIGUSR1, &sigusr1_handler);
    signal (SIGHUP, &sighup_handler);
    init_scheduler ();

    unlink(gconfig.controlfile);
    mkfifo (gconfig.controlfile, 0600);

    open_controlfd();

    l2tp_log (LOG_INFO, "xl2tpd version " SERVER_VERSION " started on %s PID:%d\n",
         hostname, getpid ());
    l2tp_log (LOG_INFO,
         "Written by Mark Spencer, Copyright (C) 1998, Adtran, Inc.\n");
    l2tp_log (LOG_INFO, "Forked by Scott Balmos and David Stipp, (C) 2001\n");
    l2tp_log (LOG_INFO, "Inherited by Jeff McAdams, (C) 2002\n");
    l2tp_log (LOG_INFO, "Forked again by Xelerance (www.xelerance.com) (C) 2006\n");
    listenaddr.s_addr = gconfig.listenaddr;
    l2tp_log (LOG_INFO, "Listening on IP address %s, port %d\n",
              inet_ntoa(listenaddr), gconfig.port);
    lac = laclist;
    while (lac)
    {
        if (lac->autodial)
        {
#ifdef DEBUG_MAGIC
            l2tp_log (LOG_DEBUG, "%s: Autodialing '%s'\n", __FUNCTION__,
                 lac->entname[0] ? lac->entname : "(unnamed)");
#endif
            lac->active = -1;
            switch_io = 1;      /* If we're a LAC, autodials will be ICRQ's */
            magic_lac_dial (lac);
        }
        lac = lac->next;
    }
}