2 * Copyright (c) 1999-2004, 2006-2008 Proofpoint, Inc. and its suppliers.
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
12 SM_RCSID("@(#)$Id: engine.c,v 8.168 2013-11-22 20:51:36 ca Exp $")
14 #include "libmilter.h"
16 #if NETINET || NETINET6
17 # include <arpa/inet.h>
18 #endif /* NETINET || NETINET6 */
20 /* generic argument for functions in the command table */
23 size_t a_len; /* length of buffer */
24 char *a_buf; /* argument string */
25 int a_idx; /* index for macro array */
26 SMFICTX_PTR a_ctx; /* context */
29 typedef struct arg_struct genarg;
31 /* structure for commands received from MTA */
34 char cm_cmd; /* command */
35 int cm_argt; /* type of arguments expected */
36 int cm_next; /* next state */
37 int cm_todo; /* what to do next */
38 int cm_macros; /* index for macros */
39 int (*cm_fct) __P((genarg *)); /* function to execute */
42 typedef struct cmdfct_t cmdfct;
44 /* possible values for cm_argt */
48 /* possible values for cm_todo */
49 #define CT_CONT 0x0000 /* continue reading commands */
50 #define CT_IGNO 0x0001 /* continue even when error */
52 /* not needed right now, done via return code instead */
53 #define CT_KEEP 0x0004 /* keep buffer (contains symbols) */
54 #define CT_END 0x0008 /* last command of session, stop replying */
56 /* index in macro array: macros only for these commands */
65 #define CI_LAST CI_EOH
67 ERROR: do not compile with CI_LAST < CI_DATA
70 ERROR: do not compile with CI_LAST < CI_EOM
73 ERROR: do not compile with CI_LAST < CI_EOH
75 #if CI_LAST < CI_ENVRCPT
76 ERROR: do not compile with CI_LAST < CI_ENVRCPT
78 #if CI_LAST < CI_ENVFROM
79 ERROR: do not compile with CI_LAST < CI_ENVFROM
82 ERROR: do not compile with CI_LAST < CI_HELO
84 #if CI_LAST < CI_CONNECT
85 ERROR: do not compile with CI_LAST < CI_CONNECT
87 #if CI_LAST >= MAX_MACROS_ENTRIES
88 ERROR: do not compile with CI_LAST >= MAX_MACROS_ENTRIES
91 /* function prototypes */
92 static int st_abortfct __P((genarg *));
93 static int st_macros __P((genarg *));
94 static int st_optionneg __P((genarg *));
95 static int st_bodychunk __P((genarg *));
96 static int st_connectinfo __P((genarg *));
97 static int st_bodyend __P((genarg *));
98 static int st_helo __P((genarg *));
99 static int st_header __P((genarg *));
100 static int st_sender __P((genarg *));
101 static int st_rcpt __P((genarg *));
102 static int st_unknown __P((genarg *));
103 static int st_data __P((genarg *));
104 static int st_eoh __P((genarg *));
105 static int st_quit __P((genarg *));
106 static int sendreply __P((sfsistat, socket_t, struct timeval *, SMFICTX_PTR));
107 static void fix_stm __P((SMFICTX_PTR));
108 static bool trans_ok __P((int, int));
109 static char **dec_argv __P((char *, size_t));
110 static int dec_arg2 __P((char *, size_t, char **, char **));
111 static void mi_clr_symlist __P((SMFICTX_PTR));
113 #if _FFR_WORKERS_POOL
114 static bool mi_rd_socket_ready __P((int));
115 #endif /* _FFR_WORKERS_POOL */
119 #define ST_INIT 0 /* initial state */
120 #define ST_OPTS 1 /* option negotiation */
121 #define ST_CONN 2 /* connection info */
122 #define ST_HELO 3 /* helo */
123 #define ST_MAIL 4 /* mail from */
124 #define ST_RCPT 5 /* rcpt to */
125 #define ST_DATA 6 /* data */
126 #define ST_HDRS 7 /* headers */
127 #define ST_EOHS 8 /* end of headers */
128 #define ST_BODY 9 /* body */
129 #define ST_ENDM 10 /* end of message */
130 #define ST_QUIT 11 /* quit */
131 #define ST_ABRT 12 /* abort */
132 #define ST_UNKN 13 /* unknown SMTP command */
133 #define ST_Q_NC 14 /* quit, new connection follows */
134 #define ST_LAST ST_Q_NC /* last valid state */
135 #define ST_SKIP 16 /* not a state but required for the state table */
137 /* in a mail transaction? must be before eom according to spec. */
138 #define ST_IN_MAIL(st) ((st) >= ST_MAIL && (st) < ST_ENDM)
141 ** set of next states
142 ** each state (ST_*) corresponds to bit in an int value (1 << state)
143 ** each state has a set of allowed transitions ('or' of bits of states)
144 ** so a state transition is valid if the mask of the next state
145 ** is set in the NX_* value
146 ** this function is coded in trans_ok(), see below.
149 #define MI_MASK(x) (0x0001 << (x)) /* generate a bit "mask" for a state */
150 #define NX_INIT (MI_MASK(ST_OPTS))
151 #define NX_OPTS (MI_MASK(ST_CONN) | MI_MASK(ST_UNKN))
152 #define NX_CONN (MI_MASK(ST_HELO) | MI_MASK(ST_MAIL) | MI_MASK(ST_UNKN))
153 #define NX_HELO (MI_MASK(ST_HELO) | MI_MASK(ST_MAIL) | MI_MASK(ST_UNKN))
154 #define NX_MAIL (MI_MASK(ST_RCPT) | MI_MASK(ST_ABRT) | MI_MASK(ST_UNKN))
155 #define NX_RCPT (MI_MASK(ST_HDRS) | MI_MASK(ST_EOHS) | MI_MASK(ST_DATA) | \
156 MI_MASK(ST_BODY) | MI_MASK(ST_ENDM) | \
157 MI_MASK(ST_RCPT) | MI_MASK(ST_ABRT) | MI_MASK(ST_UNKN))
158 #define NX_DATA (MI_MASK(ST_EOHS) | MI_MASK(ST_HDRS) | MI_MASK(ST_ABRT))
159 #define NX_HDRS (MI_MASK(ST_EOHS) | MI_MASK(ST_HDRS) | MI_MASK(ST_ABRT))
160 #define NX_EOHS (MI_MASK(ST_BODY) | MI_MASK(ST_ENDM) | MI_MASK(ST_ABRT))
161 #define NX_BODY (MI_MASK(ST_ENDM) | MI_MASK(ST_BODY) | MI_MASK(ST_ABRT))
162 #define NX_ENDM (MI_MASK(ST_QUIT) | MI_MASK(ST_MAIL) | MI_MASK(ST_UNKN) | \
166 #define NX_UNKN (MI_MASK(ST_HELO) | MI_MASK(ST_MAIL) | \
167 MI_MASK(ST_RCPT) | MI_MASK(ST_ABRT) | \
169 MI_MASK(ST_BODY) | MI_MASK(ST_UNKN) | \
170 MI_MASK(ST_ABRT) | MI_MASK(ST_QUIT) | MI_MASK(ST_Q_NC))
171 #define NX_Q_NC (MI_MASK(ST_CONN) | MI_MASK(ST_UNKN))
172 #define NX_SKIP MI_MASK(ST_SKIP)
174 static int next_states[] =
193 #define SIZE_NEXT_STATES (sizeof(next_states) / sizeof(next_states[0]))
195 /* commands received by milter */
196 static cmdfct cmds[] =
198 {SMFIC_ABORT, CM_NULLOK, ST_ABRT, CT_CONT, CI_NONE, st_abortfct}
199 , {SMFIC_MACRO, CM_BUF, ST_NONE, CT_KEEP, CI_NONE, st_macros }
200 , {SMFIC_BODY, CM_BUF, ST_BODY, CT_CONT, CI_NONE, st_bodychunk}
201 , {SMFIC_CONNECT, CM_BUF, ST_CONN, CT_CONT, CI_CONN, st_connectinfo}
202 , {SMFIC_BODYEOB, CM_NULLOK, ST_ENDM, CT_CONT, CI_EOM, st_bodyend }
203 , {SMFIC_HELO, CM_BUF, ST_HELO, CT_CONT, CI_HELO, st_helo }
204 , {SMFIC_HEADER, CM_BUF, ST_HDRS, CT_CONT, CI_NONE, st_header }
205 , {SMFIC_MAIL, CM_BUF, ST_MAIL, CT_CONT, CI_MAIL, st_sender }
206 , {SMFIC_OPTNEG, CM_BUF, ST_OPTS, CT_CONT, CI_NONE, st_optionneg}
207 , {SMFIC_EOH, CM_NULLOK, ST_EOHS, CT_CONT, CI_EOH, st_eoh }
208 , {SMFIC_QUIT, CM_NULLOK, ST_QUIT, CT_END, CI_NONE, st_quit }
209 , {SMFIC_DATA, CM_NULLOK, ST_DATA, CT_CONT, CI_DATA, st_data }
210 , {SMFIC_RCPT, CM_BUF, ST_RCPT, CT_IGNO, CI_RCPT, st_rcpt }
211 , {SMFIC_UNKNOWN, CM_BUF, ST_UNKN, CT_IGNO, CI_NONE, st_unknown }
212 , {SMFIC_QUIT_NC, CM_NULLOK, ST_Q_NC, CT_CONT, CI_NONE, st_quit }
216 ** Additional (internal) reply codes;
217 ** must be coordinated wit libmilter/mfapi.h
220 #define _SMFIS_KEEP 20
221 #define _SMFIS_ABORT 21
222 #define _SMFIS_OPTIONS 22
223 #define _SMFIS_NOREPLY SMFIS_NOREPLY
224 #define _SMFIS_FAIL (-1)
225 #define _SMFIS_NONE (-2)
228 ** MI_ENGINE -- receive commands and process them
231 ** ctx -- context structure
234 ** MI_FAILURE/MI_SUCCESS
244 int ret = MI_SUCCESS;
245 int ncmds = sizeof(cmds) / sizeof(cmdfct);
246 int curstate = ST_INIT;
253 struct timeval timeout;
254 int (*f) __P((genarg *));
255 sfsistat (*fi_abort) __P((SMFICTX *));
256 sfsistat (*fi_close) __P((SMFICTX *));
260 fi_abort = ctx->ctx_smfi->xxfi_abort;
261 #if _FFR_WORKERS_POOL
262 curstate = ctx->ctx_state;
263 if (curstate == ST_INIT)
265 mi_clr_macros(ctx, 0);
268 #else /* _FFR_WORKERS_POOL */
269 mi_clr_macros(ctx, 0);
271 #endif /* _FFR_WORKERS_POOL */
275 /* call abort only if in a mail transaction */
276 call_abort = ST_IN_MAIL(curstate);
277 timeout.tv_sec = ctx->ctx_timeout;
279 if (mi_stop() == MILTER_ABRT)
281 if (ctx->ctx_dbg > 3)
282 sm_dprintf("[%lu] milter_abort\n",
289 ** Notice: buf is allocated by mi_rd_cmd() and it will
290 ** usually be free()d after it has been used in f().
291 ** However, if the function returns _SMFIS_KEEP then buf
292 ** contains macros and will not be free()d.
293 ** Hence r must be set to _SMFIS_NONE if a new buf is
294 ** allocated to avoid problem with housekeeping, esp.
295 ** if the code "break"s out of the loop.
298 #if _FFR_WORKERS_POOL
299 /* Is the socket ready to be read ??? */
300 if (!mi_rd_socket_ready(sd))
305 #endif /* _FFR_WORKERS_POOL */
308 if ((buf = mi_rd_cmd(sd, &timeout, &cmd, &len,
309 ctx->ctx_smfi->xxfi_name)) == NULL &&
310 cmd < SMFIC_VALIDCMD)
312 if (ctx->ctx_dbg > 5)
313 sm_dprintf("[%lu] mi_engine: mi_rd_cmd error (%x)\n",
314 (long) ctx->ctx_id, (int) cmd);
317 ** eof is currently treated as failure ->
318 ** abort() instead of close(), otherwise use:
319 ** if (cmd != SMFIC_EOF)
325 if (ctx->ctx_dbg > 4)
326 sm_dprintf("[%lu] got cmd '%c' len %d\n",
327 (long) ctx->ctx_id, cmd, (int) len);
328 for (i = 0; i < ncmds; i++)
330 if (cmd == cmds[i].cm_cmd)
335 /* unknown command */
336 if (ctx->ctx_dbg > 1)
337 sm_dprintf("[%lu] cmd '%c' unknown\n",
338 (long) ctx->ctx_id, cmd);
342 if ((f = cmds[i].cm_fct) == NULL)
345 if (ctx->ctx_dbg > 1)
346 sm_dprintf("[%lu] cmd '%c' not impl\n",
347 (long) ctx->ctx_id, cmd);
352 /* is new state ok? */
353 newstate = cmds[i].cm_next;
354 if (ctx->ctx_dbg > 5)
355 sm_dprintf("[%lu] cur %x new %x nextmask %x\n",
357 curstate, newstate, next_states[curstate]);
359 if (newstate != ST_NONE && !trans_ok(curstate, newstate))
361 if (ctx->ctx_dbg > 1)
362 sm_dprintf("[%lu] abort: cur %d (%x) new %d (%x) next %x\n",
364 curstate, MI_MASK(curstate),
365 newstate, MI_MASK(newstate),
366 next_states[curstate]);
368 /* call abort only if in a mail transaction */
369 if (fi_abort != NULL && call_abort)
370 (void) (*fi_abort)(ctx);
373 ** try to reach the new state from HELO
374 ** if it can't be reached, ignore the command.
378 if (!trans_ok(curstate, newstate))
388 if (cmds[i].cm_argt != CM_NULLOK && buf == NULL)
391 if (ctx->ctx_dbg > 1)
392 sm_dprintf("[%lu] cmd='%c', buf=NULL\n",
393 (long) ctx->ctx_id, cmd);
399 if (newstate != ST_NONE)
402 ctx->ctx_state = curstate;
404 arg.a_idx = cmds[i].cm_macros;
405 call_abort = ST_IN_MAIL(curstate);
407 /* call function to deal with command */
408 MI_MONITOR_BEGIN(ctx, cmd);
410 MI_MONITOR_END(ctx, cmd);
411 if (r != _SMFIS_KEEP && buf != NULL)
416 if (sendreply(r, sd, &timeout, ctx) != MI_SUCCESS)
422 if (r == SMFIS_ACCEPT)
424 /* accept mail, no further actions taken */
427 else if (r == SMFIS_REJECT || r == SMFIS_DISCARD ||
431 ** further actions depend on current state
432 ** if the IGNO bit is set: "ignore" the error,
433 ** i.e., stay in the current state
435 if (!bitset(CT_IGNO, cmds[i].cm_todo))
438 else if (r == _SMFIS_ABORT)
440 if (ctx->ctx_dbg > 5)
441 sm_dprintf("[%lu] function returned abort\n",
446 } while (!bitset(CT_END, cmds[i].cm_todo));
448 ctx->ctx_state = curstate;
450 if (ret == MI_FAILURE)
452 /* call abort only if in a mail transaction */
453 if (fi_abort != NULL && call_abort)
454 (void) (*fi_abort)(ctx);
457 /* has close been called? */
458 if (ctx->ctx_state != ST_QUIT
459 #if _FFR_WORKERS_POOL
460 && ret != MI_CONTINUE
461 #endif /* _FFR_WORKERS_POOL */
464 if ((fi_close = ctx->ctx_smfi->xxfi_close) != NULL)
465 (void) (*fi_close)(ctx);
467 if (r != _SMFIS_KEEP && buf != NULL)
469 #if !_FFR_WORKERS_POOL
470 mi_clr_macros(ctx, 0);
471 #endif /* _FFR_WORKERS_POOL */
475 static size_t milter_addsymlist __P((SMFICTX_PTR, char *, char **));
478 milter_addsymlist(ctx, buf, newbuf)
488 SM_ASSERT(ctx != NULL);
489 SM_ASSERT(buf != NULL);
490 SM_ASSERT(newbuf != NULL);
492 for (i = 0; i < MAX_MACROS_ENTRIES; i++)
494 if (ctx->ctx_mac_list[i] != NULL)
496 len += strlen(ctx->ctx_mac_list[i]) + 1 +
504 SM_ASSERT(len + MILTER_OPTLEN > len);
505 len += MILTER_OPTLEN;
506 buffer = malloc(len);
509 (void) memcpy(buffer, buf, MILTER_OPTLEN);
510 offset = MILTER_OPTLEN;
511 for (i = 0; i < MAX_MACROS_ENTRIES; i++)
515 if (ctx->ctx_mac_list[i] == NULL)
518 SM_ASSERT(offset + MILTER_LEN_BYTES < len);
520 (void) memcpy(buffer + offset, (void *) &v,
522 offset += MILTER_LEN_BYTES;
523 l = strlen(ctx->ctx_mac_list[i]) + 1;
524 SM_ASSERT(offset + l <= len);
525 (void) memcpy(buffer + offset,
526 ctx->ctx_mac_list[i], l);
545 ** GET_NR_BIT -- get "no reply" bit matching state
548 ** state -- current protocol stage
551 ** 0: no matching bit
552 ** >0: the matching "no reply" bit
555 static unsigned long get_nr_bit __P((int));
600 ** SENDREPLY -- send a reply to the MTA
604 ** sd -- socket descriptor
605 ** timeout_ptr -- (ptr to) timeout to use for sending
606 ** ctx -- context structure
609 ** MI_SUCCESS/MI_FAILURE
613 sendreply(r, sd, timeout_ptr, ctx)
616 struct timeval *timeout_ptr;
624 bit = get_nr_bit(ctx->ctx_state);
625 if (bit != 0 && (ctx->ctx_pflags & bit) != 0 && r != SMFIS_NOREPLY)
627 if (r >= SMFIS_CONTINUE && r < _SMFIS_KEEP)
629 /* milter said it wouldn't reply, but it lied... */
631 "%s: milter claimed not to reply in state %d but did anyway %d\n",
632 ctx->ctx_smfi->xxfi_name,
638 ** Force specified behavior, otherwise libmilter
639 ** and MTA will fail to communicate properly.
659 ret = mi_wr_cmd(sd, timeout_ptr, SMFIR_CONTINUE, NULL, 0);
663 if (ctx->ctx_reply != NULL &&
664 ((r == SMFIS_TEMPFAIL && *ctx->ctx_reply == '4') ||
665 (r == SMFIS_REJECT && *ctx->ctx_reply == '5')))
667 ret = mi_wr_cmd(sd, timeout_ptr, SMFIR_REPLYCODE,
669 strlen(ctx->ctx_reply) + 1);
670 free(ctx->ctx_reply);
671 ctx->ctx_reply = NULL;
675 ret = mi_wr_cmd(sd, timeout_ptr, r == SMFIS_REJECT ?
676 SMFIR_REJECT : SMFIR_TEMPFAIL, NULL, 0);
680 ret = mi_wr_cmd(sd, timeout_ptr, SMFIR_DISCARD, NULL, 0);
683 ret = mi_wr_cmd(sd, timeout_ptr, SMFIR_ACCEPT, NULL, 0);
686 ret = mi_wr_cmd(sd, timeout_ptr, SMFIR_SKIP, NULL, 0);
693 char buf[MILTER_OPTLEN];
695 v = htonl(ctx->ctx_prot_vers2mta);
696 (void) memcpy(&(buf[0]), (void *) &v,
698 v = htonl(ctx->ctx_aflags);
699 (void) memcpy(&(buf[MILTER_LEN_BYTES]), (void *) &v,
701 v = htonl(ctx->ctx_pflags2mta);
702 (void) memcpy(&(buf[MILTER_LEN_BYTES * 2]),
703 (void *) &v, MILTER_LEN_BYTES);
704 len = milter_addsymlist(ctx, buf, &buffer);
706 ret = mi_wr_cmd(sd, timeout_ptr, SMFIC_OPTNEG,
714 (ctx->ctx_pflags & bit) != 0 &&
715 (ctx->ctx_mta_pflags & bit) == 0)
718 ** milter doesn't want to send a reply,
719 ** but the MTA doesn't have that feature: fake it.
722 ret = mi_wr_cmd(sd, timeout_ptr, SMFIR_CONTINUE, NULL,
726 default: /* don't send a reply */
733 ** MI_CLR_MACROS -- clear set of macros starting from a given index
736 ** ctx -- context structure
737 ** m -- index from which to clear all macros
744 mi_clr_macros(ctx, m)
750 for (i = m; i < MAX_MACROS_ENTRIES; i++)
752 if (ctx->ctx_mac_ptr[i] != NULL)
754 free(ctx->ctx_mac_ptr[i]);
755 ctx->ctx_mac_ptr[i] = NULL;
757 if (ctx->ctx_mac_buf[i] != NULL)
759 free(ctx->ctx_mac_buf[i]);
760 ctx->ctx_mac_buf[i] = NULL;
766 ** MI_CLR_SYMLIST -- clear list of macros
769 ** ctx -- context structure
781 SM_ASSERT(ctx != NULL);
782 for (i = SMFIM_FIRST; i <= SMFIM_LAST; i++)
784 if (ctx->ctx_mac_list[i] != NULL)
786 free(ctx->ctx_mac_list[i]);
787 ctx->ctx_mac_list[i] = NULL;
793 ** MI_CLR_CTX -- clear context
796 ** ctx -- context structure
806 SM_ASSERT(ctx != NULL);
807 if (ValidSocket(ctx->ctx_sd))
809 (void) closesocket(ctx->ctx_sd);
810 ctx->ctx_sd = INVALID_SOCKET;
812 if (ctx->ctx_reply != NULL)
814 free(ctx->ctx_reply);
815 ctx->ctx_reply = NULL;
817 if (ctx->ctx_privdata != NULL)
819 smi_log(SMI_LOG_WARN,
820 "%s: private data not NULL",
821 ctx->ctx_smfi->xxfi_name);
823 mi_clr_macros(ctx, 0);
829 ** ST_OPTIONNEG -- negotiate options
832 ** g -- generic argument structure
835 ** abort/send options/continue
842 mi_int32 i, v, fake_pflags, internal_pflags;
844 #if _FFR_MILTER_CHECK
845 bool testmode = false;
846 #endif /* _FFR_MILTER_CHECK */
847 int (*fi_negotiate) __P((SMFICTX *,
848 unsigned long, unsigned long,
849 unsigned long, unsigned long,
850 unsigned long *, unsigned long *,
851 unsigned long *, unsigned long *));
853 if (g == NULL || g->a_ctx->ctx_smfi == NULL)
854 return SMFIS_CONTINUE;
856 mi_clr_macros(ctx, g->a_idx + 1);
857 ctx->ctx_prot_vers = SMFI_PROT_VERSION;
859 /* check for minimum length */
860 if (g->a_len < MILTER_OPTLEN)
863 "%s: st_optionneg[%ld]: len too short %d < %d",
864 ctx->ctx_smfi->xxfi_name,
865 (long) ctx->ctx_id, (int) g->a_len,
870 /* protocol version */
871 (void) memcpy((void *) &i, (void *) &(g->a_buf[0]), MILTER_LEN_BYTES);
874 #define SMFI_PROT_VERSION_MIN 2
876 /* check for minimum version */
877 if (v < SMFI_PROT_VERSION_MIN)
880 "%s: st_optionneg[%ld]: protocol version too old %d < %d",
881 ctx->ctx_smfi->xxfi_name,
882 (long) ctx->ctx_id, v, SMFI_PROT_VERSION_MIN);
885 ctx->ctx_mta_prot_vers = v;
886 if (ctx->ctx_prot_vers < ctx->ctx_mta_prot_vers)
887 ctx->ctx_prot_vers2mta = ctx->ctx_prot_vers;
889 ctx->ctx_prot_vers2mta = ctx->ctx_mta_prot_vers;
891 (void) memcpy((void *) &i, (void *) &(g->a_buf[MILTER_LEN_BYTES]),
895 /* no flags? set to default value for V1 actions */
898 ctx->ctx_mta_aflags = v; /* MTA action flags */
901 (void) memcpy((void *) &i, (void *) &(g->a_buf[MILTER_LEN_BYTES * 2]),
905 /* no flags? set to default value for V1 protocol */
908 #if _FFR_MDS_NEGOTIATE
909 else if (ctx->ctx_smfi->xxfi_version >= SMFI_VERSION_MDS)
912 ** Allow changing the size only if milter is compiled
913 ** against a version that supports this.
914 ** If a milter is dynamically linked against a newer
915 ** libmilter version, we don't want to "surprise"
916 ** it with a larger buffer as it may rely on it
917 ** even though it is not documented as a limit.
920 if (bitset(SMFIP_MDS_1M, v))
922 internal_pflags |= SMFIP_MDS_1M;
923 (void) smfi_setmaxdatasize(MILTER_MDS_1M);
925 else if (bitset(SMFIP_MDS_256K, v))
927 internal_pflags |= SMFIP_MDS_256K;
928 (void) smfi_setmaxdatasize(MILTER_MDS_256K);
932 /* don't log this for now... */
933 else if (ctx->ctx_smfi->xxfi_version < SMFI_VERSION_MDS &&
934 bitset(SMFIP_MDS_1M|SMFIP_MDS_256K, v))
936 smi_log(SMI_LOG_WARN,
937 "%s: st_optionneg[%ld]: milter version=%X, trying flags=%X",
938 ctx->ctx_smfi->xxfi_name,
939 (long) ctx->ctx_id, ctx->ctx_smfi->xxfi_version, v);
942 #endif /* _FFR_MDS_NEGOTIATE */
945 ** MTA protocol flags.
946 ** We pass the internal flags to the milter as "read only",
947 ** i.e., a milter can read them so it knows which size
948 ** will be used, but any changes by a milter will be ignored
949 ** (see below, search for SMFI_INTERNAL).
952 ctx->ctx_mta_pflags = (v & ~SMFI_INTERNAL) | internal_pflags;
955 ** Copy flags from milter struct into libmilter context;
956 ** this variable will be used later on to check whether
957 ** the MTA "actions" can fulfill the milter requirements,
958 ** but it may be overwritten by the negotiate callback.
961 ctx->ctx_aflags = ctx->ctx_smfi->xxfi_flags;
962 fake_pflags = SMFIP_NR_CONN
973 if (g->a_ctx->ctx_smfi != NULL &&
974 g->a_ctx->ctx_smfi->xxfi_version > 4 &&
975 (fi_negotiate = g->a_ctx->ctx_smfi->xxfi_negotiate) != NULL)
978 unsigned long m_aflags, m_pflags, m_f2, m_f3;
981 ** let milter decide whether the features offered by the
982 ** MTA are "good enough".
984 ** - libmilter can "fake" some features (e.g., SMFIP_NR_HDR)
985 ** - m_f2, m_f3 are for future extensions
989 m_aflags = ctx->ctx_mta_aflags;
990 m_pflags = ctx->ctx_pflags;
991 if ((SMFIP_SKIP & ctx->ctx_mta_pflags) != 0)
992 m_pflags |= SMFIP_SKIP;
993 r = fi_negotiate(g->a_ctx,
995 ctx->ctx_mta_pflags|fake_pflags,
997 &m_aflags, &m_pflags, &m_f2, &m_f3);
999 #if _FFR_MILTER_CHECK
1000 testmode = bitset(SMFIP_TEST, m_pflags);
1002 m_pflags &= ~SMFIP_TEST;
1003 #endif /* _FFR_MILTER_CHECK */
1006 ** Types of protocol flags (pflags):
1007 ** 1. do NOT send protocol step X
1008 ** 2. MTA can do/understand something extra (SKIP,
1009 ** send unknown RCPTs)
1010 ** 3. MTA can deal with "no reply" for various protocol steps
1011 ** Note: this mean that it isn't possible to simply set all
1012 ** flags to get "everything":
1013 ** setting a flag of type 1 turns off a step
1014 ** (it should be the other way around:
1015 ** a flag means a protocol step can be sent)
1016 ** setting a flag of type 3 requires that milter
1017 ** never sends a reply for the corresponding step.
1018 ** Summary: the "negation" of protocol flags is causing
1019 ** problems, but at least for type 3 there is no simple
1022 ** What should "all options" mean?
1023 ** send all protocol steps _except_ those for which there is
1024 ** no callback (currently registered in ctx_pflags)
1025 ** expect SKIP as return code? Yes
1026 ** send unknown RCPTs? No,
1027 ** must be explicitly requested?
1028 ** "no reply" for some protocol steps? No,
1029 ** must be explicitly requested.
1032 if (SMFIS_ALL_OPTS == r)
1034 ctx->ctx_aflags = ctx->ctx_mta_aflags;
1035 ctx->ctx_pflags2mta = ctx->ctx_pflags;
1036 if ((SMFIP_SKIP & ctx->ctx_mta_pflags) != 0)
1037 ctx->ctx_pflags2mta |= SMFIP_SKIP;
1039 else if (r != SMFIS_CONTINUE)
1041 smi_log(SMI_LOG_ERR,
1042 "%s: st_optionneg[%ld]: xxfi_negotiate returned %d (protocol options=0x%lx, actions=0x%lx)",
1043 ctx->ctx_smfi->xxfi_name,
1044 (long) ctx->ctx_id, r, ctx->ctx_mta_pflags,
1045 ctx->ctx_mta_aflags);
1046 return _SMFIS_ABORT;
1050 ctx->ctx_aflags = m_aflags;
1051 ctx->ctx_pflags = m_pflags;
1052 ctx->ctx_pflags2mta = m_pflags;
1055 /* check whether some flags need to be "faked" */
1056 i = ctx->ctx_pflags2mta;
1057 if ((ctx->ctx_mta_pflags & i) != i)
1063 ** If some behavior can be faked (set in fake_pflags),
1064 ** but the MTA doesn't support it, then unset
1065 ** that flag in the value that is sent to the MTA.
1068 for (idx = 0; idx < 32; idx++)
1071 if ((ctx->ctx_mta_pflags & b) != b &&
1072 (fake_pflags & b) == b)
1073 ctx->ctx_pflags2mta &= ~b;
1080 ** Set the protocol flags based on the values determined
1081 ** in mi_listener() which checked the defined callbacks.
1084 ctx->ctx_pflags2mta = ctx->ctx_pflags;
1087 /* check whether actions and protocol requirements can be satisfied */
1088 i = ctx->ctx_aflags;
1089 if ((i & ctx->ctx_mta_aflags) != i)
1091 smi_log(SMI_LOG_ERR,
1092 "%s: st_optionneg[%ld]: 0x%lx does not fulfill action requirements 0x%x",
1093 ctx->ctx_smfi->xxfi_name,
1094 (long) ctx->ctx_id, ctx->ctx_mta_aflags, i);
1095 return _SMFIS_ABORT;
1098 i = ctx->ctx_pflags2mta;
1099 if ((ctx->ctx_mta_pflags & i) != i)
1102 ** Older MTAs do not support some protocol steps.
1103 ** As this protocol is a bit "wierd" (it asks for steps
1104 ** NOT to be taken/sent) we have to check whether we
1105 ** should turn off those "negative" requests.
1106 ** Currently these are only SMFIP_NODATA and SMFIP_NOUNKNOWN.
1109 if (bitset(SMFIP_NODATA, ctx->ctx_pflags2mta) &&
1110 !bitset(SMFIP_NODATA, ctx->ctx_mta_pflags))
1111 ctx->ctx_pflags2mta &= ~SMFIP_NODATA;
1112 if (bitset(SMFIP_NOUNKNOWN, ctx->ctx_pflags2mta) &&
1113 !bitset(SMFIP_NOUNKNOWN, ctx->ctx_mta_pflags))
1114 ctx->ctx_pflags2mta &= ~SMFIP_NOUNKNOWN;
1115 i = ctx->ctx_pflags2mta;
1118 if ((ctx->ctx_mta_pflags & i) != i)
1120 smi_log(SMI_LOG_ERR,
1121 "%s: st_optionneg[%ld]: 0x%lx does not fulfill protocol requirements 0x%x",
1122 ctx->ctx_smfi->xxfi_name,
1123 (long) ctx->ctx_id, ctx->ctx_mta_pflags, i);
1124 return _SMFIS_ABORT;
1128 if (ctx->ctx_dbg > 3)
1129 sm_dprintf("[%lu] milter_negotiate:"
1130 " mta_actions=0x%lx, mta_flags=0x%lx"
1131 " actions=0x%lx, flags=0x%lx\n"
1132 , (long) ctx->ctx_id
1133 , ctx->ctx_mta_aflags, ctx->ctx_mta_pflags
1134 , ctx->ctx_aflags, ctx->ctx_pflags);
1136 #if _FFR_MILTER_CHECK
1137 if (ctx->ctx_dbg > 3)
1138 sm_dprintf("[%lu] milter_negotiate:"
1139 " testmode=%d, pflags2mta=%X, internal_pflags=%X\n"
1140 , (long) ctx->ctx_id, testmode
1141 , ctx->ctx_pflags2mta, internal_pflags);
1143 /* in test mode: take flags without further modifications */
1145 /* Warning: check statement below! */
1146 #endif /* _FFR_MILTER_CHECK */
1149 ** Remove the internal flags that might have been set by a milter
1150 ** and set only those determined above.
1153 ctx->ctx_pflags2mta = (ctx->ctx_pflags2mta & ~SMFI_INTERNAL)
1155 return _SMFIS_OPTIONS;
1159 ** ST_CONNECTINFO -- receive connection information
1162 ** g -- generic argument structure
1165 ** continue or filter-specified value
1175 unsigned short port = 0;
1176 _SOCK_ADDR sockaddr;
1177 sfsistat (*fi_connect) __P((SMFICTX *, char *, _SOCK_ADDR *));
1180 return _SMFIS_ABORT;
1181 mi_clr_macros(g->a_ctx, g->a_idx + 1);
1182 if (g->a_ctx->ctx_smfi == NULL ||
1183 (fi_connect = g->a_ctx->ctx_smfi->xxfi_connect) == NULL)
1184 return SMFIS_CONTINUE;
1189 while (s[i] != '\0' && i <= l)
1192 return _SMFIS_ABORT;
1194 /* Move past trailing \0 in host string */
1197 (void) memset(&sockaddr, '\0', sizeof sockaddr);
1198 if (family != SMFIA_UNKNOWN)
1200 if (i + sizeof port >= l)
1202 smi_log(SMI_LOG_ERR,
1203 "%s: connect[%ld]: wrong len %d >= %d",
1204 g->a_ctx->ctx_smfi->xxfi_name,
1205 (long) g->a_ctx->ctx_id, (int) i, (int) l);
1206 return _SMFIS_ABORT;
1208 (void) memcpy((void *) &port, (void *) (s + i),
1212 /* make sure string is terminated */
1213 if (s[l - 1] != '\0')
1214 return _SMFIS_ABORT;
1216 if (family == SMFIA_INET)
1218 if (inet_aton(s + i, (struct in_addr *) &sockaddr.sin.sin_addr)
1221 smi_log(SMI_LOG_ERR,
1222 "%s: connect[%ld]: inet_aton failed",
1223 g->a_ctx->ctx_smfi->xxfi_name,
1224 (long) g->a_ctx->ctx_id);
1225 return _SMFIS_ABORT;
1227 sockaddr.sa.sa_family = AF_INET;
1229 sockaddr.sin.sin_port = port;
1232 # endif /* NETINET */
1234 if (family == SMFIA_INET6)
1236 if (mi_inet_pton(AF_INET6, s + i,
1237 &sockaddr.sin6.sin6_addr) != 1)
1239 smi_log(SMI_LOG_ERR,
1240 "%s: connect[%ld]: mi_inet_pton failed",
1241 g->a_ctx->ctx_smfi->xxfi_name,
1242 (long) g->a_ctx->ctx_id);
1243 return _SMFIS_ABORT;
1245 sockaddr.sa.sa_family = AF_INET6;
1247 sockaddr.sin6.sin6_port = port;
1250 # endif /* NETINET6 */
1252 if (family == SMFIA_UNIX)
1254 if (sm_strlcpy(sockaddr.sunix.sun_path, s + i,
1255 sizeof sockaddr.sunix.sun_path) >=
1256 sizeof sockaddr.sunix.sun_path)
1258 smi_log(SMI_LOG_ERR,
1259 "%s: connect[%ld]: path too long",
1260 g->a_ctx->ctx_smfi->xxfi_name,
1261 (long) g->a_ctx->ctx_id);
1262 return _SMFIS_ABORT;
1264 sockaddr.sunix.sun_family = AF_UNIX;
1267 # endif /* NETUNIX */
1269 smi_log(SMI_LOG_ERR,
1270 "%s: connect[%ld]: unknown family %d",
1271 g->a_ctx->ctx_smfi->xxfi_name,
1272 (long) g->a_ctx->ctx_id, family);
1273 return _SMFIS_ABORT;
1276 return (*fi_connect)(g->a_ctx, g->a_buf,
1277 family != SMFIA_UNKNOWN ? &sockaddr : NULL);
1281 ** ST_EOH -- end of headers
1284 ** g -- generic argument structure
1287 ** continue or filter-specified value
1294 sfsistat (*fi_eoh) __P((SMFICTX *));
1297 return _SMFIS_ABORT;
1298 if (g->a_ctx->ctx_smfi != NULL &&
1299 (fi_eoh = g->a_ctx->ctx_smfi->xxfi_eoh) != NULL)
1300 return (*fi_eoh)(g->a_ctx);
1301 return SMFIS_CONTINUE;
1305 ** ST_DATA -- DATA command
1308 ** g -- generic argument structure
1311 ** continue or filter-specified value
1318 sfsistat (*fi_data) __P((SMFICTX *));
1321 return _SMFIS_ABORT;
1322 if (g->a_ctx->ctx_smfi != NULL &&
1323 g->a_ctx->ctx_smfi->xxfi_version > 3 &&
1324 (fi_data = g->a_ctx->ctx_smfi->xxfi_data) != NULL)
1325 return (*fi_data)(g->a_ctx);
1326 return SMFIS_CONTINUE;
1330 ** ST_HELO -- helo/ehlo command
1333 ** g -- generic argument structure
1336 ** continue or filter-specified value
1343 sfsistat (*fi_helo) __P((SMFICTX *, char *));
1346 return _SMFIS_ABORT;
1347 mi_clr_macros(g->a_ctx, g->a_idx + 1);
1348 if (g->a_ctx->ctx_smfi != NULL &&
1349 (fi_helo = g->a_ctx->ctx_smfi->xxfi_helo) != NULL)
1351 /* paranoia: check for terminating '\0' */
1352 if (g->a_len == 0 || g->a_buf[g->a_len - 1] != '\0')
1354 return (*fi_helo)(g->a_ctx, g->a_buf);
1356 return SMFIS_CONTINUE;
1360 ** ST_HEADER -- header line
1363 ** g -- generic argument structure
1366 ** continue or filter-specified value
1374 sfsistat (*fi_header) __P((SMFICTX *, char *, char *));
1377 return _SMFIS_ABORT;
1378 if (g->a_ctx->ctx_smfi == NULL ||
1379 (fi_header = g->a_ctx->ctx_smfi->xxfi_header) == NULL)
1380 return SMFIS_CONTINUE;
1381 if (dec_arg2(g->a_buf, g->a_len, &hf, &hv) == MI_SUCCESS)
1382 return (*fi_header)(g->a_ctx, hf, hv);
1384 return _SMFIS_ABORT;
1387 #define ARGV_FCT(lf, rf, idx) \
1389 sfsistat (*lf) __P((SMFICTX *, char **)); \
1393 return _SMFIS_ABORT; \
1394 mi_clr_macros(g->a_ctx, g->a_idx + 1); \
1395 if (g->a_ctx->ctx_smfi == NULL || \
1396 (lf = g->a_ctx->ctx_smfi->rf) == NULL) \
1397 return SMFIS_CONTINUE; \
1398 if ((argv = dec_argv(g->a_buf, g->a_len)) == NULL) \
1399 return _SMFIS_ABORT; \
1400 r = (*lf)(g->a_ctx, argv); \
1405 ** ST_SENDER -- MAIL FROM command
1408 ** g -- generic argument structure
1411 ** continue or filter-specified value
1418 ARGV_FCT(fi_envfrom, xxfi_envfrom, CI_MAIL)
1422 ** ST_RCPT -- RCPT TO command
1425 ** g -- generic argument structure
1428 ** continue or filter-specified value
1435 ARGV_FCT(fi_envrcpt, xxfi_envrcpt, CI_RCPT)
1439 ** ST_UNKNOWN -- unrecognized or unimplemented command
1442 ** g -- generic argument structure
1445 ** continue or filter-specified value
1452 sfsistat (*fi_unknown) __P((SMFICTX *, const char *));
1455 return _SMFIS_ABORT;
1456 if (g->a_ctx->ctx_smfi != NULL &&
1457 g->a_ctx->ctx_smfi->xxfi_version > 2 &&
1458 (fi_unknown = g->a_ctx->ctx_smfi->xxfi_unknown) != NULL)
1459 return (*fi_unknown)(g->a_ctx, (const char *) g->a_buf);
1460 return SMFIS_CONTINUE;
1464 ** ST_MACROS -- deal with macros received from the MTA
1467 ** g -- generic argument structure
1473 ** set pointer in macro array to current values.
1483 if (g == NULL || g->a_len < 1)
1485 if ((argv = dec_argv(g->a_buf + 1, g->a_len - 1)) == NULL)
1487 switch (g->a_buf[0])
1514 if (g->a_ctx->ctx_mac_ptr[i] != NULL)
1515 free(g->a_ctx->ctx_mac_ptr[i]);
1516 if (g->a_ctx->ctx_mac_buf[i] != NULL)
1517 free(g->a_ctx->ctx_mac_buf[i]);
1518 g->a_ctx->ctx_mac_ptr[i] = argv;
1519 g->a_ctx->ctx_mac_buf[i] = g->a_buf;
1524 ** ST_QUIT -- quit command
1527 ** g -- generic argument structure
1538 sfsistat (*fi_close) __P((SMFICTX *));
1541 return _SMFIS_ABORT;
1542 if (g->a_ctx->ctx_smfi != NULL &&
1543 (fi_close = g->a_ctx->ctx_smfi->xxfi_close) != NULL)
1544 (void) (*fi_close)(g->a_ctx);
1545 mi_clr_macros(g->a_ctx, 0);
1546 return _SMFIS_NOREPLY;
1550 ** ST_BODYCHUNK -- deal with a piece of the mail body
1553 ** g -- generic argument structure
1556 ** continue or filter-specified value
1563 sfsistat (*fi_body) __P((SMFICTX *, unsigned char *, size_t));
1566 return _SMFIS_ABORT;
1567 if (g->a_ctx->ctx_smfi != NULL &&
1568 (fi_body = g->a_ctx->ctx_smfi->xxfi_body) != NULL)
1569 return (*fi_body)(g->a_ctx, (unsigned char *)g->a_buf,
1571 return SMFIS_CONTINUE;
1575 ** ST_BODYEND -- deal with the last piece of the mail body
1578 ** g -- generic argument structure
1581 ** continue or filter-specified value
1584 ** sends a reply for the body part (if non-empty).
1592 sfsistat (*fi_body) __P((SMFICTX *, unsigned char *, size_t));
1593 sfsistat (*fi_eom) __P((SMFICTX *));
1596 return _SMFIS_ABORT;
1598 if (g->a_ctx->ctx_smfi != NULL)
1600 if ((fi_body = g->a_ctx->ctx_smfi->xxfi_body) != NULL &&
1604 struct timeval timeout;
1606 timeout.tv_sec = g->a_ctx->ctx_timeout;
1607 timeout.tv_usec = 0;
1608 sd = g->a_ctx->ctx_sd;
1609 r = (*fi_body)(g->a_ctx, (unsigned char *)g->a_buf,
1611 if (r != SMFIS_CONTINUE &&
1612 sendreply(r, sd, &timeout, g->a_ctx) != MI_SUCCESS)
1613 return _SMFIS_ABORT;
1616 if (r == SMFIS_CONTINUE &&
1617 (fi_eom = g->a_ctx->ctx_smfi->xxfi_eom) != NULL)
1618 return (*fi_eom)(g->a_ctx);
1623 ** ST_ABORTFCT -- deal with aborts
1626 ** g -- generic argument structure
1629 ** abort or filter-specified value
1636 sfsistat (*fi_abort) __P((SMFICTX *));
1639 return _SMFIS_ABORT;
1640 if (g != NULL && g->a_ctx->ctx_smfi != NULL &&
1641 (fi_abort = g->a_ctx->ctx_smfi->xxfi_abort) != NULL)
1642 (void) (*fi_abort)(g->a_ctx);
1643 return _SMFIS_NOREPLY;
1647 ** TRANS_OK -- is the state transition ok?
1654 ** state transition ok
1664 if (s >= SIZE_NEXT_STATES)
1668 /* is this state transition allowed? */
1669 if ((MI_MASK(new) & next_states[s]) != 0)
1673 ** no: try next state;
1674 ** this works since the relevant states are ordered
1675 ** strict sequentially
1679 if (n >= SIZE_NEXT_STATES)
1683 ** can we actually "skip" this state?
1684 ** see fix_stm() which sets this bit for those
1685 ** states which the filter program is not interested in
1688 if (bitset(NX_SKIP, next_states[n]))
1692 } while (s < SIZE_NEXT_STATES);
1697 ** FIX_STM -- add "skip" bits to the state transition table
1700 ** ctx -- context structure
1706 ** may change state transition table.
1715 if (ctx == NULL || ctx->ctx_smfi == NULL)
1717 fl = ctx->ctx_pflags;
1718 if (bitset(SMFIP_NOCONNECT, fl))
1719 next_states[ST_CONN] |= NX_SKIP;
1720 if (bitset(SMFIP_NOHELO, fl))
1721 next_states[ST_HELO] |= NX_SKIP;
1722 if (bitset(SMFIP_NOMAIL, fl))
1723 next_states[ST_MAIL] |= NX_SKIP;
1724 if (bitset(SMFIP_NORCPT, fl))
1725 next_states[ST_RCPT] |= NX_SKIP;
1726 if (bitset(SMFIP_NOHDRS, fl))
1727 next_states[ST_HDRS] |= NX_SKIP;
1728 if (bitset(SMFIP_NOEOH, fl))
1729 next_states[ST_EOHS] |= NX_SKIP;
1730 if (bitset(SMFIP_NOBODY, fl))
1731 next_states[ST_BODY] |= NX_SKIP;
1732 if (bitset(SMFIP_NODATA, fl))
1733 next_states[ST_DATA] |= NX_SKIP;
1734 if (bitset(SMFIP_NOUNKNOWN, fl))
1735 next_states[ST_UNKN] |= NX_SKIP;
1739 ** DEC_ARGV -- split a buffer into a list of strings, NULL terminated
1742 ** buf -- buffer with several strings
1743 ** len -- length of buffer
1746 ** array of pointers to the individual strings
1759 for (i = 0; i < len; i++)
1767 /* last entry is only for the name */
1768 s = (char **)malloc((nelem + 1) * (sizeof *s));
1772 for (i = 0, elem = 0; i < len && elem < nelem; i++)
1780 s[elem] = &(buf[i + 1]);
1784 /* overwrite last entry (already done above, just paranoia) */
1790 ** DEC_ARG2 -- split a buffer into two strings
1793 ** buf -- buffer with two strings
1794 ** len -- length of buffer
1795 ** s1,s2 -- pointer to result strings
1798 ** MI_FAILURE/MI_SUCCESS
1802 dec_arg2(buf, len, s1, s2)
1810 /* paranoia: check for terminating '\0' */
1811 if (len == 0 || buf[len - 1] != '\0')
1814 for (i = 1; i < len && buf[i] != '\0'; i++)
1823 ** MI_SENDOK -- is it ok for the filter to send stuff to the MTA?
1826 ** ctx -- context structure
1827 ** flag -- flag to check
1830 ** sending allowed (in current state)
1834 mi_sendok(ctx, flag)
1838 if (ctx == NULL || ctx->ctx_smfi == NULL)
1841 /* did the milter request this operation? */
1842 if (flag != 0 && !bitset(flag, ctx->ctx_aflags))
1845 /* are we in the correct state? It must be "End of Message". */
1846 return ctx->ctx_state == ST_ENDM;
1849 #if _FFR_WORKERS_POOL
1851 ** MI_RD_SOCKET_READY - checks if the socket is ready for read(2)
1857 ** true iff socket is ready for read(2)
1860 #define MI_RD_CMD_TO 1
1861 #define MI_RD_MAX_ERR 16
1864 mi_rd_socket_ready (sd)
1871 #else /* SM_CONF_POLL */
1872 fd_set rd_set, exc_set;
1873 #endif /* SM_CONF_POLL */
1879 pfd.events = POLLIN;
1882 n = poll(&pfd, 1, MI_RD_CMD_TO);
1883 #else /* SM_CONF_POLL */
1884 struct timeval timeout;
1888 FD_SET(sd, &rd_set);
1889 FD_SET(sd, &exc_set);
1891 timeout.tv_sec = MI_RD_CMD_TO / 1000;
1892 timeout.tv_usec = 0;
1893 n = select(sd + 1, &rd_set, NULL, &exc_set, &timeout);
1894 #endif /* SM_CONF_POLL */
1909 } while (nerr < MI_RD_MAX_ERR);
1910 if (nerr >= MI_RD_MAX_ERR)
1914 return (pfd.revents != 0);
1915 #else /* SM_CONF_POLL */
1916 return FD_ISSET(sd, &rd_set) || FD_ISSET(sd, &exc_set);
1917 #endif /* SM_CONF_POLL */
1919 #endif /* _FFR_WORKERS_POOL */