#include #define __USE_GNU 1 #define _GNU_SOURCE #include #include #include #include #include static sfsistat t_negotiate(SMFICTX *ctx, unsigned long a, unsigned long b, unsigned long c, unsigned long d, unsigned long *a1, unsigned long *b1, unsigned long *c1, unsigned long *d1) { printf("NEGOTIATE\n"); for (int i=1; i<10; i++) { printf("NEG %i\n", i); sleep(5); } return SMFIS_CONTINUE; } static sfsistat t_abort(SMFICTX *ctx) { printf("ABORTED\n"); return SMFIS_CONTINUE; } static sfsistat t_close(SMFICTX *ctx) { printf("CLOSED\n"); return SMFIS_CONTINUE; } static struct smfiDesc smfilter = { "M1",/* filter name */ SMFI_VERSION, /* version code -- do not change */ SMFIF_CHGHDRS | SMFIF_ADDHDRS, /* flags */ NULL, /* connection info filter */ NULL, /* SMTP HELO command filter */ NULL, /* envelope sender filter */ NULL, /* envelope recipient filter */ NULL, /* header filter */ NULL, /* end of headers */ NULL, /* body block filter */ NULL, /* end of message */ t_abort, /* message aborted */ t_close, /* connection cleanup */ NULL, /* unknown */ NULL, /* data */ t_negotiate }; int main(int argc, char **argv) { int c; smfi_setconn("/tmp/zz"); opterr = 1; char *pidfile = NULL; if (smfi_register(smfilter) == MI_FAILURE) { fprintf(stderr, "smfi_register failed, most probably not enough memory\n"); return -3; } if (smfi_opensocket(1) == MI_FAILURE) { fprintf(stderr, "Socket %s could not be opened\n", optarg); return -2; } return smfi_main(); }