2016-07-28 1 views
2

을 채울 때 나는 그것이 캡처에 대해 실행할 때 다음과 같은 버그 경고를 throw 간단한 와이어 샤크의 해부학자 있습니다와이어 샤크 C 해부학자 오류 하위 트리

13:04:12   Warn Dissector bug, protocol usbserial, in packet 353: /wireshark/epan/proto.c:5504: 
failed assertion "idx >= 0 && idx < num_tree_types" 

프로토콜 등록 기능은 다음과 같습니다

static gint ett_myproto = -1; 

void 
proto_register_myproto(void) 
{ 
    /* Set up field array */ 
    static hf_register_info hf[] = { 
     { &hf_myproto_payload, 
      {"Payload", "myproto.payload", FT_BYTES, BASE_NONE, NULL, 
       0x0, NULL, HFILL }}, 
    }; 

    /* Register protocol */ 
    proto_myproto = proto_register_protocol("My Protocol", "myproto", "myproto"); 
    /* Register protocol fields */ 
    proto_register_field_array(proto_myproto, hf, array_length(hf)); 

    /* Register the dissector */ 
    register_dissector("myproto", dissect_myproto, proto_myproto); 
} 

해부학자는 데이터의 몇 가지 일반적인 munging을 수행하지만, 문제 영역의 핵심이 될 것으로 보인다 :

static int 
dissect_myproto(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, 
     void *data _U_) 
{ 
    proto_item *ti; 
    proto_tree *myproto_tree; 

    /* Create top tree and add to the item */ 
    ti = proto_tree_add_protocol_format(tree, proto_myproto, tvb, 0, -1, 
      "My Protocol"); 
    myproto_tree = proto_item_add_subtree(ti, ett_myproto); 

    proto_tree_add_bytes_format(myproto_tree, hf_myproto_payload, 
      tvb, 0, payload_len, 
      NULL, "Payload"); 
} 

프로토콜이 하위 트리를 올바르게 채우려면 어떻게해야합니까?

답변

2

여기서 문제는 하위 트리를 하위 트리 배열의 일부로 등록하지 못했습니다 (힌트는 here).

프로토콜 등록 기능에서 수행하고, "포장"(여기에서 단지 하나가 어느 : ett_myproto) 서브 트리의 변수를 필요로하는 배열로하고 proto_register_subtree_array을 사용하는 어레이 가입 :

static gint ett_myproto = -1; 

void 
proto_register_myproto(void) 
{ 
    /* Set up field array */ 
    static hf_register_info hf[] = { 
     .... 
    }; 

    /* Register protocol */ 
    proto_myproto = proto_register_protocol("My Protocol", "myproto", "myproto"); 
    /* Register protocol fields */ 
    proto_register_field_array(proto_myproto, hf, array_length(hf)); 

    /* Setup and register all protocol subtrees */ 
    static gint *ett[] = { 
     &ett_myproto, 
    }; 

    proto_register_subtree_array(ett, array_length(ett)); 

    /* Register the dissector */ 
    register_dissector("myproto", dissect_myproto, proto_myproto); 
} 

ett 변수는 하위 트리의 상태에 대한 GUI 정보 (예 : 확장 여부)를 나타내는 데 사용되는 인덱스입니다.

+0

일반적으로 이러한 문제는 [doc/packet-PROTOABBREV.c] (https://github.com/wireshark/wireshark/boc/master/doc/packet-PROTOABBREV.c)의 샘플 해독기 코드와 비교할 때 쉽게 감지됩니다.) – Lekensteyn