Update of /cvsroot/linux-decnet/latd
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31574
Modified Files:
moprc.cc moprc.8
Removed Files:
TODO.moprc
Log Message:
Add -p to change poll timer.
Add some basic changes to make it scriptable (ie it will take a file as stdin)
Index: moprc.cc
===================================================================
RCS file: /cvsroot/linux-decnet/latd/moprc.cc,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** moprc.cc 24 Mar 2004 15:39:02 -0000 1.9
--- moprc.cc 25 Mar 2004 15:59:02 -0000 1.10
***************
*** 1,4 ****
/******************************************************************************
! (c) 2001-2003 patrick Caulfield pa...@de...
This program is free software; you can redistribute it and/or modify
--- 1,4 ----
/******************************************************************************
! (c) 2001-2004 patrick Caulfield pa...@de...
This program is free software; you can redistribute it and/or modify
***************
*** 60,64 ****
static int last_message_len;
static int show_info = 0;
! static int do_moprc(u_int8_t *, int, int);
static int send_boot(u_int8_t *macaddr, int interface);
static LATinterfaces *iface;
--- 60,64 ----
static int last_message_len;
static int show_info = 0;
! static int do_moprc(u_int8_t *, int, int, int);
static int send_boot(u_int8_t *macaddr, int interface);
static LATinterfaces *iface;
***************
*** 75,78 ****
--- 75,79 ----
fprintf(f, " -b Make ^H send DEL\n");
fprintf(f, " -v Show target information\n");
+ fprintf(f, " -p <ms> Set poll interval (default 200)\n");
fprintf(f, "\n");
fprintf(f, "Node names are read from /etc/ethers\n");
***************
*** 112,115 ****
--- 113,117 ----
int trigger=0;
int convert_bs = 0;
+ int poll_interval = 200; /* in ms */
char ifname_buf[255];
char *ifname;
***************
*** 126,130 ****
/* Get command-line options */
opterr = 0;
! while ((opt=getopt(argc,argv,"?hVvtbi:")) != EOF)
{
switch(opt)
--- 128,132 ----
/* Get command-line options */
opterr = 0;
! while ((opt=getopt(argc,argv,"?hVvtbi:p:")) != EOF)
{
switch(opt)
***************
*** 153,156 ****
--- 155,162 ----
break;
+ case 'p':
+ poll_interval = atoi(optarg);
+ break;
+
case 'V':
printf("\nMoprc version %s\n\n", VERSION);
***************
*** 213,217 ****
}
! return do_moprc(addr.ether_addr_octet, interface, convert_bs);
}
--- 219,223 ----
}
! return do_moprc(addr.ether_addr_octet, interface, convert_bs, poll_interval*1000);
}
***************
*** 370,374 ****
}
! static int do_moprc(u_int8_t *macaddr, int interface, int convert_bs)
{
enum {STARTING, CONNECTED} state=STARTING;
--- 376,380 ----
}
! static int do_moprc(u_int8_t *macaddr, int interface, int convert_bs, int timeout)
{
enum {STARTING, CONNECTED} state=STARTING;
***************
*** 381,388 ****
int last_msg_tag = 99; /* Dummy */
int status;
- int timeout = 200000; /* Poll interval */
int waiting_ack;
int resends = 0;
int termfd = STDIN_FILENO;
tcgetattr(termfd, &old_term);
--- 387,395 ----
int last_msg_tag = 99; /* Dummy */
int status;
int waiting_ack;
int resends = 0;
int termfd = STDIN_FILENO;
+ int stdin_is_tty;
+ int last_packet_was_empty=1;
tcgetattr(termfd, &old_term);
***************
*** 410,423 ****
tv.tv_usec = 0;
/* Loop for input */
while ( (status = select(FD_SETSIZE, &in, NULL, NULL, &tv)) >= 0)
{
! /* No data, poll for any input from the terminal server */
! if (status == 0 && !waiting_ack)
{
! unsigned char dummybuf[1];
! send_data(dummybuf, 0, macaddr, interface);
! waiting_ack = 1;
! resends = 0;
}
--- 417,430 ----
tv.tv_usec = 0;
+ stdin_is_tty = isatty(STDIN_FILENO);
+
/* Loop for input */
while ( (status = select(FD_SETSIZE, &in, NULL, NULL, &tv)) >= 0)
{
! /* No response after 3 tries */
! if (waiting_ack && resends >= 3)
{
! printf("\nTarget does not respond\n");
! break;
}
***************
*** 427,435 ****
{
send_last_message(interface, macaddr);
! if (++resends == 3)
! {
! printf("\nTarget does not respond\n");
! break;
! }
}
--- 434,448 ----
{
send_last_message(interface, macaddr);
! resends++;
! continue;
! }
!
! /* No data, poll for any input from the terminal server */
! if (status == 0 && !waiting_ack)
! {
! unsigned char dummybuf[1];
! send_data(dummybuf, 0, macaddr, interface);
! waiting_ack = 1;
! resends = 0;
}
***************
*** 467,478 ****
/* Got some data to display */
case MOPRC_CMD_RESPONSE:
! if (datalen >= 2)
{
! int i;
! for (i=0; i<datalen-2; i++)
! {
! fputc(buf[4+i], stdout);
! }
fflush(stdout);
}
break;
--- 480,492 ----
/* Got some data to display */
case MOPRC_CMD_RESPONSE:
! if (datalen > 2)
{
! fwrite(buf+4, datalen-2, 1, stdout);
fflush(stdout);
+ last_packet_was_empty = 0;
+ }
+ else
+ {
+ last_packet_was_empty = 1;
}
break;
***************
*** 489,493 ****
}
! if (isatty(STDIN_FILENO))
printf("Console connected (press CTRL/D when finished)\n");
--- 503,507 ----
}
! if (stdin_is_tty)
printf("Console connected (press CTRL/D when finished)\n");
***************
*** 505,509 ****
{
int i;
! len = read(STDIN_FILENO, buf, sizeof(buf));
if (len < 0)
{
--- 519,523 ----
{
int i;
! len = read(STDIN_FILENO, buf, stdin_is_tty ? sizeof(buf) : 1);
if (len < 0)
{
***************
*** 531,535 ****
FD_ZERO(&in);
FD_SET(mop_socket, &in);
! if (!waiting_ack) FD_SET(STDIN_FILENO, &in);
}
--- 545,549 ----
FD_ZERO(&in);
FD_SET(mop_socket, &in);
! if (!waiting_ack && last_packet_was_empty) FD_SET(STDIN_FILENO, &in);
}
Index: moprc.8
===================================================================
RCS file: /cvsroot/linux-decnet/latd/moprc.8,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** moprc.8 17 Mar 2003 09:33:03 -0000 1.4
--- moprc.8 25 Mar 2004 15:59:03 -0000 1.5
***************
*** 37,43 ****
--- 37,51 ----
.TP
+ .I \-p <n>
+ Changes the poll interval of moprc from 200 ms to <n> ms. Changing
+ this down will increase the risk of timeouts, increasing it will
+ decrease the speed of the link.
+
+
+ .TP
.I \-h \-?
Shows the usage message.
+
.TP
.I \-V
***************
*** 57,61 ****
.SH BUGS
! On Darwin you MUST use /etc/ethers
.SS SEE ALSO
.BR latd "(8), " latd.conf "(5), " ethers "(5), " llogin "(1)"
\ No newline at end of file
--- 65,76 ----
.SH BUGS
! On Darwin you cannot specify an ethernet address on the command-line,
! the name MUST be in /etc/ethers.
! .br
! You can script moprc but it sends one character per ethernet packet so
! is very slow.
! .br
! There is no locking in moprc so be careful to only run once instance
! at a time.
.SS SEE ALSO
.BR latd "(8), " latd.conf "(5), " ethers "(5), " llogin "(1)"
\ No newline at end of file
--- TODO.moprc DELETED ---
|