+ len = 0;
+ filename = msg_opt_data(&rx.msg, NMRP_O_FILE_NAME, &len);
+ if (filename) {
+ if (!args->file_remote) {
+ args->file_remote = filename;
+ }
+ printf("Received upload request: filename '%.*s'.\n",
+ len, filename);
+ } else if (!args->file_remote) {
+ args->file_remote = args->file_local;
+ printf("Received upload request with empty filename.\n");
+ }
+
+ status = 0;
+
+ if (args->tftpcmd) {
+ printf("Executing '%s' ... \n", args->tftpcmd);
+ setenv("IP", inet_ntoa(ipconf.addr), 1);
+ setenv("PORT", lltostr(args->port, 10), 1);
+ setenv("MAC", mac_to_str(rx.eh.ether_shost), 1);
+ setenv("NETMASK", inet_ntoa(ipconf.mask), 1);
+ //setenv("FILENAME", args->file_remote ? args->file_remote : "", 1);
+ status = system(args->tftpcmd);
+ }
+
+ if (!status && args->file_local) {
+ if (!autoip) {
+ status = is_valid_ip(sock, &ipconf.addr, &ipconf.mask);
+ if (status < 0) {
+ goto out;
+ } else if (!status) {
+ printf("IP address of %s has changed. Please assign a "
+ "static ip to the interface.\n", args->intf);
+ tx.msg.code = NMRP_C_CLOSE_REQ;
+ break;
+ }
+ }
+
+ if (verbosity) {
+ printf("Using remote filename '%s'.\n",
+ args->file_remote);
+ }
+
+ if (!strcmp(args->file_local, "-")) {
+ printf("Uploading from stdin ... ");
+ } else {
+ printf("Uploading %s ... ", leafname(args->file_local));
+ }