Added experimental incoming code

This commit is contained in:
Michiel Broek 2004-02-01 15:06:16 +00:00
parent 6bf1f36cee
commit 9142e31a1b
3 changed files with 86 additions and 1 deletions

View File

@ -135,7 +135,7 @@ scanout.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/reco
emsi.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/nodelist.h ../lib/dbnode.h ../lib/clcomm.h ../lib/mberrors.h ttyio.h session.h statetbl.h config.h emsi.h emsidat.h hydra.h rdoptions.h tcp.h wazoo.h inbound.h emsi.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/nodelist.h ../lib/dbnode.h ../lib/clcomm.h ../lib/mberrors.h ttyio.h session.h statetbl.h config.h emsi.h emsidat.h hydra.h rdoptions.h tcp.h wazoo.h inbound.h
ulock.o: ../config.h ../lib/libs.h ../lib/clcomm.h ulock.o: ../config.h ../lib/libs.h ../lib/clcomm.h
callstat.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h callstat.h callstat.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h callstat.h
session.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/nodelist.h ../lib/mberrors.h ttyio.h statetbl.h emsi.h ftsc.h session.h yoohoo.h mbcico.h binkp.h callstat.h inbound.h opentcp.h session.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/nodelist.h ../lib/mberrors.h ttyio.h statetbl.h emsi.h ftsc.h session.h yoohoo.h mbcico.h binkp.h callstat.h inbound.h opentcp.h telnet.h
call.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/nodelist.h ../lib/clcomm.h ../lib/dbnode.h ../lib/mberrors.h session.h callstat.h call.h config.h dial.h lutil.h portsel.h openport.h opentcp.h rdoptions.h inbound.h call.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/nodelist.h ../lib/clcomm.h ../lib/dbnode.h ../lib/mberrors.h session.h callstat.h call.h config.h dial.h lutil.h portsel.h openport.h opentcp.h rdoptions.h inbound.h
mbcico.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/nodelist.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbftn.h ../lib/mberrors.h config.h answer.h call.h lutil.h mbcico.h session.h mbcico.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/nodelist.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbftn.h ../lib/mberrors.h config.h answer.h call.h lutil.h mbcico.h session.h
outstat.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/nodelist.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbftn.h ../lib/mberrors.h scanout.h callstat.h outstat.h outstat.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/nodelist.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbftn.h ../lib/mberrors.h scanout.h callstat.h outstat.h

View File

@ -48,6 +48,7 @@
#include "callstat.h" #include "callstat.h"
#include "inbound.h" #include "inbound.h"
#include "opentcp.h" #include "opentcp.h"
#include "telnet.h"
extern int tcp_mode; extern int tcp_mode;
@ -86,6 +87,10 @@ int session(faddr *a, node *nl, int role, int tp, char *dt)
{ {
int rc = MBERR_OK, addrlen = sizeof(struct sockaddr_in); int rc = MBERR_OK, addrlen = sizeof(struct sockaddr_in);
fa_list *tmpl; fa_list *tmpl;
#ifdef USE_EXPERIMENT
int Fdo, input_pipe[2], output_pipe[2];
pid_t fpid;
#endif
session_flags = 0; session_flags = 0;
type = tp; type = tp;
@ -113,6 +118,77 @@ int session(faddr *a, node *nl, int role, int tp, char *dt)
#ifdef USE_EXPERIMENT #ifdef USE_EXPERIMENT
if ((tcp_mode == TCPMODE_ITN) && (role == 0)) { if ((tcp_mode == TCPMODE_ITN) && (role == 0)) {
Syslog('-', "Will need to install telnet receiver thread"); Syslog('-', "Will need to install telnet receiver thread");
/*
* First make sure the current input socket gets a new file descriptor
* since it's now on stadin and stdout.
*/
Fdo = dup(0);
Syslog('s', "session: new socket %s", Fdo);
/*
* Close stdin and stdout so that when we create the pipes to
* the telnet filter they get stdin and stdout as file descriptors.
*/
fflush(stdin);
fflush(stdout);
setbuf(stdin,NULL);
setbuf(stdout, NULL);
close(0);
close(1);
/*
* Create output pipe and start output filter.
*/
if (pipe(output_pipe) == -1) {
WriteError("$could not create output_pipe");
die(MBERR_TTYIO_ERROR);
}
fpid = fork();
switch (fpid) {
case -1: WriteError("fork for telout_filter failed");
die(MBERR_TTYIO_ERROR);
case 0: if (close(output_pipe[1]) == -1) {
WriteError("$error close output_pipe[1]");
die(MBERR_TTYIO_ERROR);
}
telout_filter(output_pipe[0], Fdo);
/* NOT REACHED */
}
if (close(output_pipe[0] == -1)) {
WriteError("$error close output_pipe[0]");
die(MBERR_TTYIO_ERROR);
}
Syslog('s', "telout_filter forked with pid %d", fpid);
/*
* Create input pipe and start input filter
*/
if (pipe(input_pipe) == -1) {
WriteError("$could not create input_pipe");
die(MBERR_TTYIO_ERROR);
}
fpid = fork();
switch (fpid) {
case -1: WriteError("fork for telin_filter failed");
die(MBERR_TTYIO_ERROR);
case 0: if (close(input_pipe[0]) == -1) {
WriteError("$error close input_pipe[0]");
die(MBERR_TTYIO_ERROR);
}
telin_filter(input_pipe[1], Fdo);
/* NOT REACHED */
}
if (close(input_pipe[1]) == -1) {
WriteError("$error close input_pipe[1]");
die(MBERR_TTYIO_ERROR);
}
Syslog('s', "telin_filter forked with pid %d", fpid);
Syslog('s', "stdout = %d", output_pipe[1]);
Syslog('s', "stdin = %d", input_pipe[0]);
telnet_init(Fdo);
} }
#endif #endif
} }

View File

@ -40,11 +40,17 @@
#include "telnet.h" #include "telnet.h"
/*
* Telnet I/O filters. See RFC854 for details.
*/
#ifdef USE_EXPERIMENT #ifdef USE_EXPERIMENT
/*
* Send options to the remote.
*/
void telnet_init(int Fd) void telnet_init(int Fd)
{ {
Syslog('s', "telnet_init(%d)", Fd); Syslog('s', "telnet_init(%d)", Fd);
@ -58,6 +64,9 @@ void telnet_init(int Fd)
/*
* Answer options requested by remote.
*/
void telnet_answer(int tag, int opt, int Fd) void telnet_answer(int tag, int opt, int Fd)
{ {
char buf[3]; char buf[3];