diff options
-rw-r--r-- | plugins/profinet/packet-dcom-cba-acco.c | 311 | ||||
-rw-r--r-- | plugins/profinet/packet-dcom-cba-acco.h | 6 | ||||
-rw-r--r-- | plugins/profinet/packet-dcom-cba.c | 1599 | ||||
-rw-r--r-- | plugins/profinet/packet-pn-dcp.c | 705 | ||||
-rw-r--r-- | plugins/profinet/packet-pn-mrp.c | 260 | ||||
-rw-r--r-- | plugins/profinet/packet-pn-mrrt.c | 134 | ||||
-rw-r--r-- | plugins/profinet/packet-pn-ptcp.c | 739 | ||||
-rw-r--r-- | plugins/profinet/packet-pn-rt.c | 527 | ||||
-rw-r--r-- | plugins/profinet/packet-pn.c | 30 |
9 files changed, 2424 insertions, 1887 deletions
diff --git a/plugins/profinet/packet-dcom-cba-acco.c b/plugins/profinet/packet-dcom-cba-acco.c index 8376816055..8ac54ff43f 100644 --- a/plugins/profinet/packet-dcom-cba-acco.c +++ b/plugins/profinet/packet-dcom-cba-acco.c @@ -259,63 +259,63 @@ static const value_string cba_qos_type_short_vals[] = { typedef struct cba_frame_s { - cba_ldev_t *consparent; - cba_ldev_t *provparent; - GList *conns; - guint packet_connect; - guint packet_disconnect; - guint packet_disconnectme; - guint packet_first; - guint packet_last; - - guint16 length; - const guint8 consmac[6]; - guint16 conscrid; - guint32 provcrid; - guint32 conncrret; - guint16 qostype; - guint16 qosvalue; - guint16 offset; + cba_ldev_t *consparent; + cba_ldev_t *provparent; + GList *conns; + guint packet_connect; + guint packet_disconnect; + guint packet_disconnectme; + guint packet_first; + guint packet_last; + + guint16 length; + const guint8 consmac[6]; + guint16 conscrid; + guint32 provcrid; + guint32 conncrret; + guint16 qostype; + guint16 qosvalue; + guint16 offset; } cba_frame_t; typedef struct cba_connection_s { - cba_ldev_t *consparentacco; - cba_ldev_t *provparentacco; - cba_frame_t *parentframe; - guint packet_connect; - guint packet_disconnect; - guint packet_disconnectme; - guint packet_first; - guint packet_last; - - guint16 length; - guint32 consid; - guint32 provid; - const gchar *provitem; - guint32 connret; - guint16 typedesclen; - guint16 *typedesc; - guint16 qostype; - guint16 qosvalue; - guint16 frame_offset; + cba_ldev_t *consparentacco; + cba_ldev_t *provparentacco; + cba_frame_t *parentframe; + guint packet_connect; + guint packet_disconnect; + guint packet_disconnectme; + guint packet_first; + guint packet_last; + + guint16 length; + guint32 consid; + guint32 provid; + const gchar *provitem; + guint32 connret; + guint16 typedesclen; + guint16 *typedesc; + guint16 qostype; + guint16 qosvalue; + guint16 frame_offset; } cba_connection_t; typedef struct server_frame_call_s { - guint frame_count; - cba_frame_t **frames; + guint frame_count; + cba_frame_t **frames; } server_frame_call_t; typedef struct server_connect_call_s { - guint conn_count; - cba_frame_t *frame; + guint conn_count; + cba_frame_t *frame; cba_connection_t **conns; } server_connect_call_t; typedef struct server_disconnectme_call_s { - cba_ldev_t *cons; - cba_ldev_t *prov; + cba_ldev_t *cons; + cba_ldev_t *prov; } server_disconnectme_call_t; @@ -447,8 +447,8 @@ cba_pdev_add(packet_info *pinfo, const guint8 *ip) pdev = se_alloc(sizeof(cba_pdev_t)); memcpy( (void *) (pdev->ip), ip, 4); pdev->first_packet = pinfo->fd->num; - pdev->ldevs = NULL; - pdev->object = NULL; + pdev->ldevs = NULL; + pdev->object = NULL; cba_pdevs = g_list_append(cba_pdevs, pdev); return pdev; @@ -511,16 +511,16 @@ cba_ldev_add(packet_info *pinfo, cba_pdev_t *pdev, const char *name) /* not found, create a new */ ldev = se_alloc(sizeof(cba_ldev_t)); - ldev->name = se_strdup(name); + ldev->name = se_strdup(name); ldev->first_packet = pinfo->fd->num; - ldev->ldev_object = NULL; - ldev->acco_object = NULL; - ldev->parent = pdev; + ldev->ldev_object = NULL; + ldev->acco_object = NULL; + ldev->parent = pdev; - ldev->provframes = NULL; - ldev->consframes = NULL; - ldev->provconns = NULL; - ldev->consconns = NULL; + ldev->provframes = NULL; + ldev->consframes = NULL; + ldev->provconns = NULL; + ldev->consconns = NULL; pdev->ldevs = g_list_append(pdev->ldevs, ldev); @@ -567,7 +567,7 @@ cba_acco_add(packet_info *pinfo, const char *acco) ip_str = g_strdup(acco); - delim = strchr(ip_str, '!'); + delim = strchr(ip_str, '!'); if (delim == NULL) { g_free(ip_str); return NULL; @@ -620,20 +620,22 @@ cba_frame_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, cba_fram proto_item *sub_item; proto_tree *sub_tree; - sub_item = proto_tree_add_text(tree, tvb, 0, 0, "Cons:\"%s\" CCRID:0x%x Prov:\"%s\" PCRID:0x%x QoS:%s/%ums Len:%u", + sub_item = proto_tree_add_text(tree, tvb, 0, 0, + "Cons:\"%s\" CCRID:0x%x Prov:\"%s\" PCRID:0x%x QoS:%s/%ums Len:%u", frame->consparent ? frame->consparent->name : "", frame->conscrid, frame->provparent ? frame->provparent->name : "", frame->provcrid, - val_to_str(frame->qostype, cba_qos_type_short_vals, "%u"), frame->qosvalue, frame->length); + val_to_str(frame->qostype, cba_qos_type_short_vals, "%u"), + frame->qosvalue, frame->length); sub_tree = proto_item_add_subtree(sub_item, ett_cba_frame_info); PROTO_ITEM_SET_GENERATED(sub_item); - item = proto_tree_add_uint(sub_tree, hf_cba_acco_conn_qos_type, tvb, 0, 0, frame->qostype); + item = proto_tree_add_uint(sub_tree, hf_cba_acco_conn_qos_type, tvb, 0, 0, frame->qostype); PROTO_ITEM_SET_GENERATED(item); - item = proto_tree_add_uint(sub_tree, hf_cba_acco_conn_qos_value, tvb, 0, 0, frame->qosvalue); + item = proto_tree_add_uint(sub_tree, hf_cba_acco_conn_qos_value, tvb, 0, 0, frame->qosvalue); PROTO_ITEM_SET_GENERATED(item); - item = proto_tree_add_uint(sub_tree, hf_cba_acco_serversrt_cr_id, tvb, 0, 0, frame->conscrid); + item = proto_tree_add_uint(sub_tree, hf_cba_acco_serversrt_cr_id, tvb, 0, 0, frame->conscrid); PROTO_ITEM_SET_GENERATED(item); - item = proto_tree_add_uint(sub_tree, hf_cba_acco_prov_crid, tvb, 0, 0, frame->provcrid); + item = proto_tree_add_uint(sub_tree, hf_cba_acco_prov_crid, tvb, 0, 0, frame->provcrid); PROTO_ITEM_SET_GENERATED(item); item = proto_tree_add_uint(sub_tree, hf_cba_acco_serversrt_cr_length, tvb, 0, 0, frame->length); PROTO_ITEM_SET_GENERATED(item); @@ -685,26 +687,26 @@ cba_frame_connect(packet_info *pinfo, cba_ldev_t *cons_ldev, cba_ldev_t *prov_ld frame = se_alloc(sizeof(cba_frame_t)); - frame->consparent = cons_ldev; - frame->provparent = prov_ldev; + frame->consparent = cons_ldev; + frame->provparent = prov_ldev; - frame->packet_connect = pinfo->fd->num; - frame->packet_disconnect = 0; + frame->packet_connect = pinfo->fd->num; + frame->packet_disconnect = 0; frame->packet_disconnectme = 0; - frame->packet_first = 0; - frame->packet_last = 0; + frame->packet_first = 0; + frame->packet_last = 0; - frame->length = length; + frame->length = length; memcpy( (guint8 *) (frame->consmac), consmac, sizeof(frame->consmac)); - frame->conscrid = conscrid; - frame->qostype = qostype; - frame->qosvalue = qosvalue; + frame->conscrid = conscrid; + frame->qostype = qostype; + frame->qosvalue = qosvalue; - frame->offset = 4; - frame->conns = NULL; + frame->offset = 4; + frame->conns = NULL; - frame->provcrid = 0; - frame->conncrret = -1; + frame->provcrid = 0; + frame->conncrret = -1; cons_ldev->consframes = g_list_append(cons_ldev->consframes, frame); prov_ldev->provframes = g_list_append(prov_ldev->provframes, frame); @@ -852,11 +854,11 @@ cba_connection_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, cba sub_tree = proto_item_add_subtree(sub_item, ett_cba_conn_info); PROTO_ITEM_SET_GENERATED(sub_item); - item = proto_tree_add_string(sub_tree, hf_cba_acco_conn_provider_item, tvb, 0, 0 /* len */, conn->provitem); + item = proto_tree_add_string(sub_tree, hf_cba_acco_conn_provider_item, tvb, 0, 0 /* len */, conn->provitem); PROTO_ITEM_SET_GENERATED(item); - item = proto_tree_add_uint(sub_tree, hf_cba_acco_conn_prov_id, tvb, 0, 0 /* len */, conn->provid); + item = proto_tree_add_uint(sub_tree, hf_cba_acco_conn_prov_id, tvb, 0, 0 /* len */, conn->provid); PROTO_ITEM_SET_GENERATED(item); - item = proto_tree_add_uint(sub_tree, hf_cba_acco_conn_cons_id, tvb, 0, 0 /* len */, conn->consid); + item = proto_tree_add_uint(sub_tree, hf_cba_acco_conn_cons_id, tvb, 0, 0 /* len */, conn->consid); PROTO_ITEM_SET_GENERATED(item); item = proto_tree_add_uint(sub_tree, hf_cba_acco_serversrt_record_length, tvb, 0, 0 /* len */, conn->length); PROTO_ITEM_SET_GENERATED(item); @@ -919,34 +921,34 @@ cba_connection_connect(packet_info *pinfo, cba_ldev_t *cons_ldev, cba_ldev_t *pr conn = se_alloc(sizeof(cba_connection_t)); - conn->consparentacco = cons_ldev; - conn->provparentacco = prov_ldev; - conn->parentframe = cons_frame; + conn->consparentacco = cons_ldev; + conn->provparentacco = prov_ldev; + conn->parentframe = cons_frame; - conn->packet_connect = pinfo->fd->num; - conn->packet_disconnect = 0; + conn->packet_connect = pinfo->fd->num; + conn->packet_disconnect = 0; conn->packet_disconnectme = 0; - conn->packet_first = 0; - conn->packet_last = 0; + conn->packet_first = 0; + conn->packet_last = 0; - conn->consid = consid; - conn->provitem = se_strdup(provitem); - conn->typedesclen = typedesclen; - conn->typedesc = typedesc; - conn->qostype = qostype; - conn->qosvalue = qosvalue; - conn->length = length; + conn->consid = consid; + conn->provitem = se_strdup(provitem); + conn->typedesclen = typedesclen; + conn->typedesc = typedesc; + conn->qostype = qostype; + conn->qosvalue = qosvalue; + conn->length = length; - conn->provid = 0; - conn->connret = -1; + conn->provid = 0; + conn->connret = -1; if (cons_frame != NULL) { - conn->frame_offset = cons_frame->offset; - conn->length = length; - cons_frame->offset += length; - cons_frame->conns = g_list_append(cons_frame->conns, conn); + conn->frame_offset = cons_frame->offset; + conn->length = length; + cons_frame->offset += length; + cons_frame->conns = g_list_append(cons_frame->conns, conn); } else { - conn->frame_offset = 0; + conn->frame_offset = 0; cons_ldev->consconns = g_list_append(cons_ldev->consconns, conn); prov_ldev->provconns = g_list_append(prov_ldev->provconns, conn); } @@ -1045,7 +1047,7 @@ dissect_HResultArray_resp(tvbuff_t *tvb, int offset, offset = dissect_dcom_that(tvb, offset, pinfo, tree, drep); offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, - &u32Pointer); + &u32Pointer); if (u32Pointer) { offset = dissect_dcom_dcerpc_array_size(tvb, offset, pinfo, tree, drep, @@ -1055,13 +1057,13 @@ dissect_HResultArray_resp(tvbuff_t *tvb, int offset, u32Tmp = u32ArraySize; while (u32Tmp--) { offset = dissect_dcom_indexed_HRESULT(tvb, offset, pinfo, tree, drep, - &u32HResult, u32Idx); + &u32HResult, u32Idx); u32Idx++; } } offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, - &u32HResult); + &u32HResult); col_append_fstr(pinfo->cinfo, COL_INFO, ": Cnt=%u -> %s", u32ArraySize, @@ -1279,8 +1281,8 @@ dissect_ICBAAccoServer_Connect_rqst(tvbuff_t *tvb, int offset, if (prov_ldev != NULL && cons_ldev != NULL) { call = se_alloc(sizeof(server_connect_call_t) + u32ArraySize * sizeof(cba_connection_t *)); call->conn_count = 0; - call->frame = NULL; - call->conns = (cba_connection_t **) (call+1); + call->frame = NULL; + call->conns = (cba_connection_t **) (call+1); info->call_data->private_data = call; } else{ call = NULL; @@ -1294,8 +1296,8 @@ dissect_ICBAAccoServer_Connect_rqst(tvbuff_t *tvb, int offset, proto_item *sub_item; proto_tree *sub_tree; - sub_item = proto_tree_add_item(tree, hf_cba_connectin, tvb, offset, 0, ENC_NA); - sub_tree = proto_item_add_subtree(sub_item, ett_cba_connectin); + sub_item = proto_tree_add_item(tree, hf_cba_connectin, tvb, offset, 0, ENC_NA); + sub_tree = proto_item_add_subtree(sub_item, ett_cba_connectin); u32SubStart = offset; /* ProviderItem */ @@ -1439,8 +1441,8 @@ dissect_ICBAAccoServer2_Connect2_rqst(tvbuff_t *tvb, int offset, if (prov_ldev != NULL && cons_ldev != NULL) { call = se_alloc(sizeof(server_connect_call_t) + u32ArraySize * sizeof(cba_connection_t *)); call->conn_count = 0; - call->frame = NULL; - call->conns = (cba_connection_t **) (call+1); + call->frame = NULL; + call->conns = (cba_connection_t **) (call+1); info->call_data->private_data = call; } else{ call = NULL; @@ -1606,7 +1608,7 @@ dissect_ICBAAccoServer_Connect_resp(tvbuff_t *tvb, int offset, /* put response data into the connection */ if (call && u32Idx <= call->conn_count) { conn = call->conns[u32Idx-1]; - conn->provid = u32ProvID; + conn->provid = u32ProvID; conn->connret = u32HResult; cba_connection_info(tvb, pinfo, sub_tree, conn); @@ -1627,7 +1629,7 @@ dissect_ICBAAccoServer_Connect_resp(tvbuff_t *tvb, int offset, /* this might be a global HRESULT */ while(call && u32Idx <= call->conn_count) { conn = call->conns[u32Idx-1]; - conn->provid = 0; + conn->provid = 0; conn->connret = u32HResult; u32Idx++; } @@ -1675,8 +1677,8 @@ dissect_ICBAAccoServer_Disconnect_rqst(tvbuff_t *tvb, int offset, if (prov_ldev != NULL) { call = se_alloc(sizeof(server_connect_call_t) + u32ArraySize * sizeof(cba_connection_t *)); call->conn_count = 0; - call->frame = NULL; - call->conns = (cba_connection_t **) (call+1); + call->frame = NULL; + call->conns = (cba_connection_t **) (call+1); info->call_data->private_data = call; } else{ call = NULL; @@ -2291,7 +2293,7 @@ dissect_ICBAAccoServerSRT_ConnectCR_resp(tvbuff_t *tvb, int offset, /* put response data into the frame */ if (call && u32Idx <= call->frame_count) { frame = call->frames[u32Idx-1]; - frame->provcrid = u32ProvCRID; + frame->provcrid = u32ProvCRID; frame->conncrret = u32HResult; cba_frame_info(tvb, pinfo, sub_tree, frame); @@ -2313,7 +2315,7 @@ dissect_ICBAAccoServerSRT_ConnectCR_resp(tvbuff_t *tvb, int offset, /* this might be a global HRESULT */ while(call && u32Idx <= call->frame_count) { frame = call->frames[u32Idx-1]; - frame->provcrid = 0; + frame->provcrid = 0; frame->conncrret = u32HResult; u32Idx++; } @@ -2361,7 +2363,7 @@ dissect_ICBAAccoServerSRT_DisconnectCR_rqst(tvbuff_t *tvb, int offset, if (prov_ldev != NULL) { call = se_alloc(sizeof(server_frame_call_t) + u32ArraySize * sizeof(cba_frame_t *)); call->frame_count = 0; - call->frames = (cba_frame_t **) (call+1); + call->frames = (cba_frame_t **) (call+1); info->call_data->private_data = call; } else{ call = NULL; @@ -2449,30 +2451,32 @@ static int dissect_ICBAAccoServerSRT_Connect_rqst(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint32 u32ProvCRID; - guint8 u8State; - guint8 u8LastConnect; - guint32 u32Count; - guint32 u32ArraySize; - guint32 u32VariableOffset; - guint32 u32Idx; - guint32 u32SubStart; - guint32 u32Pointer; - gchar szProvItem[1000] = { 0 }; - guint32 u32MaxProvItemLen = sizeof(szProvItem); - guint16 u16TypeDescLen; - guint32 u32ArraySize2; - guint32 u32Idx2; - guint16 u16VarType2 = -1; - guint16 u16VarType; - guint32 u32ConsID; - guint16 u16RecordLength; + guint32 u32ProvCRID; + guint8 u8State; + guint8 u8LastConnect; + guint32 u32Count; + guint32 u32ArraySize; + guint32 u32VariableOffset; + guint32 u32Idx; + guint32 u32SubStart; + guint32 u32Pointer; + gchar szProvItem[1000] = { 0 }; + guint32 u32MaxProvItemLen = sizeof(szProvItem); + guint16 u16TypeDescLen; + guint32 u32ArraySize2; + guint32 u32Idx2; + guint16 u16VarType2 = -1; + guint16 u16VarType; + guint32 u32ConsID; + guint16 u16RecordLength; + proto_item *item; - dcerpc_info *info = (dcerpc_info *)pinfo->private_data; + dcerpc_info *info = (dcerpc_info *)pinfo->private_data; cba_ldev_t *prov_ldev; - cba_frame_t *frame = NULL; - guint16 typedesclen = 0; - guint16 *typedesc = NULL; + cba_frame_t *frame = NULL; + guint16 typedesclen = 0; + guint16 *typedesc = NULL; + cba_connection_t *conn; server_connect_call_t *call; @@ -2621,14 +2625,15 @@ static int dissect_ICBAAccoServerSRT_Connect_resp(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint32 u32Pointer; - guint32 u32ArraySize; - guint32 u32Idx = 1; - guint32 u32SubStart; - guint32 u32ProvID; - guint32 u32HResult; + guint32 u32Pointer; + guint32 u32ArraySize; + guint32 u32Idx = 1; + guint32 u32SubStart; + guint32 u32ProvID; + guint32 u32HResult; + proto_item *item; - dcerpc_info *info = (dcerpc_info *)pinfo->private_data; + dcerpc_info *info = (dcerpc_info *)pinfo->private_data; server_connect_call_t *call = info->call_data->private_data; cba_connection_t *conn; @@ -2674,7 +2679,7 @@ dissect_ICBAAccoServerSRT_Connect_resp(tvbuff_t *tvb, int offset, /* put response data into the frame */ if (call && u32Idx <= call->conn_count) { conn = call->conns[u32Idx-1]; - conn->provid = u32ProvID; + conn->provid = u32ProvID; conn->connret = u32HResult; cba_connection_info(tvb, pinfo, sub_tree, conn); @@ -2695,7 +2700,7 @@ dissect_ICBAAccoServerSRT_Connect_resp(tvbuff_t *tvb, int offset, /* this might be a global HRESULT */ while(call && u32Idx <= call->conn_count) { conn = call->conns[u32Idx-1]; - conn->provid = 0; + conn->provid = 0; conn->connret = u32HResult; u32Idx++; } @@ -2900,7 +2905,7 @@ dissect_Server_GetProvConnections_resp(tvbuff_t *tvb, int offset, } -#define CBA_MRSH_VERSION_DCOM 0x1 +#define CBA_MRSH_VERSION_DCOM 0x01 #define CBA_MRSH_VERSION_SRT_WITH_CONSID 0x10 #define CBA_MRSH_VERSION_SRT_WITHOUT_CONSID 0x11 @@ -2977,9 +2982,9 @@ dissect_CBA_Connection_Data(tvbuff_t *tvb, #endif /* is this an OnDataChanged buffer format (version), we know? */ - if (u8Version != CBA_MRSH_VERSION_DCOM && - u8Version != CBA_MRSH_VERSION_SRT_WITH_CONSID && - u8Version != CBA_MRSH_VERSION_SRT_WITHOUT_CONSID) + if ((u8Version != CBA_MRSH_VERSION_DCOM) && + (u8Version != CBA_MRSH_VERSION_SRT_WITH_CONSID) && + (u8Version != CBA_MRSH_VERSION_SRT_WITHOUT_CONSID)) { return offset; } @@ -3035,8 +3040,8 @@ dissect_CBA_Connection_Data(tvbuff_t *tvb, if (sub_tree) { proto_tree_add_item(sub_tree, hf_cba_acco_cb_item_length, tvb, offset, 2, ENC_LITTLE_ENDIAN); } - offset += 2; - u16HdrLen = 2; + offset += 2; + u16HdrLen = 2; if (u8Version == CBA_MRSH_VERSION_DCOM || u8Version == CBA_MRSH_VERSION_SRT_WITH_CONSID) @@ -3045,7 +3050,7 @@ dissect_CBA_Connection_Data(tvbuff_t *tvb, if (sub_tree) { proto_tree_add_item(sub_tree, hf_cba_acco_conn_cons_id, tvb, offset, 4, ENC_LITTLE_ENDIAN); } - offset += 4; + offset += 4; u16HdrLen += 4; } else { u32ID = 0; @@ -3056,7 +3061,7 @@ dissect_CBA_Connection_Data(tvbuff_t *tvb, if (sub_tree) { item = proto_tree_add_item(sub_tree, hf_cba_acco_qc, tvb, offset, 1, ENC_LITTLE_ENDIAN); } - offset += 1; + offset += 1; u16HdrLen += 1; if ( u8QC != 0x80 && /* GoodNonCascOk */ @@ -3167,7 +3172,7 @@ dissect_CBA_Connection_Data_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree * } u8Version = tvb_get_guint8 (tvb, 0); - u8Flags = tvb_get_guint8 (tvb, 1); + u8Flags = tvb_get_guint8 (tvb, 1); /* version and flags must be ok */ if (u8Version != 0x11 || u8Flags != 0x00) { diff --git a/plugins/profinet/packet-dcom-cba-acco.h b/plugins/profinet/packet-dcom-cba-acco.h index 37448d9a35..2d9dc888d3 100644 --- a/plugins/profinet/packet-dcom-cba-acco.h +++ b/plugins/profinet/packet-dcom-cba-acco.h @@ -71,8 +71,10 @@ extern cba_ldev_t * cba_ldev_add(packet_info *pinfo, cba_pdev_t *pdev, const char *name); -/*int +#if 0 +int dissect_CBA_Connection_Data(tvbuff_t *tvb, packet_info *pinfo, - proto_tree *tree, cba_ldev_t *ldev, cba_frame_t *frame);*/ + proto_tree *tree, cba_ldev_t *ldev, cba_frame_t *frame); +#endif #endif /* packet-dcerpc-dcom-cba-acco.h */ diff --git a/plugins/profinet/packet-dcom-cba.c b/plugins/profinet/packet-dcom-cba.c index ad95f6ebee..b89d791f48 100644 --- a/plugins/profinet/packet-dcom-cba.c +++ b/plugins/profinet/packet-dcom-cba.c @@ -173,33 +173,33 @@ static gint ett_PBAddress = -1; static const value_string cba_state_vals[] = { - { 0x00, "NonExistent" }, - { 0x01, "Initializing" }, - { 0x02, "Ready" }, - { 0x03, "Operating" }, - { 0x04, "Defect" }, + { 0x00, "NonExistent" }, + { 0x01, "Initializing" }, + { 0x02, "Ready" }, + { 0x03, "Operating" }, + { 0x04, "Defect" }, { 0, NULL } }; static const value_string cba_grouperror_vals[] = { - { 0x00, "NonAccessible" }, - { 0x01, "Okay" }, - { 0x02, "Problem" }, - { 0x03, "Unknown" }, - { 0x04, "MaintenanceRequired" }, - { 0x05, "MaintenanceDemanded" }, - { 0x06, "MaintenanceRequiredAndDemanded" }, - { 0x07, "ProblemAndMaintenanceRequired" }, - { 0x08, "ProblemAndMaintenanceDemanded" }, - { 0x09, "ProblemAndMaintenanceRequiredAndDemanded" }, + { 0x00, "NonAccessible" }, + { 0x01, "Okay" }, + { 0x02, "Problem" }, + { 0x03, "Unknown" }, + { 0x04, "MaintenanceRequired" }, + { 0x05, "MaintenanceDemanded" }, + { 0x06, "MaintenanceRequiredAndDemanded" }, + { 0x07, "ProblemAndMaintenanceRequired" }, + { 0x08, "ProblemAndMaintenanceDemanded" }, + { 0x09, "ProblemAndMaintenanceRequiredAndDemanded" }, { 0, NULL } }; static const value_string dcom_boolean_vals[] = { - { 0x00, "FALSE" }, - { 0x01, "TRUE" }, - { 0xffff, "TRUE" }, + { 0x00, "FALSE" }, + { 0x01, "TRUE" }, + { 0xffff, "TRUE" }, { 0, NULL } }; @@ -208,400 +208,400 @@ static const value_string dcom_boolean_vals[] = { static int dissect_ICBABrowse_get_Count_resp(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint32 u32Count; - guint32 u32HResult; + guint32 u32Count; + guint32 u32HResult; offset = dissect_dcom_that(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, drep, hf_cba_browse_count, &u32Count); - offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, &u32HResult); - if (u32HResult) { /* !S_OK */ - col_append_fstr(pinfo->cinfo, COL_INFO, "-> %s", - val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); + if (u32HResult) { /* !S_OK */ + col_append_fstr(pinfo->cinfo, COL_INFO, "-> %s", + val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); } else { col_append_fstr(pinfo->cinfo, COL_INFO, " Cnt=%u -> S_OK", u32Count); } - - return offset; + + return offset; } static int dissect_ICBABrowse_BrowseItems_rqst(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint32 u32Offset; - guint32 u32MaxReturn; + guint32 u32Offset; + guint32 u32MaxReturn; offset = dissect_dcom_this(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, drep, hf_cba_browse_offset, &u32Offset); - offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, drep, hf_cba_browse_max_return, &u32MaxReturn); - col_append_fstr(pinfo->cinfo, COL_INFO, " Offset=%u MaxReturn=%u", - u32Offset, u32MaxReturn); + col_append_fstr(pinfo->cinfo, COL_INFO, " Offset=%u MaxReturn=%u", + u32Offset, u32MaxReturn); - return offset; + return offset; } static int dissect_ICBABrowse_BrowseItems_resp(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint32 u32Pointer; - guint32 u32HResult; + guint32 u32Pointer; + guint32 u32HResult; offset = dissect_dcom_that(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, - &u32Pointer); - if (u32Pointer) { - offset = dissect_dcom_VARIANT(tvb, offset, pinfo, tree, drep, hf_cba_browse_item); - } - - offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, - &u32Pointer); - if (u32Pointer) { - offset = dissect_dcom_VARIANT(tvb, offset, pinfo, tree, drep, hf_cba_browse_data_type); - } - - offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, - &u32Pointer); - if (u32Pointer) { - offset = dissect_dcom_VARIANT(tvb, offset, pinfo, tree, drep, hf_cba_browse_access_right); - } - - offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, - &u32HResult); - - col_append_fstr(pinfo->cinfo, COL_INFO, " -> %s", - val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); - - return offset; + offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, + &u32Pointer); + if (u32Pointer) { + offset = dissect_dcom_VARIANT(tvb, offset, pinfo, tree, drep, hf_cba_browse_item); + } + + offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, + &u32Pointer); + if (u32Pointer) { + offset = dissect_dcom_VARIANT(tvb, offset, pinfo, tree, drep, hf_cba_browse_data_type); + } + + offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, + &u32Pointer); + if (u32Pointer) { + offset = dissect_dcom_VARIANT(tvb, offset, pinfo, tree, drep, hf_cba_browse_access_right); + } + + offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, + &u32HResult); + + col_append_fstr(pinfo->cinfo, COL_INFO, " -> %s", + val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); + + return offset; } static int dissect_ICBABrowse2_get_Count2_rqst(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint32 u32Selector; + guint32 u32Selector; offset = dissect_dcom_this(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, drep, hf_cba_browse_selector, &u32Selector); - col_append_fstr(pinfo->cinfo, COL_INFO, " Selector=%u", - u32Selector); + col_append_fstr(pinfo->cinfo, COL_INFO, " Selector=%u", + u32Selector); - return offset; + return offset; } static int dissect_ICBABrowse2_BrowseItems2_rqst(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint32 u32Selector; - guint32 u32Offset; - guint32 u32MaxReturn; + guint32 u32Selector; + guint32 u32Offset; + guint32 u32MaxReturn; offset = dissect_dcom_this(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, drep, hf_cba_browse_selector, &u32Selector); - offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, drep, hf_cba_browse_offset, &u32Offset); - offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, drep, hf_cba_browse_max_return, &u32MaxReturn); - col_append_fstr(pinfo->cinfo, COL_INFO, " Sel=%u Offset=%u MaxReturn=%u", - u32Selector, u32Offset, u32MaxReturn); + col_append_fstr(pinfo->cinfo, COL_INFO, " Sel=%u Offset=%u MaxReturn=%u", + u32Selector, u32Offset, u32MaxReturn); - return offset; + return offset; } static int dissect_ICBABrowse2_BrowseItems2_resp(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint32 u32Pointer; - guint32 u32HResult; + guint32 u32Pointer; + guint32 u32HResult; offset = dissect_dcom_that(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, - &u32Pointer); - if (u32Pointer) { - offset = dissect_dcom_VARIANT(tvb, offset, pinfo, tree, drep, hf_cba_browse_item); - } - - offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, - &u32Pointer); - if (u32Pointer) { - offset = dissect_dcom_VARIANT(tvb, offset, pinfo, tree, drep, hf_cba_browse_info1); - } - - offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, - &u32Pointer); - if (u32Pointer) { - offset = dissect_dcom_VARIANT(tvb, offset, pinfo, tree, drep, hf_cba_browse_info2); - } - - offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, - &u32HResult); - - col_append_fstr(pinfo->cinfo, COL_INFO, " -> %s", - val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); - - return offset; + offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, + &u32Pointer); + if (u32Pointer) { + offset = dissect_dcom_VARIANT(tvb, offset, pinfo, tree, drep, hf_cba_browse_item); + } + + offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, + &u32Pointer); + if (u32Pointer) { + offset = dissect_dcom_VARIANT(tvb, offset, pinfo, tree, drep, hf_cba_browse_info1); + } + + offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, + &u32Pointer); + if (u32Pointer) { + offset = dissect_dcom_VARIANT(tvb, offset, pinfo, tree, drep, hf_cba_browse_info2); + } + + offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, + &u32HResult); + + col_append_fstr(pinfo->cinfo, COL_INFO, " -> %s", + val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); + + return offset; } static int dissect_ICBAPersist2_Save2_resp(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint32 u32Pointer; - guint32 u32HResult; + guint32 u32Pointer; + guint32 u32HResult; offset = dissect_dcom_that(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, - &u32Pointer); - if (u32Pointer) { - offset = dissect_dcom_VARIANT(tvb, offset, pinfo, tree, drep, hf_cba_save_ldev_name); - } - - offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, - &u32Pointer); - if (u32Pointer) { - offset = dissect_dcom_VARIANT(tvb, offset, pinfo, tree, drep, hf_cba_save_result); - } - - offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, - &u32HResult); - - col_append_fstr(pinfo->cinfo, COL_INFO, " -> %s", - val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); - - return offset; + offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, + &u32Pointer); + if (u32Pointer) { + offset = dissect_dcom_VARIANT(tvb, offset, pinfo, tree, drep, hf_cba_save_ldev_name); + } + + offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, + &u32Pointer); + if (u32Pointer) { + offset = dissect_dcom_VARIANT(tvb, offset, pinfo, tree, drep, hf_cba_save_result); + } + + offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, + &u32HResult); + + col_append_fstr(pinfo->cinfo, COL_INFO, " -> %s", + val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); + + return offset; } static int dissect_get_BSTR_resp(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep, int hfindex) + packet_info *pinfo, proto_tree *tree, guint8 *drep, int hfindex) { - gchar szStr[1000]; - guint32 u32MaxStr = sizeof(szStr); - guint32 u32Pointer; - guint32 u32HResult; + gchar szStr[1000]; + guint32 u32MaxStr = sizeof(szStr); + guint32 u32Pointer; + guint32 u32HResult; offset = dissect_dcom_that(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, - &u32Pointer); - if (u32Pointer) { - offset = dissect_dcom_BSTR(tvb, offset, pinfo, tree, drep, - hfindex, szStr, u32MaxStr); - } - - offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, - &u32HResult); + offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, + &u32Pointer); + if (u32Pointer) { + offset = dissect_dcom_BSTR(tvb, offset, pinfo, tree, drep, + hfindex, szStr, u32MaxStr); + } + + offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, + &u32HResult); - col_append_fstr(pinfo->cinfo, COL_INFO, ": \"%s\" -> %s", szStr, - val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); + col_append_fstr(pinfo->cinfo, COL_INFO, ": \"%s\" -> %s", szStr, + val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); - return offset; + return offset; } static int dissect_get_ProductionDate_resp(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint32 u32HResult; - gdouble r8Date; + guint32 u32HResult; + gdouble r8Date; offset = dissect_dcom_that(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_DATE(tvb, offset, pinfo, tree, drep, - hf_cba_production_date, &r8Date); - - offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, - &u32HResult); + offset = dissect_dcom_DATE(tvb, offset, pinfo, tree, drep, + hf_cba_production_date, &r8Date); - col_append_fstr(pinfo->cinfo, COL_INFO, ": Date: %g -> %s", - r8Date, - val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); + offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, + &u32HResult); - return offset; + col_append_fstr(pinfo->cinfo, COL_INFO, ": Date: %g -> %s", + r8Date, + val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); + + return offset; } static int dissect_get_SerialNo_resp(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint32 u32HResult; - guint32 u32Pointer; + guint32 u32HResult; + guint32 u32Pointer; offset = dissect_dcom_that(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, - &u32Pointer); - if (u32Pointer) { - offset = dissect_dcom_VARIANT(tvb, offset, pinfo, tree, drep, - hf_cba_serial_no); - } - - offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, - &u32HResult); + offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, + &u32Pointer); + if (u32Pointer) { + offset = dissect_dcom_VARIANT(tvb, offset, pinfo, tree, drep, + hf_cba_serial_no); + } + + offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, + &u32HResult); - col_append_fstr(pinfo->cinfo, COL_INFO, " -> %s", - val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); + col_append_fstr(pinfo->cinfo, COL_INFO, " -> %s", + val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); - return offset; + return offset; } static int dissect_ICBATime_get_Time_resp(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint32 u32HResult; - gdouble r8Date; + guint32 u32HResult; + gdouble r8Date; offset = dissect_dcom_that(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_DATE(tvb, offset, pinfo, tree, drep, - hf_cba_time, &r8Date); - - offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, - &u32HResult); + offset = dissect_dcom_DATE(tvb, offset, pinfo, tree, drep, + hf_cba_time, &r8Date); - col_append_fstr(pinfo->cinfo, COL_INFO, ": Time: %g -> %s", - r8Date, - val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); + offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, + &u32HResult); - return offset; + col_append_fstr(pinfo->cinfo, COL_INFO, ": Time: %g -> %s", + r8Date, + val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); + + return offset; } static int dissect_ICBATime_put_Time_rqst(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - gdouble r8Date; + gdouble r8Date; offset = dissect_dcom_this(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_DATE(tvb, offset, pinfo, tree, drep, - hf_cba_time, &r8Date); - - return offset; + offset = dissect_dcom_DATE(tvb, offset, pinfo, tree, drep, + hf_cba_time, &r8Date); + + return offset; } static int dissect_get_Producer_resp(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - return dissect_get_BSTR_resp(tvb, offset, pinfo, tree, drep, hf_cba_producer); + return dissect_get_BSTR_resp(tvb, offset, pinfo, tree, drep, hf_cba_producer); } static int dissect_get_Product_resp(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - return dissect_get_BSTR_resp(tvb, offset, pinfo, tree, drep, hf_cba_product); + return dissect_get_BSTR_resp(tvb, offset, pinfo, tree, drep, hf_cba_product); } static int dissect_ICBAPhysicalDevice_get_LogicalDevice_rqst(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint32 u32Pointer; - gchar szStr[1000]; - guint32 u32MaxStr = sizeof(szStr); - dcerpc_info *info = (dcerpc_info *) pinfo->private_data; - gchar *call; + guint32 u32Pointer; + gchar szStr[1000]; + guint32 u32MaxStr = sizeof(szStr); + dcerpc_info *info = (dcerpc_info *) pinfo->private_data; + gchar *call; offset = dissect_dcom_this(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, - &u32Pointer); - if (u32Pointer) { - offset = dissect_dcom_BSTR(tvb, offset, pinfo, tree, drep, - hf_cba_name, szStr, u32MaxStr); - } + offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, + &u32Pointer); + if (u32Pointer) { + offset = dissect_dcom_BSTR(tvb, offset, pinfo, tree, drep, + hf_cba_name, szStr, u32MaxStr); + } - if(strlen(szStr) > 0) { + if (strlen(szStr) > 0) { call = se_strdup(szStr); info->call_data->private_data = call; } col_append_fstr(pinfo->cinfo, COL_INFO, ": \"%s\"", szStr); - return offset; + return offset; } static int dissect_ICBAPhysicalDevice_get_LogicalDevice_resp(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint32 u32HResult; - dcerpc_info *info = (dcerpc_info *) pinfo->private_data; - gchar *ldev_name = info->call_data->private_data; + guint32 u32HResult; + dcerpc_info *info = (dcerpc_info *) pinfo->private_data; + gchar *ldev_name = info->call_data->private_data; dcom_interface_t *pdev_interf; dcom_interface_t *ldev_interf; - cba_pdev_t *pdev; - cba_ldev_t *ldev; + cba_pdev_t *pdev; + cba_ldev_t *ldev; offset = dissect_dcom_that(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_PMInterfacePointer(tvb, offset, pinfo, tree, drep, 0, &ldev_interf); + offset = dissect_dcom_PMInterfacePointer(tvb, offset, pinfo, tree, drep, 0, &ldev_interf); /* try to read the ldev name from the request */ - if(ldev_name != NULL && ldev_interf != NULL) { + if (ldev_name != NULL && ldev_interf != NULL) { /* XXX - this is a hack to create a pdev interface */ /* as I currently don't understand the objref process for a root interface! */ - pdev_interf = dcom_interface_new(pinfo, pinfo->net_dst.data, &uuid_ICBAPhysicalDevice, 0, 0, &info->call_data->object_uuid); - if(pdev_interf != NULL) { + pdev_interf = dcom_interface_new(pinfo, pinfo->net_dst.data, &uuid_ICBAPhysicalDevice, 0, 0, &info->call_data->object_uuid); + if (pdev_interf != NULL) { pdev = cba_pdev_add(pinfo, pinfo->net_dst.data); cba_pdev_link(pinfo, pdev, pdev_interf); @@ -610,308 +610,308 @@ dissect_ICBAPhysicalDevice_get_LogicalDevice_resp(tvbuff_t *tvb, int offset, } } - offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, - &u32HResult); + offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, + &u32HResult); - col_append_fstr(pinfo->cinfo, COL_INFO, " -> %s", - val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); + col_append_fstr(pinfo->cinfo, COL_INFO, " -> %s", + val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); - return offset; + return offset; } static int dissect_ICBAPhysicalDevice2_Type_resp(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint16 u16MultiApp; - guint16 u16PROFInetDCOMStack; - guint32 u32HResult; + guint16 u16MultiApp; + guint16 u16PROFInetDCOMStack; + guint32 u32HResult; offset = dissect_dcom_that(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_VARIANT_BOOL(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_VARIANT_BOOL(tvb, offset, pinfo, tree, drep, hf_cba_multi_app, &u16MultiApp); - offset = dissect_dcom_VARIANT_BOOL(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_VARIANT_BOOL(tvb, offset, pinfo, tree, drep, hf_cba_profinet_dcom_stack, &u16PROFInetDCOMStack); - offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, - &u32HResult); + offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, + &u32HResult); - col_append_fstr(pinfo->cinfo, COL_INFO, " App=%s Stack=%s -> %s", - (u16MultiApp) ? "Multi" : "Single", - (u16PROFInetDCOMStack) ? "PN-DCOM" : "MS-DCOM", - val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); + col_append_fstr(pinfo->cinfo, COL_INFO, " App=%s Stack=%s -> %s", + (u16MultiApp) ? "Multi" : "Single", + (u16PROFInetDCOMStack) ? "PN-DCOM" : "MS-DCOM", + val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); - return offset; + return offset; } static int dissect_PROFInetRevision_resp(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint16 u16Major; - guint16 u16Minor; - guint16 u16ServicePack; - guint16 u16Build; - guint32 u32HResult; + guint16 u16Major; + guint16 u16Minor; + guint16 u16ServicePack; + guint16 u16Build; + guint32 u32HResult; offset = dissect_dcom_that(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, drep, hf_cba_revision_major, &u16Major); - offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, drep, hf_cba_revision_minor, &u16Minor); - offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, drep, hf_cba_revision_service_pack, &u16ServicePack); - offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, drep, hf_cba_revision_build, &u16Build); - offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, - &u32HResult); + offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, + &u32HResult); - col_append_fstr(pinfo->cinfo, COL_INFO, " Revision=%u.%u.%u.%u -> %s", - u16Major, u16Minor, u16ServicePack, u16Build, - val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); + col_append_fstr(pinfo->cinfo, COL_INFO, " Revision=%u.%u.%u.%u -> %s", + u16Major, u16Minor, u16ServicePack, u16Build, + val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); - return offset; + return offset; } static int dissect_ICBAPhysicalDevice2_get_PDevStamp_resp(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint32 u32PDevStamp; - guint32 u32HResult; + guint32 u32PDevStamp; + guint32 u32HResult; offset = dissect_dcom_that(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, drep, hf_cba_pdev_stamp, &u32PDevStamp); - offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, - &u32HResult); + offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, + &u32HResult); - col_append_fstr(pinfo->cinfo, COL_INFO, " PDevStamp=0x%x -> %s", - u32PDevStamp, - val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); + col_append_fstr(pinfo->cinfo, COL_INFO, " PDevStamp=0x%x -> %s", + u32PDevStamp, + val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); - return offset; + return offset; } static int dissect_Revision_resp(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint16 u16Major; - guint16 u16Minor; - guint32 u32HResult; + guint16 u16Major; + guint16 u16Minor; + guint32 u32HResult; offset = dissect_dcom_that(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, drep, hf_cba_revision_major, &u16Major); - offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, drep, hf_cba_revision_minor, &u16Minor); - offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, - &u32HResult); + offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, + &u32HResult); - col_append_fstr(pinfo->cinfo, COL_INFO, ": %u.%u -> %s", - u16Major, u16Minor, - val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); + col_append_fstr(pinfo->cinfo, COL_INFO, ": %u.%u -> %s", + u16Major, u16Minor, + val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); - return offset; + return offset; } static int dissect_ICBALogicalDevice_get_Name_resp(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - gchar szStr[1000]; - guint32 u32MaxStr = sizeof(szStr); - guint32 u32Pointer; - guint32 u32HResult; + gchar szStr[1000]; + guint32 u32MaxStr = sizeof(szStr); + guint32 u32Pointer; + guint32 u32HResult; offset = dissect_dcom_that(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, - &u32Pointer); - if (u32Pointer) { - offset = dissect_dcom_BSTR(tvb, offset, pinfo, tree, drep, - hf_cba_name, szStr, u32MaxStr); - } - - offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, - &u32HResult); + offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, + &u32Pointer); + if (u32Pointer) { + offset = dissect_dcom_BSTR(tvb, offset, pinfo, tree, drep, + hf_cba_name, szStr, u32MaxStr); + } + + offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, + &u32HResult); - col_append_fstr(pinfo->cinfo, COL_INFO, ": \"%s\" -> %s", szStr, - val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); + col_append_fstr(pinfo->cinfo, COL_INFO, ": \"%s\" -> %s", szStr, + val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); - return offset; + return offset; } static int dissect_RTAuto_get_Name_resp(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - return dissect_get_BSTR_resp(tvb, offset, pinfo, tree, drep, hf_cba_name); + return dissect_get_BSTR_resp(tvb, offset, pinfo, tree, drep, hf_cba_name); } static int dissect_ICBALogicalDevice_get_ACCO_resp(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint32 u32HResult; + guint32 u32HResult; dcom_interface_t *acco_interf; - dcerpc_info *info = (dcerpc_info *) pinfo->private_data; - cba_ldev_t *ldev; + dcerpc_info *info = (dcerpc_info *) pinfo->private_data; + cba_ldev_t *ldev; offset = dissect_dcom_that(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_PMInterfacePointer(tvb, offset, pinfo, tree, drep, 0, &acco_interf); - if(acco_interf == NULL) { - expert_add_info_format(pinfo, NULL, PI_UNDECODED, PI_WARN, + offset = dissect_dcom_PMInterfacePointer(tvb, offset, pinfo, tree, drep, 0, &acco_interf); + if (acco_interf == NULL) { + expert_add_info_format(pinfo, NULL, PI_UNDECODED, PI_WARN, "LDev_get_ACCO: can't resolve ACCO interface pointer"); } ldev = cba_ldev_find(pinfo, pinfo->net_src.data, &info->call_data->object_uuid); - + /* "crosslink" interface and it's object */ - if(ldev != NULL && acco_interf != NULL) { + if (ldev != NULL && acco_interf != NULL) { cba_ldev_link_acco(pinfo, ldev, acco_interf); } - offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, &u32HResult); + offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, &u32HResult); - col_append_fstr(pinfo->cinfo, COL_INFO, " -> %s", - val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); + col_append_fstr(pinfo->cinfo, COL_INFO, " -> %s", + val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); - return offset; + return offset; } static int dissect_ICBALogicalDevice_get_RTAuto_resp(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint32 u32HResult; + guint32 u32HResult; offset = dissect_dcom_that(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_PMInterfacePointer(tvb, offset, pinfo, tree, drep, 0, NULL); + offset = dissect_dcom_PMInterfacePointer(tvb, offset, pinfo, tree, drep, 0, NULL); - offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, &u32HResult); + offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, &u32HResult); - col_append_fstr(pinfo->cinfo, COL_INFO, " -> %s", - val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); + col_append_fstr(pinfo->cinfo, COL_INFO, " -> %s", + val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); - return offset; + return offset; } static int dissect_ICBALogicalDevice_Get_RTAuto_rqst(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - gchar szStr[1000]; - guint32 u32MaxStr = sizeof(szStr); - guint32 u32Pointer; + gchar szStr[1000]; + guint32 u32MaxStr = sizeof(szStr); + guint32 u32Pointer; offset = dissect_dcom_this(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, - &u32Pointer); - if (u32Pointer) { - offset = dissect_dcom_BSTR(tvb, offset, pinfo, tree, drep, - hf_cba_name, szStr, u32MaxStr); - } - - col_append_fstr(pinfo->cinfo, COL_INFO, ": \"%s\"", szStr); + offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, + &u32Pointer); + if (u32Pointer) { + offset = dissect_dcom_BSTR(tvb, offset, pinfo, tree, drep, + hf_cba_name, szStr, u32MaxStr); + } - return offset; + col_append_fstr(pinfo->cinfo, COL_INFO, ": \"%s\"", szStr); + + return offset; } static int dissect_ComponentInfo_resp(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - gchar szStr[1000]; - guint32 u32MaxStr = sizeof(szStr); - gchar szStr2[1000]; - guint32 u32MaxStr2 = sizeof(szStr2); - guint32 u32HResult; - guint32 u32Pointer; + gchar szStr[1000]; + guint32 u32MaxStr = sizeof(szStr); + gchar szStr2[1000]; + guint32 u32MaxStr2 = sizeof(szStr2); + guint32 u32HResult; + guint32 u32Pointer; offset = dissect_dcom_that(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, - &u32Pointer); - if (u32Pointer) { - offset = dissect_dcom_BSTR(tvb, offset, pinfo, tree, drep, - hf_cba_component_id, szStr, u32MaxStr); - } - - offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, - &u32Pointer); - if (u32Pointer) { - offset = dissect_dcom_BSTR(tvb, offset, pinfo, tree, drep, - hf_cba_component_version, szStr2, u32MaxStr2); - } - - offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, &u32HResult); - - col_append_fstr(pinfo->cinfo, COL_INFO, ": ID=\"%s\" Version=\"%s\" -> %s", - szStr, szStr2, - val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); - - return offset; + offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, + &u32Pointer); + if (u32Pointer) { + offset = dissect_dcom_BSTR(tvb, offset, pinfo, tree, drep, + hf_cba_component_id, szStr, u32MaxStr); + } + + offset = dissect_dcom_dcerpc_pointer(tvb, offset, pinfo, tree, drep, + &u32Pointer); + if (u32Pointer) { + offset = dissect_dcom_BSTR(tvb, offset, pinfo, tree, drep, + hf_cba_component_version, szStr2, u32MaxStr2); + } + + offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, &u32HResult); + + col_append_fstr(pinfo->cinfo, COL_INFO, ": ID=\"%s\" Version=\"%s\" -> %s", + szStr, szStr2, + val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); + + return offset; } -static void +static void dissect_PBAddressInfo(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, guint32 u32VarType _U_, guint32 u32ArraySize) { - guint8 u8ID; - guint8 u8Addr; + guint8 u8ID; + guint8 u8Addr; proto_item *sub_item; proto_tree *sub_tree; - while(u32ArraySize != 0) { - sub_item = proto_tree_add_item(tree, hf_cba_pbaddress, tvb, offset, 2, ENC_NA); - sub_tree = proto_item_add_subtree(sub_item, ett_PBAddress); - - offset = dissect_dcom_BYTE(tvb, offset, pinfo, sub_tree, drep, - hf_cba_pbaddress_system_id, &u8ID); - offset = dissect_dcom_BYTE(tvb, offset, pinfo, sub_tree, drep, - hf_cba_pbaddress_address, &u8Addr); + while (u32ArraySize != 0) { + sub_item = proto_tree_add_item(tree, hf_cba_pbaddress, tvb, offset, 2, ENC_NA); + sub_tree = proto_item_add_subtree(sub_item, ett_PBAddress); + + offset = dissect_dcom_BYTE(tvb, offset, pinfo, sub_tree, drep, + hf_cba_pbaddress_system_id, &u8ID); + offset = dissect_dcom_BYTE(tvb, offset, pinfo, sub_tree, drep, + hf_cba_pbaddress_address, &u8Addr); u32ArraySize-=2; proto_item_append_text(sub_item, ": ID=0x%x Addr=%u", u8ID, u8Addr); - col_append_fstr(pinfo->cinfo, COL_INFO, ", ID=0x%x Addr=%u", + col_append_fstr(pinfo->cinfo, COL_INFO, ", ID=0x%x Addr=%u", u8ID, u8Addr); } } @@ -919,7 +919,7 @@ dissect_PBAddressInfo(tvbuff_t *tvb, gint offset, packet_info *pinfo, static int dissect_PBAddressInfo_resp(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { guint32 u32HResult; @@ -929,8 +929,8 @@ dissect_PBAddressInfo_resp(tvbuff_t *tvb, int offset, offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, &u32HResult); - col_append_fstr(pinfo->cinfo, COL_INFO, " -> %s", - val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); + col_append_fstr(pinfo->cinfo, COL_INFO, " -> %s", + val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); return offset; } @@ -938,229 +938,229 @@ dissect_PBAddressInfo_resp(tvbuff_t *tvb, int offset, static int dissect_Advise_rqst(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { offset = dissect_dcom_this(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_PMInterfacePointer(tvb, offset, pinfo, tree, drep, 0, NULL); + offset = dissect_dcom_PMInterfacePointer(tvb, offset, pinfo, tree, drep, 0, NULL); - return offset; + return offset; } static int dissect_Advise_resp(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint32 u32Cookie; - guint32 u32HResult; + guint32 u32Cookie; + guint32 u32HResult; offset = dissect_dcom_that(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, drep, hf_cba_cookie, &u32Cookie); - offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, &u32HResult); - col_append_fstr(pinfo->cinfo, COL_INFO, ": Cookie=0x%x -> %s", - u32Cookie, - val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); + col_append_fstr(pinfo->cinfo, COL_INFO, ": Cookie=0x%x -> %s", + u32Cookie, + val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); - return offset; + return offset; } static int dissect_Unadvise_rqst(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint32 u32Cookie; + guint32 u32Cookie; offset = dissect_dcom_this(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, drep, hf_cba_cookie, &u32Cookie); - col_append_fstr(pinfo->cinfo, COL_INFO, ": Cookie=0x%x", - u32Cookie); + col_append_fstr(pinfo->cinfo, COL_INFO, ": Cookie=0x%x", + u32Cookie); - return offset; + return offset; } static int dissect_ICBAState_get_State_resp(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint16 u16State; - guint32 u32HResult; + guint16 u16State; + guint32 u32HResult; offset = dissect_dcom_that(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, drep, hf_cba_state, &u16State); - offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, &u32HResult); - col_append_fstr(pinfo->cinfo, COL_INFO, ": State=%s -> %s", - val_to_str(u16State, cba_state_vals, "Unknown (0x%08x)"), - val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); + col_append_fstr(pinfo->cinfo, COL_INFO, ": State=%s -> %s", + val_to_str(u16State, cba_state_vals, "Unknown (0x%08x)"), + val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); - return offset; + return offset; } static int dissect_ICBAStateEvent_OnStateChanged_rqst(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint16 u16NewState; - guint16 u16OldState; + guint16 u16NewState; + guint16 u16OldState; offset = dissect_dcom_this(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, drep, hf_cba_new_state, &u16NewState); - offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, drep, hf_cba_old_state, &u16OldState); - col_append_fstr(pinfo->cinfo, COL_INFO, ": NewState=%s OldState=%s", - val_to_str(u16NewState, cba_state_vals, "Unknown (0x%04x)"), - val_to_str(u16OldState, cba_state_vals, "Unknown (0x%04x)") ); + col_append_fstr(pinfo->cinfo, COL_INFO, ": NewState=%s OldState=%s", + val_to_str(u16NewState, cba_state_vals, "Unknown (0x%04x)"), + val_to_str(u16OldState, cba_state_vals, "Unknown (0x%04x)") ); - return offset; + return offset; } static int dissect_ICBAGroupError_OnGroupErrorChanged_rqst(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint16 u16NewGroupError; - guint16 u16OldGroupError; + guint16 u16NewGroupError; + guint16 u16OldGroupError; offset = dissect_dcom_this(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, drep, hf_cba_new_grouperror, &u16NewGroupError); - offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, drep, hf_cba_old_grouperror, &u16OldGroupError); - col_append_fstr(pinfo->cinfo, COL_INFO, ": NewGE=%s OldGE=%s", - val_to_str(u16NewGroupError, cba_grouperror_vals, "Unknown (0x%04x)"), - val_to_str(u16OldGroupError, cba_grouperror_vals, "Unknown (0x%04x)") ); + col_append_fstr(pinfo->cinfo, COL_INFO, ": NewGE=%s OldGE=%s", + val_to_str(u16NewGroupError, cba_grouperror_vals, "Unknown (0x%04x)"), + val_to_str(u16OldGroupError, cba_grouperror_vals, "Unknown (0x%04x)") ); - return offset; + return offset; } static int dissect_ICBAPhysicalDevicePCEvent_OnLogicalDeviceAdded_rqst(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint32 u32Cookie; - guint32 u32HResult; + guint32 u32Cookie; + guint32 u32HResult; offset = dissect_dcom_this(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, drep, hf_cba_cookie, &u32Cookie); - offset = dissect_dcom_PMInterfacePointer(tvb, offset, pinfo, tree, drep, 0, NULL); + offset = dissect_dcom_PMInterfacePointer(tvb, offset, pinfo, tree, drep, 0, NULL); - offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, &u32HResult); - col_append_fstr(pinfo->cinfo, COL_INFO, ": Cookie=0x%x %s", - u32Cookie, - val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); + col_append_fstr(pinfo->cinfo, COL_INFO, ": Cookie=0x%x %s", + u32Cookie, + val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); - return offset; + return offset; } static int dissect_ICBAGroupError_GroupError_resp(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, guint8 *drep) + packet_info *pinfo, proto_tree *tree, guint8 *drep) { - guint16 u16GroupError; - guint32 u32Cookie; - guint32 u32HResult; + guint16 u16GroupError; + guint32 u32Cookie; + guint32 u32HResult; offset = dissect_dcom_that(tvb, offset, pinfo, tree, drep); - offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_WORD(tvb, offset, pinfo, tree, drep, hf_cba_grouperror, &u16GroupError); - offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_DWORD(tvb, offset, pinfo, tree, drep, hf_cba_cookie, &u32Cookie); - offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, + offset = dissect_dcom_HRESULT(tvb, offset, pinfo, tree, drep, &u32HResult); - col_append_fstr(pinfo->cinfo, COL_INFO, ": GroupError=%s Cookie=0x%x -> %s", - val_to_str(u16GroupError, cba_grouperror_vals, "Unknown (0x%08x)"), - u32Cookie, - val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); + col_append_fstr(pinfo->cinfo, COL_INFO, ": GroupError=%s Cookie=0x%x -> %s", + val_to_str(u16GroupError, cba_grouperror_vals, "Unknown (0x%08x)"), + u32Cookie, + val_to_str(u32HResult, dcom_hresult_vals, "Unknown (0x%08x)") ); - return offset; + return offset; } /* sub dissector table of ICBAPhysicalDevice / ICBAPhysicalDevice2 interface */ static dcerpc_sub_dissector ICBAPhysicalDevice_dissectors[] = { { 0, "QueryInterface", NULL, NULL }, - { 1, "AddRef", NULL, NULL }, - { 2, "Release", NULL, NULL }, - - { 3, "GetTypeInfoCount", dissect_dcom_simple_rqst, dissect_IDispatch_GetTypeInfoCount_resp }, - { 4, "GetTypeInfo", dissect_IDispatch_GetTypeInfo_rqst, dissect_IDispatch_GetTypeInfo_resp }, - { 5, "GetIDsOfNames", dissect_IDispatch_GetIDsOfNames_rqst, dissect_IDispatch_GetIDsOfNames_resp }, - { 6, "Invoke", dissect_IDispatch_Invoke_rqst, dissect_IDispatch_Invoke_resp }, - - { 7, "get_Producer", dissect_dcom_simple_rqst, dissect_get_Producer_resp }, - { 8, "get_Product", dissect_dcom_simple_rqst, dissect_get_Product_resp }, - { 9, "get_SerialNo", dissect_dcom_simple_rqst, dissect_get_SerialNo_resp }, - {10, "get_ProductionDate", dissect_dcom_simple_rqst, dissect_get_ProductionDate_resp }, - {11, "Revision", dissect_dcom_simple_rqst, dissect_Revision_resp }, - {12, "get_LogicalDevice", dissect_ICBAPhysicalDevice_get_LogicalDevice_rqst, dissect_ICBAPhysicalDevice_get_LogicalDevice_resp }, - /* stage 2 */ - {13, "Type", dissect_dcom_simple_rqst, dissect_ICBAPhysicalDevice2_Type_resp }, - {14, "PROFInetRevision", dissect_dcom_simple_rqst, dissect_PROFInetRevision_resp }, - {15, "PDevStamp", dissect_dcom_simple_rqst, dissect_ICBAPhysicalDevice2_get_PDevStamp_resp }, - { 0, NULL, NULL, NULL }, + { 1, "AddRef", NULL, NULL }, + { 2, "Release", NULL, NULL }, + + { 3, "GetTypeInfoCount", dissect_dcom_simple_rqst, dissect_IDispatch_GetTypeInfoCount_resp }, + { 4, "GetTypeInfo", dissect_IDispatch_GetTypeInfo_rqst, dissect_IDispatch_GetTypeInfo_resp }, + { 5, "GetIDsOfNames", dissect_IDispatch_GetIDsOfNames_rqst, dissect_IDispatch_GetIDsOfNames_resp }, + { 6, "Invoke", dissect_IDispatch_Invoke_rqst, dissect_IDispatch_Invoke_resp }, + + { 7, "get_Producer", dissect_dcom_simple_rqst, dissect_get_Producer_resp }, + { 8, "get_Product", dissect_dcom_simple_rqst, dissect_get_Product_resp }, + { 9, "get_SerialNo", dissect_dcom_simple_rqst, dissect_get_SerialNo_resp }, + {10, "get_ProductionDate", dissect_dcom_simple_rqst, dissect_get_ProductionDate_resp }, + {11, "Revision", dissect_dcom_simple_rqst, dissect_Revision_resp }, + {12, "get_LogicalDevice", dissect_ICBAPhysicalDevice_get_LogicalDevice_rqst, dissect_ICBAPhysicalDevice_get_LogicalDevice_resp }, + /* stage 2 */ + {13, "Type", dissect_dcom_simple_rqst, dissect_ICBAPhysicalDevice2_Type_resp }, + {14, "PROFInetRevision", dissect_dcom_simple_rqst, dissect_PROFInetRevision_resp }, + {15, "PDevStamp", dissect_dcom_simple_rqst, dissect_ICBAPhysicalDevice2_get_PDevStamp_resp }, + { 0, NULL, NULL, NULL }, }; /* sub dissector table of ICBABrowse / ICBABrowse2 interface */ static dcerpc_sub_dissector ICBABrowse_dissectors[] = { { 0, "QueryInterface", NULL, NULL }, - { 1, "AddRef", NULL, NULL }, - { 2, "Release", NULL, NULL }, - - { 3, "GetTypeInfoCount", dissect_dcom_simple_rqst, dissect_IDispatch_GetTypeInfoCount_resp }, - { 4, "GetTypeInfo", dissect_IDispatch_GetTypeInfo_rqst, dissect_IDispatch_GetTypeInfo_resp }, - { 5, "GetIDsOfNames", dissect_IDispatch_GetIDsOfNames_rqst, dissect_IDispatch_GetIDsOfNames_resp }, - { 6, "Invoke", dissect_IDispatch_Invoke_rqst, dissect_IDispatch_Invoke_resp }, - - { 7, "get_Count", dissect_dcom_simple_rqst, dissect_ICBABrowse_get_Count_resp }, - { 8, "BrowseItems", dissect_ICBABrowse_BrowseItems_rqst, dissect_ICBABrowse_BrowseItems_resp }, - /* stage 2 */ - { 9, "get_Count2", dissect_ICBABrowse2_get_Count2_rqst, dissect_ICBABrowse_get_Count_resp }, - {10, "BrowseItems2", dissect_ICBABrowse2_BrowseItems2_rqst, dissect_ICBABrowse2_BrowseItems2_resp }, + { 1, "AddRef", NULL, NULL }, + { 2, "Release", NULL, NULL }, + + { 3, "GetTypeInfoCount", dissect_dcom_simple_rqst, dissect_IDispatch_GetTypeInfoCount_resp }, + { 4, "GetTypeInfo", dissect_IDispatch_GetTypeInfo_rqst, dissect_IDispatch_GetTypeInfo_resp }, + { 5, "GetIDsOfNames", dissect_IDispatch_GetIDsOfNames_rqst, dissect_IDispatch_GetIDsOfNames_resp }, + { 6, "Invoke", dissect_IDispatch_Invoke_rqst, dissect_IDispatch_Invoke_resp }, + + { 7, "get_Count", dissect_dcom_simple_rqst, dissect_ICBABrowse_get_Count_resp }, + { 8, "BrowseItems", dissect_ICBABrowse_BrowseItems_rqst, dissect_ICBABrowse_BrowseItems_resp }, + /* stage 2 */ + { 9, "get_Count2", dissect_ICBABrowse2_get_Count2_rqst, dissect_ICBABrowse_get_Count_resp }, + {10, "BrowseItems2", dissect_ICBABrowse2_BrowseItems2_rqst, dissect_ICBABrowse2_BrowseItems2_resp }, { 0, NULL, NULL, NULL }, }; @@ -1168,17 +1168,17 @@ static dcerpc_sub_dissector ICBABrowse_dissectors[] = { /* sub dissector table of ICBAPersist / ICBAPersist2 interface */ static dcerpc_sub_dissector ICBAPersist_dissectors[] = { { 0, "QueryInterface", NULL, NULL }, - { 1, "AddRef", NULL, NULL }, - { 2, "Release", NULL, NULL }, + { 1, "AddRef", NULL, NULL }, + { 2, "Release", NULL, NULL }, - { 3, "GetTypeInfoCount", dissect_dcom_simple_rqst, dissect_IDispatch_GetTypeInfoCount_resp }, - { 4, "GetTypeInfo", dissect_IDispatch_GetTypeInfo_rqst, dissect_IDispatch_GetTypeInfo_resp }, - { 5, "GetIDsOfNames", dissect_IDispatch_GetIDsOfNames_rqst, dissect_IDispatch_GetIDsOfNames_resp }, - { 6, "Invoke", dissect_IDispatch_Invoke_rqst, dissect_IDispatch_Invoke_resp }, + { 3, "GetTypeInfoCount", dissect_dcom_simple_rqst, dissect_IDispatch_GetTypeInfoCount_resp }, + { 4, "GetTypeInfo", dissect_IDispatch_GetTypeInfo_rqst, dissect_IDispatch_GetTypeInfo_resp }, + { 5, "GetIDsOfNames", dissect_IDispatch_GetIDsOfNames_rqst, dissect_IDispatch_GetIDsOfNames_resp }, + { 6, "Invoke", dissect_IDispatch_Invoke_rqst, dissect_IDispatch_Invoke_resp }, - { 7, "Save", dissect_dcom_simple_rqst, dissect_dcom_simple_resp }, - /* stage 2 */ - { 8, "Save2", dissect_dcom_simple_rqst, dissect_ICBAPersist2_Save2_resp }, + { 7, "Save", dissect_dcom_simple_rqst, dissect_dcom_simple_resp }, + /* stage 2 */ + { 8, "Save2", dissect_dcom_simple_rqst, dissect_ICBAPersist2_Save2_resp }, { 0, NULL, NULL, NULL }, }; @@ -1187,17 +1187,17 @@ static dcerpc_sub_dissector ICBAPersist_dissectors[] = { /* (local COM interface, not to be called over network) */ static dcerpc_sub_dissector ICBAPhysicalDevicePC_dissectors[] = { { 0, "QueryInterface", NULL, NULL }, - { 1, "AddRef", NULL, NULL }, - { 2, "Release", NULL, NULL }, + { 1, "AddRef", NULL, NULL }, + { 2, "Release", NULL, NULL }, - { 3, "AddLogicalDevice", dissect_Advise_rqst, dissect_Advise_resp }, + { 3, "AddLogicalDevice", dissect_Advise_rqst, dissect_Advise_resp }, { 4, "RemoveLogicalDevice", dissect_Unadvise_rqst, dissect_dcom_simple_resp }, - { 5, "AdvisePDevPC", dissect_Advise_rqst, dissect_Advise_resp }, - { 6, "UnadvisePDevPC", dissect_Unadvise_rqst, dissect_dcom_simple_resp }, - /* stage 2 */ - { 7, "RegisterApplication", NULL, NULL }, + { 5, "AdvisePDevPC", dissect_Advise_rqst, dissect_Advise_resp }, + { 6, "UnadvisePDevPC", dissect_Unadvise_rqst, dissect_dcom_simple_resp }, + /* stage 2 */ + { 7, "RegisterApplication", NULL, NULL }, { 8, "UnRegisterApplication", NULL, NULL }, - { 9, "AddLogicalDevice2", NULL, NULL }, + { 9, "AddLogicalDevice2", NULL, NULL }, { 0, NULL, NULL, NULL }, }; @@ -1205,11 +1205,11 @@ static dcerpc_sub_dissector ICBAPhysicalDevicePC_dissectors[] = { /* sub dissector table of ICBAPhysicalDevicePCEvent interface */ static dcerpc_sub_dissector ICBAPhysicalDevicePCEvent_dissectors[] = { { 0, "QueryInterface", NULL, NULL }, - { 1, "AddRef", NULL, NULL }, - { 2, "Release", NULL, NULL }, + { 1, "AddRef", NULL, NULL }, + { 2, "Release", NULL, NULL }, - { 3, "OnLogicalDeviceAdded", dissect_ICBAPhysicalDevicePCEvent_OnLogicalDeviceAdded_rqst, dissect_dcom_simple_resp }, - { 4, "OnLogicalDeviceRemoved", dissect_Unadvise_rqst, dissect_dcom_simple_resp }, + { 3, "OnLogicalDeviceAdded", dissect_ICBAPhysicalDevicePCEvent_OnLogicalDeviceAdded_rqst, dissect_dcom_simple_resp }, + { 4, "OnLogicalDeviceRemoved", dissect_Unadvise_rqst, dissect_dcom_simple_resp }, { 0, NULL, NULL, NULL }, }; @@ -1217,26 +1217,26 @@ static dcerpc_sub_dissector ICBAPhysicalDevicePCEvent_dissectors[] = { /* sub dissector table of ICBALogicalDevice / ICBALogicalDevice2 interface */ static dcerpc_sub_dissector ICBALogicalDevice_dissectors[] = { { 0, "QueryInterface", NULL, NULL }, - { 1, "AddRef", NULL, NULL }, - { 2, "Release", NULL, NULL }, - - { 3, "GetTypeInfoCount", dissect_dcom_simple_rqst, dissect_IDispatch_GetTypeInfoCount_resp }, - { 4, "GetTypeInfo", dissect_IDispatch_GetTypeInfo_rqst, dissect_IDispatch_GetTypeInfo_resp }, - { 5, "GetIDsOfNames", dissect_IDispatch_GetIDsOfNames_rqst, dissect_IDispatch_GetIDsOfNames_resp }, - { 6, "Invoke", dissect_IDispatch_Invoke_rqst, dissect_IDispatch_Invoke_resp }, - - { 7, "get_Name", dissect_dcom_simple_rqst, dissect_ICBALogicalDevice_get_Name_resp }, - { 8, "get_Producer", dissect_dcom_simple_rqst, dissect_get_Producer_resp }, - { 9, "get_Product", dissect_dcom_simple_rqst, dissect_get_Product_resp }, - {10, "get_SerialNo", dissect_dcom_simple_rqst, dissect_get_SerialNo_resp }, - {11, "get_ProductionDate", dissect_dcom_simple_rqst, dissect_get_ProductionDate_resp }, - {12, "Revision", dissect_dcom_simple_rqst, dissect_Revision_resp }, - {13, "get_ACCO", dissect_dcom_simple_rqst, dissect_ICBALogicalDevice_get_ACCO_resp }, - {14, "get_RTAuto", dissect_ICBALogicalDevice_Get_RTAuto_rqst, dissect_ICBALogicalDevice_get_RTAuto_resp }, - /* stage 2 */ - {15, "PROFInetRevision", dissect_dcom_simple_rqst, dissect_PROFInetRevision_resp }, - {16, "ComponentInfo", dissect_dcom_simple_rqst, dissect_ComponentInfo_resp }, - {17, "PBAddressInfo", dissect_dcom_simple_rqst, dissect_PBAddressInfo_resp }, + { 1, "AddRef", NULL, NULL }, + { 2, "Release", NULL, NULL }, + + { 3, "GetTypeInfoCount", dissect_dcom_simple_rqst, dissect_IDispatch_GetTypeInfoCount_resp }, + { 4, "GetTypeInfo", dissect_IDispatch_GetTypeInfo_rqst, dissect_IDispatch_GetTypeInfo_resp }, + { 5, "GetIDsOfNames", dissect_IDispatch_GetIDsOfNames_rqst, dissect_IDispatch_GetIDsOfNames_resp }, + { 6, "Invoke", dissect_IDispatch_Invoke_rqst, dissect_IDispatch_Invoke_resp }, + + { 7, "get_Name", dissect_dcom_simple_rqst, dissect_ICBALogicalDevice_get_Name_resp }, + { 8, "get_Producer", dissect_dcom_simple_rqst, dissect_get_Producer_resp }, + { 9, "get_Product", dissect_dcom_simple_rqst, dissect_get_Product_resp }, + {10, "get_SerialNo", dissect_dcom_simple_rqst, dissect_get_SerialNo_resp }, + {11, "get_ProductionDate", dissect_dcom_simple_rqst, dissect_get_ProductionDate_resp }, + {12, "Revision", dissect_dcom_simple_rqst, dissect_Revision_resp }, + {13, "get_ACCO", dissect_dcom_simple_rqst, dissect_ICBALogicalDevice_get_ACCO_resp }, + {14, "get_RTAuto", dissect_ICBALogicalDevice_Get_RTAuto_rqst, dissect_ICBALogicalDevice_get_RTAuto_resp }, + /* stage 2 */ + {15, "PROFInetRevision", dissect_dcom_simple_rqst, dissect_PROFInetRevision_resp }, + {16, "ComponentInfo", dissect_dcom_simple_rqst, dissect_ComponentInfo_resp }, + {17, "PBAddressInfo", dissect_dcom_simple_rqst, dissect_PBAddressInfo_resp }, { 0, NULL, NULL, NULL }, }; @@ -1244,20 +1244,20 @@ static dcerpc_sub_dissector ICBALogicalDevice_dissectors[] = { /* sub dissector table of ICBAState interface */ static dcerpc_sub_dissector ICBAState_dissectors[] = { { 0, "QueryInterface", NULL, NULL }, - { 1, "AddRef", NULL, NULL }, - { 2, "Release", NULL, NULL }, - - { 3, "GetTypeInfoCount", dissect_dcom_simple_rqst, dissect_IDispatch_GetTypeInfoCount_resp }, - { 4, "GetTypeInfo", dissect_IDispatch_GetTypeInfo_rqst, dissect_IDispatch_GetTypeInfo_resp }, - { 5, "GetIDsOfNames", dissect_IDispatch_GetIDsOfNames_rqst, dissect_IDispatch_GetIDsOfNames_resp }, - { 6, "Invoke", dissect_IDispatch_Invoke_rqst, dissect_IDispatch_Invoke_resp }, - - { 7, "get_State", dissect_dcom_simple_rqst, dissect_ICBAState_get_State_resp }, - { 8, "Activate", dissect_dcom_simple_rqst, dissect_dcom_simple_resp }, - { 9, "Deactivate", dissect_dcom_simple_rqst, dissect_dcom_simple_resp }, - {10, "Reset", dissect_dcom_simple_rqst, dissect_dcom_simple_resp }, - {11, "AdviseState", dissect_Advise_rqst, dissect_Advise_resp }, - {12, "UnadviseState", dissect_Unadvise_rqst, dissect_dcom_simple_resp }, + { 1, "AddRef", NULL, NULL }, + { 2, "Release", NULL, NULL }, + + { 3, "GetTypeInfoCount", dissect_dcom_simple_rqst, dissect_IDispatch_GetTypeInfoCount_resp }, + { 4, "GetTypeInfo", dissect_IDispatch_GetTypeInfo_rqst, dissect_IDispatch_GetTypeInfo_resp }, + { 5, "GetIDsOfNames", dissect_IDispatch_GetIDsOfNames_rqst, dissect_IDispatch_GetIDsOfNames_resp }, + { 6, "Invoke", dissect_IDispatch_Invoke_rqst, dissect_IDispatch_Invoke_resp }, + + { 7, "get_State", dissect_dcom_simple_rqst, dissect_ICBAState_get_State_resp }, + { 8, "Activate", dissect_dcom_simple_rqst, dissect_dcom_simple_resp }, + { 9, "Deactivate", dissect_dcom_simple_rqst, dissect_dcom_simple_resp }, + {10, "Reset", dissect_dcom_simple_rqst, dissect_dcom_simple_resp }, + {11, "AdviseState", dissect_Advise_rqst, dissect_Advise_resp }, + {12, "UnadviseState", dissect_Unadvise_rqst, dissect_dcom_simple_resp }, { 0, NULL, NULL, NULL }, }; @@ -1265,8 +1265,8 @@ static dcerpc_sub_dissector ICBAState_dissectors[] = { /* sub dissector table of ICBAStateEvent interface */ static dcerpc_sub_dissector ICBAStateEvent_dissectors[] = { { 0, "QueryInterface", NULL, NULL }, - { 1, "AddRef", NULL, NULL }, - { 2, "Release", NULL, NULL }, + { 1, "AddRef", NULL, NULL }, + { 2, "Release", NULL, NULL }, { 3, "OnStateChanged", dissect_ICBAStateEvent_OnStateChanged_rqst, dissect_dcom_simple_resp }, { 0, NULL, NULL, NULL }, @@ -1276,16 +1276,16 @@ static dcerpc_sub_dissector ICBAStateEvent_dissectors[] = { /* sub dissector table of ICBATime interface */ static dcerpc_sub_dissector ICBATime_dissectors[] = { { 0, "QueryInterface", NULL, NULL }, - { 1, "AddRef", NULL, NULL }, - { 2, "Release", NULL, NULL }, + { 1, "AddRef", NULL, NULL }, + { 2, "Release", NULL, NULL }, - { 3, "GetTypeInfoCount", dissect_dcom_simple_rqst, dissect_IDispatch_GetTypeInfoCount_resp }, - { 4, "GetTypeInfo", dissect_IDispatch_GetTypeInfo_rqst, dissect_IDispatch_GetTypeInfo_resp }, - { 5, "GetIDsOfNames", dissect_IDispatch_GetIDsOfNames_rqst, dissect_IDispatch_GetIDsOfNames_resp }, - { 6, "Invoke", dissect_IDispatch_Invoke_rqst, dissect_IDispatch_Invoke_resp }, + { 3, "GetTypeInfoCount", dissect_dcom_simple_rqst, dissect_IDispatch_GetTypeInfoCount_resp }, + { 4, "GetTypeInfo", dissect_IDispatch_GetTypeInfo_rqst, dissect_IDispatch_GetTypeInfo_resp }, + { 5, "GetIDsOfNames", dissect_IDispatch_GetIDsOfNames_rqst, dissect_IDispatch_GetIDsOfNames_resp }, + { 6, "Invoke", dissect_IDispatch_Invoke_rqst, dissect_IDispatch_Invoke_resp }, - { 7, "get_Time", dissect_dcom_simple_rqst, dissect_ICBATime_get_Time_resp }, - { 8, "put_Time", dissect_ICBATime_put_Time_rqst, dissect_dcom_simple_resp }, + { 7, "get_Time", dissect_dcom_simple_rqst, dissect_ICBATime_get_Time_resp }, + { 8, "put_Time", dissect_ICBATime_put_Time_rqst, dissect_dcom_simple_resp }, { 0, NULL, NULL, NULL }, }; @@ -1293,17 +1293,17 @@ static dcerpc_sub_dissector ICBATime_dissectors[] = { /* sub dissector table of ICBAGroupError interface */ static dcerpc_sub_dissector ICBAGroupError_dissectors[] = { { 0, "QueryInterface", NULL, NULL }, - { 1, "AddRef", NULL, NULL }, - { 2, "Release", NULL, NULL }, + { 1, "AddRef", NULL, NULL }, + { 2, "Release", NULL, NULL }, - { 3, "GetTypeInfoCount", dissect_dcom_simple_rqst, dissect_IDispatch_GetTypeInfoCount_resp }, - { 4, "GetTypeInfo", dissect_IDispatch_GetTypeInfo_rqst, dissect_IDispatch_GetTypeInfo_resp }, - { 5, "GetIDsOfNames", dissect_IDispatch_GetIDsOfNames_rqst, dissect_IDispatch_GetIDsOfNames_resp }, - { 6, "Invoke", dissect_IDispatch_Invoke_rqst, dissect_IDispatch_Invoke_resp }, + { 3, "GetTypeInfoCount", dissect_dcom_simple_rqst, dissect_IDispatch_GetTypeInfoCount_resp }, + { 4, "GetTypeInfo", dissect_IDispatch_GetTypeInfo_rqst, dissect_IDispatch_GetTypeInfo_resp }, + { 5, "GetIDsOfNames", dissect_IDispatch_GetIDsOfNames_rqst, dissect_IDispatch_GetIDsOfNames_resp }, + { 6, "Invoke", dissect_IDispatch_Invoke_rqst, dissect_IDispatch_Invoke_resp }, - { 7, "GroupError", dissect_dcom_simple_rqst, dissect_ICBAGroupError_GroupError_resp }, - { 8, "AdviseGroupError", dissect_Advise_rqst, dissect_Advise_resp }, - { 9, "UnadviseGroupError", dissect_Unadvise_rqst, dissect_dcom_simple_resp }, + { 7, "GroupError", dissect_dcom_simple_rqst, dissect_ICBAGroupError_GroupError_resp }, + { 8, "AdviseGroupError", dissect_Advise_rqst, dissect_Advise_resp }, + { 9, "UnadviseGroupError", dissect_Unadvise_rqst, dissect_dcom_simple_resp }, { 0, NULL, NULL, NULL }, }; @@ -1311,8 +1311,8 @@ static dcerpc_sub_dissector ICBAGroupError_dissectors[] = { /* sub dissector table of ICBAGroupErrorEvent interface */ static dcerpc_sub_dissector ICBAGroupErrorEvent_dissectors[] = { { 0, "QueryInterface", NULL, NULL }, - { 1, "AddRef", NULL, NULL }, - { 2, "Release", NULL, NULL }, + { 1, "AddRef", NULL, NULL }, + { 2, "Release", NULL, NULL }, { 3, "OnGroupErrorChanged", dissect_ICBAGroupError_OnGroupErrorChanged_rqst, dissect_dcom_simple_resp }, { 0, NULL, NULL, NULL }, @@ -1322,19 +1322,19 @@ static dcerpc_sub_dissector ICBAGroupErrorEvent_dissectors[] = { /* sub dissector table of ICBARTAuto interface */ static dcerpc_sub_dissector ICBARTAuto_dissectors[] = { { 0, "QueryInterface", NULL, NULL }, - { 1, "AddRef", NULL, NULL }, - { 2, "Release", NULL, NULL }, + { 1, "AddRef", NULL, NULL }, + { 2, "Release", NULL, NULL }, - { 3, "GetTypeInfoCount", dissect_dcom_simple_rqst, dissect_IDispatch_GetTypeInfoCount_resp }, - { 4, "GetTypeInfo", dissect_IDispatch_GetTypeInfo_rqst, dissect_IDispatch_GetTypeInfo_resp }, - { 5, "GetIDsOfNames", dissect_IDispatch_GetIDsOfNames_rqst, dissect_IDispatch_GetIDsOfNames_resp }, - { 6, "Invoke", dissect_IDispatch_Invoke_rqst, dissect_IDispatch_Invoke_resp }, + { 3, "GetTypeInfoCount", dissect_dcom_simple_rqst, dissect_IDispatch_GetTypeInfoCount_resp }, + { 4, "GetTypeInfo", dissect_IDispatch_GetTypeInfo_rqst, dissect_IDispatch_GetTypeInfo_resp }, + { 5, "GetIDsOfNames", dissect_IDispatch_GetIDsOfNames_rqst, dissect_IDispatch_GetIDsOfNames_resp }, + { 6, "Invoke", dissect_IDispatch_Invoke_rqst, dissect_IDispatch_Invoke_resp }, - { 7, "get_Name", dissect_dcom_simple_rqst, dissect_RTAuto_get_Name_resp }, - { 8, "Revision", dissect_dcom_simple_rqst, dissect_Revision_resp }, + { 7, "get_Name", dissect_dcom_simple_rqst, dissect_RTAuto_get_Name_resp }, + { 8, "Revision", dissect_dcom_simple_rqst, dissect_Revision_resp }, - /* stage 2 */ - { 9, "ComponentInfo", dissect_dcom_simple_rqst, dissect_ComponentInfo_resp }, + /* stage 2 */ + { 9, "ComponentInfo", dissect_dcom_simple_rqst, dissect_ComponentInfo_resp }, { 0, NULL, NULL, NULL }, }; @@ -1344,16 +1344,16 @@ static dcerpc_sub_dissector ICBARTAuto_dissectors[] = { /* (usually not called over network, no dissecting needed) */ static dcerpc_sub_dissector ICBASystemProperties_dissectors[] = { { 0, "QueryInterface", NULL, NULL }, - { 1, "AddRef", NULL, NULL }, - { 2, "Release", NULL, NULL }, + { 1, "AddRef", NULL, NULL }, + { 2, "Release", NULL, NULL }, - { 3, "GetTypeInfoCount", dissect_dcom_simple_rqst, dissect_IDispatch_GetTypeInfoCount_resp }, - { 4, "GetTypeInfo", dissect_IDispatch_GetTypeInfo_rqst, dissect_IDispatch_GetTypeInfo_resp }, - { 5, "GetIDsOfNames", dissect_IDispatch_GetIDsOfNames_rqst, dissect_IDispatch_GetIDsOfNames_resp }, - { 6, "Invoke", dissect_IDispatch_Invoke_rqst, dissect_IDispatch_Invoke_resp }, + { 3, "GetTypeInfoCount", dissect_dcom_simple_rqst, dissect_IDispatch_GetTypeInfoCount_resp }, + { 4, "GetTypeInfo", dissect_IDispatch_GetTypeInfo_rqst, dissect_IDispatch_GetTypeInfo_resp }, + { 5, "GetIDsOfNames", dissect_IDispatch_GetIDsOfNames_rqst, dissect_IDispatch_GetIDsOfNames_resp }, + { 6, "Invoke", dissect_IDispatch_Invoke_rqst, dissect_IDispatch_Invoke_resp }, - { 7, "StateCollection", dissect_dcom_simple_rqst, NULL }, - { 8, "StampCollection", dissect_dcom_simple_rqst, NULL }, + { 7, "StateCollection", dissect_dcom_simple_rqst, NULL }, + { 8, "StampCollection", dissect_dcom_simple_rqst, NULL }, { 0, NULL, NULL, NULL }, }; @@ -1367,153 +1367,264 @@ static void cba_reinit( void) { void proto_register_dcom_cba (void) { - static hf_register_info hf_cba_browse_array[] = { - { &hf_cba_browse_count, - { "Count", "cba.browse.count", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_browse_offset, - { "Offset", "cba.browse.offset", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_browse_max_return, - { "MaxReturn", "cba.browse.max_return", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_browse_item, - { "ItemNames", "cba.browse.item", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_browse_data_type, - { "DataTypes", "cba.browse.data_type", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_browse_access_right, - { "AccessRights", "cba.browse.access_right", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_browse_selector, - { "Selector", "cba.browse.selector", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_browse_info1, - { "Info1", "cba.browse.info1", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_browse_info2, - { "Info2", "cba.browse.info2", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - }; - - - static hf_register_info hf_cba_pdev_array[] = { - { &hf_cba_revision_major, - { "Major", "cba.revision_major", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_revision_minor, - { "Minor", "cba.revision_minor", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_revision_service_pack, - { "ServicePack", "cba.revision_service_pack", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_revision_build, - { "Build", "cba_revision_build", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_producer, - { "Producer", "cba.producer", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_product, - { "Product", "cba.product", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_multi_app, - { "MultiApp", "cba.multi_app", FT_UINT16, BASE_HEX, VALS(dcom_boolean_vals), 0x0, NULL, HFILL }}, - { &hf_cba_profinet_dcom_stack, - { "PROFInetDCOMStack", "cba.profinet_dcom_stack", FT_UINT16, BASE_HEX, VALS(dcom_boolean_vals), 0x0, NULL, HFILL }}, - { &hf_cba_pdev_stamp, - { "PDevStamp", "cba.pdev_stamp", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_save_ldev_name, - { "LDevName", "cba.save_ldev_name", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_save_result, - { "PartialResult", "cba.save_result", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - }; - - static hf_register_info hf_cba_ldev_array[] = { - { &hf_cba_name, - { "Name", "cba.name", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_component_id, - { "ComponentID", "cba.component_id", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_component_version, - { "Version", "cba.component_version", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_pbaddress, - { "PROFIBUS Address", "cba.pbaddress", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_pbaddress_system_id, - { "SystemID", "cba.pbaddress.system_id", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_pbaddress_address, - { "Address", "cba.pbaddress.address", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - }; - - static hf_register_info hf_cba_array[] = { + static hf_register_info hf_cba_browse_array[] = { + { &hf_cba_browse_count, + { "Count", "cba.browse.count", + FT_UINT32, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_browse_offset, + { "Offset", "cba.browse.offset", + FT_UINT32, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_browse_max_return, + { "MaxReturn", "cba.browse.max_return", + FT_UINT32, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_browse_item, + { "ItemNames", "cba.browse.item", + FT_NONE, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_browse_data_type, + { "DataTypes", "cba.browse.data_type", + FT_NONE, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_browse_access_right, + { "AccessRights", "cba.browse.access_right", + FT_NONE, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_browse_selector, + { "Selector", "cba.browse.selector", + FT_UINT32, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_browse_info1, + { "Info1", "cba.browse.info1", + FT_NONE, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_browse_info2, + { "Info2", "cba.browse.info2", + FT_NONE, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + }; + + + static hf_register_info hf_cba_pdev_array[] = { + { &hf_cba_revision_major, + { "Major", "cba.revision_major", + FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_revision_minor, + { "Minor", "cba.revision_minor", + FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_revision_service_pack, + { "ServicePack", "cba.revision_service_pack", + FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_revision_build, + { "Build", "cba_revision_build", + FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_producer, + { "Producer", "cba.producer", + FT_STRING, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_product, + { "Product", "cba.product", + FT_STRING, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_multi_app, + { "MultiApp", "cba.multi_app", + FT_UINT16, BASE_HEX, VALS(dcom_boolean_vals), 0x0, + NULL, HFILL }}, + + { &hf_cba_profinet_dcom_stack, + { "PROFInetDCOMStack", "cba.profinet_dcom_stack", + FT_UINT16, BASE_HEX, VALS(dcom_boolean_vals), 0x0, + NULL, HFILL }}, + + { &hf_cba_pdev_stamp, + { "PDevStamp", "cba.pdev_stamp", + FT_UINT32, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_save_ldev_name, + { "LDevName", "cba.save_ldev_name", + FT_NONE, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_save_result, + { "PartialResult", "cba.save_result", + FT_NONE, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + }; + + static hf_register_info hf_cba_ldev_array[] = { + { &hf_cba_name, + { "Name", "cba.name", + FT_STRING, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_component_id, + { "ComponentID", "cba.component_id", + FT_STRING, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_component_version, + { "Version", "cba.component_version", + FT_STRING, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_pbaddress, + { "PROFIBUS Address", "cba.pbaddress", + FT_NONE, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_pbaddress_system_id, + { "SystemID", "cba.pbaddress.system_id", + FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_pbaddress_address, + { "Address", "cba.pbaddress.address", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + }; + + static hf_register_info hf_cba_array[] = { { &hf_cba_opnum, - { "Operation", "cba.opnum", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_production_date, - { "ProductionDate", "cba.production_date", FT_DOUBLE, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_time, - { "Time", "cba.time", FT_DOUBLE, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_serial_no, - { "SerialNo", "cba.serial_no", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_state, - { "State", "cba.state", FT_UINT16, BASE_HEX, VALS(cba_state_vals), 0x0, NULL, HFILL }}, - { &hf_cba_new_state, - { "NewState", "cba.state_new", FT_UINT16, BASE_HEX, VALS(cba_state_vals), 0x0, NULL, HFILL }}, - { &hf_cba_old_state, - { "OldState", "cba.state_old", FT_UINT16, BASE_HEX, VALS(cba_state_vals), 0x0, NULL, HFILL }}, - { &hf_cba_cookie, - { "Cookie", "cba.cookie", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }}, - { &hf_cba_grouperror, - { "GroupError", "cba.grouperror", FT_UINT16, BASE_HEX, VALS(cba_grouperror_vals), 0x0, NULL, HFILL }}, - { &hf_cba_new_grouperror, - { "NewGroupError", "cba.grouperror_new", FT_UINT16, BASE_HEX, VALS(cba_grouperror_vals), 0x0, NULL, HFILL }}, - { &hf_cba_old_grouperror, - { "OldGroupError", "cba.grouperror_old", FT_UINT16, BASE_HEX, VALS(cba_grouperror_vals), 0x0, NULL, HFILL }}, - }; + { "Operation", "cba.opnum", + FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_production_date, + { "ProductionDate", "cba.production_date", + FT_DOUBLE, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_time, + { "Time", "cba.time", + FT_DOUBLE, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_serial_no, + { "SerialNo", "cba.serial_no", + FT_NONE, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_state, + { "State", "cba.state", + FT_UINT16, BASE_HEX, VALS(cba_state_vals), 0x0, + NULL, HFILL }}, + + { &hf_cba_new_state, + { "NewState", "cba.state_new", + FT_UINT16, BASE_HEX, VALS(cba_state_vals), 0x0, + NULL, HFILL }}, + + { &hf_cba_old_state, + { "OldState", "cba.state_old", + FT_UINT16, BASE_HEX, VALS(cba_state_vals), 0x0, + NULL, HFILL }}, + + { &hf_cba_cookie, + { "Cookie", "cba.cookie", + FT_UINT32, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_cba_grouperror, + { "GroupError", "cba.grouperror", + FT_UINT16, BASE_HEX, VALS(cba_grouperror_vals), 0x0, + NULL, HFILL }}, + + { &hf_cba_new_grouperror, + { "NewGroupError", "cba.grouperror_new", + FT_UINT16, BASE_HEX, VALS(cba_grouperror_vals), 0x0, + NULL, HFILL }}, + + { &hf_cba_old_grouperror, + { "OldGroupError", "cba.grouperror_old", + FT_UINT16, BASE_HEX, VALS(cba_grouperror_vals), 0x0, + NULL, HFILL }}, + + }; - static gint *ett_cba[] = { - &ett_ICBAPhysicalDevice, - &ett_ICBABrowse, - &ett_ICBAPhysicalDevicePC, - &ett_ICBAPhysicalDevicePCEvent, - &ett_ICBAPersist, - &ett_ICBALogicalDevice, - &ett_ICBAState, - &ett_ICBAStateEvent, - &ett_ICBATime, - &ett_ICBAGroupError, - &ett_ICBAGroupErrorEvent, - &ett_ICBARTAuto, - &ett_ICBASystemProperties, - &ett_PBAddress - }; + static gint *ett_cba[] = { + &ett_ICBAPhysicalDevice, + &ett_ICBABrowse, + &ett_ICBAPhysicalDevicePC, + &ett_ICBAPhysicalDevicePCEvent, + &ett_ICBAPersist, + &ett_ICBALogicalDevice, + &ett_ICBAState, + &ett_ICBAStateEvent, + &ett_ICBATime, + &ett_ICBAGroupError, + &ett_ICBAGroupErrorEvent, + &ett_ICBARTAuto, + &ett_ICBASystemProperties, + &ett_PBAddress + }; - proto_register_subtree_array (ett_cba, array_length (ett_cba)); + proto_register_subtree_array (ett_cba, array_length (ett_cba)); - proto_ICBAPhysicalDevice = proto_register_protocol ("ICBAPhysicalDevice", "ICBAPDev", "cba_pdev"); - proto_register_field_array(proto_ICBAPhysicalDevice, hf_cba_pdev_array, array_length(hf_cba_pdev_array)); + proto_ICBAPhysicalDevice = proto_register_protocol ("ICBAPhysicalDevice", "ICBAPDev", "cba_pdev"); + proto_register_field_array(proto_ICBAPhysicalDevice, hf_cba_pdev_array, array_length(hf_cba_pdev_array)); - proto_ICBAPhysicalDevice2 = proto_register_protocol ("ICBAPhysicalDevice2", "ICBAPDev2", "cba_pdev2"); + proto_ICBAPhysicalDevice2 = proto_register_protocol ("ICBAPhysicalDevice2", "ICBAPDev2", "cba_pdev2"); - proto_ICBABrowse = proto_register_protocol ("ICBABrowse", "ICBABrowse", "cba_browse"); - proto_register_field_array(proto_ICBABrowse, hf_cba_array, array_length(hf_cba_array)); - proto_register_field_array(proto_ICBABrowse, hf_cba_browse_array, array_length(hf_cba_browse_array)); + proto_ICBABrowse = proto_register_protocol ("ICBABrowse", "ICBABrowse", "cba_browse"); + proto_register_field_array(proto_ICBABrowse, hf_cba_array, array_length(hf_cba_array)); + proto_register_field_array(proto_ICBABrowse, hf_cba_browse_array, array_length(hf_cba_browse_array)); - proto_ICBABrowse2 = proto_register_protocol ("ICBABrowse2", "ICBABrowse2", "cba_browse2"); + proto_ICBABrowse2 = proto_register_protocol ("ICBABrowse2", "ICBABrowse2", "cba_browse2"); - proto_ICBAPhysicalDevicePC = proto_register_protocol ("ICBAPhysicalDevicePC", "ICBAPDevPC", "cba_pdev_pc"); + proto_ICBAPhysicalDevicePC = proto_register_protocol ("ICBAPhysicalDevicePC", "ICBAPDevPC", "cba_pdev_pc"); - proto_ICBAPhysicalDevicePCEvent = proto_register_protocol ("ICBAPhysicalDevicePCEvent", "ICBAPDevPCEvent", "cba_pdev_pc_event"); + proto_ICBAPhysicalDevicePCEvent = proto_register_protocol ("ICBAPhysicalDevicePCEvent", "ICBAPDevPCEvent", "cba_pdev_pc_event"); - proto_ICBAPersist = proto_register_protocol ("ICBAPersist", "ICBAPersist", "cba_persist"); + proto_ICBAPersist = proto_register_protocol ("ICBAPersist", "ICBAPersist", "cba_persist"); - proto_ICBAPersist2 = proto_register_protocol ("ICBAPersist2", "ICBAPersist2", "cba_persist2"); + proto_ICBAPersist2 = proto_register_protocol ("ICBAPersist2", "ICBAPersist2", "cba_persist2"); - proto_ICBALogicalDevice = proto_register_protocol ("ICBALogicalDevice", "ICBALDev", "cba_ldev"); - proto_register_field_array(proto_ICBAPhysicalDevice, hf_cba_ldev_array, array_length(hf_cba_ldev_array)); + proto_ICBALogicalDevice = proto_register_protocol ("ICBALogicalDevice", "ICBALDev", "cba_ldev"); + proto_register_field_array(proto_ICBAPhysicalDevice, hf_cba_ldev_array, array_length(hf_cba_ldev_array)); - proto_ICBALogicalDevice2 = proto_register_protocol ("ICBALogicalDevice2", "ICBALDev2", "cba_ldev2"); + proto_ICBALogicalDevice2 = proto_register_protocol ("ICBALogicalDevice2", "ICBALDev2", "cba_ldev2"); - proto_ICBAState = proto_register_protocol ("ICBAState", "ICBAState", "cba_state"); + proto_ICBAState = proto_register_protocol ("ICBAState", "ICBAState", "cba_state"); - proto_ICBAStateEvent = proto_register_protocol ("ICBAStateEvent", "ICBAStateEvent", "cba_state_event"); + proto_ICBAStateEvent = proto_register_protocol ("ICBAStateEvent", "ICBAStateEvent", "cba_state_event"); - proto_ICBATime = proto_register_protocol ("ICBATime", "ICBATime", "cba_time"); + proto_ICBATime = proto_register_protocol ("ICBATime", "ICBATime", "cba_time"); - proto_ICBAGroupError = proto_register_protocol ("ICBAGroupError", "ICBAGErr", "cba_grouperror"); + proto_ICBAGroupError = proto_register_protocol ("ICBAGroupError", "ICBAGErr", "cba_grouperror"); - proto_ICBAGroupErrorEvent = proto_register_protocol ("ICBAGroupErrorEvent", "ICBAGErrEvent", "cba_grouperror_event"); + proto_ICBAGroupErrorEvent = proto_register_protocol ("ICBAGroupErrorEvent", "ICBAGErrEvent", "cba_grouperror_event"); - proto_ICBARTAuto = proto_register_protocol ("ICBARTAuto", "ICBARTAuto", "cba_rtauto"); + proto_ICBARTAuto = proto_register_protocol ("ICBARTAuto", "ICBARTAuto", "cba_rtauto"); - proto_ICBARTAuto2 = proto_register_protocol ("ICBARTAuto2", "ICBARTAuto2", "cba_rtauto2"); + proto_ICBARTAuto2 = proto_register_protocol ("ICBARTAuto2", "ICBARTAuto2", "cba_rtauto2"); - proto_ICBASystemProperties = proto_register_protocol ("ICBASystemProperties", "ICBASysProp", "cba_sysprop"); + proto_ICBASystemProperties = proto_register_protocol ("ICBASystemProperties", "ICBASysProp", "cba_sysprop"); - register_init_routine(cba_reinit); + register_init_routine(cba_reinit); } @@ -1524,76 +1635,76 @@ proto_reg_handoff_dcom_cba (void) /* Register the CBA class ID */ guids_add_uuid(&uuid_coclass_CBAPhysicalDevice, "CBA"); - /* Register the interfaces */ - dcerpc_init_uuid(proto_ICBAPhysicalDevice, ett_ICBAPhysicalDevice, - &uuid_ICBAPhysicalDevice, ver_ICBAPhysicalDevice, - ICBAPhysicalDevice_dissectors, hf_cba_opnum); + /* Register the interfaces */ + dcerpc_init_uuid(proto_ICBAPhysicalDevice, ett_ICBAPhysicalDevice, + &uuid_ICBAPhysicalDevice, ver_ICBAPhysicalDevice, + ICBAPhysicalDevice_dissectors, hf_cba_opnum); - dcerpc_init_uuid(proto_ICBAPhysicalDevice2, ett_ICBAPhysicalDevice, - &uuid_ICBAPhysicalDevice2, ver_ICBAPhysicalDevice2, - ICBAPhysicalDevice_dissectors, hf_cba_opnum); + dcerpc_init_uuid(proto_ICBAPhysicalDevice2, ett_ICBAPhysicalDevice, + &uuid_ICBAPhysicalDevice2, ver_ICBAPhysicalDevice2, + ICBAPhysicalDevice_dissectors, hf_cba_opnum); - dcerpc_init_uuid(proto_ICBABrowse, ett_ICBABrowse, - &uuid_ICBABrowse, ver_ICBABrowse, - ICBABrowse_dissectors, hf_cba_opnum); + dcerpc_init_uuid(proto_ICBABrowse, ett_ICBABrowse, + &uuid_ICBABrowse, ver_ICBABrowse, + ICBABrowse_dissectors, hf_cba_opnum); - dcerpc_init_uuid(proto_ICBABrowse2, ett_ICBABrowse, - &uuid_ICBABrowse2, ver_ICBABrowse2, - ICBABrowse_dissectors, hf_cba_opnum); + dcerpc_init_uuid(proto_ICBABrowse2, ett_ICBABrowse, + &uuid_ICBABrowse2, ver_ICBABrowse2, + ICBABrowse_dissectors, hf_cba_opnum); - dcerpc_init_uuid(proto_ICBAPhysicalDevicePC, ett_ICBAPhysicalDevicePC, - &uuid_ICBAPhysicalDevicePC, ver_ICBAPhysicalDevicePC, - ICBAPhysicalDevicePC_dissectors, hf_cba_opnum); + dcerpc_init_uuid(proto_ICBAPhysicalDevicePC, ett_ICBAPhysicalDevicePC, + &uuid_ICBAPhysicalDevicePC, ver_ICBAPhysicalDevicePC, + ICBAPhysicalDevicePC_dissectors, hf_cba_opnum); - dcerpc_init_uuid(proto_ICBAPhysicalDevicePCEvent, ett_ICBAPhysicalDevicePCEvent, - &uuid_ICBAPhysicalDevicePCEvent, ver_ICBAPhysicalDevicePCEvent, - ICBAPhysicalDevicePCEvent_dissectors, hf_cba_opnum); + dcerpc_init_uuid(proto_ICBAPhysicalDevicePCEvent, ett_ICBAPhysicalDevicePCEvent, + &uuid_ICBAPhysicalDevicePCEvent, ver_ICBAPhysicalDevicePCEvent, + ICBAPhysicalDevicePCEvent_dissectors, hf_cba_opnum); - dcerpc_init_uuid(proto_ICBAPersist, ett_ICBAPersist, - &uuid_ICBAPersist, ver_ICBAPersist, - ICBAPersist_dissectors, hf_cba_opnum); + dcerpc_init_uuid(proto_ICBAPersist, ett_ICBAPersist, + &uuid_ICBAPersist, ver_ICBAPersist, + ICBAPersist_dissectors, hf_cba_opnum); - dcerpc_init_uuid(proto_ICBAPersist2, ett_ICBAPersist, - &uuid_ICBAPersist2, ver_ICBAPersist2, - ICBAPersist_dissectors, hf_cba_opnum); + dcerpc_init_uuid(proto_ICBAPersist2, ett_ICBAPersist, + &uuid_ICBAPersist2, ver_ICBAPersist2, + ICBAPersist_dissectors, hf_cba_opnum); - dcerpc_init_uuid(proto_ICBALogicalDevice, ett_ICBALogicalDevice, - &uuid_ICBALogicalDevice, ver_ICBALogicalDevice, - ICBALogicalDevice_dissectors, hf_cba_opnum); + dcerpc_init_uuid(proto_ICBALogicalDevice, ett_ICBALogicalDevice, + &uuid_ICBALogicalDevice, ver_ICBALogicalDevice, + ICBALogicalDevice_dissectors, hf_cba_opnum); - dcerpc_init_uuid(proto_ICBALogicalDevice2, ett_ICBALogicalDevice, - &uuid_ICBALogicalDevice2, ver_ICBALogicalDevice2, - ICBALogicalDevice_dissectors, hf_cba_opnum); + dcerpc_init_uuid(proto_ICBALogicalDevice2, ett_ICBALogicalDevice, + &uuid_ICBALogicalDevice2, ver_ICBALogicalDevice2, + ICBALogicalDevice_dissectors, hf_cba_opnum); - dcerpc_init_uuid(proto_ICBAState, ett_ICBAState, - &uuid_ICBAState, ver_ICBAState, - ICBAState_dissectors, hf_cba_opnum); + dcerpc_init_uuid(proto_ICBAState, ett_ICBAState, + &uuid_ICBAState, ver_ICBAState, + ICBAState_dissectors, hf_cba_opnum); - dcerpc_init_uuid(proto_ICBAStateEvent, ett_ICBAStateEvent, - &uuid_ICBAStateEvent, ver_ICBAStateEvent, - ICBAStateEvent_dissectors, hf_cba_opnum); + dcerpc_init_uuid(proto_ICBAStateEvent, ett_ICBAStateEvent, + &uuid_ICBAStateEvent, ver_ICBAStateEvent, + ICBAStateEvent_dissectors, hf_cba_opnum); - dcerpc_init_uuid(proto_ICBATime, ett_ICBATime, - &uuid_ICBATime, ver_ICBATime, - ICBATime_dissectors, hf_cba_opnum); + dcerpc_init_uuid(proto_ICBATime, ett_ICBATime, + &uuid_ICBATime, ver_ICBATime, + ICBATime_dissectors, hf_cba_opnum); - dcerpc_init_uuid(proto_ICBAGroupError, ett_ICBAGroupError, - &uuid_ICBAGroupError, ver_ICBAGroupError, - ICBAGroupError_dissectors, hf_cba_opnum); + dcerpc_init_uuid(proto_ICBAGroupError, ett_ICBAGroupError, + &uuid_ICBAGroupError, ver_ICBAGroupError, + ICBAGroupError_dissectors, hf_cba_opnum); - dcerpc_init_uuid(proto_ICBAGroupErrorEvent, ett_ICBAGroupErrorEvent, - &uuid_ICBAGroupErrorEvent, ver_ICBAGroupErrorEvent, - ICBAGroupErrorEvent_dissectors, hf_cba_opnum); + dcerpc_init_uuid(proto_ICBAGroupErrorEvent, ett_ICBAGroupErrorEvent, + &uuid_ICBAGroupErrorEvent, ver_ICBAGroupErrorEvent, + ICBAGroupErrorEvent_dissectors, hf_cba_opnum); - dcerpc_init_uuid(proto_ICBARTAuto, ett_ICBARTAuto, - &uuid_ICBARTAuto, ver_ICBARTAuto, - ICBARTAuto_dissectors, hf_cba_opnum); + dcerpc_init_uuid(proto_ICBARTAuto, ett_ICBARTAuto, + &uuid_ICBARTAuto, ver_ICBARTAuto, + ICBARTAuto_dissectors, hf_cba_opnum); - dcerpc_init_uuid(proto_ICBARTAuto2, ett_ICBARTAuto, - &uuid_ICBARTAuto2, ver_ICBARTAuto2, - ICBARTAuto_dissectors, hf_cba_opnum); + dcerpc_init_uuid(proto_ICBARTAuto2, ett_ICBARTAuto, + &uuid_ICBARTAuto2, ver_ICBARTAuto2, + ICBARTAuto_dissectors, hf_cba_opnum); - dcerpc_init_uuid(proto_ICBASystemProperties, ett_ICBASystemProperties, - &uuid_ICBASystemProperties, ver_ICBASystemProperties, - ICBASystemProperties_dissectors, hf_cba_opnum); + dcerpc_init_uuid(proto_ICBASystemProperties, ett_ICBASystemProperties, + &uuid_ICBASystemProperties, ver_ICBASystemProperties, + ICBASystemProperties_dissectors, hf_cba_opnum); } diff --git a/plugins/profinet/packet-pn-dcp.c b/plugins/profinet/packet-pn-dcp.c index 12dc1db683..557b02be7a 100644 --- a/plugins/profinet/packet-pn-dcp.c +++ b/plugins/profinet/packet-pn-dcp.c @@ -1,5 +1,5 @@ /* packet-pn-dcp.c - * Routines for PN-DCP (PROFINET Discovery and basic Configuration Protocol) + * Routines for PN-DCP (PROFINET Discovery and basic Configuration Protocol) * packet dissection. * * $Id$ @@ -226,7 +226,7 @@ static const value_string pn_dcp_suboption_device[] = { { 0, NULL } }; -#define PNDCP_SUBOPTION_DHCP_CLIENT_ID 61 +#define PNDCP_SUBOPTION_DHCP_CLIENT_ID 61 static const value_string pn_dcp_suboption_dhcp[] = { { 12, "Host name" }, @@ -251,10 +251,10 @@ static const value_string pn_dcp_suboption_dhcp[] = { static const value_string pn_dcp_suboption_control[] = { { 0x00, "Reserved" }, { PNDCP_SUBOPTION_CONTROL_START_TRANS, "Start Transaction" }, - { PNDCP_SUBOPTION_CONTROL_END_TRANS, "End Transaction" }, - { PNDCP_SUBOPTION_CONTROL_SIGNAL, "Signal" }, - { PNDCP_SUBOPTION_CONTROL_RESPONSE, "Response" }, - { PNDCP_SUBOPTION_CONTROL_FACT_RESET, "Reset Factory Settings" }, + { PNDCP_SUBOPTION_CONTROL_END_TRANS, "End Transaction" }, + { PNDCP_SUBOPTION_CONTROL_SIGNAL, "Signal" }, + { PNDCP_SUBOPTION_CONTROL_RESPONSE, "Response" }, + { PNDCP_SUBOPTION_CONTROL_FACT_RESET, "Reset Factory Settings" }, /*0x05 - 0xff reserved */ { 0, NULL } }; @@ -292,7 +292,7 @@ static const value_string pn_dcp_suboption_manuf[] = { /* dissect the option field */ static int -dissect_PNDCP_Option(tvbuff_t *tvb, int offset, packet_info *pinfo, +dissect_PNDCP_Option(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, proto_item *block_item, int hfindex, gboolean append_col) { guint8 option; @@ -300,40 +300,40 @@ dissect_PNDCP_Option(tvbuff_t *tvb, int offset, packet_info *pinfo, const value_string *val_str; offset = dissect_pn_uint8 (tvb, offset, pinfo, tree, hfindex, &option); - switch(option) { - case(PNDCP_OPTION_IP): - offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_ip, &suboption); + switch (option) { + case PNDCP_OPTION_IP: + offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_ip, &suboption); val_str = pn_dcp_suboption_ip; break; - case(PNDCP_OPTION_DEVICE): - offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_device, &suboption); + case PNDCP_OPTION_DEVICE: + offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_device, &suboption); val_str = pn_dcp_suboption_device; break; - case(PNDCP_OPTION_DHCP): - offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_dhcp, &suboption); + case PNDCP_OPTION_DHCP: + offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_dhcp, &suboption); val_str = pn_dcp_suboption_dhcp; break; - case(PNDCP_OPTION_CONTROL): - offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_control, &suboption); + case PNDCP_OPTION_CONTROL: + offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_control, &suboption); val_str = pn_dcp_suboption_control; break; - case(PNDCP_OPTION_DEVICEINITIATIVE): - offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_deviceinitiative, &suboption); + case PNDCP_OPTION_DEVICEINITIATIVE: + offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_deviceinitiative, &suboption); val_str = pn_dcp_suboption_deviceinitiative; break; - case(PNDCP_OPTION_ALLSELECTOR): - offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_all, &suboption); + case PNDCP_OPTION_ALLSELECTOR: + offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_all, &suboption); val_str = pn_dcp_suboption_all; break; default: - offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_manuf, &suboption); + offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_manuf, &suboption); val_str = pn_dcp_suboption_manuf; } - proto_item_append_text(block_item, ", Status from %s - %s", + proto_item_append_text(block_item, ", Status from %s - %s", val_to_str(option, pn_dcp_option, "Unknown"), val_to_str(suboption, val_str, "Unknown")); - if(append_col) { + if (append_col) { col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", val_to_str(suboption, val_str, "Unknown")); } @@ -343,15 +343,15 @@ dissect_PNDCP_Option(tvbuff_t *tvb, int offset, packet_info *pinfo, /* dissect the "IP" suboption */ static int -dissect_PNDCP_Suboption_IP(tvbuff_t *tvb, int offset, packet_info *pinfo, +dissect_PNDCP_Suboption_IP(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, proto_item *block_item, proto_item *dcp_item, guint8 service_id, gboolean is_response) { - guint8 suboption; - guint16 block_length; - guint16 block_info; - guint16 block_qualifier; - guint32 ip; + guint8 suboption; + guint16 block_length; + guint16 block_info; + guint16 block_qualifier; + guint32 ip; proto_item *item = NULL; @@ -360,38 +360,40 @@ dissect_PNDCP_Suboption_IP(tvbuff_t *tvb, int offset, packet_info *pinfo, /* DCPBlockLength */ offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_length, &block_length); - switch(suboption) { - case(PNDCP_SUBOPTION_IP_MAC): + switch (suboption) { + case PNDCP_SUBOPTION_IP_MAC: /* MACAddressValue? */ pn_append_info(pinfo, dcp_item, ", MAC"); proto_item_append_text(block_item, "IP/MAC"); - offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length); + offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length); break; - case(PNDCP_SUBOPTION_IP_IP): + case PNDCP_SUBOPTION_IP_IP: pn_append_info(pinfo, dcp_item, ", IP"); proto_item_append_text(block_item, "IP/IP"); /* BlockInfo? */ - if( ((service_id == PNDCP_SERVICE_ID_IDENTIFY) && is_response) || - ((service_id == PNDCP_SERVICE_ID_HELLO) && !is_response) || - ((service_id == PNDCP_SERVICE_ID_GET) && is_response)) { + if ( ((service_id == PNDCP_SERVICE_ID_IDENTIFY) && is_response) || + ((service_id == PNDCP_SERVICE_ID_HELLO) && !is_response) || + ((service_id == PNDCP_SERVICE_ID_GET) && is_response)) { block_info = tvb_get_ntohs (tvb, offset); if (tree) { item = proto_tree_add_uint(tree, hf_pn_dcp_suboption_ip_block_info, tvb, offset, 2, block_info); } offset += 2; - proto_item_append_text(block_item, ", BlockInfo: %s", val_to_str(block_info, pn_dcp_suboption_ip_block_info, "Undecoded")); + proto_item_append_text(block_item, ", BlockInfo: %s", + val_to_str(block_info, pn_dcp_suboption_ip_block_info, "Undecoded")); block_length -= 2; - if(block_info & 0x80) { + if (block_info & 0x80) { expert_add_info_format(pinfo, item, PI_RESPONSE_CODE, PI_NOTE, "IP address conflict detected!"); } } /* BlockQualifier? */ - if( (service_id == PNDCP_SERVICE_ID_SET) && !is_response) { + if ( (service_id == PNDCP_SERVICE_ID_SET) && !is_response) { offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_qualifier, &block_qualifier); - proto_item_append_text(block_item, ", BlockQualifier: %s", val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown")); + proto_item_append_text(block_item, ", BlockQualifier: %s", + val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown")); block_length -= 2; } @@ -410,7 +412,7 @@ dissect_PNDCP_Suboption_IP(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_item_append_text(block_item, ", Gateway: %s", ip_to_str((guint8*)&ip)); break; default: - offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length); + offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length); } return offset; @@ -419,25 +421,25 @@ dissect_PNDCP_Suboption_IP(tvbuff_t *tvb, int offset, packet_info *pinfo, /* dissect the "device" suboption */ static int -dissect_PNDCP_Suboption_Device(tvbuff_t *tvb, int offset, packet_info *pinfo, - proto_tree *tree, proto_item *block_item, proto_item *dcp_item, +dissect_PNDCP_Suboption_Device(tvbuff_t *tvb, int offset, packet_info *pinfo, + proto_tree *tree, proto_item *block_item, proto_item *dcp_item, guint8 service_id, gboolean is_response) { - guint8 suboption; - guint16 block_length; - gchar *info_str; - guint8 device_role; - guint16 vendor_id; - guint16 device_id; - char *typeofstation; - char *nameofstation; - char *aliasname; - guint16 block_info; - guint16 block_qualifier; - gboolean have_block_info=FALSE; - gboolean have_block_qualifier=FALSE; - guint8 device_instance_high; - guint8 device_instance_low; + guint8 suboption; + guint16 block_length; + gchar *info_str; + guint8 device_role; + guint16 vendor_id; + guint16 device_id; + char *typeofstation; + char *nameofstation; + char *aliasname; + guint16 block_info; + guint16 block_qualifier; + gboolean have_block_info = FALSE; + gboolean have_block_qualifier = FALSE; + guint8 device_instance_high; + guint8 device_instance_low; /* SuboptionDevice... */ @@ -446,120 +448,147 @@ dissect_PNDCP_Suboption_Device(tvbuff_t *tvb, int offset, packet_info *pinfo, offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_length, &block_length); /* BlockInfo? */ - if( ((service_id == PNDCP_SERVICE_ID_IDENTIFY) && is_response) || - ((service_id == PNDCP_SERVICE_ID_HELLO) && !is_response) || - ((service_id == PNDCP_SERVICE_ID_GET) && is_response)) { + if ( ((service_id == PNDCP_SERVICE_ID_IDENTIFY) && is_response) || + ((service_id == PNDCP_SERVICE_ID_HELLO) && !is_response) || + ((service_id == PNDCP_SERVICE_ID_GET) && is_response)) { offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_info, &block_info); - have_block_info=TRUE; + have_block_info = TRUE; block_length -= 2; } /* BlockQualifier? */ - if( (service_id == PNDCP_SERVICE_ID_SET) && !is_response) { + if ( (service_id == PNDCP_SERVICE_ID_SET) && !is_response) { offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_qualifier, &block_qualifier); - have_block_qualifier=TRUE; + have_block_qualifier = TRUE; block_length -= 2; } - switch(suboption) { - case(PNDCP_SUBOPTION_DEVICE_MANUF): + switch (suboption) { + case PNDCP_SUBOPTION_DEVICE_MANUF: typeofstation = ep_alloc(block_length+1); tvb_memcpy(tvb, (guint8 *) typeofstation, offset, block_length); typeofstation[block_length] = '\0'; proto_tree_add_string (tree, hf_pn_dcp_suboption_device_typeofstation, tvb, offset, block_length, typeofstation); pn_append_info(pinfo, dcp_item, ", DeviceVendorValue"); proto_item_append_text(block_item, "Device/Manufacturer specific"); - if(have_block_qualifier) - proto_item_append_text(block_item, ", BlockQualifier: %s", val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown")); - if(have_block_info) - proto_item_append_text(block_item, ", BlockInfo: %s", val_to_str(block_info, pn_dcp_block_info, "Unknown")); + if (have_block_qualifier) { + proto_item_append_text(block_item, ", BlockQualifier: %s", + val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown")); + } + if (have_block_info){ + proto_item_append_text(block_item, ", BlockInfo: %s", + val_to_str(block_info, pn_dcp_block_info, "Unknown")); + } proto_item_append_text(block_item, ", DeviceVendorValue: \"%s\"", typeofstation); offset += block_length; break; - case(PNDCP_SUBOPTION_DEVICE_NAMEOFSTATION): + case PNDCP_SUBOPTION_DEVICE_NAMEOFSTATION: nameofstation = ep_alloc(block_length+1); tvb_memcpy(tvb, (guint8 *) nameofstation, offset, block_length); nameofstation[block_length] = '\0'; proto_tree_add_string (tree, hf_pn_dcp_suboption_device_nameofstation, tvb, offset, block_length, nameofstation); pn_append_info(pinfo, dcp_item, ep_strdup_printf(", NameOfStation:\"%s\"", nameofstation)); proto_item_append_text(block_item, "Device/NameOfStation"); - if(have_block_qualifier) - proto_item_append_text(block_item, ", BlockQualifier: %s", val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown")); - if(have_block_info) - proto_item_append_text(block_item, ", BlockInfo: %s", val_to_str(block_info, pn_dcp_block_info, "Unknown")); + if (have_block_qualifier) { + proto_item_append_text(block_item, ", BlockQualifier: %s", + val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown")); + } + if (have_block_info) { + proto_item_append_text(block_item, ", BlockInfo: %s", + val_to_str(block_info, pn_dcp_block_info, "Unknown")); + } proto_item_append_text(block_item, ", \"%s\"", nameofstation); offset += block_length; break; - case(PNDCP_SUBOPTION_DEVICE_DEV_ID): + case PNDCP_SUBOPTION_DEVICE_DEV_ID: offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_vendor_id, &vendor_id); offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_device_id, &device_id); pn_append_info(pinfo, dcp_item, ", Dev-ID"); proto_item_append_text(block_item, "Device/Device ID"); - if(have_block_qualifier) - proto_item_append_text(block_item, ", BlockQualifier: %s", val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown")); - if(have_block_info) - proto_item_append_text(block_item, ", BlockInfo: %s", val_to_str(block_info, pn_dcp_block_info, "Unknown")); + if (have_block_qualifier) { + proto_item_append_text(block_item, ", BlockQualifier: %s", + val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown")); + } + if (have_block_info) { + proto_item_append_text(block_item, ", BlockInfo: %s", + val_to_str(block_info, pn_dcp_block_info, "Unknown")); + } proto_item_append_text(block_item, ", VendorID: 0x%04x / DeviceID: 0x%04x", vendor_id, device_id); break; - case(PNDCP_SUBOPTION_DEVICE_DEV_ROLE): + case PNDCP_SUBOPTION_DEVICE_DEV_ROLE: offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_device_role, &device_role); offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_reserved8, NULL); pn_append_info(pinfo, dcp_item, ", Dev-Role"); proto_item_append_text(block_item, "Device/Device Role"); - if(have_block_qualifier) - proto_item_append_text(block_item, ", BlockQualifier: %s", val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown")); - if(have_block_info) + if (have_block_qualifier) { + proto_item_append_text(block_item, ", BlockQualifier: %s", + val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown")); + } + if (have_block_info) proto_item_append_text(block_item, ", BlockInfo: %s", val_to_str(block_info, pn_dcp_block_info, "Unknown")); - if(device_role & 0x01) + if (device_role & 0x01) proto_item_append_text(block_item, ", IO-Device"); - if(device_role & 0x02) + if (device_role & 0x02) proto_item_append_text(block_item, ", IO-Controller"); - if(device_role & 0x04) + if (device_role & 0x04) proto_item_append_text(block_item, ", IO-Multidevice"); - if(device_role & 0x08) + if (device_role & 0x08) proto_item_append_text(block_item, ", PN-Supervisor"); break; - case(PNDCP_SUBOPTION_DEVICE_DEV_OPTIONS): + case PNDCP_SUBOPTION_DEVICE_DEV_OPTIONS: info_str = ep_strdup_printf(", Dev-Options(%u)", block_length/2); pn_append_info(pinfo, dcp_item, info_str); proto_item_append_text(block_item, "Device/Device Options"); - if(have_block_qualifier) - proto_item_append_text(block_item, ", BlockQualifier: %s", val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown")); - if(have_block_info) - proto_item_append_text(block_item, ", BlockInfo: %s", val_to_str(block_info, pn_dcp_block_info, "Unknown")); + if (have_block_qualifier) { + proto_item_append_text(block_item, ", BlockQualifier: %s", + val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown")); + } + if (have_block_info) { + proto_item_append_text(block_item, ", BlockInfo: %s", + val_to_str(block_info, pn_dcp_block_info, "Unknown")); + } proto_item_append_text(block_item, ", %u options", block_length/2); for( ; block_length != 0; block_length -= 2) { - offset = dissect_PNDCP_Option(tvb, offset, pinfo, tree, NULL /*block_item*/, hf_pn_dcp_option, + offset = dissect_PNDCP_Option(tvb, offset, pinfo, tree, NULL /*block_item*/, hf_pn_dcp_option, FALSE /* append_col */); } break; - case(PNDCP_SUBOPTION_DEVICE_ALIAS_NAME): + case PNDCP_SUBOPTION_DEVICE_ALIAS_NAME: aliasname = ep_alloc(block_length+1); tvb_memcpy(tvb, (guint8 *) aliasname, offset, block_length); aliasname[block_length] = '\0'; proto_tree_add_string (tree, hf_pn_dcp_suboption_device_aliasname, tvb, offset, block_length, aliasname); pn_append_info(pinfo, dcp_item, ep_strdup_printf(", AliasName:\"%s\"", aliasname)); proto_item_append_text(block_item, "Device/AliasName"); - if(have_block_qualifier) - proto_item_append_text(block_item, ", BlockQualifier: %s", val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown")); - if(have_block_info) - proto_item_append_text(block_item, ", BlockInfo: %s", val_to_str(block_info, pn_dcp_block_info, "Unknown")); + if (have_block_qualifier) { + proto_item_append_text(block_item, ", BlockQualifier: %s", + val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown")); + } + if (have_block_info) { + proto_item_append_text(block_item, ", BlockInfo: %s", + val_to_str(block_info, pn_dcp_block_info, "Unknown")); + } proto_item_append_text(block_item, ", \"%s\"", aliasname); offset += block_length; break; - case(PNDCP_SUBOPTION_DEVICE_DEV_INSTANCE): + case PNDCP_SUBOPTION_DEVICE_DEV_INSTANCE: offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_device_instance_high, &device_instance_high); offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_device_instance_low, &device_instance_low); pn_append_info(pinfo, dcp_item, ", Dev-Instance"); proto_item_append_text(block_item, "Device/Device Instance"); - if(have_block_qualifier) - proto_item_append_text(block_item, ", BlockQualifier: %s", val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown")); - if(have_block_info) - proto_item_append_text(block_item, ", BlockInfo: %s", val_to_str(block_info, pn_dcp_block_info, "Unknown")); - proto_item_append_text(block_item, ", InstanceHigh: %d, Instance Low: %d", device_instance_high, device_instance_low); + if (have_block_qualifier) { + proto_item_append_text(block_item, ", BlockQualifier: %s", + val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown")); + } + if (have_block_info) { + proto_item_append_text(block_item, ", BlockInfo: %s", + val_to_str(block_info, pn_dcp_block_info, "Unknown")); + } + proto_item_append_text(block_item, ", InstanceHigh: %d, Instance Low: %d", + device_instance_high, device_instance_low); break; default: - offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length); + offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length); } return offset; @@ -568,50 +597,54 @@ dissect_PNDCP_Suboption_Device(tvbuff_t *tvb, int offset, packet_info *pinfo, /* dissect the "DHCP" suboption */ static int -dissect_PNDCP_Suboption_DHCP(tvbuff_t *tvb, int offset, packet_info *pinfo, - proto_tree *tree, proto_item *block_item, proto_item *dcp_item, +dissect_PNDCP_Suboption_DHCP(tvbuff_t *tvb, int offset, packet_info *pinfo, + proto_tree *tree, proto_item *block_item, proto_item *dcp_item, guint8 service_id _U_, gboolean is_response _U_) { - guint8 suboption; - guint16 block_length; - guint16 block_info; - guint16 block_qualifier; - gboolean have_block_info=FALSE; - gboolean have_block_qualifier=FALSE; + guint8 suboption; + guint16 block_length; + guint16 block_info; + guint16 block_qualifier; + gboolean have_block_info = FALSE; + gboolean have_block_qualifier = FALSE; offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_dhcp, &suboption); offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_length, &block_length); /* BlockInfo? */ - if( ((service_id == PNDCP_SERVICE_ID_IDENTIFY) && is_response) || - ((service_id == PNDCP_SERVICE_ID_HELLO) && !is_response) || - ((service_id == PNDCP_SERVICE_ID_GET) && is_response)) { + if ( ((service_id == PNDCP_SERVICE_ID_IDENTIFY) && is_response) || + ((service_id == PNDCP_SERVICE_ID_HELLO) && !is_response) || + ((service_id == PNDCP_SERVICE_ID_GET) && is_response)) { offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_info, &block_info); have_block_info=TRUE; block_length -= 2; } /* BlockQualifier? */ - if( (service_id == PNDCP_SERVICE_ID_SET) && !is_response) { + if ( (service_id == PNDCP_SERVICE_ID_SET) && !is_response) { offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_qualifier, &block_qualifier); have_block_qualifier=TRUE; block_length -= 2; } - switch(suboption) { - case(PNDCP_SUBOPTION_DHCP_CLIENT_ID): + switch (suboption) { + case PNDCP_SUBOPTION_DHCP_CLIENT_ID: pn_append_info(pinfo, dcp_item, ", DHCP client identifier"); proto_item_append_text(block_item, "DHCP/Client-ID"); - if(have_block_qualifier) - proto_item_append_text(block_item, ", BlockQualifier: %s", val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown")); - if(have_block_info) - proto_item_append_text(block_item, ", BlockInfo: %s", val_to_str(block_info, pn_dcp_block_info, "Unknown")); + if (have_block_qualifier) { + proto_item_append_text(block_item, ", BlockQualifier: %s", + val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown")); + } + if (have_block_info) { + proto_item_append_text(block_item, ", BlockInfo: %s", + val_to_str(block_info, pn_dcp_block_info, "Unknown")); + } proto_tree_add_item(tree, hf_pn_dcp_suboption_dhcp_device_id, tvb, offset, block_length, ENC_NA); offset += block_length; break; default: - offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length); + offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length); } return offset; @@ -620,66 +653,68 @@ dissect_PNDCP_Suboption_DHCP(tvbuff_t *tvb, int offset, packet_info *pinfo, /* dissect the "control" suboption */ static int -dissect_PNDCP_Suboption_Control(tvbuff_t *tvb, int offset, packet_info *pinfo, - proto_tree *tree, proto_item *block_item, proto_item *dcp_item, +dissect_PNDCP_Suboption_Control(tvbuff_t *tvb, int offset, packet_info *pinfo, + proto_tree *tree, proto_item *block_item, proto_item *dcp_item, guint8 service_id _U_, gboolean is_response _U_) { - guint8 suboption; - guint16 block_length; - guint16 block_qualifier; - gchar *info_str; - guint8 block_error; + guint8 suboption; + guint16 block_length; + guint16 block_qualifier; + gchar *info_str; + guint8 block_error; proto_item *item = NULL; offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_control, &suboption); offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_length, &block_length); - switch(suboption) { - case(PNDCP_SUBOPTION_CONTROL_START_TRANS): + switch (suboption) { + case PNDCP_SUBOPTION_CONTROL_START_TRANS: pn_append_info(pinfo, dcp_item, ", Start-Trans"); proto_item_append_text(block_item, "Control/Start-Transaction"); offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_qualifier, &block_qualifier); break; - case(PNDCP_SUBOPTION_CONTROL_END_TRANS): + case PNDCP_SUBOPTION_CONTROL_END_TRANS: pn_append_info(pinfo, dcp_item, ", End-Trans"); proto_item_append_text(block_item, "Control/End-Transaction"); offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_qualifier, &block_qualifier); break; - case(PNDCP_SUBOPTION_CONTROL_SIGNAL): + case PNDCP_SUBOPTION_CONTROL_SIGNAL: pn_append_info(pinfo, dcp_item, ", Signal"); proto_item_append_text(block_item, "Control/Signal"); offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_qualifier, &block_qualifier); block_length -= 2; - offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length); + offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length); break; - case(PNDCP_SUBOPTION_CONTROL_RESPONSE): + case PNDCP_SUBOPTION_CONTROL_RESPONSE: proto_item_append_text(block_item, "Control/Response"); - offset = dissect_PNDCP_Option(tvb, offset, pinfo, tree, block_item, hf_pn_dcp_suboption_control_response, + offset = dissect_PNDCP_Option(tvb, offset, pinfo, tree, block_item, hf_pn_dcp_suboption_control_response, FALSE /* append_col */); block_error = tvb_get_guint8 (tvb, offset); if (tree) { item = proto_tree_add_uint(tree, hf_pn_dcp_block_error, tvb, offset, 1, block_error); } offset += 1; - if(block_error != 0) { - expert_add_info_format(pinfo, item, PI_RESPONSE_CODE, PI_CHAT, - "%s", val_to_str(block_error, pn_dcp_block_error, "Unknown")); + if (block_error != 0) { + expert_add_info_format(pinfo, item, PI_RESPONSE_CODE, PI_CHAT, "%s", + val_to_str(block_error, pn_dcp_block_error, "Unknown")); } - info_str = ep_strdup_printf(", Response(%s)", val_to_str(block_error, pn_dcp_block_error, "Unknown")); + info_str = ep_strdup_printf(", Response(%s)", + val_to_str(block_error, pn_dcp_block_error, "Unknown")); pn_append_info(pinfo, dcp_item, info_str); - proto_item_append_text(block_item, ", BlockError: %s", val_to_str(block_error, pn_dcp_block_error, "Unknown")); + proto_item_append_text(block_item, ", BlockError: %s", + val_to_str(block_error, pn_dcp_block_error, "Unknown")); break; - case(PNDCP_SUBOPTION_CONTROL_FACT_RESET): + case PNDCP_SUBOPTION_CONTROL_FACT_RESET: pn_append_info(pinfo, dcp_item, ", Reset FactorySettings"); proto_item_append_text(block_item, "Control/Reset FactorySettings"); offset += 2; block_length -= 2; break; default: - offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length); + offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length); } return offset; @@ -688,11 +723,11 @@ dissect_PNDCP_Suboption_Control(tvbuff_t *tvb, int offset, packet_info *pinfo, /* dissect the "deviceinitaitve" suboption */ static int -dissect_PNDCP_Suboption_DeviceInitiative(tvbuff_t *tvb, int offset, packet_info *pinfo, +dissect_PNDCP_Suboption_DeviceInitiative(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, proto_item *block_item, proto_item *dcp_item, guint8 service_id, gboolean is_response) { - guint8 suboption; + guint8 suboption; guint16 block_length; guint16 block_info; guint16 block_qualifier; @@ -706,18 +741,20 @@ dissect_PNDCP_Suboption_DeviceInitiative(tvbuff_t *tvb, int offset, packet_info proto_item_append_text(block_item, "DeviceInitiative/DeviceInitiative"); /* BlockInfo? */ - if( ((service_id == PNDCP_SERVICE_ID_IDENTIFY) && is_response) || + if ( ((service_id == PNDCP_SERVICE_ID_IDENTIFY) && is_response) || ((service_id == PNDCP_SERVICE_ID_HELLO) && !is_response) || ((service_id == PNDCP_SERVICE_ID_GET) && is_response)) { offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_info, &block_info); - proto_item_append_text(block_item, ", BlockInfo: %s", val_to_str(block_info, pn_dcp_block_info, "Unknown")); + proto_item_append_text(block_item, ", BlockInfo: %s", + val_to_str(block_info, pn_dcp_block_info, "Unknown")); block_length -= 2; } /* BlockQualifier? */ - if( (service_id == PNDCP_SERVICE_ID_SET) && !is_response) { + if ( (service_id == PNDCP_SERVICE_ID_SET) && !is_response) { offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_qualifier, &block_qualifier); - proto_item_append_text(block_item, ", BlockQualifier: %s", val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown")); + proto_item_append_text(block_item, ", BlockQualifier: %s", + val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown")); block_length -= 2; } @@ -730,24 +767,24 @@ dissect_PNDCP_Suboption_DeviceInitiative(tvbuff_t *tvb, int offset, packet_info /* dissect the "all" suboption */ static int -dissect_PNDCP_Suboption_All(tvbuff_t *tvb, int offset, packet_info *pinfo, +dissect_PNDCP_Suboption_All(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, proto_item *block_item, proto_item *dcp_item, guint8 service_id _U_, gboolean is_response _U_) { - guint8 suboption; + guint8 suboption; guint16 block_length; offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_all, &suboption); offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_length, &block_length); - switch(suboption) { - case(255): /* All */ + switch (suboption) { + case 255: /* All */ pn_append_info(pinfo, dcp_item, ", All"); proto_item_append_text(block_item, "All/All"); break; default: - offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length); + offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length); } return offset; @@ -756,22 +793,22 @@ dissect_PNDCP_Suboption_All(tvbuff_t *tvb, int offset, packet_info *pinfo, /* dissect the "manufacturer" suboption */ static int -dissect_PNDCP_Suboption_Manuf(tvbuff_t *tvb, int offset, packet_info *pinfo, +dissect_PNDCP_Suboption_Manuf(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, proto_item *block_item, proto_item *dcp_item, guint8 service_id _U_, gboolean is_response _U_) { - guint8 suboption; + guint8 suboption; guint16 block_length; - offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_manuf, &suboption); - offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_length, &block_length); + offset = dissect_pn_uint8( tvb, offset, pinfo, tree, hf_pn_dcp_suboption_manuf, &suboption); + offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_length, &block_length); - switch(suboption) { + switch (suboption) { default: pn_append_info(pinfo, dcp_item, ", Manufacturer Specific"); proto_item_append_text(block_item, "Manufacturer Specific"); - offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length); + offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length); } return offset; @@ -780,51 +817,51 @@ dissect_PNDCP_Suboption_Manuf(tvbuff_t *tvb, int offset, packet_info *pinfo, /* dissect one DCP block */ static int -dissect_PNDCP_Block(tvbuff_t *tvb, int offset, packet_info *pinfo, - proto_tree *tree, proto_item *dcp_item, +dissect_PNDCP_Block(tvbuff_t *tvb, int offset, packet_info *pinfo, + proto_tree *tree, proto_item *dcp_item, guint8 service_id, gboolean is_response) { - guint8 option; + guint8 option; proto_item *block_item; proto_tree *block_tree; - int ori_offset = offset; + int ori_offset = offset; /* subtree for block */ - block_item = proto_tree_add_none_format(tree, hf_pn_dcp_block, + block_item = proto_tree_add_none_format(tree, hf_pn_dcp_block, tvb, offset, 0, "Block: "); block_tree = proto_item_add_subtree(block_item, ett_pn_dcp_block); offset = dissect_pn_uint8(tvb, offset, pinfo, block_tree, hf_pn_dcp_option, &option); - switch(option) { - case(PNDCP_OPTION_IP): + switch (option) { + case PNDCP_OPTION_IP: offset = dissect_PNDCP_Suboption_IP(tvb, offset, pinfo, block_tree, block_item, dcp_item, service_id, is_response); break; - case(PNDCP_OPTION_DEVICE): + case PNDCP_OPTION_DEVICE: offset = dissect_PNDCP_Suboption_Device(tvb, offset, pinfo, block_tree, block_item, dcp_item, service_id, is_response); break; - case(PNDCP_OPTION_DHCP): + case PNDCP_OPTION_DHCP: offset = dissect_PNDCP_Suboption_DHCP(tvb, offset, pinfo, block_tree, block_item, dcp_item, service_id, is_response); break; - case(PNDCP_OPTION_CONTROL): + case PNDCP_OPTION_CONTROL: offset = dissect_PNDCP_Suboption_Control(tvb, offset, pinfo, block_tree, block_item, dcp_item, service_id, is_response); break; - case(PNDCP_OPTION_DEVICEINITIATIVE): + case PNDCP_OPTION_DEVICEINITIATIVE: offset = dissect_PNDCP_Suboption_DeviceInitiative(tvb, offset, pinfo, block_tree, block_item, dcp_item, service_id, is_response); break; - case(PNDCP_OPTION_ALLSELECTOR): + case PNDCP_OPTION_ALLSELECTOR: offset = dissect_PNDCP_Suboption_All(tvb, offset, pinfo, block_tree, block_item, dcp_item, service_id, is_response); break; - case(PNDCP_OPTION_MANUF_X80): - case(PNDCP_OPTION_MANUF_X81): + case PNDCP_OPTION_MANUF_X80: + case PNDCP_OPTION_MANUF_X81: default: offset = dissect_PNDCP_Suboption_Manuf(tvb, offset, pinfo, block_tree, block_item, dcp_item, service_id, is_response); } proto_item_set_len(block_item, offset-ori_offset); - if((offset-ori_offset) & 1) { + if ((offset-ori_offset) & 1) { /* we have an odd number of bytes in this block, add a padding byte */ offset = dissect_pn_padding(tvb, offset, pinfo, tree, 1); } @@ -835,23 +872,23 @@ dissect_PNDCP_Block(tvbuff_t *tvb, int offset, packet_info *pinfo, /* dissect a whole DCP PDU */ static void -dissect_PNDCP_PDU(tvbuff_t *tvb, +dissect_PNDCP_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *dcp_item) { - guint8 service_id; - guint8 service_type; - guint32 xid; - guint16 response_delay; - guint16 data_length; - int offset = 0; - gchar *xid_str; - gboolean is_response = FALSE; + guint8 service_id; + guint8 service_type; + guint32 xid; + guint16 response_delay; + guint16 data_length; + int offset = 0; + gchar *xid_str; + gboolean is_response = FALSE; offset = dissect_pn_uint8 (tvb, offset, pinfo, tree, hf_pn_dcp_service_id, &service_id); offset = dissect_pn_uint8 (tvb, offset, pinfo, tree, hf_pn_dcp_service_type, &service_type); offset = dissect_pn_uint32(tvb, offset, pinfo, tree, hf_pn_dcp_xid, &xid); - if(service_id == PNDCP_SERVICE_ID_IDENTIFY && service_type == PNDCP_SERVICE_TYPE_REQUEST) { + if (service_id == PNDCP_SERVICE_ID_IDENTIFY && service_type == PNDCP_SERVICE_TYPE_REQUEST) { /* multicast header */ offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_response_delay, &response_delay); } else { @@ -860,38 +897,38 @@ dissect_PNDCP_PDU(tvbuff_t *tvb, } offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_data_length, &data_length); - switch(service_id) { - case(PNDCP_SERVICE_ID_GET): + switch (service_id) { + case PNDCP_SERVICE_ID_GET: pn_append_info(pinfo, dcp_item, "Get"); break; - case(PNDCP_SERVICE_ID_SET): + case PNDCP_SERVICE_ID_SET: pn_append_info(pinfo, dcp_item, "Set"); break; - case(PNDCP_SERVICE_ID_IDENTIFY): + case PNDCP_SERVICE_ID_IDENTIFY: pn_append_info(pinfo, dcp_item, "Ident"); break; - case(PNDCP_SERVICE_ID_HELLO): + case PNDCP_SERVICE_ID_HELLO: pn_append_info(pinfo, dcp_item, "Hello"); break; default: - dissect_pn_undecoded(tvb, offset, pinfo, tree, tvb_length_remaining(tvb, offset)); + dissect_pn_undecoded(tvb, offset, pinfo, tree, tvb_length_remaining(tvb, offset)); return; } - switch(service_type) { - case(PNDCP_SERVICE_TYPE_REQUEST): + switch (service_type) { + case PNDCP_SERVICE_TYPE_REQUEST: pn_append_info(pinfo, dcp_item, " Req"); break; - case(PNDCP_SERVICE_TYPE_RESPONSE_SUCCESS): + case PNDCP_SERVICE_TYPE_RESPONSE_SUCCESS: pn_append_info(pinfo, dcp_item, " Ok "); is_response = TRUE; break; - case(PNDCP_SERVICE_TYPE_RESPONSE_UNSUPPORTED): + case PNDCP_SERVICE_TYPE_RESPONSE_UNSUPPORTED: pn_append_info(pinfo, dcp_item, " unsupported"); is_response = TRUE; break; default: - dissect_pn_undecoded(tvb, offset, pinfo, tree, tvb_length_remaining(tvb, offset)); + dissect_pn_undecoded(tvb, offset, pinfo, tree, tvb_length_remaining(tvb, offset)); return; } @@ -902,15 +939,15 @@ dissect_PNDCP_PDU(tvbuff_t *tvb, while(data_length) { int ori_offset = offset; - if(service_id == PNDCP_SERVICE_ID_GET && service_type == PNDCP_SERVICE_TYPE_REQUEST) { + if (service_id == PNDCP_SERVICE_ID_GET && service_type == PNDCP_SERVICE_TYPE_REQUEST) { /* Selectors */ - offset = dissect_PNDCP_Option(tvb, offset, pinfo, + offset = dissect_PNDCP_Option(tvb, offset, pinfo, tree, dcp_item, hf_pn_dcp_option, TRUE /* append_col */); } else { offset = dissect_PNDCP_Block(tvb, offset, pinfo, tree, dcp_item, service_id, is_response); } /* prevent an infinite loop */ - if(offset <= ori_offset || data_length < (offset - ori_offset)) { + if (offset <= ori_offset || data_length < (offset - ori_offset)) { THROW(ReportedBoundsError); } data_length -= (offset - ori_offset); @@ -923,9 +960,9 @@ static gboolean dissect_PNDCP_Data_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { - guint16 u16FrameID; - proto_item *item = NULL; - proto_tree *dcp_tree = NULL; + guint16 u16FrameID; + proto_item *item; + proto_tree *dcp_tree; /* the tvb will NOT contain the frame_id here, so get it from our private data! */ @@ -956,84 +993,186 @@ void proto_register_pn_dcp (void) { static hf_register_info hf[] = { - { &hf_pn_dcp_service_id, - { "ServiceID", "pn_dcp.service_id", FT_UINT8, BASE_DEC, VALS(pn_dcp_service_id), 0x0, NULL, HFILL }}, - { &hf_pn_dcp_service_type, - { "ServiceType", "pn_dcp.service_type", FT_UINT8, BASE_DEC, VALS(pn_dcp_service_type), 0x0, NULL, HFILL }}, - { &hf_pn_dcp_xid, - { "Xid", "pn_dcp.xid", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_dcp_reserved8, - { "Reserved", "pn_dcp.reserved8", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_dcp_reserved16, - { "Reserved", "pn_dcp.reserved16", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_dcp_response_delay, - { "ResponseDelay", "pn_dcp.response_delay", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_dcp_data_length, - { "DCPDataLength", "pn_dcp.data_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_dcp_block_length, - { "DCPBlockLength", "pn_dcp.block_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_dcp_option, - { "Option", "pn_dcp.option", FT_UINT8, BASE_DEC, VALS(pn_dcp_option), 0x0, NULL, HFILL }}, - { &hf_pn_dcp_suboption, - { "Suboption", "pn_dcp.suboption", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_dcp_block_error, - { "BlockError", "pn_dcp.block_error", FT_UINT8, BASE_DEC, VALS(pn_dcp_block_error), 0x0, NULL, HFILL }}, - { &hf_pn_dcp_block, - { "Block", "pn_dcp.block", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_dcp_block_info, - { "BlockInfo", "pn_dcp.block_info", FT_UINT16, BASE_DEC, VALS(pn_dcp_block_info), 0x0, NULL, HFILL }}, - { &hf_pn_dcp_block_qualifier, - { "BlockQualifier", "pn_dcp.block_qualifier", FT_UINT16, BASE_DEC, VALS(pn_dcp_block_qualifier), 0x0, NULL, HFILL }}, - { &hf_pn_dcp_suboption_ip, - { "Suboption", "pn_dcp.suboption_ip", FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_ip), 0x0, NULL, HFILL }}, - { &hf_pn_dcp_suboption_ip_block_info, - { "BlockInfo", "pn_dcp.suboption_ip_block_info", FT_UINT16, BASE_DEC, VALS(pn_dcp_suboption_ip_block_info), 0x0, NULL, HFILL }}, - { &hf_pn_dcp_suboption_ip_ip, - { "IPaddress", "pn_dcp.subobtion_ip_ip", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_dcp_suboption_ip_subnetmask, - { "Subnetmask", "pn_dcp.subobtion_ip_subnetmask", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_dcp_suboption_ip_standard_gateway, - { "StandardGateway", "pn_dcp.suboption_ip_standard_gateway", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - - { &hf_pn_dcp_suboption_device, - { "Suboption", "pn_dcp.suboption_device", FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_device), 0x0, NULL, HFILL }}, - { &hf_pn_dcp_suboption_device_typeofstation, - { "DeviceVendorValue", "pn_dcp.suboption_device_devicevendorvalue", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_dcp_suboption_device_nameofstation, - { "NameOfStation", "pn_dcp.suboption_device_nameofstation", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_dcp_suboption_vendor_id, - { "VendorID", "pn_dcp.suboption_vendor_id", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_dcp_suboption_device_id, - { "DeviceID", "pn_dcp.suboption_device_id", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_dcp_suboption_device_role, - { "DeviceRoleDetails", "pn_dcp.suboption_device_role", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_dcp_suboption_device_aliasname, - { "AliasName", "pn_dcp.suboption_device_aliasname", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_dcp_suboption_device_instance_high, - { "DeviceInstanceHigh", "pn_dcp.suboption_device_instance", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_dcp_suboption_device_instance_low, - { "DeviceInstanceLow", "pn_dcp.suboption_device_instance", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }}, - - { &hf_pn_dcp_suboption_dhcp, - { "Suboption", "pn_dcp.suboption_dhcp", FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_dhcp), 0x0, NULL, HFILL }}, - { &hf_pn_dcp_suboption_dhcp_device_id, - { "Device ID", "pn_dcp.suboption_dhcp_device_id", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - - { &hf_pn_dcp_suboption_control, - { "Suboption", "pn_dcp.suboption_control", FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_control), 0x0, NULL, HFILL }}, - { &hf_pn_dcp_suboption_control_response, - { "Response", "pn_dcp.suboption_control_response", FT_UINT8, BASE_DEC, VALS(pn_dcp_option), 0x0, NULL, HFILL }}, - - { &hf_pn_dcp_suboption_deviceinitiative, - { "Suboption", "pn_dcp.suboption_deviceinitiative", FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_deviceinitiative), 0x0, NULL, HFILL }}, - { &hf_pn_dcp_deviceinitiative_value, - { "DeviceInitiativeValue", "pn_dcp.deviceinitiative_value", FT_UINT16, BASE_DEC, VALS(pn_dcp_deviceinitiative_value), 0x0, NULL, HFILL }}, - - { &hf_pn_dcp_suboption_all, - { "Suboption", "pn_dcp.suboption_all", FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_all), 0x0, NULL, HFILL }}, - - { &hf_pn_dcp_suboption_manuf, - { "Suboption", "pn_dcp.suboption_manuf", FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_manuf), 0x0, NULL, HFILL }}, + { &hf_pn_dcp_service_id, + { "ServiceID", "pn_dcp.service_id", + FT_UINT8, BASE_DEC, VALS(pn_dcp_service_id), 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_service_type, + { "ServiceType", "pn_dcp.service_type", + FT_UINT8, BASE_DEC, VALS(pn_dcp_service_type), 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_xid, + { "Xid", "pn_dcp.xid", + FT_UINT32, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_reserved8, + { "Reserved", "pn_dcp.reserved8", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_reserved16, + { "Reserved", "pn_dcp.reserved16", + FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_response_delay, + { "ResponseDelay", "pn_dcp.response_delay", + FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_data_length, + { "DCPDataLength", "pn_dcp.data_length", + FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_block_length, + { "DCPBlockLength", "pn_dcp.block_length", + FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_option, + { "Option", "pn_dcp.option", + FT_UINT8, BASE_DEC, VALS(pn_dcp_option), 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_suboption, + { "Suboption", "pn_dcp.suboption", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_block_error, + { "BlockError", "pn_dcp.block_error", + FT_UINT8, BASE_DEC, VALS(pn_dcp_block_error), 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_block, + { "Block", "pn_dcp.block", + FT_NONE, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_block_info, + { "BlockInfo", "pn_dcp.block_info", + FT_UINT16, BASE_DEC, VALS(pn_dcp_block_info), 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_block_qualifier, + { "BlockQualifier", "pn_dcp.block_qualifier", + FT_UINT16, BASE_DEC, VALS(pn_dcp_block_qualifier), 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_suboption_ip, + { "Suboption", "pn_dcp.suboption_ip", + FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_ip), 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_suboption_ip_block_info, + { "BlockInfo", "pn_dcp.suboption_ip_block_info", + FT_UINT16, BASE_DEC, VALS(pn_dcp_suboption_ip_block_info), 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_suboption_ip_ip, + { "IPaddress", "pn_dcp.subobtion_ip_ip", + FT_IPv4, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_suboption_ip_subnetmask, + { "Subnetmask", "pn_dcp.subobtion_ip_subnetmask", + FT_IPv4, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_suboption_ip_standard_gateway, + { "StandardGateway", "pn_dcp.suboption_ip_standard_gateway", + FT_IPv4, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_suboption_device, + { "Suboption", "pn_dcp.suboption_device", + FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_device), 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_suboption_device_typeofstation, + { "DeviceVendorValue", "pn_dcp.suboption_device_devicevendorvalue", + FT_STRING, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_suboption_device_nameofstation, + { "NameOfStation", "pn_dcp.suboption_device_nameofstation", + FT_STRING, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_suboption_vendor_id, + { "VendorID", "pn_dcp.suboption_vendor_id", + FT_UINT16, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_suboption_device_id, + { "DeviceID", "pn_dcp.suboption_device_id", + FT_UINT16, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_suboption_device_role, + { "DeviceRoleDetails", "pn_dcp.suboption_device_role", + FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_suboption_device_aliasname, + { "AliasName", "pn_dcp.suboption_device_aliasname", + FT_STRING, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_suboption_device_instance_high, + { "DeviceInstanceHigh", "pn_dcp.suboption_device_instance", + FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_suboption_device_instance_low, + { "DeviceInstanceLow", "pn_dcp.suboption_device_instance", + FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_suboption_dhcp, + { "Suboption", "pn_dcp.suboption_dhcp", + FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_dhcp), 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_suboption_dhcp_device_id, + { "Device ID", "pn_dcp.suboption_dhcp_device_id", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_suboption_control, + { "Suboption", "pn_dcp.suboption_control", + FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_control), 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_suboption_control_response, + { "Response", "pn_dcp.suboption_control_response", + FT_UINT8, BASE_DEC, VALS(pn_dcp_option), 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_suboption_deviceinitiative, + { "Suboption", "pn_dcp.suboption_deviceinitiative", + FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_deviceinitiative), 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_deviceinitiative_value, + { "DeviceInitiativeValue", "pn_dcp.deviceinitiative_value", + FT_UINT16, BASE_DEC, VALS(pn_dcp_deviceinitiative_value), 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_suboption_all, + { "Suboption", "pn_dcp.suboption_all", + FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_all), 0x0, + NULL, HFILL }}, + + { &hf_pn_dcp_suboption_manuf, + { "Suboption", "pn_dcp.suboption_manuf", + FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_manuf), 0x0, + NULL, HFILL }}, + }; static gint *ett[] = { diff --git a/plugins/profinet/packet-pn-mrp.c b/plugins/profinet/packet-pn-mrp.c index b03ff9ae6f..46505cd281 100644 --- a/plugins/profinet/packet-pn-mrp.c +++ b/plugins/profinet/packet-pn-mrp.c @@ -58,29 +58,29 @@ static gint ett_pn_mrp = -1; static const value_string pn_mrp_block_type_vals[] = { - { 0x00, "End" }, - { 0x01, "Common" }, - { 0x02, "Test" }, - { 0x03, "TopologyChange" }, - { 0x04, "LinkDown" }, - { 0x05, "LinkUp" }, + { 0x00, "End" }, + { 0x01, "Common" }, + { 0x02, "Test" }, + { 0x03, "TopologyChange" }, + { 0x04, "LinkDown" }, + { 0x05, "LinkUp" }, /*0x06 - 0x7E Reserved */ - { 0x7F, "Organizationally Specific"}, - { 0, NULL }, + { 0x7F, "Organizationally Specific"}, + { 0, NULL }, }; static const value_string pn_mrp_oui_vals[] = { - { OUI_PROFINET, "PROFINET" }, - { OUI_SIEMENS, "SIEMENS" }, + { OUI_PROFINET, "PROFINET" }, + { OUI_SIEMENS, "SIEMENS" }, - { 0, NULL } + { 0, NULL } }; static const value_string pn_mrp_port_role_vals[] = { - { 0x0000, "Primary ring port" }, - { 0x0001, "Secondary ring port"}, + { 0x0000, "Primary ring port" }, + { 0x0001, "Secondary ring port"}, /*0x0002 - 0xFFFF Reserved */ { 0, NULL } @@ -96,8 +96,8 @@ static const value_string pn_mrp_role_vals[] = { }; static const value_string pn_mrp_ring_state_vals[] = { - { 0x0000, "Ring open" }, - { 0x0001, "Ring closed"}, + { 0x0000, "Ring open" }, + { 0x0001, "Ring closed"}, /*0x0002 - 0xFFFF Reserved */ { 0, NULL } @@ -105,7 +105,7 @@ static const value_string pn_mrp_ring_state_vals[] = { static const value_string pn_mrp_prio_vals[] = { - { 0x8000, "Default priority for redundancy manager" }, + { 0x8000, "Default priority for redundancy manager" }, { 0, NULL } }; @@ -115,8 +115,8 @@ int dissect_pn_uint16_ret_item(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, proto_tree *tree, int hfindex, guint16 *pdata, proto_item ** new_item) { - guint16 data; - proto_item *item = NULL; + guint16 data; + proto_item *item = NULL; data = tvb_get_ntohs (tvb, offset); @@ -125,7 +125,7 @@ dissect_pn_uint16_ret_item(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, } if (pdata) *pdata = data; - if(new_item) + if (new_item) *new_item = item; return offset + 2; } @@ -134,9 +134,9 @@ dissect_pn_uint16_ret_item(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, static int dissect_PNMRP_Common(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item) + packet_info *pinfo, proto_tree *tree, proto_item *item) { - guint16 sequence_id; + guint16 sequence_id; e_uuid_t uuid; @@ -156,9 +156,9 @@ dissect_PNMRP_Common(tvbuff_t *tvb, int offset, #if 0 static int dissect_PNMRP_LinkUp(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item) + packet_info *pinfo, proto_tree *tree, proto_item *item) { - guint8 mac[6]; + guint8 mac[6]; guint16 port_role; guint16 interval; guint16 blocked; @@ -188,12 +188,12 @@ dissect_PNMRP_LinkUp(tvbuff_t *tvb, int offset, static int dissect_PNMRP_LinkDown(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item) + packet_info *pinfo, proto_tree *tree, proto_item *item) { - guint8 mac[6]; - guint16 port_role; - guint16 interval; - guint16 blocked; + guint8 mac[6]; + guint16 port_role; + guint16 interval; + guint16 blocked; proto_item *sub_item; /* MRP_SA */ @@ -204,10 +204,10 @@ dissect_PNMRP_LinkDown(tvbuff_t *tvb, int offset, /* MRP_Interval */ offset = dissect_pn_uint16_ret_item(tvb, offset, pinfo, tree, hf_pn_mrp_interval, &interval, &sub_item); - if(tree) + if (tree) { proto_item_append_text(sub_item,"Interval for next topology change event (in ms)"); - if(interval <0x07D1) + if (interval <0x07D1) proto_item_append_text(sub_item,"Mandatory"); else proto_item_append_text(sub_item,"Optional"); @@ -257,20 +257,20 @@ if (prio ==0xFFFF) static int dissect_PNMRP_Test(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item) + packet_info *pinfo, proto_tree *tree, proto_item *item) { - guint16 prio; - guint8 mac[6]; - guint16 port_role; - guint16 ring_state; - guint16 transition; - guint32 time_stamp; + guint16 prio; + guint8 mac[6]; + guint16 port_role; + guint16 ring_state; + guint16 transition; + guint32 time_stamp; proto_item *sub_item; /* MRP_Prio */ offset = dissect_pn_uint16_ret_item(tvb, offset, pinfo, tree, hf_pn_mrp_prio, &prio, &sub_item); - if(tree) + if (tree) proto_item_append_text(sub_item, "%s", mrp_Prio2msg(prio)); /* MRP_SA */ @@ -292,7 +292,7 @@ dissect_PNMRP_Test(tvbuff_t *tvb, int offset, offset = dissect_pn_align4(tvb, offset, pinfo, tree); col_append_str(pinfo->cinfo, COL_INFO, "Test"); - if(tree) + if (tree) proto_item_append_text(item, "Test"); return offset; @@ -301,17 +301,17 @@ dissect_PNMRP_Test(tvbuff_t *tvb, int offset, static int dissect_PNMRP_TopologyChange(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item) + packet_info *pinfo, proto_tree *tree, proto_item *item) { - guint16 prio; - guint8 mac[6]; - guint16 interval; + guint16 prio; + guint8 mac[6]; + guint16 interval; proto_item *sub_item; /* MRP_Prio */ offset = dissect_pn_uint16_ret_item(tvb, offset, pinfo, tree, hf_pn_mrp_prio, &prio, &sub_item); - if(tree) + if (tree) proto_item_append_text(sub_item, "%s", mrp_Prio2msg(prio)); /* MRP_SA */ @@ -319,10 +319,10 @@ dissect_PNMRP_TopologyChange(tvbuff_t *tvb, int offset, /* MRP_Interval */ offset = dissect_pn_uint16_ret_item(tvb, offset, pinfo, tree, hf_pn_mrp_interval, &interval, &sub_item); - if(tree) + if (tree) { proto_item_append_text(sub_item," Interval for next topology change event (in ms) "); - if(interval <0x07D1) + if (interval <0x07D1) proto_item_append_text(sub_item,"Mandatory"); else proto_item_append_text(sub_item,"Optional"); @@ -331,7 +331,7 @@ dissect_PNMRP_TopologyChange(tvbuff_t *tvb, int offset, /*offset = dissect_pn_align4(tvb, offset, pinfo, tree);*/ col_append_str(pinfo->cinfo, COL_INFO, "TopologyChange"); - if(tree) + if (tree) proto_item_append_text(item, "TopologyChange"); return offset; @@ -353,7 +353,7 @@ dissect_pn_ManuData(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, static int dissect_PNMRP_Option(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item, guint8 length) + packet_info *pinfo, proto_tree *tree, proto_item *item, guint8 length) { guint32 oui; @@ -363,20 +363,20 @@ dissect_PNMRP_Option(tvbuff_t *tvb, int offset, length -= 3; switch (oui) - { - case OUI_SIEMENS: + { + case OUI_SIEMENS: proto_item_append_text(item, "Option(SIEMENS)"); /* No Padding ! if (offset % 4) { length -= 4 - (offset % 4); offset = dissect_pn_align4(tvb, offset, pinfo, tree); } */ - if(length != 0) { + if (length != 0) { offset = dissect_pn_ManuData(tvb, offset, pinfo, tree, length); } col_append_str(pinfo->cinfo, COL_INFO, "Option(Siemens)"); - break; - default: + break; + default: proto_item_append_text(item, "Option(Unknown-OUI)"); offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, length); @@ -392,12 +392,12 @@ dissect_PNMRP_Option(tvbuff_t *tvb, int offset, static int dissect_PNMRP_PDU(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item) + packet_info *pinfo, proto_tree *tree, proto_item *item) { - guint16 version; - guint8 type; - guint8 length; - gint i; + guint16 version; + guint8 type; + guint8 length; + gint i; tvbuff_t *new_tvb; @@ -416,40 +416,40 @@ dissect_PNMRP_PDU(tvbuff_t *tvb, int offset, /* MRP_TLVHeader.Length */ offset = dissect_pn_uint8(new_tvb, offset, pinfo, tree, hf_pn_mrp_length, &length); - if(i != 0) { + if (i != 0) { col_append_str(pinfo->cinfo, COL_INFO, ", "); proto_item_append_text(item, ", "); } switch(type) { - case(0x00): + case 0x00: /* no content */ col_append_str(pinfo->cinfo, COL_INFO, "End"); proto_item_append_text(item, "End"); return offset; break; - case(0x01): + case 0x01: offset = dissect_PNMRP_Common(new_tvb, offset, pinfo, tree, item); break; - case(0x02): + case 0x02: offset = dissect_PNMRP_Test(new_tvb, offset, pinfo, tree, item); break; - case(0x03): + case 0x03: offset = dissect_PNMRP_TopologyChange(new_tvb, offset, pinfo, tree, item); break; - case(0x04): - case(0x05): /* dissection of up and down is identical! */ + case 0x04: + case 0x05: /* dissection of up and down is identical! */ offset = dissect_PNMRP_LinkDown(new_tvb, offset, pinfo, tree, item); break; - case(0x7f): + case 0x7f: offset = dissect_PNMRP_Option(new_tvb, offset, pinfo, tree, item, length); break; default: offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, length); - col_append_fstr(pinfo->cinfo, COL_INFO, "Unknown TLVType 0x%x", type); - proto_item_append_text(item, "Unknown TLVType 0x%x", type); + col_append_fstr(pinfo->cinfo, COL_INFO, "Unknown TLVType 0x%x", type); + proto_item_append_text(item, "Unknown TLVType 0x%x", type); } } @@ -461,7 +461,7 @@ dissect_PNMRP_PDU(tvbuff_t *tvb, int offset, static void dissect_PNMRP(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - proto_item *ti = NULL; + proto_item *ti = NULL; proto_tree *mrp_tree = NULL; guint32 offset = 0; @@ -484,57 +484,101 @@ dissect_PNMRP(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) void proto_register_pn_mrp (void) { - static hf_register_info hf[] = { - { &hf_pn_mrp_type, - { "MRP_TLVHeader.Type", "pn_mrp.type", FT_UINT8, BASE_HEX, VALS(pn_mrp_block_type_vals), 0x0, NULL, HFILL }}, - { &hf_pn_mrp_length, - { "MRP_TLVHeader.Length", "pn_mrp.length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_mrp_version, - { "MRP_Version", "pn_mrp.version", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_mrp_sequence_id, - { "MRP_SequenceID", "pn_mrp.sequence_id", FT_UINT16, BASE_HEX, NULL, 0x0, "Unique sequence number to each outstanding service request", HFILL }}, - { &hf_pn_mrp_sa, - { "MRP_SA", "pn_mrp.sa", FT_ETHER, BASE_NONE, 0x0, 0x0, NULL, HFILL }}, - { &hf_pn_mrp_prio, - { "MRP_Prio", "pn_mrp.prio", FT_UINT16, BASE_HEX, 0, 0x0, NULL, HFILL }}, - { &hf_pn_mrp_port_role, - { "MRP_PortRole", "pn_mrp.port_role", FT_UINT16, BASE_HEX, VALS(pn_mrp_port_role_vals), 0x0, NULL, HFILL }}, - { &hf_pn_mrp_ring_state, - { "MRP_RingState", "pn_mrp.ring_state", FT_UINT16, BASE_HEX, VALS(pn_mrp_ring_state_vals), 0x0, NULL, HFILL }}, - { &hf_pn_mrp_interval, - { "MRP_Interval", "pn_mrp.interval", FT_UINT16, BASE_DEC, NULL, 0x0, "Interval for next topology change event (in ms)", HFILL }}, - { &hf_pn_mrp_transition, - { "MRP_Transition", "pn_mrp.transition", FT_UINT16, BASE_HEX, NULL, 0x0, "Number of transitions between media redundancy lost and ok states", HFILL }}, - { &hf_pn_mrp_time_stamp, - { "MRP_TimeStamp [ms]", "pn_mrp.time_stamp", FT_UINT32, BASE_HEX, NULL, 0x0, "Actual counter value of 1ms counter", HFILL }}, - { &hf_pn_mrp_blocked, - { "MRP_Blocked", "pn_mrp.blocked", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_manufacturer_data, - { "MRP_ManufacturerData", "pn_mrp.ManufacturerData", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_mrp_domain_uuid, - { "MRP_DomainUUID", "pn_mrp.domain_uuid", FT_GUID, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_mrp_oui, - { "MRP_ManufacturerOUIr", "pn_mrp.oui", FT_UINT24, BASE_HEX, - VALS(pn_mrp_oui_vals), 0x0, NULL, HFILL }}, + static hf_register_info hf[] = { + { &hf_pn_mrp_type, + { "MRP_TLVHeader.Type", "pn_mrp.type", + FT_UINT8, BASE_HEX, VALS(pn_mrp_block_type_vals), 0x0, + NULL, HFILL }}, + + { &hf_pn_mrp_length, + { "MRP_TLVHeader.Length", "pn_mrp.length", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_mrp_version, + { "MRP_Version", "pn_mrp.version", + FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_mrp_sequence_id, + { "MRP_SequenceID", "pn_mrp.sequence_id", + FT_UINT16, BASE_HEX, NULL, 0x0, + "Unique sequence number to each outstanding service request", HFILL }}, + + { &hf_pn_mrp_sa, + { "MRP_SA", "pn_mrp.sa", + FT_ETHER, BASE_NONE, 0x0, 0x0, + NULL, HFILL }}, + + { &hf_pn_mrp_prio, + { "MRP_Prio", "pn_mrp.prio", + FT_UINT16, BASE_HEX, 0, 0x0, + NULL, HFILL }}, + + { &hf_pn_mrp_port_role, + { "MRP_PortRole", "pn_mrp.port_role", + FT_UINT16, BASE_HEX, VALS(pn_mrp_port_role_vals), 0x0, + NULL, HFILL }}, + + { &hf_pn_mrp_ring_state, + { "MRP_RingState", "pn_mrp.ring_state", + FT_UINT16, BASE_HEX, VALS(pn_mrp_ring_state_vals), 0x0, + NULL, HFILL }}, + + { &hf_pn_mrp_interval, + { "MRP_Interval", "pn_mrp.interval", + FT_UINT16, BASE_DEC, NULL, 0x0, + "Interval for next topology change event (in ms)", HFILL }}, + + { &hf_pn_mrp_transition, + { "MRP_Transition", "pn_mrp.transition", + FT_UINT16, BASE_HEX, NULL, 0x0, + "Number of transitions between media redundancy lost and ok states", HFILL }}, + + { &hf_pn_mrp_time_stamp, + { "MRP_TimeStamp [ms]", "pn_mrp.time_stamp", + FT_UINT32, BASE_HEX, NULL, 0x0, + "Actual counter value of 1ms counter", HFILL }}, + + { &hf_pn_mrp_blocked, + { "MRP_Blocked", "pn_mrp.blocked", + FT_UINT16, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_manufacturer_data, + { "MRP_ManufacturerData", "pn_mrp.ManufacturerData", + FT_STRING, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_mrp_domain_uuid, + { "MRP_DomainUUID", "pn_mrp.domain_uuid", + FT_GUID, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_mrp_oui, + { "MRP_ManufacturerOUIr", "pn_mrp.oui", + FT_UINT24, BASE_HEX, VALS(pn_mrp_oui_vals), 0x0, + NULL, HFILL }}, + }; - static gint *ett[] = { - &ett_pn_mrp + static gint *ett[] = { + &ett_pn_mrp }; proto_pn_mrp = proto_register_protocol ("PROFINET MRP", "PN-MRP", "pn_mrp"); - proto_register_field_array (proto_pn_mrp, hf, array_length (hf)); - proto_register_subtree_array (ett, array_length (ett)); + proto_register_field_array (proto_pn_mrp, hf, array_length (hf)); + proto_register_subtree_array (ett, array_length (ett)); } void proto_reg_handoff_pn_mrp (void) { - dissector_handle_t mrp_handle; + dissector_handle_t mrp_handle; - mrp_handle = create_dissector_handle(dissect_PNMRP,proto_pn_mrp); - dissector_add_uint("ethertype", ETHERTYPE_MRP, mrp_handle); + mrp_handle = create_dissector_handle(dissect_PNMRP,proto_pn_mrp); + dissector_add_uint("ethertype", ETHERTYPE_MRP, mrp_handle); } diff --git a/plugins/profinet/packet-pn-mrrt.c b/plugins/profinet/packet-pn-mrrt.c index 33f15edc2f..a604b22b47 100644 --- a/plugins/profinet/packet-pn-mrrt.c +++ b/plugins/profinet/packet-pn-mrrt.c @@ -1,5 +1,5 @@ /* packet-pn-mrrt.c - * Routines for PN-MRRT (PROFINET Media Redundancy for cyclic realtime data) + * Routines for PN-MRRT (PROFINET Media Redundancy for cyclic realtime data) * packet dissection. * * $Id$ @@ -7,17 +7,17 @@ * Wireshark - Network traffic analyzer * By Gerald Combs <gerald@wireshark.org> * Copyright 1998 Gerald Combs - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. @@ -26,6 +26,7 @@ #include "config.h" #include <glib.h> + #include <epan/packet.h> #include <epan/dissectors/packet-dcerpc.h> #include <epan/oui.h> @@ -47,22 +48,22 @@ static gint ett_pn_mrrt = -1; static const value_string pn_mrrt_block_type_vals[] = { - { 0x00, "End" }, - { 0x01, "Common" }, - { 0x02, "Test" }, + { 0x00, "End" }, + { 0x01, "Common" }, + { 0x02, "Test" }, /*0x03 - 0x7E Reserved */ - { 0x7F, "Organizationally Specific"}, - { 0, NULL }, + { 0x7F, "Organizationally Specific"}, + { 0, NULL }, }; static int -dissect_PNMRRT_Common(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item, guint8 length _U_) +dissect_PNMRRT_Common(tvbuff_t *tvb, int offset, + packet_info *pinfo, proto_tree *tree, proto_item *item, guint8 length _U_) { - guint16 sequence_id; + guint16 sequence_id; e_uuid_t uuid; @@ -81,8 +82,8 @@ dissect_PNMRRT_Common(tvbuff_t *tvb, int offset, static int -dissect_PNMRRT_Test(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item, guint8 length _U_) +dissect_PNMRRT_Test(tvbuff_t *tvb, int offset, + packet_info *pinfo, proto_tree *tree, proto_item *item, guint8 length _U_) { guint8 mac[6]; @@ -101,19 +102,19 @@ dissect_PNMRRT_Test(tvbuff_t *tvb, int offset, } static int -dissect_PNMRRT_PDU(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item) +dissect_PNMRRT_PDU(tvbuff_t *tvb, int offset, + packet_info *pinfo, proto_tree *tree, proto_item *item) { guint16 version; - guint8 type; - guint8 length; - gint i =0; + guint8 type; + guint8 length; + gint i = 0; /* MRRT_Version */ offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_mrrt_version, &version); - while(tvb_length_remaining(tvb, offset) > 0) { + while (tvb_length_remaining(tvb, offset) > 0) { /* MRRT_TLVHeader.Type */ offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_mrrt_type, &type); @@ -121,7 +122,7 @@ dissect_PNMRRT_PDU(tvbuff_t *tvb, int offset, offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_mrrt_length, &length); - if(i != 0) { + if (i != 0) { col_append_str(pinfo->cinfo, COL_INFO, ", "); proto_item_append_text(item, ", "); @@ -130,23 +131,24 @@ dissect_PNMRRT_PDU(tvbuff_t *tvb, int offset, i++; switch(type) { - case(0x00): + case 0x00: /* no content */ col_append_str(pinfo->cinfo, COL_INFO, "End"); proto_item_append_text(item, "End"); return offset; break; - case(0x01): + case 0x01: offset = dissect_PNMRRT_Common(tvb, offset, pinfo, tree, item, length); break; - case(0x02): + case 0x02: offset = dissect_PNMRRT_Test(tvb, offset, pinfo, tree, item, length); break; default: offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, length); - col_append_fstr(pinfo->cinfo, COL_INFO, "Unknown TLVType 0x%x", type); - proto_item_append_text(item, "Unknown TLVType 0x%x", type); + col_append_fstr(pinfo->cinfo, COL_INFO, "Unknown TLVType 0x%x", type); + proto_item_append_text(item, "Unknown TLVType 0x%x", type); + break; } } @@ -159,33 +161,33 @@ static gboolean dissect_PNMRRT_Data_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { - guint16 u16FrameID; - proto_item *item = NULL; - proto_tree *mrrt_tree = NULL; - int offset = 0; - guint32 u32SubStart; + guint16 u16FrameID; + proto_item *item; + proto_tree *mrrt_tree; + int offset = 0; + guint32 u32SubStart; /* the tvb will NOT contain the frame_id here, so get it from our private data! */ u16FrameID = GPOINTER_TO_UINT(pinfo->private_data); - /* frame id must be in valid range (MRRT) */ - if (u16FrameID != 0xFF60) { + /* frame id must be in valid range (MRRT) */ + if (u16FrameID != 0xFF60) { /* we are not interested in this packet */ return FALSE; } - + col_set_str(pinfo->cinfo, COL_PROTOCOL, "PN-MRRT"); col_clear(pinfo->cinfo, COL_INFO); /* subtree for MRRT */ - item = proto_tree_add_protocol_format(tree, proto_pn_mrrt, tvb, 0, 0, "PROFINET MRRT, "); - mrrt_tree = proto_item_add_subtree(item, ett_pn_mrrt); + item = proto_tree_add_protocol_format(tree, proto_pn_mrrt, tvb, 0, 0, "PROFINET MRRT, "); + mrrt_tree = proto_item_add_subtree(item, ett_pn_mrrt); u32SubStart = offset; offset = dissect_PNMRRT_PDU(tvb, offset, pinfo, mrrt_tree, item); - proto_item_set_len(item, offset - u32SubStart); + proto_item_set_len(item, offset - u32SubStart); return TRUE; } @@ -194,30 +196,48 @@ dissect_PNMRRT_Data_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void proto_register_pn_mrrt (void) { - static hf_register_info hf[] = { - - { &hf_pn_mrrt_type, - { "Type", "pn_mrrt.type", FT_UINT8, BASE_HEX, VALS(pn_mrrt_block_type_vals), 0x0, NULL, HFILL }}, - { &hf_pn_mrrt_length, - { "Length", "pn_mrrt.length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_mrrt_version, - { "Version", "pn_mrrt.version", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_mrrt_sequence_id, - { "SequenceID", "pn_mrrt.sequence_id", FT_UINT16, BASE_HEX, NULL, 0x0, "Unique sequence number to each outstanding service request", HFILL }}, - { &hf_pn_mrrt_sa, - { "SA", "pn_mrrt.sa", FT_ETHER, BASE_NONE, 0x0, 0x0, NULL, HFILL }}, - { &hf_pn_mrrt_domain_uuid, - { "DomainUUID", "pn_mrrt.domain_uuid", FT_GUID, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + static hf_register_info hf[] = { + + { &hf_pn_mrrt_type, + { "Type", "pn_mrrt.type", + FT_UINT8, BASE_HEX, VALS(pn_mrrt_block_type_vals), 0x0, + NULL, HFILL }}, + + { &hf_pn_mrrt_length, + { "Length", "pn_mrrt.length", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_mrrt_version, + { "Version", "pn_mrrt.version", + FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_mrrt_sequence_id, + { "SequenceID", "pn_mrrt.sequence_id", + FT_UINT16, BASE_HEX, NULL, 0x0, + "Unique sequence number to each outstanding service request", HFILL }}, + + { &hf_pn_mrrt_sa, + { "SA", "pn_mrrt.sa", + FT_ETHER, BASE_NONE, 0x0, 0x0, + NULL, HFILL }}, + + { &hf_pn_mrrt_domain_uuid, + { "DomainUUID", "pn_mrrt.domain_uuid", + FT_GUID, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + }; - static gint *ett[] = { - &ett_pn_mrrt + static gint *ett[] = { + &ett_pn_mrrt }; - proto_pn_mrrt = proto_register_protocol ("PROFINET MRRT", "PN-MRRT", "pn_mrrt"); - proto_register_field_array (proto_pn_mrrt, hf, array_length (hf)); - proto_register_subtree_array (ett, array_length (ett)); + proto_pn_mrrt = proto_register_protocol ("PROFINET MRRT", "PN-MRRT", "pn_mrrt"); + proto_register_field_array (proto_pn_mrrt, hf, array_length (hf)); + proto_register_subtree_array (ett, array_length (ett)); } @@ -226,5 +246,5 @@ proto_reg_handoff_pn_mrrt (void) { /* register ourself as an heuristic pn-rt payload dissector */ - heur_dissector_add("pn_rt", dissect_PNMRRT_Data_heur, proto_pn_mrrt); + heur_dissector_add("pn_rt", dissect_PNMRRT_Data_heur, proto_pn_mrrt); } diff --git a/plugins/profinet/packet-pn-ptcp.c b/plugins/profinet/packet-pn-ptcp.c index 164b88762d..7a18cc1170 100644 --- a/plugins/profinet/packet-pn-ptcp.c +++ b/plugins/profinet/packet-pn-ptcp.c @@ -88,7 +88,7 @@ static gint ett_pn_ptcp_header = -1; static gint ett_pn_ptcp_block = -1; static gint ett_pn_ptcp_block_header = -1; -#define OUI_PROFINET_MULTICAST 0x010ECF /* PROFIBUS Nutzerorganisation e.V. */ +#define OUI_PROFINET_MULTICAST 0x010ECF /* PROFIBUS Nutzerorganisation e.V. */ #define PN_PTCP_BT_END 0x00 @@ -104,89 +104,89 @@ static gint ett_pn_ptcp_block_header = -1; static const value_string pn_ptcp_block_type[] = { - { PN_PTCP_BT_END, "End" }, - { PN_PTCP_BT_SUBDOMAIN, "Subdomain"}, - { PN_PTCP_BT_TIME, "Time"}, - { PN_PTCP_BT_TIME_EXTENSION, "TimeExtension"}, - { PN_PTCP_BT_MASTER, "Master"}, - { PN_PTCP_BT_PORT_PARAMETER, "PortParameter"}, - { PN_PTCP_BT_DELAY_PARAMETER, "DelayParameter"}, - { PN_PTCP_BT_PORT_TIME, "PortTime"}, + { PN_PTCP_BT_END, "End" }, + { PN_PTCP_BT_SUBDOMAIN, "Subdomain"}, + { PN_PTCP_BT_TIME, "Time"}, + { PN_PTCP_BT_TIME_EXTENSION, "TimeExtension"}, + { PN_PTCP_BT_MASTER, "Master"}, + { PN_PTCP_BT_PORT_PARAMETER, "PortParameter"}, + { PN_PTCP_BT_DELAY_PARAMETER, "DelayParameter"}, + { PN_PTCP_BT_PORT_TIME, "PortTime"}, /*0x08 - 0x7E Reserved */ - { PN_PTCP_BT_OPTION, "Organizationally Specific"}, + { PN_PTCP_BT_OPTION, "Organizationally Specific"}, { 0, NULL } }; static const value_string pn_ptcp_oui_vals[] = { - { OUI_PROFINET, "PROFINET" }, - { OUI_PROFINET_MULTICAST, "PROFINET" }, - { 0, NULL } + { OUI_PROFINET, "PROFINET" }, + { OUI_PROFINET_MULTICAST, "PROFINET" }, + { 0, NULL } }; static const value_string pn_ptcp_master_prio1_vals[] = { - { 0x00, "Sync slave" }, - { 0x01, "Primary master" }, - { 0x02, "Secondary master" }, - { 0x03, "Reserved" }, - { 0x04, "Reserved" }, - { 0x05, "Reserved" }, - { 0x06, "Reserved" }, - { 0x07, "Reserved" }, - { 0, NULL } + { 0x00, "Sync slave" }, + { 0x01, "Primary master" }, + { 0x02, "Secondary master" }, + { 0x03, "Reserved" }, + { 0x04, "Reserved" }, + { 0x05, "Reserved" }, + { 0x06, "Reserved" }, + { 0x07, "Reserved" }, + { 0, NULL } }; static const value_string pn_ptcp_master_prio1_levels[] = { - { 0x00, "Level 0 (highest)" }, - { 0x01, "Level 1" }, - { 0x02, "Level 2" }, - { 0x03, "Level 3" }, - { 0x04, "Level 4" }, - { 0x05, "Level 5" }, - { 0x06, "Level 6" }, - { 0x07, "Level 7 (lowest)" }, - { 0, NULL } + { 0x00, "Level 0 (highest)" }, + { 0x01, "Level 1" }, + { 0x02, "Level 2" }, + { 0x03, "Level 3" }, + { 0x04, "Level 4" }, + { 0x05, "Level 5" }, + { 0x06, "Level 6" }, + { 0x07, "Level 7 (lowest)" }, + { 0, NULL } }; static const value_string pn_ptcp_master_prio1_vals_active[] = { - { 0x00, "inactive" }, - { 0x01, "active" }, - { 0, NULL } + { 0x00, "inactive" }, + { 0x01, "active" }, + { 0, NULL } }; static const value_string pn_ptcp_master_prio1_short_vals[] = { - { 0x01, "Primary" }, - { 0x02, "Secondary" }, - { 0, NULL } + { 0x01, "Primary" }, + { 0x02, "Secondary" }, + { 0, NULL } }; static const value_string pn_ptcp_master_prio2_vals[] = { - { 0xFF, "Default" }, - { 0, NULL } + { 0xFF, "Default" }, + { 0, NULL } }; static const value_string pn_ptcp_clock_class_vals[] = { - { 0xFF, "Slave-only clock" }, - { 0, NULL } + { 0xFF, "Slave-only clock" }, + { 0, NULL } }; static const value_string pn_ptcp_clock_accuracy_vals[] = { - { 0x20, "25ns" }, - { 0x21, "100ns (Default)" }, - { 0x22, "250ns" }, - { 0x23, "1us" }, - { 0x24, "2.5us" }, - { 0x25, "10us" }, - { 0x26, "25us" }, - { 0x27, "100us" }, - { 0x28, "250us" }, - { 0x29, "1ms" }, - { 0xFE, "Unknown" }, - { 0, NULL } + { 0x20, "25ns" }, + { 0x21, "100ns (Default)" }, + { 0x22, "250ns" }, + { 0x23, "1us" }, + { 0x24, "2.5us" }, + { 0x25, "10us" }, + { 0x26, "25us" }, + { 0x27, "100us" }, + { 0x28, "250us" }, + { 0x29, "1ms" }, + { 0xFE, "Unknown" }, + { 0, NULL } }; static const value_string pn_ptcp_profinet_subtype_vals[] = { - { 0x01, "RTData" }, - { 0, NULL } + { 0x01, "RTData" }, + { 0, NULL } }; @@ -194,7 +194,7 @@ static const value_string pn_ptcp_profinet_subtype_vals[] = { static int dissect_PNPTCP_TLVHeader(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 *type, guint16 *length) + packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 *type, guint16 *length) { guint16 tl_type; guint16 tl_length; @@ -205,7 +205,7 @@ dissect_PNPTCP_TLVHeader(tvbuff_t *tvb, int offset, *type = tl_type >> 9; /* Length */ - offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_ptcp_tl_length, &tl_length); + offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_ptcp_tl_length, &tl_length); *length = tl_length & 0x1FF; return offset; @@ -214,9 +214,9 @@ dissect_PNPTCP_TLVHeader(tvbuff_t *tvb, int offset, static int dissect_PNPTCP_Subdomain(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 u16FrameID) + packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 u16FrameID) { - guint8 mac[6]; + guint8 mac[6]; e_uuid_t uuid; @@ -226,20 +226,20 @@ dissect_PNPTCP_Subdomain(tvbuff_t *tvb, int offset, /* SubdomainUUID */ offset = dissect_pn_uuid(tvb, offset, pinfo, tree, hf_pn_ptcp_subdomain_uuid, &uuid); - if(u16FrameID == 0xff00 || u16FrameID == 0xff01) { - col_append_fstr(pinfo->cinfo, COL_INFO, ", Master=%02x:%02x:%02x:%02x:%02x:%02x", + if ((u16FrameID == 0xff00) || (u16FrameID == 0xff01)) { + col_append_fstr(pinfo->cinfo, COL_INFO, ", Master=%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); } - proto_item_append_text(item, ": MasterSource=%02x:%02x:%02x:%02x:%02x:%02x", + proto_item_append_text(item, ": MasterSource=%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); proto_item_append_text(item, ", Subdomain=%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - uuid.Data1, uuid.Data2, uuid.Data3, - uuid.Data4[0], uuid.Data4[1], - uuid.Data4[2], uuid.Data4[3], - uuid.Data4[4], uuid.Data4[5], - uuid.Data4[6], uuid.Data4[7]); + uuid.Data1, uuid.Data2, uuid.Data3, + uuid.Data4[0], uuid.Data4[1], + uuid.Data4[2], uuid.Data4[3], + uuid.Data4[4], uuid.Data4[5], + uuid.Data4[6], uuid.Data4[7]); return offset; } @@ -247,7 +247,7 @@ dissect_PNPTCP_Subdomain(tvbuff_t *tvb, int offset, static int dissect_PNPTCP_Time(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item) + packet_info *pinfo, proto_tree *tree, proto_item *item) { guint16 EpochNumber; guint32 Seconds; @@ -263,10 +263,10 @@ dissect_PNPTCP_Time(tvbuff_t *tvb, int offset, /* NanoSeconds */ offset = dissect_pn_uint32(tvb, offset, pinfo, tree, hf_pn_ptcp_nanoseconds, &NanoSeconds); - proto_item_append_text(item, ": Seconds=%u NanoSeconds=%u EpochNumber=%u", + proto_item_append_text(item, ": Seconds=%u NanoSeconds=%u EpochNumber=%u", Seconds, NanoSeconds, EpochNumber); - col_append_fstr(pinfo->cinfo, COL_INFO, ", Time: %4us %09uns, Epoch: %u", + col_append_fstr(pinfo->cinfo, COL_INFO, ", Time: %4us %09uns, Epoch: %u", Seconds, NanoSeconds, EpochNumber); return offset; @@ -275,7 +275,7 @@ dissect_PNPTCP_Time(tvbuff_t *tvb, int offset, static int dissect_PNPTCP_TimeExtension(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item) + packet_info *pinfo, proto_tree *tree, proto_item *item) { guint16 Flags; guint16 CurrentUTCOffset; @@ -290,7 +290,7 @@ dissect_PNPTCP_TimeExtension(tvbuff_t *tvb, int offset, /* Padding */ offset = dissect_pn_align4(tvb, offset, pinfo, tree); - proto_item_append_text(item, ": Flags=0x%x, CurrentUTCOffset=%u", Flags, CurrentUTCOffset); + proto_item_append_text(item, ": Flags=0x%x, CurrentUTCOffset=%u", Flags, CurrentUTCOffset); return offset; } @@ -298,7 +298,7 @@ dissect_PNPTCP_TimeExtension(tvbuff_t *tvb, int offset, static int dissect_PNPTCP_Master(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item) + packet_info *pinfo, proto_tree *tree, proto_item *item) { guint8 MasterPriority1; guint8 MasterPriority2; @@ -335,21 +335,21 @@ dissect_PNPTCP_Master(tvbuff_t *tvb, int offset, col_append_fstr(pinfo->cinfo, COL_INFO, ", Prio1=\"%s\"", val_to_str(MasterPriority1 & 0x7, pn_ptcp_master_prio1_vals, "(Reserved: 0x%x)")); - if((MasterPriority1 & 0x80) == 0){ - proto_item_append_text(item, ": Prio1=\"%s\", Prio2=%s, Clock: Class=\"%s\", Accuracy=%s, Variance=%d", - val_to_str(MasterPriority1 & 0x7, pn_ptcp_master_prio1_vals, "(Reserved: 0x%x)"), - val_to_str(MasterPriority2, pn_ptcp_master_prio2_vals, "(Reserved: 0x%x)"), - val_to_str(ClockClass, pn_ptcp_clock_class_vals, "(Reserved: 0x%x)"), - val_to_str(ClockAccuracy, pn_ptcp_clock_accuracy_vals, "(Reserved: 0x%x)"), - ClockVariance); + if ((MasterPriority1 & 0x80) == 0) { + proto_item_append_text(item, ": Prio1=\"%s\", Prio2=%s, Clock: Class=\"%s\", Accuracy=%s, Variance=%d", + val_to_str(MasterPriority1 & 0x7, pn_ptcp_master_prio1_vals, "(Reserved: 0x%x)"), + val_to_str(MasterPriority2, pn_ptcp_master_prio2_vals, "(Reserved: 0x%x)"), + val_to_str(ClockClass, pn_ptcp_clock_class_vals, "(Reserved: 0x%x)"), + val_to_str(ClockAccuracy, pn_ptcp_clock_accuracy_vals, "(Reserved: 0x%x)"), + ClockVariance); } - else{ + else { col_append_fstr(pinfo->cinfo, COL_INFO, " active"); proto_item_append_text(item, ": Prio1=\"%s\" is active, Prio2=%s, Clock: Class=\"%s\", Accuracy=%s, Variance=%d", - val_to_str(MasterPriority1 & 0x7, pn_ptcp_master_prio1_vals, "(Reserved: 0x%x)"), - val_to_str(MasterPriority2, pn_ptcp_master_prio2_vals, "(Reserved: 0x%x)"), - val_to_str(ClockClass, pn_ptcp_clock_class_vals, "(Reserved: 0x%x)"), - val_to_str(ClockAccuracy, pn_ptcp_clock_accuracy_vals, "(Reserved: 0x%x)"), + val_to_str(MasterPriority1 & 0x7, pn_ptcp_master_prio1_vals, "(Reserved: 0x%x)"), + val_to_str(MasterPriority2, pn_ptcp_master_prio2_vals, "(Reserved: 0x%x)"), + val_to_str(ClockClass, pn_ptcp_clock_class_vals, "(Reserved: 0x%x)"), + val_to_str(ClockAccuracy, pn_ptcp_clock_accuracy_vals, "(Reserved: 0x%x)"), ClockVariance); } @@ -360,7 +360,7 @@ dissect_PNPTCP_Master(tvbuff_t *tvb, int offset, static int dissect_PNPTCP_PortParameter(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item) + packet_info *pinfo, proto_tree *tree, proto_item *item) { guint32 t2portrxdelay; guint32 t3porttxdelay; @@ -375,7 +375,7 @@ dissect_PNPTCP_PortParameter(tvbuff_t *tvb, int offset, /* T3PortTxDelay */ offset = dissect_pn_uint32(tvb, offset, pinfo, tree, hf_pn_ptcp_t3porttxdelay, &t3porttxdelay); - proto_item_append_text(item, ": T2PortRxDelay=%uns, T3PortTxDelay=%uns", + proto_item_append_text(item, ": T2PortRxDelay=%uns, T3PortTxDelay=%uns", t2portrxdelay, t3porttxdelay); col_append_fstr(pinfo->cinfo, COL_INFO, ", T2Rx=%uns, T3Tx=%uns", @@ -387,7 +387,7 @@ dissect_PNPTCP_PortParameter(tvbuff_t *tvb, int offset, static int dissect_PNPTCP_DelayParameter(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item) + packet_info *pinfo, proto_tree *tree, proto_item *item) { guint8 mac[6]; @@ -411,7 +411,7 @@ dissect_PNPTCP_DelayParameter(tvbuff_t *tvb, int offset, static int dissect_PNPTCP_PortTime(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item) + packet_info *pinfo, proto_tree *tree, proto_item *item) { guint32 t2timestamp; @@ -419,31 +419,31 @@ dissect_PNPTCP_PortTime(tvbuff_t *tvb, int offset, /* Padding */ offset = dissect_pn_align4(tvb, offset, pinfo, tree); - /* T2TimeStamp */ + /* T2TimeStamp */ offset = dissect_pn_uint32(tvb, offset, pinfo, tree, hf_pn_ptcp_t2timestamp, &t2timestamp); - proto_item_append_text(item, ": T2TimeStamp=%uns", t2timestamp); + proto_item_append_text(item, ": T2TimeStamp=%uns", t2timestamp); col_append_fstr(pinfo->cinfo, COL_INFO, ", T2TS=%uns", t2timestamp); - return offset; + return offset; } static int dissect_PNPTCP_Option_PROFINET(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 length) + packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 length) { - guint8 subType; + guint8 subType; e_uuid_t uuid; /* OUI already dissected! */ /* SubType */ - offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_ptcp_profinet_subtype, &subType); - length --; + offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_ptcp_profinet_subtype, &subType); + length -= 1;; - switch(subType) { + switch (subType) { case 1: /* RTData */ /* Padding */ offset = dissect_pn_align4(tvb, offset, pinfo, tree); @@ -469,100 +469,98 @@ dissect_PNPTCP_Option_PROFINET(tvbuff_t *tvb, int offset, static int dissect_PNPTCP_Option(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 length) + packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 length) { - guint32 oui; + guint32 oui; /* verify remaining TLV length */ - if (length < 4) - { - if (tree) { - /* too short */ - offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, length); - } - return (offset); - } + if (length < 4) + { + /* too short */ + offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, length); + return (offset); + } - /* OUI (organizational unique id) */ - offset = dissect_pn_oid(tvb, offset, pinfo,tree, hf_pn_ptcp_oui, &oui); + /* OUI (organizational unique id) */ + offset = dissect_pn_oid(tvb, offset, pinfo,tree, hf_pn_ptcp_oui, &oui); length -= 3; - switch (oui) - { - case OUI_PROFINET: - case OUI_PROFINET_MULTICAST: - proto_item_append_text(item, ": PROFINET"); - offset = dissect_PNPTCP_Option_PROFINET(tvb, offset, pinfo, tree, item, length); - break; - default: - /* SubType */ - offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, length); - } + switch (oui) + { + case OUI_PROFINET: + case OUI_PROFINET_MULTICAST: + proto_item_append_text(item, ": PROFINET"); + offset = dissect_PNPTCP_Option_PROFINET(tvb, offset, pinfo, tree, item, length); + break; + default: + /* SubType */ + offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, length); + } - return (offset); + return (offset); } static int dissect_PNPTCP_block(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item _U_, gboolean *end, guint16 u16FrameID) + packet_info *pinfo, proto_tree *tree, proto_item *item _U_, gboolean *end, guint16 u16FrameID) { - guint16 type; - guint16 length; + guint16 type; + guint16 length; - proto_item *sub_item; - proto_tree *sub_tree; - proto_item *tlvheader_item; - proto_tree *tlvheader_tree; - guint32 u32SubStart; + proto_item *sub_item; + proto_tree *sub_tree; + proto_item *tlvheader_item; + proto_tree *tlvheader_tree; + guint32 u32SubStart; *end = FALSE; /* block subtree */ - sub_item = proto_tree_add_item(tree, hf_pn_ptcp_block, tvb, offset, 0, ENC_NA); - sub_tree = proto_item_add_subtree(sub_item, ett_pn_ptcp_block); + sub_item = proto_tree_add_item(tree, hf_pn_ptcp_block, tvb, offset, 0, ENC_NA); + sub_tree = proto_item_add_subtree(sub_item, ett_pn_ptcp_block); u32SubStart = offset; /* tlvheader subtree */ tlvheader_item = proto_tree_add_item(sub_tree, hf_pn_ptcp_block_tlvheader, tvb, offset, 2 /* len */, ENC_NA); - tlvheader_tree = proto_item_add_subtree(tlvheader_item, ett_pn_ptcp_block_header); + tlvheader_tree = proto_item_add_subtree(tlvheader_item, ett_pn_ptcp_block_header); offset = dissect_PNPTCP_TLVHeader(tvb, offset, pinfo, tlvheader_tree, sub_item, &type, &length); - proto_item_set_text(sub_item, "%s", + proto_item_set_text(sub_item, "%s", val_to_str(type, pn_ptcp_block_type, "Unknown")); - proto_item_append_text(tlvheader_item, ": Type=%s (%x), Length=%u", + proto_item_append_text(tlvheader_item, ": Type=%s (%x), Length=%u", val_to_str(type, pn_ptcp_block_type, "Unknown"), type, length); - switch(type) { - case(0x00): /* End, no content */ + switch (type) { + case 0x00: /* End, no content */ *end = TRUE; break; - case(0x01): /* Subdomain */ + case 0x01: /* Subdomain */ dissect_PNPTCP_Subdomain(tvb, offset, pinfo, sub_tree, sub_item, u16FrameID); break; - case(0x02): /* Time */ + case 0x02: /* Time */ dissect_PNPTCP_Time(tvb, offset, pinfo, sub_tree, sub_item); break; - case(0x03): /* TimeExtension */ + case 0x03: /* TimeExtension */ dissect_PNPTCP_TimeExtension(tvb, offset, pinfo, sub_tree, sub_item); break; - case(0x04): /* Master */ + case 0x04: /* Master */ dissect_PNPTCP_Master(tvb, offset, pinfo, sub_tree, sub_item); break; - case(0x05): /* PortParameter */ + case 0x05: /* PortParameter */ dissect_PNPTCP_PortParameter(tvb, offset, pinfo, sub_tree, sub_item); break; - case(0x06): /* DelayParameter */ + case 0x06: /* DelayParameter */ dissect_PNPTCP_DelayParameter(tvb, offset, pinfo, sub_tree, sub_item); break; - case(0x07): /* PortTime */ + case 0x07: /* PortTime */ dissect_PNPTCP_PortTime(tvb, offset, pinfo, sub_tree, sub_item); break; - case(0x7F): /* Organizational Specific */ + case 0x7F: /* Organizational Specific */ dissect_PNPTCP_Option(tvb, offset, pinfo, sub_tree, sub_item, length); break; default: @@ -570,7 +568,7 @@ dissect_PNPTCP_block(tvbuff_t *tvb, int offset, } offset += length; - proto_item_set_len(sub_item, offset - u32SubStart); + proto_item_set_len(sub_item, offset - u32SubStart); return offset; } @@ -578,12 +576,12 @@ dissect_PNPTCP_block(tvbuff_t *tvb, int offset, static int dissect_PNPTCP_blocks(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 u16FrameID) + packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 u16FrameID) { gboolean end = FALSE; /* as long as we have some bytes, try a new block */ - while(!end) { + while (!end) { offset = dissect_PNPTCP_block(tvb, offset, pinfo, tree, item, &end, u16FrameID); } @@ -593,17 +591,18 @@ dissect_PNPTCP_blocks(tvbuff_t *tvb, int offset, static int dissect_PNPTCP_FollowUpPDU(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 u16FrameID, const char *name, const char *name_short) + packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 u16FrameID, + const char *name, const char *name_short) { - proto_item *header_item; - proto_tree *header_tree; - guint16 seq_id; - gint32 delay1ns_fup; + proto_item *header_item; + proto_tree *header_tree; + guint16 seq_id; + gint32 delay1ns_fup; /* dissect the header */ header_item = proto_tree_add_item(tree, hf_pn_ptcp_header, tvb, offset, 20 /* len */, ENC_NA); - header_tree = proto_item_add_subtree(header_item, ett_pn_ptcp_header); + header_tree = proto_item_add_subtree(header_item, ett_pn_ptcp_header); /* Padding 12 bytes */ offset = dissect_pn_padding(tvb, offset, pinfo, header_tree, 12); @@ -631,22 +630,23 @@ dissect_PNPTCP_FollowUpPDU(tvbuff_t *tvb, int offset, static int dissect_PNPTCP_RTSyncPDU(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 u16FrameID, const char *name, const char *name_short) + packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 u16FrameID, + const char *name, const char *name_short) { - proto_item *header_item; - proto_tree *header_tree; - guint32 res_1; - guint32 res_2; - guint32 delay10ns; - guint16 seq_id; - guint8 delay1ns_8; - guint64 delay1ns_64; - guint32 delay1ns_32; - guint32 delayms; + proto_item *header_item; + proto_tree *header_tree; + guint32 res_1; + guint32 res_2; + guint32 delay10ns; + guint16 seq_id; + guint8 delay1ns_8; + guint64 delay1ns_64; + guint32 delay1ns_32; + guint32 delayms; header_item = proto_tree_add_item(tree, hf_pn_ptcp_header, tvb, offset, 20 /* len */, ENC_NA); - header_tree = proto_item_add_subtree(header_item, ett_pn_ptcp_header); + header_tree = proto_item_add_subtree(header_item, ett_pn_ptcp_header); /* Reserved_1 */ offset = dissect_pn_uint32(tvb, offset, pinfo, header_tree, hf_pn_ptcp_res1, &res_1); @@ -674,21 +674,21 @@ dissect_PNPTCP_RTSyncPDU(tvbuff_t *tvb, int offset, delay1ns_64 = ((guint64) delay10ns) * 10 + delay1ns_8 + delay1ns_32; - delayms = (guint32) (delay1ns_64 / (1000 * 1000)); + delayms = (guint32) (delay1ns_64 / (1000 * 1000)); col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq=%3u, Delay=%11" G_GINT64_MODIFIER "uns", - name, seq_id, delay1ns_64); - proto_item_append_text(item, "%s: Sequence=%u, Delay=%" G_GINT64_MODIFIER "uns", + name, seq_id, delay1ns_64); + proto_item_append_text(item, "%s: Sequence=%u, Delay=%" G_GINT64_MODIFIER "uns", name_short, seq_id, delay1ns_64); - proto_item_append_text(header_item, ": Sequence=%u, Delay=%" G_GINT64_MODIFIER "uns", + proto_item_append_text(header_item, ": Sequence=%u, Delay=%" G_GINT64_MODIFIER "uns", seq_id, delay1ns_64); - if(delay1ns_64 != 0) + if (delay1ns_64 != 0) proto_item_append_text(header_item, " (%u.%03u,%03u,%03u sec)", delayms / 1000, delayms % 1000, (delay10ns % (1000*100)) / 100, - delay10ns % 100 * 10 + delay1ns_8); + delay10ns % 100 * 10 + delay1ns_8); /* dissect the PDU */ offset = dissect_PNPTCP_blocks(tvb, offset, pinfo, tree, item, u16FrameID); @@ -699,16 +699,17 @@ dissect_PNPTCP_RTSyncPDU(tvbuff_t *tvb, int offset, static int dissect_PNPTCP_AnnouncePDU(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 u16FrameID, const char *name, const char *name_short) + packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 u16FrameID, + const char *name, const char *name_short) { - proto_item *header_item; - proto_tree *header_tree; - guint16 seq_id; + proto_item *header_item; + proto_tree *header_tree; + guint16 seq_id; /* dissect the header */ header_item = proto_tree_add_item(tree, hf_pn_ptcp_header, tvb, offset, 20 /* len */, ENC_NA); - header_tree = proto_item_add_subtree(header_item, ett_pn_ptcp_header); + header_tree = proto_item_add_subtree(header_item, ett_pn_ptcp_header); /* Padding 12 bytes */ offset = dissect_pn_padding(tvb, offset, pinfo, header_tree, 12); @@ -733,17 +734,18 @@ dissect_PNPTCP_AnnouncePDU(tvbuff_t *tvb, int offset, static int dissect_PNPTCP_DelayPDU(tvbuff_t *tvb, int offset, - packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 u16FrameID, const char *name, const char *name_short) + packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 u16FrameID, + const char *name, const char *name_short) { - proto_item *header_item; - proto_tree *header_tree; - guint16 seq_id; - guint32 delay1ns; + proto_item *header_item; + proto_tree *header_tree; + guint16 seq_id; + guint32 delay1ns; /* dissect the header */ header_item = proto_tree_add_item(tree, hf_pn_ptcp_header, tvb, offset, 20 /* len */, ENC_NA); - header_tree = proto_item_add_subtree(header_item, ett_pn_ptcp_header); + header_tree = proto_item_add_subtree(header_item, ett_pn_ptcp_header); /* Padding 12 bytes */ offset = dissect_pn_padding(tvb, offset, pinfo, header_tree, 12); @@ -771,27 +773,25 @@ dissect_PNPTCP_DelayPDU(tvbuff_t *tvb, int offset, /* possibly dissect a PN-RT packet (frame ID must be in the appropriate range) */ static gboolean -dissect_PNPTCP_Data_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, - void *data _U_) +dissect_PNPTCP_Data_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { - guint16 u16FrameID; - proto_item *item = NULL; - proto_tree *ptcp_tree = NULL; - int offset = 0; - guint32 u32SubStart; - /*proto_item *unknown_item = NULL;*/ + guint16 u16FrameID; + proto_item *item; + proto_tree *ptcp_tree; + int offset = 0; + guint32 u32SubStart; /* the tvb will NOT contain the frame_id here, so get it from our private data! */ u16FrameID = GPOINTER_TO_UINT(pinfo->private_data); - /* frame id must be in valid range (acyclic Real-Time, PTCP) */ + /* frame id must be in valid range (acyclic Real-Time, PTCP) */ /* 0x0000 - 0x007F: RTSyncPDU (with follow up) */ /* 0x0080 - 0x00FF: RTSyncPDU (without follow up) */ /* 0xFF00 - 0xFF1F: AnnouncePDU */ /* 0xFF20 - 0xFF3F: FollowUpPDU */ /* 0xFF40 - 0xFF5F: Delay...PDU */ - if ( (u16FrameID >= 0x0100 && u16FrameID < 0xFF00) || (u16FrameID > 0xFF5F) ) { + if ( ((u16FrameID >= 0x0100) && (u16FrameID < 0xFF00)) || (u16FrameID > 0xFF5F) ) { /* we are not interested in this packet */ return FALSE; } @@ -800,69 +800,82 @@ dissect_PNPTCP_Data_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, col_clear(pinfo->cinfo, COL_INFO); /* subtree for PTCP */ - item = proto_tree_add_protocol_format(tree, proto_pn_ptcp, tvb, 0, 0, "PROFINET PTCP, "); - ptcp_tree = proto_item_add_subtree(item, ett_pn_ptcp); + item = proto_tree_add_protocol_format(tree, proto_pn_ptcp, tvb, 0, 0, "PROFINET PTCP, "); + ptcp_tree = proto_item_add_subtree(item, ett_pn_ptcp); u32SubStart = offset; - switch(u16FrameID) { + switch (u16FrameID) { /* range 1 (0x0000 - 0x007F) */ /* 0x0000 - 0x001F reserved */ - case(0x0020): - offset = dissect_PNPTCP_RTSyncPDU (tvb, offset, pinfo, ptcp_tree, item, u16FrameID, "RTSync FU (Clock)", "RTSync FU (Clock)"); + case 0x0020: + offset = dissect_PNPTCP_RTSyncPDU(tvb, offset, pinfo, ptcp_tree, item, u16FrameID, + "RTSync FU (Clock)", "RTSync FU (Clock)"); break; - case(0x0021): - offset = dissect_PNPTCP_RTSyncPDU (tvb, offset, pinfo, ptcp_tree, item, u16FrameID, "RTSync FU (Time)", "RTSync FU (Time)"); + case 0x0021: + offset = dissect_PNPTCP_RTSyncPDU(tvb, offset, pinfo, ptcp_tree, item, u16FrameID, + "RTSync FU (Time)", "RTSync FU (Time)"); break; /* 0x0022 - 0x007F reserved */ /* range 2 (0x0080 - 0x00FF) */ - case(0x0080): - offset = dissect_PNPTCP_RTSyncPDU (tvb, offset, pinfo, ptcp_tree, item, u16FrameID, "RTSync (Clock)", "RTSync (Clock)"); + case 0x0080: + offset = dissect_PNPTCP_RTSyncPDU(tvb, offset, pinfo, ptcp_tree, item, u16FrameID, + "RTSync (Clock)", "RTSync (Clock)"); break; - case(0x0081): - offset = dissect_PNPTCP_RTSyncPDU (tvb, offset, pinfo, ptcp_tree, item, u16FrameID, "RTSync (Time)", "RTSync (Time)"); + case 0x0081: + offset = dissect_PNPTCP_RTSyncPDU(tvb, offset, pinfo, ptcp_tree, item, u16FrameID, + "RTSync (Time)", "RTSync (Time)"); break; /* 0x0081 - 0x00FF reserved */ /* range 7 (0xFF00 - 0xFF5F) */ - case(0xff00): - offset = dissect_PNPTCP_AnnouncePDU (tvb, offset, pinfo, ptcp_tree, item, u16FrameID, "Announce (Clock)", "Announce (Clock)"); + case 0xff00: + offset = dissect_PNPTCP_AnnouncePDU(tvb, offset, pinfo, ptcp_tree, item, u16FrameID, + "Announce (Clock)", "Announce (Clock)"); break; - case(0xff01): - offset = dissect_PNPTCP_AnnouncePDU (tvb, offset, pinfo, ptcp_tree, item, u16FrameID, "Announce (Time)", "Announce (Time)"); + case 0xff01: + offset = dissect_PNPTCP_AnnouncePDU(tvb, offset, pinfo, ptcp_tree, item, u16FrameID, + "Announce (Time)", "Announce (Time)"); break; /* 0xFF02 - 0xFF1F reserved */ - case(0xff20): - offset = dissect_PNPTCP_FollowUpPDU (tvb, offset, pinfo, ptcp_tree, item, u16FrameID, "FollowUp (Clock)", "FollowUp (Clock)"); + case 0xff20: + offset = dissect_PNPTCP_FollowUpPDU(tvb, offset, pinfo, ptcp_tree, item, u16FrameID, + "FollowUp (Clock)", "FollowUp (Clock)"); break; - case(0xff21): - offset = dissect_PNPTCP_FollowUpPDU (tvb, offset, pinfo, ptcp_tree, item, u16FrameID, "FollowUp (Time)", "FollowUp (Time)"); + case 0xff21: + offset = dissect_PNPTCP_FollowUpPDU(tvb, offset, pinfo, ptcp_tree, item, u16FrameID, + "FollowUp (Time)", "FollowUp (Time)"); break; /* 0xFF22 - 0xFF3F reserved */ - case(0xff40): - offset = dissect_PNPTCP_DelayPDU (tvb, offset, pinfo, ptcp_tree, item, u16FrameID, "DelayReq ", "DelayReq"); + case 0xff40: + offset = dissect_PNPTCP_DelayPDU(tvb, offset, pinfo, ptcp_tree, item, u16FrameID, + "DelayReq ", "DelayReq"); break; - case(0xff41): - offset = dissect_PNPTCP_DelayPDU (tvb, offset, pinfo, ptcp_tree, item, u16FrameID, "DelayRes ", "DelayRes"); + case 0xff41: + offset = dissect_PNPTCP_DelayPDU(tvb, offset, pinfo, ptcp_tree, item, u16FrameID, + "DelayRes ", "DelayRes"); break; - case(0xff42): - offset = dissect_PNPTCP_DelayPDU (tvb, offset, pinfo, ptcp_tree, item, u16FrameID, "DelayFuRes ", "DelayFuRes"); + case 0xff42: + offset = dissect_PNPTCP_DelayPDU(tvb, offset, pinfo, ptcp_tree, item, u16FrameID, + "DelayFuRes ", "DelayFuRes"); break; - case(0xff43): - offset = dissect_PNPTCP_DelayPDU (tvb, offset, pinfo, ptcp_tree, item, u16FrameID, "DelayRes ", "DelayRes"); + case 0xff43: + offset = dissect_PNPTCP_DelayPDU(tvb, offset, pinfo, ptcp_tree, item, u16FrameID, + "DelayRes ", "DelayRes"); break; - /* 0xFF44 - 0xFF5F reserved */ + /* 0xFF44 - 0xFF5F reserved */ default: offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, tvb_length_remaining(tvb, offset)); - col_append_fstr(pinfo->cinfo, COL_INFO, "Reserved FrameID 0x%04x", u16FrameID); + col_append_fstr(pinfo->cinfo, COL_INFO, "Reserved FrameID 0x%04x", u16FrameID); - proto_item_append_text(item, "Reserved FrameID 0x%04x", u16FrameID); + proto_item_append_text(item, "Reserved FrameID 0x%04x", u16FrameID); offset += tvb_length_remaining(tvb, offset); + break; } - proto_item_set_len(item, offset - u32SubStart); + proto_item_set_len(item, offset - u32SubStart); return TRUE; } @@ -871,103 +884,203 @@ dissect_PNPTCP_Data_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void proto_register_pn_ptcp (void) { - static hf_register_info hf[] = { - { &hf_pn_ptcp_header, - { "Header", "pn_ptcp.header", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_ptcp_block, - { "Block", "pn_ptcp.block", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_ptcp_block_tlvheader, - { "TLVHeader", "pn_ptcp.tlvheader", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - - { &hf_pn_ptcp_res1, - { "Reserved 1", "pn_ptcp.res1", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_ptcp_res2, - { "Reserved 2", "pn_ptcp.res2", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_ptcp_delay10ns, - { "Delay10ns", "pn_ptcp.delay10ns", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_ptcp_seq_id, - { "SequenceID", "pn_ptcp.sequence_id", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_ptcp_delay1ns_byte, - { "Delay1ns_Byte", "pn_ptcp.delay1ns_byte", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_ptcp_delay1ns, - { "Delay1ns", "pn_ptcp.delay1ns", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_ptcp_delay1ns_fup, - { "Delay1ns_FUP", "pn_ptcp.delay1ns_fup", FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - - { &hf_pn_ptcp_tl_length, - { "TypeLength.Length", "pn_ptcp.tl_length", FT_UINT16, BASE_DEC, 0x0, 0x1FF, NULL, HFILL }}, - { &hf_pn_ptcp_tl_type, - { "TypeLength.Type", "pn_ptcp.tl_type", FT_UINT16, BASE_DEC, 0x0, 0xFE00, NULL, HFILL }}, - - { &hf_pn_ptcp_master_source_address, - { "MasterSourceAddress", "pn_ptcp.master_source_address", FT_ETHER, BASE_NONE, 0x0, 0x0, NULL, HFILL }}, - { &hf_pn_ptcp_subdomain_uuid, - { "SubdomainUUID", "pn_ptcp.subdomain_uuid", FT_GUID, BASE_NONE, 0x0, 0x0, NULL, HFILL }}, - - { &hf_pn_ptcp_port_mac_address, - { "PortMACAddress", "pn_ptcp.port_mac_address", FT_ETHER, BASE_NONE, 0x0, 0x0, NULL, HFILL }}, - - { &hf_pn_ptcp_t2portrxdelay, - { "T2PortRxDelay (ns)", "pn_ptcp.t2portrxdelay", FT_UINT32, BASE_DEC, 0x0, 0x0, NULL, HFILL }}, - { &hf_pn_ptcp_t3porttxdelay, - { "T3PortTxDelay (ns)", "pn_ptcp.t3porttxdelay", FT_UINT32, BASE_DEC, 0x0, 0x0, NULL, HFILL }}, - { &hf_pn_ptcp_t2timestamp, - { "T2TimeStamp (ns)", "pn_ptcp.t2timestamp", FT_UINT32, BASE_DEC, 0x0, 0x0, NULL, HFILL }}, - - { &hf_pn_ptcp_epoch_number, - { "EpochNumber", "pn_ptcp.epoch_number", FT_UINT16, BASE_DEC, 0x0, 0x0, NULL, HFILL }}, - { &hf_pn_ptcp_seconds, - { "Seconds", "pn_ptcp.seconds", FT_UINT32, BASE_DEC, 0x0, 0x0, NULL, HFILL }}, - { &hf_pn_ptcp_nanoseconds, - { "NanoSeconds", "pn_ptcp.nanoseconds", FT_UINT32, BASE_DEC, 0x0, 0x0, NULL, HFILL }}, - - { &hf_pn_ptcp_flags, - { "Flags", "pn_ptcp.flags", FT_UINT16, BASE_HEX, 0x0, 0x0, NULL, HFILL }}, - { &hf_pn_ptcp_currentutcoffset, - { "CurrentUTCOffset", "pn_ptcp.currentutcoffset", FT_UINT16, BASE_DEC, 0x0, 0x0, NULL, HFILL }}, - - { &hf_pn_ptcp_master_priority1, - { "MasterPriority1.Priority", "pn_ptcp.master_priority1_prio", FT_UINT8, BASE_HEX, VALS(pn_ptcp_master_prio1_vals), 0x07, NULL, HFILL }}, - { &hf_pn_ptcp_master_priority_level, - { "MasterPriority1.Level", "pn_ptcp.master_priority1_level", FT_UINT8, BASE_HEX, VALS(pn_ptcp_master_prio1_levels), 0x38, NULL, HFILL }}, - { &hf_pn_ptcp_master_priority1_res, - { "MasterPriority1.Reserved", "pn_ptcp.master_priority1_res", FT_UINT8, BASE_HEX, 0x0, 0x40, NULL, HFILL }}, - { &hf_pn_ptcp_master_priority1_act, - { "MasterPriority1.Active", "pn_ptcp.master_priority1_act", FT_UINT8, BASE_HEX, VALS(pn_ptcp_master_prio1_vals_active), 0x80, NULL, HFILL }}, - { &hf_pn_ptcp_master_priority2, - { "MasterPriority2", "pn_ptcp.master_priority2", FT_UINT8, BASE_DEC, VALS(pn_ptcp_master_prio2_vals), 0x0, NULL, HFILL }}, - { &hf_pn_ptcp_clock_class, - { "ClockClass", "pn_ptcp.clock_class", FT_UINT8, BASE_DEC, VALS(pn_ptcp_clock_class_vals), 0x0, NULL, HFILL }}, - { &hf_pn_ptcp_clock_accuracy, - { "ClockAccuracy", "pn_ptcp.clock_accuracy", FT_UINT8, BASE_DEC, VALS(pn_ptcp_clock_accuracy_vals), 0x0, NULL, HFILL }}, - { &hf_pn_ptcp_clockvariance, - { "ClockVariance", "pn_ptcp.clockvariance", FT_INT16, BASE_DEC, 0x0, 0x0, NULL, HFILL }}, - - { &hf_pn_ptcp_oui, - { "Organizationally Unique Identifier", "pn_ptcp.oui", FT_UINT24, BASE_HEX, - VALS(pn_ptcp_oui_vals), 0x0, NULL, HFILL }}, - { &hf_pn_ptcp_profinet_subtype, - { "Subtype", "pn_ptcp.subtype", FT_UINT8, BASE_HEX, - VALS(pn_ptcp_profinet_subtype_vals), 0x0, "PROFINET Subtype", HFILL }}, - - { &hf_pn_ptcp_irdata_uuid, - { "IRDataUUID", "pn_ptcp.irdata_uuid", FT_GUID, BASE_NONE, 0x0, 0x0, NULL, HFILL }}, - }; - - static gint *ett[] = { - &ett_pn_ptcp, - &ett_pn_ptcp_header, + static hf_register_info hf[] = { + { &hf_pn_ptcp_header, + { "Header", "pn_ptcp.header", + FT_NONE, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_ptcp_block, + { "Block", "pn_ptcp.block", + FT_NONE, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_ptcp_block_tlvheader, + { "TLVHeader", "pn_ptcp.tlvheader", + FT_NONE, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + + { &hf_pn_ptcp_res1, + { "Reserved 1", "pn_ptcp.res1", + FT_UINT32, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_ptcp_res2, + { "Reserved 2", "pn_ptcp.res2", + FT_UINT32, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_ptcp_delay10ns, + { "Delay10ns", "pn_ptcp.delay10ns", + FT_UINT32, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_ptcp_seq_id, + { "SequenceID", "pn_ptcp.sequence_id", + FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_ptcp_delay1ns_byte, + { "Delay1ns_Byte", "pn_ptcp.delay1ns_byte", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_ptcp_delay1ns, + { "Delay1ns", "pn_ptcp.delay1ns", + FT_UINT32, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_ptcp_delay1ns_fup, + { "Delay1ns_FUP", "pn_ptcp.delay1ns_fup", + FT_INT32, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + + { &hf_pn_ptcp_tl_length, + { "TypeLength.Length", "pn_ptcp.tl_length", + FT_UINT16, BASE_DEC, 0x0, 0x1FF, + NULL, HFILL }}, + + { &hf_pn_ptcp_tl_type, + { "TypeLength.Type", "pn_ptcp.tl_type", + FT_UINT16, BASE_DEC, 0x0, 0xFE00, + NULL, HFILL }}, + + + { &hf_pn_ptcp_master_source_address, + { "MasterSourceAddress", "pn_ptcp.master_source_address", + FT_ETHER, BASE_NONE, 0x0, 0x0, + NULL, HFILL }}, + + { &hf_pn_ptcp_subdomain_uuid, + { "SubdomainUUID", "pn_ptcp.subdomain_uuid", + FT_GUID, BASE_NONE, 0x0, 0x0, + NULL, HFILL }}, + + + { &hf_pn_ptcp_port_mac_address, + { "PortMACAddress", "pn_ptcp.port_mac_address", + FT_ETHER, BASE_NONE, 0x0, 0x0, + NULL, HFILL }}, + + + { &hf_pn_ptcp_t2portrxdelay, + { "T2PortRxDelay (ns)", "pn_ptcp.t2portrxdelay", + FT_UINT32, BASE_DEC, 0x0, 0x0, + NULL, HFILL }}, + + { &hf_pn_ptcp_t3porttxdelay, + { "T3PortTxDelay (ns)", "pn_ptcp.t3porttxdelay", + FT_UINT32, BASE_DEC, 0x0, 0x0, + NULL, HFILL }}, + + { &hf_pn_ptcp_t2timestamp, + { "T2TimeStamp (ns)", "pn_ptcp.t2timestamp", + FT_UINT32, BASE_DEC, 0x0, 0x0, + NULL, HFILL }}, + + + { &hf_pn_ptcp_epoch_number, + { "EpochNumber", "pn_ptcp.epoch_number", + FT_UINT16, BASE_DEC, 0x0, 0x0, + NULL, HFILL }}, + + { &hf_pn_ptcp_seconds, + { "Seconds", "pn_ptcp.seconds", + FT_UINT32, BASE_DEC, 0x0, 0x0, + NULL, HFILL }}, + + { &hf_pn_ptcp_nanoseconds, + { "NanoSeconds", "pn_ptcp.nanoseconds", + FT_UINT32, BASE_DEC, 0x0, 0x0, + NULL, HFILL }}, + + + { &hf_pn_ptcp_flags, + { "Flags", "pn_ptcp.flags", + FT_UINT16, BASE_HEX, 0x0, 0x0, + NULL, HFILL }}, + + { &hf_pn_ptcp_currentutcoffset, + { "CurrentUTCOffset", "pn_ptcp.currentutcoffset", + FT_UINT16, BASE_DEC, 0x0, 0x0, + NULL, HFILL }}, + + + { &hf_pn_ptcp_master_priority1, + { "MasterPriority1.Priority", "pn_ptcp.master_priority1_prio", + FT_UINT8, BASE_HEX, VALS(pn_ptcp_master_prio1_vals), 0x07, + NULL, HFILL }}, + + { &hf_pn_ptcp_master_priority_level, + { "MasterPriority1.Level", "pn_ptcp.master_priority1_level", + FT_UINT8, BASE_HEX, VALS(pn_ptcp_master_prio1_levels), 0x38, + NULL, HFILL }}, + + { &hf_pn_ptcp_master_priority1_res, + { "MasterPriority1.Reserved", "pn_ptcp.master_priority1_res", + FT_UINT8, BASE_HEX, 0x0, 0x40, + NULL, HFILL }}, + + { &hf_pn_ptcp_master_priority1_act, + { "MasterPriority1.Active", "pn_ptcp.master_priority1_act", + FT_UINT8, BASE_HEX, VALS(pn_ptcp_master_prio1_vals_active), 0x80, + NULL, HFILL }}, + + { &hf_pn_ptcp_master_priority2, + { "MasterPriority2", "pn_ptcp.master_priority2", + FT_UINT8, BASE_DEC, VALS(pn_ptcp_master_prio2_vals), 0x0, + NULL, HFILL }}, + + { &hf_pn_ptcp_clock_class, + { "ClockClass", "pn_ptcp.clock_class", + FT_UINT8, BASE_DEC, VALS(pn_ptcp_clock_class_vals), 0x0, + NULL, HFILL }}, + + { &hf_pn_ptcp_clock_accuracy, + { "ClockAccuracy", "pn_ptcp.clock_accuracy", + FT_UINT8, BASE_DEC, VALS(pn_ptcp_clock_accuracy_vals), 0x0, + NULL, HFILL }}, + + { &hf_pn_ptcp_clockvariance, + { "ClockVariance", "pn_ptcp.clockvariance", + FT_INT16, BASE_DEC, 0x0, 0x0, + NULL, HFILL }}, + + + { &hf_pn_ptcp_oui, + { "Organizationally Unique Identifier", "pn_ptcp.oui", + FT_UINT24, BASE_HEX, VALS(pn_ptcp_oui_vals), 0x0, + NULL, HFILL }}, + + { &hf_pn_ptcp_profinet_subtype, + { "Subtype", "pn_ptcp.subtype", + FT_UINT8, BASE_HEX, VALS(pn_ptcp_profinet_subtype_vals), 0x0, + "PROFINET Subtype", HFILL }}, + + + { &hf_pn_ptcp_irdata_uuid, + { "IRDataUUID", "pn_ptcp.irdata_uuid", + FT_GUID, BASE_NONE, 0x0, 0x0, + NULL, HFILL }}, + + }; + + static gint *ett[] = { + &ett_pn_ptcp, + &ett_pn_ptcp_header, &ett_pn_ptcp_block, &ett_pn_ptcp_block_header }; - proto_pn_ptcp = proto_register_protocol ("PROFINET PTCP", "PN-PTCP", "pn_ptcp"); - proto_register_field_array (proto_pn_ptcp, hf, array_length (hf)); - proto_register_subtree_array (ett, array_length (ett)); + proto_pn_ptcp = proto_register_protocol ("PROFINET PTCP", "PN-PTCP", "pn_ptcp"); + proto_register_field_array (proto_pn_ptcp, hf, array_length (hf)); + proto_register_subtree_array (ett, array_length (ett)); } void proto_reg_handoff_pn_ptcp (void) { /* register ourself as an heuristic pn-rt payload dissector */ - heur_dissector_add("pn_rt", dissect_PNPTCP_Data_heur, proto_pn_ptcp); + heur_dissector_add("pn_rt", dissect_PNPTCP_Data_heur, proto_pn_ptcp); } diff --git a/plugins/profinet/packet-pn-rt.c b/plugins/profinet/packet-pn-rt.c index 799d39691c..bf61f412a5 100644 --- a/plugins/profinet/packet-pn-rt.c +++ b/plugins/profinet/packet-pn-rt.c @@ -111,8 +111,8 @@ static const value_string pn_rt_position_control[] = { { 0, NULL } }; static const value_string pn_rt_ds_redundancy[] = { - { 0x00, "One primary AR of a given AR-set is present" }, - { 0x01, "None primary AR of a given AR-set is present" }, + { 0x00, "One primary AR of a given AR-set is present" }, + { 0x01, "None primary AR of a given AR-set is present" }, { 0, NULL } }; @@ -138,40 +138,41 @@ dissect_DataStatus(tvbuff_t *tvb, int offset, proto_tree *tree, guint8 u8DataSta tvb, offset, 1, u8DataStatus, "DataStatus: 0x%02x (Frame: %s and %s, Provider: %s and %s)", u8DataStatus, - (u8DataStatus & 0x04) ? "Valid" : "Invalid", + (u8DataStatus & 0x04) ? "Valid" : "Invalid", (u8DataStatus & 0x01) ? "Primary" : "Backup", - (u8DataStatus & 0x20) ? "Ok" : "Problem", - (u8DataStatus & 0x10) ? "Run" : "Stop"); + (u8DataStatus & 0x20) ? "Ok" : "Problem", + (u8DataStatus & 0x10) ? "Run" : "Stop"); sub_tree = proto_item_add_subtree(sub_item, ett_pn_rt_data_status); - proto_tree_add_uint(sub_tree, hf_pn_rt_data_status_ignore, tvb, offset, 1, u8DataStatus); + proto_tree_add_uint(sub_tree, hf_pn_rt_data_status_ignore, tvb, offset, 1, u8DataStatus); proto_tree_add_uint(sub_tree, hf_pn_rt_data_status_Reserved_2, tvb, offset, 1, u8DataStatus); - proto_tree_add_uint(sub_tree, hf_pn_rt_data_status_ok, tvb, offset, 1, u8DataStatus); - proto_tree_add_uint(sub_tree, hf_pn_rt_data_status_operate, tvb, offset, 1, u8DataStatus); - proto_tree_add_uint(sub_tree, hf_pn_rt_data_status_res3, tvb, offset, 1, u8DataStatus); - proto_tree_add_uint(sub_tree, hf_pn_rt_data_status_valid, tvb, offset, 1, u8DataStatus); + proto_tree_add_uint(sub_tree, hf_pn_rt_data_status_ok, tvb, offset, 1, u8DataStatus); + proto_tree_add_uint(sub_tree, hf_pn_rt_data_status_operate, tvb, offset, 1, u8DataStatus); + proto_tree_add_uint(sub_tree, hf_pn_rt_data_status_res3, tvb, offset, 1, u8DataStatus); + proto_tree_add_uint(sub_tree, hf_pn_rt_data_status_valid, tvb, offset, 1, u8DataStatus); proto_tree_add_uint(sub_tree, hf_pn_rt_data_status_redundancy, tvb, offset, 1, u8DataStatus); - proto_tree_add_uint(sub_tree, hf_pn_rt_data_status_primary, tvb, offset, 1, u8DataStatus); + proto_tree_add_uint(sub_tree, hf_pn_rt_data_status_primary, tvb, offset, 1, u8DataStatus); } -static gboolean IsDFP_Frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +static gboolean +IsDFP_Frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - guint16 u16SFCRC16; - guint8 u8SFPosition; - guint8 u8SFDataLength = 255; - int offset = 0; - guint32 u32SubStart; - guint16 crc; - gint tvb_len =0; - unsigned char virtualFramebuffer[16]; - guint16 u16FrameID; + guint16 u16SFCRC16; + guint8 u8SFPosition; + guint8 u8SFDataLength = 255; + int offset = 0; + guint32 u32SubStart; + guint16 crc; + gint tvb_len = 0; + unsigned char virtualFramebuffer[16]; + guint16 u16FrameID; /* the sub tvb will NOT contain the frame_id here! */ u16FrameID = GPOINTER_TO_UINT(pinfo->private_data); /* try to bild a temporaray buffer for generating this CRC */ - memcpy(&virtualFramebuffer[0], pinfo->dst.data,6); - memcpy(&virtualFramebuffer[6], pinfo->src.data,6); + memcpy(&virtualFramebuffer[0], pinfo->dst.data, 6); + memcpy(&virtualFramebuffer[6], pinfo->src.data, 6); virtualFramebuffer[12] = 0x88; virtualFramebuffer[13] = 0x92; virtualFramebuffer[15] = (unsigned char) (u16FrameID &0xff); @@ -181,9 +182,9 @@ static gboolean IsDFP_Frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) crc = crc16_plain_finalize(crc); /* can check this CRC only by having built a temporary data buffer out of the pinfo data */ u16SFCRC16 = tvb_get_letohs(tvb, offset); - if(u16SFCRC16 != 0) /* no crc! */ + if (u16SFCRC16 != 0) /* no crc! */ { - if(u16SFCRC16 != crc) + if (u16SFCRC16 != crc) { proto_item_append_text(tree, ", no packed frame: SFCRC16 is 0x%x should be 0x%x", u16SFCRC16, crc); return(FALSE); @@ -193,11 +194,11 @@ static gboolean IsDFP_Frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) offset += 2; /*Skip first crc */ tvb_len = tvb_length(tvb); - if(offset + 4 > tvb_len) + if (offset + 4 > tvb_len) return FALSE; - if(tvb_get_letohs(tvb, offset) == 0) + if (tvb_get_letohs(tvb, offset) == 0) return FALSE; /* no valid DFP frame */ - while(1) { + while (1) { u32SubStart = offset; u8SFPosition = tvb_get_guint8(tvb, offset); @@ -206,21 +207,21 @@ static gboolean IsDFP_Frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) u8SFDataLength = tvb_get_guint8(tvb, offset); offset += 1; - if(u8SFDataLength == 0) { + if (u8SFDataLength == 0) { break; } offset += 2; offset += u8SFDataLength; - if(offset > tvb_len) + if (offset > tvb_len) return /*TRUE; */FALSE; u16SFCRC16 = tvb_get_letohs(tvb, offset); - if(u16SFCRC16 != 0){ - if(u8SFPosition & 0x80) { + if (u16SFCRC16 != 0) { + if (u8SFPosition & 0x80) { crc = crc16_plain_tvb_offset_seed(tvb, u32SubStart, offset-u32SubStart, 0); - if(crc != u16SFCRC16) { + if (crc != u16SFCRC16) { return FALSE; } else { } @@ -234,39 +235,38 @@ static gboolean IsDFP_Frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* possibly dissect a CSF_SDU related PN-RT packet */ gboolean -dissect_CSF_SDU_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, - void *data _U_) +dissect_CSF_SDU_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { - guint16 u16FrameID; - guint16 u16SFCRC16; - guint8 u8SFPosition; - guint8 u8SFDataLength = 255; - guint8 u8SFCycleCounter; - guint8 u8SFDataStatus; - gint offset = 0; - guint32 u32SubStart; + guint16 u16FrameID; + guint16 u16SFCRC16; + guint8 u8SFPosition; + guint8 u8SFDataLength = 255; + guint8 u8SFCycleCounter; + guint8 u8SFDataStatus; + gint offset = 0; + guint32 u32SubStart; proto_item *sub_item; proto_tree *sub_tree; proto_item *item; - guint16 crc; + guint16 crc; /* the sub tvb will NOT contain the frame_id here! */ u16FrameID = GPOINTER_TO_UINT(pinfo->private_data); /* possible FrameID ranges for DFP */ - if((u16FrameID < 0x100) || (u16FrameID > 0x0FFF)) + if ((u16FrameID < 0x100) || (u16FrameID > 0x0FFF)) return (FALSE); if (IsDFP_Frame(tvb, pinfo, tree)) { /* can't check this CRC, as the checked data bytes are not available */ u16SFCRC16 = tvb_get_letohs(tvb, offset); - if(u16SFCRC16 != 0) + if (u16SFCRC16 != 0) proto_tree_add_uint(tree, hf_pn_rt_sf_crc16_ok, tvb, offset, 2, u16SFCRC16); else proto_tree_add_uint(tree, hf_pn_rt_sf_crc16_null, tvb, offset, 2, u16SFCRC16); offset += 2; - while(1) { + while (1) { sub_item = proto_tree_add_item(tree, hf_pn_rt_sf, tvb, offset, 0, ENC_NA); sub_tree = proto_item_add_subtree(sub_item, ett_pn_rt_sf); u32SubStart = offset; @@ -279,7 +279,7 @@ dissect_CSF_SDU_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree_add_uint(sub_tree, hf_pn_rt_sf_data_length, tvb, offset, 1, u8SFDataLength); offset += 1; - if(u8SFDataLength == 0) { + if (u8SFDataLength == 0) { proto_item_append_text(sub_item, ": Pos:%u, Length:%u", u8SFPosition, u8SFDataLength); proto_item_set_len(sub_item, offset - u32SubStart); break; @@ -298,9 +298,9 @@ dissect_CSF_SDU_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, u16SFCRC16 = tvb_get_letohs(tvb, offset); item = proto_tree_add_uint(sub_tree, hf_pn_rt_sf_crc16, tvb, offset, 2, u16SFCRC16); - if(u16SFCRC16 != 0 /* "old check": u8SFPosition & 0x80 */) { + if (u16SFCRC16 != 0 /* "old check": u8SFPosition & 0x80 */) { crc = crc16_plain_tvb_offset_seed(tvb, u32SubStart, offset-u32SubStart, 0); - if(crc != u16SFCRC16) { + if (crc != u16SFCRC16) { proto_item_append_text(item, " [Preliminary check: incorrect, should be: %u]", crc); expert_add_info_format(pinfo, item, PI_CHECKSUM, PI_ERROR, "Bad checksum"); } else { @@ -346,13 +346,15 @@ static void pnio_defragment_init(void) { guint32 i; - if( reasembled_frag_table != NULL ) { + + if ( reasembled_frag_table != NULL ) { g_hash_table_destroy( reasembled_frag_table ); reasembled_frag_table = NULL; } - for (i=0; i < 16;i++) /* init the reasemble help array */ + for (i=0; i < 16; i++) /* init the reasemble help array */ start_frag_OR_ID[i] = 0; + fragment_table_init(&pdu_frag_table); if (reasembled_frag_table == NULL) { @@ -362,25 +364,10 @@ pnio_defragment_init(void) /* possibly dissect a FRAG_PDU related PN-RT packet */ static gboolean -dissect_FRAG_PDU_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, - void *data _U_) +dissect_FRAG_PDU_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { guint16 u16FrameID; - guint32 u32FrameKey = 0; - guint32 u32FragID = 0; - guint16 pdu_length = 0; - guint32 u32ReasembleID =0xfedc; - int offset = 0; - proto_item *sub_item; - proto_tree *sub_tree; - guint8 u8FragDataLength; - proto_item *status_item; - proto_tree *status_tree; - guint8 u8FragStatus; - gboolean bMoreFollows; - guint8 uFragNumber; - fragment_data *pdu_frag; - tvbuff_t *pdu_tvb = NULL; + int offset = 0; /* the sub tvb will NOT contain the frame_id here! */ @@ -388,6 +375,15 @@ dissect_FRAG_PDU_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, /* possible FrameID ranges for FRAG_PDU */ if (u16FrameID >= 0xFF80 && u16FrameID <= 0xFF8F) { + proto_item *sub_item; + proto_tree *sub_tree; + proto_item *status_item; + proto_tree *status_tree; + guint8 u8FragDataLength; + guint8 u8FragStatus; + gboolean bMoreFollows; + guint8 uFragNumber; + sub_item = proto_tree_add_item(tree, hf_pn_rt_frag, tvb, offset, 0, ENC_NA); sub_tree = proto_item_add_subtree(sub_item, ett_pn_rt_frag); @@ -404,45 +400,54 @@ dissect_FRAG_PDU_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree_add_uint(status_tree, hf_pn_rt_frag_status_fragment_number, tvb, offset, 1, u8FragStatus); offset += 1; uFragNumber = u8FragStatus & 0x3F; /* bits 0 to 5 */ - bMoreFollows = (u8FragStatus & 0x80) != 0; + bMoreFollows = (u8FragStatus & 0x80) != 0; proto_item_append_text(status_item, ": Number: %u, %s", uFragNumber, val_to_str( (u8FragStatus & 0x80) >> 7, pn_rt_frag_status_more_follows, "Unknown")); - proto_tree_add_string_format(sub_tree, hf_pn_rt_frag_data, tvb, offset, tvb_length(tvb) - offset, "data", + proto_tree_add_string_format(sub_tree, hf_pn_rt_frag_data, tvb, offset, tvb_length(tvb) - offset, "data", "Fragment Length: %d bytes", tvb_length(tvb) - offset); - col_append_fstr(pinfo->cinfo, COL_INFO," Fragment Length: %d bytes", tvb_length(tvb) - offset); + col_append_fstr(pinfo->cinfo, COL_INFO, " Fragment Length: %d bytes", tvb_length(tvb) - offset); dissect_pn_user_data_bytes(tvb, offset, pinfo, sub_tree, tvb_length(tvb) - offset, FRAG_DATA); - if((guint)(tvb_length(tvb) - offset) < (guint)(u8FragDataLength *8)){ + if ((guint)(tvb_length(tvb) - offset) < (guint)(u8FragDataLength *8)) { proto_item_append_text(status_item, ": FragDataLength out of Framerange -> discarding!"); return (TRUE); } /* defragmentation starts here */ - if(pnio_desegment) + if (pnio_desegment) { - u32FragID = (u16FrameID & 0xf); - if(uFragNumber == 0) + guint32 u32FragID; + guint32 u32ReasembleID /*= 0xfedc ??*/; + fragment_data *pdu_frag; + + u32FragID = (u16FrameID & 0xf); + if (uFragNumber == 0) { /* this is the first "new" fragment, so set up a new key Id */ + guint32 u32FrameKey; u32FrameKey = (pinfo->fd->num << 2) | u32FragID; /* store it in the array */ start_frag_OR_ID[u32FragID] = u32FrameKey; } u32ReasembleID = start_frag_OR_ID[u32FragID]; - /* use frame data instead of "pnio fraglen" which sets 8 octet steps */ - pdu_frag = fragment_add_seq(tvb, offset, pinfo, u32ReasembleID, pdu_frag_table, uFragNumber, (tvb_length(tvb) - offset)/*u8FragDataLength*8*/, bMoreFollows); + /* use frame data instead of "pnio fraglen" which sets 8 octet steps */ + pdu_frag = fragment_add_seq(tvb, offset, pinfo, u32ReasembleID, pdu_frag_table, uFragNumber, + (tvb_length(tvb) - offset)/*u8FragDataLength*8*/, bMoreFollows); - if(pdu_frag && !bMoreFollows) /* PDU is complete! and last fragment */ + if (pdu_frag && !bMoreFollows) /* PDU is complete! and last fragment */ { /* store this frag as the completed frag in hash table */ - g_hash_table_insert(reasembled_frag_table,GUINT_TO_POINTER(pinfo->fd->num),pdu_frag); + g_hash_table_insert(reasembled_frag_table, GUINT_TO_POINTER(pinfo->fd->num), pdu_frag); start_frag_OR_ID[u32FragID] = 0; /* reset the starting frame counter */ } - if(!bMoreFollows) /* last fragment */ + if (!bMoreFollows) /* last fragment */ { - pdu_frag = g_hash_table_lookup(reasembled_frag_table,GUINT_TO_POINTER(pinfo->fd->num)); - if(pdu_frag) /* found a matching frag dissect it */ + pdu_frag = g_hash_table_lookup(reasembled_frag_table, GUINT_TO_POINTER(pinfo->fd->num)); + if (pdu_frag) /* found a matching frag dissect it */ { - guint16 type; + guint16 type; + guint16 pdu_length; + tvbuff_t *pdu_tvb; + pdu_length = pdu_frag->len; /* create the new tvb for defraged frame */ pdu_tvb = tvb_new_child_real_data(tvb, pdu_frag->data, pdu_length, pdu_length); @@ -455,8 +460,8 @@ dissect_FRAG_PDU_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, call_dissector(data_handle, pdu_tvb, pinfo, tree); } } - return TRUE; - } + return TRUE; + } else return TRUE; } @@ -470,20 +475,20 @@ dissect_FRAG_PDU_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, static void dissect_pn_rt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - gint pdu_len; - gint data_len; - guint16 u16FrameID; - guint8 u8DataStatus; - guint8 u8TransferStatus; - guint16 u16CycleCounter; + gint pdu_len; + gint data_len; + guint16 u16FrameID; + guint8 u8DataStatus; + guint8 u8TransferStatus; + guint16 u16CycleCounter; const gchar *pszProtAddInfo; const gchar *pszProtShort; const gchar *pszProtSummary; const gchar *pszProtComment; - proto_tree *pn_rt_tree, *ti; - gchar szFieldSummary[100]; - tvbuff_t *next_tvb; - gboolean bCyclic; + proto_tree *pn_rt_tree, *ti; + gchar szFieldSummary[100]; + tvbuff_t *next_tvb; + gboolean bCyclic; /* If the link-layer dissector for the protocol above us knows whether @@ -509,7 +514,7 @@ dissect_pn_rt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* Initialize variables */ pn_rt_tree = NULL; - ti = NULL; + ti = NULL; /* * Set the columns now, so that they'll be set correctly if we throw @@ -561,35 +566,35 @@ dissect_pn_rt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) pszProtShort = "PN-RTC3"; pszProtAddInfo = "RTC3, "; pszProtSummary = "Isochronous-Real-Time"; - pszProtComment = "0x0100-0x06FF: RED: Real-Time(class=3): non redundant, normal or DFP"; + pszProtComment = "0x0100-0x06FF: RED: Real-Time(class=3): non redundant, normal or DFP"; bCyclic = TRUE; - } else if (u16FrameID <= 0x0FFF){ + } else if (u16FrameID <= 0x0FFF) { pszProtShort = "PN-RTC3"; pszProtAddInfo = "RTC3, "; pszProtSummary = "Isochronous-Real-Time"; - pszProtComment = "0x0700-0x0FFF: RED: Real-Time(class=3): redundant, normal or DFP"; + pszProtComment = "0x0700-0x0FFF: RED: Real-Time(class=3): redundant, normal or DFP"; bCyclic = TRUE; } else if (u16FrameID <= 0x7FFF) { pszProtShort = "PN-RT"; pszProtAddInfo = "reserved, "; pszProtSummary = "Real-Time"; - pszProtComment = "0x1000-0x7FFF: Reserved ID"; + pszProtComment = "0x1000-0x7FFF: Reserved ID"; bCyclic = FALSE; - } else if (u16FrameID <= 0xBBFF){ + } else if (u16FrameID <= 0xBBFF) { pszProtShort = "PN-RTC1"; pszProtAddInfo = "RTC1, "; pszProtSummary = "cyclic Real-Time"; pszProtComment = "0x8000-0xBBFF: Real-Time(class=1 unicast): non redundant, normal"; bCyclic = TRUE; - } else if (u16FrameID <= 0xBFFF){ + } else if (u16FrameID <= 0xBFFF) { pszProtShort = "PN-RTC1"; pszProtAddInfo = "RTC1, "; pszProtSummary = "cyclic Real-Time"; pszProtComment = "0xBC00-0xBFFF: Real-Time(class=1 multicast): non redundant, normal"; bCyclic = TRUE; - } else if (u16FrameID <= 0xF7FF){ + } else if (u16FrameID <= 0xF7FF) { /* check if udp frame on PNIO port */ - if(pinfo->destport == 0x8892) + if (pinfo->destport == 0x8892) { /* UDP frame */ pszProtShort = "PN-RTCUDP,"; pszProtAddInfo = "RT_CLASS_UDP, "; @@ -603,8 +608,8 @@ dissect_pn_rt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } pszProtSummary = "cyclic Real-Time"; bCyclic = TRUE; - } else if (u16FrameID <= 0xFBFF){ - if(pinfo->destport == 0x8892) + } else if (u16FrameID <= 0xFBFF) { + if (pinfo->destport == 0x8892) { /* UDP frame */ pszProtShort = "PN-RTCUDP,"; pszProtAddInfo = "RT_CLASS_UDP, "; @@ -618,7 +623,7 @@ dissect_pn_rt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } pszProtSummary = "cyclic Real-Time"; bCyclic = TRUE; - } else if (u16FrameID <= 0xFDFF){ + } else if (u16FrameID <= 0xFDFF) { pszProtShort = "PN-RTA"; pszProtAddInfo = "Reserved, "; pszProtSummary = "acyclic Real-Time"; @@ -631,7 +636,7 @@ dissect_pn_rt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) pszProtComment = "Real-Time: Acyclic PN-IO Alarm high priority"; } - } else if (u16FrameID <= 0xFEFF){ + } else if (u16FrameID <= 0xFEFF) { pszProtShort = "PN-RTA"; pszProtAddInfo = "Reserved, "; pszProtSummary = "acyclic Real-Time"; @@ -667,43 +672,43 @@ dissect_pn_rt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) pszProtSummary = "acyclic Real-Time"; pszProtComment = "Real-Time: DCP (Dynamic Configuration Protocol) identify response"; } - } else if (u16FrameID <= 0xFF01){ + } else if (u16FrameID <= 0xFF01) { pszProtShort = "PN-PTCP"; pszProtAddInfo = "RTA Sync, "; pszProtSummary = "acyclic Real-Time"; pszProtComment = "0xFF00-0xFF01: PTCP Announce"; bCyclic = FALSE; - } else if (u16FrameID <= 0xFF1F){ + } else if (u16FrameID <= 0xFF1F) { pszProtShort = "PN-PTCP"; pszProtAddInfo = "RTA Sync, "; pszProtSummary = "acyclic Real-Time"; pszProtComment = "0xFF02-0xFF1F: Reserved"; bCyclic = FALSE; - } else if (u16FrameID <= 0xFF21){ + } else if (u16FrameID <= 0xFF21) { pszProtShort = "PN-PTCP"; pszProtAddInfo = "Follow Up, "; pszProtSummary = "acyclic Real-Time"; pszProtComment = "0xFF20-0xFF21: PTCP Follow Up"; bCyclic = FALSE; - } else if (u16FrameID <= 0xFF22){ + } else if (u16FrameID <= 0xFF22) { pszProtShort = "PN-PTCP"; pszProtAddInfo = "Follow Up, "; pszProtSummary = "acyclic Real-Time"; pszProtComment = "0xFF22-0xFF3F: Reserved"; bCyclic = FALSE; - } else if (u16FrameID <= 0xFF43){ + } else if (u16FrameID <= 0xFF43) { pszProtShort = "PN-PTCP"; pszProtAddInfo = "Delay, "; pszProtSummary = "acyclic Real-Time"; pszProtComment = "0xFF40-0xFF43: Acyclic Real-Time: Delay"; bCyclic = FALSE; - } else if (u16FrameID <= 0xFF7F){ + } else if (u16FrameID <= 0xFF7F) { pszProtShort = "PN-RT"; pszProtAddInfo = "Reserved, "; pszProtSummary = "Real-Time"; pszProtComment = "0xFF44-0xFF7F: reserved ID"; bCyclic = FALSE; - } else if (u16FrameID <= 0xFF8F){ + } else if (u16FrameID <= 0xFF8F) { pszProtShort = "PN-RT"; pszProtAddInfo = ""; pszProtSummary = "Fragmentation"; @@ -720,17 +725,17 @@ dissect_pn_rt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* decode optional cyclic fields at the packet end and build the summary line */ if (bCyclic) { /* cyclic transfer has cycle counter, data status and transfer status fields at the end */ - u16CycleCounter = tvb_get_ntohs(tvb, pdu_len - 4); - u8DataStatus = tvb_get_guint8(tvb, pdu_len - 2); + u16CycleCounter = tvb_get_ntohs(tvb, pdu_len - 4); + u8DataStatus = tvb_get_guint8(tvb, pdu_len - 2); u8TransferStatus = tvb_get_guint8(tvb, pdu_len - 1); g_snprintf (szFieldSummary, sizeof(szFieldSummary), - "%sID:0x%04x, Len:%4u, Cycle:%5u (%s,%s,%s,%s)", + "%sID:0x%04x, Len:%4u, Cycle:%5u (%s,%s,%s,%s)", pszProtAddInfo, u16FrameID, pdu_len - 2 - 4, u16CycleCounter, - (u8DataStatus & 0x04) ? "Valid" : "Invalid", + (u8DataStatus & 0x04) ? "Valid" : "Invalid", (u8DataStatus & 0x01) ? "Primary" : "Backup", - (u8DataStatus & 0x20) ? "Ok" : "Problem", - (u8DataStatus & 0x10) ? "Run" : "Stop"); + (u8DataStatus & 0x20) ? "Ok" : "Problem", + (u8DataStatus & 0x10) ? "Run" : "Stop"); /* user data length is packet len - frame id - optional cyclic status fields */ data_len = pdu_len - 2 - 4; @@ -795,7 +800,7 @@ dissect_pn_rt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) next_tvb = tvb_new_subset(tvb, 2, data_len, data_len); /* ask heuristics, if some sub-dissector is interested in this packet payload */ - if(!dissector_try_heuristic(heur_subdissector_list, next_tvb, pinfo, tree, NULL)) { + if (!dissector_try_heuristic(heur_subdissector_list, next_tvb, pinfo, tree, NULL)) { /*col_set_str(pinfo->cinfo, COL_INFO, "Unknown");*/ /* Oh, well, we don't know this; dissect it as data. */ @@ -808,96 +813,176 @@ dissect_pn_rt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) void proto_register_pn_rt(void) { - static hf_register_info hf[] = { - { &hf_pn_rt_frame_id, { - "FrameID", "pn_rt.frame_id", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_rt_cycle_counter, { - "CycleCounter", "pn_rt.cycle_counter", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_rt_data_status, { - "DataStatus", "pn_rt.ds", FT_UINT8, BASE_HEX, 0, 0x0, NULL, HFILL }}, - { &hf_pn_rt_data_status_ignore, { - "Ignore (1:Ignore/0:Evaluate)", "pn_rt.ds_ignore", FT_UINT8, BASE_HEX, 0, 0x80, NULL, HFILL }}, - { &hf_pn_rt_data_status_Reserved_2, { - "Reserved_2 (should be zero)", "pn_rt.ds_Reserved_2", FT_UINT8, BASE_HEX, 0, 0x40, NULL, HFILL }}, - { &hf_pn_rt_data_status_ok, { - "StationProblemIndicator (1:Ok/0:Problem)", "pn_rt.ds_ok", FT_UINT8, BASE_HEX, 0, 0x20, NULL, HFILL }}, - { &hf_pn_rt_data_status_operate, { - "ProviderState (1:Run/0:Stop)", "pn_rt.ds_operate", FT_UINT8, BASE_HEX, 0, 0x10, NULL, HFILL }}, - { &hf_pn_rt_data_status_res3, { - "Reserved_1 (should be zero)", "pn_rt.ds_res3", FT_UINT8, BASE_HEX, 0, 0x08, NULL, HFILL }}, - { &hf_pn_rt_data_status_valid, { - "DataValid (1:Valid/0:Invalid)", "pn_rt.ds_valid", FT_UINT8, BASE_HEX, 0, 0x04, NULL, HFILL }}, - { &hf_pn_rt_data_status_redundancy, { - "Redundancy", "pn_rt.ds_redundancy", FT_UINT8, BASE_HEX, VALS(pn_rt_ds_redundancy), 0x02, NULL, HFILL }}, - { &hf_pn_rt_data_status_primary, { - "State (1:Primary/0:Backup)", "pn_rt.ds_primary", FT_UINT8, BASE_HEX, 0, 0x01, NULL, HFILL }}, - { &hf_pn_rt_transfer_status, - { "TransferStatus", "pn_rt.transfer_status", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_rt_sf, { - "SubFrame", "pn_rt.sf", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_rt_sf_crc16, { - "SFCRC16", "pn_rt.sf.crc16", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_rt_sf_crc16_ok, { - "SFCRC16 checked [ok]", "pn_rt.sf.crc16_ok", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_rt_sf_crc16_null, { - "SFCRC16 not checked but ok", "pn_rt.sf.crc16_null", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_rt_sf_position, { - "Position", "pn_rt.sf.position", FT_UINT8, BASE_DEC, NULL, 0x7F, NULL, HFILL }}, - { &hf_pn_rt_sf_position_control, { - "Control", "pn_rt.sf.position_control", FT_UINT8, BASE_DEC, VALS(pn_rt_position_control), 0x80, NULL, HFILL }}, - { &hf_pn_rt_sf_data_length, { - "DataLength", "pn_rt.sf.data_length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_rt_sf_cycle_counter, { - "CycleCounter", "pn_rt.sf.cycle_counter", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_rt_frag, { - "PROFINET Fragment", "pn_rt.frag", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_rt_frag_data_length, { - "FragDataLength", "pn_rt.frag_data_length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_rt_frag_status, { - "FragStatus", "pn_rt.frag_status", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - { &hf_pn_rt_frag_status_more_follows, { - "MoreFollows", "pn_rt.frag_status.more_follows", FT_UINT8, BASE_HEX, VALS(pn_rt_frag_status_more_follows), 0x80, NULL, HFILL }}, - { &hf_pn_rt_frag_status_error, { - "Reserved", "pn_rt.frag_status.error", FT_UINT8, BASE_HEX, VALS(pn_rt_frag_status_error), 0x40, NULL, HFILL }}, - { &hf_pn_rt_frag_status_fragment_number, { - "FragmentNumber (zero based)", "pn_rt.frag_status.fragment_number", FT_UINT8, BASE_DEC, NULL, 0x3F, NULL, HFILL }}, - { &hf_pn_rt_frag_data, { - "FragData", "pn_rt.frag_data", FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL }}, - }; - static gint *ett[] = { - &ett_pn_rt, - &ett_pn_rt_data_status, - &ett_pn_rt_sf, - &ett_pn_rt_frag, - &ett_pn_rt_frag_status - }; - module_t *pn_rt_module; - - proto_pn_rt = proto_register_protocol("PROFINET Real-Time Protocol", - "PN-RT", "pn_rt"); - - proto_register_field_array(proto_pn_rt, hf, array_length(hf)); - proto_register_subtree_array(ett, array_length(ett)); - - /* Register our configuration options */ - - pn_rt_module = prefs_register_protocol(proto_pn_rt, NULL); - - prefs_register_bool_preference(pn_rt_module, "summary_in_tree", - "Show PN-RT summary in protocol tree", - "Whether the PN-RT summary line should be shown in the protocol tree", - &pn_rt_summary_in_tree); - - prefs_register_bool_preference(pn_rt_module, "desegment", - "reassemble PNIO Fragments", - "Reassemble PNIO Fragments and get them decoded", - &pnio_desegment); - - /* register heuristics anchor for payload dissectors */ - register_heur_dissector_list("pn_rt", &heur_subdissector_list); - - init_pn (proto_pn_rt); - register_init_routine(pnio_defragment_init); + static hf_register_info hf[] = { + { &hf_pn_rt_frame_id, + { "FrameID", "pn_rt.frame_id", + FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_rt_cycle_counter, + { "CycleCounter", "pn_rt.cycle_counter", + FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_rt_data_status, + { "DataStatus", "pn_rt.ds", + FT_UINT8, BASE_HEX, 0, 0x0, + NULL, HFILL }}, + + { &hf_pn_rt_data_status_ignore, + { "Ignore (1:Ignore/0:Evaluate)", "pn_rt.ds_ignore", FT_UINT8, BASE_HEX, 0, 0x80, + NULL, HFILL }}, + + { &hf_pn_rt_data_status_Reserved_2, + { "Reserved_2 (should be zero)", "pn_rt.ds_Reserved_2", + FT_UINT8, BASE_HEX, 0, 0x40, + NULL, HFILL }}, + + { &hf_pn_rt_data_status_ok, + { "StationProblemIndicator (1:Ok/0:Problem)", "pn_rt.ds_ok", + FT_UINT8, BASE_HEX, 0, 0x20, + NULL, HFILL }}, + + { &hf_pn_rt_data_status_operate, + { "ProviderState (1:Run/0:Stop)", "pn_rt.ds_operate", + FT_UINT8, BASE_HEX, 0, 0x10, + NULL, HFILL }}, + + { &hf_pn_rt_data_status_res3, + { "Reserved_1 (should be zero)", "pn_rt.ds_res3", + FT_UINT8, BASE_HEX, 0, 0x08, + NULL, HFILL }}, + + { &hf_pn_rt_data_status_valid, + { "DataValid (1:Valid/0:Invalid)", "pn_rt.ds_valid", + FT_UINT8, BASE_HEX, 0, 0x04, + NULL, HFILL }}, + + { &hf_pn_rt_data_status_redundancy, + { "Redundancy", "pn_rt.ds_redundancy", + FT_UINT8, BASE_HEX, VALS(pn_rt_ds_redundancy), 0x02, + NULL, HFILL }}, + + { &hf_pn_rt_data_status_primary, + { "State (1:Primary/0:Backup)", "pn_rt.ds_primary", + FT_UINT8, BASE_HEX, 0, 0x01, + NULL, HFILL }}, + + { &hf_pn_rt_transfer_status, + { "TransferStatus", "pn_rt.transfer_status", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_rt_sf, + { "SubFrame", "pn_rt.sf", + FT_NONE, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_rt_sf_crc16, + { "SFCRC16", "pn_rt.sf.crc16", + FT_UINT16, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_rt_sf_crc16_ok, + { "SFCRC16 checked [ok]", "pn_rt.sf.crc16_ok", + FT_UINT16, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_rt_sf_crc16_null, + { "SFCRC16 not checked but ok", "pn_rt.sf.crc16_null", + FT_UINT16, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_rt_sf_position, + { "Position", "pn_rt.sf.position", + FT_UINT8, BASE_DEC, NULL, 0x7F, + NULL, HFILL }}, + + { &hf_pn_rt_sf_position_control, + { "Control", "pn_rt.sf.position_control", + FT_UINT8, BASE_DEC, VALS(pn_rt_position_control), 0x80, + NULL, HFILL }}, + + { &hf_pn_rt_sf_data_length, + { "DataLength", "pn_rt.sf.data_length", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_rt_sf_cycle_counter, + { "CycleCounter", "pn_rt.sf.cycle_counter", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_rt_frag, + { "PROFINET Fragment", "pn_rt.frag", + FT_NONE, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_rt_frag_data_length, + { "FragDataLength", "pn_rt.frag_data_length", + FT_UINT8, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_rt_frag_status, + { "FragStatus", "pn_rt.frag_status", + FT_NONE, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_pn_rt_frag_status_more_follows, + { "MoreFollows", "pn_rt.frag_status.more_follows", + FT_UINT8, BASE_HEX, VALS(pn_rt_frag_status_more_follows), 0x80, + NULL, HFILL }}, + + { &hf_pn_rt_frag_status_error, + { "Reserved", "pn_rt.frag_status.error", + FT_UINT8, BASE_HEX, VALS(pn_rt_frag_status_error), 0x40, + NULL, HFILL }}, + + { &hf_pn_rt_frag_status_fragment_number, + { "FragmentNumber (zero based)", "pn_rt.frag_status.fragment_number", + FT_UINT8, BASE_DEC, NULL, 0x3F, + NULL, HFILL }}, + + { &hf_pn_rt_frag_data, + { "FragData", "pn_rt.frag_data", + FT_STRING, BASE_NONE, NULL, 0x00, + NULL, HFILL }}, + + }; + static gint *ett[] = { + &ett_pn_rt, + &ett_pn_rt_data_status, + &ett_pn_rt_sf, + &ett_pn_rt_frag, + &ett_pn_rt_frag_status + }; + module_t *pn_rt_module; + + proto_pn_rt = proto_register_protocol("PROFINET Real-Time Protocol", + "PN-RT", "pn_rt"); + + proto_register_field_array(proto_pn_rt, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + + /* Register our configuration options */ + + pn_rt_module = prefs_register_protocol(proto_pn_rt, NULL); + + prefs_register_bool_preference(pn_rt_module, "summary_in_tree", + "Show PN-RT summary in protocol tree", + "Whether the PN-RT summary line should be shown in the protocol tree", + &pn_rt_summary_in_tree); + + prefs_register_bool_preference(pn_rt_module, "desegment", + "reassemble PNIO Fragments", + "Reassemble PNIO Fragments and get them decoded", + &pnio_desegment); + + /* register heuristics anchor for payload dissectors */ + register_heur_dissector_list("pn_rt", &heur_subdissector_list); + + init_pn (proto_pn_rt); + register_init_routine(pnio_defragment_init); } @@ -905,17 +990,17 @@ proto_register_pn_rt(void) void proto_reg_handoff_pn_rt(void) { - dissector_handle_t pn_rt_handle; + dissector_handle_t pn_rt_handle; - pn_rt_handle = create_dissector_handle(dissect_pn_rt, proto_pn_rt); + pn_rt_handle = create_dissector_handle(dissect_pn_rt, proto_pn_rt); - dissector_add_uint("ethertype", ETHERTYPE_PROFINET, pn_rt_handle); - dissector_add_uint("udp.port", 0x8892, pn_rt_handle); + dissector_add_uint("ethertype", ETHERTYPE_PROFINET, pn_rt_handle); + dissector_add_uint("udp.port", 0x8892, pn_rt_handle); - heur_dissector_add("pn_rt", dissect_CSF_SDU_heur, proto_pn_rt); - heur_dissector_add("pn_rt", dissect_FRAG_PDU_heur, proto_pn_rt); - data_handle = find_dissector("data"); + heur_dissector_add("pn_rt", dissect_CSF_SDU_heur, proto_pn_rt); + heur_dissector_add("pn_rt", dissect_FRAG_PDU_heur, proto_pn_rt); + data_handle = find_dissector("data"); - ethertype_subdissector_table = find_dissector_table("ethertype"); + ethertype_subdissector_table = find_dissector_table("ethertype"); } diff --git a/plugins/profinet/packet-pn.c b/plugins/profinet/packet-pn.c index 527454e2cd..a6b73a1fec 100644 --- a/plugins/profinet/packet-pn.c +++ b/plugins/profinet/packet-pn.c @@ -290,17 +290,35 @@ init_pn (int proto) { static hf_register_info hf[] = { { &hf_pn_padding, - { "Padding", "pn.padding", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + { "Padding", "pn.padding", + FT_STRING, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + { &hf_pn_undecoded_data, - { "Undecoded Data", "pn.undecoded", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + { "Undecoded Data", "pn.undecoded", + FT_STRING, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + { &hf_pn_user_data, - { "User Data", "pn.user_data", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + { "User Data", "pn.user_data", + FT_STRING, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + { &hf_pn_user_bytes, - { "Substitute Data", "pn.user_bytes", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + { "Substitute Data", "pn.user_bytes", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + { &hf_pn_frag_bytes, - { "Fragment Data", "pn.frag_bytes", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + { "Fragment Data", "pn.frag_bytes", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + { &hf_pn_malformed, - { "Malformed", "pn_rt.malformed", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }} + { "Malformed", "pn_rt.malformed", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }} + }; |