示例#1
0
int main(int argc, char **argv)
{
     // Bring up the TCP/IP network
     init_all_network_interfaces();
     
     for (;;)
     {
          cyg_ppp_options_t options;
          cyg_ppp_handle_t ppp_handle;
          
          // Initialize the options
          cyg_ppp_options_init( &options );
          
          options.script=windows_script;
          options.baud = CYGNUM_SERIAL_BAUD_38400;
          options.flowctl = CYG_PPP_FLOWCTL_NONE;
          options.idle_time_limit = 0; // never shut down.      
          
          // Start up PPP
          ppp_handle = cyg_ppp_up( "/dev/ser0", &options );
          
          // Wait for it to get running
          if( cyg_ppp_wait_up( ppp_handle ) == 0 )
          {
               // Make use of PPP
               for (;;)
               {
                    telnet();
               }
               
               // never reached, but  for illustration:
               
               // Bring PPP link down
               cyg_ppp_down( ppp_handle );
               
               // Wait for connection to go down.
               cyg_ppp_wait_down( ppp_handle );
          }
     }
}
示例#2
0
void
main(int argc, char *argv[])
{
	int returns;

	returns = 1;
	ARGBEGIN{
	case 'C':
		opt[Echo].noway = 1;
		break;
	case 'd':
		debug = 1;
		break;
	case 'n':
		notkbd = 1;
		break; 
	case 'r':
		returns = 0;
		break;
	case 's':
		srv = EARGF(usage());
		break;
	default:
		usage();
	}ARGEND

	if(argc != 1)
		usage();

	/* options we need routines for */
	opt[Echo].change = echochange;
	opt[Term].sub = termsub;
	opt[Xloc].sub = xlocsub;

	comm = share(sizeof(comm));
	comm->returns = returns;

	telnet(dodial(argv[0]));
}
示例#3
0
/*
 * Get a pty, scan input lines.
 */
static void
doit(struct sockaddr_in *who)
{
	const char *host;
#ifndef REALLY_SMALL_TELNETD
	struct hostent *hp;
#endif
	int level;
	char user_name[256];

	/*
	 * Find an available pty to use.
	 */
#ifndef	convex
	pty = getpty();
	if (pty < 0)
		fatal(net, "All network ports in use");
#else
	for (;;) {
		char *lp;
		extern char *line, *getpty();

		if ((lp = getpty()) == NULL)
			fatal(net, "Out of ptys");

		if ((pty = open(lp, 2)) >= 0) {
			strcpy(line,lp);
			line[5] = 't';
			break;
		}
	}
#endif

#ifndef REALLY_SMALL_TELNETD
	/* get name of connected client */
	hp = gethostbyaddr((char *)&who->sin_addr, sizeof (struct in_addr),
		who->sin_family);
	if (hp)
		host = hp->h_name;
	else
#endif
		host = inet_ntoa(who->sin_addr);

#ifndef REALLY_SMALL_TELNETD
	/*
	 * We must make a copy because Kerberos is probably going
	 * to also do a gethost* and overwrite the static data...
	 */
	strncpy(remote_host_name, host, sizeof(remote_host_name)-1);
	remote_host_name[sizeof(remote_host_name)-1] = 0;
	host = remote_host_name;

	{
		struct hostent *h;
		gethostname(host_name, sizeof(host_name));
		h = gethostbyname(host_name);
		if (h) {
		    strncpy(host_name, h->h_name, sizeof(host_name));
		    host_name[sizeof(host_name)-1] = 0;
		}
	}
#endif

#if	defined(AUTHENTICATE) || defined(ENCRYPT)
	auth_encrypt_init(host_name, host, "TELNETD", 1);
#endif

	init_env();
	/*
	 * get terminal type.
	 */
	*user_name = 0;
	level = getterminaltype(user_name);
#ifdef ENV
	setenv("TERM", terminaltype ? terminaltype : "network", 1);
#endif

	/*
	 * Start up the login process on the slave side of the terminal
	 */
#ifndef	convex
	startslave(host, level, user_name);

	telnet(net, pty);  /* begin server processing */
#else
	telnet(net, pty, host);
#endif
	/*NOTREACHED*/
}  /* end of doit */
示例#4
0
void WindowsOutpost::thread_main()
{
  thread_running = true;
  while (thread_run) {
    switch (stage) {
    case STAGE_ZERO:
      {
        // Next stage.
        stage = STAGE_START;
        break;
      }
    case STAGE_START:
      {
        // Start Outpost if it does not already run.
        if (!program_is_running(Directories->get_bwoutpost_exeonly())) {
          // Start Outpost and wait a few seconds till it settles. 
          GwSpawn spawn(Directories->get_bwoutpost());
          spawn.async();
          spawn.run();
          g_usleep(3000000);
        }
        // Decide on next stage.
	// TO DO: Don't poll in such an inefficient manner.
        if (program_is_running(Directories->get_bwoutpost_exeonly())) {
          stage = STAGE_CONNECT;
        } else {
          stage = STAGE_WAIT_RETRY;
        }
        break;
      }
    case STAGE_CONNECT:
      {
        ustring hostname = "localhost";
        telnet(hostname);
        if (connected) {
          stage = STAGE_COMMUNICATE;
        } else {
          stage = STAGE_WAIT_RETRY;
        }
        break;
      }
    case STAGE_COMMUNICATE:
      {
        // Break if it communicates directly.
        if (OnlineBibleDirectMode) {
          break;
        }
        // Carry out the scheduled tasks.
        // Whether the Online Bible server should be connected to.
        if (online_bible_server_requested_action != 0) {
          if (online_bible_server_requested_action) {
            // There is a request to connect to the Online Bible server.
            if (!online_bible_server_connected) {
              if (online_bible_is_running ()) {
                send_line("OLB Connect");
                log (Readln ());
                online_bible_server_connected = true;
              }
            }
          } else {
            // There is a request to disconnect from the Online Bible server.
            if (online_bible_server_connected) {
              if (online_bible_is_running ()) {
                send_line("OLB Disconnect");
              }
            }
            // Since the Online Bible may have been shutdown, it will always be disconnected.
            online_bible_server_connected = false;
          }
          // Requested action handled.
          online_bible_server_requested_action = 0;
          break;
        }
        if (!bibleworks_reference_set_value.empty()) {
          // Make a quick copy of the value, so that if the value is set again during the time
          // it takes to send this to BibleWorks, the new value will be kept for next time.
          ustring value (bibleworks_reference_set_value);
          bibleworks_reference_set_value.clear();
          // If BibleWorks does not run, and Outpost tries to contact it, it 
          // crashes in Wine and becomes unusable. Therefore check whether BibleWorks runs.
          if (bibleworks_is_running ()) {
            send_line(value);
          }
          break;
        }
        if (!santafefocus_reference_set_value.empty()) {
          ustring value (santafefocus_reference_set_value);
          santafefocus_reference_set_value.clear();
          send_line(value);
          break;
        }
        if (!santafefocus_word_set_value.empty()) {
          ustring value (santafefocus_word_set_value);
          santafefocus_word_set_value.clear();
          send_line(value);
          break;
        }
        if (!onlinebible_reference_set_value.empty()) {
          ustring value (onlinebible_reference_set_value);
          onlinebible_reference_set_value.clear();
          bool online_bible_runs = online_bible_is_running ();
          if (online_bible_runs) {
            if (online_bible_server_connected) {
              send_line (value);
            }
          } else {
            online_bible_server_connected = false;
          }
          break;
        }
        if (!get_reference_command.empty()) {
          send_line (get_reference_command);
          get_reference_command.clear();
          get_reference_reply = Readln ();
          break;
        }
        break;
      }
    case STAGE_WAIT_RETRY:
      {
        stage++;
        break;
      }
    case STAGE_RETRY:
      {
        clear();
        break;
      }
    default:
      {
        stage++;
      }
    }
    g_usleep(300000);
  }
  thread_running = false;
}
示例#5
0
/*
 * Get a pty, scan input lines.
 */
static void
doit(struct sockaddr_in *who)
{
	const char *host;
	struct hostent *hp;
	int level;
	char user_name[256];
	char portnum[8];

	/*
	 * Find an available pty to use.
	 */
	pty = getpty();
	if (pty < 0)
		fatal(net, "All network ports in use");

	/* get name of connected client */
	hp = gethostbyaddr((char *)&who->sin_addr, sizeof (struct in_addr),
		who->sin_family);
	if (hp)
		host = hp->h_name;
	else
		host = inet_ntoa(who->sin_addr);

	/*
	 * We must make a copy because Kerberos is probably going
	 * to also do a gethost* and overwrite the static data...
	 */
	{
		int i;
		strncpy(remote_host_name, host, sizeof(remote_host_name)-1);
		remote_host_name[sizeof(remote_host_name)-1] = 0;

		/* Disallow funnies. */
		for (i=0; remote_host_name[i]; i++) {
		    if (remote_host_name[i]<=32 || remote_host_name[i]>126) 
			remote_host_name[i] = '?';
		}
	}
	host = remote_host_name;

	/* Get local host name */
	{
		struct hostent *h;
		gethostname(host_name, sizeof(host_name));
		h = gethostbyname(host_name);
		if (h) {
		    strncpy(host_name, h->h_name, sizeof(host_name));
		    host_name[sizeof(host_name)-1] = 0;
		}
	}

#if	defined(AUTHENTICATE) || defined(ENCRYPT)
	auth_encrypt_init(host_name, host, "TELNETD", 1);
#endif

	init_env();
	/*
	 * get terminal type.
	 */
	*user_name = 0;
	level = getterminaltype(user_name);
	setenv("HOME", "/opt/mud/plogin",1);
	setenv("TERM", terminaltype ? terminaltype : "network", 1);

	/* TODO list stuff provided by Laszlo Vecsey <*****@*****.**> */

	/*
	 * Set REMOTEHOST environment variable
	 */
	setproctitle("%s", host);

	sprintf(portnum, "%d", ntohs(who->sin_port));

	setenv("REMOTEADDR", inet_ntoa(who->sin_addr), 1);
	setenv("REMOTEHOST", host, 1);
	setenv("REMOTEPORT", portnum, 1);

	/*
	 * Start up the login process on the slave side of the terminal
	 */
	startslave(host, level, user_name);

	telnet(net, pty);  /* begin server processing */

	/*NOTREACHED*/
}  /* end of doit */
示例#6
0
/*
 * Get a pty, scan input lines.
 */
static void
doit(struct sockaddr *who, socklen_t who_len)
{
	char *host;
	int level;
	char user_name[256];
	int i;
	struct addrinfo hints, *res;

	/*
	 * Find an available pty to use.
	 */
	pty = getpty();
	if (pty < 0)
		fatalperror(net, "getpty");

	/* get name of connected client */
	if (getnameinfo(who, who_len, remote_host_name,
			sizeof(remote_host_name), 0, 0, 
			numeric_hosts ? NI_NUMERICHOST : 0)) {
		syslog(LOG_ERR, "doit: getnameinfo: %m");
		*remote_host_name = 0;
        }

	/* Disallow funnies. */
	for (i=0; remote_host_name[i]; i++) {
	    if (remote_host_name[i]<=32 || remote_host_name[i]>126) 
		remote_host_name[i] = '?';
	}
	host = remote_host_name;

	/* Get local host name */
	gethostname(host_name, sizeof(host_name));
	memset(&hints, 0, sizeof(hints));
	hints.ai_family = PF_UNSPEC;
	hints.ai_flags = AI_CANONNAME;
	if ((i = getaddrinfo(host_name, 0, &hints, &res)))
		syslog(LOG_WARNING, "doit: getaddrinfo: %s", gai_strerror(i));
	else {
		strncpy(host_name, res->ai_canonname, sizeof(host_name)-1);
		host_name[sizeof(host_name)-1] = 0;
	}

#if	defined(AUTHENTICATE) || defined(ENCRYPT)
	auth_encrypt_init(host_name, host, "TELNETD", 1);
#endif

	init_env();
	/*
	 * get terminal type.
	 */
	*user_name = 0;
	level = getterminaltype(user_name);
	setenv("TERM", terminaltype ? terminaltype : "network", 1);

	/* TODO list stuff provided by Laszlo Vecsey <*****@*****.**> */

#ifdef USE_SSL
	if (debug) {
	    fprintf(stderr,"doit - ALIVE\n");
	    fflush(stderr);
	    sleep(2);
	}
#endif /* USE_SSL */


	/*
	 * Set REMOTEHOST environment variable
	 */
	setproctitle("%s", host);
	setenv("REMOTEHOST", host, 0);

#ifdef USE_SSL
	if (debug) {
	    fprintf(stderr,"doit - starting telnet protocol itself\n");
	    fflush(stderr);
	    sleep(2);
	}
#endif /* USE_SSL */

	/*
	 * Start up the login process on the slave side of the terminal
	 */
	startslave(host, level, user_name);

	telnet(net, pty);  /* begin server processing */

	/*NOTREACHED*/
}  /* end of doit */