proto.c:3640: failed assertion "idx >=0 && idx < num_tree_types"

I have a plugin dissector I am working on that dissects a custom protocol with about a dozen main message types.  In order to manage it easier I have broken the code into multiple .c files.  I seems that when I do that though, the actual functions I call in the 2nd .c file have problems with the ett subtree array.

When compiled and run I see the following errors for all packets dissected in the 2nd .c file.

   Dissector bug, protocol BLAH:  proto.c:3640:  failed assertion "idx >=0 && idx < num_tree_types"

Here is the snippet of code:

dissect_keep_alive(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree, int message_length)
{
        proto_item *ti = NULL;
        proto_tree *keepalive_tree = NULL;

        if (tree) {
            ti = proto_tree_add_text(tree, tvb, offset, message_length, "KeepAlive");
            ti = proto_tree_add_text(tree, tvb, offset, message_length, "ett_keepalive %d",ett_keepalive);
            keepalive_tree = proto_item_add_subtree(ti, ett_keepalive);
            proto_tree_add_item(keepalive_tree, hf_keepalive_timeout, tvb, offset, 2, FALSE); offset += 2;
            proto_tree_add_item(keepalive_tree, hf_keepalive_spare, tvb, offset, 2, FALSE); offset += 2;
        }
}

It appears that ett_keepalive is -1 when I run wireshark.  I have defined the ett_keepalive and the ett subtree in the .h file.  

static gint ett_keepalive = -1;
static gint *ett[] = {
...
    &ett_keepalive,
...
};


It all works when I have just one source file but when I moved these functions to the 2nd file, I started having this problem.  Do I need to define these in the proto_register function and explicitly pass the ett subtree array?  Is there an example dissector that has the dissector spread across multiple .c files and single .h file?  

My C skills are a bit rusty so thank you for your patience.
Jason
 
 
原因:
   static gint *ett[] = {  
    	&ett_lte_m2m,
        &ett_lte_m2m_downlink_pdu,
        &ett_lte_m2m_uplink_pdu,
        &ett_lte_m2m_trans_mode,
        &ett_lte_m2m_rach_downlink,
        &ett_lte_m2m_rach_uplink, 
    };
没有吧新加的注册进来。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值