Pages: [1]   Go Down
Author Topic: a DNS-query using 28j60  (Read 299 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 0
Posts: 153
veroboaring is the new XGame - Extreme Veroboarder
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is a DNS-quiery routine for bascom.
I'm trying to write it but in C.
Some one want to work & test with me? ;D

Best Regards
Frank

Sub Udp_dns_query
   Call Rtr2dest
   Call Src2mymac
   T_enetpackettype = &H0008                     ' = &h0800
   T_ip_vers_len = &H45
   T_tos = &H00
   T_ip_pktlen0 = &H00
   T_ip_pktlen1 = &H39
   T_id0 = &H48
   T_id1 = &H15
   T_flags = &H00
   T_offset = &H00
   T_ttl = &H80
   'protocol (ICMP=1, TCP=6, UDP=11)
   T_ip_proto = &H11
   'checksum
   'checksum
   'IP address of source
   T_ip_srcaddr0 = Myip(1)
   T_ip_srcaddr1 = Myip(2)
   T_ip_srcaddr2 = Myip(3)
   T_ip_srcaddr3 = Myip(4)
   'IP address of destination                            'you have to put the IP-number of
   T_ip_destaddr0 = 213                                  ' the DNS-server here (@HOME)
   T_ip_destaddr1 = 51
   T_ip_destaddr2 = 144
   T_ip_destaddr3 = 37
   'UDP-header
   T_udp_srcport0 = &H04
   T_udp_srcport1 = &H12
   T_udp_destport0 = &H00                            ' port &H0035 = 53 DNS
   T_udp_destport1 = &H35
   T_udp_len0 = &H00
   T_udp_len1 = &H25
   'checksum
   'checksum
   'DNS-query
   T_udp_data = &H00                                      'ID
   T_udp_data1 = &HB4
   T_udp_data2 = &H01                                   'flags
   T_udp_data3 = &H00
   T_udp_data4 = &H00                                   'questions
   T_udp_data5 = &H01
   T_udp_data6 = &H00                                   'Answer RRs
   T_udp_data7 = &H00
   T_udp_data8 = &H00                                   'Authority
   T_udp_data9 = &H00
   T_udp_data10 = &H00                                 'Additional
   T_udp_data11 = &H00
   'queries
   T_udp_data12 = &H03                                 'length of www
   T_udp_data13 = Asc( "w")
   T_udp_data14 = Asc( "w")
   T_udp_data15 = Asc( "w")
   T_udp_data16 = &H04                                 'length of home
   T_udp_data17 = Asc( "h")
   T_udp_data18 = Asc( "o")
   T_udp_data19 = Asc( "m")
   T_udp_data20 = Asc( "e")
   T_udp_data21 = &H02                                 'length of nl
   T_udp_data22 = Asc( "n")
   T_udp_data23 = Asc( "l")
   T_udp_data24 = &H00
   'host address
   T_udp_data25 = &H00
   T_udp_data26 = &H01
   'Class: INET
   T_udp_data27 = &H00
   T_udp_data28 = &H01
   Call Ip_header_checksum
   Call Udp_checksum
   Call Echopacket
End Sub

Here www.home.nl is used. If you want to query mail.home.nl change this

   'queries
   T_udp_data12 = &H04                          'length of mail
   T_udp_data13 = Asc( "m")
   T_udp_data14 = Asc( "a")
   T_udp_data15 = Asc( "i")
   T_udp_data16 = Asc( "l" )
   T_udp_data17 = &H04                          'length of home
   T_udp_data18 = Asc( "h")
   T_udp_data19 = Asc( "o")
   T_udp_data20 = Asc( "m")
   T_udp_data21 = Asc( "e")
   T_udp_data22 = &H02                           'length of nl
   T_udp_data23 = Asc( "n")
   T_udp_data24 = Asc( "l")
   T_udp_data25 = &H00

Since the UDP-message is one longer....

   T_udp_len0 = &H00
   T_udp_len1 = &H26

Since the total packet is one longer....

   T_ip_pktlen0 = &H00
   T_ip_pktlen1 = &H3A

Logged

Pages: [1]   Go Up
Jump to: