Newer
Older
dhcp2MQTT / docker / dash-listen.py
# sudo apt-get install python-scapy tcpdump tcpreplay wireshark

# Note that wireshark prompts during installation if non-root users
# should be allowed to perform packed capture.

from scapy.all import *
import os
#import requests

DASH_MAC_ADDRESS=os.environ.get('DASH_MAC_ADDRESS')
DASH_INTERFACE=os.environ.get('DASH_INTERFACE')
#URL_CALLBACK=os.environ.get('URL_CALLBACK')

def arp_display(pkt):
	if (pkt.haslayer(DHCP)):
		if (pkt[Ether].src == DASH_MAC_ADDRESS):
			#requests.get(URL_CALLBACK)
			print "DHCP from " + pkt[Ether].src
		# end if
	# end if
# end apr_display


while True:
	try:
		print sniff(prn=arp_display, iface=DASH_INTERFACE, filter="ip", store=0, count=0)
	except:
		pass
	# end try
# end while