6 #* Copyright (c) 1993, 1995 by Colorado Digital Eclectics (CODE)
7 #* All rights reserved.
9 #* This code is derived from software contributed to CODE by
10 #* John Conner, WD0FHG.
12 #* Redistribution and use in source and binary forms, with or without
13 #* modification, are permitted provided that the following conditions
15 #* 1. Redistributions of source code must retain the above copyright
16 #* notice, this list of conditions and the following disclaimer.
17 #* 2. Redistributions in binary form must reproduce the above copyright
18 #* notice, this list of conditions and the following disclaimer in the
19 #* documentation and/or other materials provided with the distribution.
20 #* 3. All advertising materials mentioning features or use of this software
21 #* must display the following acknowledgement:
22 #* This product includes software developed by Colorado Digital Eclectics
23 #* and its contributors.
24 #* 4. Neither the CODE name nor the names of its contributors may be used
25 #* to endorse or promote products derived from this software without
26 #* specific prior written permission.
28 #* THIS SOFTWARE IS PROVIDED BY CODE AND CONTRIBUTORS ``AS IS'' AND
29 #* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 #* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 #* ARE DISCLAIMED. IN NO EVENT SHALL CODE OR THE CONTRIBUTORS BE LIABLE
32 #* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 #* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 #* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 #* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 #* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 #* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42 $FILEDIR = "/etc/p10cfgd/";
43 $LOGFILE = "/var/log/p10cfgd.log";
47 $IPPORT_RMTCFG = 1236;
48 $sockaddr = 'S n a4 x8';
51 # just incase someone wants to set on a different port
53 $port = $IPPORT_RMTCFG unless $port;
55 open(LOG,">>$LOGFILE") || die "Can't open log file: $!\n";
57 ($sec,$min,$hour,$mday,$mon,$year) = gmtime(time);
59 print LOG "Starting p10cfgd: $mon/$mday/$year $hour:$min:$sec\n";
61 # if we were started by inetd then STDIN will be our
62 # socket and getsockname will return $myport == $port
63 $mysockaddr = getsockname(STDIN);
64 ($family, $myport, $myaddr) = unpack($fileaddr,$mysockaddr);
65 print LOG "Started by inetd port=$myport\n";
66 if ( $myport == $port ) {
67 # we were started by inetd
69 $addr = getpeername(NS);
72 exit; #should never get here
75 # we were started normally
77 ($name, $aliases, $proto) = getprotobyname('tcp');
78 if ($port !~ /^\d+$/) {
79 ($name, $aliases, $port) = getservbyport($port, 'tcp');
82 $this = pack($sockaddr, $AF_INET, $port, "\0\0\0\0");
84 select(NS); $| = 1; select(stdout);
86 socket(S, $AF_INET, $SOCK_STREAM, $proto) || die "socket: $!";
87 bind(S,$this) || die "bind: $!";
88 listen(S,5) || die "connect: $!";
90 select(S); $| = 1; select(stdout);
93 print LOG "Listening for connection on Port = $port\n";
97 # wait here for connection
98 ($addr = accept(NS,S)) || die $!;
101 # now process the remote's file request
102 if (($child[$con] = fork()) == 0) {
103 unless (fork) { # child[$con]'s child
106 #first child exits quickly
109 wait; #parent reaps first child quickly
113 sub ServiceConnection {
114 open(LOG,">>$LOGFILE") || die "Can't open log file: $!\n";
115 ($sec,$min,$hour,$mday,$mon,$year) = gmtime(time);
117 print LOG "$con: $mon/$mday/$year $hour:$min:$sec\n";
119 ($af,$port,$inetaddr) = unpack($sockaddr,$addr);
120 @inetaddr = unpack('C4',$inetaddr);
121 print LOG "$con: accept ok connection from @inetaddr\n";
123 # the only thing we are expecting from the remote is a file name
125 chop( $file ); # get rid of the newline
126 $file =~ s/\r$//; # get rid of the return that may be at the end
128 print LOG "$con: Requested file - $file\n";
129 print NS "# Config file: $file\n"; #Send a comment line
131 $file = "$FILEDIR$file";
134 print NS "# Unable to open requested config file.\n";
136 print LOG "$con: Could not open file $file: $!\n";
138 } unless open( FILE, $file );
140 # now copy the requested file to the socket
143 s/^$/ /; #make sure that all lines have at least one char
144 s/^_$//; #except for lines starting with a underscore
148 # now send the time (MMDDYYHHMM) this should work for all files and
149 # set the switch time when any command file is read. It should just
150 # add a time stamp to the info files.
152 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime( time );
155 printf (NS "time %2.2d%2.2.2d%2.2d%2.2d%2.2d \n",$mon,$mday,$year,$hour,$min);
161 } # end-ServiceConnection
164 ###############################################################
166 # These next few lines are legal in both Perl and nroff.
170 'di \" finish diversion--previous line must be blank
171 .nr nl 0-1 \" fake up transition to first page again
172 .nr % 0 \" start at page 1
173 '; __END__ ##### From here on it's a standard manual page #####
175 .TH P10CFGD 1 "July 29, 1993"
178 p10cfgd \- remote configuration daemom for Gracilis PackeTen
182 Copyright (c) 1993 by Colorado Digital Eclectics (CODE)
188 is a server program used to send configuration
189 files to a Gracilis PackeTen. It can be run in
190 background or it can be run by inetd.
193 is to be run by inetd, add the following line to
197 rmtcfg 1236/tcp # Remote Configuration of PackeTen
200 and add the following to
204 # Remote configuration service for PackeTen
205 rmtcfg stream tcp nowait root /usr/bin/p10cfgd p10cfgd
209 normally does not require the IP_PORT parameter. It
210 listens for connections on IP Port 1236 as a default.
212 The program will send on a line by line basis the file requested
213 by the client that connects on the IP Port. The only expected
214 input from the client is the file name. When the file has been
215 sent, the connection is closed. The requested file must be in
216 the directory /etc/p10cfgd.
219 maintains a log of its activity in the file
220 /var/log/p10cfgd.log. Program startup and all connections are
221 logged in the file with GMT time stamps. The file is opened
224 The protocol used by the PackeTen is very simple.
225 The PackeTen opens a tcp connection to port 1236 on
226 a host system. Once the connection is made, the PackeTen
227 sends the name of the file it wants to the host. The
228 host then opens the file and sends it line by line to
229 the PackeTen until all lines have been sent. The files
230 to be transfered must be plain text files and each line
231 must have at least one character in addition to the newline
234 replaces all blank lines with lines that contain two spaces.
235 If you wish to send a blank line, to stop loading of part
236 of a LocalInfo file for example, place an underscore '_' at
237 the begining of the line. The entire contents of the line will
238 be deleted and a blank line will be sent to the client.
239 At the end of the file,
240 the server sends a time command
241 ( time MMDDYYHHMM ) with the UTC time on the server.
242 This will either set the time on the PackeTen or add a time stamp
243 to the LocalInfo file.
244 The server then closes the connection.
246 The remote configuration command used on the PackeTen is
248 rmtcfg <server_host> <filename> [options]
249 The valid options are
250 -t <timeout in seconds> default is 60 sec
251 -p <IP port #> default is 1236
252 -i the file is for LocalInfo
253 -h <secondary server> if the primary does not answer
256 The rmtcfg commands would be placed in to the EEPROM on the
257 PackeTen so that they would be executed during a reboot. The
258 information stored in the EEPROM should include enough information
259 to set the PackeTen up to allow communications with the primary and
260 the secondary server.
261 This would include commands to set MYCALL and the IP_ADDRESS, to attach an
262 interface to the channel with the server, routing information and
263 so forth. A sample EEPROM configuration for a PackeTen,
264 empire.wd0fhg.ampr.org [44.32.0.32],
265 that gets its configuration from a remote system
266 winfree.n3eua.ampr.org [44.32.0.2],
267 over a 9600 baud ax25 path would be:
270 # first the general setup of the PackeTen
271 ee hostname gw.wd0fhg
275 # Then we attach a 9600 ax25 interface as ax1
276 ee attach sync302 1 hdx ax25 ax1 8192 256 9600 ext ext nrzi
277 # and set the default route to send every thing out ax1
278 ee route add default ax1 44.32.0.1
279 ee password sure-thing
281 # Now we will ask for the remainder of the setup
282 # from the server winfree.n3eua.ampr.org [44.32.0.2]
283 # Note that we have a secondary server available at
284 # [44.20.0.195] that would be used if winfree is down.
285 # first the Local Information file
286 ee com 0 rmtcfg 44.32.0.2 empire.info -i -h 44.20.0.195
287 # and then the remaining configuration command file
288 ee com 1 rmtcfg 44.32.0.2 empire.cfg -h 44.20.0.195
291 # end-of-eeprom setup
295 started life as the simple server program in PERL by
296 Larry Wall and R.L. Schwartz published by ORA,Inc.
299 No environment variables are used.
302 /etc/p10cfgd/* - files that can be accessed remotely
303 /var/log/p10cfgd.log - p10cfgd log file
307 John Conner, WD0FHG, conner@empire.com
308 hacked on by Bdale Garbee, N3EUA, bdale@gag.com.
311 Gracilis, Inc. PackeTen Manual and NOS User's Manual
314 Complains if it can't open a file to remote client and to log file.