
    hz             	       5   d Z ddlZddlZddlZddlZddlZddlmZ ddlmZ ddl	m
Z
mZmZ ddlmZmZ ddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ ddl0m1Z1 dd	l2m3Z3 dd
l	m4Z4 ddl5m6Z6 ddl7m8Z8 dZ9dZ:dZ;dZ<dZ=dZ> G d de          Z?dddddddddZ@i dddddddd dd!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9i d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[i d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzdod{d|i d}dod~ddddddddddddddddddddddddddddddddddZAi ddddddddd"dd$dd&dd(dd*dd,dd.dd0dd2dd4dd6dd8dd:dZBg dZC G d de          ZD G d de          ZE G d de          ZF G d de          ZG G d de          ZH G d de          ZI G d de          ZJ G d de          ZK G dÄ de          ZL G dń de          ZM G dǄ de          ZN G dɄ de          ZO G d˄ de          ZP G d̈́ de          ZQ G dτ de          ZR G dф de          ZS G dӄ de          ZT G dՄ de          ZU G dׄ de          ZV G dل de          ZW G dۄ de          ZX G d݄ de          ZY G d߄ de          ZZ G d de          Z[ G d de          Z\ G d de          Z] G d de          Z^ G d de          Z_ G d de          Z` G d de          Za G d de          Zb G d de          Zc G d de          Zd G d de          Ze G d de          Zf G d de          Zg G d de          Zh G d de          Zi G d d e          Zj G d de          Zk G d de          Zl G d de          Zm G d de          Zn G d	 d
e          Zo G d de          Zp G d de          Zq G d de          Zr G d de          Zs G d de          Zt G d de          Zu G d de          Zv G d de          Zw G d de          Zx G d de          Zy G d d ey          Zz G d! d"e          Z{ G d# d$e          Z| G d% d&e          Z} G d' d(e          Z~ G d) d*e          Z G d+ d,e          Z G d- d.e          Z G d/ d0e          Z G d1 d2e          Z G d3 d4e          Z G d5 d6e          Z G d7 d8e          Z G d9 d:e          Z G d; d<e          Z G d= d>e          Z G d? d@e          Z G dA dBe          Z G dC dDe          Z G dE dFe          Z G dG dHe          Z G dI dJe          Z G dK dLe          Z G dM dNe          Z G dO dPe          Z G dQ dRe          Z G dS dTe          Z G dU dVe          Z G dW dXe          Z G dY dZe          Z G d[ d\e          Z G d] d^e          Z G d_ d`e          Z G da dbe          Z G dc dde          Z G de dfe          Z G dg dhe          Z G di dje          Z G dk dle          Z G dm dne          Z G do dpe          Z G dq dre          Z G ds dte          Z G du dve          Z G dw dxe          Z G dy dze          Z G d{ d|e          Z G d} d~e          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G dÄ de          Z G dń de          Z G dǄ de          Z G dɄ de          Z G d˄ de          Z G d̈́ de          Z G dτ de          Z G dф de          Z G dӄ de          Z G dՄ de          Z G dׄ de          Z G dل de          Z G dۄ de          Z G d݄ de          Z G d߄ de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d d e          Z G d de          Z G d de          Z G d de          Z G d de          Z G d	 d
e          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d d e          Z G d! d"e          Z G d# d$e          Z G d% d&e          Z G d' d(e          Z G d) d*e          Z G d+ d,e          Z  G d- d.e          Z G d/ d0e          Z G d1 d2e          Z G d3 d4e          Z G d5 d6e          Z ee?eD            eeDed7            eeDeEd7            eeDed7            eeDej                   ej                            e
eD           ej                            ee?            eeedd8            eeedd8            eeedd8            eeedd8            eeedd"8            eeedd$8            eeedd(8            eeedd*8            eeedd,8            eeedd.8            eeedd08            eeedd28            eeedd68            eeedd:8            eeedd>8            eeeddF8            eeeddJ8            eeeddL8            eeeddN8            eeeddP8            eeeddn8            eeeddp8            eeeddr8            eeeddt8            eeeddv8            eeeddx8            eeedd}8            eeedd8            eeedd8            eeedd8            eeedd"8            eeedd>8            eeedd@8            eeeddD8            eeedd98            eeedd:8            eeedd;8            eeedd8            eeedd8            eeedd*8            eeed"d8            eeed"d"8            eeed$d8            eeed$d8            eeed(d8            eeed(d<8            eeed(d8            eeed(d"8            eeed(d$8            eeed(d(8            eeed(d*8            eeed(d,8            eeed(d.8            eeed(d08            eeed(d28            eeed(d48            eeed(d68            eeed(d88            eeed(d:8            eeed(d<8            eeed(d>8            eeed(dD8            eeed(dJ8            eeed(dL8            eeed(dN8            eeed=            eeed=            eeed=            eeed"=            eeed&=            eeed(=            eeed.=            eeed0=            eeed4=            eeed6=            eeed>=            eeedF=            eeed\=            eeed^=            eeedv=            eeed{=            eeed=            eeed>?            eeed@?            eeedA?            eeedB?            eee dC?            eeedD            eeedD            eeedD            eeed"D            eeed7            eeed7            eeed7            eeed7            eeed"7            eeed$7            eeed&7            eeed(7            eeed*7            eeed87            eeed,7            eeed27            eeed47            eeed67            eeed:7            eeed<7            eeedD7            eeedX7            eeedZ7            eeedE7            eee            eeEeF            eeFeGdF            eeFeGd"F            eeGeJd=            eeGeHd=            eeGeId=            eeGeKd=            eeGeLd"=            eeGeMd$=            eeGeNd&=            eeGeOd(=            eeGePd*=            eeGeQd,=            eeGeRd.=            eeGeSd0=            eeGeTd2=            eeGeUd4=            eeGeVd6=            eeGeWd8=            eeGeXd:=            eeGeYd<=            eeGeZd>=            eeGe[d@=            eeGe\dB=            eeGe]dD=            eeGe^dF=            eeGe_dH=            eeGe`dJ=            eeGeadL=            eeFebdF            eebeed?            eebefd?            eebegd?            eebehd?            eebeid"?            eebejd$?            eebekd&?            eebeld(?            eebemd(?            eebeod*?            eebepd,?            eebeqd.?            eebe~d0?            eebed2?            eeberd4?            eebesd6?            eebetd8?            eebeud:?            eebevd<?            eebexd>?            eebeydD?            eebezdF?            eebe|dH?            eebe}dJ?            eebewd9?            eebe{dN?            eebedR?            eeFed$F            eeedG            eeedG            eeedG            eeedG            eeed"G            eeed$G            eeed&G            eeed(G            eeed*G            eeed,G            eeed0G            eeed2G            G dH dIe          Z	 G dJ dKe	          Z
 G dL dMe          Z G dN dOe          Z G dP dQe          Z ee	ed?            ee	ed?            ee	ed?            ee	ed,?            ee	ed0?           ej                            ee
            G dR dS          Z G dT dUe          Z G dV dWe          Z G dX dYe1          Z G dZ d[e          Z G d\ d]e1          Z G d^ d_ej                  Z G d` dae1          Z G db dce          Z G dd dee          Zee_        ej        j        didg            Zej        j        dh             ZdS (j  z7
Bluetooth layers, sockets and send/receive functions.
    N)sizeof)conf)DLT_BLUETOOTH_HCI_H4DLT_BLUETOOTH_HCI_H4_WITH_PHDRDLT_BLUETOOTH_LINUX_MONITOR)bind_layersPacket)BitField	XBitFieldByteEnumField	ByteFieldFieldLenFieldFieldListField
FlagsFieldIntFieldLEShortEnumFieldLEShortField
LEIntFieldLenFieldMultipleTypeFieldNBytesFieldPacketListFieldPadField
ShortFieldSignedByteFieldStrFieldStrFixedLenFieldStrLenFieldStrNullField	UUIDField
XByteFieldXLE3BytesFieldXLELongFieldXStrLenFieldXLEShortFieldXLEIntField
LEMACFieldBitEnumField)SuperSocket)sndrcv)MTU)WINDOWS)warning              c                   ,    e Zd ZdZ edd          gZdS )HCI_PHDR_HdrzHCI PHDR transport layer	directionr   N)__name__
__module____qualname__namer   fields_desc     Z/mounts/lovelace/software/anaconda3/lib/python3.11/site-packages/scapy/layers/bluetooth.pyr4   r4   Y   s'        %D8K++,KKKr<   r4   AcknowledgementCommandzACL DataSynchronousEventReserveVendorzLink Control)r   r.   r/   r0   r1            SuccesszUnknown HCI CommandzUnknown Connection IdentifierzHardware FailurezPage TimeoutrD   zAuthentication Failure   zPIN or Key Missing   zMemory Capacity Exceeded   zConnection Timeout	   zConnection Limit Exceeded
   z1Synchronous Connection Limit To A Device Exceeded   zConnection Already Exists   zCommand Disallowed   z,Connection Rejected due to Limited ResourcesrE   z+Connection Rejected Due To Security ReasonsrF   z/Connection Rejected due to Unacceptable BD_ADDR   z"Connection Accept Timeout Exceeded   z&Unsupported Feature or Parameter Value   zInvalid HCI Command Parameters   z!Remote User Terminated Connection   z8Remote Device Terminated Connection due to Low Resources   z4Remote Device Terminated Connection due to Power Off   z#Connection Terminated By Local Host   zRepeated Attempts   zPairing Not Allowed   zUnknown LMP PDU   z4Unsupported Remote Feature / Unsupported LMP Feature   zSCO Offset Rejected   zSCO Interval Rejected   zSCO Air Mode Rejected   z.Invalid LMP Parameters / Invalid LL Parameters   zUnspecified Error    z@Unsupported LMP Parameter Value / Unsupported LL Parameter Value!   zRole Change Not Allowed"   z*LMP Response Timeout / LL Response Timeout#   z8LMP Error Transaction Collision / LL Procedure Collision$   zLMP PDU Not Allowed%   zEncryption Mode Not Acceptable&   zLink Key cannot be Changed'   zRequested QoS Not Supported(   zInstant Passed)   z#Pairing With Unit Key Not Supported*   zDifferent Transaction Collision+   zReserved for future use,   zQoS Unacceptable Parameter-   zQoS Rejected.   z$Channel Classification Not Supported/   zInsufficient Security0   z Parameter Out Of Mandatory Range1   2   zRole Switch Pending3   4   zReserved Slot Violation5   zRole Switch Failed6   z#Extended Inquiry Response Too Large7   z+Secure Simple Pairing Not Supported By Host8   zHost Busy - Pairing9   z4Connection Rejected due to No Suitable Channel Found:   zController Busy;   z"Unacceptable Connection Parameters<   zAdvertising Timeout=   z(Connection Terminated due to MIC Failure>   z=Connection Failed to be Established / Synchronization Timeout?   zMAC Connection Failed@   zLCoarse Clock Adjustment Rejected but Will Try to Adjust Using Clock DraggingA   zType0 Submap Not DefinedB   zUnknown Advertising IdentifierC   zLimit ReachedzOperation Cancelled by HostzPacket Too Long)D   E   zinvalid handlezread not permittedzwrite not permittedzinvalid pduzinsufficient authzunsupported reqzinvalid offsetzinsufficient authorzprepare queue fullzattr not foundzattr not longzinsufficient key sizezinvalid value sizeunlikelyzinsufficiet encryptzunsupported gpr typezinsufficient resources)@3_slot_packets5_slot_packets
encryptionslot_offsettiming_accuracyrole_switch	hold_mode
sniff_mode	park_modepower_control_requests channel_quality_driven_data_ratesco_linkhv2_packetshv3_packetsu_law_log_synchronous_dataa_law_log_synchronous_datacvsd_synchronous_datapaging_parameter_negotiationpower_controltransparent_synchronous_dataflow_control_lag_4_bit0flow_control_lag_4_bit1flow_control_lag_4_bit2broadband_encryptionr   edr_acl_2_mbps_modeedr_acl_3_mbps_modeenhanced_inquiry_scaninterlaced_inquiry_scaninterlaced_page_scanrssi_with_inquiry_resultsev3_packetsev4_packetsev5_packetsreservedafh_capable_slaveafh_classification_slavebr_edr_not_supportedle_supported_controller3_slot_edr_acl_packets5_slot_edr_acl_packetssniff_subratingpause_encryptionafh_capable_masterafh_classification_masteredr_esco_2_mbps_modeedr_esco_3_mbps_mode3_slot_edr_esco_packetsextended_inquiry_response<simultaneous_le_and_br_edr_to_same_device_capable_controller	reserved2secure_simple_pairingencapsulated_pduerroneous_data_reporting"non_flushable_packet_boundary_flag	reserved3&link_supervision_timeout_changed_eventinquiry_tx_power_levelenhanced_power_controlreserved4_bit0reserved4_bit1reserved4_bit2reserved4_bit3extended_featuresc                   4    e Zd ZdZ edde          gZd ZdS )HCI_Hdrz
HCI headertyper/   c                 ,    |                      d          S )Nz
HCI %type%sprintfselfs    r=   	mysummaryzHCI_Hdr.mysummary      ||L)))r<   N)r6   r7   r8   r9   r   _bluetooth_packet_typesr:   r   r;   r<   r=   r   r     s?        D =,CDDEK* * * * *r<   r   c                       e Zd ZdZ edddd           eddd           eddd	d
           edd          gZd ZdS )HCI_ACL_HdrzHCI ACL headerBCr   r/   tot_sizePBhandlerN   end_tot_sizelenNc                     ||z  }| j         8|d d         t          j        dt          |                    z   |dd          z   }|S Nr/   <Hr1   r   structpackr   ppays      r=   
post_buildzHCI_ACL_Hdr.post_build  I    	S8"1"D#c((333ae;Ar<   )r6   r7   r8   r9   r
   r   r:   r   r;   r<   r=   r   r     s{        D8D!Q4448D!Q''8Ha"===<t,,0K
    r<   r   c                   P    e Zd ZdZ edd           eddddd          gZd	 ZdS )
	L2CAP_HdrzL2CAP headerr   Ncidr   control	attribute)r.   r1   c                 x    ||z  }| j         -t          j        dt          |                    |dd          z   }|S )Nr   r/   r   r   s      r=   r   zL2CAP_Hdr.post_build(  s<    	S8D#c((++ae3Ar<   )r6   r7   r8   r9   r   r   r:   r   r;   r<   r=   r   r   #  sY        D<t,,##E1).L.LMMQK    r<   r   c                       e Zd ZdZ eddi dddddd	d
ddddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.	           ed/d0           ed1d2          gZd3 Zd4 Z	d2S )5L2CAP_CmdHdrzL2CAP command headercoderJ   r.   rejr/   conn_reqr0   	conn_respr1   conf_reqrD   	conf_resprH   disconn_reqrI   disconn_respecho_reqrK   	echo_resprL   info_reqrM   	info_resprN   create_channel_reqrO   create_channel_resprE   move_channel_reqrF   move_channel_resprP   move_channel_confirm_reqrQ   move_channel_confirm_respconn_param_update_reqconn_param_update_respLE_credit_based_conn_reqLE_credit_based_conn_respflow_control_credit_indcredit_based_conn_reqcredit_based_conn_respcredit_based_reconf_reqcredit_based_reconf_resp)	rR   rS   rT   rU   rV   rW   rX   rY   rZ   idr   r   Nc                     ||z  }| j         8|d d         t          j        dt          |                    z   |dd          z   }|S r   r   r   s      r=   r   zL2CAP_CmdHdr.post_buildO  r   r<   c                     |j         | j         k    rU| j        dk    rdS |j        dv r?| j        |j        dz   k    r,|j        dk    rdS | j                            |j                  S dS )Nr.   )r/   r1   rH   rJ   rL   rR   rJ   r   )r
  r   payloadanswersr   others     r=   r  zL2CAP_CmdHdr.answersU  so    8twyA~~qz111di5:PQ>6Q6Q:??1|++EM:::qr<   )
r6   r7   r8   r9   r   r   r   r:   r   r  r;   r<   r=   r   r   /  s       !Dfa "B!U "B"#Z"B"#["B #$Z"B #$[	"B
 #$]"B #$^"B #$Z"B #$["B #%j"B #%k"B #%&:"B #%&;"B #%&8"B #%&9"B #%&@"B  #%&A!"B" '>&>&@&A&?&=&>&?&@3"B "B "B 	C 	C4 		$UD!!9#K<      r<   r   c                       e Zd ZdZ eddi dddddd	d
dddddddddddddddddddddd d!d"d#           ed$d          gZd%S )&L2CAP_ConnReqzL2CAP Conn Reqpsmr   r.   SDPr0   RFCOMMrD   TCS-BINrI   TCS-BIN-CORDLESSrF   BNEPrQ   HID-ControlrS   HID-InterruptrU   UPnPrW   AVCTP-ControlrY   AVDTPr[   AVCTP-Browsingr]   UDI_C-Planer_   ATTra   3DSPrc   IPSPre   OTSscidNr6   r7   r8   r9   r   r   r:   r;   r<   r=   r  r  `  s        D##E1 /:q% /:/0(/:/0)/: 012D/: 026	/:
 02=/: 02?/: 026/: 02?/: 027/: 023C/: 02=/: 025/: 026/: 026/: 025/: ; ;   <**!KKKr<   r  c            	           e Zd ZdZ edd           edd           eddg d           eddg d          gZd	 Zd
S )L2CAP_ConnRespzL2CAP Conn Respdcidr   r$  result)successpend
cr_bad_psmcr_sec_block	cr_no_memr   cr_inval_scidcr_scid_in_usestatus)no_infoauthen_pendauthor_pendr   c                 L    t          |t                    o| j        |j        k    S N)
isinstancer  r$  r  s     r=   r  zL2CAP_ConnResp.answers~  s     %//KDI4KKr<   Nr6   r7   r8   r9   r   r   r:   r  r;   r<   r=   r'  r'  v  s        D<**<**##Ha  2_  2_  2_  `  `##Ha1f1f1fggKL L L L Lr<   r'  c                   ,    e Zd ZdZ edd          gZdS )L2CAP_CmdRejzL2CAP Command Rejreasonr   Nr6   r7   r8   r9   r   r:   r;   r<   r=   r:  r:    s)        D<!,, KKKr<   r:  c                   B    e Zd ZdZ edd           edd          gZdS )L2CAP_ConfReqzL2CAP Conf Reqr(  r   flagsNr<  r;   r<   r=   r>  r>    s8        D<**<++KKKr<   r>  c                   d    e Zd ZdZ edd           edd           eddg d          gZd ZdS )	L2CAP_ConfRespzL2CAP Conf Respr$  r   r?  r)  )r*  unacceptrejectunknownc                 ,    t          |t                    S r6  )r7  r>  r  s     r=   r  zL2CAP_ConfResp.answers  s    %///r<   Nr8  r;   r<   r=   rA  rA    sf        D<**<++##Ha1]1]1]^^K
0 0 0 0 0r<   rA  c                   B    e Zd ZdZ edd           edd          gZdS )L2CAP_DisconnReqzL2CAP Disconn Reqr(  r   r$  Nr<  r;   r<   r=   rG  rG    s8        D<**<**.KKKr<   rG  c                   H    e Zd ZdZ edd           edd          gZd ZdS )L2CAP_DisconnRespzL2CAP Disconn Respr(  r   r$  c                 "    | j         |j         k    S r6  )r$  r  s     r=   r  zL2CAP_DisconnResp.answers      yEJ&&r<   N)r6   r7   r8   r9   r   r:   r  r;   r<   r=   rI  rI    sM        D<**<**.K' ' ' ' 'r<   rI  c                   ,    e Zd ZdZ edd          gZdS )L2CAP_EchoReqzL2CAP Echo Reqdata Nr6   r7   r8   r9   r   r:   r;   r<   r=   rM  rM    s'        D8FB''*KKKr<   rM  c                   ,    e Zd ZdZ edd          gZdS )L2CAP_EchoRespzL2CAP Echo ResprN  rO  NrP  r;   r<   r=   rR  rR    s'        D8FB''*KKKr<   rR  c                   J    e Zd ZdZ eddddd           edd          gZd	S )
L2CAP_InfoReqzL2CAP Info Reqr   r   CL_MTU	FEAT_MASK)r.   r/   rN  rO  N)r6   r7   r8   r9   r   r   r:   r;   r<   r=   rT  rT    sC        D##FA8/L/LMM8FB''KKKr<   rT  c                   d    e Zd ZdZ edd           eddddg           edd          gZd	 Zd
S )L2CAP_InfoRespzL2CAP Info Respr   r   r)  r*  not_supprN  rO  c                 "    | j         |j         k    S r6  r   r  s     r=   r  zL2CAP_InfoResp.answers  rK  r<   N)	r6   r7   r8   r9   r   r   r   r:   r  r;   r<   r=   rX  rX    sd        D<**##Ha)Z1HII8FB''+K' ' ' ' 'r<   rX  c                       e Zd ZdZ eddi dddddd	d
dddddddddddddddddddddd d!d"d#           ed$d           ed%d          gZd&S )'L2CAP_Create_Channel_RequestzL2CAP Create Channel Requestr  r   r.   r  r0   r  rD   r  rI   r  rF   r  rQ   r  rS   r  rU   r  rW   r  rY   r  r[   r  r]   r  r_   r   ra   r!  rc   r"  re   r#  r$  controller_idN)r6   r7   r8   r9   r   r   r   r:   r;   r<   r=   r]  r]    s       )D##E1 /:q% /:/0(/:/0)/: 012D/: 026	/:
 02=/: 02?/: 026/: 02?/: 027/: 023C/: 02=/: 025/: 026/: 026/: 025/: ; ;   <**9_a00#4KKKr<   r]  c                       e Zd ZdZ edd           edd           edddddd	d
dddd           edddddd          gZdS )L2CAP_Create_Channel_ResponsezL2CAP Create Channel Responser(  r   r$  r)  Connection successfulzConnection pendingz&Connection refused - PSM not supportedz#Connection refused - security block+Connection refused - no resources availablez*Connection refused - cont_ID not supported!Connection refused - invalid scid+Connection refused - scid already allocated)r   r.   r/   r0   r1   rD   rH   rI   r1  z No further information availablezAuthentication pendingzAuthorization pendingr   r.   r/   Nr6   r7   r8   r9   r   r   r:   r;   r<   r=   r`  r`    s        *D<**<**##Ha1.B?GF=G2I 2I J J $#Ha<2123 23 4 47KKKr<   r`  c                   B    e Zd ZdZ edd           edd          gZdS )L2CAP_Move_Channel_RequestzL2CAP Move Channel Requesticidr   dest_controller_idN)r6   r7   r8   r9   r   r   r:   r;   r<   r=   rh  rh    s9        'D<**911559KKKr<   rh  c                   T    e Zd ZdZ edd           eddddddd	d
dd          gZdS )L2CAP_Move_Channel_ResponsezL2CAP Move Channel Responseri  r   r)  Move successzMove pendingz$Move refused - Cont_ID not supportedz)Move refused - Cont_ID is same as old onez*Move refused - Configuration not supportedz%Move refused - Move channel collisionz&Move refused - Not allowed to be movedr   r.   r/   r0   r1   rD   rH   Nrf  r;   r<   r=   rl  rl    sa        (D<**##Ha((@EFAB2D 2D E EHKKKr<   rl  c                   J    e Zd ZdZ edd           eddddd          gZdS )	'L2CAP_Move_Channel_Confirmation_Requestz'L2CAP Move Channel Confirmation Requestri  r   r)  rm  zMove failurer   r.   Nrf  r;   r<   r=   rp  rp    sQ        4D<**##Ha^5C2E 2E F FIKKKr<   rp  c                   ,    e Zd ZdZ edd          gZdS )(L2CAP_Move_Channel_Confirmation_Responsez(L2CAP Move Channel Confirmation Responseri  r   Nr<  r;   r<   r=   rs  rs  	  s'        5D<**-KKKr<   rs  c                   n    e Zd ZdZ edd           edd           edd           edd          gZdS ))L2CAP_Connection_Parameter_Update_Requestz)L2CAP Connection Parameter Update Requestmin_intervalr   max_intervalslave_latencytimeout_multNr<  r;   r<   r=   ru  ru    sV        6D<22<22<33<226KKKr<   ru  c                   ,    e Zd ZdZ edd          gZdS )*L2CAP_Connection_Parameter_Update_Responsez*L2CAP Connection Parameter Update Responsemove_resultr   Nr<  r;   r<   r=   r{  r{    s'        7D<q114KKKr<   r{  c                       e Zd ZdZ edd           edd           edd           edd           edd          gZdS )	(L2CAP_LE_Credit_Based_Connection_Requestz(L2CAP LE Credit Based Connection Requestspsmr   r$  mtumpsinitial_creditsNr<  r;   r<   r=   r~  r~    sf        5D<**<**<q))<q))< 1155	9KKKr<   r~  c                       e Zd ZdZ edd           edd           edd           edd           edddd	d
dddddddd
          gZdS ))L2CAP_LE_Credit_Based_Connection_Responsez)L2CAP LE Credit Based Connection Responser(  r   r  r  r  r)  ra  z'Connection refused - SPSM not supportedrb  z)Connection refused - authentication errorz(Connection refused - authorization errorz+Connection refused - encrypt_key size errorz,Connection refused - insufficient encryptionrc  rd  z%Connection refused - parameters error)
r   r/   r1   rD   rH   rI   rJ   rK   rL   rM   Nrf  r;   r<   r=   r  r  $  s        6D<**<q))<q))< 1155##Ha1CGEDGH=HB
2D 
2D 
E 
E	HKKKr<   r  c                   B    e Zd ZdZ edd           edd          gZdS )L2CAP_Flow_Control_Credit_IndzL2CAP Flow Control Credit Indr   r   creditsNr<  r;   r<   r=   r  r  7  s8        *D<q))<	1--1KKKr<   r  c                       e Zd ZdZ edd           edd           edd           edd           edd          gZdS )	%L2CAP_Credit_Based_Connection_Requestz%L2CAP Credit Based Connection Requestr  r   r  r  r  r$  Nr<  r;   r<   r=   r  r  =  sf        2D<**<q))<q))< 1155<**	.KKKr<   r  c                       e Zd ZdZ edd           edd           edd           eddddd	d
dddddddd           edd          gZdS )&L2CAP_Credit_Based_Connection_Responsez&L2CAP Credit Based Connection Responser  r   r  r  r)  zAll connection successfulz+All connection refused - SPSM not supportedz*Some connections refused - resources errorz-All connection refused - authentication errorz,All connection refused - authorization errorz/All connection refused - encrypt_key size errorz)All connection refused - encryption errorz&Some connection refused - invalid scidz0Some connection refused - scid already allocatedz0All Connection refused - unacceptable parametersz,All connections refused - invalid parameters)r   r/   r1   rD   rH   rI   rJ   rK   rL   rM   rN   r(  Nrf  r;   r<   r=   r  r  F  s        3D<q))<q))< 1155##Ha5GFIHKEBMMI2K 2K L L  <**.KKKr<   r  c                   X    e Zd ZdZ edd           edd           edd          gZdS )&L2CAP_Credit_Based_Reconfigure_Requestz&L2CAP Credit Based Reconfigure Requestr  r   r  r(  Nr<  r;   r<   r=   r  r  Z  sG        3D<q))<q))<**.KKKr<   r  c            
       :    e Zd ZdZ edddddddd	          gZd
S )'L2CAP_Credit_Based_Reconfigure_Responsez'L2CAP Credit Based Reconfigure Responser)  r   zReconfig successfulz0Reconfig failed - MTU size reduction not allowedz0Reconfig failed - MPS size reduction not allowedz+Reconfig failed - one or more dcids invalidz)Reconfig failed - unacceptable parametersr   r.   r/   r0   r1   N)r6   r7   r8   r9   r   r:   r;   r<   r=   r  r  a  sL        4D##Ha+HHCA2C 2C D D GKKKr<   r  c                   ,    e Zd ZdZ edd          gZdS )ATT_Hdrz
ATT headeropcodeNr6   r7   r8   r9   r!   r:   r;   r<   r=   r  r  k  s'        D:h--0KKKr<   r  c                   H    e Zd ZdZ edd           edd          gZd ZdS )
ATT_HandlezATT Short Handler   r   valuec                 
    d|fS Nr<   r;   r   ss     r=   extract_paddingzATT_Handle.extract_paddingu      Avr<   Nr6   r7   r8   r9   r%   r:   r  r;   r<   r=   r  r  p  sM        D =1-- =!,,.K    r<   r  c                   V    e Zd ZdZ edd           eddej                  gZd ZdS )ATT_Handle_UUID128zATT Handle (UUID 128)r   r   r  Nuuid_fmtc                 
    d|fS r  r;   r  s     r=   r  z"ATT_Handle_UUID128.extract_padding~  r  r<   )	r6   r7   r8   r9   r%   r    
FORMAT_REVr:   r  r;   r<   r=   r  r  y  sV        "D =1--9WdY5IJJJLK    r<   r  c                   Z    e Zd ZdZ edd           edd           edde          gZdS )ATT_Error_ResponsezError Responserequestr   r   ecodeN)	r6   r7   r8   r9   r!   r   r   _att_error_codesr:   r;   r<   r=   r  r    sK        D:i++<!,, =!-=>>BKKKr<   r  c                   ,    e Zd ZdZ edd          gZdS )ATT_Exchange_MTU_RequestzExchange MTU Requestr  r   Nr<  r;   r<   r=   r  r    s'        !D<q)),KKKr<   r  c                   ,    e Zd ZdZ edd          gZdS )ATT_Exchange_MTU_ResponsezExchange MTU Responser  r   Nr<  r;   r<   r=   r  r    s'        "D<q)),KKKr<   r  c                   B    e Zd ZdZ edd           edd          gZdS )ATT_Find_Information_RequestzFind Information Requeststartr   endr2   Nr6   r7   r8   r9   r%   r:   r;   r<   r=   r  r    s8        %D =&11 =//3KKKr<   r  c            	           e Zd ZdZ edd           e edg e          d f edg e          d fg e	ddd	                    gZ
d
S )ATT_Find_Information_ResponsezFind Information Responseformatr.   handlesc                     | j         dk    S Nr.   r  pkts    r=   <lambda>z&ATT_Find_Information_Response.<lambda>      
a r<   c                     | j         dk    S Nr/   r  r  s    r=   r  z&ATT_Find_Information_Response.<lambda>  r  r<   rO  r   lengthN)r6   r7   r8   r9   r!   r   r   r  r  r   r:   r;   r<   r=   r  r    s        &D
8Q B
;;//1 B0BCC//1 Y1555	
 	
KKKr<   r  c                   n    e Zd ZdZ edd           edd           edd           edd	          gZdS )
ATT_Find_By_Type_Value_RequestzFind By Type Value Requestr  r.   r  r2   uuidNrN  rO  r6   r7   r8   r9   r%   r   r:   r;   r<   r=   r  r    sV        'D =&11 =// =..8FB''+KKKr<   r  c                   .    e Zd ZdZ edg e          gZdS )ATT_Find_By_Type_Value_ResponsezFind By Type Value Responser  N)r6   r7   r8   r9   r   r  r:   r;   r<   r=   r  r    s)        (D"?9b*==>KKKr<   r  c                       e Zd ZdZ edd           edd           edd           edd          gZed
d	            ZdS )ATT_Read_By_Type_Request_128bitRead By Type Requestr  r.   r  r2   uuid1Nuuid2c                 H    |rt          |          dk    rt          S t          S )NrH   )r   ATT_Read_By_Type_Requestr  )cls_pktargskargss       r=   dispatch_hookz-ATT_Read_By_Type_Request_128bit.dispatch_hook  s$     	,CIINN++..r<   r6  )	r6   r7   r8   r9   r%   r#   r:   classmethodr  r;   r<   r=   r  r    s|        !D =&11 =//<..<..0K
 / / / [/ / /r<   r  c                   X    e Zd ZdZ edd           edd           edd          gZdS )r  r  r  r.   r  r2   r  Nr  r;   r<   r=   r  r    sG        !D =&11 =// =..0KKKr<   r  c                   X    e Zd ZdgZ edd           eddd           gZdd	Zd
 ZdS )ATT_Handle_Variable
val_lengthr   r   r  c                     | j         S r6  r  r  s    r=   r  zATT_Handle_Variable.<lambda>  s    s~ r<   length_fromr<   r/   c                 :    || _         t          j        | |fi | d S r6  )r  r	   __init__)r   r  r  kwargss       r=   r  zATT_Handle_Variable.__init__  s)    $d--f-----r<   c                 
    d|fS r  r;   r  s     r=   r  z#ATT_Handle_Variable.extract_padding  r  r<   N)r<   r/   )	r6   r7   r8   	__slots__r%   r$   r:   r  r  r;   r<   r=   r  r    st        I =1--<#=#=? ? ?@K
. . . .    r<   r  c                   ^    e Zd ZdZ edd           edg d           gZed             ZdS )	ATT_Read_By_Type_ResponsezRead By Type Responser   r1   r  c                      | j         | g|R  S r6  )_next_cls_cb)r  r  s     r=   r  z"ATT_Read_By_Type_Response.<lambda>  s    +3+C7$777 r<   next_cls_cbc                 |    t          |          |j         k    r#t          j        t          |j         dz
            S d S )Nr/   r  )r   	functoolspartialr  )r  r  lstr   remains        r=   r  z&ATT_Read_By_Type_Response._next_cls_cb  sB    v;;#'!!$#7Q;    tr<   N)	r6   r7   r8   r9   r   r   r:   r  r  r;   r<   r=   r  r    sm        "D9UA&&"? "$ $  K   [  r<   r  c                   ,    e Zd ZdZ edd          gZdS )ATT_Read_RequestzRead Requestgatt_handler   Nr  r;   r<   r=   r  r    s'        D =225KKKr<   r  c                   ,    e Zd ZdZ edd          gZdS )ATT_Read_ResponsezRead Responser  rO  NrP  r;   r<   r=   r  r    s'        D8GR(()KKKr<   r  c                   B    e Zd ZdZ edg  edd                    gZdS )ATT_Read_Multiple_RequestzRead Multiple Requestr  rO  r   N)r6   r7   r8   r9   r   r%   r:   r;   r<   r=   r  r    s5        "D!>)Rr11E1EFFGKKKr<   r  c                   ,    e Zd ZdZ edd          gZdS )ATT_Read_Multiple_ResponsezRead Multiple ResponsevaluesrO  NrP  r;   r<   r=   r  r    s'        #D8Hb))*KKKr<   r  c                   X    e Zd ZdZ edd           edd           edd          gZdS )ATT_Read_By_Group_Type_RequestzRead By Group Type Requestr  r   r  r2   r  Nr  r;   r<   r=   r  r    sG        'D =!,, =// =++/KKKr<   r  c                   B    e Zd ZdZ edd           edd          gZdS )ATT_Read_By_Group_Type_ResponsezRead By Group Type Responser  r   rN  rO  N)r6   r7   r8   r9   r!   r   r:   r;   r<   r=   r  r    s8        (D:h**8FB''+KKKr<   r  c                   B    e Zd ZdZ edd           edd          gZdS )ATT_Write_RequestWrite Requestr  r   rN  rO  Nr  r;   r<   r=   r  r    8        D =228FB''+KKKr<   r  c                   B    e Zd ZdZ edd           edd          gZdS )ATT_Write_Commandr  r  r   rN  rO  Nr  r;   r<   r=   r   r     r  r<   r   c                       e Zd ZdZdS )ATT_Write_ResponsezWrite ResponseNr6   r7   r8   r9   r;   r<   r=   r  r    s        DDDr<   r  c                   X    e Zd ZdZ edd           edd           edd          gZdS )ATT_Prepare_Write_RequestzPrepare Write Requestr  r   offsetrN  rO  N)r6   r7   r8   r9   r%   r   r   r:   r;   r<   r=   r  r    sG        "DmQ''Xq!!KKKr<   r  c                       e Zd ZdZdS )ATT_Prepare_Write_ResponsezPrepare Write ResponseNr  r;   r<   r=   r  r  '          #DDDr<   r  c                   B    e Zd ZdZ edd           edd          gZdS )ATT_Handle_Value_NotificationzHandle Value Notificationr  r   r  rO  Nr  r;   r<   r=   r  r  +  s8        &D =228GR((,KKKr<   r  c                   4    e Zd ZdZ eddddd          gZdS )ATT_Execute_Write_RequestzExecute Write Requestr?  r.   zCancel all prepared writesz-Immediately write all pending prepared valuesrq  Nr6   r7   r8   r9   r   r:   r;   r<   r=   r  r  1  s=        "Dgq+>#
 #
 	 	KKKr<   r  c                       e Zd ZdZdS )ATT_Execute_Write_ResponsezExecute Write ResponseNr  r;   r<   r=   r  r  ;  r	  r<   r  c                   B    e Zd ZdZ edd           edd          gZdS )ATT_Read_Blob_RequestzRead Blob Requestr  r   r  Nr6   r7   r8   r9   r%   r   r:   r;   r<   r=   r  r  ?  s8        DmQ''Xq!!KKKr<   r  c                   ,    e Zd ZdZ edd          gZdS )ATT_Read_Blob_ResponsezRead Blob Responser  rO  NrP  r;   r<   r=   r  r  G  s)        D"KKKr<   r  c                   B    e Zd ZdZ edd           edd          gZdS )ATT_Handle_Value_IndicationzHandle Value Indicationr  r   r  rO  Nr  r;   r<   r=   r  r  N  s8        $DmQ''"KKKr<   r  c                   ,    e Zd ZdZ edd          gZdS )SM_Hdrz	SM header
sm_commandNr6   r7   r8   r9   r   r:   r;   r<   r=   r  r  V  s'        D9\4001KKKr<   r  c            
           e Zd ZdZ edddddddd	           ed
dddd           eddd           edd           edd           edd          gZdS )SM_Pairing_RequestzPairing Requestiocapr0   DisplayOnlyDisplayYesNoKeyboardOnlyNoInputNoOutputKeyboardDisplayr  oobr   Not PresentPresent (from remote device)rq  authenticationrJ   max_key_sizerP   initiator_key_distributionresponder_key_distributionNr6   r7   r8   r9   r   r
   r   r:   r;   r<   r=   r  r  [  s        D =!>Vdiz  @Q  .R  .R  S  S =}A_+`+`aa8,a339^R00991==991==AKKKr<   r  c            
           e Zd ZdZ edddddddd	           ed
dddd           eddd           edd           edd           edd          gZdS )SM_Pairing_ResponsezPairing Responser  r0   r  r   r!  r"  r#  r  r$  r   r%  r&  rq  r'  rJ   r(  rP   r)  r*  Nr+  r;   r<   r=   r-  r-  e  s        D =!>Vdiz  @Q  .R  .R  S  S =}A_+`+`aa8,a339^R00991==991==AKKKr<   r-  c                   .    e Zd ZdZ eddd          gZdS )
SM_ConfirmzPairing Confirmconfirm                   rP   Nr6   r7   r8   r9   r   r:   r;   r<   r=   r/  r/  o  s*        D##I|R@@AKKKr<   r/  c                   .    e Zd ZdZ eddd          gZdS )	SM_RandomzPairing Randomrandomr1  rP   Nr2  r;   r<   r=   r4  r4  t  s*        D##HlB??@KKKr<   r4  c                   ,    e Zd ZdZ edd          gZdS )	SM_FailedzPairing Failedr;  r   Nr  r;   r<   r=   r7  r7  y  s'        D:h**+KKKr<   r7  c                   .    e Zd ZdZ eddd          gZdS )SM_Encryption_InformationzEncryption Informationltkr1  rP   Nr2  r;   r<   r=   r9  r9  ~  s*        #D##E<<<?KKKr<   r9  c                   D    e Zd ZdZ edd           eddd          gZdS )SM_Master_IdentificationzMaster Identificationedivr   rands           rJ   N)r6   r7   r8   r9   r%   r   r:   r;   r<   r=   r<  r<    s;        "D =++##FK;;?KKKr<   r<  c                   .    e Zd ZdZ eddd          gZdS )SM_Identity_InformationzIdentity Informationirkr1  rP   Nr2  r;   r<   r=   r@  r@    s*        !D##E<<<?KKKr<   r@  c                   H    e Zd ZdZ eddddi           edd          gZdS )SM_Identity_Address_InformationzIdentity Address Informationatyper   publicaddressNr6   r7   r8   r9   r   r'   r:   r;   r<   r=   rC  rC    s>        )D =!a];;:i..2KKKr<   rC  c                   .    e Zd ZdZ eddd          gZdS )SM_Signing_InformationzSigning Informationcsrkr1  rP   Nr2  r;   r<   r=   rI  rI    s*         D##FL"==@KKKr<   rI  c                   F    e Zd ZdZ eddd           eddd          gZdS )SM_Public_Keyz
Public Keykey_xs                                    r`   key_yNr2  r;   r<   r=   rL  rL    s?        D##G\2>>##G\2>>BKKKr<   rL  c                   .    e Zd ZdZ eddd          gZdS )SM_DHKey_CheckzDHKey Checkdhkey_checkr1  rP   Nr2  r;   r<   r=   rP  rP    s*        D##M<DDGKKKr<   rP  c                   H    e Zd ZdZ edddd            eddi d	d
dddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*i d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdU          gZdV Z fdWZ xZ	S )XEIR_Hdrz
EIR Headerr   NBc                     | dz   S r  r;   )xs    r=   r  zEIR_Hdr.<lambda>  s
    A r<   )fmtadjustr   r   r.   r?  r/    incomplete_list_16_bit_svc_uuidsr0   complete_list_16_bit_svc_uuidsr1    incomplete_list_32_bit_svc_uuidsrD   complete_list_32_bit_svc_uuidsrH   !incomplete_list_128_bit_svc_uuidsrI   complete_list_128_bit_svc_uuidsrJ   shortened_local_namerK   complete_local_namerL   tx_power_levelrO   class_of_devicerE   simple_pairing_hashrF   simple_pairing_randrP   
sec_mgr_tkrQ   sec_mgr_oob_flagsrR   slave_conn_intvl_rangerT   !list_16_bit_svc_sollication_uuidsrU   "list_128_bit_svc_sollication_uuidsrV   svc_data_16_bit_uuidrW   pub_target_addrrX   rand_target_addrrY   
appearancerZ   	adv_intvlr[   le_addrr\   le_roler]   simple_pairing_hash_256r^   simple_pairing_rand_256r_   !list_32_bit_svc_sollication_uuidsr`   svc_data_32_bit_uuidra   svc_data_128_bit_uuidrb   sec_conn_confirmrc   sec_conn_randrd   urire   indoor_positioningtransport_discoveryle_supported_featureschannel_map_updatemesh_pb_advmesh_messagemesh_beacon3d_informationmfg_specific_data)rf   rg   rh   ri   rj   rk   r}      c                 ,    |                      d          S )Nz
EIR %type%r   r   s    r=   r   zEIR_Hdr.mysummary  r   r<   c                     | j         dk    rt          j        S t          t          |                               |          S Nr   )r   r   padding_layersuperrS  guess_payload_class)r   r  	__class__s     r=   r  zEIR_Hdr.guess_payload_class  s5    8q==%%Wd##77@@@r<   )
r6   r7   r8   r9   r   r   r:   r   r  __classcell__r  s   @r=   rS  rS    sz       D#oo>>>fa /"
'/"
4/"
 2/"
 4	/"

 2/"
 5/"
 3/"
 (/"
 '/"
 "/"
 #/"
 '/"
 '/"
 ,/"
  %!/"
" *#/"
$ 5%/"
 /"
& 6'/"
( ()/"
* #+/"
, $-/"
. ,//"
0 +1/"
2 )3/"
4 )5/"
6 +7/"
8 +9/"
: 5;/"
> (?/"
@ )A/"
B $C/"
D /E/"
F %G/"
H &I/"
 /"
J ()& "%]/"
 /"
 /"
 /	 /	3Kj* * *A A A A A A A A Ar<   rS  c                   .    e Zd ZdZd Zed             ZdS )EIR_ElementzEIR Elementc                 
    d|fS r  r;   r  s     r=   r  zEIR_Element.extract_padding  s    Avr<   c                 P    | j         st          d           dS | j         j        dz
  S )NzMissing an upper-layerr   r.   )
underlayerr-   r   r  s    r=   r  zEIR_Element.length_from  s0    ~ 	,---1~!A%%r<   N)r6   r7   r8   r9   r  staticmethodr  r;   r<   r=   r  r    sC        D   & & \& & &r<   r  c                   :    e Zd ZdZ eddej                  gZdS )EIR_RawzEIR RawrN  rO  r  Nr6   r7   r8   r9   r   r  r  r:   r;   r<   r=   r  r    s1        DFBK,CDDDKKKr<   r  c                   B    e Zd ZdZ edddg dddgz  z             gZdS )		EIR_FlagsFlagsr?  r/   rJ   )limited_disc_modegeneral_disc_moder   simul_le_br_edr_ctrlsimul_le_br_edr_hostr0   r   N)r6   r7   r8   r9   r   r:   r;   r<   r=   r  r    sO        D
7C, , ,./:,.>?	@ 	@KKKr<   r  c                   P    e Zd ZdZ edd edd          ej                  gZdS )!EIR_CompleteList16BitServiceUUIDsz%Complete list of 16-bit service UUIDs	svc_uuidsNr  r   r  )	r6   r7   r8   r9   r   r%   r  r  r:   r;   r<   r=   r  r    sH        2D 	{D--*B*B#.#:	< 	< 	<KKKr<   r  c                       e Zd ZdZdS )#EIR_IncompleteList16BitServiceUUIDsz'Incomplete list of 16-bit service UUIDsNr  r;   r<   r=   r  r            4DDDr<   r  c                   P    e Zd ZdZ edd edd          ej                  gZdS )!EIR_CompleteList32BitServiceUUIDsz%Complete list of 32-bit service UUIDsr  Nr  r   r  )	r6   r7   r8   r9   r   r&   r  r  r:   r;   r<   r=   r  r    sH        2D 	{D++fa*@*@#.#:	< 	< 	<KKKr<   r  c                       e Zd ZdZdS )#EIR_IncompleteList32BitServiceUUIDsz'Incomplete list of 32-bit service UUIDsNr  r;   r<   r=   r  r    r  r<   r  c            	       ^    e Zd ZdZ edd eddej                  ej                  gZ	dS )"EIR_CompleteList128BitServiceUUIDsz&Complete list of 128-bit service UUIDsr  Nr  r  r  )
r6   r7   r8   r9   r   r    r  r  r  r:   r;   r<   r=   r  r     sO        3D{D y	8LMMM#.#:	< 	< 	<KKKr<   r  c                       e Zd ZdZdS )$EIR_IncompleteList128BitServiceUUIDsz(Incomplete list of 128-bit service UUIDsNr  r;   r<   r=   r  r  )  s        5DDDr<   r  c                   :    e Zd ZdZ eddej                  gZdS )EIR_CompleteLocalNamezComplete Local Name
local_namerO  r  Nr  r;   r<   r=   r  r  -  s1         DL"+2IJJJKKKr<   r  c                       e Zd ZdZdS )EIR_ShortenedLocalNamezShortened Local NameNr  r;   r<   r=   r  r  4  s        !DDDr<   r  c                   ,    e Zd ZdZ edd          gZdS )EIR_TX_Power_LevelzTX Power Levellevelr   N)r6   r7   r8   r9   r   r:   r;   r<   r=   r  r  8  s'        D"?7A../KKKr<   r  c                       e Zd ZdZ edddg dd           eddd	d
ddddddddddd           eddd           edddd          gZdS )EIR_ClassOfDevicezClass of devicemajor_service_classesr   rM   )limited_discoverable_modele_audior   positioning
networking	rendering	capturingobject_transferaudio	telephonyinformationr   major_device_classrD   miscellaneouscomputerphonelanaudio_video
peripheralimagingwearabletoyhealthuncategorized)r   r.   r/   r0   r1   rD   rH   rI   rJ   rK   r_   minor_device_classrH   fixedr/   r   N)r6   r7   r8   r9   r   r(   r
   r:   r;   r<   r=   r  r  =  s        D
*Ar 4
 4
 4
 	 	 	 	)1a!!2
 2
 	 	 	%q!,,!QR0009KKKr<   r  c                   .    e Zd ZdZ eddd          gZdS )EIR_SecureSimplePairingHashC192z Secure Simple Pairing Hash C-192hashr   rP   Nr6   r7   r8   r9   r   r:   r;   r<   r=   r  r  _  s)        -D;vq"--.KKKr<   r  c                   .    e Zd ZdZ eddd          gZdS )%EIR_SecureSimplePairingRandomizerR192z&Secure Simple Pairing Randomizer R-192
randomizerr   rP   Nr  r;   r<   r=   r  r  d  s)        3D;|Q334KKKr<   r  c            	           e Zd ZdZ eddd           eddd           eddd           eddd           eddd	          gZd
S )EIR_SecurityManagerOOBFlagsz"Security Manager Out of Band Flagsoob_flags_fieldr   r.   le_supportedpreviously_usedaddress_typer   r1   N)r6   r7   r8   r9   r
   r:   r;   r<   r=   r  r  i  sq        /D"Aq))A&&"Aq))A&&Q""KKKr<   r  c                   B    e Zd ZdZ edd           edd          gZdS )%EIR_PeripheralConnectionIntervalRangez$Peripheral Connection Interval Rangeconn_interval_minr2   conn_interval_maxNr<  r;   r<   r=   r  r  t  s:        1D(&11(&11KKKr<   r  c                   T    e Zd ZdZ edd          gZi Zedd            Zd Z	d Z
dS )EIR_Manufacturer_Specific_DatazEIR Manufacturer Specific Data
company_idNc                     |:t          |d          r|j        }n"t          d                    |                    || j        |<   dS )ao  
        Registers a payload type that uses magic data.

        Traditional payloads require registration of a Bluetooth Company ID
        (requires company membership of the Bluetooth SIG), or a Bluetooth
        Short UUID (requires a once-off payment).

        There are alternatives which don't require registration (such as
        128-bit UUIDs), but the biggest consumer of energy in a beacon is the
        radio -- so the energy consumption of a beacon is proportional to the
        number of bytes in a beacon frame.

        Some beacon formats side-step this issue by using the Company ID of
        their beacon hardware manufacturer, and adding a "magic data sequence"
        at the start of the Manufacturer Specific Data field.

        Examples of this are AltBeacon and GeoBeacon.

        For an example of this method in use, see ``scapy.contrib.altbeacon``.

        :param Type[scapy.packet.Packet] payload_cls:
            A reference to a Packet subclass to register as a payload.
        :param Callable[[bytes], bool] magic_check:
            (optional) callable to use to if a payload should be associated
            with this type. If not supplied, ``payload_cls.magic_check`` is
            used instead.
        :raises TypeError: If ``magic_check`` is not specified,
                           and ``payload_cls.magic_check`` is not implemented.
        Nmagic_checkz>magic_check not specified, and {} has no attribute magic_check)hasattrr  	TypeErrorr  registered_magic_payloads)r  payload_clsr  s      r=   register_magic_payloadz5EIR_Manufacturer_Specific_Data.register_magic_payload  sd    > {M22 M)5 !88>{8K8KM M M 6A%k222r<   c                     t           j                                        D ]\  }} ||          r|c S t          j        | |          S r6  )r  r  itemsr	   default_payload_class)r   r  r  checks       r=   r  z4EIR_Manufacturer_Specific_Data.default_payload_class  sY    *DJJLL	 	JC uW~~ 


 +D':::r<   c                 d    t                               |           dz
  }|d |         ||d          fS r  r  r  r   r  plens      r=   r  z.EIR_Manufacturer_Specific_Data.extract_padding  5    &&t,,q0$x455!!r<   r6  )r6   r7   r8   r9   r%   r:   r  r  r  r  r  r;   r<   r=   r  r  |  sz        +D 	lD))K
 !#%A %A %A [%AN; ; ;" " " " "r<   r  c                   n    e Zd ZdZ edd           edd           edd           edd          gZdS )EIR_Device_IDz	Device IDvendor_id_sourcer   	vendor_id
product_idversionNr  r;   r<   r=   r  r    sW        D(!,,k1%%lA&&i##	KKKr<   r  c                   2    e Zd ZdZ edd          gZd ZdS )EIR_ServiceData16BitUUIDzEIR Service Data - 16-bit UUIDsvc_uuidNc                 d    t                               |           dz
  }|d |         ||d          fS r  r  r  s      r=   r  z(EIR_ServiceData16BitUUID.extract_padding  r  r<   r  r;   r<   r=   r  r    s@        +D 	j$''K
" " " " "r<   r  c                   2    e Zd ZdZ edd          gZd ZdS )EIR_ServiceData32BitUUIDzEIR Service Data - 32-bit UUIDr  r   c                 d    t                               |           dz
  }|d |         ||d          fS )Nr1   r  r  s      r=   r  z(EIR_ServiceData32BitUUID.extract_padding  r  r<   N)r6   r7   r8   r9   r&   r:   r  r;   r<   r=   r  r    s>        +DJ""K" " " " "r<   r  c                   @    e Zd ZdZ eddej                  gZd ZdS )EIR_ServiceData128BitUUIDzEIR Service Data - 128-bit UUIDr  Nr  c                 d    t                               |           dz
  }|d |         ||d          fS )NrP   r  r  s      r=   r  z)EIR_ServiceData128BitUUID.extract_padding  s5    &&t,,r1$x455!!r<   )r6   r7   r8   r9   r    r  r:   r  r;   r<   r=   r   r     sF        ,D	*dY-ABBBK" " " " "r<   r   c                       e Zd ZdZ edddd           edddd	           ed
dd          gZd Zed             Z	d Z
dS )HCI_Command_HdrzHCI Command headerogfr   rH   r   r   ocfrL   r   r   NrT  rW  c                     dS NFr;   r  s     r=   r  zHCI_Command_Hdr.answers  s    ur<   c                 &    | j         dz  | j        z   S )NrL   r  r  r   s    r=   r  zHCI_Command_Hdr.opcode  s    B$(**r<   c                     ||z  }| j         8|d d         t          j        dt          |                    z   |dd          z   }|S )Nr/   rT  r0   r   r   s      r=   r   zHCI_Command_Hdr.post_build  sI    	S8"1"CS222QqrrU:Ar<   )r6   r7   r8   r9   r   r   r:   r  propertyr  r   r;   r<   r=   r  r    s        D9UAq26669UAr;;;8E4S1115K   + + X+    r<   r  c                   F    e Zd Z e edg d           dd          gZdS )HCI_Extended_Inquiry_Responseeir_datac                  \    | d          s| d         j         dk    rt          pt          j        S )Nr/   r   )r   rS  r   	raw_layer)r  s    r=   r  z&HCI_Extended_Inquiry_Response.<lambda>  s,    a[4DGK1$4A'ST^ r<   r  r_       alignpadwithN)r6   r7   r8   r   r   r:   r;   r<   r=   r  r    sS        OB    e	
 	
 	

KKKr<   r  c                   \    e Zd ZdZdZ edd           edd           edd          gZdS )	HCI_Cmd_Inquiryz
    7.1.1 Inquiry command
    HCI_Inquirylap3 inquiry_lengthr   num_responsesN)r6   r7   r8   __doc__r9   r"   r   r:   r;   r<   r=   r  r    sT          D!>%229-q119_a002KKKr<   r  c                       e Zd ZdZdZdS )HCI_Cmd_Inquiry_Cancelz&
    7.1.2 Inquiry Cancel command
    HCI_Inquiry_CancelNr6   r7   r8   r  r9   r;   r<   r=   r  r    s           DDDr<   r  c                       e Zd ZdZdZ edd           edd           edd           ed	d
           edd
          gZdS )HCI_Cmd_Periodic_Inquiry_Modez-
    7.1.3 Periodic Inquiry Mode command
    HCI_Periodic_Inquiry_Modemax_period_lengthr0   min_period_lengthr/   r  r  r  r   r  N)	r6   r7   r8   r  r9   r   r"   r   r:   r;   r<   r=   r#  r#  %  st          'D< 3V<<< 3V<<!>%229-q119_a00	2KKKr<   r#  c                       e Zd ZdZdZdS )!HCI_Cmd_Exit_Peiodic_Inquiry_Modez2
    7.1.4 Exit Periodic Inquiry Mode command
    HCI_Exit_Periodic_Inquiry_ModeNr!  r;   r<   r=   r(  r(  1  s          ,DDDr<   r(  c            	           e Zd ZdZdZ edd           edd           edd           ed	d
           edd
           edd          gZdS )HCI_Cmd_Create_Connectionz)
    7.1.5 Create Connection command
    HCI_Create_Connectionbd_addrNpacket_typei  page_scan_repetition_moder/   r   r   clock_offsetallow_role_switchr.   )	r6   r7   r8   r  r9   r'   r   r   r:   r;   r<   r=   r+  r+  8  s          #D:i..<v6698$??9Z--<4490#66:KKKr<   r+  c                   F    e Zd ZdZdZ edd           edd          gZdS )HCI_Cmd_Disconnectz"
    7.1.6 Disconnect command
    HCI_Disconnectr   r   r;  rS   N)r6   r7   r8   r  r9   r%   r   r:   r;   r<   r=   r3  r3  E  sD          D =1--9Xt,,0KKKr<   r3  c                   0    e Zd ZdZdZ edd          gZdS ) HCI_Cmd_Create_Connection_Cancelz0
    7.1.7 Create Connection Cancel command
    HCI_Create_Connection_Cancelr-  Nr6   r7   r8   r  r9   r'   r:   r;   r<   r=   r6  r6  N  s3          *D:i..1KKKr<   r6  c                   F    e Zd ZdZdZ edd           edd          gZdS )!HCI_Cmd_Accept_Connection_Requestz1
    7.1.8 Accept Connection Request command
    HCI_Accept_Connection_Requestr-  Nroler.   r6   r7   r8   r  r9   r'   r   r:   r;   r<   r=   r:  r:  V  sD          +D:i..9VS))-KKKr<   r:  c                   F    e Zd ZdZdZ edd           edd          gZdS )"HCI_Cmd_Reject_Connection_Responsez1
    7.1.9 Reject Connection Request command
    HCI_Reject_Connection_Responser-  Nr;  r.   r=  r;   r<   r=   r?  r?  _  sD          ,D:i..9Xs++/KKKr<   r?  c                   H    e Zd ZdZdZ edd           eddd          gZdS )HCI_Cmd_Link_Key_Request_Replyz/
    7.1.10 Link Key Request Reply command
    HCI_Link_Key_Request_Replyr-  Nlink_keyrP   r6   r7   r8   r  r9   r'   r   r:   r;   r<   r=   rB  rB  h  sF          (D:i..;z4448KKKr<   rB  c                   0    e Zd ZdZdZ edd          gZdS )'HCI_Cmd_Link_Key_Request_Negative_Replyz8
    7.1.11 Link Key Request Negative Reply command
    #HCI_Link_Key_Request_Negative_Replyr-  Nr8  r;   r<   r=   rG  rG  q  3          1D:i..1KKKr<   rG  c                   `    e Zd ZdZdZ edd           edd           eddd	
          gZdS )HCI_Cmd_PIN_Code_Request_Replyz/
    7.1.12 PIN Code Request Reply command
    HCI_PIN_Code_Request_Replyr-  Npin_code_lengthrI   pin_coder1  rP   sz)	r6   r7   r8   r  r9   r'   r   r   r:   r;   r<   r=   rK  rK  y  sZ          (D:i..9.22;z<B???CKKKr<   rK  c                   0    e Zd ZdZdZ edd          gZdS )'HCI_Cmd_PIN_Code_Request_Negative_Replyz8
    7.1.13 PIN Code Request Negative Reply command
    #HCI_PIN_Code_Request_Negative_Replyr-  Nr8  r;   r<   r=   rR  rR    rI  r<   rR  c                   F    e Zd ZdZd Z edd           edd          gZdS )%HCI_Cmd_Change_Connection_Packet_Typez6
    7.1.14 Change Connection Packet Type command
    connection_handleNr.  r   )r6   r7   r8   r  r9   r%   r   r:   r;   r<   r=   rU  rU    sE          3D =!4d;;<q115KKKr<   rU  c                   0    e Zd ZdZdZ edd          gZdS ) HCI_Cmd_Authentication_Requestedz1
    7.1.15 Authentication Requested command
    HCI_Authentication_Requestedr   r   Nr6   r7   r8   r  r9   r   r:   r;   r<   r=   rX  rX    s3          *D<!,,-KKKr<   rX  c                   F    e Zd ZdZdZ edd           edd          gZdS )!HCI_Cmd_Set_Connection_Encryptionz2
    7.1.16 Set Connection Encryption command
    HCI_Set_Connection_Encryptionr   r   encryption_enableNr6   r7   r8   r  r9   r   r   r:   r;   r<   r=   r\  r\    sB          +D<!,,ii8KQ.O.OPKKKr<   r\  c                   0    e Zd ZdZdZ edd          gZdS )"HCI_Cmd_Change_Connection_Link_Keyz3
    7.1.17 Change Connection Link Key command
    HCI_Change_Connection_Link_Keyr   r   NrZ  r;   r<   r=   ra  ra    s3          ,D<!,,/KKKr<   ra  c                   8    e Zd ZdZd Z eddddd          gZdS )HCI_Cmd_Link_Key_Selectionz3
    7.1.18 Change Connection Link Key command
    r   r   zUse semi-permanent Link KeyszUse Temporary Link Keyrq  Nr6   r7   r8   r  r9   r   r:   r;   r<   r=   rd  rd    sN          (D =12P2J/N /N O O RKKKr<   rd  c                   r    e Zd ZdZdZ edd           edd           edd           ed	d          gZdS )
HCI_Cmd_Remote_Name_Requestz,
    7.1.19 Remote Name Request command
    HCI_Remote_Name_Requestr-  Nr/  r/   r   r   r0  )	r6   r7   r8   r  r9   r'   r   r   r:   r;   r<   r=   rg  rg    sc          %D:i..98$??9Z--<448KKKr<   rg  c                   0    e Zd ZdZdZ edd          gZdS )"HCI_Cmd_Remote_Name_Request_Cancelz3
    7.1.20 Remote Name Request Cancel command
    HCI_Remote_Name_Request_Cancelr-  Nr8  r;   r<   r=   rj  rj    s3          ,D:i..1KKKr<   rj  c                   0    e Zd ZdZdZ edd          gZdS )&HCI_Cmd_Read_Remote_Supported_Featuresz7
    7.1.21 Read Remote Supported Features command
    "HCI_Read_Remote_Supported_FeaturesrV  NrZ  r;   r<   r=   rm  rm    s4          0D< 3T::=KKKr<   rm  c                   F    e Zd ZdZdZ edd           edd          gZdS )%HCI_Cmd_Read_Remote_Extended_Featuresz6
    7.1.22 Read Remote Extended Features command
    rn  rV  Npage_numberr_  r;   r<   r=   rp  rp    sE          0D< 3T::9]D115KKKr<   rp  c                       e Zd ZdZdZ edd           edddddd	d
           eddddddd
           eddddddddd          gZdS )#HCI_Cmd_IO_Capability_Request_Replyz4
    7.1.29 IO Capability Request Reply command
    rn  r-  Nio_capabilityr  r   r!  r"  r   r.   r/   r0   oob_data_presentr%  zP-192zP-256zP-192 + P-256authentication_requirementzMITM Not RequiredzMITM Required, No Bondingz%MITM Not Required + Dedicated Pairingz!MITM Required + Dedicated Pairingz"MITM Not Required, General BondingzMITM Required + General Bonding)r   r.   r/   r0   r1   rD   )r6   r7   r8   r  r9   r'   r   r:   r;   r<   r=   rs  rs    s          0D:i.. =$}?M?M?P9T 9T U U !=!3T-BIBIBQ<U <U V V !=!=t(;(C(O(K(L(I"K "KL LOKKKr<   rs  c                   0    e Zd ZdZdZ edd          gZdS )'HCI_Cmd_User_Confirmation_Request_Replyz8
    7.1.30 User Confirmation Request Reply command
    #HCI_User_Confirmation_Request_Replyr-  Nr8  r;   r<   r=   ry  ry    rI  r<   ry  c                   0    e Zd ZdZdZ edd          gZdS )0HCI_Cmd_User_Confirmation_Request_Negative_ReplyzA
    7.1.31 User Confirmation Request Negative Reply command
    ,HCI_User_Confirmation_Request_Negative_Replyr-  Nr8  r;   r<   r=   r|  r|    s3          :D:i..1KKKr<   r|  c                   F    e Zd ZdZdZ edd           edd          gZdS )"HCI_Cmd_User_Passkey_Request_Replyz3
    7.1.32 User Passkey Request Reply command
    HCI_User_Passkey_Request_Replyr-  Nnumeric_value)r6   r7   r8   r  r9   r'   r   r:   r;   r<   r=   r  r     sD          ,D:i..:ot448KKKr<   r  c                   0    e Zd ZdZdZ edd          gZdS )+HCI_Cmd_User_Passkey_Request_Negative_Replyz<
    7.1.33 User Passkey Request Negative Reply command
    'HCI_User_Passkey_Request_Negative_Replyr-  Nr8  r;   r<   r=   r  r  	  s3          5D:i..1KKKr<   r  c                   d    e Zd ZdZdZ edd           eddd           ed	dd          gZdS )
%HCI_Cmd_Remote_OOB_Data_Request_Replyz6
    7.1.34 Remote OOB Data Request Reply command
    !HCI_Remote_OOB_Data_Request_Replyr-  NCr1  rP   rO  RrE  r;   r<   r=   r  r    s]          /D:i..;sLR888;sLR888<KKKr<   r  c                   0    e Zd ZdZdZ edd          gZdS ).HCI_Cmd_Remote_OOB_Data_Request_Negative_Replyz?
    7.1.35 Remote OOB Data Request Negative Reply command
    *HCI_Remote_OOB_Data_Request_Negative_Replyr-  Nr8  r;   r<   r=   r  r    s3          8D:i..1KKKr<   r  c                   X    e Zd ZdZ edd           edd           edd          gZdS )HCI_Cmd_Hold_ModeHCI_Hold_ModerV  r   hold_mode_max_intervalr/   hold_mode_min_intervalNr<  r;   r<   r=   r  r  %  sK        D< 3Q77< 8&AA< 8&AAEKKKr<   r  c                   2    e Zd ZdZdZ eddd          gZdS )HCI_Cmd_Set_Event_Maskz&
    7.3.1 Set Event Mask command
    HCI_Set_Event_Maskmasks   =rJ   Nr6   r7   r8   r  r9   r   r:   r;   r<   r=   r  r  .  s8           D##F,OQRSSTKKKr<   r  c                       e Zd ZdZdZdS )HCI_Cmd_Resetz
    7.3.2 Reset command
    	HCI_ResetNr!  r;   r<   r=   r  r  6  s          DDDr<   r  c                   6    e Zd ZdZdZ eddddi          gZdS )HCI_Cmd_Set_Event_Filterz(
    7.3.3 Set Event Filter command
    HCI_Set_Event_Filterr   r   clearNre  r;   r<   r=   r  r  =  s9          "D =QL99<KKKr<   r  c                   4    e Zd ZdZdZ eddd          gZdS )HCI_Cmd_Write_Local_Namez)
    7.3.11 Write Local Name command
    HCI_Write_Local_Namer9   rO     r  Nr  r;   r<   r=   r  r  E  s9          "D##FBs;;;<KKKr<   r  c                       e Zd ZdZdZdS )HCI_Cmd_Read_Local_Namez(
    7.3.12 Read Local Name command
    HCI_Read_Local_NameNr!  r;   r<   r=   r  r  M  s          !DDDr<   r  c                   ,    e Zd ZdZ edd          gZdS )$HCI_Cmd_Write_Connect_Accept_Timeout#HCI_Write_Connection_Accept_Timeouttimeouti }  Nr<  r;   r<   r=   r  r  T  s'        0D<	5112KKKr<   r  c                   .    e Zd ZdZ edd          egZdS )'HCI_Cmd_Write_Extended_Inquiry_Response#HCI_Write_Extended_Inquiry_Responsefec_requiredr   N)r6   r7   r8   r9   r   r  r:   r;   r<   r=   r  r  Y  s,        0D9^Q//02KKKr<   r  c                       e Zd ZdZdS )HCI_Cmd_Read_LE_Host_SupportHCI_Read_LE_Host_SupportNr  r;   r<   r=   r  r  _  s        %DDDr<   r  c                   B    e Zd ZdZ edd           edd          gZdS )HCI_Cmd_Write_LE_Host_SupportHCI_Write_LE_Host_Support	supportedr.   unusedNr  r;   r<   r=   r  r  c  s8        &D9[!,,9Xq))-KKKr<   r  c                       e Zd ZdZdZdS )&HCI_Cmd_Read_Local_Version_Informationz6
    7.4.1 Read Local Version Information command
    "HCI_Read_Local_Version_InformationNr!  r;   r<   r=   r  r  k  s          0DDDr<   r  c                   0    e Zd ZdZdZ edd          gZdS )$HCI_Cmd_Read_Local_Extended_Featuresz4
    7.4.4 Read Local Extended Features command
     HCI_Read_Local_Extended_Featuresrq  r   N)r6   r7   r8   r  r9   r   r:   r;   r<   r=   r  r  r  s3          .D9]A../KKKr<   r  c                       e Zd ZdZdZdS )HCI_Cmd_Read_BD_Addrz$
    7.4.6 Read BD_ADDR command
    HCI_Read_BD_ADDRNr!  r;   r<   r=   r  r  z  s          DDDr<   r  c                   ,    e Zd ZdZ edd          gZdS )HCI_Cmd_Read_Link_QualityHCI_Read_Link_Qualityr   r   Nr<  r;   r<   r=   r  r    s'        "D<!,,-KKKr<   r  c                   ,    e Zd ZdZ edd          gZdS )HCI_Cmd_Read_RSSIHCI_Read_RSSIr   r   Nr<  r;   r<   r=   r  r    s'        D<!,,-KKKr<   r  c                       e Zd ZdZdS )HCI_Cmd_Read_Loopback_ModeHCI_Read_Loopback_ModeNr  r;   r<   r=   r  r    r	  r<   r  c                   6    e Zd ZdZ edddddd          gZdS )	HCI_Cmd_Write_Loopback_ModeHCI_Write_Loopback_Modeloopback_moder   zno loopbackzenable local loopbackzenable remote loopbackre  Nr  r;   r<   r=   r  r    sC        $D =!%2%<%="? "?@ @ AKKKr<   r  c                       e Zd ZdZdS )HCI_Cmd_LE_Read_Buffer_Size_V1zHCI_LE_Read_Buffer_Size [v1]Nr  r;   r<   r=   r  r            )DDDr<   r  c                       e Zd ZdZdS )HCI_Cmd_LE_Read_Buffer_Size_V2zHCI_LE_Read_Buffer_Size [v2]Nr  r;   r<   r=   r  r    r  r<   r  c                       e Zd ZdZdS )(HCI_Cmd_LE_Read_Local_Supported_Features$HCI_LE_Read_Local_Supported_FeaturesNr  r;   r<   r=   r  r    s        1DDDr<   r  c                   ,    e Zd ZdZ edd          gZdS )HCI_Cmd_LE_Set_Random_AddressHCI_LE_Set_Random_AddressrF  N)r6   r7   r8   r9   r'   r:   r;   r<   r=   r  r    s'        &D:i../KKKr<   r  c                       e Zd ZdZ edd           edd           eddddd	d
dd           eddddd           eddddd           edd           edd           eddddddd          gZdS )%HCI_Cmd_LE_Set_Advertising_Parameters!HCI_LE_Set_Advertising_Parametersinterval_mini   interval_maxadv_typer   ADV_INDADV_DIRECT_INDADV_SCAN_INDADV_NONCONN_INDADV_DIRECT_IND_LOWr  oatyperE  r5  rq  datypedaddrNchannel_maprI   filter_policyzall:allzconnect:all scan:whitelistzconnect:whitelist scan:allzall:whitelistru  )	r6   r7   r8   r9   r   r   r'   r   r:   r;   r<   r=   r  r    s        .D<77<77 =QIBRWej{  AU  1V  1V  W  W =1(x.H.HII =1(x.H.HII:gt,,9]A.. =!Gc  iE  JY  6Z  6Z  [  [^KKKr<   r  c            	       h    e Zd ZdZ edddd           e edg ed           d	d
          gZdS )HCI_Cmd_LE_Set_Advertising_DataHCI_LE_Set_Advertising_Datar   NrN  rT  	length_ofrW  c                     | j         S r6  r   r  s    r=   r  z(HCI_Cmd_LE_Set_Advertising_Data.<lambda>  s    sw r<   r  r_   r  r  )	r6   r7   r8   r9   r   r   r   rS  r:   r;   r<   r=   r  r    sl        (D =CHHH8&vr73F3FH H H0 0 03KKKr<   r  c                   N    e Zd ZdZ edddd           eddd 	          gZdS )
!HCI_Cmd_LE_Set_Scan_Response_DataHCI_LE_Set_Scan_Response_Datar   NrN  rT  r  rO  c                     | j         S r6  r  r  s    r=   r  z*HCI_Cmd_LE_Set_Scan_Response_Data.<lambda>  s    37 r<   r  )r6   r7   r8   r9   r   r   r:   r;   r<   r=   r  r    sI        *D =CHHH;vr7J7JKKKOKKKr<   r  c                   ,    e Zd ZdZ edd          gZdS )HCI_Cmd_LE_Set_Advertise_EnableHCI_LE_Set_Advertising_Enableenabler   Nr  r;   r<   r=   r  r    s'        *D9Xq))*KKKr<   r  c                       e Zd ZdZ eddddd           edd           ed	d           ed
dddddd           eddddd          gZdS )HCI_Cmd_LE_Set_Scan_ParametersHCI_LE_Set_Scan_Parametersr   r   passiveactiverq  intervalrP   windowrD  rE  r5  z	rpa (pub)zrpa (random)ru  policyall	whitelistN)r6   r7   r8   r9   r   r%   r:   r;   r<   r=   r  r    s        'D =	h,G,GHH =R00 =2.. =!191<1?.A .A B B !=1%K.H.HIIKKKKr<   r  c                   B    e Zd ZdZ edd           edd          gZdS )HCI_Cmd_LE_Set_Scan_EnableHCI_LE_Set_Scan_Enabler  r.   filter_dupsNr  r;   r<   r=   r   r     s8        #D9Xq))9]A..2KKKr<   r   c                   4   e Zd ZdZ edd           edd           eddddi           ed	dd
dd           edd           eddd
dd           edd           edd           edd           edd           edd           edd          gZdS )HCI_Cmd_LE_Create_ConnectionHCI_LE_Create_Connectionr  `   r  rp   filterr   rF  patyperE  r5  rq  paddrNrD  rv  rh   rw  rx   latencyr  rj   min_cemax_ce)r6   r7   r8   r9   r   r   r'   r:   r;   r<   r=   r  r    s        %D<
B//<"-- =1q)n== =1(x.H.HII:gt,, =!h-G-GHH<33<33<	1--<	2..<!,,<!,,0KKKr<   r  c                       e Zd ZdZdS )#HCI_Cmd_LE_Create_Connection_CancelHCI_LE_Create_Connection_CancelNr  r;   r<   r=   r  r            ,DDDr<   r  c                       e Zd ZdZdS )'HCI_Cmd_LE_Read_Filter_Accept_List_Size#HCI_LE_Read_Filter_Accept_List_SizeNr  r;   r<   r=   r  r    s        0DDDr<   r  c                       e Zd ZdZdS )#HCI_Cmd_LE_Clear_Filter_Accept_ListHCI_LE_Clear_Filter_Accept_ListNr  r;   r<   r=   r  r    r  r<   r  c                   L    e Zd ZdZ edddddd           edd	          gZd	S )
+HCI_Cmd_LE_Add_Device_To_Filter_Accept_List'HCI_LE_Add_Device_To_Filter_Accept_Listr  r   rE  r5  	anonymous)r   r.   r  rF  NrG  r;   r<   r=   r  r    sT        4D =8@;F5H 5H I I :i..0KKKr<   r  c                       e Zd ZdZdS )0HCI_Cmd_LE_Remove_Device_From_Filter_Accept_List,HCI_LE_Remove_Device_From_Filter_Accept_ListNr  r;   r<   r=   r  r    s        9DDDr<   r  c            
           e Zd ZdZ edd           edd           edd           edd           edd           edd           ed	d
          gZdS )HCI_Cmd_LE_Connection_UpdateHCI_LE_Connection_Updater   r   rv  rw  r
  r  r  r  r2   Nr  r;   r<   r=   r  r    s        %D =1-- =33 =33 =A.. =A..<!,,<&115KKKr<   r  c                   ,    e Zd ZdZ edd          gZdS )HCI_Cmd_LE_Read_Remote_FeaturesHCI_LE_Read_Remote_Featuresr   r   Nr<  r;   r<   r=   r"  r"    s'        (D<"--.KKKr<   r"  c                   r    e Zd ZdZ edd           eddd           edd           edd	d
          gZdS )HCI_Cmd_LE_Enable_EncryptionHCI_LE_Enable_Encryptionr   r   r>  NrJ   r=  r:  r1  rP   r6   r7   r8   r9   r   r   r%   r:   r;   r<   r=   r%  r%    s]        %D<!,,##FD!44 =++##E<<<@KKKr<   r%  c                   D    e Zd ZdZ edd           eddd          gZdS )&HCI_Cmd_LE_Long_Term_Key_Request_Reply"HCI_LE_Long_Term_Key_Request_Replyr   r   r:  r1  rP   N)r6   r7   r8   r9   r   r   r:   r;   r<   r=   r)  r)     s<        /D<!,,##E<<<@KKKr<   r)  c                   ,    e Zd ZdZ edd          gZdS )/HCI_Cmd_LE_Long_Term_Key_Request_Negative_Replyz,HCI_LE_Long_Term_Key_Request _Negative_Replyr   r   Nr<  r;   r<   r=   r,  r,  &  s'        9D<!,,/KKKr<   r,  c                   L    e Zd ZdZ edd           eddd          gZd ZdS )	HCI_Event_HdrzHCI Event headerr   r   r   NrT  r  c                 L    t           |vrdS | j                            |          S r  )r  r  r  r  s     r=   r  zHCI_Event_Hdr.answers0  s*    %''5 |##E***r<   )r6   r7   r8   r9   r!   r   r:   r  r;   r<   r=   r.  r.  +  sR        D:fa((8E4S1115K+ + + + +r<   r.  c                   2    e Zd ZdZdZ edde          gZdS )HCI_Event_Inquiry_Completez&
    7.7.1 Inquiry Complete event
    HCI_Inquiry_Completer1  r   N)r6   r7   r8   r  r9   r   _bluetooth_error_codesr:   r;   r<   r=   r1  r1  8  s8          "Dh#9::KKKr<   r1  c                   *   e Zd ZdZdZ edd           edd edd          d            ed	d ed	d          d
            edd edd          d            edd e	dd          d            edd edd          d           gZ
dS )HCI_Event_Inquiry_Resultz$
    7.7.2 Inquiry Result event
    HCI_Inquiry_Resultnum_responser   addrNc                     | j         S r6  r7  r   s    r=   r  z!HCI_Event_Inquiry_Result.<lambda>J      AN r<   
count_fromr/  c                     | j         S r6  r:  r;  s    r=   r  z!HCI_Event_Inquiry_Result.<lambda>M  r<  r<   r   c                     | j         S r6  r:  r;  s    r=   r  z!HCI_Event_Inquiry_Result.<lambda>O  r<  r<   device_classc                     | j         S r6  r:  r;  s    r=   r  z!HCI_Event_Inquiry_Result.<lambda>Q  r<  r<   r0  c                     | j         S r6  r:  r;  s    r=   r  z!HCI_Event_Inquiry_Result.<lambda>S  r<  r<   )r6   r7   r8   r  r9   r   r   r'   r   r"   r:   r;   r<   r=   r5  r5  B  s          D	.$''vtZZ%=%=":":	< 	< 	<2D y!<a@@":":	< 	< 	< 	z4j!)D)D":":	< 	< 	<~t^^NA-N-N":":	< 	< 	<~t\\.!-L-L":":	< 	< 	<KKKr<   r5  c                       e Zd ZdZdZ edde           edd           edd           ed	dd
dd           eddddd          gZ	dS )HCI_Event_Connection_Completez)
    7.7.3 Connection Complete event
    HCI_Connection_Completer1  r   r      r-  N	link_typezSCO connectionzACL connectionrq  encryption_enabledzlink level encryption disabledzlink level encryption enabled)
r6   r7   r8   r  r9   r   r3  r   r'   r:   r;   r<   r=   rE  rE  W  s          %D =1.DEE<&11:i.. =a5E5E2I 2I J J =!5q%E%D"H "HI ILKKKr<   rE  c                   ^    e Zd ZdZdZ edde           edd           edd          gZ	dS ) HCI_Event_Disconnection_Completez,
    7.7.5 Disconnection Complete event
    HCI_Disconnection_Completer1  r   r   r;  N)
r6   r7   r8   r  r9   r   r3  r   r!   r:   r;   r<   r=   rK  rK  f  sV          (D =1.DEE<!,,:h**.KKKr<   rK  c                   `    e Zd ZdZdZ edde           edd           eddd	          gZ	dS )
&HCI_Event_Remote_Name_Request_Completez2
    7.7.7 Remote Name Request Complete event
     HCI_Remote_Name_Request_Completer1  r   r-  Nremote_namer  r  )
r6   r7   r8   r  r9   r   r3  r'   r   r:   r;   r<   r=   rN  rN  p  sZ          .D =1.DEE:i..##M7C@@DKKKr<   rN  c            
       l    e Zd ZdZdZ eddddi           edd           edddd	d
d          gZdS )HCI_Event_Encryption_Changez'
    7.7.8 Encryption Change event
    HCI_Encryption_Changer1  r   zchange has occurredr   enabledOFFzON (LE)zON (BR/EDR)re  N)r6   r7   r8   r  r9   r   r   r:   r;   r<   r=   rR  rR  z  sh          #D =1q2G.HII<!,, =A5Y=/Y/YZZ^KKKr<   rR  c                   b    e Zd ZdZdZ edde           edd           eddde	          gZ
dS )	1HCI_Event_Read_Remote_Supported_Features_Completez>
    7.7.11 Read Remote Supported Features Complete event
    +HCI_Read_Remote_Supported_Features_Completer1  r   r   lmp_featuresiN)r6   r7   r8   r  r9   r   r3  r   r   _bluetooth_featuresr:   r;   r<   r=   rW  rW    s[          9Dh#9::Xq!!
>1c+>??KKKr<   rW  c                       e Zd ZdZdZ edde           edd           edd           edd           edd          gZ	d	S )
2HCI_Event_Read_Remote_Version_Information_Completez?
    7.7.12 Read Remote Version Information Complete event
    #HCI_Read_Remote_Version_Informationr1  r   r   r  manufacturer_name
subversionN)
r6   r7   r8   r  r9   r   r3  r   r   r:   r;   r<   r=   r\  r\    su          1Dh#9::Xq!!	)T""(&11\6**KKKr<   r\  c                   d    e Zd ZdZdZ edd           edd           edde          gZ	d Z
dS )	HCI_Event_Command_Completez'
    7.7.14 Command Complete event
    HCI_Command_Completenumberr   r  r1  c                 N    t           |vrdS |t                    j        | j        k    S r  r  r  r  s     r=   r  z"HCI_Event_Command_Complete.answers  '    %''5_%,;;r<   N)r6   r7   r8   r  r9   r   r%   r   r3  r:   r  r;   r<   r=   ra  ra    sl          "D9Xq)) =1-- =1.DEEGK< < < < <r<   ra  c                   h    e Zd ZdZdZ eddddi           edd           edd          gZd	 Z	dS )
HCI_Event_Command_Statusz%
    7.7.15 Command Status event
    HCI_Command_Statusr1  r   pendingrc  r  Nc                 N    t           |vrdS |t                    j        | j        k    S r  re  r  s     r=   r  z HCI_Event_Command_Status.answers  rf  r<   )
r6   r7   r8   r  r9   r   r   r%   r:   r  r;   r<   r=   rh  rh    sn           D =1q)n==9Xq)) =4004K< < < < <r<   rh  c            
           e Zd ZdZdZ edd           edd edd          d 	           ed
d edd          d 	          gZdS )%HCI_Event_Number_Of_Completed_Packetsz2
    7.7.19 Number Of Completed Packets event
    HCI_Number_Of_Completed_Packetsnum_handlesr   connection_handle_listNrV  c                     | j         S r6  ro  r;  s    r=   r  z.HCI_Event_Number_Of_Completed_Packets.<lambda>      q} r<   r=  num_completed_packets_listnum_completed_packetsc                     | j         S r6  rr  r;  s    r=   r  z.HCI_Event_Number_Of_Completed_Packets.<lambda>  rs  r<   )	r6   r7   r8   r  r9   r   r   r   r:   r;   r<   r=   rm  rm    s          -D9]A..!>":D".,/BA"F"F-D-DF F F ">">".,/F"J"J-D-DF F F	GKKKr<   rm  c                   0    e Zd ZdZdZ edd          gZdS )HCI_Event_Link_Key_Requestz'
    7.7.23 Link Key Request event
    HCI_Link_Key_Requestr-  Nr8  r;   r<   r=   rx  rx    s5          "D
9d##KKKr<   rx  c                       e Zd ZdZdZ edd           edded            ed	ded
            edded            edde	d            edded            edde
d           gZdS )"HCI_Event_Inquiry_Result_With_Rssiz/
    7.7.33 Inquiry Result with RSSI event
    HCI_Inquiry_Result_with_RSSIr7  r   r-  Nc                     | j         S r6  r:  r;  s    r=   r  z+HCI_Event_Inquiry_Result_With_Rssi.<lambda>  r<  r<   r=  r/  c                     | j         S r6  r:  r;  s    r=   r  z+HCI_Event_Inquiry_Result_With_Rssi.<lambda>  r<  r<   r   c                     | j         S r6  r:  r;  s    r=   r  z+HCI_Event_Inquiry_Result_With_Rssi.<lambda>  r<  r<   rA  c                     | j         S r6  r:  r;  s    r=   r  z+HCI_Event_Inquiry_Result_With_Rssi.<lambda>  r<  r<   r0  c                     | j         S r6  r:  r;  s    r=   r  z+HCI_Event_Inquiry_Result_With_Rssi.<lambda>  r<  r<   rssic                     | j         S r6  r:  r;  s    r=   r  z+HCI_Event_Inquiry_Result_With_Rssi.<lambda>  r<  r<   )r6   r7   r8   r  r9   r   r   r'   r   r"   r   r:   r;   r<   r=   r{  r{    s          *D	.$''y$
":":	< 	< 	<2D)":":	< 	< 	<z4":":	< 	< 	<~t^":":	< 	< 	<~t\":":	< 	< 	<vt_":":	< 	< 	<KKKr<   r{  c                       e Zd ZdZdZ edde           edd           edd           edd           e	dd          gZ
d	S )
0HCI_Event_Read_Remote_Extended_Features_Completez=
    7.7.34 Read Remote Extended Features Complete event
    *HCI_Read_Remote_Extended_Features_Completer1  r   r   pagemax_pager   N)r6   r7   r8   r  r9   r   r3  r   r   r#   r:   r;   r<   r=   r  r    su          8Dh#9::Xq!!	&$	*d##(!,,KKKr<   r  c            
           e Zd ZdZdZ edd           edd           edd           ed	d           ed
d           edd           e	dd          e
gZdS )!HCI_Event_Extended_Inquiry_Resultz.
    7.7.38 Extended Inquiry Result event
    HCI_Extended_Inquiry_Resultr7  r.   r-  Nr/  r   r   rA  r0  r  )r6   r7   r8   r  r9   r   r'   r"   r   r   r  r:   r;   r<   r=   r  r    s          )D	.$''
9d##	-t44	*d##~x00^V,,%%%	KKKr<   r  c                   r    e Zd ZdZdZ edd           edd           edd           edd          gZdS )	 HCI_Event_IO_Capability_Responsez-
    7.7.41 IO Capability Response event
    HCI_IO_Capability_Responser-  Nrt  r   rv  authentication_requirementsr=  r;   r<   r=   r  r    sd          (D
9d##	/4((	$d++	/66	KKKr<   r  c            	       B    e Zd ZdZdZ eddddddd	          gZd
 ZdS )HCI_Event_LE_Metaz
    7.7.65 LE Meta event
    HCI_LE_Metaeventr   connection_completeadvertising_reportconnection_update_completelong_term_key_request)r.   r/   r0   rD   c                 H    | j         sdS | j                             |          S r  )r  r  r  s     r=   r  zHCI_Event_LE_Meta.answers$  s)    | 	5 |##E***r<   N)r6   r7   r8   r  r9   r   r:   r  r;   r<   r=   r  r    sd          D =!+*2-	. .   K+ + + + +r<   r  c                   4    e Zd ZdZdZ eddd          gZdS ) HCI_Cmd_Complete_Read_Local_Namez1
    7.3.12 Read Local Name command complete
    z Read Local Name command completer  rO  r  r  Nr  r;   r<   r=   r  r  ,  s9          .D##L"SAAABKKKr<   r  c                       e Zd ZdZdZ edd           edd           edd           edd           edd          gZd	S )
/HCI_Cmd_Complete_Read_Local_Version_Informationz?
    7.4.1 Read Local Version Information command complete
    zRead Local Version Informationhci_versionr   hci_subversionlmp_versioncompany_identifierlmp_subversionN)r6   r7   r8   r  r9   r   r   r:   r;   r<   r=   r  r  4  st          ,D	-##%q))	-##)1--%q))+KKKr<   r  c                   \    e Zd ZdZdZ edd           edd           edd          gZdS )-HCI_Cmd_Complete_Read_Local_Extended_Featuresz=
    7.4.4 Read Local Extended Features command complete
    z-Read Local Extended Features command completer  r   r  r   N)r6   r7   r8   r  r9   r   r#   r:   r;   r<   r=   r  r  A  sT          ;D	&$	*d##(!,,KKKr<   r  c                   0    e Zd ZdZdZ edd          gZdS )HCI_Cmd_Complete_Read_BD_Addrz-
    7.4.6 Read BD_ADDR command complete
    zRead BD Addrr8  Nr8  r;   r<   r=   r  r  M  s3          D:fd++.KKKr<   r  c                   B    e Zd ZdZ edd           edd          gZdS )(HCI_Cmd_Complete_LE_Read_White_List_SizezLE Read White List Sizer1  r   sizeNr  r;   r<   r=   r  r  U  s8        $D9Xq))9VQ''+KKKr<   r  c                       e Zd ZdZ eddddi           edd           eddddi           eddd	d
d           edd           edd           edd           edd           edd          g	Zd Z	dS )HCI_LE_Meta_Connection_CompletezConnection Completer1  r   r*  r   r<  masterr  rE  r5  rq  r	  Nr  rv   r
  supervisionrj   clock_latencyrD   c                     t           |vrdS |t                    j        | j        k    o|t                    j        | j        k    S r  )r  r  r	  r  s     r=   r  z'HCI_LE_Meta_Connection_Complete.answersg  sD    'u44523:dkI H239TZG	Ir<   )
r6   r7   r8   r9   r   r   r'   r!   r:   r  r;   r<   r=   r  r  [  s         D =1q)n==<!,, =QM:: =1(x.H.HII:gt,,<
B//<	1--<r22:oq115KI I I I Ir<   r  c                       e Zd ZdZ eddddi           edd           edd           edd           ed	d
          gZdS )&HCI_LE_Meta_Connection_Update_CompletezConnection Update Completer1  r   r*  r   r  rv   r
  r  rj   N)r6   r7   r8   r9   r   r   r:   r;   r<   r=   r  r  o  sk        'D =1q)n==<!,,<
B//<	1--<	2..	2KKKr<   r  c            
           e Zd ZdZ eddddd           edddd	d
           edd           edddd           edg ed            e	dd          gZ
d ZdS )HCI_LE_Meta_Advertising_ReportzAdvertising Reportr   r   conn_undscan_rsp)r   r1   rD  rE  r5  rq  r8  Nr   rN  rT  r  c                     | j         S r6  r  r  s    r=   r  z'HCI_LE_Meta_Advertising_Report.<lambda>  s    37 r<   r  r  c                 
    d|fS )NrO  r;   r  s     r=   r  z.HCI_LE_Meta_Advertising_Report.extract_padding  s    1ur<   )r6   r7   r8   r9   r   r'   r   r   rS  r   r:   r  r;   r<   r=   r  r  x  s        D =
z,J,JKK =!h-G-GHH:fd++ =CHHH"?62w/B/BD D D"?61--/K    r<   r  c                   P    e Zd ZdZ edddd           edded           gZdS )	HCI_LE_Meta_Advertising_ReportszAdvertising Reportsr   NreportsrT  )count_ofrW  c                     | j         S r6  r  r  s    r=   r  z(HCI_LE_Meta_Advertising_Reports.<lambda>  s    #' r<   r=  )r6   r7   r8   r9   r   r   r  r:   r;   r<   r=   r  r    sU         D =ycJJJ"?9d#A.A.AC C CDKKKr<   r  c                   Z    e Zd ZdZ edd           eddd           edd          gZdS )!HCI_LE_Meta_Long_Term_Key_RequestzLong Term Key Requestr   r   r>  NrJ   r=  r'  r;   r<   r=   r  r    sJ        "D<!,,##FD!44 =++/KKKr<   r  r[  r
  R   l   m   r  )r   i  )r  i  i  i	  i   )r  r  )r   )r  c            	           e Zd ZdZ eddi dddddd	d
dddddddddddddddddddddd d!d"d#d$d%d&d'd(d)           ed*d           ed+d          gZdS ),HCI_Mon_Hdrz(Bluetooth Linux Monitor Transport Headerr  Nr   z	New indexr.   zDelete indexr/   zCommand pktr0   z	Event pktr1   z
ACL TX pktrD   z
ACL RX pktrH   z
SCO TX pktrI   z
SCO RX pktrJ   z
Open indexrK   zClose indexrL   z
Index inforM   zVendor diagrN   zSystem noterO   zUser loggingrE   z	Ctrl openrF   z
Ctrl closerP   zCtrl commandz
Ctrl eventz
ISO TX pktz
ISO RX pkt)rQ   rR   rS   
adapter_idr   r%  r;   r<   r=   r  r  |	  s5       5D4 *
{*
~*
 }*
 {	*

 |*
 |*
 |*
 |*
 |*
 }*
 *
 *
 *
 *
 *
  !*
" #*
$ )*
 *
 *
 	 	, 	\4((UD!!1KKKr<   r  c                   B    e Zd ZdZ edd           edd          gZdS )HCI_Mon_Pcap_Hdrz-Bluetooth Linux Monitor Transport Pcap Headerr  Nr  )r6   r7   r8   r9   r   r:   r;   r<   r=   r  r  	  s8        :D
<&&
8T""KKKr<   r  c                       e Zd ZdZ eddddd           edddd	d
ddddd           edd           eddd          gZdS )HCI_Mon_New_Indexz2Bluetooth Linux Monitor Transport New Index Packetbusr   zBR/EDRAMPrq  r   VirtualUSBzPC CardUARTRS232PCISDIOrn  r8  NdevnamerJ   )r6   r7   r8   r9   r   r'   r   r:   r;   r<   r=   r  r  	  s        ?DeQ!
 !
 	 	 	fa"
 "
 	 	 	
64  D!,,KKKr<   r  c                   B    e Zd ZdZ edd           edd          gZdS )HCI_Mon_Index_Infoz3Bluetooth Linux Monitor Transport Index Info Packetr8  Nmanufacturer)r6   r7   r8   r9   r'   r%   r:   r;   r<   r=   r  r  	  s8        @D
64  nd++KKKr<   r  c                   ,    e Zd ZdZ edd          gZdS )HCI_Mon_System_Notez4Bluetooth Linux Monitor Transport System Note PacketnoteN)r6   r7   r8   r9   r   r:   r;   r<   r=   r  r  	  s)        ADVT""KKKr<   r  c                   X    e Zd ZdZ e             eddg          z  gZd Zd Zd Z	dS )	LowEnergyBeaconHelpera  
    Helpers for building packets for Bluetooth Low Energy Beacons.

    Implementers provide a :meth:`build_eir` implementation.

    This is designed to be used as a mix-in -- see
    ``scapy.contrib.eddystone`` and ``scapy.contrib.ibeacon`` for examples.
    r  r   )r?  c                      t          d          )z
        Builds a list of EIR messages to wrap this frame.

        Users of this helper must implement this method.

        :return: List of HCI_Hdr with payloads that describe this beacon type
        :rtype: list[scapy.bluetooth.HCI_Hdr]
        	build_eir)NotImplementedErrorr   s    r=   r  zLowEnergyBeaconHelper.build_eir	  s     "+...r<   c                 J    t          dd|                                           S )z
        Builds a HCI_LE_Meta_Advertising_Report containing this frame.

        :rtype: scapy.bluetooth.HCI_LE_Meta_Advertising_Report
        r   r.   )r   rD  rN  )r  r  r   s    r=   build_advertising_reportz.LowEnergyBeaconHelper.build_advertising_report	  s.     .!!
 
 
 	
r<   c                     t                      t                      z  t          |                                           z  S )zBuilds a HCI_Cmd_LE_Set_Advertising_Data containing this frame.

        This includes the :class:`HCI_Hdr` and :class:`HCI_Command_Hdr` layers.

        :rtype: scapy.bluetooth.HCI_Hdr
        )rN  )r   r  r  r  r   s    r=   build_set_advertising_dataz0LowEnergyBeaconHelper.build_set_advertising_data	  s?     yy?,,,/N!!0
 0
 0
 
 	
r<   N)
r6   r7   r8   r  rS  r  base_eirr  r  r  r;   r<   r=   r  r  	  s          		II3-5 6 6 6 6 9H	/ 	/ 	/
 
 


 

 

 

 

r<   r  c                       e Zd ZdS )BluetoothSocketErrorNr6   r7   r8   r;   r<   r=   r  r  
          Dr<   r  c                       e Zd ZdS )BluetoothCommandErrorNr  r;   r<   r=   r  r  
  r  r<   r  c                   "    e Zd ZdZd ZefdZdS )BluetoothL2CAPSocketz.read/write packets on a connected L2CAP socketc                     t           rt          d           d S t          j        t          j        t          j        t          j                  }|                    |df           |x| _        | _        d S )NNot available on Windowsr   )	r,   r-   socketAF_BLUETOOTHSOCK_RAWBTPROTO_L2CAPconnectinsouts)r   
bt_addressr  s      r=   r  zBluetoothL2CAPSocket.__init__
  sf     	.///FM&-v .0 0			:q/"""  4999r<   c                 P    t          | j                            |                    S r6  )r   r  recvr   rV  s     r=   r  zBluetoothL2CAPSocket.recv 
  s    DHMM!,,---r<   Nr6   r7   r8   descr  r+   r  r;   r<   r=   r  r  
  sA        ;D! ! !  . . . . . .r<   r  c                       e Zd ZdZddZdS )BluetoothRFCommSocketz/read/write packets on a connected RFCOMM socketr   c                     t          j         t           j        t           j        t           j                  }|                    ||f           |x| _        | _        d S r6  )r  r  r  BTPROTO_RFCOMMr  r  r  )r   r  portr  s       r=   r  zBluetoothRFCommSocket.__init__'
  sK    M&-v /1 1			:t$%%%  4999r<   Nr   )r6   r7   r8   r  r  r;   r<   r=   r  r  $
  s.        99! ! ! ! ! !r<   r  c                   $    e Zd ZdZddZefdZdS )BluetoothHCISocketz$read/write on a BlueTooth HCI socket   Nc                    t           rt          d           d S t          j        t          j        t          j        t          j                  }|                    t          j        t          j        d           |                    t          j        t          j	        d           |                    t          j        t          j
        t          j        ddddd                     |                    |f           |x| _        | _        d S )Nr  r.   IIIh2xl    r   )r,   r-   r  r  r  BTPROTO_HCI
setsockoptSOL_HCIHCI_DATA_DIRHCI_TIME_STAMP
HCI_FILTERr   r   bindr  r  )r   ifacer   r  s       r=   r  zBluetoothHCISocket.__init__1
  s     	.///FM&-v@RSS	V^V%8!<<<	V^V%:A>>>	V^V%6HjZdfprs8t8tuuu	x  4999r<   c                 P    t          | j                            |                    S r6  r   r  r  r  s     r=   r  zBluetoothHCISocket.recv=
      tx}}Q''(((r<   )r   Nr  r;   r<   r=   r  r  .
  sF        1D	! 	! 	! 	!  ) ) ) ) ) )r<   r  c                   B    e Zd Zdej        fdej        fdej        fgZdS )sockaddr_hci
sin_familyhci_devhci_channelN)r6   r7   r8   ctypesc_ushort_fields_r;   r<   r=   r  r  A
  s3        	v'	FO$	(HHHr<   r  c                   (    e Zd Zd ZddZd Zd ZdS )_BluetoothLibcSocketc           	         t           rt          d           d S t          j        t                    }ddlm} t          j                             |d                    }|j	        }t          j
        t          j
        t          j
        f|_        t          j
        |_        |j        }	t          j
        t          j        t                    t          j
        f|	_        t          j
        |	_         ||||          }
|
dk     rt          d| d| d| d           |	|
 ||          t          |                    }|dk    rt          d          |
| _        t          j        |
|||          x| _        | _        d S )	Nr  r   find_libraryczUnable to open socket(z, )zUnable to bind)r,   r-   r  POINTERr  ctypes.utilr  cdllLoadLibraryr  c_intargtypesrestyper	  r  r   hci_fdfromfdr  r  )r   socket_domainsocket_typesocket_protocolsock_addresssockaddr_hcipr  libcsocket_cr	  r  rs               r=   r  z_BluetoothLibcSocket.__init__J
  s    	.///F |44,,,,,,{&&||C'8'899;#\6<F!<y55' | H]KAAq55&& & &+ & &"& & &' ' '
 DMM,//1E1EFF66&'7888%}}k? <  < 	<4999r<   r   c                 j    t          j         | j        gg g |          \  }}}t          |          dk    S r  )selectr  r   )r   r  r  _s       r=   readablez_BluetoothLibcSocket.readablep
  s1    mTXJB@@a3xx!|r<   c                     |                                  r*|                                  |                                  (d S d S r6  )r1  r  r   s    r=   flushz_BluetoothLibcSocket.flusht
  sE    mmoo 	IIKKK mmoo 	 	 	 	 	r<   c                    | j         rd S ddlm} t          j                             |d                    }|j        }t          j        |_        d| _         t          | d          rmt          | d          r| j
        | j        k    rM| j        rFt          s| j                                        dk    r" || j                                                   t          | d          rM| j
        rFt          s| j
                                        dk    r" || j
                                                   t          | d          r || j                   d S d S )	Nr   r  r  Tr  r  r$  )closedr  r  r  r  r   closer!  r#  r  r  r  r,   filenor$  )r   r  r+  r7  s       r=   r7  z_BluetoothLibcSocket.closex
  s]   ; 	F 	-,,,,,{&&||C'8'899
4   	.4'' .48ty+@+@9 .' .TY-=-=-?-?2-E-EE$)**,,---4 	)x )W )(9(9R(?(?dhoo''(((4"" 	E$+	 	r<   Nr  )r6   r7   r8   r  r1  r3  r7  r;   r<   r=   r  r  I
  sV        $< $< $<L         r<   r  c                   4     e Zd ZdZd fd	Zd ZefdZ xZS )BluetoothUserSocketz+read/write H4 over a Bluetooth user channelr   c                     t                      }t          j        |_        ||_        t
          |_        t                                          t          j        t          j	        t          j
        |           d S N)r&  r'  r(  r)  )r  r  r  r  r  HCI_CHANNEL_USERr  r  r  r  r  )r   adapter_indexsar  s      r=   r  zBluetoothUserSocket.__init__
  sc    ^^+"
) -".	 	 	 	 	 	 	r<   c                     |j         }|                     |           	 |                                 }|j        dk    r<|j        dk    r1|j         |k    r&|j        dk    rt          d||j        fz            |S \)NTr1   rE   r   zCommand %x failed with %x)r  sendr  r   r   r1  r  )r   cmdr  r-  s       r=   send_commandz BluetoothUserSocket.send_command
  s}    		#			Av~~!&C--AH4F4F8q==/0KvWXW_N`0`aaa	r<   c                 P    t          | j                            |                    S r6  r  r  s     r=   r  zBluetoothUserSocket.recv
  r  r<   r  )	r6   r7   r8   r  r  rC  r+   r  r  r  s   @r=   r:  r:  
  sj        8D	 	 	 	 	 	    ) ) ) ) ) ) ) )r<   r:  c                   ,     e Zd ZdZ fdZefdZ xZS )BluetoothMonitorSocketz+Read/write over a Bluetooth monitor channelc                     t                      }t          j        |_        t          |_        t          |_        t                      	                    t          j        t          j
        t          j        |           d S r<  )r  r  r  r  HCI_DEV_NONEr  HCI_CHANNEL_MONITORr  r  r  r  r  )r   r?  r  s     r=   r  zBluetoothMonitorSocket.__init__
  sc    ^^+!
, -".	 	 	 	 	 	 	r<   c                 P    t          | j                            |                    S r6  )r  r  r  r  s     r=   r  zBluetoothMonitorSocket.recv
  s    48==++,,,r<   )r6   r7   r8   r  r  r+   r  r  r  s   @r=   rF  rF  
  sV        8D	 	 	 	 	  - - - - - - - -r<   rF  皙?c                     d|v r*t          j        | |                    d                    }nt          j        |           }t          ||g|R d|i|\  }}|                                 ||fS )z)send and receive using a bluetooth socketr  )r  r  )r  inter)r   BTsocketpopr*   r7  )r  pktsrM  r  r  r  abs           r=   srbtrS  
  s     MZeii6G6GHHHMZ000!T7777777DAqGGIIIa4Kr<   c                 p    t          | |g|R i |\  }}t          |          dk    r|d         d         S dS )z2send and receive 1 packet using a bluetooth socketr   r.   N)rS  r   )r  rP  r  r  rQ  rR  s         r=   srbt1rU  
  sJ     
D14111511DAq
1vvzztAw zr<   )rK  (  r  r  r  r  r   r/  r   scapy.configr   
scapy.datar   r   r   scapy.packetr   r	   scapy.fieldsr
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   scapy.supersocketr)   scapy.sendrecvr*   r+   scapy.constsr,   scapy.errorr-   HCI_CHANNEL_RAWr=  rI  HCI_CHANNEL_CONTROLHCI_CHANNEL_LOGGINGrH  r4   r   r3  r  rZ  r   r   r   r   r  r'  r:  r>  rA  rG  rI  rM  rR  rT  rX  r]  r`  rh  rl  rp  rs  ru  r{  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r  r  r  r-  r/  r4  r7  r9  r<  r@  rC  rI  rL  rP  rS  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r#  r(  r+  r3  r6  r:  r?  rB  rG  rK  rR  rU  rX  r\  ra  rd  rg  rj  rm  rp  rs  ry  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r"  r%  r)  r,  r.  r1  r5  rE  rK  rN  rR  rW  r\  ra  rh  rm  rx  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  l2typesregisterr  r  r  r  r  r  BaseExceptionr  r  r  r  r  	Structurer  r  r:  rF  rN  commandsrS  rU  r;   r<   r=   <module>rf     s?                                
 - , , , , , , ,                                                                                                                                   B * ) ) ) ) ) ! ! ! ! ! !                             - - - - -6 - - - 	 	 H)H
H 	
)H 	
	H
 	.H 	
"H 	
H 	
$H 	
H 	
%H 	
=H 	
%H 	
H 	
8H 	
7H  	
;!H" 	
.#H H$ 	
2%H& 	
*'H( 	
-)H* 	
D+H, 	
@-H. 	
//H0 	
1H2 	
3H4 	
5H6 	
@7H8 	
9H: 	
!;H< 	
!=H> 	
:?H@ 	
AHB 	
LCHD 	
#EH H HF 	
6GHH 	
DIHJ 	
KHL 	
*MHN 	
&OHP 	
'QHR 	
SHT 	
/UHV 	
+WHX 	
#YHZ 	
&[H\ 	.]H^ 	
0_H` 	
!aHb 	
,cHd 	
#eHf 	
gH H Hh 	
#iHj 	
#kHl 	
mHn 	
/oHp 	
7qHr 	
sHt 	
@uHv 	
wHx 	
.yHz 	
{H| 	
4}H~ 	
IH@ 	
!AHB 	 CHF 	
$GHH 	
*IHJ 	/KH HL (
OH H H T

 	
 	-	
 	
 	
 	
 	
 	
 	
 	/ 	
! 	
 	* 	
  	
 !" 	
"# (A A A H* * * * *f * * *    &   	 	 	 	 	 	 	 	. . . . .6 . . .b    F   ,
L 
L 
L 
L 
LV 
L 
L 
L    6       F   	0 	0 	0 	0 	0V 	0 	0 	0. . . . .v . . .' ' ' ' ' ' ' '+ + + + +F + + +
+ + + + +V + + +
    F   ' ' ' ' 'V ' ' '4 4 4 4 46 4 4 4,7 7 7 7 7F 7 7 7&9 9 9 9 9 9 9 9
H 
H 
H 
H 
H& 
H 
H 
HI I I I If I I I. . . . .v . . .
6 6 6 6 6 6 6 65 5 5 5 5 5 5 5
9 9 9 9 9v 9 9 9H H H H H H H H&1 1 1 1 1F 1 1 1. . . . .F . . .. . . . .V . . .(. . . . .V . . .G G G G Gf G G G1 1 1 1 1f 1 1 1
              B B B B B B B B- - - - -v - - -
- - - - - - - -
3 3 3 3 36 3 3 3    F    + + + + +V + + +? ? ? ? ?f ? ? ?
/ / / / /f / / /0 0 0 0 0v 0 0 0    &          &6 6 6 6 6v 6 6 6
* * * * * * * *
H H H H H H H H
+ + + + + + + +
/ / / / /V / / /+ + + + +f + + ++ + + + + + + ++ + + + + + + +              $ $ $ $ $!: $ $ $, , , , ,F , , ,       $ $ $ $ $ $ $ $    F       V       &   2 2 2 2 2V 2 2 2
A A A A A A A AA A A A A& A A AB B B B B B B B
A A A A A A A A
, , , , , , , ,
@ @ @ @ @ @ @ @
? ? ? ? ?v ? ? ?@ @ @ @ @f @ @ @
2 2 2 2 2f 2 2 2A A A A AV A A A
B B B B BF B B BH H H H HV H H H
>A >A >A >A >Af >A >A >AB& & & & && & & &     k                 5 5 5 5 5*K 5 5 5       5 5 5 5 5*K 5 5 5       6 6 6 6 6+M 6 6 6    K   " " " " "2 " " "0 0 0 0 0 0 0 0
       D/ / / / /k / / /
5 5 5 5 5K 5 5 5
    +       K   =" =" =" =" ="[ =" =" ="@    K   
" 
" 
" 
" 
"{ 
" 
" 
"	" 	" 	" 	" 	"{ 	" 	" 	"	" 	" 	" 	" 	" 	" 	" 	"    f   .    F   $2 2 2 2 2f 2 2 2         V      	2 	2 	2 	2 	2F 	2 	2 	2, , , , , , , ,
: 
: 
: 
: 
: 
: 
: 
:0 0 0 0 0 0 0 02 2 2 2 2v 2 2 2- - - - - - - -/ / / / / / / /8 8 8 8 8V 8 8 82 2 2 2 2f 2 2 2C C C C CV C C C2 2 2 2 2f 2 2 25 5 5 5 5F 5 5 5. . . . .v . . .Q Q Q Q Q Q Q Q0 0 0 0 0 0 0 0R R R R R R R R8 8 8 8 8& 8 8 82 2 2 2 2 2 2 2> > > > >V > > >5 5 5 5 5F 5 5 5O O O O O& O O O.2 2 2 2 2f 2 2 22 2 2 2 2v 2 2 28 8 8 8 8 8 8 82 2 2 2 2& 2 2 2< < < < <F < < <2 2 2 2 2V 2 2 2E E E E E E E EU U U U UV U U U    F   = = = = =v = = == = = = =v = = =! ! ! ! !f ! ! !3 3 3 3 36 3 3 3
2 2 2 2 2f 2 2 2& & & & &6 & & &- - - - -F - - -0 0 0 0 0V 0 0 00 0 0 0 06 0 0 0    6   . . . . . . . .
. . . . . . . .$ $ $ $ $ $ $ $A A A A A& A A A* * * * *V * * ** * * * *V * * *2 2 2 2 2v 2 2 20 0 0 0 0F 0 0 0
	^ 	^ 	^ 	^ 	^F 	^ 	^ 	^3 3 3 3 3f 3 3 3O O O O O O O O+ + + + +f + + +
	K 	K 	K 	K 	KV 	K 	K 	K2 2 2 2 2 2 2 20 0 0 0 06 0 0 0 - - - - -& - - -1 1 1 1 1f 1 1 1- - - - -& - - -0 0 0 0 0& 0 0 0: : : : :7b : : :5 5 5 5 56 5 5 5/ / / / /f / / /
@ @ @ @ @6 @ @ @@ @ @ @ @V @ @ @0 0 0 0 0f 0 0 0

+ 
+ 
+ 
+ 
+F 
+ 
+ 
+           v   *L L L L LF L L L. . . . .v . . .D D D D DV D D D^ ^ ^ ^ ^& ^ ^ ^	 	 	 	 	 	 	 	       < < < < < < < < < < < < <v < < < G G G G GF G G G              ,    v          "
 
 
 
 
v 
 
 
+ + + + + + + +(C C C C Cv C C C
+ 
+ 
+ 
+ 
+f 
+ 
+ 
+	 	 	 	 	F 	 	 	/ / / / /F / / /+ + + + +v + + +I I I I If I I I(2 2 2 2 2V 2 2 2    V   D D D D Df D D D/ / / / / / / / L' " " " G_1 - - - - G[q ) ) ) ) G] + + + + GT^ % % %   *G 4 4 4   4l C C C O_$F C C C C O36 J J J J O:& Q Q Q Q O>Df U U U U O6Df M M M M O/Tv F F F F O=4V T T T T O>Df U U U U O?Tv V V V V O;6 R R R R OD&" " " " O;6 R R R R OB&" " " " O=4V T T T T O>Df U U U U O?Tv V V V V O8d O O O O O?Tv V V V V OC&" " " " OB&" " " " O@dPV W W W W OD&" " " " OM&" " " " O?Tv V V V V OH&" " " " OB&" " " " OK&" " " " O.Df E E E E O36 J J J J O]& A A A A O54V L L L L O54V L L L L O4$F K K K K OAtQW X X X X OD$TZ [ [ [ [ O9t P P P P O:& Q Q Q Q OCSY Z Z Z Z OAtQW X X X X O1t H H H H O6Df M M M M O.Df E E E E O7Tv N N N N O8d O O O O O;6 R R R R O;6 R R R R OE&" " " " O:& Q Q Q Q OBRX Y Y Y Y O<$F S S S S O>Df U U U U O<$F S S S S O;6 R R R R O7Tv N N N N O9t P P P P O@dPV W W W W OD&" " " " O@dPV W W W W OHdX^ _ _ _ _ OMSW]c d d d d O9t P P P P O<$F S S S S O9t P P P P OCSY Z Z Z Z OLRV\b c c c c M5D A A A A M3$ ? ? ? ? M8t D D D D M;$ G G G G MA M M M M M6T B B B B MLSW X X X X MMTX Y Y Y Y M5D A A A A M3$ ? ? ? ? M@t L L L L M5D A A A A M=D I I I I MKRV W W W W M<4 H H H H M;$ G G G G M,4 8 8 8 8 &(HQW X X X X &(W`f g g g g &(U^d e e e e &(Ef U U U U &(PY_ ` ` ` ` >a H H H H >a H H H H EQ O O O O @ J J J J GYT * * * * G8t D D D D G6T B B B B G8t D D D D G6T B B B B G9 E E E E G7d C C C C G+$ 7 7 7 7 G* 6 6 6 6 G] . . . . G'd 3 3 3 3 G&T 2 2 2 2 G44 @ @ @ @ G: F F F F G0t < < < < G: F F F F G-D 9 9 9 9 G-D 9 9 9 9 G.T : : : : G3$ ? ? ? ? GW    K $ $ $ I| + + + + I| + + + + L,Q / / / / L-a 0 0 0 0 L.q 1 1 1 1 L-a 0 0 0 0 L.q 1 1 1 1 L* 3 3 3 3 L+! 4 4 4 4 L-a 0 0 0 0 L.q 1 1 1 1 L-b 1 1 1 1 L.r 2 2 2 2 L6R @ @ @ @ L7b A A A A L42 > > > > L5B ? ? ? ? LA K K K K LB L L L L LC" M M M M LD2 N N N N LB L L L L LC" M M M M L7b A A A A L?b I I I I L@r J J J J L@r J J J J LA K K K K IwA & & & & G' 4 4 4 4 G-c : : : : G.s ; ; ; ; G1# > > > > G23 ? ? ? ? G3C @ @ @ @ G4S A A A A G4S A A A A G-c : : : : G.s ; ; ; ; G%c 2 2 2 2 G&s 3 3 3 3 G*3 7 7 7 7 G+C 8 8 8 8 G.s ; ; ; ; G/ < < < < G3D A A A A G4T B B B B G&t 4 4 4 4 G' 5 5 5 5 G.t < < < < G/ = = = = G.t < < < < G/ = = = = G&t 4 4 4 4 G24 @ @ @ @ G0 > > > > Iv1 % % % % F&1 5 5 5 5 F'A 6 6 6 6 FJ1 - - - - FI! , , , , FI! , , , , F-! < < < < F, ; ; ; ; F+ : : : : F3 B B B B F*t < < < < FMd 3 3 3 3 FNt 4 4 4 4    &   >    {          *           &    K*1 5 5 5 5 K 3 3 3 3 Kq 1 1 1 1 K+B 7 7 7 7 K,R 8 8 8 8   13C D D D0
 0
 0
 0
 0
 0
 0
 0
n	 	 	 	 	= 	 	 		 	 	 	 	M 	 	 	. . . . .; . . . ! ! ! ! !0 ! ! !) ) ) ) ) ) ) )&    6#   B B B B B; B B BJ) ) ) ) ). ) ) )8- - - - -1 - - -$ &
         r<   