| milter manager Reference Manual | ||||
|---|---|---|---|---|
#define MILTER_SERVER_CONTEXT_ERROR #define MILTER_SERVER_CONTEXT_DEFAULT_CONNECTION_TIMEOUT #define MILTER_SERVER_CONTEXT_DEFAULT_WRITING_TIMEOUT #define MILTER_SERVER_CONTEXT_DEFAULT_READING_TIMEOUT #define MILTER_SERVER_CONTEXT_DEFAULT_END_OF_MESSAGE_TIMEOUT enum MilterServerContextError; enum MilterServerContextState; MilterServerContext; GQuark milter_server_context_error_quark (void); MilterServerContext* milter_server_context_new (void); void milter_server_context_set_connection_timeout (MilterServerContext *context, gdouble timeout); void milter_server_context_set_writing_timeout (MilterServerContext *context, gdouble timeout); void milter_server_context_set_reading_timeout (MilterServerContext *context, gdouble timeout); void milter_server_context_set_end_of_message_timeout (MilterServerContext *context, gdouble timeout); gboolean milter_server_context_set_connection_spec (MilterServerContext *context, const gchar *spec, GError **error); gboolean milter_server_context_establish_connection (MilterServerContext *context, GError **error); MilterStatus milter_server_context_get_status (MilterServerContext *context); MilterServerContextState milter_server_context_get_state (MilterServerContext *context); void milter_server_context_set_state (MilterServerContext *context, MilterServerContextState state); gboolean milter_server_context_is_processing (MilterServerContext *context); gboolean milter_server_context_negotiate (MilterServerContext *context, MilterOption *option); gboolean milter_server_context_connect (MilterServerContext *context, const gchar *host_name, struct sockaddr *address, socklen_t address_length); gboolean milter_server_context_helo (MilterServerContext *context, const gchar *fqdn); gboolean milter_server_context_envelope_from (MilterServerContext *context, const gchar *from); gboolean milter_server_context_envelope_recipient (MilterServerContext *context, const gchar *recipient); gboolean milter_server_context_data (MilterServerContext *context); gboolean milter_server_context_unknown (MilterServerContext *context, const gchar *command); gboolean milter_server_context_header (MilterServerContext *context, const gchar *name, const gchar *value); gboolean milter_server_context_end_of_header (MilterServerContext *context); gboolean milter_server_context_body (MilterServerContext *context, const gchar *chunk, gsize size); gboolean milter_server_context_end_of_message (MilterServerContext *context, const gchar *chunk, gsize size); gboolean milter_server_context_quit (MilterServerContext *context); gboolean milter_server_context_abort (MilterServerContext *context); gboolean milter_server_context_is_enable_step (MilterServerContext *context, MilterStepFlags step); gboolean milter_server_context_get_skip_body (MilterServerContext *context); const gchar* milter_server_context_get_name (MilterServerContext *context); void milter_server_context_set_name (MilterServerContext *context, const gchar *name);
The MilterServerContext processes one server side milter
protocol session. It means MilterServerContext instance
is created for each milter protocol session.
#define MILTER_SERVER_CONTEXT_ERROR (milter_server_context_error_quark())
Used to get the GError quark for MilterServerContext errors.
#define MILTER_SERVER_CONTEXT_DEFAULT_CONNECTION_TIMEOUT 300
The default connection timeout by seconds.
#define MILTER_SERVER_CONTEXT_DEFAULT_WRITING_TIMEOUT 10
The default writing timeout by seconds.
#define MILTER_SERVER_CONTEXT_DEFAULT_READING_TIMEOUT 10
The default reading timeout by seconds.
#define MILTER_SERVER_CONTEXT_DEFAULT_END_OF_MESSAGE_TIMEOUT 300
The default end-of-message response timeout by seconds.
typedef enum
{
MILTER_SERVER_CONTEXT_ERROR_CONNECTION_FAILURE,
MILTER_SERVER_CONTEXT_ERROR_NO_SPEC,
MILTER_SERVER_CONTEXT_ERROR_INVALID_STATE,
MILTER_SERVER_CONTEXT_ERROR_BUSY,
MILTER_SERVER_CONTEXT_ERROR_IO_ERROR,
MILTER_SERVER_CONTEXT_ERROR_NEWER_VERSION_REQUESTED
} MilterServerContextError;
These identify the variable errors that can occur while
calling MilterServerContext functions.
| Indicates a connection failure. | |
| Indicates the connection spec isn't set. | |
Indicates
unexpected response is received on the current
MilterServerContextState.
|
|
| Indicates a new operation is requested before the previous operation's response is received. | |
| Indicates an IO error causing on writing/reading milter protocol data. | |
| Indicates unsupported newer version is requested. |
typedef enum
{
MILTER_SERVER_CONTEXT_STATE_START,
MILTER_SERVER_CONTEXT_STATE_DEFINE_MACRO,
MILTER_SERVER_CONTEXT_STATE_NEGOTIATE,
MILTER_SERVER_CONTEXT_STATE_CONNECT,
MILTER_SERVER_CONTEXT_STATE_HELO,
MILTER_SERVER_CONTEXT_STATE_ENVELOPE_FROM,
MILTER_SERVER_CONTEXT_STATE_ENVELOPE_RECIPIENT,
MILTER_SERVER_CONTEXT_STATE_DATA,
MILTER_SERVER_CONTEXT_STATE_UNKNOWN,
MILTER_SERVER_CONTEXT_STATE_HEADER,
MILTER_SERVER_CONTEXT_STATE_END_OF_HEADER,
MILTER_SERVER_CONTEXT_STATE_BODY,
MILTER_SERVER_CONTEXT_STATE_END_OF_MESSAGE,
MILTER_SERVER_CONTEXT_STATE_QUIT,
MILTER_SERVER_CONTEXT_STATE_ABORT
} MilterServerContextState;
These identify the state of MilterServerContext.
| Just started. | |
| Sent macro definition. | |
| Negotiating. | |
| Sent connection information. | |
| Sent HELO information. | |
| Sent MAIL FROM command information. | |
| Sent RCPT TO command information. | |
| Sent DATA command information. | |
| Sent unknown SMTP command. | |
| Sent a header. | |
| Sent all headers. | |
| Sent a body chunk. | |
| Sent all body chunks. | |
| Sent quit request. | |
| Sent abort request. |
MilterServerContext* milter_server_context_new (void);
Creates a new context object.
Returns : |
a new MilterServerContext object.
|
void milter_server_context_set_connection_timeout
(MilterServerContext *context,
gdouble timeout);
Sets the timeout by seconds on connection. If context
doesn't connects to client in timeout seconds,
"timeout" signal is emitted.
|
a MilterServerContext.
|
|
the connection timeout by seconds. (default is
MILTER_SERVER_CONTEXT_DEFAULT_CONNECTION_TIMEOUT)
|
void milter_server_context_set_writing_timeout
(MilterServerContext *context,
gdouble timeout);
Sets the timeout by seconds on writing. If context
doesn't write to client socket in timeout seconds,
"timeout" signal is emitted.
|
a MilterServerContext.
|
|
the writing timeout by seconds. (default is
MILTER_SERVER_CONTEXT_DEFAULT_WRITING_TIMEOUT)
|
void milter_server_context_set_reading_timeout
(MilterServerContext *context,
gdouble timeout);
Sets the timeout by seconds on reading. If context
doesn't receive response from client socket in timeout
seconds, "timeout" signal is emitted.
|
a MilterServerContext.
|
|
the reading timeout by seconds. (default is
MILTER_SERVER_CONTEXT_DEFAULT_READING_TIMEOUT)
|
void milter_server_context_set_end_of_message_timeout
(MilterServerContext *context,
gdouble timeout);
Sets the timeout by seconds on end-of-message. If
context doesn't receive response for end-of-message from
client socket in timeout seconds,
"timeout" signal is emitted.
|
a MilterServerContext.
|
|
the timeout by seconds on end-of-message.
(default is
MILTER_SERVER_CONTEXT_DEFAULT_END_OF_MESSAGE_TIMEOUT)
|
gboolean milter_server_context_set_connection_spec (MilterServerContext *context, const gchar *spec, GError **error);
Sets a connection specification of client. If spec is
invalid format and error is not NULL, error detail is
stored into error.
|
a MilterServerContext.
|
|
the connection spec of client. |
|
return location for an error, or NULL.
|
Returns : |
TRUE on success.
|
gboolean milter_server_context_establish_connection (MilterServerContext *context, GError **error);
Establishes a connection to client. If establishing is
failed and error is not NULL, error detail is stored
into error.
|
a MilterServerContext.
|
|
return location for an error, or NULL.
|
Returns : |
TRUE on success.
|
MilterStatus milter_server_context_get_status (MilterServerContext *context);
Gets the current status.
|
a MilterServerContext.
|
Returns : |
the current status. |
MilterServerContextState milter_server_context_get_state (MilterServerContext *context);
Gets the current state.
|
a MilterServerContext.
|
Returns : |
the current state. |
void milter_server_context_set_state (MilterServerContext *context, MilterServerContextState state);
Sets the current state.
|
a MilterServerContext.
|
|
the new state. |
gboolean milter_server_context_is_processing (MilterServerContext *context);
Gets whether waiting response.
|
a MilterServerContext.
|
Returns : |
TRUE if any response is received after the last
writing, FALSE otherwise.
|
gboolean milter_server_context_negotiate (MilterServerContext *context, MilterOption *option);
Negotiates with client.
|
a MilterServerContext.
|
|
the negotiate option. |
Returns : |
TRUE on success.
|
gboolean milter_server_context_connect (MilterServerContext *context, const gchar *host_name, struct sockaddr *address, socklen_t address_length);
Sends connected SMTP client information.
|
a MilterServerContext.
|
|
the host name of connected SMTP client. |
|
the address of connected SMTP client. |
|
the length of address.
|
Returns : |
TRUE on success.
|
gboolean milter_server_context_helo (MilterServerContext *context, const gchar *fqdn);
Sends the FQDN passed on HELO.
|
a MilterServerContext.
|
|
the FQDN. |
Returns : |
TRUE on success.
|
gboolean milter_server_context_envelope_from (MilterServerContext *context, const gchar *from);
Sends the parameter passed on MAIL FROM.
|
a MilterServerContext.
|
|
the envelope from address. |
Returns : |
TRUE on success.
|
gboolean milter_server_context_envelope_recipient (MilterServerContext *context, const gchar *recipient);
Sends the parameter passed on RCPT TO.
|
a MilterServerContext.
|
|
the envelope recipient address. |
Returns : |
TRUE on success.
|
gboolean milter_server_context_data (MilterServerContext *context);
Notifies DATA is received.
|
a MilterServerContext.
|
Returns : |
TRUE on success.
|
gboolean milter_server_context_unknown (MilterServerContext *context, const gchar *command);
Sends received unknown SMTP command.
|
a MilterServerContext.
|
|
the unknown SMTP command. |
Returns : |
TRUE on success.
|
gboolean milter_server_context_header (MilterServerContext *context, const gchar *name, const gchar *value);
Sends a header.
|
a MilterServerContext.
|
|
the header name. |
|
the header value. |
Returns : |
TRUE on success.
|
gboolean milter_server_context_end_of_header (MilterServerContext *context);
Notifies all headers are sent.
|
a MilterServerContext.
|
Returns : |
TRUE on success.
|
gboolean milter_server_context_body (MilterServerContext *context, const gchar *chunk, gsize size);
Sends a body chunk.
|
a MilterServerContext.
|
|
the body chunk. |
|
the size of chunk.
|
Returns : |
TRUE on success.
|
gboolean milter_server_context_end_of_message (MilterServerContext *context, const gchar *chunk, gsize size);
Notifies all body chunks are sent with optional the last body chunk.
|
a MilterServerContext.
|
|
the body chunk. maybe NULL.
|
|
the size of chunk.
|
Returns : |
TRUE on success.
|
gboolean milter_server_context_quit (MilterServerContext *context);
Quits the current connection.
|
a MilterServerContext.
|
Returns : |
TRUE on success.
|
gboolean milter_server_context_abort (MilterServerContext *context);
Aborts the current connection.
|
a MilterServerContext.
|
Returns : |
TRUE on success.
|
gboolean milter_server_context_is_enable_step (MilterServerContext *context, MilterStepFlags step);
Gets whether step flag is enabled in the context's option.
|
a MilterServerContext.
|
|
the step flag. |
Returns : |
TRUE if step flags is enabled, FALSE otherwise.
|
gboolean milter_server_context_get_skip_body (MilterServerContext *context);
Gets whether context received skip response on sending
body chunks.
|
a MilterServerContext.
|
Returns : |
TRUE if body chunks are skipped, FALSE
otherwise.
|
const gchar* milter_server_context_get_name (MilterServerContext *context);
Gets the name of context.
|
a MilterServerContext.
|
Returns : |
the name of context.
|
void milter_server_context_set_name (MilterServerContext *context, const gchar *name);
Sets the name of context.
|
a MilterServerContext.
|
|
the name. |