Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/scapy/layers/ir.py: 94%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

17 statements  

1# SPDX-License-Identifier: GPL-2.0-only 

2# This file is part of Scapy 

3# See https://scapy.net/ for more information 

4# Copyright (C) Philippe Biondi <phil@secdev.org> 

5 

6""" 

7IrDA infrared data communication. 

8""" 

9 

10from scapy.packet import Packet, bind_layers 

11from scapy.fields import BitEnumField, ByteEnumField, StrField, XBitField, \ 

12 XByteField, XIntField, XShortField 

13from scapy.layers.l2 import CookedLinux 

14 

15 

16# IR 

17 

18class IrLAPHead(Packet): 

19 name = "IrDA Link Access Protocol Header" 

20 fields_desc = [XBitField("Address", 0x7f, 7), 

21 BitEnumField("Type", 1, 1, {"Response": 0, 

22 "Command": 1})] 

23 

24 

25class IrLAPCommand(Packet): 

26 name = "IrDA Link Access Protocol Command" 

27 fields_desc = [XByteField("Control", 0), 

28 XByteField("Format_identifier", 0), 

29 XIntField("Source_address", 0), 

30 XIntField("Destination_address", 0xffffffff), 

31 XByteField("Discovery_flags", 0x1), 

32 ByteEnumField("Slot_number", 255, {"final": 255}), 

33 XByteField("Version", 0)] 

34 

35 

36class IrLMP(Packet): 

37 name = "IrDA Link Management Protocol" 

38 fields_desc = [XShortField("Service_hints", 0), 

39 XByteField("Character_set", 0), 

40 StrField("Device_name", "")] 

41 

42 

43bind_layers(CookedLinux, IrLAPHead, proto=23) 

44bind_layers(IrLAPHead, IrLAPCommand, Type=1) 

45bind_layers(IrLAPCommand, IrLMP,)