General cleanup:

- Localize some variables; remove unneeded initializers;
- Reformat some hf[] entries;
- Whitespace; style; long lines.

svn path=/trunk/; revision=46529
This commit is contained in:
Bill Meier 2012-12-13 18:17:47 +00:00
parent e5fc8a400e
commit 5a8c275b26
9 changed files with 2371 additions and 1834 deletions

View File

@ -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;
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;
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;
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;
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) {

View File

@ -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 */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -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);
}

View File

@ -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[] = {
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 }},
{ &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);
}

File diff suppressed because it is too large Load Diff

View File

@ -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;
static hf_register_info hf[] = {
{ &hf_pn_rt_frame_id,
{ "FrameID", "pn_rt.frame_id",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
proto_pn_rt = proto_register_protocol("PROFINET Real-Time Protocol",
"PN-RT", "pn_rt");
{ &hf_pn_rt_cycle_counter,
{ "CycleCounter", "pn_rt.cycle_counter",
FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
proto_register_field_array(proto_pn_rt, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
{ &hf_pn_rt_data_status,
{ "DataStatus", "pn_rt.ds",
FT_UINT8, BASE_HEX, 0, 0x0,
NULL, HFILL }},
/* Register our configuration options */
{ &hf_pn_rt_data_status_ignore,
{ "Ignore (1:Ignore/0:Evaluate)", "pn_rt.ds_ignore", FT_UINT8, BASE_HEX, 0, 0x80,
NULL, HFILL }},
pn_rt_module = prefs_register_protocol(proto_pn_rt, NULL);
{ &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 }},
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);
{ &hf_pn_rt_data_status_ok,
{ "StationProblemIndicator (1:Ok/0:Problem)", "pn_rt.ds_ok",
FT_UINT8, BASE_HEX, 0, 0x20,
NULL, HFILL }},
prefs_register_bool_preference(pn_rt_module, "desegment",
"reassemble PNIO Fragments",
"Reassemble PNIO Fragments and get them decoded",
&pnio_desegment);
{ &hf_pn_rt_data_status_operate,
{ "ProviderState (1:Run/0:Stop)", "pn_rt.ds_operate",
FT_UINT8, BASE_HEX, 0, 0x10,
NULL, HFILL }},
/* register heuristics anchor for payload dissectors */
register_heur_dissector_list("pn_rt", &heur_subdissector_list);
{ &hf_pn_rt_data_status_res3,
{ "Reserved_1 (should be zero)", "pn_rt.ds_res3",
FT_UINT8, BASE_HEX, 0, 0x08,
NULL, HFILL }},
init_pn (proto_pn_rt);
register_init_routine(pnio_defragment_init);
{ &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");
}

View File

@ -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 }}
};