X-Git-Url: https://git.distorted.org.uk/~mdw/fwd/blobdiff_plain/e82f7154f65062d9ac8b9677862774498b331058..667fb920a9ace885b3ac2dc8277d104930bd2727:/identify.c diff --git a/identify.c b/identify.c index db6df93..50f7ae2 100644 --- a/identify.c +++ b/identify.c @@ -1,10 +1,10 @@ /* -*-c-*- * - * $Id: identify.c,v 1.1 1999/07/01 08:56:23 mdw Exp $ + * $Id: identify.c,v 1.3 1999/07/26 23:26:21 mdw Exp $ * * Identifies and logs the client of a connection * - * (c) 1999 Mark Wooding + * (c) 1999 Straylight/Edgeware */ /*----- Licensing notice --------------------------------------------------* @@ -29,8 +29,14 @@ /*----- Revision history --------------------------------------------------* * * $Log: identify.c,v $ - * Revision 1.1 1999/07/01 08:56:23 mdw - * Initial revision + * Revision 1.3 1999/07/26 23:26:21 mdw + * Minor modifications for new design. + * + * Revision 1.2 1999/07/03 13:56:59 mdw + * Log connections to syslog or stderr as appropriate. + * + * Revision 1.1.1.1 1999/07/01 08:56:23 mdw + * Initial revision. * */ @@ -77,8 +83,6 @@ typedef struct id { id_req q; /* Copy of client's request block */ - void (*func)(void */*p*/); /* Function to call when done */ - void *p; /* Argument to pass to function */ time_t when; /* When the connection occurred */ conn c; /* Connection selector */ unsigned state; /* Current state of the world */ @@ -107,9 +111,6 @@ typedef struct id { static void id_done(id *i) { - char buf[64]; - struct tm *tm; - /* --- Close down the various dependent bits --- */ if (!(i->state & S_HOST)) @@ -123,14 +124,13 @@ static void id_done(id *i) /* --- Report the final result --- */ - tm = localtime(&i->when); - strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tm); - syslog(LOG_NOTICE, "%s %s %s from %s@%s\n", - buf, i->q.desc, i->q.act, i->user, i->host); + fw_log(i->when, "[%s] %s from %s@%s [%s]", + i->q.desc, i->q.act, + i->user, i->host, inet_ntoa(i->q.rsin.sin_addr)); /* --- Dispose of the block --- */ - i->func(i->p); + REFFD_DEC(i->q.r); free(i); } @@ -237,8 +237,6 @@ static void id_timer(struct timeval *tv, void *vp) /* --- @identify@ --- * * * Arguments: @const id_req *q@ = pointer to request block - * @void (*func)(void *p)@ = function to call when done - * @void *p@ = argument to pass to function * * Returns: --- * @@ -246,8 +244,7 @@ static void id_timer(struct timeval *tv, void *vp) * which will, eventually, report a message to the system log. */ -void identify(const id_req *q, - void (*func)(void */*p*/), void *p) +void identify(const id_req *q) { id *i; @@ -255,8 +252,7 @@ void identify(const id_req *q, i = xmalloc(sizeof(*i)); i->q = *q; - i->func = func; - i->p = p; + REFFD_INC(i->q.r); str_sanitize(i->host, inet_ntoa(q->rsin.sin_addr), sizeof(i->host)); strcpy(i->user, ""); @@ -279,9 +275,11 @@ void identify(const id_req *q, close(fd); id_conn(-1, i); } else { + int opt = 1; sin.sin_family = AF_INET; sin.sin_addr = q->rsin.sin_addr; sin.sin_port = htons(113); + setsockopt(fd, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(opt)); conn_init(&i->c, sel, fd, (struct sockaddr *)&sin, sizeof(sin), id_conn, i);