scapy.contrib.pnio_dcp module

class scapy.contrib.pnio_dcp.DCPAliasNameBlock

Bases: scapy.packet.Packet

aliastypes = [<class 'scapy.contrib.pnio_dcp.DCPAliasNameBlock'>, <class 'scapy.packet.Packet'>]
extract_padding(s)

DEV: to be overloaded to extract current layer’s padding.

Parameters:s (str) – the current layer
Returns:a couple of strings (actual layer, padding)
fields_desc = [<Field (DCPAliasNameBlock).option>, <Field (DCPAliasNameBlock).sub_option>, <Field (DCPAliasNameBlock).dcp_block_length>, <Field (DCPAliasNameBlock).block_info>, <Field (DCPAliasNameBlock).alias_name>, <scapy.fields.PadField object>]
class scapy.contrib.pnio_dcp.DCPBaseBlock

Bases: scapy.packet.Packet

base class for all DCP Blocks

aliastypes = [<class 'scapy.contrib.pnio_dcp.DCPBaseBlock'>, <class 'scapy.packet.Packet'>]
extract_padding(s)

DEV: to be overloaded to extract current layer’s padding.

Parameters:s (str) – the current layer
Returns:a couple of strings (actual layer, padding)
fields_desc = [<Field (DCPBaseBlock).option>, <Field (DCPBaseBlock).sub_option>, <Field (DCPBaseBlock).dcp_block_length>, <Field (DCPBaseBlock).block_info>, <Field (DCPBaseBlock).data>]
class scapy.contrib.pnio_dcp.DCPControlBlock

Bases: scapy.packet.Packet

aliastypes = [<class 'scapy.contrib.pnio_dcp.DCPControlBlock'>, <class 'scapy.packet.Packet'>]
extract_padding(s)

DEV: to be overloaded to extract current layer’s padding.

Parameters:s (str) – the current layer
Returns:a couple of strings (actual layer, padding)
fields_desc = [<Field (DCPControlBlock).option>, <Field (DCPControlBlock).sub_option>, <Field (DCPControlBlock).dcp_block_length>, <Field (DCPControlBlock).response>, <Field (DCPControlBlock).response_sub_option>, <Field (DCPControlBlock).block_error>, <scapy.fields.PadField object>]
class scapy.contrib.pnio_dcp.DCPDeviceIDBlock

Bases: scapy.packet.Packet

aliastypes = [<class 'scapy.contrib.pnio_dcp.DCPDeviceIDBlock'>, <class 'scapy.packet.Packet'>]
extract_padding(s)

DEV: to be overloaded to extract current layer’s padding.

Parameters:s (str) – the current layer
Returns:a couple of strings (actual layer, padding)
fields_desc = [<Field (DCPDeviceIDBlock).option>, <Field (DCPDeviceIDBlock).sub_option>, <Field (DCPDeviceIDBlock).dcp_block_length>, <Field (DCPDeviceIDBlock).block_info>, <Field (DCPDeviceIDBlock).vendor_id>, <Field (DCPDeviceIDBlock).device_id>, <scapy.fields.PadField object>]
class scapy.contrib.pnio_dcp.DCPDeviceInstanceBlock

Bases: scapy.packet.Packet

aliastypes = [<class 'scapy.contrib.pnio_dcp.DCPDeviceInstanceBlock'>, <class 'scapy.packet.Packet'>]
extract_padding(s)

DEV: to be overloaded to extract current layer’s padding.

Parameters:s (str) – the current layer
Returns:a couple of strings (actual layer, padding)
fields_desc = [<Field (DCPDeviceInstanceBlock).option>, <Field (DCPDeviceInstanceBlock).sub_option>, <Field (DCPDeviceInstanceBlock).dcp_block_length>, <Field (DCPDeviceInstanceBlock).block_info>, <Field (DCPDeviceInstanceBlock).device_instance_high>, <Field (DCPDeviceInstanceBlock).device_instance_low>, <scapy.fields.PadField object>]
class scapy.contrib.pnio_dcp.DCPDeviceOptionsBlock

Bases: scapy.packet.Packet

aliastypes = [<class 'scapy.contrib.pnio_dcp.DCPDeviceOptionsBlock'>, <class 'scapy.packet.Packet'>]
extract_padding(s)

DEV: to be overloaded to extract current layer’s padding.

Parameters:s (str) – the current layer
Returns:a couple of strings (actual layer, padding)
fields_desc = [<Field (DCPDeviceOptionsBlock).option>, <Field (DCPDeviceOptionsBlock).sub_option>, <Field (DCPDeviceOptionsBlock).dcp_block_length>, <Field (DCPDeviceOptionsBlock).block_info>, <Field (DCPDeviceOptionsBlock).device_options>, <scapy.fields.PadField object>]
class scapy.contrib.pnio_dcp.DCPDeviceRoleBlock

Bases: scapy.packet.Packet

aliastypes = [<class 'scapy.contrib.pnio_dcp.DCPDeviceRoleBlock'>, <class 'scapy.packet.Packet'>]
extract_padding(s)

DEV: to be overloaded to extract current layer’s padding.

Parameters:s (str) – the current layer
Returns:a couple of strings (actual layer, padding)
fields_desc = [<Field (DCPDeviceRoleBlock).option>, <Field (DCPDeviceRoleBlock).sub_option>, <Field (DCPDeviceRoleBlock).dcp_block_length>, <Field (DCPDeviceRoleBlock).block_info>, <Field (DCPDeviceRoleBlock).device_role_details>, <Field (DCPDeviceRoleBlock).reserved>, <scapy.fields.PadField object>]
class scapy.contrib.pnio_dcp.DCPIPBlock

Bases: scapy.packet.Packet

aliastypes = [<class 'scapy.contrib.pnio_dcp.DCPIPBlock'>, <class 'scapy.packet.Packet'>]
extract_padding(s)

DEV: to be overloaded to extract current layer’s padding.

Parameters:s (str) – the current layer
Returns:a couple of strings (actual layer, padding)
fields_desc = [<Field (DCPIPBlock).option>, <Field (DCPIPBlock).sub_option>, <Field (DCPIPBlock).dcp_block_length>, <Field (DCPIPBlock).block_info>, <Field (DCPIPBlock).ip>, <Field (DCPIPBlock).netmask>, <Field (DCPIPBlock).gateway>, <scapy.fields.PadField object>]
class scapy.contrib.pnio_dcp.DCPMACBlock

Bases: scapy.packet.Packet

aliastypes = [<class 'scapy.contrib.pnio_dcp.DCPMACBlock'>, <class 'scapy.packet.Packet'>]
extract_padding(s)

DEV: to be overloaded to extract current layer’s padding.

Parameters:s (str) – the current layer
Returns:a couple of strings (actual layer, padding)
fields_desc = [<Field (DCPMACBlock).option>, <Field (DCPMACBlock).sub_option>, <Field (DCPMACBlock).dcp_block_length>, <Field (DCPMACBlock).block_info>, <Field (DCPMACBlock).mac>, <scapy.fields.PadField object>]
class scapy.contrib.pnio_dcp.DCPManufacturerSpecificBlock

Bases: scapy.packet.Packet

aliastypes = [<class 'scapy.contrib.pnio_dcp.DCPManufacturerSpecificBlock'>, <class 'scapy.packet.Packet'>]
extract_padding(s)

DEV: to be overloaded to extract current layer’s padding.

Parameters:s (str) – the current layer
Returns:a couple of strings (actual layer, padding)
fields_desc = [<Field (DCPManufacturerSpecificBlock).option>, <Field (DCPManufacturerSpecificBlock).sub_option>, <Field (DCPManufacturerSpecificBlock).dcp_block_length>, <Field (DCPManufacturerSpecificBlock).block_info>, <Field (DCPManufacturerSpecificBlock).device_vendor_value>, <scapy.fields.PadField object>]
class scapy.contrib.pnio_dcp.DCPNameOfStationBlock

Bases: scapy.packet.Packet

aliastypes = [<class 'scapy.contrib.pnio_dcp.DCPNameOfStationBlock'>, <class 'scapy.packet.Packet'>]
extract_padding(s)

DEV: to be overloaded to extract current layer’s padding.

Parameters:s (str) – the current layer
Returns:a couple of strings (actual layer, padding)
fields_desc = [<Field (DCPNameOfStationBlock).option>, <Field (DCPNameOfStationBlock).sub_option>, <Field (DCPNameOfStationBlock).dcp_block_length>, <Field (DCPNameOfStationBlock).block_info>, <Field (DCPNameOfStationBlock).name_of_station>, <scapy.fields.PadField object>]
class scapy.contrib.pnio_dcp.DeviceOption

Bases: scapy.packet.Packet

aliastypes = [<class 'scapy.contrib.pnio_dcp.DeviceOption'>, <class 'scapy.packet.Packet'>]
extract_padding(s)

DEV: to be overloaded to extract current layer’s padding.

Parameters:s (str) – the current layer
Returns:a couple of strings (actual layer, padding)
fields_desc = [<Field (DeviceOption).option>, <Field (DeviceOption).sub_option>]
class scapy.contrib.pnio_dcp.ProfinetDCP

Bases: scapy.packet.Packet

Profinet DCP Packet

Requests are handled via ConditionalField because here only 1 Block is used every time.

Response can contain 1..n Blocks, for that you have to use one ProfinetDCP Layer with one or multiple DCP*Block Layers:

ProfinetDCP / DCPNameOfStationBlock / DCPDeviceIDBlock ...

Example for a DCP Identify All Request:

Ether(dst="01:0e:cf:00:00:00") /
ProfinetIO(frameID=DCP_IDENTIFY_REQUEST_FRAME_ID) /
ProfinetDCP(service_id=DCP_SERVICE_ID_IDENTIFY,
    service_type=DCP_REQUEST, option=255, sub_option=255,
    dcp_data_length=4)

Example for a DCP Identify Response:

Ether(dst=dst_mac) /
ProfinetIO(frameID=DCP_IDENTIFY_RESPONSE_FRAME_ID) /
ProfinetDCP(
    service_id=DCP_SERVICE_ID_IDENTIFY,
    service_type=DCP_RESPONSE) /
DCPNameOfStationBlock(name_of_station="device1")

Example for a DCP Set Request:

Ether(dst=mac) /
ProfinetIO(frameID=DCP_GET_SET_FRAME_ID) /
ProfinetDCP(service_id=DCP_SERVICE_ID_SET, service_type=DCP_REQUEST,
    option=2, sub_option=2, dcp_data_length=14, dcp_block_length=10,
    name_of_station=name, reserved=0)
aliastypes = [<class 'scapy.contrib.pnio_dcp.ProfinetDCP'>, <class 'scapy.packet.Packet'>]
fields_desc = [<Field (ProfinetDCP).service_id>, <Field (ProfinetDCP).service_type>, <Field (ProfinetDCP).xid>, <Field (ProfinetDCP).reserved>, <Field (ProfinetDCP).dcp_data_length>, <scapy.fields.ConditionalField object>, <scapy.fields.ConditionalField object>, <scapy.fields.ConditionalField object>, <scapy.fields.ConditionalField object>, <scapy.fields.ConditionalField object>, <scapy.fields.ConditionalField object>, <scapy.fields.ConditionalField object>, <scapy.fields.ConditionalField object>, <scapy.fields.ConditionalField object>, <scapy.fields.ConditionalField object>, <scapy.fields.ConditionalField object>, <scapy.fields.ConditionalField object>]
payload_guess = [({}, <class 'scapy.packet.Padding'>)]
post_build(pkt, pay)

DEV: called right after the current layer is build.

Parameters:
  • pkt (str) – the current packet (build by self_buil function)
  • pay (str) – the packet payload (build by do_build_payload function)
Returns:

a string of the packet with the payload

scapy.contrib.pnio_dcp.guess_dcp_block_class(packet, **kargs)

returns the correct dcp block class needed to dissect the current tag if nothing can be found -> dcp base block will be used

Parameters:packet – the current packet
Returns:dcp block class