Exemplo n.º 1
0
gdmaps_t* gdmaps_test_init(const char* config_path) {

    dmn_init_log();

    dmn_assert(config_path);

    const vscf_data_t* cfg_root = conf_load(config_path);
    conf_options(cfg_root);
    gdnsd_set_cfdir(config_path);

    const vscf_data_t* maps_cfg = conf_get_maps(cfg_root);
    gdmaps_t* gdmaps = gdmaps_new(maps_cfg);
    vscf_destroy(cfg_root);

    gdmaps_load_geoip_databases(gdmaps);
    gdmaps_setup_geoip_watcher_paths(gdmaps);
    gdmaps_setup_geoip_watchers(gdmaps);

    return gdmaps;
}
Exemplo n.º 2
0
/* ------------------------------------------------------------------------- */
int session_init_incoming()
{
	int    c = 0;
	int    pos = 0;
	bool   canemsi = FALSE;
	bool   canyoohoo = FALSE;
	bool   canftsc = FALSE;
	char   buf[13];
	int    emsi_seq = 0;      /* start reading emsi sequence     */
	int    yoohoo_count = 0;  /* number of ENQ received          */
	int    tsync_count  = 0;  /* number of NAK or 'C' received   */
	int    yoohoo_need = 1;
	int    tsync_need = 1;
	time_t mast_timer = 0;    /* master timer, seems to be 60sec */
	time_t sync_timer = 0;
	long   options = conf_options(cf_options);
	int    unexp_count = 0;

	state.session = SESSION_UNKNOWN;
	
	//log("init");
	
	if( (options & OPTIONS_NO_EMSI) != OPTIONS_NO_EMSI ) {
		//log("can emsi");
		canemsi = TRUE;
	}
	if( (options & OPTIONS_NO_YOOHOO) != OPTIONS_NO_YOOHOO ) {
		//log("can yahoo");
		canyoohoo = TRUE;
	}
	if( (options & OPTIONS_NO_FTS1) != OPTIONS_NO_FTS1 ) {
		//log("can ftsc");
		canftsc = TRUE;
	}
	
	yoohoo_need = canemsi ? 2 : 1;
	tsync_need = (canemsi || canyoohoo) ? 2 : 1;

	if( PUTCHAR('\r') < 0 ) {
		log("error: cannot put char");
		return 1;
	}
	
	/*
	 * Output banner
	 */
	if( canemsi && PUTSTR("**EMSI_REQA77E\r") < 0 ) {
		log("error: cannot put banner");
		return 1;
	}

	if( state.connstr )
	{
		/* Show connect string */
		if( PUTCHAR('[') < 0 ) {
			log("error: cannot put ']'");
			return 1;
		}
		if( PUTSTR(state.connstr) < 0 ) {
			log("error: cannot put connstr");
			return 1;
		}
		if( PUTSTR("]\n") < 0 ) {
			log("error: cannot put ']'");
			return 1;
		}
	}
	
	if( PUTSTR(BF_BANNERVER) < 0 || PUTCHAR(' ') < 0
	 || PUTSTR(BF_COPYRIGHT) < 0 || PUTCHAR('\n') < 0 ) {
		log("session_init_incoming error: output");
		return 1;
	}

	if( FLUSHOUT() < 0 ) {
		log("session_init_incoming error: flush");
		return 1;
	}
	
	/* Start timers */
	timer_set(&mast_timer, INCOMING_MAST_TIMER);
	timer_set(&sync_timer, INCOMING_SYNC_TIMER/2);
	
	/*
	 * Determine supported handshakes on called system
	 * (support for FTS-1, YooHoo, EMSI)
	 */
	 
	//log("begin loop");
	while(1)
	{
		if( timer_expired(mast_timer) )
		{
			log("session initialisation timed out");
			DEB((D_HSHAKE, "handshake initialisation timed out"));
			
			return 1;
		}
		
		if( timer_expired(sync_timer) )
		{
			DEB((D_HSHAKE, "rx_init: resyncing"));
			
			if( canemsi && PUTSTR("**EMSI_REQA77E\r") < 0 ) {
				log("session_init_incoming error: output");
				return 1;
			}

			if( FLUSHOUT() < 0 ) {
				log("session_init_incoming error: flush");
				return 1;
			}
			
			timer_set(&sync_timer, INCOMING_SYNC_TIMER);
		}
		
		/*
		 * Pickup next char
		 */
		if( (c = GETCHAR(1)) < 0 )
		{
			if( c != TTY_TIMEOUT )
			{
				DEB((D_HSHAKE, "rx_init: got TTY_ERROR/TTY_HANGUP"));
				return 1;
			}				
		}
		else if( c == XON || c == XOFF )
		{
			/* Do nothing. Drop them down */
		}
		else if( c == YOOHOO )
		{
			if( ++yoohoo_count >= yoohoo_need && canyoohoo )
			{
				DEB((D_HSHAKE, "rx_init: exit with YooHoo"));
				state.session = SESSION_YOOHOO;
				
				return 0;
			}
		}
		else if( c == TSYNC )
		{
			if( ++tsync_count > tsync_need && canftsc )
			{
				DEB((D_HSHAKE, "rx_init: exit with FTS-1"));
				state.session = SESSION_FTSC;
				
				return 0;
			}
		}
		else if( canemsi && c > ' ' && c < '~' )
		{
			tsync_count = 0;
			yoohoo_count = 0;
			
			if( c == '*' )
			{
				memset(buf, '\0', sizeof(buf));
				pos = 0;
				emsi_seq = 1;
			}
			else if( emsi_seq )
			{
				if( pos < sizeof(buf)-1 )
				{
					buf[pos++] = (char)(c & 0xff);
					buf[pos  ] = '\0';
				}
			
				if( pos >= sizeof(buf)-1 )
				{
					emsi_seq = 0;
					
					DEB((D_HSHAKE, "rx_init: emsi buffer full \"%s\"",
							string_printable(buf)));
					
					if( !strncasecmp(buf, "EMSI_INQC816", 12) )
					{
						DEB((D_HSHAKE, "rx_init: exit with EMSI"));
						state.session = SESSION_EMSI;
						
						return 0;
					}
					else if( !strncasecmp(buf, "EMSI", 4) )
					{
						log("unexpected emsi sequence \"%s\"",
								string_printable(buf));
						
						if( ++unexp_count > 10 )
						{
							log("too many unexpected emsi sequences");
							return 1;
						}
					}
				}
			}
		}
		else if( emsi_seq )
		{
			emsi_seq = 0;
			DEB((D_HSHAKE, "rx_init: bad character 0x%02x in \"%s\"",
					c, string_printable(buf)));
		}
	}
	
	return 1;
}
Exemplo n.º 3
0
/* ------------------------------------------------------------------------- */
void emsi_set_sysinfo(s_emsi *emsi, s_emsi *remote_emsi, int hrc,
                      e_protocol protocol)
{
	char buf[64];
	s_cval_entry *addr_ptr;
	s_cval_entry *hide_ptr;
	s_faddr *primary = NULL;
	
	const long options      = conf_options(cf_options);
	const long speed        = conf_number(cf_max_speed);
	const char *p_systname  = conf_string(cf_system_name);
	const char *p_location  = conf_string(cf_location);
	const char *p_sysopname = conf_string(cf_sysop_name);
	const char *p_phone     = conf_string(cf_phone);
	const char *p_flags     = conf_string(cf_flags);
	const char *p_emsioh    = conf_string(cf_emsi_OH_time);
	const char *p_emsifr    = conf_string(cf_emsi_FR_time);

	/* free previously allocated memory */
//	if( emsi->addrs ) free(emsi->addrs);
		
	memset(emsi, '\0', sizeof(s_emsi));
	
	/* ----------------------------------------------------------------- */
	/* Data for {EMSI} field                                             */
	/* ----------------------------------------------------------------- */
	emsi->have_emsi = 1;
	
	/* Set best primary address */
	primary = session_get_bestaka(state.node.addr);
		
	/* Add primary address */
	if( primary )
		session_addrs_add(&state.localaddrs, &state.n_localaddr, *primary);

	/* Add other AKAs */
	for( addr_ptr = conf_first(cf_address); addr_ptr;
	     addr_ptr = conf_next(addr_ptr) )
	{
		for( hide_ptr = conf_first(cf_hide_our_aka); hide_ptr;
		     hide_ptr = conf_next(hide_ptr) )
		{
			if( !ftn_addrcomp(hide_ptr->d.falist.addr, addr_ptr->d.falist.addr) )
				break;
		}
		
		if( !hide_ptr && primary != &addr_ptr->d.falist.addr )
			session_addrs_add(&state.localaddrs, &state.n_localaddr,
					addr_ptr->d.falist.addr);
	}
	
	if( state.localaddrs == 0 )
		log("warning: no addresses will be presented to remote");

	/* session password */
	if( state.caller )
	{
		session_get_password(state.node.addr, emsi->passwd, sizeof(emsi->passwd));
	}
	else if( hrc == HRC_OK )
	{
		/* Satisfy remote with their password */
		const char *p = state.handshake->remote_password(state.handshake);
		if( p )
			strnxcpy(emsi->passwd, p, sizeof(emsi->passwd));
	}
	
	/* link codes */
	if( state.caller ) /* CALLER */
	{
		if( (options & OPTIONS_NO_RH1)   != OPTIONS_NO_RH1
		 && (options & OPTIONS_NO_HYDRA) != OPTIONS_NO_HYDRA)
			{ emsi->linkcodes.RH1 = 1; }
		
		if( (options & OPTIONS_NO_PICKUP) == OPTIONS_NO_PICKUP )
			{ emsi->linkcodes.NPU = 1; }
		else
			{ emsi->linkcodes.PUA = 1; }
			
		if( (options & OPTIONS_MAILONLY) == OPTIONS_MAILONLY )
			{ emsi->linkcodes.HXT = 1; }
		
		if( (options & OPTIONS_NO_EMSI_II) != OPTIONS_NO_EMSI_II )
		{
			/* EMSI-II */
			if( (options & OPTIONS_HOLDREQ) != OPTIONS_HOLDREQ )
				{ emsi->linkcodes.RMA = 1; }
		}
		else
		{
			/* EMSI-I */
			emsi->linkcodes.N81 = 1;
		}
	}
	else if( (remote_emsi->compcodes.EII == 1)
	      && (options & OPTIONS_NO_EMSI_II) != OPTIONS_NO_EMSI_II )
	{
		/* ANSWER/EMSI-II */
		if( remote_emsi->linkcodes.RH1 && protocol == PROT_HYDRA )
			{ emsi->linkcodes.RH1 = 1; }
		
		if( state.reqstat == REQS_ALLOW && remote_emsi->linkcodes.RMA )
			{ emsi->linkcodes.RMA = 1; }
		else if( state.reqstat == REQS_NOTALLOW )
			{ emsi->linkcodes.HRQ = 1; }
		
		if( (options & OPTIONS_MAILONLY) == OPTIONS_MAILONLY )
			{ emsi->linkcodes.HXT = 1; }
	}
	else
	{
		/* ANSWER/EMSI-I */
		if( remote_emsi->linkcodes.RH1 && protocol == PROT_HYDRA )
			{ emsi->linkcodes.RH1 = 1; }
		
		if( state.reqstat == REQS_NOTALLOW )
			{ emsi->linkcodes.HRQ = 1; }
		
		if( (options & OPTIONS_MAILONLY) == OPTIONS_MAILONLY )
			{ emsi->linkcodes.HXT = 1; }
	}
	
	/* compatibility codes */
	if( state.caller )
	{
		if( (options & OPTIONS_NO_EMSI_II) != OPTIONS_NO_EMSI_II )
		{
			/* EMSI-II */
			emsi->compcodes.EII = 1;
		}
		else
		{
			/* EMSI-I */
			emsi->compcodes.ARC = 1;
			emsi->compcodes.XMA = 1;
		}
		if( (options & OPTIONS_NO_ZMODEM) != OPTIONS_NO_ZMODEM )
			{ emsi->compcodes.ZMO = 1; }
		if( (options & OPTIONS_NO_ZEDZAP) != OPTIONS_NO_ZEDZAP )
			{ emsi->compcodes.ZAP = 1; }
		if( (options & OPTIONS_NO_DIRZAP) != OPTIONS_NO_DIRZAP )
			{ emsi->compcodes.DZA = 1; }
		if( (options & OPTIONS_NO_JANUS) != OPTIONS_NO_JANUS )
			{ emsi->compcodes.JAN = 1; }
		if( (options & OPTIONS_NO_HYDRA) != OPTIONS_NO_HYDRA )
			{ emsi->compcodes.HYD = 1; }
	}
	else
	{
		if( (remote_emsi->compcodes.EII == 1)
		 && (options & OPTIONS_NO_EMSI_II) != OPTIONS_NO_EMSI_II )
		{
			/* EMSI-II */
			emsi->compcodes.EII = 1;
		}
		else
		{
			/* EMSI-I */
			emsi->compcodes.ARC = 1;
			emsi->compcodes.XMA = 1;
		}
		
		if( state.reqstat == REQS_DISABLED )
			{ emsi->compcodes.NRQ = 1; }
			
		switch(protocol) {
		case PROT_NOPROT: emsi->compcodes.NCP = 1; break;
		case PROT_ZMODEM: emsi->compcodes.ZMO = 1; break;
		case PROT_ZEDZAP: emsi->compcodes.ZAP = 1; break;
		case PROT_DIRZAP: emsi->compcodes.DZA = 1; break;
		case PROT_JANUS:  emsi->compcodes.JAN = 1; break;
		case PROT_HYDRA:  emsi->compcodes.HYD = 1; break;
		default:          ASSERT(FALSE);           break;
		}
	}
	
	strnxcpy(emsi->m_pid,  BF_EMSI_NUM,  sizeof(emsi->m_pid));
	strnxcpy(emsi->m_name, BF_EMSI_NAME, sizeof(emsi->m_name));
	
	if( hrc != HRC_BAD_PASSWD )
	{
		strnxcpy(emsi->m_ver,  BF_EMSI_VER,  sizeof(emsi->m_ver));
		strnxcpy(emsi->m_reg,  BF_EMSI_REG,  sizeof(emsi->m_reg));
	}
	else
	{
		strnxcpy(emsi->m_ver, "?", sizeof(emsi->m_ver));
		strnxcpy(emsi->m_reg, "?", sizeof(emsi->m_reg));
	}

	/* ----------------------------------------------------------------- */
	/* Data for {IDENT} field                                            */
	/* ----------------------------------------------------------------- */
	emsi->have_ident = 1;
	emsi->speed = (speed > 0) ? speed : 300;
	
	strnxcpy(emsi->sysop, p_sysopname ? p_sysopname : "Unknown", sizeof(emsi->sysop));
	strnxcpy(emsi->phone, p_phone     ? p_phone     : "Unknown", sizeof(emsi->phone));
	
	switch(hrc) {
	case HRC_BAD_PASSWD:
		strnxcpy(emsi->sname,    "Bad password", sizeof(emsi->sname));
		strnxcpy(emsi->location, "Check security table", sizeof(emsi->location));
		strnxcpy(emsi->flags,    "Password Error", sizeof(emsi->flags));
		break;
	case HRC_LOW_SPEED:
		strnxcpy(emsi->sname,    "Connect speed too low", sizeof(emsi->sname));
		strnxcpy(emsi->location, "Buy new modem and call again", sizeof(emsi->location));
		sprintf(buf, "Minimal speed: %ldbps", (long)state.minspeed);
		strnxcpy(emsi->flags,    buf, sizeof(emsi->flags));
		break;
	case HRC_BUSY:
		strnxcpy(emsi->sname,    "All AKAs are busy", sizeof(emsi->sname));
		strnxcpy(emsi->location, "Possible another session is running", sizeof(emsi->location));
		strnxcpy(emsi->flags,    "Please, call later", sizeof(emsi->flags));
		break;
	default:
		strnxcpy(emsi->sname,    p_systname  ? p_systname  : "Unknown", sizeof(emsi->sname));
		strnxcpy(emsi->location, p_location  ? p_location  : "Unknown", sizeof(emsi->location));
		strnxcpy(emsi->flags,    p_flags     ? p_flags     : "MO",      sizeof(emsi->flags));
	}
	
	/* ----------------------------------------------------------------- */
	/* Data for {OHFR} field                                             */
	/* ----------------------------------------------------------------- */
	if( p_emsioh && *p_emsioh && hrc != HRC_BAD_PASSWD )
	{
		emsi->have_ohfr = 1;
		strnxcpy(emsi->oh_time, p_emsioh, sizeof(emsi->oh_time));
		if( p_emsifr && *p_emsifr )
			strnxcpy(emsi->fr_time, p_emsifr, sizeof(emsi->fr_time));
	}
	
	/* ----------------------------------------------------------------- */
	/* Data for {TRX#} field                                             */
	/* ----------------------------------------------------------------- */
	emsi->have_trx = 1;
	emsi->time = localtogmt(time(NULL));
	
	/* ----------------------------------------------------------------- */
	/* Data for {TRAF} and {MOH#} fields                                 */
	/* ----------------------------------------------------------------- */
	if( state.caller == 0 && hrc != HRC_BAD_PASSWD )
	{
		emsi->have_traf = 1;
		emsi->netmail_size = state.traff_send.netmail_size;
		emsi->arcmail_size = state.traff_send.arcmail_size;
		if ( state.traff_send.files_size )
		{
			emsi->have_moh = 1;
			emsi->files_size = state.traff_send.files_size;
		}	
	}
}
Exemplo n.º 4
0
/* ------------------------------------------------------------------------- */
int session_init_outgoing()
{
	int    c = 0;
	int    tries = 0;
	int    pos_emsi = 0;
	int    pos_intro = 0;
	bool   canemsi = FALSE;
	bool   canyoohoo = FALSE;
	bool   canftsc = FALSE;
	bool   canintro = FALSE;
	char   buf_emsi[13];
	char   buf_intro[256];
	int    emsi_seq = 0;    /* start reading emsi sequence     */
	int    enqcount = 0;    /* number of ENQ received          */
	int    nakcount = 0;    /* number of NAK or 'C' received   */
	int    enq_need = 1;
	int    nak_need = 1;
	time_t mast_timer = 0;  /* master timer, seems to be 60sec */
	time_t sync_timer = 0;  /* resync every .. seconds         */
	long   options = conf_options(cf_options);
	int    intro_lines = 0;
	int    intro_count = 0;
	int    unexp_count = 0;

	state.session = SESSION_UNKNOWN;
	
	if( (options & OPTIONS_NO_EMSI) != OPTIONS_NO_EMSI )
		canemsi = TRUE;
	if( (options & OPTIONS_NO_YOOHOO) != OPTIONS_NO_YOOHOO )
		canyoohoo = TRUE;
	if( (options & OPTIONS_NO_FTS1) != OPTIONS_NO_FTS1 )
		canftsc = TRUE;
	if( (options & OPTIONS_NO_INTRO) != OPTIONS_NO_INTRO )
		canintro = TRUE;
	
	enq_need = canemsi ? 2 : 1;
	nak_need = (canemsi || canyoohoo) ? 2 : 1;
	
	/*
	 * Put CR until any character received
	 */
	if( PUTCHAR('\r') < 0 || FLUSHOUT() < 0 ) {
		log("error: output");
		return 1;
	}
	
	while( !CHARWAIT(1) )
	{
		if( ++tries > 15 )
		{
			log("too much tries waking remote");
			return 1;
		}
		
		if( PUTCHAR('\r') < 0 || FLUSHOUT() < 0 ) {
			log("error: output");
			return 1;
		}
	}
	
#ifdef DEBUG
	if( tries > 0 )
		DEB((D_HSHAKE, "tx_init: remote waked on %d try", tries));
#endif
	
	/*
	 * Safety is the 1st law
	 */
	*buf_emsi = '\0';
	*buf_intro = '\0';
	
	/*
	 * Start timers
	 */
	timer_set(&mast_timer, OUTGOING_MAST_TIMER);
	timer_set(&sync_timer, OUTGOING_SYNC_TIMER*2);

	/*
	 * Determine supported handshakes on called system
	 * (support for FTS-1, YooHoo, EMSI)
	 */
	while(1)
	{
		if( timer_expired(mast_timer) )
		{
			log("session initialisation timed out");
			DEB((D_HSHAKE, "handshake initialisation timed out"));
			
			return 1;
		}
		
		if( timer_expired(sync_timer) )
		{
			DEB((D_HSHAKE, "tx_sendsync: resyncing"));
			
			if( canemsi && PUTSTR("**EMSI_INQC816**EMSI_INQC816") < 0 ) {
				log("error: output");
				return 1;
			}
			if( canyoohoo && PUTCHAR(YOOHOO) < 0 ) {
				log("error: output");
				return 1;
			}
			if( canftsc && PUTCHAR(TSYNC) < 0 ) {
				log("error: output");
				return 1;
			}
			if( canemsi && PUTCHAR('\r') < 0 ) {
				log("error: output");
				return 1;
			}

			if( FLUSHOUT() < 0 ) {
				log("error: flush");
				return 1;
			}
			
			timer_set(&sync_timer, OUTGOING_SYNC_TIMER);
		}
		
		/*
		 * Pickup next char
		 */
		c = GETCHAR(1);
		
		if( canintro && c > 0 )
		{
			if( c == XON || c == XOFF )
			{
				/* Do nothing. Drop them down */
			}
			else if( c == '\r' || c == '\n' )
			{
				if( pos_intro > 0 )
				{
					intro_lines += 1;
					intro_count += pos_intro;
					
					recode_intro_in(buf_intro);
					log("intro: \"%s\"",
						string_printable(buf_intro));
					
					pos_intro = 0;
					buf_intro[0] = '\0';
				}
			}
			else if( pos_intro < sizeof(buf_intro) - 1 )
			{
				buf_intro[pos_intro++] = (char)c;
				buf_intro[pos_intro  ] = '\0';
			}
			
			if( pos_intro >= sizeof(buf_intro) - 1 )
			{
				intro_lines += 1;
				intro_count += pos_intro;
				
				recode_intro_in(buf_intro);
				log("intro buffer is full");
				log("intro: \"%s\"",
					string_printable(buf_intro));
				
				pos_intro = 0;
				buf_intro[0] = '\0';
			}

			if( intro_lines >= INTRO_MAX_LINES )
			{
				log("stop logging intro: %d lines limit", intro_lines);
				canintro = FALSE;
			}
			else if( intro_count >= INTRO_MAX_SIZE )
			{
				log("stop logging intro: %d bytes limit", intro_count);
				canintro = FALSE;
			}
		}
		
		if( c < 0 )
		{
			if( c != TTY_TIMEOUT )
			{
				DEB((D_HSHAKE, "tx_init: got TTY_ERROR/TTY_HANGUP"));
				return 1;
			}				
		}
		else if( c == XON || c == XOFF )
		{
			/* Do nothing. Drop them down */
		}
		else if( c == ENQ )
		{
			if( enq_need && ++enqcount >= enq_need && canyoohoo )
			{
				DEB((D_HSHAKE, "tx_init: exit with YooHoo"));
				state.session = SESSION_YOOHOO;
				return 0;
			}
		}
		else if( c == TSYNC )
		{
			if( nak_need && ++nakcount > nak_need && canftsc )
			{
				DEB((D_HSHAKE, "tx_init: exit with FTS-1"));
				state.session = SESSION_FTSC;
				return 0;
			}
		}
		else if( canemsi && c > ' ' && c < '~' )
		{
			if( c != 'C' )
				nakcount = 0;
			
			enqcount = 0;
			
			if( c == '*' )
			{
				memset(buf_emsi, '\0', sizeof(buf_emsi));
				pos_emsi = 0;
				emsi_seq = 1;
			}
			else if( emsi_seq )
			{
				if( pos_emsi < sizeof(buf_emsi)-1 )
				{
					buf_emsi[pos_emsi++] = (char)c;
					buf_emsi[pos_emsi  ] = '\0';
				}
			
				if( pos_emsi >= sizeof(buf_emsi)-1 )
				{
					emsi_seq = 0;
					
					DEB((D_HSHAKE, "tx_init: emsi buffer full \"%s\"",
							string_printable(buf_emsi)));
					
					if( !strncasecmp(buf_emsi, "EMSI_REQA77E", 12)
					 || !strncasecmp(buf_emsi, "EMSI_NAKEEC3", 12) )
					{
						DEB((D_HSHAKE, "tx_init: exit with EMSI"));
						state.session = SESSION_EMSI;
						
						if( PUTSTR("**EMSI_INQC816\r") < 0
						 || PUTSTR("**EMSI_INQC816\r") < 0 ) {
							log("error: output");
							return 1;
						}
						if( FLUSHOUT() < 0 ) {
							log("error: output");
							return 1;
						}
						
						return 0;
					}
					else if( !strncasecmp(buf_emsi, "EMSI_INQC816", 12) )
					{
						/*
						 * Most probable it is echo of
						 * our own EMSI_INQ, try to send
						 * separated EMSI_INQ as user
						 * name and password to be sure
						 * that they understand us.
						 */

						/* Wait for a login prompt */
						sleep(3);
						
						if( PUTSTR("**EMSI_INQC816\r") < 0
						 || FLUSHOUT() < 0 ) {
							log("error: flush");
							return 1;
						}

						/* Wait for a password prompt */
						sleep(2);
						
						if( PUTSTR("**EMSI_INQC816\r") < 0
						 || FLUSHOUT() < 0 ) {
							log("error: output");
							return 1;
						}
						
						timer_set(&sync_timer, OUTGOING_SYNC_TIMER);
					}
					else if( !strncasecmp(buf_emsi, "EMSI", 4) )
					{
						log("unexpected emsi sequence \"%s\"",
								string_printable(buf_emsi));
						
						if( ++unexp_count > 10 )
						{
							log("too many unexpected emsi sequences");
							return 1;
						}
					}
				}
			}
		}
		else if( emsi_seq )
		{
			emsi_seq = 0;
			DEB((D_HSHAKE, "sm_rx_waitseq: bad character 0x%02x in \"%s\"",
					c, string_printable(buf_emsi)));
		}
	}
	//log("session_init_outgoing: end loop");

	return 1;
}