2017-12-21 8 views
0

우리는 소프트웨어를 개발하고 프로토콜은 표준 pdcp를 사용하지만 표준 pdcp 프로토콜 앞에 44 바이트 사용자 정의 데이터를 추가합니다.
wireshark 플러그인을 작성하여 패키지를 구문 분석하고 헤드 44 바이트 사용자 정의 데이터를 무시하고 다른 데이터를 구문 분석 한 후 wireshark pdcp dissector를 사용하십시오. 코드 목록은 아래 : PDCP parsewireshark 플러그인은 상세 정보를 표시 할 수 없습니다

코드와 무슨 일이야 :

static gint ett_dtmpdcp = -1; 
static gint hf_sdtprot_pdu_Msg_Content_None 
static hf_register_info hf[] = { 
    { &hf_sdtprot_pdu_Msg_Content_None, 
     { " ", "dtmpdcp.none", 
     FT_NONE, BASE_NONE, 
     NULL, 0x0, 
     NULL, HFILL } 
    } 
}; 

static gint *ett[] = { 
    &ett_dtmpdcp 
}; 

int packet_parse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset) 
{ 
    int item_offset = 44; //ignore head 44 bytes custom data 

    gint16 pdu_len = tvb_reported_length(tvb); 

    proto_item * pdcp_item = proto_tree_add_item(tree, proto_dtmpdcp, tvb, 0, -1, ENC_NA); 
    proto_item_append_text(pdcp_item, ",PDU len : %-05u", pdu_len); 

    proto_tree * subtree = proto_item_add_subtree(pdcp_item, ett_dtmpdcp); 
    offset += item_offset; 

    //use wireshark pdcp dissector,wireshark register pdcp-lte dissector in packet_pdcp_lte.c file 
    dissector_handle_t handle = find_dissector("pdcp-lte"); 

    if(handle) 
    { 
     tvbuff_t* next_tvb = tvb_new_subset(tvb, offset, -1, pdu_len - item_offset); 
     if(next_tvb) 
     { 
      call_dissector(handle, next_tvb, pinfo, subtree); 
      //tvb_free(next_tvb); 
     } 
    } 

    return 0; 
} 

const char *c_proto_string = "DTM-PDCP"; 

static void 
dissect_dtmpdcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) 
{ 
    col_set_str(pinfo->cinfo, COL_PROTOCOL, c_proto_string); 
    col_clear(pinfo->cinfo,COL_INFO); 

    if (tree) 
    { 
     gint offset = 0; 

     do 
     { 
      offset = packet_parse(tvb, pinfo, tree, offset); 
     } while(offset > 0); 
    } 
} 

void proto_register_dtmpdcp(void) 
{ 
    module_t *sdtpprot_module; 

    proto_dtmpdcp = proto_register_protocol("PDCP DTM", /* name  */ 
     "a-pdcp", /* short name */ 
     "a-pdcp" /* abbrev  */ 
     ); 

    proto_register_field_array(proto_dtmpdcp, hf, array_length(hf)); 
    proto_register_subtree_array(ett, array_length(ett)); 

    sdtpprot_module = prefs_register_protocol(proto_dtmpdcp, NULL); 

    prefs_register_bool_preference(sdtpprot_module, "desegment", 
     "Desegment all dtm-pdcp messages spanning multiple TCP segments", 
     "Whether the dtm-pdcp dissector should desegment all messages spanning multiple TCP segments", 
     &sdtpprot_desegment); 
} 

void proto_reg_handoff_dtmpdcp(void) 
{ 
    dissector_handle_t dtmpdcp_handle; 
    int port = 20000; 

    dtmpdcp_handle = create_dissector_handle(dissect_dtmpdcp, proto_dtmpdcp); 
    dissector_add_uint("udp.port", port, dtmpdcp_handle); 
} 

때 사용하는 패키지를 해부학자이 플러그인, 와이어 샤크 UI는 PDCP 프로토콜 상세 정보]를 표시하지 않습니다?
감사합니다.

답변

0

dissect_dtmpdcp()if (tree) 수표를 삭제하는 것으로 시작합니다. README.dissector에서 : 검사를 추가 내 경험에

In the interest of speed, if "tree" is NULL, avoid building a 
protocol tree and adding stuff to it, or even looking at any packet 
data needed only if you're building the protocol tree, if possible. 

Note, however, that you must fill in column information, create 
conversations, reassemble packets, do calls to "expert" functions, 
build any other persistent state needed for dissection, and call 
subdissectors regardless of whether "tree" is NULL or not. 

This might be inconvenient to do without doing most of the 
dissection work; the routines for adding items to the protocol tree 
can be passed a null protocol tree pointer, in which case they'll 
return a null item pointer, and "proto_item_add_subtree()" returns 
a null tree pointer if passed a null item pointer, so, if you're 
careful not to dereference any null tree or item pointers, you can 
accomplish this by doing all the dissection work. This might not 
be as efficient as skipping that work if you're not building a 
protocol tree, but if the code would have a lot of tests whether 
"tree" is null if you skipped that work, you might still be better 
off just doing all that work regardless of whether "tree" is null 
or not. 

Note also that there is no guarantee, the first time the dissector is 
called, whether "tree" will be null or not; your dissector must work 
correctly, building or updating whatever state information is 
necessary, in either case. 

, 일반적으로 좋은보다 더 많은 피해를 않습니다.

나는 또한 packet-catapult-dct2000.c과 같은 작동하는 Wireshark 해부학자를 검사하고 이에 따라 의사를 수정하는 것이 좋습니다. 예를 들어

:

static dissector_handle_t pdcp_lte_handle; 

int packet_parse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset) 
{ 
    ... 
    if (pdcp_lte_handle) 
    { 
     tvbuff_t* next_tvb = tvb_new_subset_remaining(tvb, offset); 
     if (next_tvb) 
      call_dissector(pdcp_lte_handle, next_tvb, pinfo, subtree); 
    } 
} 

void proto_reg_handoff_dtmpdcp(void) 
{ 
    ... 
    pdcp_lte_handle = find_dissector("pdcp-lte"); 
    ... 
} 

이 방법으로 문제가 해결되지 않으면, 당신이 어딘가에 샘플 캡처 파일을 게시해야합니다 (cloudshark, 보관 등) 더 나은 도움을 드릴 수 있습니다.