diff -ru busybox-0.60.5.orig/Config.h busybox-0.60.5/Config.h --- busybox-0.60.5.orig/Config.h 2002-09-18 08:04:28.000000000 +1000 +++ busybox-0.60.5/Config.h 2003-04-04 23:40:51.000000000 +1000 @@ -388,6 +388,7 @@ // Tell tftp what commands that should be supported. #define BB_FEATURE_TFTP_PUT #define BB_FEATURE_TFTP_GET +#define BB_FEATURE_TFTP_BCAST // // features for vi #define BB_FEATURE_VI_COLON // ":" colon commands, no "ex" mode diff -ru busybox-0.60.5.orig/tftp.c busybox-0.60.5/tftp.c --- busybox-0.60.5.orig/tftp.c 2002-10-25 22:05:51.000000000 +1000 +++ busybox-0.60.5/tftp.c 2003-04-04 23:40:51.000000000 +1000 @@ -76,6 +76,7 @@ const int tftp_cmd_get = 1; const int tftp_cmd_put = 2; +const int tftp_cmd_bcast = 4; #ifdef BB_FEATURE_TFTP_BLOCKSIZE @@ -145,6 +146,7 @@ { const int cmd_get = cmd & tftp_cmd_get; const int cmd_put = cmd & tftp_cmd_put; + const int bcast = cmd & tftp_cmd_bcast; const int bb_tftp_num_retries = 5; struct sockaddr_in sa; @@ -175,6 +177,12 @@ perror_msg("socket"); return EXIT_FAILURE; } + +#ifdef BB_FEATURE_TFTP_BCAST + if (setsockopt(socketfd, SOL_SOCKET, SO_BROADCAST, &bcast, + sizeof(bcast)) < 0) + perror("setsockopt SO_BROADCAST"); +#endif len = sizeof(sa); @@ -505,6 +513,12 @@ #define BS #endif +#ifdef BB_FEATURE_TFTP_BCAST +#define BCAST "c" +#else +#define BCAST +#endif + #ifdef BB_FEATURE_TFTP_GET #define GET "g" #else @@ -517,7 +531,7 @@ #define PUT #endif - while ((opt = getopt(argc, argv, BS GET PUT "l:r:")) != -1) { + while ((opt = getopt(argc, argv, BS GET PUT BCAST "l:r:")) != -1) { switch (opt) { #ifdef BB_FEATURE_TFTP_BLOCKSIZE case 'b': @@ -527,6 +541,11 @@ } break; #endif +#ifdef BB_FEATURE_TFTP_BCAST + case 'c': + cmd |= tftp_cmd_bcast; + break; +#endif #ifdef BB_FEATURE_TFTP_GET case 'g': cmd = tftp_cmd_get; diff -ru busybox-0.60.5.orig/usage.h busybox-0.60.5/usage.h --- busybox-0.60.5.orig/usage.h 2002-10-01 06:59:58.000000000 +1000 +++ busybox-0.60.5/usage.h 2003-04-04 23:41:26.000000000 +1000 @@ -1667,6 +1667,11 @@ #else #define USAGE_TFTP_PUT(a) #endif +#ifdef BB_FEATURE_TFTP_BCAST + #define USAGE_TFTP_BCAST(a) a +#else + #define USAGE_TFTP_BCAST(a) +#endif #define time_trivial_usage \ "[OPTION]... COMMAND [ARGS...]" @@ -1682,6 +1687,9 @@ "Transfers a file from/to a tftp server using \"octet\" mode.\n\n" \ "Options:\n" \ "\t-b SIZE\tTransfer blocks of SIZE octets.\n" \ + USAGE_TFTP_BCAST( \ + "\t-c\tEnable broadcast.\n" \ + ) \ USAGE_TFTP_GET( \ "\t-g\tGet file.\n" \ ) \