commit - aeda4d4ea624e48cf756f264b48dcd924e736fc6
commit + 42a4c51212217fcabacff280cd3f4e414c4c6904
blob - c0a62bea425731e330f9f4cf6e15b25c1c1c0370
blob + e5653488965f2f558d3371ae9420c4a66dfa2c79
--- main.c
+++ main.c
static size_t nblacklists = 0;
void usage(void);
-void dnsbl_connect(char *, int, time_t, char *, char *, uint64_t, uint64_t,
- struct smtp_filter_connect *);
+void dnsbl_connect(char *, int, struct timespec *, char *, char *, uint64_t,
+ uint64_t, struct smtp_filter_connect *);
void dnsbl_resolve(struct asr_result *, void *);
void dnsbl_session_free(struct dnsbl_session *);
}
void
-dnsbl_connect(char *type, int version, time_t tm, char *direction, char *phase,
- uint64_t reqid, uint64_t token, struct smtp_filter_connect *params)
+dnsbl_connect(char *type, int version, struct timespec *tm, char *direction,
+ char *phase, uint64_t reqid, uint64_t token,
+ struct smtp_filter_connect *params)
{
struct dnsbl_session *session;
char query[255];
blob - 3f637237b5a2f04c6b9d9dd2ab692a7b2199402d
blob + 4c6897df89f109535425b4c83591e4841dde56f6
--- smtp_proc.c
+++ smtp_proc.c
#define NITEMS(x) (sizeof(x) / sizeof(*x))
-typedef int (*smtp_cb)(char *, int, time_t, char *, char *, uint64_t, uint64_t,
- void *);
+typedef int (*smtp_cb)(char *, int, struct timespec *, char *, char *, uint64_t,
+ uint64_t, void *);
struct smtp_callback;
struct smtp_request;
static int smtp_register(char *, char *, char *, smtp_cb);
static void smtp_newline(int, short, void *);
-static void smtp_connect(struct smtp_callback *, int, time_t, uint64_t,
- uint64_t, char *);
-static void smtp_handle_filter(struct smtp_callback *, int, time_t, uint64_t,
- uint64_t, void *);
+static void smtp_connect(struct smtp_callback *, int, struct timespec *,
+ uint64_t, uint64_t, char *);
+static void smtp_handle_filter(struct smtp_callback *, int, struct timespec *,
+ uint64_t, uint64_t, void *);
static int smtp_request_cmp(struct smtp_request *, struct smtp_request *);
RB_PROTOTYPE_STATIC(smtp_requests, smtp_request, entry, smtp_request_cmp);
char *type;
char *phase;
char *direction;
- void (*smtp_parse)(struct smtp_callback *, int, time_t, uint64_t,
- uint64_t, char *);
+ void (*smtp_parse)(struct smtp_callback *, int, struct timespec *,
+ uint64_t, uint64_t, char *);
smtp_cb cb;
} smtp_callbacks[] = {
{"filter", "connect", "smtp-in", smtp_connect, NULL}
static int resolved = 1;
int
-smtp_register_filter_connect(void (*cb)(char *, int, time_t, char *, char *,
- uint64_t, uint64_t, struct smtp_filter_connect *))
+smtp_register_filter_connect(void (*cb)(char *, int, struct timespec *, char *,
+ char *, uint64_t, uint64_t, struct smtp_filter_connect *))
{
return smtp_register("filter", "connect", "smtp-in", (smtp_cb) cb);
}
ssize_t linelen;
char *start, *end, *type, *direction, *phase, *params;
int version;
- time_t tm;
+ struct timespec tm;
uint64_t reqid, token;
int i;
if ((direction = strchr(start, '|')) == NULL)
errx(1, "Invalid line received: missing direction");
direction++[0] = '\0';
- tm = (time_t) strtoull(start, &end, 10);
- if (start[0] == '\0' || end[0] != '\0')
+ tm.tv_sec = (time_t) strtoull(start, &end, 10);
+ tm.tv_nsec = 0;
+ if (start[0] == '\0' || (end[0] != '\0' && end[0] != '.'))
errx(1, "Invalid line received: invalid timestamp");
+ if (end[0] == '.') {
+ start = end + 1;
+ tm.tv_nsec = strtol(start, &end, 10);
+ if (start[0] == '\0' || end[0] != '\0')
+ errx(1, "Invalid line received: invalid "
+ "timestamp");
+ for (i = 9 - (end - start); i > 0; i--) {
+ tm.tv_nsec *= 10;
+ }
+ }
if ((phase = strchr(direction, '|')) == NULL)
errx(1, "Invalid line receieved: missing phase");
phase++[0] = '\0';
errx(1, "Invalid line received: received unregistered "
"%s: %s", type, phase);
}
- smtp_callbacks[i].smtp_parse(&(smtp_callbacks[i]), version, tm,
+ smtp_callbacks[i].smtp_parse(&(smtp_callbacks[i]), version, &tm,
reqid, token, params);
}
if (feof(stdin) || (ferror(stdin) && errno != EAGAIN))
}
static void
-smtp_connect(struct smtp_callback *cb, int version, time_t tm, uint64_t reqid,
- uint64_t token, char *params)
+smtp_connect(struct smtp_callback *cb, int version, struct timespec *tm,
+ uint64_t reqid, uint64_t token, char *params)
{
struct smtp_filter_connect sfconnect;
char *address;
}
static void
-smtp_handle_filter(struct smtp_callback *cb, int version, time_t tm,
+smtp_handle_filter(struct smtp_callback *cb, int version, struct timespec *tm,
uint64_t reqid, uint64_t token, void *params)
{
enum filter_decision fdes;
if (resolved)
errx(1, "reqid: %016"PRIx64" token: %016"PRIx64" already "
"resolved", reqid, token);
- printf("filter-result|%016"PRIx64"|%016"PRIx64"|proceed\n", token, reqid);
+ printf("filter-result|%016"PRIx64"|%016"PRIx64"|proceed\n", token,
+ reqid);
resolved = 1;
}
blob - 0d634c86bcf021e0031d0b73af37fa750387bc63
blob + fa683bd047374ac2553016d10a3e68943857d0b8
--- smtp_proc.h
+++ smtp_proc.h
FILTER_REWRITE
};
-int smtp_register_filter_connect(void (*cb)(char *, int, time_t,
+int smtp_register_filter_connect(void (*cb)(char *, int, struct timespec *,
char *, char *, uint64_t, uint64_t, struct smtp_filter_connect *));
void smtp_filter_proceed(uint64_t, uint64_t);
void smtp_filter_reject(uint64_t, uint64_t, int, const char *, ...)