hi everyone, i`m creating a very simple dissector for
a DSR protocol. The protocol`s head is 3 fields:
nextheader(1 byte,it indicates waht protocol go after
dsr TCP UDP or ICMP),reserved(1 byte) and payload (2
bytes, it indicates the length of the payload of the
dsrpacket), i only want that my dissector shows the
header fields of DSR, but when i do click in a DSR
packet ethereal close itself y appear a violation
segment like error, why my dissector doesn't work,
here is the code: i don't find the error in this
simple code!!!!:
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <epan/packet.h>
#include <epan/ipproto.h>
void proto_reg_handoff_dsr(void);
static int proto_dsr=-1;
static int hf_dsr_nextheader=-1;
static int hf_dsr_reserved=-1;
static int hf_dsr_payloadlength=-1;
static gint ett_dsr=-1;
static void
dissect_dsr(tvbuff_t *tvb,packet_info
*pinfo,proto_tree *tree)
{
proto_item *tp,*t0,*t1,*t2;
proto_tree *dsr_tree;
guint8 nextheader;
guint8 reserved;
guint16 payloadlength;
pinfo->current_proto="DSR";
if(check_col(pinfo->cinfo,COL_PROTOCOL))
col_set_str(pinfo->cinfo,COL_PROTOCOL,"DSR");
if(check_col(pinfo->cinfo,COL_INFO))
col_clear(pinfo->cinfo,COL_INFO);
if(check_col(pinfo->cinfo,COL_INFO))
col_set_str(pinfo->cinfo,COL_INFO,"DynamicSourceRoute");
nextheader=tvb_get_guint8(tvb,0);
reserved=tvb_get_guint8(tvb,1);
payloadlength=tvb_get_letohs(tvb,2);
dsr_tree=proto_item_add_subtree(tp,ett_dsr);
t0=proto_tree_add_uint(dsr_tree,hf_dsr_nextheader,tvb,0,1,nextheader);
t1=proto_tree_add_uint(dsr_tree,hf_dsr_reserved,tvb,1,1,reserved);
t2=proto_tree_add_uint(dsr_tree,hf_dsr_payloadlength,tvb,2,2,payloadlength);
}
void
proto_register_dsr(void)
{
static hf_register_info hf[]= {
{ &hf_dsr_nextheader,
{
"nextheader","dsr.nextheader",FT_UINT8,BASE_DEC,NULL,0x00,"",HFILL}
},
{ &hf_dsr_reserved,
{
"reserved","dsr.reserved",FT_UINT8,BASE_HEX,NULL,0x00,"",HFILL}
},
{ &hf_dsr_payloadlength,
{
"payloadlength","dsr.payloadlength",FT_UINT16,BASE_DEC,NULL,0x00,"",HFILL}
},
};
static gint *ett[]= {
&ett_dsr,
};
proto_dsr=proto_register_protocol("DynamicSourceRoute","DSR","dsr");
proto_register_field_array(proto_dsr,hf,array_length(hf));
proto_register_subtree_array(ett,array_length(ett));
}
void proto_reg_handoff_dsr(void)
{
dissector_handle_t dsr_handle;
dsr_handle=create_dissector_handle(dissect_dsr,proto_dsr);
dissector_add("ip.proto",IP_PROTO_DSR,dsr_handle);
}
______________________________________________
LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y m�viles desde 1 c�ntimo por minuto.
http://es.voice.yahoo.com