rawshark: Get "field string values" from existing functionality.
rawshark shouldn't be converting FT_ and BASE_ values into strings on its own, there's a function for that. Change-Id: Ib4ce1651ee130a03644b5de3ab471333444e19a9 Reviewed-on: https://code.wireshark.org/review/15341 Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
parent
d09bf3157d
commit
82373315fd
|
@ -962,6 +962,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
|
||||||
proto_enable_heuristic_by_name@Base 1.99.8
|
proto_enable_heuristic_by_name@Base 1.99.8
|
||||||
proto_expert@Base 1.9.1
|
proto_expert@Base 1.9.1
|
||||||
proto_field_is_referenced@Base 1.9.1
|
proto_field_is_referenced@Base 1.9.1
|
||||||
|
proto_field_display_to_string@Base 2.1.0
|
||||||
proto_find_field_from_offset@Base 1.9.1
|
proto_find_field_from_offset@Base 1.9.1
|
||||||
proto_find_finfo@Base 1.9.1
|
proto_find_finfo@Base 1.9.1
|
||||||
proto_find_undecoded_data@Base 1.99.3
|
proto_find_undecoded_data@Base 1.99.3
|
||||||
|
|
|
@ -6376,6 +6376,11 @@ static const value_string hf_display[] = {
|
||||||
{ BASE_PT_SCTP, "BASE_PT_SCTP" },
|
{ BASE_PT_SCTP, "BASE_PT_SCTP" },
|
||||||
{ 0, NULL } };
|
{ 0, NULL } };
|
||||||
|
|
||||||
|
const char* proto_field_display_to_string(int field_display)
|
||||||
|
{
|
||||||
|
return val_to_str_const(field_display, hf_display, "Unknown");
|
||||||
|
}
|
||||||
|
|
||||||
static inline port_type
|
static inline port_type
|
||||||
display_to_port_type(field_display_e e)
|
display_to_port_type(field_display_e e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2366,6 +2366,10 @@ WS_DLL_PUBLIC void proto_registrar_dump_fields(void);
|
||||||
/** Dumps a glossary field types and descriptive names to STDOUT */
|
/** Dumps a glossary field types and descriptive names to STDOUT */
|
||||||
WS_DLL_PUBLIC void proto_registrar_dump_ftypes(void);
|
WS_DLL_PUBLIC void proto_registrar_dump_ftypes(void);
|
||||||
|
|
||||||
|
/** Get string representation of display field value
|
||||||
|
@param field_display field display value (one of BASE_ values)
|
||||||
|
@return string representation of display field value or "Unknown" if doesn't exist */
|
||||||
|
WS_DLL_PUBLIC const char* proto_field_display_to_string(int field_display);
|
||||||
|
|
||||||
/** Number of elements in the tree_is_expanded array. With MSVC and a
|
/** Number of elements in the tree_is_expanded array. With MSVC and a
|
||||||
* libwireshark.dll, we need a special declaration. */
|
* libwireshark.dll, we need a special declaration. */
|
||||||
|
|
135
rawshark.c
135
rawshark.c
|
@ -1127,6 +1127,7 @@ typedef struct _pci_t {
|
||||||
|
|
||||||
static const char* ftenum_to_string(header_field_info *hfi)
|
static const char* ftenum_to_string(header_field_info *hfi)
|
||||||
{
|
{
|
||||||
|
const char* str;
|
||||||
if (!hfi) {
|
if (!hfi) {
|
||||||
return "n.a.";
|
return "n.a.";
|
||||||
}
|
}
|
||||||
|
@ -1135,109 +1136,23 @@ static const char* ftenum_to_string(header_field_info *hfi)
|
||||||
return "FT_STRING";
|
return "FT_STRING";
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(hfi->type) {
|
str = ftype_name(hfi->type);
|
||||||
case FT_NONE:
|
if (str == NULL) {
|
||||||
return "FT_NONE";
|
str = "n.a.";
|
||||||
case FT_PROTOCOL:
|
|
||||||
return "FT_PROTOCOL";
|
|
||||||
case FT_BOOLEAN:
|
|
||||||
return "FT_BOOLEAN";
|
|
||||||
case FT_UINT8:
|
|
||||||
return "FT_UINT8";
|
|
||||||
case FT_UINT16:
|
|
||||||
return "FT_UINT16";
|
|
||||||
case FT_UINT24:
|
|
||||||
return "FT_UINT24";
|
|
||||||
case FT_UINT32:
|
|
||||||
return "FT_UINT32";
|
|
||||||
case FT_UINT64:
|
|
||||||
return "FT_UINT64";
|
|
||||||
case FT_INT8:
|
|
||||||
return "FT_INT8";
|
|
||||||
case FT_INT16:
|
|
||||||
return "FT_INT16";
|
|
||||||
case FT_INT24:
|
|
||||||
return "FT_INT24";
|
|
||||||
case FT_INT32:
|
|
||||||
return "FT_INT32";
|
|
||||||
case FT_INT64:
|
|
||||||
return "FT_INT64";
|
|
||||||
case FT_FLOAT:
|
|
||||||
return "FT_FLOAT";
|
|
||||||
case FT_DOUBLE:
|
|
||||||
return "FT_DOUBLE";
|
|
||||||
case FT_ABSOLUTE_TIME:
|
|
||||||
return "FT_ABSOLUTE_TIME";
|
|
||||||
case FT_RELATIVE_TIME:
|
|
||||||
return "FT_RELATIVE_TIME";
|
|
||||||
case FT_STRING:
|
|
||||||
return "FT_STRING";
|
|
||||||
case FT_STRINGZ:
|
|
||||||
return "FT_STRINGZ";
|
|
||||||
case FT_UINT_STRING:
|
|
||||||
return "FT_UINT_STRING";
|
|
||||||
case FT_ETHER:
|
|
||||||
return "FT_ETHER";
|
|
||||||
case FT_BYTES:
|
|
||||||
return "FT_BYTES";
|
|
||||||
case FT_UINT_BYTES:
|
|
||||||
return "FT_UINT_BYTES";
|
|
||||||
case FT_IPv4:
|
|
||||||
return "FT_IPv4";
|
|
||||||
case FT_IPv6:
|
|
||||||
return "FT_IPv6";
|
|
||||||
case FT_IPXNET:
|
|
||||||
return "FT_IPXNET";
|
|
||||||
case FT_FRAMENUM:
|
|
||||||
return "FT_FRAMENUM";
|
|
||||||
case FT_PCRE:
|
|
||||||
return "FT_PCRE";
|
|
||||||
case FT_GUID:
|
|
||||||
return "FT_GUID";
|
|
||||||
case FT_OID:
|
|
||||||
return "FT_OID";
|
|
||||||
case FT_REL_OID:
|
|
||||||
return "FT_REL_OID";
|
|
||||||
case FT_SYSTEM_ID:
|
|
||||||
return "FT_SYSTEM_ID";
|
|
||||||
case FT_STRINGZPAD:
|
|
||||||
return "FT_STRIGZPAD";
|
|
||||||
case FT_NUM_TYPES:
|
|
||||||
return "FT_NUM_TYPES";
|
|
||||||
default:
|
|
||||||
return "n.a.";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char* absolute_time_display_e_to_string(absolute_time_display_e atd)
|
|
||||||
{
|
|
||||||
switch(atd) {
|
|
||||||
case ABSOLUTE_TIME_LOCAL:
|
|
||||||
return "ABSOLUTE_TIME_LOCAL";
|
|
||||||
case ABSOLUTE_TIME_UTC:
|
|
||||||
return "ABSOLUTE_TIME_UTC";
|
|
||||||
default:
|
|
||||||
return "n.a.";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* field_display_e_to_string(field_display_e bd)
|
static void field_display_to_string(header_field_info *hfi, char* buf, int size)
|
||||||
{
|
{
|
||||||
switch(bd) {
|
if (hfi->type != FT_BOOLEAN)
|
||||||
case BASE_NONE:
|
{
|
||||||
return "BASE_NONE";
|
g_strlcpy(buf, proto_field_display_to_string(hfi->display), size);
|
||||||
case BASE_DEC:
|
}
|
||||||
return "BASE_DEC";
|
else
|
||||||
case BASE_HEX:
|
{
|
||||||
return "BASE_HEX";
|
g_snprintf(buf, size, "(Bit count: %d)", hfi->display);
|
||||||
case BASE_OCT:
|
|
||||||
return "BASE_OCT";
|
|
||||||
case BASE_DEC_HEX:
|
|
||||||
return "BASE_DEC_HEX";
|
|
||||||
case BASE_HEX_DEC:
|
|
||||||
return "BASE_HEX_DEC";
|
|
||||||
default:
|
|
||||||
return "n.a.";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1426,6 +1341,7 @@ protocolinfo_init(char *field)
|
||||||
pci_t *rs;
|
pci_t *rs;
|
||||||
header_field_info *hfi;
|
header_field_info *hfi;
|
||||||
GString *error_string;
|
GString *error_string;
|
||||||
|
char hfibuf[100];
|
||||||
|
|
||||||
hfi=proto_registrar_get_byname(field);
|
hfi=proto_registrar_get_byname(field);
|
||||||
if(!hfi){
|
if(!hfi){
|
||||||
|
@ -1433,22 +1349,11 @@ protocolinfo_init(char *field)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (hfi->type) {
|
field_display_to_string(hfi, hfibuf, sizeof(hfibuf));
|
||||||
|
printf("%d %s %s - ",
|
||||||
case FT_ABSOLUTE_TIME:
|
g_cmd_line_index,
|
||||||
printf("%d %s %s - ",
|
ftenum_to_string(hfi),
|
||||||
g_cmd_line_index,
|
hfibuf);
|
||||||
ftenum_to_string(hfi),
|
|
||||||
absolute_time_display_e_to_string((absolute_time_display_e)hfi->display));
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
printf("%d %s %s - ",
|
|
||||||
g_cmd_line_index,
|
|
||||||
ftenum_to_string(hfi),
|
|
||||||
field_display_e_to_string((field_display_e)hfi->display));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
rs=(pci_t *)g_malloc(sizeof(pci_t));
|
rs=(pci_t *)g_malloc(sizeof(pci_t));
|
||||||
rs->hf_index=hfi->id;
|
rs->hf_index=hfi->id;
|
||||||
|
|
Loading…
Reference in New Issue