Skip to content
  • João Valverde's avatar
    dfilter: Try to resolve field reference instead of using a heuristic · 8746eea2
    João Valverde authored and A Wireshark GitLab Utility's avatar A Wireshark GitLab Utility committed
    Instead of using a heuristic to decide whether the form ${...} is
    a macro or not, try to resolve the name to a registered protocol
    field and use that instead.
    
    This increases somewhat the surface for clobbering existing macro
    names with new field registrations but we'll cross that bridge when
    we get to it.
    
    Rejecting protocol field types reduces this probability again but it
    may not be intuitive to the user trying to mistakenly use a reference
    to a protocol why it is parsed as a macro. The reasons for rejecting
    FT_PROTOCOL types as not interesting field references are not
    very strong but it seems reasonable.
    
    $ dftest 'frame.number != ${frame.number}'
    Filter: frame.number != ${frame.number}
    
    Instructions:
    00000 READ_TREE		frame.number -> reg#0
    00001 IF_FALSE_GOTO	5
    00002 READ_REFERENCE	${frame.number} -> reg#1
    00003 IF_FALSE_GOTO	5
    00004 ALL_NE		reg#0 != reg#1
    00005 RETURN
    
    $ dftest 'frame != ${frame}'
    dftest: macro 'frame' does not exist
    8746eea2