Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 382809) +++ channels/chan_sip.c (working copy) @@ -797,6 +797,7 @@ static unsigned int global_cos_text; /*!< 802.1p class of service for text RTP packets */ static unsigned int recordhistory; /*!< Record SIP history. Off by default */ static unsigned int dumphistory; /*!< Dump history to verbose before destroying SIP dialog */ +static unsigned int optionsenable; /*!< Enable OPTIONS 200 OK response */ static char global_useragent[AST_MAX_EXTENSION]; /*!< Useragent for the SIP channel */ static char global_sdpsession[AST_MAX_EXTENSION]; /*!< SDP session name for the SIP channel */ static char global_sdpowner[AST_MAX_EXTENSION]; /*!< SDP owner name for the SIP channel */ @@ -1323,6 +1324,7 @@ static char *sip_do_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static char *sip_cli_notify(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static char *sip_set_history(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); +static char *sip_set_options(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a); static int sip_dtmfmode(struct ast_channel *chan, const char *data); static int sip_addheader(struct ast_channel *chan, const char *data); static int sip_do_reload(enum channelreloadreason reason); @@ -20770,6 +20772,7 @@ ast_cli(a->fd, " From: Domain: %s\n", default_fromdomain); } ast_cli(a->fd, " Record SIP history: %s\n", AST_CLI_ONOFF(recordhistory)); + ast_cli(a->fd, " Enable SIP OPTIONS: %s\n", AST_CLI_ONOFF(optionsenable)); ast_cli(a->fd, " Call Events: %s\n", AST_CLI_ONOFF(sip_cfg.callevents)); ast_cli(a->fd, " Auth. Failure Events: %s\n", AST_CLI_ONOFF(global_authfailureevents)); @@ -21827,6 +21830,35 @@ return CLI_SUCCESS; } +/*! \brief Enable/Disable SIP OPTIONS response (CLI) */ +static char *sip_set_options(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +{ + switch (cmd) { + case CLI_INIT: + e->command = "sip set options {on|off}"; + e->usage = + "Usage: sip set options {on|off}\n" + " Enables/Disables 200 OK response to SIP OPTIONS ping.\n"; + return NULL; + case CLI_GENERATE: + return NULL; + } + + if (a->argc != e->args) + return CLI_SHOWUSAGE; + + if (!strncasecmp(a->argv[e->args - 1], "on", 2)) { + optionsenable = TRUE; + ast_cli(a->fd, "SIP Options Response Enabled)\n"); + } else if (!strncasecmp(a->argv[e->args - 1], "off", 3)) { + optionsenable = FALSE; + ast_cli(a->fd, "SIP Options Response Disabled\n"); + } else { + return CLI_SHOWUSAGE; + } + return CLI_SUCCESS; +} + /*! \brief Authenticate for outbound registration */ static int do_register_auth(struct sip_pvt *p, struct sip_request *req, enum sip_auth_type code) { @@ -24864,7 +24896,7 @@ if (ast_strlen_zero(p->context)) ast_string_field_set(p, context, sip_cfg.default_context); - if (ast_shutting_down()) { + if (ast_shutting_down() || !optionsenable) { msg = "503 Unavailable"; } else { msg = "404 Not Found"; @@ -31598,6 +31630,7 @@ /* Debugging settings, always default to off */ dumphistory = FALSE; recordhistory = FALSE; + optionsenable = TRUE; sipdebug &= ~sip_debug_config; /* Misc settings for the channel */ @@ -33538,6 +33571,7 @@ AST_CLI_DEFINE(sip_prune_realtime, "Prune cached Realtime users/peers"), AST_CLI_DEFINE(sip_do_debug, "Enable/Disable SIP debugging"), AST_CLI_DEFINE(sip_set_history, "Enable/Disable SIP history"), + AST_CLI_DEFINE(sip_set_options, "Enable/Disable SIP OPTIONS"), AST_CLI_DEFINE(sip_reload, "Reload SIP configuration"), AST_CLI_DEFINE(sip_show_tcp, "List TCP Connections") };