Пример #1
0
/**
 * @brief	Enqueue a protocol-specific handler to service a specified connection, and update any statistics accordingly.
 * @note	If an invalid protocol is specified, the connection will be destroyed gracefully.
 * @param	con		a pointer to the connection object to be serviced.
 * @return	This function returns no value.
 */
void protocol_enqueue(connection_t *con) {

	void *function = NULL;

	// Pedantic sanity checks of the passed in data.
	log_check(con == NULL);
	log_check(con->server == NULL);

	switch (con->server->protocol) {

	case (POP):
		stats_increment_by_name("pop.connections.total");
		if (con_secure(con) == 1) stats_increment_by_name("pop.connections.secure");
		function = &pop_init;
		break;
	case (IMAP):
		stats_increment_by_name("imap.connections.total");
		if (con_secure(con) == 1) stats_increment_by_name("imap.connections.secure");
		function = &imap_init;
		break;
	case (HTTP):
		stats_increment_by_name("http.connections.total");
		if (con_secure(con) == 1) stats_increment_by_name("http.connections.secure");
		function = &http_init;
		break;
	case (SMTP):
		stats_increment_by_name("smtp.connections.total");
		if (con_secure(con) == 1) stats_increment_by_name("smtp.connections.secure");
		function = &smtp_init;
		break;
	case (SUBMISSION):
		stats_increment_by_name("smtp.connections.total");
		if (con_secure(con) == 1) stats_increment_by_name("smtp.connections.secure");
		function = &submission_init;
		break;
	case (MOLTEN):
		stats_increment_by_name("molten.connections.total");
		if (con_secure(con) == 1) stats_increment_by_name("molten.connections.secure");
		function = &molten_init;
		break;
	default:
		log_pedantic("Protocol enqueue was passed a connection using an unsupported or unknown protocol.");
		con_destroy(con);
		return;
	}

	enqueue(function, con);
	return;

}
Пример #2
0
/**
 * @brief	Gracefully destroy a POP3 session, whether because of an error or in response to a user QUIT command.
 * @param	con		the POP3 client connection to be shut down.
 * @brief	This function returns no value.
 */
void pop_quit(connection_t *con) {

	if (con_status(con) == 2) {
		con_write_bl(con, "-ERR Unexpected connection shutdown detected. Goodbye.\r\n", 56);
	}
	else if (con_status(con) >= 0) {
		con_write_bl(con, "+OK Goodbye.\r\n", 14);
	}
	else {
		con_write_bl(con, "-ERR Network connection failure.\r\n", 34);
	}

	con_destroy(con);

	return;
}
Пример #3
0
void molten_quit(connection_t *con) {

	con_destroy(con);
	return;
}