diff -rc dip-3.3.7g/Makefile dip-3.3.7h/Makefile *** dip-3.3.7g/Makefile Wed Aug 31 02:04:05 1994 --- dip-3.3.7h/Makefile Fri Sep 2 12:45:40 1994 *************** *** 32,45 **** # would like (:-). I don't use it myself, won't test # it and won't care. ! SKEYDEF = -DSKEY ! SKEYLIB = -L/usr/local/lib -lskey CC = gcc -pipe -O6 -Wall -m486 -fomit-frame-pointer LD = gcc CFLAGS = -DLINUX $(SKEYDEF) ! LDFLAGS = -s -N LIBS = $(SKEYLIB) --- 32,45 ---- # would like (:-). I don't use it myself, won't test # it and won't care. ! #SKEYDEF = -DSKEY ! #SKEYLIB = -L/usr/local/lib -lskey CC = gcc -pipe -O6 -Wall -m486 -fomit-frame-pointer LD = gcc CFLAGS = -DLINUX $(SKEYDEF) ! LDFLAGS = -s -Xlinker -qmagic LIBS = $(SKEYLIB) diff -rc dip-3.3.7g/README dip-3.3.7h/README *** dip-3.3.7g/README Tue Aug 30 22:24:22 1994 --- dip-3.3.7h/README Fri Sep 2 12:45:40 1994 *************** *** 85,92 **** Oh, Pauline's patches add the ability not to have DIP users listed in /etc/passwd file at all, being completely defined ! in /etc/diphosts... I don't like it, but if you want it, ! you get it. TAKE A LOOK at "sample.dip" file - it's there for a purpose. (:-) SAME IS TRUE for "diphosts". --- 85,92 ---- Oh, Pauline's patches add the ability not to have DIP users listed in /etc/passwd file at all, being completely defined ! in /etc/diphosts... (Ala taylor UUCP) I don't like it, but ! if you want it, you get it. TAKE A LOOK at "sample.dip" file - it's there for a purpose. (:-) SAME IS TRUE for "diphosts". diff -rc dip-3.3.7g/attach.c dip-3.3.7h/attach.c *** dip-3.3.7g/attach.c Wed Aug 31 06:44:51 1994 --- dip-3.3.7h/attach.c Fri Sep 2 12:45:40 1994 *************** *** 314,332 **** int ! attach(char *name, struct dip *dip) { char buff[1024]; - bzero(buff, sizeof(buff)); - memcpy((char *)&_dip, (char *)dip, sizeof(struct dip)); /* Some more updates will be here - made by Paul Cadach */ /* Set up for "upping" the desired interface. */ sprintf(buff, "%s %s %s pointopoint ", _PATH_BIN_IFCONFIG, ! name, inet_ntoa(dip->loc_ip)); sprintf(&buff[strlen(buff)], "%s mtu %d ", inet_ntoa(dip->rmt_ip), dip->mtu); if (dip->netmask[0] != '\0') --- 314,330 ---- int ! attach(struct dip *dip) { char buff[1024]; memcpy((char *)&_dip, (char *)dip, sizeof(struct dip)); /* Some more updates will be here - made by Paul Cadach */ /* Set up for "upping" the desired interface. */ sprintf(buff, "%s %s %s pointopoint ", _PATH_BIN_IFCONFIG, ! dip->ifname, inet_ntoa(dip->loc_ip)); sprintf(&buff[strlen(buff)], "%s mtu %d ", inet_ntoa(dip->rmt_ip), dip->mtu); if (dip->netmask[0] != '\0') *************** *** 338,344 **** /* Add route to the remote IP addr */ sprintf(buff, "%s add %s %s", _PATH_BIN_ROUTE, ! inet_ntoa(dip->rmt_ip), name); if (opt_v) syslog(LOG_INFO, ">>> ATTACH \"%s\"\n", buff); if (system(buff) != 0) return(-1); --- 336,342 ---- /* Add route to the remote IP addr */ sprintf(buff, "%s add %s %s", _PATH_BIN_ROUTE, ! inet_ntoa(dip->rmt_ip), dip->ifname); if (opt_v) syslog(LOG_INFO, ">>> ATTACH \"%s\"\n", buff); if (system(buff) != 0) return(-1); *************** *** 346,352 **** /* the default route goes over the LOCAL adaptor... */ if (dip->rtdefault == 1) { sprintf(buff, "%s add -net default gw %s metric %1d %s", ! _PATH_BIN_ROUTE, inet_ntoa(dip->rmt_ip), 1, name); if (opt_v) syslog(LOG_INFO, ">>> ATTACH \"%s\"\n", buff); if (system(buff) != 0) return(-1); --- 344,350 ---- /* the default route goes over the LOCAL adaptor... */ if (dip->rtdefault == 1) { sprintf(buff, "%s add -net default gw %s metric %1d %s", ! _PATH_BIN_ROUTE, inet_ntoa(dip->rmt_ip), 1, dip->ifname); if (opt_v) syslog(LOG_INFO, ">>> ATTACH \"%s\"\n", buff); if (system(buff) != 0) return(-1); *************** *** 355,361 **** else { /* hosts get added by their local address too.. */ sprintf(buff, "%s add -host %s %s", _PATH_BIN_ROUTE, ! inet_ntoa(dip->loc_ip), name); if (opt_v) syslog(LOG_INFO, ">>> ATTACH \"%s\"\n", buff); if (system(buff) != 0) return(-1); --- 353,359 ---- else { /* hosts get added by their local address too.. */ sprintf(buff, "%s add -host %s %s", _PATH_BIN_ROUTE, ! inet_ntoa(dip->loc_ip), dip->ifname); if (opt_v) syslog(LOG_INFO, ">>> ATTACH \"%s\"\n", buff); if (system(buff) != 0) return(-1); *************** *** 372,391 **** void ! detach(char *name, struct dip *dip) { char buff[1024]; static int flag = 0; - bzero(buff, sizeof(buff)); - /* To make sure we're not called more than once! */ if (flag != 0) return; flag = 1; /* Set up for "downing" the desired interface. */ ! sprintf(buff, "%s %s down", _PATH_BIN_IFCONFIG, name); if (opt_v) syslog(LOG_INFO, ">>> DETACH \"%s\"\n", buff); (void) system(buff); --- 370,387 ---- void ! detach(struct dip *dip) { char buff[1024]; static int flag = 0; /* To make sure we're not called more than once! */ if (flag != 0) return; flag = 1; /* Set up for "downing" the desired interface. */ ! sprintf(buff, "%s %s down", _PATH_BIN_IFCONFIG, dip->ifname); if (opt_v) syslog(LOG_INFO, ">>> DETACH \"%s\"\n", buff); (void) system(buff); diff -rc dip-3.3.7g/command.c dip-3.3.7h/command.c *** dip-3.3.7g/command.c Wed Aug 31 06:39:52 1994 --- dip-3.3.7h/command.c Fri Sep 2 12:45:40 1994 *************** *** 1118,1131 **** return(i); } - /* Quit upon error - reset the tty to the proper ldisc */ - static int - do_quit(int argc, char *argv[]) - { - (void) tty_close(); - exit(1); - } - /* Store the netmask in "mydip" structure */ static int do_netmask(int argc, char *argv[]) --- 1118,1123 ---- *************** *** 1153,1162 **** return(0); } static int do_proxyarp(int argc, char *argv[]) { if (argc != 1) { ! fprintf(stderr, "Usage: default\n"); return(-1); } if (opt_v == 1) printf("Setting Proxy ARP entry...\n"); --- 1145,1168 ---- return(0); } + /* Set timeout */ + static int + do_timeout(int argc, char *argv[]) + { + if (argc != 2) { + fprintf(stderr, "Usage: timeout \n"); + return(-1); + } + mydip.timeout = atoi(argv[1]); + if (opt_v == 1) printf("Timeout set to %d seconds\n",mydip.timeout); + + return(0); + } + static int do_proxyarp(int argc, char *argv[]) { if (argc != 1) { ! fprintf(stderr, "Usage: proxyarp\n"); return(-1); } if (opt_v == 1) printf("Setting Proxy ARP entry...\n"); *************** *** 1499,1505 **** { "proxyarp", do_proxyarp }, { "print", do_print }, { "port", do_port }, - { "quit", do_quit }, { "reset", do_reset }, { "send", do_send }, #ifdef SKEY --- 1505,1510 ---- *************** *** 1509,1514 **** --- 1514,1520 ---- { "speed", do_speed }, { "stopbits", do_stopbits }, { "term", do_term }, + { "timeout", do_timeout }, { "wait", do_wait }, { (char *)NULL, NULL } }; *************** *** 1598,1602 **** cleanup(); #endif ! exit(0); } --- 1604,1608 ---- cleanup(); #endif ! exit(errlevel); } diff -rc dip-3.3.7g/daemon.c dip-3.3.7h/daemon.c *** dip-3.3.7g/daemon.c Wed Aug 31 00:13:26 1994 --- dip-3.3.7h/daemon.c Fri Sep 2 12:45:40 1994 *************** *** 87,92 **** --- 87,108 ---- (void) fclose(fp); } + static + void readifc(char *ifname, int *TX, int *RX) + { + FILE *fp = fopen("/proc/net/dev","r"); + char buf[255]; + + while (fgets(buf,sizeof(buf),fp)) { + char *bp = buf; + while (*bp && isspace(*bp)) bp++; + if (strncmp(bp,ifname,strlen(ifname))==0 && bp[strlen(ifname)]==':') { + sscanf(bp,"%*s %d %*d %*d %*d %*d %d",TX,RX); + break; + } + } + fclose(fp); + } int dip_setup(struct dip *dp) *************** *** 114,120 **** /* Wait forever to terminate. */ do_exit = 1; while(do_exit) { ! (void) sleep(30); } syslog(LOG_ERR, "DIP must never be here!!!\n"); --- 130,146 ---- /* Wait forever to terminate. */ do_exit = 1; while(do_exit) { ! if (dp->timeout) { ! static int oldTX=-1, oldRX=-1; ! int valTX,valRX; ! ! readifc(dp->ifname,&valTX,&valRX); ! if (valTX==oldTX && valRX==oldRX) sig_catcher(0); ! oldTX = valTX; ! oldRX = valRX; ! sleep(dp->timeout); ! } ! else (void) sleep(30); } syslog(LOG_ERR, "DIP must never be here!!!\n"); Only in dip-3.3.7g: dip diff -rc dip-3.3.7g/dip.h dip-3.3.7h/dip.h *** dip-3.3.7g/dip.h Wed Aug 31 06:49:08 1994 --- dip-3.3.7h/dip.h Fri Sep 2 12:45:40 1994 *************** *** 69,75 **** struct dip { /* Login info. */ char name[16]; /* login name of host */ ! char passwd[14]; /* any external passwd */ char home[1024]; /* user home directory */ /* Misc protocol info. */ --- 69,75 ---- struct dip { /* Login info. */ char name[16]; /* login name of host */ ! char passwd[16]; /* any external passwd */ char home[1024]; /* user home directory */ /* Misc protocol info. */ *************** *** 92,97 **** --- 92,99 ---- struct in_addr rmt_rt; /* mapped IP address */ int rtdefault; /* are we the dflt gw? */ int proxyarp; /* set proxy arp? */ + int timeout; /* timeout function? */ + char ifname[32]; /* device name */ }; *************** *** 146,153 **** extern int mdm_reset(void); extern int mdm_hangup(void); ! extern int attach(char *name, struct dip *dip); ! extern void detach(char *name, struct dip *dip); extern void cleanup(void); --- 148,155 ---- extern int mdm_reset(void); extern int mdm_hangup(void); ! extern int attach(struct dip *dip); ! extern void detach(struct dip *dip); extern void cleanup(void); diff -rc dip-3.3.7g/login.c dip-3.3.7h/login.c *** dip-3.3.7g/login.c Tue Aug 30 22:17:13 1994 --- dip-3.3.7h/login.c Fri Sep 2 13:10:28 1994 *************** *** 40,46 **** if (buff[0] == '#' || buff[0] == '\0') continue; sp = buff; ! memset((char *) &dip, 0, sizeof(struct dip)); bp = sp; while (*sp && *sp != ':') sp++; --- 40,46 ---- if (buff[0] == '#' || buff[0] == '\0') continue; sp = buff; ! dip = mydip; bp = sp; while (*sp && *sp != ':') sp++; *************** *** 53,90 **** ) continue; ! strncpy(dip.name, bp, 16); bp = sp; while (*sp && *sp != ':') sp++; *sp++ = '\0'; ! strncpy(dip.passwd, bp, 8); bp = sp; while (*sp && *sp != ':') sp++; *sp++ = '\0'; ! strncpy(dip.remote, bp, 128); bp = sp; while (*sp && *sp != ':') sp++; *sp++ = '\0'; if (*bp) ! strncpy(dip.local, bp, 128); bp = sp; while (*sp && *sp != ':') sp++; *sp++ = '\0'; ! strncpy(dip.netmask, bp, 128); bp = sp; while (*sp && *sp != ':') sp++; *sp++ = '\0'; ! strncpy(dip.comment, bp, 128); bp = sp; while (*sp && *sp != ':' && *sp != ',') sp++; *sp++ = '\0'; ! strncpy(dip.protocol, bp, 16); bp = sp; while (*sp && *sp != ',') sp++; --- 53,90 ---- ) continue; ! strncpy(dip.name, bp, sizeof(dip.name)); bp = sp; while (*sp && *sp != ':') sp++; *sp++ = '\0'; ! strncpy(dip.passwd, bp, sizeof(dip.passwd)); bp = sp; while (*sp && *sp != ':') sp++; *sp++ = '\0'; ! strncpy(dip.remote, bp, sizeof(dip.remote)); bp = sp; while (*sp && *sp != ':') sp++; *sp++ = '\0'; if (*bp) ! strncpy(dip.local, bp, sizeof(dip.local)); bp = sp; while (*sp && *sp != ':') sp++; *sp++ = '\0'; ! strncpy(dip.netmask, bp, sizeof(dip.netmask)); bp = sp; while (*sp && *sp != ':') sp++; *sp++ = '\0'; ! strncpy(dip.comment, bp, sizeof(dip.comment)); bp = sp; while (*sp && *sp != ':' && *sp != ',') sp++; *sp++ = '\0'; ! strncpy(dip.protocol, bp, sizeof(dip.protocol)); bp = sp; while (*sp && *sp != ',') sp++; *************** *** 108,115 **** extern char *h_errlist[]; extern int h_errno; - (void) openlog("dip", LOG_PID, LOG_DAEMON); - if (name) { dip = getdipnam(name); if (dip == (struct dip *)NULL) { --- 108,113 ---- *************** *** 123,129 **** p = getpass("password: "); if ((dip == (struct dip *)NULL) || (strcmp(dip->passwd,p) != 0)) { fprintf(stderr, "You do not have DIP access. Go away.\n"); ! syslog(LOG_WARNING, "%s tried to access DIP: no access!", p); exit(-1); } } --- 121,127 ---- p = getpass("password: "); if ((dip == (struct dip *)NULL) || (strcmp(dip->passwd,p) != 0)) { fprintf(stderr, "You do not have DIP access. Go away.\n"); ! syslog(LOG_WARNING, "%s tried to access DIP: no access!", dip->name); exit(-1); } } *************** *** 191,196 **** --- 189,195 ---- printf("Comments: \"%s\"\n", dip->comment); printf("Protocol: \"%s\" (%d)\n", dip->protocol, dip->protonr); printf("MTU : %d\n", dip->mtu); + printf("Proxy : %d\n", dip->proxyarp); } syslog(LOG_INFO, "%s connecting %s/%s to local %s/%s with %s/%d", dip->name, diff -rc dip-3.3.7g/main.c dip-3.3.7h/main.c *** dip-3.3.7g/main.c Thu Sep 1 01:39:03 1994 --- dip-3.3.7h/main.c Fri Sep 2 13:11:45 1994 *************** *** 31,36 **** --- 31,40 ---- * - Removed the strange parsing of argv[0] which overwrote * part of the string. * - Added code to ask interactivly for username. (-a) + * - added timeout for disconnects after idle seconds + * - removed 'quit', since it is superflucious (see exit) + * - various source changes + * - Well, and since everybody is doing it: (C) 1994. * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General *************** *** 61,74 **** void cleanup(void) { - char name[32]; int disc; if (tty_askfd() >= 0) { if(tty_get_disc(&disc) == 0) { if ((disc > 0) && (disc != N_TTY)) { ! tty_get_name(name); ! detach(name, &mydip); } } if (tty_getmode()) --- 65,76 ---- void cleanup(void) { int disc; if (tty_askfd() >= 0) { if(tty_get_disc(&disc) == 0) { if ((disc > 0) && (disc != N_TTY)) { ! detach(&mydip); } } if (tty_getmode()) *************** *** 261,266 **** --- 263,269 ---- opt_t = 0; Argv = argv[0]; + while (*envp) envp++; LastArg = envp[-1] + strlen(envp[-1]); /* *************** *** 277,284 **** else sp = argv[0]; #else if ((sp = strrchr(argv[0], '/')) == NULL) sp = argv[0]; #endif ! if ((*sp == '-') || !strcmp(sp, "diplogin") || !strcmp(sp, "login")) opt_i = 1; if (!strcmp(sp, "diplogini")) opt_i = opt_a = 1; --- 280,289 ---- else sp = argv[0]; #else if ((sp = strrchr(argv[0], '/')) == NULL) sp = argv[0]; + else sp++; #endif ! if (*sp=='-') sp++; ! if (!strcmp(sp, "diplogin") || !strcmp(sp, "login")) opt_i = 1; if (!strcmp(sp, "diplogini")) opt_i = opt_a = 1; *************** *** 325,330 **** --- 330,338 ---- usage(); } + /* make sure we log the attachments */ + openlog("dip", LOG_PID, LOG_DAEMON); + printf("DIP: Dialup IP Protocol Driver version %s\n", VERSION); printf("Written by Fred N. van Kempen, MicroWalt Corporation.\n\n"); *************** *** 352,358 **** /* Are we going to be a dialIN server? */ if (opt_i == 1) { ! /* Enforce Proxy ARP for now... */ mydip.proxyarp = 1; if (opt_a == 1) sp = NULL; --- 360,366 ---- /* Are we going to be a dialIN server? */ if (opt_i == 1) { ! /* Enforce PROXY Arp for now */ mydip.proxyarp = 1; if (opt_a == 1) sp = NULL; diff -rc dip-3.3.7g/pathnames.h dip-3.3.7h/pathnames.h *** dip-3.3.7g/pathnames.h Tue Aug 30 21:50:01 1994 --- dip-3.3.7h/pathnames.h Fri Sep 2 12:45:41 1994 *************** *** 33,39 **** #define _PATH_DIP_PID "/etc/dip.pid" #define _PATH_DIP_KIL "/var/run" ! #define _PATH_LOCKD "/usr/spool/uucp" /* lock files */ #define _UID_UUCP "uucp" /* owns locks */ --- 33,39 ---- #define _PATH_DIP_PID "/etc/dip.pid" #define _PATH_DIP_KIL "/var/run" ! #define _PATH_LOCKD "/var/lock" /* lock files */ #define _UID_UUCP "uucp" /* owns locks */ diff -rc dip-3.3.7g/slip.c dip-3.3.7h/slip.c *** dip-3.3.7g/slip.c Sun Jun 5 23:16:22 1994 --- dip-3.3.7h/slip.c Fri Sep 2 12:45:41 1994 *************** *** 26,33 **** void do_slip(struct dip *dip) { - char ifname[32]; - (void) strcpy((char *) dip->protocol, "SLIP"); /* Put line in SLIP discipline. */ --- 26,31 ---- *************** *** 43,49 **** } /* Ask the kernel for the name of our interface. */ ! if (tty_get_name(ifname) < 0) { syslog(LOG_ERR, "GIFNAME: %m"); (void) tty_set_disc(-1); return; --- 41,47 ---- } /* Ask the kernel for the name of our interface. */ ! if (tty_get_name(dip->ifname) < 0) { syslog(LOG_ERR, "GIFNAME: %m"); (void) tty_set_disc(-1); return; *************** *** 51,70 **** #if 0 if (opt_v == 1) { ! printf("DIP: Interface %s\n",ifname); } #endif /* Add the route to that host. */ ! (void) attach(ifname, dip); } void do_cslip(struct dip *dip) { - char ifname[32]; - (void) strcpy((char *) dip->protocol, "CSLIP"); /* Put line in SLIP discipline. */ --- 49,66 ---- #if 0 if (opt_v == 1) { ! printf("DIP: Interface %s\n",dip->ifname); } #endif /* Add the route to that host. */ ! (void) attach(dip); } void do_cslip(struct dip *dip) { (void) strcpy((char *) dip->protocol, "CSLIP"); /* Put line in SLIP discipline. */ *************** *** 80,91 **** } /* Ask the kernel for the name of our interface. */ ! if (tty_get_name(ifname) < 0) { syslog(LOG_ERR, "GIFNAME: %m"); (void) tty_set_disc(-1); return; } /* Add the route to that host. */ ! (void) attach(ifname, dip); } --- 76,87 ---- } /* Ask the kernel for the name of our interface. */ ! if (tty_get_name(dip->ifname) < 0) { syslog(LOG_ERR, "GIFNAME: %m"); (void) tty_set_disc(-1); return; } /* Add the route to that host. */ ! (void) attach(dip); } diff -rc dip-3.3.7g/tty.c dip-3.3.7h/tty.c *** dip-3.3.7g/tty.c Wed Aug 31 06:32:09 1994 --- dip-3.3.7h/tty.c Fri Sep 2 12:45:41 1994 *************** *** 745,755 **** int tty_login_close(void) { #ifdef NE_PAUL - char ifname[32]; - if (tty_fd >= 0) { ! (void) tty_get_name(ifname); ! (void) detach(ifname, &mydip); (void) mdm_hangup(); } #else --- 745,752 ---- int tty_login_close(void) { #ifdef NE_PAUL if (tty_fd >= 0) { ! (void) detach(&mydip); (void) mdm_hangup(); } #else .