scapy.contrib.mac_control

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
guess_payload_class(payload)
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
fields_desc
MACControlClassBasedFlowControl fields

_op_code

ShortField

257

_reserved

ByteField

0

c7_enabled

BitField (1 bit)

0

c6_enabled

BitField (1 bit)

0

c5_enabled

BitField (1 bit)

0

c4_enabled

BitField (1 bit)

0

c3_enabled

BitField (1 bit)

0

c2_enabled

BitField (1 bit)

0

c1_enabled

BitField (1 bit)

0

c0_enabled

BitField (1 bit)

0

c0_pause_time

ShortField

0

c1_pause_time

ShortField

0

c2_pause_time

ShortField

0

c3_pause_time

ShortField

0

c4_pause_time

ShortField

0

c5_pause_time

ShortField

0

c6_pause_time

ShortField

0

c7_pause_time

ShortField

0

class scapy.contrib.mac_control.MACControlGate

Bases: scapy.contrib.mac_control.MACControl

aliastypes
fields_desc
MACControlGate fields

_op_code

ShortField

2

timestamp

IntField

0

exception scapy.contrib.mac_control.MACControlInvalidSpeedException

Bases: scapy.error.Scapy_Exception

class scapy.contrib.mac_control.MACControlPause

Bases: scapy.contrib.mac_control.MACControl

aliastypes
fields_desc
MACControlPause fields

_op_code

ShortField

1

pause_time

ShortField

0

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
fields_desc
MACControlRegister fields

_op_code

ShortField

5

timestamp

IntField

0

flags

ByteEnumField

0

echoed_assigned_port

ShortField

0

echoed_sync_time

ShortField

0

class scapy.contrib.mac_control.MACControlRegisterAck

Bases: scapy.contrib.mac_control.MACControl

aliastypes
fields_desc
MACControlRegisterAck fields

_op_code

ShortField

6

timestamp

IntField

0

flags

ByteEnumField

0

echoed_assigned_port

ShortField

0

echoed_sync_time

ShortField

0

class scapy.contrib.mac_control.MACControlRegisterReq

Bases: scapy.contrib.mac_control.MACControl

aliastypes
fields_desc
MACControlRegisterReq fields

_op_code

ShortField

4

timestamp

IntField

0

assigned_port

ShortField

0

flags

ByteEnumField

0

sync_time

ShortField

0

echoed_pending_grants

ByteField

0

class scapy.contrib.mac_control.MACControlReport

Bases: scapy.contrib.mac_control.MACControl

aliastypes
fields_desc
MACControlReport fields

_op_code

ShortField

3

timestamp

IntField

0

flags

ByteEnumField

0

pending_grants

ByteField

0