
    h                         d Z ddlmZmZmZmZmZmZmZ ddl	m
Z
mZmZ ddlmZmZ dZ G d dee          Z G d d	ee          Z G d
 de          Z eeee            eeed           dS )a	  
scapy.contrib.ibeacon - Apple iBeacon Bluetooth LE proximity beacons.

Packet format documentation can be found at at:

* https://en.wikipedia.org/wiki/IBeacon#Packet_Structure_Byte_Map (public)
* https://developer.apple.com/ibeacon/ (official, requires license)

    )ByteEnumFieldConditionalFieldLenFieldPacketListField
ShortFieldSignedByteField	UUIDField)EIR_HdrEIR_Manufacturer_Specific_DataLowEnergyBeaconHelper)bind_layersPacketL   c                       e Zd ZdZdZ eddddddd	d
ddd           e eddd          d           gZd Z	d Z
d ZdS )Apple_BLE_Submessagez#
    A basic Apple submessage.
    zApple BLE submessagesubtypeNoverflowibeaconairdropairpodsairplay_sinkairplay_srchandoffnearby)            	   
         lenB)fmtc                     | j         dk    S )Nr   r   )pkts    Y/mounts/lovelace/software/anaconda3/lib/python3.11/site-packages/scapy/contrib/ibeacon.py<lambda>zApple_BLE_Submessage.<lambda>/   s    t+     c                 |    | j         dk    r|d d         |dd          fS |d | j                 || j        d          fS )Nr   r"   )r   r#   )selfss     r)   extract_paddingz$Apple_BLE_Submessage.extract_padding3   sH    <4SbS61RSS6>!$(|Qtxyy\))r+   c                 $    t          | g          S )z+Wraps this submessage in a Apple_BLE_Frame.)plist)Apple_BLE_Framer-   s    r)   build_framez Apple_BLE_Submessage.build_frame<   s    dV,,,,r+   c                 N    |                                                                  S )zSee Apple_BLE_Frame.build_eir.)r4   	build_eirr3   s    r)   r6   zApple_BLE_Submessage.build_eir@   s     !!++---r+   )__name__
__module____qualname____doc__namer   r   r   fields_descr/   r4   r6    r+   r)   r   r      s          "Di 	(
 	(
 		 		 	HUDc***++	
 	
K$* * *- - -. . . . .r+   r   c                   8    e Zd ZdZdZ edde          gZd ZdS )r2   z
    The wrapper for a BLE manufacturer-specific data advertisement from Apple
    devices.

    Each advertisement is composed of one or multiple submessages.

    The length of this field comes from the EIR_Hdr.
    zApple BLE broadcast framer1   Nc                 ^    t           j        t                      t                      z  | z  gz   S )z1Builds a list of EIR messages to wrap this frame.)r   base_eirr
   r   r3   s    r)   r6   zApple_BLE_Frame.build_eirS   s1     %-II68884?1
 
 	
r+   )	r7   r8   r9   r:   r;   r   r   r<   r6   r=   r+   r)   r2   r2   E   sM          'D';<<K
 
 
 
 
r+   r2   c                       e Zd ZdZdZ eddej                   edd           edd           edd          gZ	dS )	IBeacon_DatazS
    iBeacon broadcast data frame. Composed on top of an Apple_BLE_Submessage.
    ziBeacon datauuidN)uuid_fmtmajorminortx_power)
r7   r8   r9   r:   r;   r	   	FORMAT_BEr   r   r<   r=   r+   r)   rB   rB   [   sj          D	&$)<===
7D!!
7D!!
D))	KKKr+   rB   )
company_idr   r'   N)r:   scapy.fieldsr   r   r   r   r   r   r	   scapy.layers.bluetoothr
   r   r   scapy.packetr   r   	APPLE_MFGr   r2   rB   r=   r+   r)   <module>rN      s~   < < < < < < < < < < < < < < < < < <          , , , , , , , ,	'. '. '. '. '.6#8 '. '. '.T
 
 
 
 
f3 
 
 
,
 
 
 
 
6 
 
 
 *O " " " "  , : : : : : :r+   