summaryrefslogtreecommitdiff
path: root/main/event.c
diff options
context:
space:
mode:
authorKinsey Moore <kmoore@digium.com>2012-03-02 21:06:12 +0000
committerKinsey Moore <kmoore@digium.com>2012-03-02 21:06:12 +0000
commit8d1bde49a9255ddf5738aa453cb1daf83e7566bb (patch)
treecad2e4977b3fabd2356d7b69e2ec6ee73e46e34f /main/event.c
parent9926662aba1ed9410461cb5eb127a72477ae7fcd (diff)
Fix case-sensitivity for device-specific event subscriptions and CCSS
This change fixes case-sensitivity for device-specific subscriptions such that the technology identifier is case-insensitive while the remainder of the device string is still case-sensitive. This should also preserve the original case of the device string as passed in to the event system. CCSS is the only feature affected as it is the only consumer of device-specific event subscriptions. The second part of this patch addresses similar case-sensitivity issues within CCSS itself that prevented it from functioning correctly after the fix to the events system. This adds a unit test to verify that the event system works as expected. (closes issue ASTERISK-19422) Review: https://reviewboard.asterisk.org/r/1780/ ........ Merged revisions 357940 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 357941 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@357942 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/event.c')
-rw-r--r--main/event.c41
1 files changed, 36 insertions, 5 deletions
diff --git a/main/event.c b/main/event.c
index fc1d668e6..eb1924b06 100644
--- a/main/event.c
+++ b/main/event.c
@@ -415,8 +415,16 @@ static int match_sub_ie_val_to_event(const struct ast_event_ie_val *sub_ie_val,
res = (sub_ie_val->payload.uint & event_ie_val->payload.uint);
break;
case AST_EVENT_IE_PLTYPE_STR:
- res = !strcmp(sub_ie_val->payload.str, event_ie_val->payload.str);
+ {
+ const char *substr = sub_ie_val->payload.str;
+ const char *estr = event_ie_val->payload.str;
+ if (sub_ie_val->ie_type == AST_EVENT_IE_DEVICE) {
+ substr = ast_tech_to_upper(ast_strdupa(substr));
+ estr = ast_tech_to_upper(ast_strdupa(estr));
+ }
+ res = !strcmp(substr, estr);
break;
+ }
case AST_EVENT_IE_PLTYPE_RAW:
res = (sub_ie_val->raw_datalen == event_ie_val->raw_datalen
&& !memcmp(sub_ie_val->payload.raw, event_ie_val->payload.raw,
@@ -580,8 +588,19 @@ static int match_ie_val(const struct ast_event *event,
}
str = event2 ? ast_event_get_ie_str(event2, ie_val->ie_type) : ie_val->payload.str;
- if (str && !strcmp(str, ast_event_get_ie_str(event, ie_val->ie_type))) {
- return 1;
+ if (str) {
+ const char *e1str, *e2str;
+ e1str = ast_event_get_ie_str(event, ie_val->ie_type);
+ e2str = str;
+
+ if (ie_val->ie_type == AST_EVENT_IE_DEVICE) {
+ e1str = ast_tech_to_upper(ast_strdupa(e1str));
+ e2str = ast_tech_to_upper(ast_strdupa(e2str));
+ }
+
+ if (!strcmp(e1str, e2str)) {
+ return 1;
+ }
}
return 0;
@@ -824,7 +843,13 @@ int ast_event_sub_append_ie_str(struct ast_event_sub *sub,
return -1;
}
- ie_val->payload.hash = ast_str_hash(str);
+ if (ie_type == AST_EVENT_IE_DEVICE) {
+ char *uppertech = ast_strdupa(str);
+ ast_tech_to_upper(uppertech);
+ ie_val->payload.hash = ast_str_hash(uppertech);
+ } else {
+ ie_val->payload.hash = ast_str_hash(str);
+ }
AST_LIST_INSERT_TAIL(&sub->ie_vals, ie_val, entry);
@@ -1120,7 +1145,13 @@ int ast_event_append_ie_str(struct ast_event **event, enum ast_event_ie_type ie_
str_payload = alloca(payload_len);
strcpy(str_payload->str, str);
- str_payload->hash = ast_str_hash(str);
+ if (ie_type == AST_EVENT_IE_DEVICE) {
+ char *uppertech = ast_strdupa(str);
+ ast_tech_to_upper(uppertech);
+ str_payload->hash = ast_str_hash(uppertech);
+ } else {
+ str_payload->hash = ast_str_hash(str);
+ }
return ast_event_append_ie_raw(event, ie_type, str_payload, payload_len);
}