| Top |
| #define | SM_LM_VRS_MAJOR() |
| #define | SM_LM_VRS_MINOR() |
| #define | SM_LM_VRS_PLVL() |
| int | smfi_opensocket () |
| int | smfi_register () |
| int | smfi_main () |
| int | smfi_setbacklog () |
| int | smfi_setdbg () |
| int | smfi_settimeout () |
| int | smfi_setconn () |
| int | smfi_stop () |
| int | smfi_version () |
| char * | smfi_getsymval () |
| int | smfi_setreply () |
| int | smfi_setmlreply () |
| int | smfi_addheader () |
| int | smfi_chgheader () |
| int | smfi_insheader () |
| int | smfi_chgfrom () |
| int | smfi_addrcpt () |
| int | smfi_addrcpt_par () |
| int | smfi_delrcpt () |
| int | smfi_progress () |
| int | smfi_replacebody () |
| int | smfi_quarantine () |
| int | smfi_setpriv () |
| void * | smfi_getpriv () |
| int | smfi_setsymlist () |
libmilter/mfapi.h provides Sendmail's libmilter compatible API. You can use this library instead of Sendmail's libmilter. See also API Documentation on milter.org.
#define SM_LM_VRS_MAJOR(version) (((version) & 0x7f000000) >> 24)
Extracts major version number from version
.
#define SM_LM_VRS_MINOR(version) (((version) & 0x007fff00) >> 8)
Extracts minor version number from version
.
#define SM_LM_VRS_PLVL(version) ((version) & 0x0000007f)
Extracts patch level from version
.
int
smfi_opensocket (bool remove_socket);
Creates the socket that is used to connect from MTA.
Normally, smfi_opensocket() isn't needed to call
explicitly. The socket is created in smfi_main()
implicitly.
Here are the fail conditions:
smfi_register() hasn't called successfully.
smfi_setconn() hasn't called successfully.
smfi_opensocket() fails to remove existing UNIX
domain socket if connection spec is for UNIX domain
socket and remove_socket
is true.
smfi_opensocket() fails to create the new socket.
See also smfi_opensocket on milter.org.
int
smfi_register (struct smfiDesc description);
Registers the milter implementation as callbacks.
Here are the fail conditions:
incompatible xxfi_version.
illegal xxfi_flags value.
See also smfi_register on milter.org.
int
smfi_main (void);
Enters event loop. The milter should be initialized
with smfi_register(), smfi_setconn() and so on before
smfi_main() is called.
Here are the fail conditions:
failed to create the socket.
See also smfi_main on milter.org.
int
smfi_setbacklog (int backlog);
Sets the milters' backlog value that is used for listen(2).
Here are the fail conditions:
backlog
<= 0.
See also smfi_setbacklog on milter.org.
int
smfi_setdbg (int level);
Sets the log level. If level
is 0, turns off any log
message. The greater value is specified, more log
messages are output.
See also smfi_setdbg on milter.org.
int
smfi_settimeout (int timeout);
Sets the I/O timeout value in seconds. The default value
is 7210 seconds. timeout
== 0 means no wait, not "wait
forever".
See also smfi_settimeout on milter.org.
int
smfi_setconn (char *connection_spec);
Sets the connection spec.
connection_spec
format is one of them:
"unix:/PATH/TO/SOCKET": UNIX domain socket.
"inet:PORT", "inet:PORT@HOST_NAME" or "inet:PORT@IP_ADDRESS": IPv4.
"inet6:PORT", "inet6:PORT@HOST_NAME" or "inet6:PORT@IP_ADDRESS": IPv6.
Here are the fail conditions:
invalid format.
connection_spec
is NULL.
See also smfi_setconn on milter.org.
int
smfi_stop (void);
Stops the milter. No more connections are accepted but processing connections are continued until they are finished.
See also smfi_stop on milter.org.
int smfi_version (unsigned int *major,unsigned int *minor,unsigned int *patch_level);
Gets the libmilter version. The version is for using libmilter not built libmilter.
See also smfi_version on milter.org.
char * smfi_getsymval (SMFICTX *context,char *name);
Gets a value of the macro named name
in the current milter
session context. smfi_getsymval() can be called in
xxfi_XXX callbacks. (e.g. xxfi_connect(), xxfi_helo(),
...)
name
should be enclosed in braces ("{" and "}") like
"{if_name}" except name
contains a character like "i".
See also smfi_getsymval on milter.org. Sendmail's default macros are also shown in the page.
int smfi_setreply (SMFICTX *context,char *return_code,char *extended_code,char *message);
Sets the error reply code. 4xx return_code
is used on
SMFIS_TEMPFAIL. 5xx return_code
is used on
SMFIS_REJECT.
Here are the fail conditions:
return_code
is neither 4xx nor 5xx.
extended_code
is neither 4.x.x nor 5.x.x.
See also smfi_setreply on milter.org.
int smfi_setmlreply (SMFICTX *context,const char *return_code,const char *extended_code,...);
Sets the error reply code. 4xx return_code
is used on
SMFIS_TEMPFAIL. 5xx return_code
is used on
SMFIS_REJECT.
Here are the fail conditions:
return_code
is neither 4xx nor 5xx.
extended_code
is neither 4.x.x nor 5.x.x.
See also smfi_setmlreply on milter.org.
context |
the context for the current milter session. |
|
return_code |
the three-digit SMTP error reply code. (RFC 2821) Only 4xx and 5xx are accepted. |
|
extended_code |
the extended reply code (RFC 1893/2034),
or |
|
... |
the single lines of text part of the SMTP reply,
terminated by |
int smfi_addheader (SMFICTX *context,char *name,char *value);
Adds a header to the current message's header
list. smfi_addheader() can be called in xxfi_eom().
Here are the fail conditions:
name
is NULL.
value
is NULL.
called in except xxfi_eom().
SMFIF_ADDHDRS flag isn't set in smfi_register() or
xxfi_negotiate().
network error is occurred.
See also smfi_addheader on milter.org.
int smfi_chgheader (SMFICTX *context,char *name,int index,char *value);
Changes a header that is located at index
in headers
that all of them are named name
. If value
is NULL, the
header is deleted. smfi_chgheader() can be called in
xxfi_eom().
Here are the fail conditions:
name
is NULL.
called in except xxfi_eom(). FIXME: not-implemented yet.
SMFIF_CHGHDRS flag isn't set in smfi_register() or
xxfi_negotiate(). FIXME: not-implemented yet.
network error is occurred.
See also smfi_chgheader on milter.org.
context |
the context for the current milter session. |
|
name |
the header name. |
|
index |
the index of headers that all of them are named
|
|
value |
the header value. Use |
int smfi_insheader (SMFICTX *context,int index,char *name,char *value);
Inserts a header to index
in headers. smfi_insheader()
can be called in xxfi_eom().
Here are the fail conditions:
name
is NULL.
value
is NULL. FIXME: not-implemented yet.
called in except xxfi_eom(). FIXME: not-implemented yet.
SMFIF_ADDHDRS flag isn't set in smfi_register() or
xxfi_negotiate(). FIXME: not-implemented yet.
network error is occurred.
See also smfi_insheader on milter.org.
int smfi_chgfrom (SMFICTX *context,char *mail,char *arguments);
Changes a sender address. smfi_chgfrom() can be called in
xxfi_eom().
Here are the fail conditions:
mail
is NULL. FIXME: not-implemented yet.
called in except xxfi_eom(). FIXME: not-implemented yet.
SMFIF_CHGFROM flag isn't set in smfi_register() or
xxfi_negotiate(). FIXME: not-implemented yet.
network error is occurred.
See also smfi_chgfrom on milter.org.
int smfi_addrcpt (SMFICTX *context,char *recipient);
Adds a recipient address. smfi_addrcpt() can be called in
xxfi_eom().
Here are the fail conditions:
recipient
is NULL. FIXME: not-implemented yet.
called in except xxfi_eom(). FIXME: not-implemented yet.
SMFIF_ADDRCPT flag isn't set in smfi_register() or
xxfi_negotiate(). FIXME: not-implemented yet.
network error is occurred.
See also smfi_addrcpt on milter.org.
int smfi_addrcpt_par (SMFICTX *context,char *recipient,char *arguments);
Adds a recipient address with extra ESMTP
arguments. smfi_addrcpt_par() can be called in
xxfi_eom().
Here are the fail conditions:
recipient
is NULL. FIXME: not-implemented yet.
called in except xxfi_eom(). FIXME: not-implemented yet.
SMFIF_ADDRCPT_PAR flag isn't set in smfi_register() or
xxfi_negotiate(). FIXME: not-implemented yet.
network error is occurred.
See also smfi_addrcpt_par on milter.org.
int smfi_delrcpt (SMFICTX *context,char *recipient);
Deletes a recipient address. smfi_delrcpt() can be called in
xxfi_eom().
Here are the fail conditions:
recipient
is NULL. FIXME: not-implemented yet.
called in except xxfi_eom(). FIXME: not-implemented yet.
SMFIF_DELRCPT flag isn't set in smfi_register() or
xxfi_negotiate(). FIXME: not-implemented yet.
network error is occurred.
See also smfi_delrcpt on milter.org.
int
smfi_progress (SMFICTX *context);
Keeps the current connection. smfi_progress() can be called in
xxfi_eom().
Here are the fail conditions:
called in except xxfi_eom(). FIXME: not-implemented yet.
network error is occurred.
See also smfi_progress on milter.org.
int smfi_replacebody (SMFICTX *context,unsigned char *new_body,int new_body_size);
Replaces the current body data with
new_body
. smfi_replacebody() can be called in
xxfi_eom().
Here are the fail conditions:
new_body
== NULL and new_body_size
> 0. FIXME:
not-implemented yet.
called in except xxfi_eom(). FIXME: not-implemented yet.
SMFIF_CHGBODY flag isn't set in smfi_register() or
xxfi_negotiate(). FIXME: not-implemented yet.
network error is occurred.
See also smfi_replacebody on milter.org.
int smfi_quarantine (SMFICTX *context,char *reason);
Quarantines the current message with
reason
. smfi_quarantine() can be called in xxfi_eom().
Here are the fail conditions:
reason
is NULL or empty. FIXME: not-implemented yet.
called in except xxfi_eom(). FIXME: not-implemented yet.
SMFIF_QUARANTINE flag isn't set in smfi_register() or
xxfi_negotiate(). FIXME: not-implemented yet.
network error is occurred.
See also smfi_quarantine on milter.org.
int smfi_setpriv (SMFICTX *context,void *data);
Sets the private data.
Here are the fail conditions:
context
is invalid. FIXME: not-implemented yet.
See also smfi_setpriv on milter.org.
void *
smfi_getpriv (SMFICTX *context);
Gets the private data.
Here are the fail conditions:
context
is invalid. FIXME: not-implemented yet.
See also smfi_getpriv on milter.org.
int smfi_setsymlist (SMFICTX *context,int state,char *macros);
Sets the list of requested macros. smfi_setsymlist() can
be called in xxfi_negotiate().
Here are the fail conditions:
state
is not a valid value. FIXME: not-implemented yet.
macros
is NULL or empty. FIXME: not-implemented yet.
the macro list for state
has been set before. FIXME:
not-implemented yet.
called in except xxfi_negotiate(). FIXME: not-implemented yet.
network error is occurred.
See also smfi_setsymlist on milter.org.
context |
the context for the current milter session. |
|
state |
the state defined as SMFIM_XXX like |
|
macros |
the space separated macro names like "{rcpt_mailer} {rcpt_host}". |
typedef struct smfi_str SMFICTX;
Holds information for a milter session. SMFICTX is
created for each milter session. SMFICTX is the most
important object in libmilter API.
typedef struct smfiDesc smfiDesc_str;
Holds information for the milter. smfiDesc_str is
used by smfi_register().
typedef int sfsistat;
Indicates response status returned by callback.
Available response status is one of the followings:
struct smfiDesc {
char *xxfi_name;
int xxfi_version;
unsigned long xxfi_flags;
sfsistat (*xxfi_connect) (SMFICTX *context,
char *host_name,
_SOCK_ADDR *address);
sfsistat (*xxfi_helo) (SMFICTX *context,
char *fqdn);
sfsistat (*xxfi_envfrom) (SMFICTX *context,
char **arguments);
sfsistat (*xxfi_envrcpt) (SMFICTX *context,
char **arguments);
sfsistat (*xxfi_header) (SMFICTX *context,
char *name,
char *value);
sfsistat (*xxfi_eoh) (SMFICTX *context);
sfsistat (*xxfi_body) (SMFICTX *context,
unsigned char *data,
size_t data_size);
sfsistat (*xxfi_eom) (SMFICTX *context);
sfsistat (*xxfi_abort) (SMFICTX *context);
sfsistat (*xxfi_close) (SMFICTX *context);
sfsistat (*xxfi_unknown) (SMFICTX *context,
const char *command);
sfsistat (*xxfi_data) (SMFICTX *context);
sfsistat (*xxfi_negotiate) (SMFICTX *context,
unsigned long actions,
unsigned long steps,
unsigned long unused0,
unsigned long unused1,
unsigned long *actions_output,
unsigned long *steps_output,
unsigned long *unused0_output,
unsigned long *unused1_output);
};
smfiDesc is used by smfi_register() to register a milter.
If xxfi_name
is NULL, "Unknown" is used as default
milter name.
xxfi_version
must be specified SMFI_VERSION.
Here are the available xxfi_flags
values:
SMFIF_ADDHDRS: The milter may call smfi_addheader().
SMFIF_CHGHDRS: The milter may call smfi_chgheader().
SMFIF_CHGBODY: The milter may call smfi_chgbody().
SMFIF_ADDRCPT: The milter may call smfi_addrcpt().
SMFIF_ADDRCPT_PAR: The milter may call smfi_addrcpt_par().
SMFIF_DELRCPT: The milter may call smfi_delrcpt().
SMFIF_QUARANTINE: The milter may call smfi_quarantine().
SMFIF_CHGFROM: The milter may call smfi_chgfrom().
SMFIF_SETSMLIST: The milter may call smfi_setsymlist().
They can be used together by bitwise OR.
All callbacks (e.g. xxfi_helo(), xxfi_envfrom() and so
on) may be NULL. If a callback is NULL, the event is
just ignored the milter.
The name of the milter. |
||
The version code of the milter. |
||
The flags of the milter. Available values are SMFIF_*. |
||
See |
||
See |
||
See |
||
See |
||
See |
||
See |
||
See |
||
See |
||
See |
||
See |
||
See |
||
See |
||
See |
#define SMFIF_ADDHDRS 0x00000001L
The milter may call smfi_addheader().
See also smfiDesc, xxfi_negotiate() and
smfi_register on milter.org.
#define SMFIF_CHGBODY 0x00000002L
The milter may call smfi_chgbody().
See also smfiDesc, xxfi_negotiate() and
smfi_register on milter.org.
#define SMFIF_ADDRCPT 0x00000004L
The milter may call smfi_addrcpt().
See also smfiDesc, xxfi_negotiate() and
smfi_register on milter.org.
#define SMFIF_DELRCPT 0x00000008L
The milter may call smfi_delrcpt().
See also smfiDesc, xxfi_negotiate() and
smfi_register on milter.org.
#define SMFIF_CHGHDRS 0x00000010L
The milter may call smfi_chgheader().
See also smfiDesc, xxfi_negotiate() and
smfi_register on milter.org.
#define SMFIF_QUARANTINE 0x00000020L
The milter may call smfi_quarantine().
See also smfiDesc, xxfi_negotiate() and
smfi_register on milter.org.
#define SMFIF_CHGFROM 0x00000040L
The milter may call smfi_chgfrom().
See also smfiDesc, xxfi_negotiate() and
smfi_register on milter.org.
#define SMFIF_ADDRCPT_PAR 0x00000080L
The milter may call smfi_addrcpt_par().
See also smfiDesc, xxfi_negotiate() and
smfi_register on milter.org.
#define SMFIF_SETSYMLIST 0x00000100L
The milter may call smfi_setsymlist().
See also smfiDesc, xxfi_negotiate() and
smfi_register on milter.org.
#define SMFIS_CONTINUE 0
Continues the current process.
See each callback (xxfi_connect(), xxfi_helo() and so
on) and
callback return status description on milter.org.
#define SMFIS_REJECT 1
Rejects the current processing target.
See each callback (xxfi_connect(), xxfi_helo() and so
on) and
callback return status description on milter.org.
#define SMFIS_DISCARD 2
Accepts the current processing target and discards it silently.
See each callback (xxfi_envfrom(), xxfi_envrcpt() and so
on) and
callback return status description on milter.org.
#define SMFIS_ACCEPT 3
Accepts the current processing target.
See each callback (xxfi_connect(), xxfi_helo() and so
on) and
callback return status description on milter.org.
#define SMFIS_TEMPFAIL 4
Replies a temporary failure status for the current processing target.
See each callback (xxfi_connect(), xxfi_helo() and so
on) and
callback return status description on milter.org.
#define SMFIS_NOREPLY 7
Doesn't reply to the MTA.
See each callback (xxfi_connect(), xxfi_helo() and so
on) and
callback return status description on milter.org.
#define SMFIS_SKIP 8
Skips the rest body chunks. This can be used only in
xxfi_body().
See also callback return status description on milter.org.
#define SMFIS_ALL_OPTS 10
Uses the all negotiate options received from the
MTA. This can be used only in xxfi_negotiate().
#define SMFIM_CONNECT 0
Indicates the protocol stage for xxfi_connect().
See smfi_setsymlist().
#define SMFIM_HELO 1
Indicates the protocol stage for xxfi_helo().
See smfi_setsymlist().
#define SMFIM_ENVFROM 2
Indicates the protocol stage for xxfi_envfrom().
See smfi_setsymlist().
#define SMFIM_ENVRCPT 3
Indicates the protocol stage for xxfi_envrcpt().
See smfi_setsymlist().
#define SMFIM_DATA 4
Indicates the protocol stage for xxfi_data().
See smfi_setsymlist().
#define SMFIP_NOCONNECT 0x00000001L
Indicates that the MTA should not send information for
xxfi_connect().
This flag can be got/set to steps_output
of xxfi_negotiate().
#define SMFIP_NOHELO 0x00000002L
Indicates that the MTA should not send information for
xxfi_helo().
This flag can be got/set to steps_output
of xxfi_negotiate().
#define SMFIP_NOMAIL 0x00000004L
Indicates that the MTA should not send information for
xxfi_mail().
This flag can be got/set to steps_output
of xxfi_negotiate().
#define SMFIP_NORCPT 0x00000008L
Indicates that the MTA should not send information for
xxfi_rcpt().
This flag can be got/set to steps_output
of xxfi_negotiate().
#define SMFIP_NOHDRS 0x00000020L
Indicates that the MTA should not send information for
xxfi_header().
This flag can be got/set to steps_output
of xxfi_negotiate().
#define SMFIP_NOEOH 0x00000040L
Indicates that the MTA should not send information for
xxfi_eoh().
This flag can be got/set to steps_output
of xxfi_negotiate().
#define SMFIP_NR_HDR 0x00000080L
Indicates that the milter don't reply on xxfi_header().
This flag can be got/set to steps_output
of xxfi_negotiate().
#define SMFIP_NOUNKNOWN 0x00000100L
Indicates that the MTA should not send information for
xxfi_unknown().
This flag can be got/set to steps_output
of xxfi_negotiate().
#define SMFIP_NODATA 0x00000200L
Indicates that the MTA should not send information for
xxfi_data().
This flag can be got/set to steps_output
of xxfi_negotiate().
#define SMFIP_SKIP 0x00000400L
Indicates that the MTA supports SMFIS_SKIP in xxfi_body().
This flag can be got/set to steps_output
of xxfi_negotiate().
#define SMFIP_RCPT_REJ 0x00000800L
Indicates that the MTA should send rejected envelope
recipients and xxfi_envrcpt() is called for them.
This flag can be got/set to steps_output
of xxfi_negotiate().
#define SMFIP_NR_CONN 0x00001000L
Indicates that the milter don't reply on xxfi_connect().
This flag can be got/set to steps_output
of xxfi_negotiate().
#define SMFIP_NR_HELO 0x00002000L
Indicates that the milter don't reply on xxfi_helo().
This flag can be got/set to steps_output
of xxfi_negotiate().
#define SMFIP_NR_MAIL 0x00004000L
Indicates that the milter don't reply on xxfi_envfrom().
This flag can be got/set to steps_output
of xxfi_negotiate().
#define SMFIP_NR_RCPT 0x00008000L
Indicates that the milter don't reply on xxfi_envrcpt().
This flag can be got/set to steps_output
of xxfi_negotiate().
#define SMFIP_NR_DATA 0x00010000L
Indicates that the milter don't reply on xxfi_data().
This flag can be got/set to steps_output
of xxfi_negotiate().
#define SMFIP_NR_UNKN 0x00020000L
Indicates that the milter don't reply on xxfi_unknown().
This flag can be got/set to steps_output
of xxfi_negotiate().
#define SMFIP_NR_EOH 0x00040000L
Indicates that the milter don't reply on xxfi_eoh().
This flag can be got/set to steps_output
of xxfi_negotiate().
#define SMFIP_NR_BODY 0x00080000L
Indicates that the milter don't reply on xxfi_body().
This flag can be got/set to steps_output
of xxfi_negotiate().