scapy.contrib.mac_control

MACControl

author:

Thomas Tannhaeuser, hecke@naberius.de

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(_pkt, /)[源代码]

基类: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(_pkt, /, *, _op_code=257, _reserved=0, c7_enabled=0, c6_enabled=0, c5_enabled=0, c4_enabled=0, c3_enabled=0, c2_enabled=0, c1_enabled=0, c0_enabled=0, c0_pause_time=0, c1_pause_time=0, c2_pause_time=0, c3_pause_time=0, c4_pause_time=0, c5_pause_time=0, c6_pause_time=0, c7_pause_time=0)[源代码]

基类:MACControl

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             OP CODE           |    RESERVED   |C|C|C|C|C|C|C|C|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         C0 PAUSE TIME         |         C1 PAUSE TIME         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         C2 PAUSE TIME         |         C3 PAUSE TIME         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         C4 PAUSE TIME         |         C5 PAUSE TIME         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         C6 PAUSE TIME         |         C7 PAUSE TIME         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

               Fig. MACControlClassBasedFlowControl               
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(_pkt, /, *, _op_code=2, timestamp=0)[源代码]

基类:MACControl

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             OP CODE           |           TIMESTAMP           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                       Fig. MACControlGate                        
MACControlGate fields

_op_code

ShortField

2

timestamp

IntField

0

exception scapy.contrib.mac_control.MACControlInvalidSpeedException[源代码]

基类:Scapy_Exception

class scapy.contrib.mac_control.MACControlPause(_pkt, /, *, _op_code=1, pause_time=0)[源代码]

基类:MACControl

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             OP CODE           |           PAUSE TIME          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                       Fig. MACControlPause                       
MACControlPause fields

_op_code

ShortField

1

pause_time

ShortField

0

get_pause_time(speed=4)[源代码]

get pause time for given link speed in seconds

参数:

speed -- select link speed to get the pause time for, must be ETHER_SPEED_MBIT_[10,100,1000] # noqa: E501

返回:

pause time in seconds

抛出:

MACControlInvalidSpeedException -- on invalid speed selector

class scapy.contrib.mac_control.MACControlRegister(_pkt, /, *, _op_code=5, timestamp=0, flags=0, echoed_assigned_port=0, echoed_sync_time=0)[源代码]

基类:MACControl

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             OP CODE           |           TIMESTAMP           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |     FLAGS     |ECHOED ASSIGNED|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |        ECHOED SYNC TIME       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                     Fig. MACControlRegister                      
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(_pkt, /, *, _op_code=6, timestamp=0, flags=0, echoed_assigned_port=0, echoed_sync_time=0)[源代码]

基类:MACControl

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             OP CODE           |           TIMESTAMP           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |     FLAGS     |ECHOED ASSIGNED|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |        ECHOED SYNC TIME       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                    Fig. MACControlRegisterAck                    
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(_pkt, /, *, _op_code=4, timestamp=0, assigned_port=0, flags=0, sync_time=0, echoed_pending_grants=0)[源代码]

基类:MACControl

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             OP CODE           |           TIMESTAMP           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |         ASSIGNED PORT         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     FLAGS     |           SYNC TIME           |ECHOED PENDING |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                    Fig. MACControlRegisterReq                    
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(_pkt, /, *, _op_code=3, timestamp=0, flags=0, pending_grants=0)[源代码]

基类:MACControl

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             OP CODE           |           TIMESTAMP           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |     FLAGS     | PENDING GRANTS|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                      Fig. MACControlReport                       
MACControlReport fields

_op_code

ShortField

3

timestamp

IntField

0

flags

ByteEnumField

0

pending_grants

ByteField

0