def __arpMonitorThread()

in src/tashi/nodemanager/nodemanagerservice.py [0:0]


	def __arpMonitorThread(self, conf):
		try:
			pc = pcap.pcap()
			# Look for ARP or DHCP traffic
			pc.setfilter('arp or udp port 67')
	
			for ts, pkt in pc:
				e = dpkt.ethernet.Ethernet(pkt)
				if e.type == dpkt.ethernet.ETH_TYPE_IP:
					ip = e.data
					udp = ip.data
					dhcp = dpkt.dhcp.DHCP(udp.data)
					if dhcp.op == dpkt.dhcp.DHCPACK or dhcp.op == dpkt.dhcp.DHCPOFFER:
						macaddress = self.__stringToMac(dhcp.chaddr)
						ipaddress = socket.inet_ntoa(pack("!I",dhcp.ciaddr))
						self.__updateInstanceIp(macaddress, ipaddress)
				elif e.type == dpkt.ethernet.ETH_TYPE_ARP:
					a = e.data
					if a.op == dpkt.arp.ARP_OP_REPLY:
						ipaddress = socket.inet_ntoa(a.spa)
						macaddress = self.__stringToMac(a.sha)
						self.__updateInstanceIp(macaddress, ipaddress)
		except:
			self.log.exception('arpMonitorThread threw an exception')