oremanj/python-netfilterqueue

using scapy with nfq

Pooshkis opened this issue · 1 comments

I have a code (well, part of it):

def decode_message(pkt):
    bind_layers(UDP, RTP, sport=10000)
    #pkt.decode_payload_as(RTP)
    if pckt[RTP].version == 1:
        mesg = pckt[RTP].load
        word = str(mesg[-1])
        char_bin = word.encode(encoding="utf-8")
        char_hex = char_bin.hex()
        char_bin_str = format(int(char_hex, 16), "08b")
    return char_bin_str[-1]

And I get an error:

Traceback (most recent call last):
  File "payload_read.py", line 14, in decode_message
    if pckt[RTP].version == 1:
TypeError: 'netfilterqueue.Packet' object is not subscriptable

pkt.decode_payload_as(RTP) and if pckt[RTP].version == 1: works great while I don't use Netfilterqueue (those are used with scapy library).
Any ideas how could I disect packets with scapy while using netfilterqueue? How can I separate where packet is used by netfilterqueue and where (same packet) by scapy (Don't know any other place where I could ask)

Figured out..