[asterisk-commits] branch oej/videosupport r15146 - in
/team/oej/videosupport: ./ channels/ conf...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Sun Mar 26 20:14:17 MST 2006
Author: oej
Date: Sun Mar 26 21:14:16 2006
New Revision: 15146
URL: http://svn.digium.com/view/asterisk?rev=15146&view=rev
Log:
Resolve, restart, go!
Modified:
team/oej/videosupport/ (props changed)
team/oej/videosupport/channels/chan_sip.c
team/oej/videosupport/configs/sip.conf.sample
Propchange: team/oej/videosupport/
------------------------------------------------------------------------------
automerge = http://edvina.net/training/
Propchange: team/oej/videosupport/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sun Mar 26 21:14:16 2006
@@ -1,1 +1,1 @@
-/trunk:1-15099
+/trunk:1-15145
Modified: team/oej/videosupport/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/videosupport/channels/chan_sip.c?rev=15146&r1=15145&r2=15146&view=diff
==============================================================================
--- team/oej/videosupport/channels/chan_sip.c (original)
+++ team/oej/videosupport/channels/chan_sip.c Sun Mar 26 21:14:16 2006
@@ -405,6 +405,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; /*!< IP Type of service */
static int compactheaders; /*!< send compact sip headers */
@@ -609,9 +611,12 @@
#define SIP_PAGE2_DYNAMIC (1 << 7) /*!< Dynamic Peers register with Asterisk */
#define SIP_PAGE2_SELFDESTRUCT (1 << 8) /*!< Automatic peers need to destruct themselves */
#define SIP_PAGE2_VIDEOSUPPORT (1 << 9)
+#define SIP_PAGE2_ALLOWSUBSCRIBE (1 << 10) /*!< Allow subscriptions from this peer? */
+#define SIP_PAGE2_ALLOWOVERLAP (1 << 11) /*!< Allow overlap dialing ? */
+
#define SIP_PAGE2_FLAGS_TO_COPY \
- (SIP_PAGE2_VIDEOSUPPORT)
+ (SIP_PAGE2_ALLOWSUBSCRIBE | SIP_PAGE2_ALLOWOVERLAP | SIP_PAGE2_VIDEOSUPPORT)
/* SIP packet flags */
#define SIP_PKT_DEBUG (1 << 0) /*!< Debug this packet */
@@ -672,7 +677,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) */
@@ -7180,6 +7185,7 @@
/* Find user based on user name in the from header */
if (user && ast_apply_ha(user->ha, sin)) {
ast_copy_flags(p, user, SIP_FLAGS_TO_COPY);
+ ast_copy_flags(p, &user->flags_page2, SIP_PAGE2_FLAGS_TO_COPY);
/* copy channel vars */
for (v = user->chanvars ; v ; v = v->next) {
if ((tmpvar = ast_variable_new(v->name, v->value))) {
@@ -8157,6 +8163,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)));
@@ -8386,6 +8394,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");
@@ -10439,8 +10449,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
@@ -10573,11 +10581,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);
@@ -10721,10 +10729,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) {
@@ -10891,6 +10902,17 @@
ast_log(LOG_DEBUG, "Got a re-subscribe on existing subscription %s\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) {
/* Use this as the basis */
if (debug)
@@ -10931,6 +10953,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);
@@ -10940,10 +10970,7 @@
gotdest = get_destination(p, NULL);
build_contact(p);
if (gotdest) {
- if (gotdest < 0)
- transmit_response(p, "404 Not Found", 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);
} else {
@@ -12082,6 +12109,7 @@
oldha = user->ha;
user->ha = NULL;
ast_copy_flags(user, &global_flags, SIP_FLAGS_TO_COPY);
+ ast_copy_flags(user, &global_flags_page2, SIP_PAGE2_FLAGS_TO_COPY);
user->capability = global_capability;
user->prefs = default_prefs;
/* set default context */
@@ -12125,6 +12153,17 @@
ast_copy_string(user->musicclass, v->value, sizeof(user->musicclass));
} 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)
@@ -12175,6 +12214,7 @@
}
ast_copy_flags((&peer->flags_page2), &global_flags_page2, SIP_PAGE2_FLAGS_TO_COPY);
ast_copy_flags(peer, &global_flags, SIP_FLAGS_TO_COPY);
+ ast_copy_flags(&peer->flags_page2, &global_flags_page2, SIP_PAGE2_FLAGS_TO_COPY);
strcpy(peer->context, default_context);
strcpy(peer->subscribecontext, default_subscribecontext);
strcpy(peer->language, default_language);
@@ -12299,6 +12339,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"))
@@ -12517,6 +12568,7 @@
global_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));
@@ -12532,6 +12584,10 @@
global_rtpholdtimeout = 0;
global_rtpkeepalive = 0;
global_rtautoclear = 120;
+ 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 */
@@ -12707,6 +12763,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/videosupport/configs/sip.conf.sample
URL: http://svn.digium.com/view/asterisk/team/oej/videosupport/configs/sip.conf.sample?rev=15146&r1=15145&r2=15146&view=diff
==============================================================================
--- team/oej/videosupport/configs/sip.conf.sample (original)
+++ team/oej/videosupport/configs/sip.conf.sample Sun Mar 26 21:14:16 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
@@ -314,6 +316,8 @@
; amaflags amaflags
; call-limit call-limit
; restrictcid restrictcid
+; allowoverlap allowoverlap
+; allowsubscribe allowsubscribe
; subscribecontext subscribecontext
; videosupport videosupport
; maxcallbitrate maxcallbitrate
More information about the asterisk-commits
mailing list