Protobuf: Support leading dot for the message/enum type of field
The message/enum type of field is allowed to start with '.' (for example, .foo.bar.Baz), that means to search the message/enum to start from the outermost scope instead. Please refer to: https://developers.google.com/protocol-buffers/docs/proto3#packages-and-name-resolution Please find example capture file from Bug: 16118 Ping-Bug: 16118 Change-Id: I78702d0b2316b4071f04aba9fc7d185e382e4cbf Reviewed-on: https://code.wireshark.org/review/34752 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
62101950f3
commit
26354037a3
|
@ -160,6 +160,10 @@ pbl_find_node_in_pool(const pbl_descriptor_pool_t* pool, const char* full_name,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (full_name[0] == '.') {
|
||||
full_name++; /* skip leading dot */
|
||||
}
|
||||
|
||||
full_name_buf = g_strdup(full_name);
|
||||
len = (int)strlen(full_name_buf);
|
||||
/* scan from end to begin, and replace '.' to '\0' */
|
||||
|
@ -246,6 +250,15 @@ pbl_find_node_in_context(const pbl_node_t* context, const char* name, pbl_node_t
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (name[0] == '.') {
|
||||
/* A leading '.' (for example, .foo.bar.Baz) means to start from the outermost scope. */
|
||||
if (context->file && context->file->pool) {
|
||||
return pbl_find_node_in_pool(context->file->pool, name, nodetype);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* try find node in context first */
|
||||
if (context->children_by_name) {
|
||||
node = (pbl_node_t*) g_hash_table_lookup(context->children_by_name, name);
|
||||
|
@ -262,7 +275,7 @@ pbl_find_node_in_context(const pbl_node_t* context, const char* name, pbl_node_t
|
|||
}
|
||||
}
|
||||
/* find pool */
|
||||
if (context && context->file) {
|
||||
if (context->file) {
|
||||
pool = context->file->pool;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue