2 #***************************************************************************
4 # Project ___| | | | _ \| |
6 # | (__| |_| | _ <| |___
7 # \___|\___/|_| \_\_____|
9 # Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
11 # This software is licensed as described in the file COPYING, which
12 # you should have received as part of this distribution. The terms
13 # are also available at https://curl.se/docs/copyright.html.
15 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
16 # copies of the Software, and permit persons to whom the Software is
17 # furnished to do so, under the terms of the COPYING file.
19 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 # KIND, either express or implied.
22 # SPDX-License-Identifier: curl
24 #***************************************************************************
30 push(@INC, $ENV{'srcdir'}) if(defined $ENV{'srcdir'});
43 my $verbose = 0; # set to 1 for debugging
44 my $port = 8997; # just a default
45 my $ipvnum = 4; # default IP version of tftp server
46 my $idnum = 1; # default tftp server instance number
47 my $proto = 'tftp'; # protocol the tftp server speaks
56 my $logdir = $path .'/log';
59 if($ARGV[0] eq '--pidfile') {
65 elsif($ARGV[0] eq '--portfile') {
71 elsif($ARGV[0] eq '--logfile') {
77 elsif($ARGV[0] eq '--logdir') {
83 elsif($ARGV[0] eq '--srcdir') {
89 elsif($ARGV[0] eq '--ipv4') {
92 elsif($ARGV[0] eq '--ipv6') {
95 elsif($ARGV[0] eq '--port') {
96 if($ARGV[1] =~ /^(\d+)$/) {
101 elsif($ARGV[0] eq '--id') {
102 if($ARGV[1] =~ /^(\d+)$/) {
103 $idnum = $1 if($1 > 0);
107 elsif($ARGV[0] eq '--verbose') {
111 print STDERR "\nWarning: tftpserver.pl unknown parameter: $ARGV[0]\n";
117 $srcdir = $ENV{'srcdir'} || '.';
120 $pidfile = server_pidfilename($path, $proto, $ipvnum, $idnum);
123 $logfile = server_logfilename($logdir, $proto, $ipvnum, $idnum);
126 $flags .= "--pidfile \"$pidfile\" ".
127 "--portfile \"$portfile\" ".
128 "--logfile \"$logfile\" ".
129 "--logdir \"$logdir\" ";
130 $flags .= "--ipv$ipvnum --port $port --srcdir \"$srcdir\"";
133 exec("exec server/tftpd".exe_ext('SRV')." $flags");