Hi Folks,

I am a Master student, trying to build an app in POX.
I am trying to respond to DNS query in the controller by creating response
dns packet with answer. But it is not working.

Here is my code :
 #Create DNS Response message
 91         dns_resp = dnsp()
 92         dns_resp.qr = 1
 93         dns_resp.aa = 1
 94         dns_resp.answers.rdata = IPAddr('10.0.0.9')
 95         dns_resp.questions = dns.questions
 96         dns_resp.id = dns.id
 97         dns_resp.total_questions = dns.total_questions
 98         dns_resp.total_answers = 1
 99
100         udp_req = event.parsed.find('udp')
101         udp = udpp()
102         udp.srcport = udp_req.dstport
103         udp.dstport = udp_req.srcport
104         udp.len = len(dns_resp) + udpp.MIN_LEN
105         udp.csum = udpp.checksum()
106         udp.set_payload(dns_resp)
107
108         ip = ipv4p()
109         ip_req = event.parsed.find('ipv4')
110         ip = ip_req
111         ip.srcip = ip_req.dstip
112         ip.dstip = ip_req.srcip
113         ip.set_payload(udp)
114
115         eth = ethernet()
116         eth.type = ethernet.IP_TYPE
117         eth.dst = event.parsed.src
118         eth.src = EthAddr("00:01:43:00:00:05")
119         eth.set_payload(ip)
120
121         msg = oflow.ofp_packet_out()
122         msg.in_port = event.parsed.in_port
123         msg.data = eth.pack()
124         action = oflow.ofp_action_output(port = oflow.OFPP_IN_PORT)
125         msg.actions.append(action)
126         self.connection.send(msg)
127         print "Succesfully sent dns response !"
128


Thanks
Anil

Reply via email to