scapy.contrib.mac_control module

MACControl

author:

Thomas Tannhaeuser, hecke@naberius.de

license:

GPLv2

This module 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 module 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.

description:
This module provides Scapy layers for the MACControl protocol messages:
  • Pause
  • Gate
  • Report
  • Register/REQ/ACK
  • Class Based Flow Control
normative references:
  • IEEE 802.3x
NOTES:
class scapy.contrib.mac_control.MACControl

Bases: scapy.packet.Packet

DEFAULT_DST_MAC = '01:80:c2:00:00:01'
FLAG_ACK = 3
FLAG_DEREGISTER = 2
FLAG_NACK = 4
FLAG_REGISTER = 1
OP_CODES = {1: 'pause', 2: 'gate', 3: 'report', 4: 'register req', 5: 'register', 6: 'register_ack', 257: 'class based flow control'}

flags used by Register* messages

OP_CODE_CLASS_BASED_FLOW_CONTROL = 257
OP_CODE_GATE = 2
OP_CODE_PAUSE = 1
OP_CODE_REGISTER = 5
OP_CODE_REGISTER_ACK = 6
OP_CODE_REGISTER_REQ = 4
OP_CODE_REPORT = 3
REGISTER_FLAGS = {1: 'register', 2: 'deregister', 3: 'ack', 4: 'nack'}
aliastypes = [<class 'scapy.contrib.mac_control.MACControl'>, <class 'scapy.packet.Packet'>]
guess_payload_class(payload)

DEV: Guesses the next payload class from layer bonds. Can be overloaded to use a different mechanism.

Parameters:payload (str) – the layer’s payload
Returns:the payload class
post_build(pkt, pay)

add padding to the frame if required.

note that padding is only added if pay is None/empty. this allows us to add # noqa: E501 any payload after the MACControl* PDU if needed (piggybacking).

class scapy.contrib.mac_control.MACControlClassBasedFlowControl

Bases: scapy.contrib.mac_control.MACControl

aliastypes = [<class 'scapy.contrib.mac_control.MACControlClassBasedFlowControl'>, <class 'scapy.contrib.mac_control.MACControl'>, <class 'scapy.packet.Packet'>]
fields_desc = [<Field (MACControlClassBasedFlowControl)._op_code>, <Field (MACControlClassBasedFlowControl)._reserved>, <Field (MACControlClassBasedFlowControl).c7_enabled>, <Field (MACControlClassBasedFlowControl).c6_enabled>, <Field (MACControlClassBasedFlowControl).c5_enabled>, <Field (MACControlClassBasedFlowControl).c4_enabled>, <Field (MACControlClassBasedFlowControl).c3_enabled>, <Field (MACControlClassBasedFlowControl).c2_enabled>, <Field (MACControlClassBasedFlowControl).c1_enabled>, <Field (MACControlClassBasedFlowControl).c0_enabled>, <Field (MACControlClassBasedFlowControl).c0_pause_time>, <Field (MACControlClassBasedFlowControl).c1_pause_time>, <Field (MACControlClassBasedFlowControl).c2_pause_time>, <Field (MACControlClassBasedFlowControl).c3_pause_time>, <Field (MACControlClassBasedFlowControl).c4_pause_time>, <Field (MACControlClassBasedFlowControl).c5_pause_time>, <Field (MACControlClassBasedFlowControl).c6_pause_time>, <Field (MACControlClassBasedFlowControl).c7_pause_time>]
class scapy.contrib.mac_control.MACControlGate

Bases: scapy.contrib.mac_control.MACControl

aliastypes = [<class 'scapy.contrib.mac_control.MACControlGate'>, <class 'scapy.contrib.mac_control.MACControl'>, <class 'scapy.packet.Packet'>]
fields_desc = [<Field (MACControlGate)._op_code>, <Field (MACControlGate).timestamp>]
exception scapy.contrib.mac_control.MACControlInvalidSpeedException

Bases: scapy.error.Scapy_Exception

class scapy.contrib.mac_control.MACControlPause

Bases: scapy.contrib.mac_control.MACControl

aliastypes = [<class 'scapy.contrib.mac_control.MACControlPause'>, <class 'scapy.contrib.mac_control.MACControl'>, <class 'scapy.packet.Packet'>]
fields_desc = [<Field (MACControlPause)._op_code>, <Field (MACControlPause).pause_time>]
get_pause_time(speed=4)

get pause time for given link speed in seconds

Parameters:speed – select link speed to get the pause time for, must be ETHER_SPEED_MBIT_[10,100,1000] # noqa: E501
Returns:pause time in seconds
Raises:MACControlInvalidSpeedException – on invalid speed selector
class scapy.contrib.mac_control.MACControlRegister

Bases: scapy.contrib.mac_control.MACControl

aliastypes = [<class 'scapy.contrib.mac_control.MACControlRegister'>, <class 'scapy.contrib.mac_control.MACControl'>, <class 'scapy.packet.Packet'>]
fields_desc = [<Field (MACControlRegister)._op_code>, <Field (MACControlRegister).timestamp>, <Field (MACControlRegister).flags>, <Field (MACControlRegister).echoed_assigned_port>, <Field (MACControlRegister).echoed_sync_time>]
class scapy.contrib.mac_control.MACControlRegisterAck

Bases: scapy.contrib.mac_control.MACControl

aliastypes = [<class 'scapy.contrib.mac_control.MACControlRegisterAck'>, <class 'scapy.contrib.mac_control.MACControl'>, <class 'scapy.packet.Packet'>]
fields_desc = [<Field (MACControlRegisterAck)._op_code>, <Field (MACControlRegisterAck).timestamp>, <Field (MACControlRegisterAck).flags>, <Field (MACControlRegisterAck).echoed_assigned_port>, <Field (MACControlRegisterAck).echoed_sync_time>]
class scapy.contrib.mac_control.MACControlRegisterReq

Bases: scapy.contrib.mac_control.MACControl

aliastypes = [<class 'scapy.contrib.mac_control.MACControlRegisterReq'>, <class 'scapy.contrib.mac_control.MACControl'>, <class 'scapy.packet.Packet'>]
fields_desc = [<Field (MACControlRegisterReq)._op_code>, <Field (MACControlRegisterReq).timestamp>, <Field (MACControlRegisterReq).assigned_port>, <Field (MACControlRegisterReq).flags>, <Field (MACControlRegisterReq).sync_time>, <Field (MACControlRegisterReq).echoed_pending_grants>]
class scapy.contrib.mac_control.MACControlReport

Bases: scapy.contrib.mac_control.MACControl

aliastypes = [<class 'scapy.contrib.mac_control.MACControlReport'>, <class 'scapy.contrib.mac_control.MACControl'>, <class 'scapy.packet.Packet'>]
fields_desc = [<Field (MACControlReport)._op_code>, <Field (MACControlReport).timestamp>, <Field (MACControlReport).flags>, <Field (MACControlReport).pending_grants>]