def listen(): s = socket.socket(socket.AF_INET,socket.SOCK_RAW,socket.IPPROTO_ICMP) s.setsockopt(socket.SOL_IP, socket.IP_HDRINCL, 1) ClientTable = '/var/www/cgi-bin/ClientTable.txt' RapTestTable = '/var/www/cgi-bin/RapTable.txt' while 1: data, addr = s.recvfrom(1508) #print s.recvfrom(1508) if addr == ('192.168.0.40',0): rcvData = data[28:] rcvData = rcvData.rstrip(' \t\r\n\0') data = rcvData.split(',') print "Data Received: ", data #print "Lenth of Received Data: ", len(data) #if len(data) > 4: if data[0]=='l': #load print "Loading Table Data" print rcvData c_handle = ClientTable_Handler() c_handle.add_entry(rcvData) elif data[0] == 'e': #edit print "Editing Table" print rcvData mac,keyID = data[1],data[5] c_handle = ClientTable_Handler() c_handle.edit_entry(mac, keyID,rcvData) elif data[0] == 'a': #acknowledge receipt of send print "\nValues: ", data if data[1] == 'd': keyID = data[2] print "removing data for keyID ", keyID, " from table" ##need the mac address returned c_handle = ClientTable_Handler() c_handle.delete_entry(keyID) lines = open(ClientTable).readlines() print lines elif data[1] == 'r': print "Result acknowldedgement received" else: print "No matches found" print rcvData else: print addr
def listen(): s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_ICMP) s.setsockopt(socket.SOL_IP, socket.IP_HDRINCL, 1) ClientTable = '/var/www/cgi-bin/ClientTable.txt' while 1: data, addr = s.recvfrom(1508) #print s.recvfrom(1508) if addr == ('10.0.0.40', 0): rcvData = data[28:] rcvData = rcvData.rstrip(' \t\r\n\0') data = rcvData.split(',') #print "Lenth of Received Data: ", len(data) if len(data) > 4: print "Updating Table" print rcvData c_handle = ClientTable_Handler() c_handle.add_entry(rcvData) #client_tbl = open(ClientTable,'a') #client_tbl.write(rcvData+'\n') #print data #mac, port, passKey, violation, keyID = data #client_tbl.close() else: print "\nValues: ", data if data[1] == 'd': keyID = data[2] print "removing data for keyID ", keyID, " from table" ##need the mac address returned c_handle = ClientTable_Handler() c_handle.delete_entry(keyID) lines = open(ClientTable).readlines() print lines else: print rcvData else: print addr
def listen(): s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_ICMP) s.setsockopt(socket.SOL_IP, socket.IP_HDRINCL, 1) ClientTable = '/var/www/cgi-bin/ClientTable.txt' RapTestTable = '/var/www/cgi-bin/RapTable.txt' while 1: data, addr = s.recvfrom(1508) #print s.recvfrom(1508) if addr == ('192.168.0.40', 0): rcvData = data[28:] rcvData = rcvData.rstrip(' \t\r\n\0') data = rcvData.split(',') print "Data Received: ", data #print "Lenth of Received Data: ", len(data) #if len(data) > 4: if data[0] == 'l': #load print "Loading Table Data" print rcvData c_handle = ClientTable_Handler() c_handle.add_entry(rcvData) elif data[0] == 'e': #edit print "Editing Table" print rcvData mac, keyID = data[1], data[5] c_handle = ClientTable_Handler() c_handle.edit_entry(mac, keyID, rcvData) elif data[0] == 'a': #acknowledge receipt of send print "\nValues: ", data if data[1] == 'd': keyID = data[2] print "removing data for keyID ", keyID, " from table" ##need the mac address returned c_handle = ClientTable_Handler() c_handle.delete_entry(keyID) lines = open(ClientTable).readlines() print lines elif data[1] == 'r': print "Result acknowldedgement received" else: print "No matches found" print rcvData else: print addr