Fix http://bugs.wireshark.org/bugzilla/show_bug.cgi?id=2186 (many unnamed structs in packet-ecatmb.h) by adding predictable (but not very descriptive) struct names

svn path=/trunk/; revision=24061
This commit is contained in:
Jeff Morriss 2008-01-10 22:19:53 +00:00
parent 3be6284ef3
commit 283ddb3d0c
3 changed files with 123 additions and 123 deletions

View File

@ -288,8 +288,8 @@ void init_foe_header(PETHERCAT_FOE_HEADER pFoE, tvbuff_t *tvb, gint offset)
void init_soe_header(PETHERCAT_SOE_HEADER pSoE, tvbuff_t *tvb, gint offset)
{
pSoE->anSoeHeaderControlUnion.Control = tvb_get_guint8(tvb, offset++);
pSoE->anSoeHeaderControlUnion.Element = tvb_get_guint8(tvb, offset++);
pSoE->anSoeHeaderControlUnion.v2.Control = tvb_get_guint8(tvb, offset++);
pSoE->anSoeHeaderControlUnion.v2.Element = tvb_get_guint8(tvb, offset++);
pSoE->anSoeHeaderDataUnion.FragmentsLeft = tvb_get_letohs(tvb, offset);
}
@ -320,64 +320,64 @@ static void MailboxTypeFormater(PETHERCAT_MBOX_HEADER pMbx, char *szText, gint n
for(i = 0; i<sizeof(EcMBoxType)/sizeof(value_string); i++ )
{
if( EcMBoxType[i].value == pMbx->aControlUnion.Type )
if( EcMBoxType[i].value == pMbx->aControlUnion.v.Type )
{
g_snprintf(szText, nMax, "Type : %s (0x%x)", EcMBoxType[i].strptr, pMbx->aControlUnion.Type);
g_snprintf(szText, nMax, "Type : %s (0x%x)", EcMBoxType[i].strptr, pMbx->aControlUnion.v.Type);
return;
}
}
g_snprintf ( szText, nMax,"Type : %d", pMbx->aControlUnion.Type);
g_snprintf ( szText, nMax,"Type : %d", pMbx->aControlUnion.v.Type);
}
static void EoETypeFormater(PETHERCAT_EOE_HEADER pEoE, char *szText, gint nMax)
{
switch (pEoE->anEoeHeaderInfoUnion.Type)
switch (pEoE->anEoeHeaderInfoUnion.v.Type)
{
case EOE_TYPE_FRAME_FRAG:
g_snprintf ( szText, nMax, "Type(%d) : Fragment", pEoE->anEoeHeaderInfoUnion.Type);
g_snprintf ( szText, nMax, "Type(%d) : Fragment", pEoE->anEoeHeaderInfoUnion.v.Type);
break;
case EOE_TYPE_TIMESTAMP_RES:
g_snprintf ( szText, nMax, "Type(%d) : TimeStamp", pEoE->anEoeHeaderInfoUnion.Type);
g_snprintf ( szText, nMax, "Type(%d) : TimeStamp", pEoE->anEoeHeaderInfoUnion.v.Type);
break;
case EOE_TYPE_INIT_REQ:
g_snprintf ( szText, nMax, "Type(%d) : Init Req", pEoE->anEoeHeaderInfoUnion.Type);
g_snprintf ( szText, nMax, "Type(%d) : Init Req", pEoE->anEoeHeaderInfoUnion.v.Type);
break;
case EOE_TYPE_INIT_RES:
g_snprintf ( szText, nMax, "Type(%d) : Init Res", pEoE->anEoeHeaderInfoUnion.Type);
g_snprintf ( szText, nMax, "Type(%d) : Init Res", pEoE->anEoeHeaderInfoUnion.v.Type);
break;
case EOE_TYPE_MACFILTER_REQ:
g_snprintf ( szText, nMax, "Type(%d) : MAC Req", pEoE->anEoeHeaderInfoUnion.Type);
g_snprintf ( szText, nMax, "Type(%d) : MAC Req", pEoE->anEoeHeaderInfoUnion.v.Type);
break;
case EOE_TYPE_MACFILTER_RES:
g_snprintf ( szText, nMax, "Type(%d) : MAC Res", pEoE->anEoeHeaderInfoUnion.Type);
g_snprintf ( szText, nMax, "Type(%d) : MAC Res", pEoE->anEoeHeaderInfoUnion.v.Type);
break;
default:
g_snprintf ( szText, nMax, "Type(%d) : Unknown", pEoE->anEoeHeaderInfoUnion.Type);
g_snprintf ( szText, nMax, "Type(%d) : Unknown", pEoE->anEoeHeaderInfoUnion.v.Type);
break;
}
}
static void EoEFragNoFormater(PETHERCAT_EOE_HEADER pEoE, char *szText, gint nMax)
{
g_snprintf ( szText, nMax, "FragNo : %d", pEoE->anEoeHeaderDataUnion.Fragment);
g_snprintf ( szText, nMax, "FragNo : %d", pEoE->anEoeHeaderDataUnion.v.Fragment);
}
static void EoEOffsetFormater(PETHERCAT_EOE_HEADER pEoE, char *szText, gint nMax)
{
if ( pEoE->anEoeHeaderDataUnion.Fragment == 0 )
g_snprintf ( szText, nMax, "BufferSize : %d", 32*pEoE->anEoeHeaderDataUnion.OffsetBuffer);
if ( pEoE->anEoeHeaderDataUnion.v.Fragment == 0 )
g_snprintf ( szText, nMax, "BufferSize : %d", 32*pEoE->anEoeHeaderDataUnion.v.OffsetBuffer);
else
g_snprintf ( szText, nMax, "Offset : %d", 32*pEoE->anEoeHeaderDataUnion.OffsetBuffer);
g_snprintf ( szText, nMax, "Offset : %d", 32*pEoE->anEoeHeaderDataUnion.v.OffsetBuffer);
}
static void EoEFrameFormater(PETHERCAT_EOE_HEADER pEoE, char *szText, gint nMax)
{
g_snprintf ( szText, nMax, "FrameNo : %d", pEoE->anEoeHeaderDataUnion.FrameNo);
g_snprintf ( szText, nMax, "FrameNo : %d", pEoE->anEoeHeaderDataUnion.v.FrameNo);
}
static void EoELastFormater(PETHERCAT_EOE_HEADER pEoE, char *szText, gint nMax)
{
if ( pEoE->anEoeHeaderInfoUnion.LastFragment != 0 )
if ( pEoE->anEoeHeaderInfoUnion.v.LastFragment != 0 )
g_snprintf ( szText, nMax, "Last Frag");
else
g_snprintf ( szText, nMax, "More Frags...");
@ -385,36 +385,36 @@ static void EoELastFormater(PETHERCAT_EOE_HEADER pEoE, char *szText, gint nMax)
static void CANopenNumberFormater(PETHERCAT_COE_HEADER pCoE, char *szText, gint nMax)
{
g_snprintf( szText, nMax, "Number : %d", pCoE->Number);
g_snprintf( szText, nMax, "Number : %d", pCoE->v.Number);
}
static void CANopenTypeFormater(PETHERCAT_COE_HEADER pCoE, char *szText, gint nMax)
{
switch ( pCoE->Type)
switch ( pCoE->v.Type)
{
case ETHERCAT_COE_TYPE_EMERGENCY:
g_snprintf ( szText, nMax, "Type : EMERGENCY(%d)", pCoE->Type);
g_snprintf ( szText, nMax, "Type : EMERGENCY(%d)", pCoE->v.Type);
break;
case ETHERCAT_COE_TYPE_SDOREQ:
g_snprintf ( szText, nMax, "Type : SDO Req(%d)", pCoE->Type);
g_snprintf ( szText, nMax, "Type : SDO Req(%d)", pCoE->v.Type);
break;
case ETHERCAT_COE_TYPE_SDORES:
g_snprintf ( szText, nMax, "Type : SDO Res(%d)", pCoE->Type);
g_snprintf ( szText, nMax, "Type : SDO Res(%d)", pCoE->v.Type);
break;
case ETHERCAT_COE_TYPE_TXPDO:
g_snprintf ( szText, nMax, "Type : TxPDO(%d)", pCoE->Type);
g_snprintf ( szText, nMax, "Type : TxPDO(%d)", pCoE->v.Type);
break;
case ETHERCAT_COE_TYPE_RXPDO:
g_snprintf ( szText, nMax, "Type : RxPDO(%d)", pCoE->Type);
g_snprintf ( szText, nMax, "Type : RxPDO(%d)", pCoE->v.Type);
break;
case ETHERCAT_COE_TYPE_TXPDO_RTR:
g_snprintf ( szText, nMax, "Type : TxPDO_RTR(%d)", pCoE->Type);
g_snprintf ( szText, nMax, "Type : TxPDO_RTR(%d)", pCoE->v.Type);
break;
case ETHERCAT_COE_TYPE_RXPDO_RTR:
g_snprintf ( szText, nMax, "Type : RxPDO_RTR(%d)", pCoE->Type);
g_snprintf ( szText, nMax, "Type : RxPDO_RTR(%d)", pCoE->v.Type);
break;
default:
g_snprintf ( szText, nMax, "Type :%d", pCoE->Type);
g_snprintf ( szText, nMax, "Type :%d", pCoE->v.Type);
}
}
@ -449,9 +449,9 @@ static void CANopenSdoResFormater(PETHERCAT_SDO_HEADER pSdo, char *szText, gint
static void CANopenSdoInfoFormater(PETHERCAT_SDO_INFO_HEADER pHead, char *szText, gint nMax)
{
guint8 opCode = pHead->anSdoControlUnion.OpCode&0x7F;
guint8 opCode = pHead->anSdoControlUnion.v.OpCode & 0x7F;
char* txt2 = "";
if ( (pHead->anSdoControlUnion.OpCode&0x80) != 0 )
if ( (pHead->anSdoControlUnion.v.OpCode & 0x80) != 0 )
txt2 = " - More Follows";
switch (opCode)
{
@ -508,19 +508,19 @@ static void FoeFormater(tvbuff_t *tvb, gint offset, char *szText, gint nMax, gui
g_snprintf ( szText, nMax, "FoE WRQ (%d) : '%s'", foe.aFoeHeaderDataUnion.FileLength, tmp);
break;
case ECAT_FOE_OPMODE_DATA:
g_snprintf ( szText, nMax, "FoE DATA (%d) : %d Bytes", foe.aFoeHeaderDataUnion.PacketNo, foe_length-ETHERCAT_FOE_HEADER_LEN);
g_snprintf ( szText, nMax, "FoE DATA (%d) : %d Bytes", foe.aFoeHeaderDataUnion.v.PacketNo, foe_length-ETHERCAT_FOE_HEADER_LEN);
break;
case ECAT_FOE_OPMODE_ACK:
g_snprintf ( szText, nMax, "FoE ACK (%d)", foe.aFoeHeaderDataUnion.PacketNo);
g_snprintf ( szText, nMax, "FoE ACK (%d)", foe.aFoeHeaderDataUnion.v.PacketNo);
break;
case ECAT_FOE_OPMODE_ERR:
g_snprintf ( szText, nMax, "FoE ERR (%d) : '%s'", foe.aFoeHeaderDataUnion.ErrorCode, tmp);
break;
case ECAT_FOE_OPMODE_BUSY:
if ( foe.aFoeHeaderDataUnion.Entire > 0 )
g_snprintf ( szText, nMax, "FoE BUSY (%d%%)", ((guint32)foe.aFoeHeaderDataUnion.Done*100)/foe.aFoeHeaderDataUnion.Entire);
if ( foe.aFoeHeaderDataUnion.v2.Entire > 0 )
g_snprintf ( szText, nMax, "FoE BUSY (%d%%)", ((guint32)foe.aFoeHeaderDataUnion.v2.Done*100)/foe.aFoeHeaderDataUnion.v2.Entire);
else
g_snprintf ( szText, nMax, "FoE BUSY (%d/%d)", foe.aFoeHeaderDataUnion.Done, foe.aFoeHeaderDataUnion.Entire);
g_snprintf ( szText, nMax, "FoE BUSY (%d/%d)", foe.aFoeHeaderDataUnion.v2.Done, foe.aFoeHeaderDataUnion.v2.Entire);
break;
}
}
@ -543,27 +543,27 @@ static void SoeFormater(tvbuff_t *tvb, gint offset, char *szText, gint nMax, gui
init_soe_header(&soe, tvb, offset);
offset+=ETHERCAT_SOE_HEADER_LEN;
if ( !soe.anSoeHeaderControlUnion.Error )
if ( !soe.anSoeHeaderControlUnion.v.Error )
{
if ( !soe.anSoeHeaderControlUnion.InComplete )
if ( !soe.anSoeHeaderControlUnion.v.InComplete )
{
SoEIdToString(tmp, soe.anSoeHeaderDataUnion.IDN, sizeof(tmp)-1);
elm[0] = 0;
if ( soe.anSoeHeaderControlUnion.DataState )
if ( soe.anSoeHeaderControlUnion.v.DataState )
strcat(elm, "D");
if ( soe.anSoeHeaderControlUnion.Name )
if ( soe.anSoeHeaderControlUnion.v.Name )
strcat(elm, "N");
if ( soe.anSoeHeaderControlUnion.Attribute )
if ( soe.anSoeHeaderControlUnion.v.Attribute )
strcat(elm, "A");
if ( soe.anSoeHeaderControlUnion.Unit )
if ( soe.anSoeHeaderControlUnion.v.Unit )
strcat(elm, "U");
if ( soe.anSoeHeaderControlUnion.Min )
if ( soe.anSoeHeaderControlUnion.v.Min )
strcat(elm, "I");
if ( soe.anSoeHeaderControlUnion.Max )
if ( soe.anSoeHeaderControlUnion.v.Max )
strcat(elm, "X");
if ( soe.anSoeHeaderControlUnion.Value )
if ( soe.anSoeHeaderControlUnion.v.Value )
strcat(elm, "V");
switch ( soe.anSoeHeaderControlUnion.OpCode )
switch ( soe.anSoeHeaderControlUnion.v.OpCode )
{
case ECAT_SOE_OPCODE_RRQ:
g_snprintf ( szText, nMax, "SoE: RRQ (%s, '%s')", tmp, elm);
@ -626,17 +626,17 @@ static void dissect_ecat_coe(tvbuff_t *tvb, gint offset, packet_info *pinfo, pro
ecat_coe_tree = proto_item_add_subtree(aitem, ett_ecat_mailbox_coe);
CANopenNumberFormater(&coe, szText, nMax);
aitem = proto_tree_add_uint(ecat_coe_tree, hf_ecat_mailbox_coe_number, tvb, offset, ETHERCAT_COE_HEADER_LEN, coe.Number);
aitem = proto_tree_add_uint(ecat_coe_tree, hf_ecat_mailbox_coe_number, tvb, offset, ETHERCAT_COE_HEADER_LEN, coe.v.Number);
proto_item_set_text(aitem, szText);
CANopenTypeFormater(&coe, szText, nMax);
aitem = proto_tree_add_uint(ecat_coe_tree, hf_ecat_mailbox_coe_type, tvb, offset, ETHERCAT_COE_HEADER_LEN, coe.Type);
aitem = proto_tree_add_uint(ecat_coe_tree, hf_ecat_mailbox_coe_type, tvb, offset, ETHERCAT_COE_HEADER_LEN, coe.v.Type);
proto_item_set_text(aitem, szText);
}
offset += ETHERCAT_COE_HEADER_LEN;
switch (coe.Type)
switch (coe.v.Type)
{
case ETHERCAT_COE_TYPE_SDOREQ:
{
@ -833,7 +833,7 @@ static void dissect_ecat_coe(tvbuff_t *tvb, gint offset, packet_info *pinfo, pro
aitem = proto_tree_add_item(ecat_coe_tree, hf_ecat_mailbox_coe_sdoinfofrag, tvb, offset, 2, TRUE);
offset+=2;
switch ( info.anSdoControlUnion.OpCode )
switch ( info.anSdoControlUnion.v.OpCode )
{
case ECAT_COE_INFO_OPCODE_LIST_Q:
{
@ -987,11 +987,11 @@ static void dissect_ecat_soe(tvbuff_t *tvb, gint offset, packet_info *pinfo, pro
aitem = proto_tree_add_item(ecat_soeflag_tree, hf_ecat_mailbox_soe_header_reserved, tvb, offset, 2, TRUE);
offset+=2;
if ( !soe.anSoeHeaderControlUnion.Error )
if ( !soe.anSoeHeaderControlUnion.v.Error )
{
if ( !soe.anSoeHeaderControlUnion.InComplete )
if ( !soe.anSoeHeaderControlUnion.v.InComplete )
{
switch (soe.anSoeHeaderControlUnion.OpCode)
switch (soe.anSoeHeaderControlUnion.v.OpCode)
{
case ECAT_SOE_OPCODE_RRQ:
case ECAT_SOE_OPCODE_WRS:
@ -1055,8 +1055,8 @@ static void dissect_ecat_eoe(tvbuff_t *tvb, gint offset, packet_info *pinfo, pro
init_eoe_header(&eoe, tvb, offset);
if (check_col(pinfo->cinfo, COL_INFO))
{
if ( eoe.anEoeHeaderInfoUnion.Type == EOE_TYPE_FRAME_FRAG )
g_snprintf ( szText, nMax, "EoE-Frag %d", eoe.anEoeHeaderDataUnion.Fragment);
if ( eoe.anEoeHeaderInfoUnion.v.Type == EOE_TYPE_FRAME_FRAG )
g_snprintf ( szText, nMax, "EoE-Frag %d", eoe.anEoeHeaderDataUnion.v.Fragment);
else
g_snprintf ( szText, nMax, "EoE");
col_append_str(pinfo->cinfo, COL_INFO, szText);
@ -1070,51 +1070,51 @@ static void dissect_ecat_eoe(tvbuff_t *tvb, gint offset, packet_info *pinfo, pro
proto_item_set_text(aitem, "Header");
ecat_fraghead_tree = proto_item_add_subtree(aitem, ett_ecat_mailbox_fraghead);
aitem = proto_tree_add_uint(ecat_fraghead_tree, hf_ecat_mailbox_eoe_type, tvb, offset, 4, eoe.anEoeHeaderInfoUnion.Type);
aitem = proto_tree_add_uint(ecat_fraghead_tree, hf_ecat_mailbox_eoe_type, tvb, offset, 4, eoe.anEoeHeaderInfoUnion.v.Type);
EoETypeFormater(&eoe, szText, nMax);
proto_item_set_text(aitem,szText);
switch ( eoe.anEoeHeaderInfoUnion.Type )
switch ( eoe.anEoeHeaderInfoUnion.v.Type )
{
case EOE_TYPE_FRAME_FRAG:
aitem = proto_tree_add_uint(ecat_fraghead_tree, hf_ecat_mailbox_eoe_fragno, tvb, offset, 4, eoe.anEoeHeaderDataUnion.Fragment);
aitem = proto_tree_add_uint(ecat_fraghead_tree, hf_ecat_mailbox_eoe_fragno, tvb, offset, 4, eoe.anEoeHeaderDataUnion.v.Fragment);
EoEFragNoFormater(&eoe, szText, nMax);
proto_item_set_text(aitem,szText);
aitem = proto_tree_add_uint(ecat_fraghead_tree, hf_ecat_mailbox_eoe_offset, tvb, offset, 4, 32*eoe.anEoeHeaderDataUnion.OffsetBuffer);
aitem = proto_tree_add_uint(ecat_fraghead_tree, hf_ecat_mailbox_eoe_offset, tvb, offset, 4, 32*eoe.anEoeHeaderDataUnion.v.OffsetBuffer);
EoEOffsetFormater(&eoe, szText, nMax);
proto_item_set_text(aitem,szText);
aitem = proto_tree_add_uint(ecat_fraghead_tree, hf_ecat_mailbox_eoe_frame, tvb, offset, 4, eoe.anEoeHeaderDataUnion.FrameNo);
aitem = proto_tree_add_uint(ecat_fraghead_tree, hf_ecat_mailbox_eoe_frame, tvb, offset, 4, eoe.anEoeHeaderDataUnion.v.FrameNo);
EoEFrameFormater(&eoe, szText, nMax);
proto_item_set_text(aitem,szText);
aitem = proto_tree_add_uint(ecat_fraghead_tree, hf_ecat_mailbox_eoe_last, tvb, offset, 4, eoe.anEoeHeaderInfoUnion.LastFragment);
aitem = proto_tree_add_uint(ecat_fraghead_tree, hf_ecat_mailbox_eoe_last, tvb, offset, 4, eoe.anEoeHeaderInfoUnion.v.LastFragment);
EoELastFormater(&eoe, szText, nMax);
proto_item_set_text(aitem,szText);
if ( eoe.anEoeHeaderInfoUnion.TimeStampRequested )
if ( eoe.anEoeHeaderInfoUnion.v.TimeStampRequested )
{
aitem = proto_tree_add_uint(ecat_fraghead_tree, hf_ecat_mailbox_eoe_timestampreq, tvb, offset, 4, eoe.anEoeHeaderInfoUnion.TimeStampRequested);
aitem = proto_tree_add_uint(ecat_fraghead_tree, hf_ecat_mailbox_eoe_timestampreq, tvb, offset, 4, eoe.anEoeHeaderInfoUnion.v.TimeStampRequested);
proto_item_set_text(aitem, "Time Stamp Requested");
}
if ( eoe.anEoeHeaderInfoUnion.TimeStampAppended )
if ( eoe.anEoeHeaderInfoUnion.v.TimeStampAppended )
{
aitem = proto_tree_add_uint(ecat_fraghead_tree, hf_ecat_mailbox_eoe_timestampapp, tvb, offset, 4, eoe.anEoeHeaderInfoUnion.TimeStampAppended);
aitem = proto_tree_add_uint(ecat_fraghead_tree, hf_ecat_mailbox_eoe_timestampapp, tvb, offset, 4, eoe.anEoeHeaderInfoUnion.v.TimeStampAppended);
proto_item_set_text(aitem, "Time Stamp Appended");
}
offset+=ETHERCAT_EOE_HEADER_LEN;
aitem = proto_tree_add_item(ecat_eoe_tree, hf_ecat_mailbox_eoe_fragment, tvb, offset, eoe_length-offset, TRUE);
if ( eoe.anEoeHeaderDataUnion.Fragment == 0 )
if ( eoe.anEoeHeaderDataUnion.v.Fragment == 0 )
{
next_tvb = tvb_new_subset(tvb, offset, eoe_length-offset, eoe_length-offset);
call_dissector( eth_handle, next_tvb, pinfo, ecat_eoe_tree);
}
if ( eoe.anEoeHeaderInfoUnion.TimeStampAppended )
if ( eoe.anEoeHeaderInfoUnion.v.TimeStampAppended )
{
aitem = proto_tree_add_item(ecat_eoe_tree, hf_ecat_mailbox_eoe_timestamp, tvb, eoe_length-ETHERCAT_EOE_TIMESTAMP_LEN, ETHERCAT_EOE_TIMESTAMP_LEN, TRUE);
}
@ -1177,13 +1177,13 @@ static void dissect_ecat_eoe(tvbuff_t *tvb, gint offset, packet_info *pinfo, pro
aitem = proto_tree_add_item(ecat_eoe_macfilter_tree, hf_ecat_mailbox_eoe_macfilter_filter, tvb, offset, 16*ETHERNET_ADDRESS_LEN, TRUE);
ecat_eoe_macfilter_filter_tree = proto_item_add_subtree(aitem, ett_ecat_mailbox_eoe_macfilter_filter);
for( nCnt=0; nCnt<options.MacFilterCount; nCnt++)
for( nCnt=0; nCnt<options.v.MacFilterCount; nCnt++)
aitem = proto_tree_add_item(ecat_eoe_macfilter_filter_tree, hf_ecat_mailbox_eoe_macfilter_filters[nCnt], tvb, offset+nCnt*ETHERNET_ADDRESS_LEN, ETHERNET_ADDRESS_LEN, TRUE);
offset+=16*ETHERNET_ADDRESS_LEN;
aitem = proto_tree_add_item(ecat_eoe_macfilter_tree, hf_ecat_mailbox_eoe_macfilter_filtermask, tvb, offset, 4*sizeof(guint32), TRUE);
ecat_eoe_macfilter_filtermask_tree = proto_item_add_subtree(aitem, ett_ecat_mailbox_eoe_macfilter_filtermask);
for( nCnt=0; nCnt<options.MacFilterMaskCount; nCnt++)
for( nCnt=0; nCnt<options.v.MacFilterMaskCount; nCnt++)
aitem = proto_tree_add_item(ecat_eoe_macfilter_tree, hf_ecat_mailbox_eoe_macfilter_filtermasks[nCnt], tvb, offset+nCnt*sizeof(guint32), sizeof(guint32), TRUE);
}
else
@ -1348,14 +1348,14 @@ static void dissect_ecat_mailbox(tvbuff_t *tvb, packet_info *pinfo, proto_tree *
proto_item_set_text(aitem,szText);
aitem = proto_tree_add_item(ecat_mailbox_tree, hf_ecat_mailboxcounter, tvb, offset, 1,TRUE);
proto_item_set_text(aitem,"Counter : %d",hdr.aControlUnion.Counter);
proto_item_set_text(aitem,"Counter : %d",hdr.aControlUnion.v.Counter);
offset++;
}
else
offset+=ETHERCAT_MBOX_HEADER_LEN;
next_tvb = tvb_new_subset (tvb, offset, hdr.Length, hdr.Length);
switch ( hdr.aControlUnion.Type )
switch ( hdr.aControlUnion.v.Type )
{
case ETHERCAT_MBOX_TYPE_ADS:
call_dissector(ams_handle, next_tvb, pinfo, ecat_mailbox_tree);

View File

@ -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -50,7 +50,7 @@ typedef union tMbxHeaderControlUnion
guint16 Type : 4; /* TETHERCAT_MBOX_TYPE_xxx*/
guint16 Counter : 3; /* 0 = counter not used (old version)*/
guint16 Unsupported : 1; /* unsupported protocol detected*/
};
} v;
} MbxHeaderControlUnion;
typedef struct TETHERCAT_MBOX_HEADER
@ -101,13 +101,13 @@ typedef struct TETHERCAT_MBOX_HEADER
typedef union tEoeMacFilterOptionsUnion
{
struct
{
{
guint16 MacFilterCount :4;
guint16 MacFilterMaskCount :2;
guint16 Reserved1 :1;
guint16 NoBroadcasts :1;
guint16 Reserved2 :8;
};
} v;
guint16 Options;
} EoeMacFilterOptionsUnion;
@ -134,26 +134,26 @@ typedef union tEoeHeaderDataUnion
guint16 OffsetBuffer : 6; /* byte offset multiplied by 32 (if Fragment != 0) (EOE_TYPE_FRAME_FRAG only) */
/* buffer size multiplied by 32 (if Fragment == 0) (EOE_TYPE_FRAME_FRAG only) */
guint16 FrameNo : 4; /* frame number (EOE_TYPE_FRAME_FRAG and EOE_TYPE_TIMESTAMP_RES only) */
};
} v;
guint16 Result; /* EOE_TYPE_INIT_RES and EOE_TYPE_MACFILTER_RES only */
} EoeHeaderDataUnion;
typedef union tEoeHeaderInfoUnion
{
struct
{
{
guint16 Type : 4; /* specifies following data */
guint16 PortAssign : 4; /* 0 = unspecified, 1 = port 1 */
guint16 LastFragment : 1; /* TRUE if last fragment (EOE_TYPE_FRAME_FRAG only) */
guint16 TimeStampAppended : 1; /* 32 bit time stamp appended (EOE_TYPE_FRAME_FRAG with LastFragment=1 only) */
guint16 TimeStampRequested : 1; /* time stamp response requested (EOE_TYPE_FRAME_FRAG only) */
guint16 Reserved : 5;
};
} v;
guint16 Info;
} EoeHeaderInfoUnion;
typedef struct TETHERCAT_EOE_HEADER
{
{
EoeHeaderInfoUnion anEoeHeaderInfoUnion;
EoeHeaderDataUnion anEoeHeaderDataUnion;
} ETHERCAT_EOE_HEADER, *PETHERCAT_EOE_HEADER;
@ -177,7 +177,7 @@ typedef union TETHERCAT_COE_HEADER
guint16 Number : 9; /* e.g. PDO number*/
guint16 Reserved : 3; /* = 0*/
guint16 Type : 4; /* CANopen type*/
};
} v;
guint16 header;
} ETHERCAT_COE_HEADER, *PETHERCAT_COE_HEADER;
#define ETHERCAT_COE_HEADER_LEN sizeof(ETHERCAT_COE_HEADER)
@ -352,7 +352,7 @@ typedef union tSdoControlUnion
{
guint8 OpCode : 7; /* == SDO_INFO_TYPE_XXX */
guint8 InComplete : 1;
};
} v;
guint8 Control;
} SdoControlUnion;
@ -392,13 +392,13 @@ typedef union tFoeHeaderDataUnion
{
guint16 PacketNo; /* (DATA, ACK)*/
guint16 Reserved2; /* (DATA, ACK)*/
};
} v;
guint32 ErrorCode; /* (ERR)*/
struct
{
guint16 Done; /* (BUSY)*/
guint16 Entire; /* (BUSY)*/
};
} v2;
} FoeHeaderDataUnion;
typedef struct TETHERCAT_FOE_HEADER
@ -451,12 +451,12 @@ typedef union tSoeHeaderControlUnion
guint8 Max : 1; /* follows or requested */
guint8 Value : 1; /* follows or requested */
guint8 Reserved : 1;
};
} v;
struct
{
guint8 Control;
guint8 Element;
};
} v2;
} SoeHeaderControlUnion;
typedef union tSoeHeaderDataUnion
@ -471,8 +471,8 @@ typedef struct TETHERCAT_SOE_HEADER
SoeHeaderDataUnion anSoeHeaderDataUnion;
/* typedef union tMailBoxDataUnion
{
guint8 Data[] rest of mailbox data if (Error==0)
guint16 ErrorCode if (Error==1)
guint8 Data[] rest of mailbox data if (Error==0)
guint16 ErrorCode if (Error==1)
} MailBoxDataUnion;*/
} ETHERCAT_SOE_HEADER, *PETHERCAT_SOE_HEADER;
#define ETHERCAT_SOE_HEADER_LEN sizeof(ETHERCAT_SOE_HEADER)

View File

@ -8,17 +8,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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -223,7 +223,7 @@ static const true_false_string tfs_ecat_syncman_flag13 =
static const true_false_string tfs_ecat_syncman_flag16 =
{
"SyncMan enabled", "SyncMan disabled",
"SyncMan enabled", "SyncMan disabled",
};
static const char* convertEcCmdToText(int cmd)
@ -326,26 +326,26 @@ static void EcSummaryFormater(guint32 datalength, tvbuff_t *tvb, gint offset, ch
{
guint16 len = ecFirst.len&0x07ff;
guint16 cnt = get_wc(&ecFirst, tvb, offset);
g_snprintf ( szText, nMax, "'%s', Len: %d, Adp 0x%x, Ado 0x%x, Wc %d ",
g_snprintf ( szText, nMax, "'%s', Len: %d, Adp 0x%x, Ado 0x%x, Wc %d ",
convertEcCmdToText(ecFirst.cmd), len, ecFirst.anAddrUnion.adp, ecFirst.anAddrUnion.ado, cnt );
}
else if ( nSub == 2 )
{
g_snprintf ( szText, nMax, "%d Cmds, '%s', Len %d, '%s', Len %d ",
g_snprintf ( szText, nMax, "%d Cmds, '%s', Len %d, '%s', Len %d ",
nSub, convertEcCmdToText(nCmds[0]), nLens[0], convertEcCmdToText(nCmds[1]), nLens[1]);
}
else if ( nSub == 3 )
{
g_snprintf ( szText, nMax, "%d Cmds, '%s', Len %d, '%s', Len %d, '%s', Len %d",
g_snprintf ( szText, nMax, "%d Cmds, '%s', Len %d, '%s', Len %d, '%s', Len %d",
nSub, convertEcCmdToText(nCmds[0]), nLens[0], convertEcCmdToText(nCmds[1]), nLens[1], convertEcCmdToText(nCmds[2]), nLens[2]);
}
else if ( nSub == 4 )
{
g_snprintf ( szText, nMax, "%d Cmds, '%s', L %d, '%s', L %d, '%s', L %d, '%s', L %d",
g_snprintf ( szText, nMax, "%d Cmds, '%s', L %d, '%s', L %d, '%s', L %d, '%s', L %d",
nSub, convertEcCmdToText(nCmds[0]), nLens[0], convertEcCmdToText(nCmds[1]), nLens[1], convertEcCmdToText(nCmds[2]), nLens[2], convertEcCmdToText(nCmds[3]), nLens[3]);
}
else
g_snprintf ( szText, nMax, "%d Cmds, SumLen %d, '%s'... ",
g_snprintf ( szText, nMax, "%d Cmds, SumLen %d, '%s'... ",
nSub, nLen, convertEcCmdToText(ecFirst.cmd));
}
@ -372,13 +372,13 @@ static void EcSubFormater(tvbuff_t *tvb, gint offset, char *szText, gint nMax)
case EC_CMD_TYPE_BRW:
case EC_CMD_TYPE_ARMW:
case EC_CMD_TYPE_FRMW:
g_snprintf ( szText, nMax, "Sub Frame: Cmd: '%s' (%d), Len: %d, Adp 0x%x, Ado 0x%x, Cnt %d",
g_snprintf ( szText, nMax, "Sub Frame: Cmd: '%s' (%d), Len: %d, Adp 0x%x, Ado 0x%x, Cnt %d",
convertEcCmdToText(ecParser.cmd), ecParser.cmd, len, ecParser.anAddrUnion.adp, ecParser.anAddrUnion.ado, cnt);
break;
case EC_CMD_TYPE_LRD:
case EC_CMD_TYPE_LWR:
case EC_CMD_TYPE_LRW:
g_snprintf ( szText, nMax, "Sub Frame: Cmd: '%s' (%d), Len: %d, Addr 0x%x, Cnt %d",
g_snprintf ( szText, nMax, "Sub Frame: Cmd: '%s' (%d), Len: %d, Addr 0x%x, Cnt %d",
convertEcCmdToText(ecParser.cmd), ecParser.cmd, len, ecParser.anAddrUnion.addr, cnt);
break;
case EC_CMD_TYPE_EXT:
@ -390,7 +390,7 @@ static void EcSubFormater(tvbuff_t *tvb, gint offset, char *szText, gint nMax)
}
static void EcLenFormater(guint16 len, char *szText, gint nMax)
{
{
g_snprintf( szText, nMax, "(0x%x) - %s - %s", len&0x07ff, len&0x4000 ? "Roundtrip" : "No Roundtrip", len&0x8000 ? "More Follows...":"Last Sub Command" );
}
@ -422,11 +422,11 @@ static void dissect_ecat_datagram(tvbuff_t *tvb, packet_info *pinfo, proto_tree
if ( (ecHdr.len&0x8000) == 0 )
break;
}
EcSummaryFormater(ecLength, tvb, offset, szText, nMax);
if (check_col(pinfo->cinfo, COL_INFO))
if (check_col(pinfo->cinfo, COL_INFO))
col_append_str(pinfo->cinfo, COL_INFO, szText);
if( tree )
{
ti = proto_tree_add_item(tree, proto_ecat_datagram, tvb, 0, -1, TRUE);
@ -453,14 +453,14 @@ static void dissect_ecat_datagram(tvbuff_t *tvb, packet_info *pinfo, proto_tree
len = ecHdr.len&0x7fff;
if ( len >= sizeof(ETHERCAT_MBOX_HEADER_LEN) &&
(ecHdr.cmd==EC_CMD_TYPE_FPWR || ecHdr.cmd==EC_CMD_TYPE_FPRD || ecHdr.cmd==EC_CMD_TYPE_APWR || ecHdr.cmd==EC_CMD_TYPE_APRD) &&
ecHdr.anAddrUnion.ado>=0x1000
(ecHdr.cmd==EC_CMD_TYPE_FPWR || ecHdr.cmd==EC_CMD_TYPE_FPRD || ecHdr.cmd==EC_CMD_TYPE_APWR || ecHdr.cmd==EC_CMD_TYPE_APRD) &&
ecHdr.anAddrUnion.ado>=0x1000
)
{
ETHERCAT_MBOX_HEADER mbox;
init_mbx_header(&mbox, tvb, suboffset+EcParserHDR_Len);
switch ( mbox.aControlUnion.Type )
switch ( mbox.aControlUnion.v.Type )
{
case ETHERCAT_MBOX_TYPE_EOE:
case ETHERCAT_MBOX_TYPE_ADS:
@ -735,8 +735,8 @@ static void dissect_ecat_datagram(tvbuff_t *tvb, packet_info *pinfo, proto_tree
if ( (ecHdr.len&0x8000) == 0 )
break;
offset+=subsize;
offset+=subsize;
subCount++;
}
}
@ -746,11 +746,11 @@ void proto_register_ecat(void)
{
static hf_register_info hf[] =
{
{ &hf_ecat_sub,
{ &hf_ecat_sub,
{ "Sub Frame", "ecat.sub", FT_BYTES, BASE_NONE, NULL, 0x0,
"", HFILL }
},
{ &hf_ecat_header,
{ &hf_ecat_header,
{ "Header", "ecat.header",
FT_BYTES, BASE_NONE, NULL, 0x0, "", HFILL }
},
@ -794,11 +794,11 @@ void proto_register_ecat(void)
{ "Data ", "ecat.sub10.data",
FT_BYTES, BASE_NONE, NULL, 0x0, "", HFILL }
},
{ &hf_ecat_data,
{ &hf_ecat_data,
{ "Data ", "ecat.data",
FT_BYTES, BASE_NONE, NULL, 0x0, "", HFILL }
},
{ &hf_ecat_cnt,
{ &hf_ecat_cnt,
{ "Working Cnt", "ecat.cnt",
FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }
},
@ -842,7 +842,7 @@ void proto_register_ecat(void)
{ "Working Cnt", "ecat.sub10.cnt",
FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }
},
{ &hf_ecat_cmd,
{ &hf_ecat_cmd,
{ "Command ", "ecat.cmd",
FT_UINT8, BASE_HEX, VALS(EcCmd), 0x0, "", HFILL }
},
@ -886,7 +886,7 @@ void proto_register_ecat(void)
{ "Command ", "ecat.sub10.cmd",
FT_UINT8, BASE_HEX, VALS(EcCmd), 0x0, "", HFILL }
},
{ &hf_ecat_idx,
{ &hf_ecat_idx,
{ "Index ", "ecat.idx",
FT_UINT8, BASE_HEX, NULL, 0x0,
"", HFILL }
@ -941,7 +941,7 @@ void proto_register_ecat(void)
FT_UINT8, BASE_HEX, NULL, 0x0,
"", HFILL }
},
{ &hf_ecat_adp,
{ &hf_ecat_adp,
{ "Slave Addr ", "ecat.adp",
FT_UINT16, BASE_HEX, NULL, 0x0,
"", HFILL }
@ -996,7 +996,7 @@ void proto_register_ecat(void)
FT_UINT16, BASE_HEX, NULL, 0x0,
"", HFILL }
},
{ &hf_ecat_ado,
{ &hf_ecat_ado,
{ "Offset Addr", "ecat.ado",
FT_UINT16, BASE_HEX, NULL, 0x0,
"", HFILL }
@ -1051,7 +1051,7 @@ void proto_register_ecat(void)
FT_UINT16, BASE_HEX, NULL, 0x0,
"", HFILL }
},
{ &hf_ecat_lad,
{ &hf_ecat_lad,
{ "Log Addr ", "ecat.lad",
FT_UINT32, BASE_HEX, NULL, 0x0,
"", HFILL }
@ -1126,7 +1126,7 @@ void proto_register_ecat(void)
FT_UINT16, BASE_HEX, NULL, 0x0,
"", HFILL }
},
{ &hf_ecat_syncman_len,
{ &hf_ecat_syncman_len,
{ "SM Length ", "ecat.syncman.len",
FT_UINT16, BASE_HEX, NULL, 0x0,
"", HFILL }
@ -1196,7 +1196,7 @@ void proto_register_ecat(void)
FT_BOOLEAN, 32, TFS(&tfs_ecat_syncman_flag16), 0x00010000,
"", HFILL }
},
{ &hf_ecat_fmmu,
{ &hf_ecat_fmmu,
{ "FMMU", "ecat.fmmu",
FT_BYTES, BASE_NONE, NULL, 0x0,
"", HFILL }
@ -1215,17 +1215,17 @@ void proto_register_ecat(void)
{ "Log StartBit ", "ecat.fmmu.lstartbit",
FT_UINT8, BASE_HEX, NULL, 0x0,
"", HFILL }
},
},
{ &hf_ecat_fmmu_lendbit,
{ "Log EndBit ", "ecat.fmmu.lendbit",
FT_UINT8, BASE_HEX, NULL, 0x0,
"", HFILL }
},
},
{ &hf_ecat_fmmu_pstart,
{ "Phys Start ", "ecat.fmmu.pstart",
FT_UINT8, BASE_HEX, NULL, 0x0,
"", HFILL }
},
},
{ &hf_ecat_fmmu_pstartbit,
{ "Phys StartBit", "ecat.fmmu.pstartbit",
FT_UINT8, BASE_HEX, NULL, 0x0,