[asterisk-commits] branch oej/test-this-branch r12650 - in
/team/oej/test-this-branch: ./ channe...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Sun Mar 12 12:45:39 MST 2006
Author: oej
Date: Sun Mar 12 13:45:35 2006
New Revision: 12650
URL: http://svn.digium.com/view/asterisk?rev=12650&view=rev
Log:
Adding #6705 - disable-ol-and-sub: Settings for disabling SIP subscriptions and
overlap dialing
Modified:
team/oej/test-this-branch/README.test-this-branch
team/oej/test-this-branch/channels/chan_sip.c
team/oej/test-this-branch/configs/sip.conf.sample
Modified: team/oej/test-this-branch/README.test-this-branch
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/README.test-this-branch?rev=12650&r1=12649&r2=12650&view=diff
==============================================================================
--- team/oej/test-this-branch/README.test-this-branch (original)
+++ team/oej/test-this-branch/README.test-this-branch Sun Mar 12 13:45:35 2006
@@ -32,6 +32,8 @@
- func_realtime: Realtime dialplan function (bweschke, #5695)
- metermaids: Subscription support for parking lots (#5779)
- filenamelen: Some code changes for file name lengths (oej)
+- disable-ol-and-sub: Settings for disabling sip subscriptions and overlap
+ dialing (#6705, oej)
And the following stand-alone patches
- Additional options for the CHANNEL dialplan function (oej, #6670)
@@ -53,7 +55,7 @@
Coming here soon:
-- siptransfer: Improved SIP transfer support
+- siptransfer: Improved SIP transfer support (branch)
All of these exist in the bug tracker. Please report your findings
in each open issue report, so that we get the feedback for each
Modified: team/oej/test-this-branch/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/channels/chan_sip.c?rev=12650&r1=12649&r2=12650&view=diff
==============================================================================
--- team/oej/test-this-branch/channels/chan_sip.c (original)
+++ team/oej/test-this-branch/channels/chan_sip.c Sun Mar 12 13:45:35 2006
@@ -428,6 +428,8 @@
static int global_reg_timeout;
static int global_regattempts_max; /*!< Registration attempts before giving up */
static int global_allowguest; /*!< allow unauthenticated users/peers to connect? */
+static int global_allowsubscribe; /*!< Flag for disabling ALL subscriptions, this is FALSE only if all peers are FALSE
+ the global setting is in globals_flag_page2 */
static int global_mwitime; /*!< Time between MWI checks for peers */
static int global_tos_sip; /*!< IP Type of service for SIP */
static int global_tos_audio; /*!< IP Type of service for RTP audio */
@@ -623,7 +625,7 @@
SIP_PROG_INBAND | SIP_OSPAUTH | SIP_USECLIENTCODE | SIP_NAT | \
SIP_INSECURE_PORT | SIP_INSECURE_INVITE)
-/* a new page of flags for peers */
+/* a new page of flags */
#define SIP_PAGE2_RTCACHEFRIENDS (1 << 0)
#define SIP_PAGE2_RTUPDATE (1 << 1)
#define SIP_PAGE2_RTAUTOCLEAR (1 << 2)
@@ -637,9 +639,11 @@
#define SIP_PAGE2_SUBSCRIBEMWIONLY (1 << 9) /*!< Only support subscription-related MWI notification */
#define SIP_PAGE2_VIDEOSUPPORT (1 << 10) /*!< Support video for this peer */
#define SIP_PAGE2_PEER_REGISTER (1 << 11) /*!< Register this peer with service */
+#define SIP_PAGE2_ALLOWOVERLAP (1 << 12) /*!< Allow overlap dialing */
+#define SIP_PAGE2_ALLOWSUBSCRIBE (1 << 13) /*!< Allow SUBSCRIBE */
#define SIP_PAGE2_FLAGS_TO_COPY \
- (SIP_PAGE2_VIDEOSUPPORT)
+ (SIP_PAGE2_VIDEOSUPPORT | SIP_PAGE2_ALLOWOVERLAP | SIP_PAGE2_ALLOWSUBSCRIBE)
/* SIP packet flags */
#define SIP_PKT_DEBUG (1 << 0) /*!< Debug this packet */
@@ -703,7 +707,7 @@
ast_group_t pickupgroup; /*!< Pickup group */
int lastinvite; /*!< Last Cseq of invite */
unsigned int flags; /*!< SIP_ flags */
- struct ast_flags flags_page2; /*!< SIP_PAGE2 flags */
+ struct ast_flags flags_page2; /*!< SIP_PAGE2 flags */
int timer_t1; /*!< SIP timer T1, ms rtt */
unsigned int sipoptions; /*!< Supported SIP sipoptions on the other end */
int capability; /*!< Special capability (codec) */
@@ -7372,6 +7376,7 @@
/* Ok, we have a device, let's check authentication if needed */
ast_copy_flags(p, device, SIP_FLAGS_TO_COPY);
+ ast_copy_flags(p, &device->flags_page2, SIP_PAGE2_FLAGS_TO_COPY);
/* Copy SIP extensions profile to peer */
if (p->sipoptions)
@@ -8234,6 +8239,8 @@
ast_cli(fd, " Video Support: %s\n", (ast_test_flag((&peer->flags_page2), SIP_PAGE2_VIDEOSUPPORT)?"Yes":"No"));
ast_cli(fd, " Trust RPID : %s\n", (ast_test_flag(peer, SIP_TRUSTRPID) ? "Yes" : "No"));
ast_cli(fd, " Send RPID : %s\n", (ast_test_flag(peer, SIP_SENDRPID) ? "Yes" : "No"));
+ ast_cli(fd, " Subscriptions: %s\n", ast_test_flag(&peer->flags_page2, SIP_PAGE2_ALLOWSUBSCRIBE) ? "Yes" : "No");
+ ast_cli(fd, " Overlap dial : %s\n", ast_test_flag(&peer->flags_page2, SIP_PAGE2_ALLOWOVERLAP) ? "Yes" : "No");
/* - is enumerated */
ast_cli(fd, " DTMFmode : %s\n", dtmfmode2str(ast_test_flag(peer, SIP_DTMF)));
@@ -8459,6 +8466,8 @@
ast_cli(fd, " Videosupport: %s\n", ast_test_flag((&global_flags_page2), SIP_PAGE2_VIDEOSUPPORT) ? "Yes" : "No");
ast_cli(fd, " AutoCreatePeer: %s\n", autocreatepeer ? "Yes" : "No");
ast_cli(fd, " Allow unknown access: %s\n", global_allowguest ? "Yes" : "No");
+ ast_cli(fd, " Allow subscriptions: %s\n", ast_test_flag(&global_flags_page2, SIP_PAGE2_ALLOWSUBSCRIBE) ? "Yes" : "No");
+ ast_cli(fd, " Allow overlap dialing: %s\n", ast_test_flag(&global_flags_page2, SIP_PAGE2_ALLOWOVERLAP) ? "Yes" : "No");
ast_cli(fd, " Promsic. redir: %s\n", ast_test_flag(&global_flags, SIP_PROMISCREDIR) ? "Yes" : "No");
ast_cli(fd, " SIP domain support: %s\n", AST_LIST_EMPTY(&domain_list) ? "No" : "Yes");
ast_cli(fd, " Call to non-local dom.: %s\n", allow_external_domains ? "Yes" : "No");
@@ -10519,8 +10528,6 @@
ast_string_field_set(p, context, default_context);
if (res < 0)
transmit_response_with_allow(p, "404 Not Found", req, 0);
- else if (res > 0)
- transmit_response_with_allow(p, "484 Address Incomplete", req, 0);
else
transmit_response_with_allow(p, "200 OK", req, 0);
/* Destroy if this OPTIONS was the opening request, but not if
@@ -10653,11 +10660,11 @@
build_contact(p); /* Build our contact header */
if (gotdest) {
- if (gotdest < 0) {
- transmit_response_reliable(p, "404 Not Found", req);
+ if (gotdest == 1 && ast_test_flag(&p->flags_page2, SIP_PAGE2_ALLOWOVERLAP)) {
+ transmit_response_reliable(p, "484 Address Incomplete", req);
update_call_counter(p, DEC_CALL_LIMIT);
} else {
- transmit_response_reliable(p, "484 Address Incomplete", req);
+ transmit_response_reliable(p, "404 Not Found", req);
update_call_counter(p, DEC_CALL_LIMIT);
}
ast_set_flag(p, SIP_NEEDDESTROY);
@@ -10801,10 +10808,13 @@
if (ast_strlen_zero(p->context))
ast_string_field_set(p, context, default_context);
res = get_refer_info(p, req);
- if (res < 0)
+ if (res > 0) {
+ if (ast_test_flag(&p->flags_page2, SIP_PAGE2_ALLOWOVERLAP))
+ transmit_response_with_allow(p, "484 Address Incomplete", req, 1);
+ else
+ transmit_response_with_allow(p, "404 Not Found", req, 1);
+ } else if (res < 0)
transmit_response_with_allow(p, "404 Not Found", req, 1);
- else if (res > 0)
- transmit_response_with_allow(p, "484 Address Incomplete", req, 1);
else {
int nobye = 0;
if (!ignore) {
@@ -10976,6 +10986,16 @@
ast_log(LOG_DEBUG, "Got a new subscription %s (possibly with auth)\n", p->callid);
}
}
+
+ /* Check if we have a global disallow setting on subscriptions.
+ if so, we don't have to check peer/user settings after auth, which saves a lot of processing
+ */
+ if (!global_allowsubscribe) {
+ transmit_response(p, "403 Forbidden (policy)", req);
+ ast_set_flag(p, SIP_NEEDDESTROY);
+ return 0;
+ }
+
if (!ignore && !p->initreq.headers) { /* Set up dialog, new subscription */
/* Use this as the basis */
if (debug)
@@ -10999,6 +11019,14 @@
}
return 0;
}
+
+ /* Check if this user/peer is allowed to subscribe at all */
+ if (! ast_test_flag(&p->flags_page2, SIP_PAGE2_ALLOWSUBSCRIBE)) {
+ transmit_response(p, "403 Forbidden (policy)", req);
+ ast_set_flag(p, SIP_NEEDDESTROY);
+ return 0;
+ }
+
/* Initialize the context if it hasn't been already */
if (!ast_strlen_zero(p->subscribecontext))
ast_string_field_set(p, context, p->subscribecontext);
@@ -11009,10 +11037,7 @@
gotdest = get_destination(p, NULL);
build_contact(p);
if (gotdest) {
- if (gotdest < 0)
- transmit_response(p, "404 Not Found (gotdest)", req);
- else
- transmit_response(p, "484 Address Incomplete", req); /* Overlap dialing on SUBSCRIBE?? */
+ transmit_response(p, "404 Not Found", req);
ast_set_flag(p, SIP_NEEDDESTROY);
return 0;
} else {
@@ -12269,6 +12294,17 @@
ast_copy_string(user->parkinglot, v->value, sizeof(user->parkinglot));
} else if (!strcasecmp(v->name, "accountcode")) {
ast_copy_string(user->accountcode, v->value, sizeof(user->accountcode));
+ } else if (!strcasecmp(v->name, "allowsubscribe")) {
+ if (ast_true(v->value)) {
+ global_allowsubscribe = TRUE; /* No global ban any more */
+ ast_set_flag(&user->flags_page2, SIP_PAGE2_ALLOWSUBSCRIBE);
+ } else
+ ast_clear_flag(&user->flags_page2, SIP_PAGE2_ALLOWSUBSCRIBE);
+ } else if (!strcasecmp(v->name, "allowoverlap")) {
+ if (ast_true(v->value)) {
+ ast_set_flag(&user->flags_page2, SIP_PAGE2_ALLOWOVERLAP);
+ } else
+ ast_clear_flag(&user->flags_page2, SIP_PAGE2_ALLOWOVERLAP);
} else if (!strcasecmp(v->name, "call-limit")) {
user->call_limit = atoi(v->value);
if (user->call_limit < 0)
@@ -12406,6 +12442,17 @@
ast_copy_string(peer->context, v->value, sizeof(peer->context));
} else if (!strcasecmp(v->name, "subscribecontext")) {
ast_copy_string(peer->subscribecontext, v->value, sizeof(peer->subscribecontext));
+ } else if (!strcasecmp(v->name, "allowsubscribe")) {
+ if (ast_true(v->value)) {
+ global_allowsubscribe = TRUE; /* No global ban any more */
+ ast_set_flag(&peer->flags_page2, SIP_PAGE2_ALLOWSUBSCRIBE);
+ } else
+ ast_clear_flag(&peer->flags_page2, SIP_PAGE2_ALLOWSUBSCRIBE);
+ } else if (!strcasecmp(v->name, "allowoverlap")) {
+ if (ast_true(v->value)) {
+ ast_set_flag(&peer->flags_page2, SIP_PAGE2_ALLOWOVERLAP);
+ } else
+ ast_clear_flag(&peer->flags_page2, SIP_PAGE2_ALLOWOVERLAP);
} else if (!strcasecmp(v->name, "fromdomain"))
ast_copy_string(peer->fromdomain, v->value, sizeof(peer->fromdomain));
else if (!strcasecmp(v->name, "usereqphone"))
@@ -12640,6 +12687,7 @@
regcontext[0] = '\0';
expiry = DEFAULT_EXPIRY;
global_notifyringing = DEFAULT_NOTIFYRINGING;
+ global_allowsubscribe = TRUE;
ast_copy_string(global_useragent, DEFAULT_USERAGENT, sizeof(global_useragent));
ast_copy_string(default_notifymime, DEFAULT_NOTIFYMIME, sizeof(default_notifymime));
ast_copy_string(global_realm, DEFAULT_REALM, sizeof(global_realm));
@@ -12655,6 +12703,10 @@
global_rtptimeout = 0;
global_rtpholdtimeout = 0;
global_rtpkeepalive = 0;
+ global_allowsubscribe = TRUE; /* Global flag, default = TRUE */
+ ast_set_flag(&global_flags_page2, SIP_PAGE2_ALLOWSUBSCRIBE); /* Default for peers, users: TRUE */
+ ast_set_flag(&global_flags_page2, SIP_PAGE2_ALLOWOVERLAP); /* Default for peers, users: TRUE */
+
ast_set_flag(&global_flags_page2, SIP_PAGE2_RTUPDATE);
/* Initialize some reasonable defaults at SIP reload (used both for channel and as default for peers and users */
@@ -12844,6 +12896,24 @@
ast_parse_allow_disallow(&default_prefs, &global_capability, v->value, 1);
} else if (!strcasecmp(v->name, "disallow")) {
ast_parse_allow_disallow(&default_prefs, &global_capability, v->value, 0);
+ } else if (!strcasecmp(v->name, "allowsubscribe")) {
+ if (ast_true(v->value)) {
+ ast_log(LOG_DEBUG, "Turning on global subscription support!\n");
+ global_allowsubscribe = TRUE;
+ ast_set_flag(&global_flags_page2, SIP_PAGE2_ALLOWSUBSCRIBE);
+ } else {
+ global_allowsubscribe = FALSE;
+ ast_log(LOG_DEBUG, "Turning off global subscription support!\n");
+ ast_clear_flag(&global_flags_page2, SIP_PAGE2_ALLOWSUBSCRIBE);
+ }
+ } else if (!strcasecmp(v->name, "allowoverlap")) {
+ if (ast_true(v->value)) {
+ ast_log(LOG_DEBUG, "Turning on global overlap support!\n");
+ ast_set_flag(&global_flags_page2, SIP_PAGE2_ALLOWOVERLAP);
+ } else {
+ ast_log(LOG_DEBUG, "Turning off global overlap support!\n");
+ ast_clear_flag(&global_flags_page2, SIP_PAGE2_ALLOWOVERLAP);
+ }
} else if (!strcasecmp(v->name, "allowexternaldomains")) {
allow_external_domains = ast_true(v->value);
} else if (!strcasecmp(v->name, "autodomain")) {
Modified: team/oej/test-this-branch/configs/sip.conf.sample
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/configs/sip.conf.sample?rev=12650&r1=12649&r2=12650&view=diff
==============================================================================
--- team/oej/test-this-branch/configs/sip.conf.sample (original)
+++ team/oej/test-this-branch/configs/sip.conf.sample Sun Mar 12 13:45:35 2006
@@ -26,7 +26,9 @@
[general]
context=default ; Default context for incoming calls
;allowguest=no ; Allow or reject guest calls (default is yes, this can also be set to 'osp'
- ; if asterisk was compiled with OSP support.
+ ; if asterisk was compiled with OSP support.)
+;allowoverlap=no ; Disable overlap dialing support. Default is yes
+;allowsubscribe=no ; Disable support for subscriptions. Default is yes
;realm=mydomain.tld ; Realm for digest authentication
; defaults to "asterisk"
; Realms MUST be globally unique according to RFC 3261
@@ -343,6 +345,8 @@
; call-limit call-limit
; restrictcid restrictcid
; subscribecontext subscribecontext
+; allowsubscribe allowsubscribe
+; allowoverlap allowoverlap
; videosupport videosupport
; maxcallbitrate maxcallbitrate
; mailbox
More information about the asterisk-commits
mailing list