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
this is based on the MACControl dissector used by Wireshark (https://github.com/wireshark/wireshark/blob/master/epan/dissectors/packet-maccontrol.c)
- class scapy.contrib.mac_control.MACControl(*args, **kargs)
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(*args, **kargs)
Bases:
scapy.contrib.mac_control.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
257
_reserved
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
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
- class scapy.contrib.mac_control.MACControlGate(*args, **kargs)
Bases:
scapy.contrib.mac_control.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
2
timestamp
0
- exception scapy.contrib.mac_control.MACControlInvalidSpeedException
Bases:
scapy.error.Scapy_Exception
- class scapy.contrib.mac_control.MACControlPause(*args, **kargs)
Bases:
scapy.contrib.mac_control.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
1
pause_time
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(*args, **kargs)
Bases:
scapy.contrib.mac_control.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
5
timestamp
0
flags
0
echoed_assigned_port
0
echoed_sync_time
0
- class scapy.contrib.mac_control.MACControlRegisterAck(*args, **kargs)
Bases:
scapy.contrib.mac_control.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
6
timestamp
0
flags
0
echoed_assigned_port
0
echoed_sync_time
0
- class scapy.contrib.mac_control.MACControlRegisterReq(*args, **kargs)
Bases:
scapy.contrib.mac_control.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
4
timestamp
0
assigned_port
0
flags
0
sync_time
0
echoed_pending_grants
0
- class scapy.contrib.mac_control.MACControlReport(*args, **kargs)
Bases:
scapy.contrib.mac_control.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
3
timestamp
0
flags
0
pending_grants
0