Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

TFTP Client & Server

$
0
0

Hello all,
 
I'm trying to write a TFTP Client and a TFTP Server in autoIT..., so far I'm only at the client... I would greatly appreciate the input of some RFC gurus.
This is the code that I have:

AutoIt         
  1. #include <String.au3>
  2.  
  3. $socket = UDPOpen("192.168.1.84", 69)
  4. $rrq="0x"&"0001676574006f6374657400"
  5. $status = UDPSend($socket, $rrq)
  6. If $status = 0 then
  7.     MsgBox(0, "ERROR", "Error while sending UDP message: " & @error)
  8.     Exit
  9. $srcv = UDPRecv($socket, 516)
  10. ConsoleWrite("Received Response: "&_HexToString(Stringmid($srcv,9)))
  11. ConsoleWrite("Received Response: "&$srcv)
  12. $rrq2="0x"&"0004001"
  13. $status2 = UDPSend($socket, $rrq2)
  14. $srcv2 = UDPRecv($socket, 516)
  15. ConsoleWrite("Received Response: "&_HexToString(Stringmid($srcv2,9)))
  16. ConsoleWrite("Received Response: "&$srcv2)

the first packet that I send is in the $rrq (READ REQUEST) variable: |2 byte op code "00:01" for RRQ|file name "67:65:74", meaning "get"|1 byte delimiter 0 "00"|mode "6f:63:74:65:74" meaning "octet"|1 byte ending 0 "00"

 

I actually get back the file from the server, its a text file named get, containing the string "TRANSFER TEST FILE"

I get the response:

 

 

Received Response: <SOH>TRANSFER TEST FILE

Received Response: 0x000300015452414E5346455220544553542046494C45

 

meaning: 2 byte opcode "00:03" which is DATA|2 byte block ID for block #1 "00:01" (also in this case this 4 bytes are SOH = start of header)|18 bytes as the content of the file....

and this is the part where Im stuck since after I receive this I send an ACK "00:04" <- ACK opcode|"00:01" <- block ID but the TFTP server respondes with a EBADOP "Illegal TFP operation" adding an EOT (end of transmission) header:

 

 

Received Response: <EOT>Illegal TFTP operation

Received Response: 0x00050004496C6C6567616C2054465450206F7065726174696F6E00

 

the "00:05" is opcode for error, and "00:04" is illegal TFTP operation, "00" is closing byte for the opcode...

 

I'm using Tftpd32 4.0.0.0 as a server, I'm getting this error from it:

 

 

Connection received from 192.168.1.84 on port 65047 [29/06 01:29:49.019]

Read request for file <get>. Mode octet [29/06 01:29:49.023]
Using local port 65048 [29/06 01:29:49.024]
Connection received from 192.168.1.84 on port 65047 [29/06 01:29:49.030]
Unexpected request 4 from peer [29/06 01:29:49.036]
Returning EBADOP to Peer [29/06 01:29:49.036]
File <get> : error 10054 in system call recv An existing connection was forcibly closed by the remote host. [29/06 01:29:50.028]

 

I really don't know what to try... I'm guessing that I'm miss interpreting something from the RFC http://www.networksorcery.com/enp/rfc/rfc1350.txt


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>