1 /* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
2
3 #include "lib.h"
4 #include "smtp-syntax.h"
5
6 #include "smtp-server-private.h"
7
8 /* NOOP command */
9
smtp_server_cmd_noop(struct smtp_server_cmd_ctx * cmd,const char * params)10 void smtp_server_cmd_noop(struct smtp_server_cmd_ctx *cmd,
11 const char *params)
12 {
13 struct smtp_server_connection *conn = cmd->conn;
14 struct smtp_server_command *command = cmd->cmd;
15 const struct smtp_server_callbacks *callbacks = conn->callbacks;
16 const char *param, *error;
17 int ret;
18
19 /* "NOOP" [ SP String ] CRLF */
20 ret = smtp_string_parse(params, ¶m, &error);
21 if (ret < 0) {
22 smtp_server_reply(cmd, 501, "5.5.4",
23 "Invalid string parameter: %s",
24 error);
25 return;
26 }
27
28 smtp_server_command_input_lock(cmd);
29
30 smtp_server_command_ref(command);
31 if (callbacks != NULL && callbacks->conn_cmd_noop != NULL) {
32 /* specific implementation of NOOP command */
33 ret = callbacks->conn_cmd_noop(conn->context, cmd);
34 if (ret <= 0) {
35 i_assert(ret == 0 ||
36 smtp_server_command_is_replied(command));
37 /* command is waiting for external event or it failed */
38 smtp_server_command_unref(&command);
39 return;
40 }
41 }
42 if (!smtp_server_command_is_replied(command))
43 smtp_server_cmd_noop_reply_success(cmd);
44 smtp_server_command_unref(&command);
45 }
46
smtp_server_cmd_noop_reply_success(struct smtp_server_cmd_ctx * cmd)47 void smtp_server_cmd_noop_reply_success(struct smtp_server_cmd_ctx *cmd)
48 {
49 i_assert(cmd->cmd->reg->func == smtp_server_cmd_noop);
50
51 smtp_server_reply(cmd, 250, "2.0.0", "OK");
52 }
53