aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-zbee-nwk-gp.c
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2016-10-23 18:51:09 +0200
committerPascal Quantin <pascal.quantin@gmail.com>2016-10-23 20:24:36 +0000
commita3a20531b1a7ae2bb8b48ca25fbe27f10e2462a9 (patch)
tree9a23bc2a0a87bba8a0652f0b07dcf80af6fa67a6 /epan/dissectors/packet-zbee-nwk-gp.c
parent3c3f592ebc9e84a7c77bb50bf45ae7222dcd8a4c (diff)
ZigBee Green Power: fix loading of keys during runtime
Register a post update calback to ensure that the keys are loaded for all entries and not only the ones last edited Bug: 13031 Change-Id: Ib670f9e1c702546631df5fe6094b02484806dd00 Reviewed-on: https://code.wireshark.org/review/18416 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-zbee-nwk-gp.c')
-rw-r--r--epan/dissectors/packet-zbee-nwk-gp.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/epan/dissectors/packet-zbee-nwk-gp.c b/epan/dissectors/packet-zbee-nwk-gp.c
index f7069469f1..64f73dfe7b 100644
--- a/epan/dissectors/packet-zbee-nwk-gp.c
+++ b/epan/dissectors/packet-zbee-nwk-gp.c
@@ -335,6 +335,10 @@ typedef struct {
guint8 key[ZBEE_SEC_CONST_KEYSIZE];
} uat_key_record_t;
+static const guint8 empty_key[ZBEE_SEC_CONST_KEYSIZE] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
static uat_key_record_t *gp_uat_key_records = NULL;
static uat_t *zbee_gp_sec_key_table_uat;
@@ -657,6 +661,18 @@ uat_key_record_update_cb(void *r, char **err)
return TRUE;
}
+static void uat_key_record_post_update_cb(void) {
+ guint i;
+
+ for (i = 0; i < num_uat_key_records; i++) {
+ if (memcmp(gp_uat_key_records[i].key, empty_key, ZBEE_SEC_CONST_KEYSIZE) == 0) {
+ /* key was not loaded from string yet */
+ zbee_gp_security_parse_key(gp_uat_key_records[i].string, gp_uat_key_records[i].key,
+ gp_uat_key_records[i].byte_order);
+ }
+ }
+}
+
/**
*Dissector for ZigBee Green Power commissioning.
*
@@ -1483,7 +1499,7 @@ gp_init_zbee_security(void)
for (i = 0; gp_uat_key_records && (i < num_uat_key_records); i++) {
key_record.frame_num = 0;
key_record.label = g_strdup(gp_uat_key_records[i].label);
- memcpy(&key_record.key, &gp_uat_key_records[i].key, ZBEE_SEC_CONST_KEYSIZE);
+ memcpy(key_record.key, gp_uat_key_records[i].key, ZBEE_SEC_CONST_KEYSIZE);
zbee_gp_keyring = g_slist_prepend(zbee_gp_keyring, g_memdup(&key_record, sizeof(key_record_t)));
}
}
@@ -1841,7 +1857,7 @@ proto_register_zbee_nwk_gp(void)
zbee_gp_sec_key_table_uat = uat_new("ZigBee GP Security Keys", sizeof(uat_key_record_t), "zigbee_gp_keys", TRUE,
&gp_uat_key_records, &num_uat_key_records, UAT_AFFECTS_DISSECTION, NULL, uat_key_record_copy_cb,
- uat_key_record_update_cb, uat_key_record_free_cb, NULL, key_uat_fields);
+ uat_key_record_update_cb, uat_key_record_free_cb, uat_key_record_post_update_cb, key_uat_fields);
prefs_register_uat_preference(gp_zbee_prefs, "gp_key_table", "Pre-configured GP Security Keys",
"Pre-configured GP Security Keys.", zbee_gp_sec_key_table_uat);