forgot a newline in the last change (to psym)
[unix-history] / usr / src / old / implogd / implogd.c
index e392868..87caaaf 100644 (file)
@@ -1,17 +1,18 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)implogd.c  4.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)implogd.c  4.8 (Berkeley) %G%";
 #endif
 
 #endif
 
-#include <time.h>
 #include <sgtty.h>
 
 #include <sgtty.h>
 
-#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/param.h>
 #include <sys/socket.h>
 #include <sys/socket.h>
+#include <sys/file.h>
 
 #include <netinet/in.h>
 
 #include <netinet/in.h>
+#include <netimp/if_imp.h>
 
 #define        LOGFILE "/usr/adm/implog"
 
 #define        LOGFILE "/usr/adm/implog"
-#define        IMPMTU  ((8159 / 8) & ~01)
 
 u_char request[1024];
 int    marktime();
 
 u_char request[1024];
 int    marktime();
@@ -57,26 +58,28 @@ main(argc, argv)
          }
        }
 #endif
          }
        }
 #endif
-       log = open(LOGFILE, 1);
-       if (log < 0)
+       log = open(LOGFILE, O_CREAT|O_WRONLY|O_APPEND, 0644);
+       if (log < 0) {
+               perror("implogd: open");
                exit(1);
                exit(1);
-       lseek(log, 0L, 2);
+       }
        from.sin_time = time(0);
        from.sin_len = sizeof (time_t);
        write(log, (char *)&from, sizeof (from));
        from.sin_time = time(0);
        from.sin_len = sizeof (time_t);
        write(log, (char *)&from, sizeof (from));
-again:
-       s = socket(AF_IMPLINK, SOCK_RAW, 0, 0);
-       if (s < 0) {
-               perror("socket");
+       while ((s = socket(AF_IMPLINK, SOCK_RAW, 0, 0)) < 0) {
+               perror("implogd: socket");
                sleep(5);
                sleep(5);
-               goto again;
        }
        for (;;) {
        }
        for (;;) {
-               int len = sizeof (request);
+               int fromlen = sizeof (from), len;
 
 
-               if (recvfrom(s, request, &len, &from, sizeof (from), 0) < 0)
+               len = recvfrom(s, request, sizeof (request), 0,
+                       &from, &fromlen);
+               if (len < 0) {
+                       perror("implogd: recvfrom");
                        continue;
                        continue;
-               if (len <= 0 || len > IMPMTU)   /* sanity */
+               }
+               if (len == 0 || len > IMPMTU)   /* sanity */
                        continue;
                from.sin_len = len;
                from.sin_time = time(0);
                        continue;
                from.sin_len = len;
                from.sin_time = time(0);