There is a source code for a specialized tftp utility for a busybox router (I don’t cite all the text so as not to tire people with copy-paste) here is a fragment:

#if !defined(SUPPORT_SQN_KTHP) if ((cmd == 0) || (optind == argc) || !(glbUploadType == 'i' || glbUploadType == 'c' || glbUploadType == 'f')) { bb_show_usage(); } #else if ((cmd == 0) || (optind == argc) || !(glbUploadType == 's' || glbUploadType == 'd' || glbUploadType == 'p'|| glbUploadType == 'k' || glbUploadType == 'i')) { bb_show_usage(); } #endif if(!remotefile || remotefile[0] == '\0') bb_show_usage(); if (glbUploadType == 'i' && cmd != tftp_cmd_get){ printf("tftp client only support upgrade firmware\n"); return EXIT_FAILURE; } if ( glbUploadType == 's' || glbUploadType == 'd' || glbUploadType == 'p'|| glbUploadType == 'k' ){ if ( !(andyCheckTftpcEnable()) ){ printf("Can not enable upgrade/download certificate data\n"); return EXIT_FAILURE; } } if (glbUploadType == 'c') fBufType = BUF_CONFIG_DATA; 

Theoretically, in the end, there should be a check of the possibility of downloading / unloading corresponding files by tftp. If it does not converge, output the corresponding command: "Can not enable upgrade / download certificate data". After building help tftp writes

 Usage: tftp [OPTION]... tftp_server_ip Update certificate data from/or backup certificate. data to a tftp server. Options: -g Get file. (Certificate data) -p Put file. (backup Certificate data) -f remote file name. -ts for server root ,d for device, p for device private and k 

I enter the command: tftp –g 192.168.1.2 –f file.pem –ts (similar command for downloading the firmware image - works - tftp –g 192.168.1.2 –f file.bin –ti ) as a result I get "Can not upgrade / download certificate data " And it does not matter –g or –p I guess that the error is here:

 if ( glbUploadType == 's' || glbUploadType == 'd' || glbUploadType == 'p'|| glbUploadType == 'k' ){ if ( !(andyCheckTftpcEnable()) ){ printf("Can not enable upgrade/download certificate data\n"); return EXIT_FAILURE; } } 

Tell me plz what needs to be fixed if I'm right

    2 answers 2

    And what to fix? andyCheckTftpcEnable () returns false in the case of -ts. In the case of ti, this code does not work. See andyCheckTftpcEnable ().

    • @andruxa Thank you for your prompt response. The problem was that "andyCheckTftpcEnable" rejects the options that determine the type of file being transferred. Further, they are used to download / copy acc. files, but the action is interrupted earlier. I try to deal with "andy ..." and with options. Result otpishu - Ruslan

    The code was correctly checked the connected files - the function "andyCheckTftpcEnable" by default checks if telnet is enabled and if not - a socket is created, but the telnet support was not specified in the rules. It was necessary to add to the beginning of the file (rules)

      #define SUPPORT_ENABLE_TELNET 

    and it worked right