forked from osmocom/wireshark
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>
This commit is contained in:
parent
3c3f592ebc
commit
a3a20531b1
|
@ -335,6 +335,10 @@ typedef struct {
|
||||||
guint8 key[ZBEE_SEC_CONST_KEYSIZE];
|
guint8 key[ZBEE_SEC_CONST_KEYSIZE];
|
||||||
} uat_key_record_t;
|
} 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_key_record_t *gp_uat_key_records = NULL;
|
||||||
static uat_t *zbee_gp_sec_key_table_uat;
|
static uat_t *zbee_gp_sec_key_table_uat;
|
||||||
|
|
||||||
|
@ -657,6 +661,18 @@ uat_key_record_update_cb(void *r, char **err)
|
||||||
return TRUE;
|
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.
|
*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++) {
|
for (i = 0; gp_uat_key_records && (i < num_uat_key_records); i++) {
|
||||||
key_record.frame_num = 0;
|
key_record.frame_num = 0;
|
||||||
key_record.label = g_strdup(gp_uat_key_records[i].label);
|
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)));
|
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,
|
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,
|
&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",
|
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);
|
"Pre-configured GP Security Keys.", zbee_gp_sec_key_table_uat);
|
||||||
|
|
Loading…
Reference in New Issue