diff --git a/BUILDING b/BUILDING index cd76c3e..9e92d95 100644 --- a/BUILDING +++ b/BUILDING @@ -33,7 +33,7 @@ have all or most of these but it still doesn't hurt to be sure: sudo apt-get update sudo apt-get upgrade -sudo apt-get install make g++ unzip git +sudo apt-get install make g++ unzip git libconfig++-dev and maybe a few more. Here is one of my favorites: @@ -64,9 +64,17 @@ password for sudo access. Upon completetion, make sure you are still in the g2_ircddb directory and type "make" to build all the g2_ircddb executables. If you need DTMFS then also execute "make g2link_test". -Next, edit all the *.cfg files, g2_ircddb.cfg, g2_link.cfg and either dvap_rptr.cfg -or dvrptr.cfg. These files contain detailed comments about all of the values you -need to set. Just read through the configuration files and edit accordingly. +Next, crate your g2.cfg configuration file. There are two example for you to look at: +. g2.everything.cfg contains all parameter with lengthly comments about what + each parameter does. The definitions that are commented out are defined with + their default value. +. g2.dvap.cfg is the simplest possible configuration for a 2m DVAP. If you have + a 70cm DVAP rename the module to "b" and change the frequency. + +Remeber the everything file contain detailed comments about all of the values you +can set. Just read through it and edit accordingly. In the end you will need +a configuration file called "g2.cfg". + Additional information about the configuration as well as other important and useful features are also in the CONFIGURING file. @@ -78,7 +86,10 @@ default 30001 prot. This will allow you to connect to these XREF reflectors with creating any port-forwarding rules on your home router. You will also want to move X-reflectors to port 20001 if you are going to tether you device via WiFi to a smart-phone for internet access. Most phone companies will not let you configure -port-forwarding rules on you phone internet account. +port-forwarding rules on you phone internet account. If you operate behing a +router/firewall without port forwarding in place, you will not be able to +do most callsign routing techniques discussed in CONFIGURING.txt, but you should +still be able to connect to reflectors. There are MANY OTHER gateways to which you can connect. Executing get_gwys_list.sh will download a HUGE list of reflectors and gateways from www.va3uv.com with port @@ -92,8 +103,8 @@ Based on the above discussion, execute either "./get_reflectors.sh" or "./get_gwy_list.sh". If you want to be able to update your hotspot dynamically, you can modify either one of these scripts by adding a "reboot" or "service g2_link restart" command at the end and moving it to /usr/local/etc/exec_?X.sh -where "?" is a number or letter. See the discussion of executables in the -CONFIGURING text file. +where "?" is a number or letter. You can then execute this script with ?X in YRCALL. +See the discussion of executables in the CONFIGURING text file. If you plan on using DTMFS, you can also edit proc_g2_ircddb_dtmfs.sh to add new dtmfs commands. @@ -104,9 +115,9 @@ Finally, if you want/need DTMFS, type "sudo make installdtmfs". This will install the service scripts and symbolic links in /etc/init.d and everything else in /usr/local. The executables will be in /usr/local/bin and the -*.cfg files and other data will be in /usr/local/etc. If you find that you need to -modify a configuration file, edit the ones in /usr/local/etc as root. If you edit -the files in the build directory, you will either have to copy these modified +g2.cfg file and other data will be in /usr/local/etc. If you find that you need to +modify the configuration file, edit the one in /usr/local/etc as root. If you edit +the file in the build directory, you will either have to copy these modified configuration files you you will have to reinstall the application. At this point, you can either reboot to start the three or four services, or start @@ -115,17 +126,17 @@ service g2_ircddb start". (See the man page for service.) If you are having trouble connecting, look in the *.log files in /var/log. These log files are recreated every time you restart a service. The beginning of each -log file will report the values of all the configuration parameters and after that +log file will report the values of all the configuration parameters (even the ones +you didn't specify in g2.cfg) and after that you will see the verbose reports of what each service is doing. These logs are -invaluable for traking down problems with your *.cfg files. In a putty or ssh +invaluable for traking down problems with your g2.cfg file. In a putty or ssh shell, you can see in real time what is being added to the logs during operation by typing "tail -f /var/log/.log", where is one of the service programs, 'g2_ircddb', 'g2_link', 'dvap_rptr', etc. -These services talk to each other through ports and the *.cfg file default values -are set up for a 2M gateway (module C). If you are using a 70cm setup, pay close -attention to the port configuration in the *.cfg files. You will need to change -several values. +These services talk to each other through ports and the default values +are set up for a 2M gateway (module C). If you are using a 70cm setup, just +change the module from "c" to "b". You can clean up the build directory of intermediate *.o files with "make clean" or, you can remove the intermediate *.o files and binary executables with "make diff --git a/CONFIGURING b/CONFIGURING index 0f7047e..4f44f59 100644 --- a/CONFIGURING +++ b/CONFIGURING @@ -1,14 +1,46 @@ -You need to configure three software programs, g2_ircddb, g2_link, and either -dvap_rptr or dvrptr by setting values in their *.cfg text files. Use your -favorite text editor to do this. Scott's comments within those files are -mostly self explainatory. +I have substantially modified (and hopefully simplified) the configuration +of this software, now, modules g2_ircddb, g2_link, dvap_rptr and dvrptr +all use a single configuration file. Further, and this is the exciting +part, NEARLY ALL of the parameters these modules need have a useful +default value. If the default value is acceptible to you (and it +probably will be) then you only need to specify what you need to change. + + +This means that for most users, you will only need to specify a few +parameters. For example, if you want to set up a 2M dvap, your a working +configuration file might be: + +------------------------------------------------------------------- +# my configuration, using rr.openquad.net with my DVAP Dongle + +ircddb = { + login = "XX0XXX" +} + +module = { + c = { + type = "dvap" + frequency = 146.55 + serial_number = "AP123456" + } +} + +------------------------------------------------------------------- + +Of course, you can add other parameters, such as latitude and longitude, +or a URL that will show up on the "User Gateways" page of +www.openquad.net. This software is highly flexible, so you can have +different modules running on different computers and these hidden +configuration parameters to allow that are there, waiting to be defined. +However, most hams won't have to bother with them! Some other features are discussed below. -Tom Early, ac2ie@arrl.net +Tom Early, ac2ie (at) arrl (dot) net /* * Copyright (C) 2010, 2011, 2012 by Scott Lawson KI4LKF + * addition Copyright (C) 2015 by Thomas A. Early AC2IE * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -174,10 +206,7 @@ Required software to run the g2_ircddb gateway correctly: --- rptr: This is our dstar repeater software that uses a GMSK adapter/modem. Instead of rptr, you can use our dvap_rptr dstar repeater software which uses a DVAP device. Intead of rptr, you can use our dvrptr - dstar repeater software which uses the DV-RPTR modem(dg1ht). Intead - of rptr, you can use our snd_rptr dstar repeater software which - uses a SOUND CARD. You can also use the ICOM's RP2C repeater - hardware box. + dstar repeater software which uses the DV-RPTR modem(dg1ht). ROUTING methods =============== @@ -319,21 +348,6 @@ x_voicemail.dat where x is one of A.B or C. Now copy that file into id.dat. Open the file g2_link.cfg: - Edit the values for LOGIN_CALL, OWNER and ADMIN. LOGIN_CALL is - always your PERSONAL callsign. It is used to connect to REF - reflectors. (REF reflectors check if the value of LOGIN_CALL is a - user callsign registered with UStrust.) - - OWNER is your GATEWAY/club/Repeater callsign. If you do not have a - GATEWAY/club/Repeater callsign, you can set OWNER equal to your - PERSONAL callsign. - - If you set OWNER to a PERSONAL callsign, then the Gateway config - file(g2_ircddb.cfg, g2_ccs.cfg) must also use the same PERSONAL - callsign. If you set OWNER to your GATEWAY/club/Repeater callsign, - then the Gateway config file(g2_ircddb.cfg, g2_ccs.cfg) must also - use the same GATEWAY/club/Repeater callsign. - You can add as many lines to gwys.txt, if you know of any other reflectors that you want to be able to connect to. REF reflectors use port 20001(for USER connections), DCS reflectors use port @@ -374,27 +388,24 @@ dvrptr The serial number required in the .cfg file can most easily be obtained by examining the /var/log/dvrptr.log file once the board has been powered up by the BBB or RasPi. Once you know the board serial number, -edit /usr/local/etc/dvrptr.cfg. Please note that once installed, you +edit /usr/local/etc/g2.cfg. Please note that once installed, you need to edit the configuration files in /usr/local/etc, not where you build the software. You need to be root to edit files in /usr/local/etc. -After editing /usr/local/etc/dvrptr.cfg file you can restart the effected -program with "sudo service dvrptr restart. +After editing /usr/local/etc/g2.cfg file you can restart the effected +program with "sudo service dvrptr restart". Or you can alway just +reboot with "sudo reboot". -Rig specific parameters are in "RF_AUDIO_Level", "RX_Inverse" and -"TX_Inverse". You need to play with these to work best with your rig. -With my Kenwood TM-V71, I use: +Rig specific parameters are in "dvrptr.rf_rx_level", "dvrptr.inverse.rx" and +"dvrptr.inverse.tx". You need to play with these to work best with your rig. +With my Kenwood TM-V71, I use the default values. -RF_AUDIO_Level=80 -TX_Inverse=1 -RX_Inverse=1 - -You can first start with RX_Inverse, trying 0 or 1. Use the echo command +You can first start with inverse.rx, trying true or false. Use the echo command on your radio and look in the logs to see if you are getting into the dvprtr. Remember to restart the dvrptr service anytime you modify -/usr/local/etc/dvrptr.cfg. Once you are able to get into the dvrptr, -then you can work out the TX_Inverse paramter. Once you hear anything -with in the echo mode, move RF_AUDIO_Level up or down to get the best +/usr/local/etc/g2.cfg. Once you are able to get into the dvrptr, +then you can work out the inverse.tx paramter. Once you hear anything +with in the echo mode, move rf_rx_level up or down to get the best audio. -Once you have a working system, it's a good idea to back up you *.cfg +Once you have a working system, it's a good idea to back up you g2.cfg files. diff --git a/Makefile b/Makefile index 925640e..b8ebf0c 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ CFGDIR=/usr/local/etc LOGDIR=/var/log CPPFLAGS=-W -Wall -I/usr/include `wx-config --cppflags base` -LDFLAGS=-L/usr/lib `wx-config --libs base` +LDFLAGS=-L/usr/lib `wx-config --libs base` -lconfig++ PROGRAMS=g2_ircddb g2_link dvap_rptr dvrptr g2link_test g2link_test_audio @@ -33,13 +33,13 @@ g2_ircddb : g2_ircddb.cpp $(IRCDDBOBJS) versions.h g++ $(CPPFLAGS) -o g2_ircddb g2_ircddb.cpp $(IRCDDBOBJS) $(LDFLAGS) -pthread g2_link : g2_link.cpp versions.h - g++ -W -Wall -o g2_link g2_link.cpp -lrt -pthread + g++ -W -Wall -o g2_link g2_link.cpp -lrt -lconfig++ -pthread dvap_rptr : dvap_rptr.cpp dstar_dv.o golay23.o versions.h - g++ -W -Wall -o dvap_rptr dvap_rptr.cpp golay23.o dstar_dv.o -I/usr/include -L/usr/lib -lrt -pthread + g++ -W -Wall -o dvap_rptr dvap_rptr.cpp golay23.o dstar_dv.o -I/usr/include -L/usr/lib -lrt -lconfig++ -pthread dvrptr : dvrptr.cpp dstar_dv.o golay23.o - g++ -W -Wall -o dvrptr dvrptr.cpp golay23.o dstar_dv.o -I/usr/include -L/usr/lib -lrt + g++ -W -Wall -o dvrptr dvrptr.cpp golay23.o dstar_dv.o -I/usr/include -L/usr/lib -lconfig++ -lrt IRCDDB.o : IRCDDB.cpp IRCDDB.h g++ $(CPPFLAGS) -c $(CPPFLAGS) IRCDDB.cpp @@ -90,13 +90,12 @@ realclean : installdvap : dvap_rptr g2_link g2_ircddb ######### g2_ircddb ######### /bin/cp -f g2_ircddb $(BINDIR) - /bin/cp -f g2_ircddb.cfg $(CFGDIR) + /bin/cp -f g2.cfg $(CFGDIR) /bin/cp -f service.g2_ircddb /etc/init.d/g2_ircddb /usr/sbin/update-rc.d g2_ircddb defaults /usr/sbin/update-rc.d g2_ircddb enable ######### g2_link ######### /bin/cp -f g2_link $(BINDIR) - /bin/cp -f g2_link.cfg $(CFGDIR) /bin/cp -f announce/*.dat $(CFGDIR) /bin/cp -f gwys.txt $(CFGDIR) /bin/cp -f exec_?.sh $(CFGDIR) @@ -106,7 +105,6 @@ installdvap : dvap_rptr g2_link g2_ircddb ######### dvap_rptr ######### /bin/cp -f dvap_rptr $(BINDIR) /bin/cp -f dvap_rptr.sh $(BINDIR) - /bin/cp -f dvap_rptr.cfg $(CFGDIR) /bin/cp -f service.dvap_rptr /etc/init.d/dvap_rptr /usr/sbin/update-rc.d dvap_rptr defaults /usr/sbin/update-rc.d dvap_rptr enable @@ -114,13 +112,12 @@ installdvap : dvap_rptr g2_link g2_ircddb installdvrptr : dvrptr g2_link g2_ircddb ######### g2_ircddb ######### /bin/cp -f g2_ircddb $(BINDIR) - /bin/cp -f g2_ircddb.cfg $(CFGDIR) + /bin/cp -f g2.cfg $(CFGDIR) /bin/cp -f service.g2_ircddb /etc/init.d/g2_ircddb /usr/sbin/update-rc.d g2_ircddb defaults /usr/sbin/update-rc.d g2_ircddb enable ######### g2_link ######### /bin/cp -f g2_link $(BINDIR) - /bin/cp -f g2_link.cfg $(CFGDIR) /bin/cp -f announce/*.dat $(CFGDIR) /bin/cp -f gwys.txt $(CFGDIR) /bin/cp -f exec_?.sh $(CFGDIR) @@ -130,7 +127,6 @@ installdvrptr : dvrptr g2_link g2_ircddb ######### dvrptr ########## /bin/cp -f dvrptr $(BINDIR) /bin/cp -f dvrptr.sh $(BINDIR) - /bin/cp -f dvrptr.cfg $(CFGDIR) /bin/cp -f service.dvrptr /etc/init.d/dvrptr /usr/sbin/update-rc.d dvrptr defaults /usr/sbin/update-rc.d dvrptr enable @@ -155,13 +151,12 @@ uninstalldvap : /bin/rm -f /etc/init.d/g2_ircddb /usr/sbin/update-rc.d g2_ircddb remove /bin/rm -f $(BINDIR)/g2_ircddb - /bin/rm -f $(CFGDIR)/g2_ircddb.cfg + /bin/rm -f $(CFGDIR)/g2.cfg ######### g2_link ######### /usr/sbin/service g2_link stop /bin/rm -f /etc/init.d/g2_link /usr/sbin/update-rc.d g2_link remove /bin/rm -f $(BINDIR)/g2_link - /bin/rm -f $(CFGDIR)/g2_link.cfg /bin/rm -f $(CFGDIR)/already_linked.dat /bin/rm -f $(CFGDIR)/already_unlinked.dat /bin/rm -f $(CFGDIR)/failed_linked.dat @@ -178,7 +173,6 @@ uninstalldvap : /usr/sbin/update-rc.d dvap_rptr remove /bin/rm -f $(BINDIR)/dvap_rptr /bin/rm -f $(BINDIR)/dvap_rptr.sh - /bin/rm -r $(CFGDIR)/dvap_rptr.cfg uninstalldvrptr: ######### g2_ircddb ######### @@ -186,13 +180,12 @@ uninstalldvrptr: /bin/rm -f /etc/init.d/g2_ircddb /usr/sbin/update-rc.d g2_ircddb remove /bin/rm -f $(BINDIR)/g2_ircddb - /bin/rm -f $(CFGDIR)/g2_ircddb.cfg + /bin/rm -f $(CFGDIR)/g2.cfg ######### g2_link ######### /usr/sbin/service g2_link stop /bin/rm -f /etc/init.d/g2_link /usr/sbin/update-rc.d g2_link remove /bin/rm -f $(BINDIR)/g2_link - /bin/rm -f $(CFGDIR)/g2_link.cfg /bin/rm -f $(CFGDIR)/already_linked.dat /bin/rm -f $(CFGDIR)/already_unlinked.dat /bin/rm -f $(CFGDIR)/failed_linked.dat @@ -209,4 +202,3 @@ uninstalldvrptr: /usr/sbin/update-rc.d dvrtpr remove /bin/rm -f $(BINDIR)/dvrptr /bin/rm -f $(BINDIR)/dvrptr.sh - /bin/rm -f $(CFGDIR)/dvrptr.cfg diff --git a/README.md b/README.md index 54d47de..e2b98c1 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,28 @@ g2_ircddb ========= +NEW! Software configuration is SIGNIFICANTLY easier because most parameters now have default values. Most hams will only need to define a few things. + +PRETTY NEW: g2_ircddb has come up to current practices when it comes to ":IRCDDB" irc commands. This means irc hosts like rr.openquad.net can list your repeater frequency, offset, location and URL automatically if you want. + This package is for making a ircddb gateway based on Scott Lawson KI4LKF g2_ircddb gateway software. -Two repeater devices are supported so far: the DVAP dongle (http://www.dvapdongle.com) and the dvrptr (http://www.dvrptr.net). +Two repeater devices are supported so far: the DVAP dongle (http://www.dvapdongle.com) and the dvrptr V1 (http://www.dvrptr.net). -Creating a portable ircddb hotspot based on a Raspberry Pi or a BeagleBone Black that can connect to DStar reflectors, XREF reflectors and DCS reflectors based on Scott Lawson KI4LKF software is easy. +Creating a portable ircddb hotspot based on a Raspberry Pi or a BeagleBone Black that can connect to DStar reflectors, XREF reflectors and DCS reflectors based on this software is easy. -As configured, this software requires a Debian or Debian-based Linux OS and is specifically designed for a Raspberry Pi (http://raspberrypi.org) on Raspbian Liunx or a BeagleBone Black (http://beagleboard.org) running Debian Linux. Depending on your knowledge with your choice of OS, you can probably get this to work on others as well. The closer you are to a Debian base, the easier it will be. +As configured, this software requires a Debian or Debian-based Linux OS and works very well on a Raspberry Pi (http://raspberrypi.org) on Raspbian Liunx or a BeagleBone Black (http://beagleboard.org) running Debian Linux. Depending on your knowledge with your choice of OS, you can probably get this to work on others as well. The closer you are to a Debian base, the easier it will be. -Start with a Raspberry Pi with the latest Raspbian image (see http://raspberrypi.org) or a BeagleBone Black with the latest Debian image (see http://www.armhf.com). Scott's software will EASILY fit on the 2gb on-board memory of the older Rev. B of the BBB, but you will still need a uSD card to install the armhf.com Debian image to the on-board memory. If you are using Raspbian on a RasPi, be sure to configure Raspbian with the `sudo raspi-config` command. If you are using Debian on a BBB, be sure to look over the notes on expanding the uSD memory on the www.armhf.com website. +Start with a Raspberry Pi with the latest Raspbian image (see http://raspberrypi.org) or a BeagleBone Black with the latest Debian image (see http://www.armhf.com). This software will EASILY fit on the 2gb on-board memory of the older Rev. B of the BBB, but you will still need a uSD card to install the armhf.com Debian image to the on-board memory. If you are using Raspbian on a RasPi, be sure to configure Raspbian with the `sudo raspi-config` command. If you are using Debian on a BBB, be sure to look over the notes on expanding the uSD memory on the www.armhf.com website. You can also use the new Debian images on BeagleBone.org. New BBBs (with the 4gb on-board memory) are now shipping with Debian instead of Angstrom and g2_ircddb will compile and install just fine on this Debian image. However, right now (late June 2014) there are still some minor bugs in this package, e.g., `halt` in a ssh shell will hang the shell. Hopefully, `sudo apt-get upgrade` will eventually fix this. -You will need several packages to build Scott's gateway. The RasPi will probably have all or most of these but it still doesn't hurt to be sure: +You will need several packages to build software. The RasPi will probably have most of these but it still doesn't hurt to be sure: ``` sudo apt-get update sudo apt-get upgrade -sudo apt-get install make g++ unzip git +sudo apt-get install make g++ unzip git libconfig++-dev ``` and maybe a few more of your favorite packages. Here is one of my favorites: `sudo apt-get install avahi-daemon`. Then you can `ssh user@hostname.local` instead of `ssh user@ip_address`. @@ -27,7 +31,15 @@ After you install all the required packages, the g2_ircddb gateway installation ``` git clone git://github.com/ac2ie/g2_ircddb.git ``` -Then cd into the new g2_ircddb directory and review the `BUILDING` and `CONFIGURING` file for further instructions. +Then cd into the new g2_ircddb directory and review the `BUILDING` and `CONFIGURING` file for further instructions, here is an outline: +``` +Build the wxWidgets library. +Make the g2 modules. +Edit the configuration file, g2.cfg. +Download the latest gateway list, gwys.txt. +Install g2. +Reboot and enjoy! +``` 73 diff --git a/dvap_rptr.cfg b/dvap_rptr.cfg deleted file mode 100644 index c2f8375..0000000 --- a/dvap_rptr.cfg +++ /dev/null @@ -1,82 +0,0 @@ -# This is the configuration file for the DVAP device(2m dongle with antenna) - -# This is Dstar repeater callsign -# Use a correct repeater call. -# If you set RPTR different from the OWNER -# then only the RF user identified by RPTR callsign can talk on this repeater. -# This mode is called "restriction" mode and in some countries(UK,...) -# it is the only valid mode that you can use, while waiting for a repeater license. -# In a case like this, set RPTR to be your personal callsign -RPTR= - -# This is the Gateway callsign -# This must be equal to the OWNER value in the gateway software(g2_ircddb.cfg) -OWNER= - -# To protect the repeater owners from bad STN programs out there -# and to also protect the repeater owners from RF users that abuse the STN stuff -# Reject values in YRCALL that start with STN -# If you want to allow the local RF users to subscribe to remote STN groups, -# then set it to XXX or something that is invalid like 123 -INVALID_YRCALL_KEY=STN - -# This is the module of the Dstar repeater -# Please read the comments about RPTR_PORT below -RPTR_MOD= - -# This identifies the IP for the repeater(controler) -# The DVAP device will run here -# For repeater module A: RPTR_PORT=19998 -# For repeater module B: RPTR_PORT=19999 -# For repeater module C: RPTR_PORT=20000 -RPTR_VIRTUAL_IP=0.0.0.0 -RPTR_PORT=20000 - -# This is the INTERNAL IP and PORT of your local G2 gateway -G2_INTERNAL_IP=127.0.0.1 -G2_PORT=19000 - -# This is the serial number of your DVAP device -DVP_SERIAL=APXXXXXX - -# This is your 2m frequency for the DVAP device, Between 144000000 and 148000000 -# of course, 70cm frequencies are also acceptable for the 70cm DVAP. -DVP_FREQ=145500000; - -# This is the power level for the DVAP device, Between -12 and 10 -DVP_PWR=10; - -# This is the squelch setting for the DVAP device, between -128 and -45 -DVP_SQL=-100; - -# This is the offset frequency for the DVAP device, between -2000 and 2000 -DVP_OFF=0; - -# How long before we say that the local gateway has stopped sending packets to our repeater. -# This value is in seconds. -# Lets say that you set REMOTE_TIMEOUT=2 seconds and WAIT_FOR_PACKETS=25 milliseconds -# The program does a small calculation: ( (REMOTE_TIMEOUT * 1000) / WAIT_FOR_PACKETS)) -# So that is (2000 / 25) = 80 = number_of_times_to_loop -# This calculated value of 80 is the number of times we will loop waiting for -# packets from the remote system. -# A value of 2 is sufficient. Minimum is 1 seconds. -REMOTE_TIMEOUT=2 - -# This is used in a loop to wait for packets from your local gateway -# This is in milliseconds -WAIT_FOR_PACKETS=25 - -# This is in seconds, -# It allows the dvap to re-initialize before we send the repeater ack back to it -DELAY_BEFORE=2 - -# This is in milliseconds -# Dstar packets should reach the dvap at a rate of about 17-23 milliseconds -# We use that when we send a repeater ack back to the DVAP -DELAY_BETWEEN=19 -# 19 seems to be a good value for both the RasPi and the BBB. - -# Do you want a repeater ack sent to dvap, after the local RF radio user releases PTT ? -# Valid values are Y or N -RPTR_ACK=Y - diff --git a/dvap_rptr.cpp b/dvap_rptr.cpp index 3d0acd0..0d49ea4 100644 --- a/dvap_rptr.cpp +++ b/dvap_rptr.cpp @@ -1,6 +1,8 @@ /* * Copyright (C) 2010, 2011 by Scott Lawson KI4LKF * + * Copyright (C) 2015 by Thomas A. Early AC2IE + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -39,6 +41,11 @@ #include #include "versions.h" +#include +#include +using namespace std; +using namespace libconfig; + #define VERSION DVAP_VERSION #define CALL_SIZE 8 #define RPTR_SIZE 8 @@ -120,24 +127,24 @@ struct dvap_ack_arg_type { dvap_ack_arg_type dvap_ack_arg; /* Default configuration data */ -static char RPTR[RPTR_SIZE + 1] = {"ABCDEF"}; -static char OWNER[RPTR_SIZE + 1] = {"ABCDEF"}; -static char RPTR_MOD = 'B'; -static char RPTR_VIRTUAL_IP[IP_SIZE + 1] = {"172.16.0.1"}; -static int RPTR_PORT = 20000; -static char G2_INTERNAL_IP[IP_SIZE + 1] = {"172.16.0.20"}; -static int G2_PORT = 20000; +static char RPTR[RPTR_SIZE + 1]; +static char OWNER[RPTR_SIZE + 1]; +static char RPTR_MOD; +static char RPTR_VIRTUAL_IP[IP_SIZE + 1]; +static int RPTR_PORT; +static char G2_INTERNAL_IP[IP_SIZE + 1]; +static int G2_PORT; static char DVP_SERIAL[64]; /* APxxxxxx */ -static u_int32_t DVP_FREQ = 145500000; /* between 144000000 and 148000000 */ -static int16_t DVP_PWR = 10; /* between -12 and 10 */ -static char DVP_SQL = -100; /* between -128 and -45 */ -static int16_t DVP_OFF = 0; /* between -2000 and 2000 */ -static int WAIT_FOR_PACKETS=25; /* wait 25 ms in reading from local G2 */ -static int REMOTE_TIMEOUT=1; /* 1 second */ -static int DELAY_BETWEEN = 20; -static int DELAY_BEFORE = 1; -static bool RPTR_ACK = true; -static char INVALID_YRCALL_KEY[CALL_SIZE + 1] = { "" }; +static u_int32_t DVP_FREQ; /* between 144000000 and 148000000 */ +static int16_t DVP_PWR; /* between -12 and 10 */ +static char DVP_SQL; /* between -128 and -45 */ +static int16_t DVP_OFF; /* between -2000 and 2000 */ +static int WAIT_FOR_PACKETS; /* wait 25 ms in reading from local G2 */ +static int REMOTE_TIMEOUT; /* 1 second */ +static int DELAY_BETWEEN; +static int DELAY_BEFORE; +static bool RPTR_ACK; +static char INVALID_YRCALL_KEY[CALL_SIZE + 1]; /* helper data */ static int32_t val32bits = 1; @@ -344,7 +351,7 @@ static void traceit(const char *fmt,...) time(<ime); localtime_r(<ime,&mytm); - snprintf(trace_buf,TRACE_BFSZ - 1,"%02d%02d%02d at %02d:%02d:%02d:", + snprintf(trace_buf,TRACE_BFSZ - 1,"%02d/%02d/%02d %02d:%02d:%02d:", mytm.tm_mon+1,mytm.tm_mday,mytm.tm_year % 100, mytm.tm_hour,mytm.tm_min,mytm.tm_sec); @@ -357,194 +364,177 @@ static void traceit(const char *fmt,...) return; } +bool get_value(const Config &cfg, const char *path, int &value, int min, int max, int default_value) +{ + if (cfg.lookupValue(path, value)) { + if (value < min || value > max) + value = default_value; + } else + value = default_value; + traceit("%s = [%d]\n", path, value); + return true; +} + +bool get_value(const Config &cfg, const char *path, double &value, double min, double max, double default_value) +{ + if (cfg.lookupValue(path, value)) { + if (value < min || value > max) + value = default_value; + } else + value = default_value; + traceit("%s = [%lg]\n", path, value); + return true; +} + +bool get_value(const Config &cfg, const char *path, bool &value, bool default_value) +{ + if (! cfg.lookupValue(path, value)) + value = default_value; + traceit("%s = [%s]\n", path, value ? "true" : "false"); + return true; +} + +bool get_value(const Config &cfg, const char *path, string &value, int min, int max, const char *default_value) +{ + if (cfg.lookupValue(path, value)) { + int l = value.length(); + if (lmax) { + traceit("%s is invalid\n", path, value.c_str()); + return false; + } + } else + value = default_value; + traceit("%s = [%s]\n", path, value.c_str()); + return true; +} + /* process configuration file */ static int read_config(const char *cfgFile) { - short int valid_params = 18; - short int params = 0; - - FILE *cnf = NULL; - char inbuf[1024]; - char *p = NULL; - char *ptr; - unsigned short i; - - cnf = fopen(cfgFile, "r"); - if (!cnf) { - traceit("Failed to open file %s\n", cfgFile); + int i; + Config cfg; + + traceit("Reading file %s\n", cfgFile); + // Read the file. If there is an error, report it and exit. + try { + cfg.readFile(cfgFile); + } + catch(const FileIOException &fioex) { + traceit("Can't read %s\n", cfgFile); + return 1; + } + catch(const ParseException &pex) { + traceit("Parse error at %s:%d - %s\n", pex.getFile(), pex.getLine(), pex.getError()); return 1; } - traceit("Reading file %s\n", cfgFile); - while (fgets(inbuf, 1020, cnf) != NULL) { - if (strchr(inbuf, '#')) - continue; - - p = strchr(inbuf, '\r'); - if (p) - *p = '\0'; - p = strchr(inbuf, '\n'); - if (p) - *p = '\0'; - - p = strchr(inbuf, '='); - if (!p) - continue; - *p = '\0'; - - if (strcmp(inbuf,"RPTR") == 0) { - memset(RPTR,' ', sizeof(RPTR)); - RPTR[RPTR_SIZE] = '\0'; - - ptr = strchr(p + 1, ' '); - if (ptr) - *ptr = '\0'; - - if ((strlen(p + 1) < 1) || (strlen(p + 1) > (RPTR_SIZE - 2))) - traceit("RPTR value [%s] invalid\n", p + 1); - else { - memcpy(RPTR, p + 1, strlen(p + 1)); - traceit("RPTR=[%s]\n",RPTR); - params ++; + string dvap_path, value; + for (i=0; i<3; i++) { + dvap_path = "module."; + dvap_path += ('a' + i); + if (cfg.lookupValue(dvap_path + ".type", value)) { + if (0 == strcasecmp(value.c_str(), "dvap")) + break; + } + } + if (i >= 3) { + traceit("dvap not defined in any module!\n"); + return 1; + } + RPTR_MOD = 'A' + i; + + if (cfg.lookupValue(string(dvap_path+".callsign").c_str(), value) || cfg.lookupValue("ircddb.login", value)) { + int l = value.length(); + if (l<3 || l>CALL_SIZE-2) { + traceit("Call '%s' is invalid length!\n", value.c_str()); + return 1; + } else { + for (i=0; i (RPTR_SIZE - 2))) - traceit("OWNER value [%s] invalid\n", p + 1); - else { - memcpy(OWNER, p + 1, strlen(p + 1)); - traceit("OWNER=[%s]\n",OWNER); - params ++; + value.resize(CALL_SIZE, ' '); + } + strcpy(RPTR, value.c_str()); + traceit("%s.login = [%s]\n", dvap_path.c_str(), RPTR); + } else { + traceit("%s.login is not defined!\n", dvap_path.c_str()); + return 1; + } + + if (cfg.lookupValue("ircddb.login", value)) { + int l = value.length(); + if (l<3 || l>CALL_SIZE-2) { + traceit("Call '%s' is invalid length!\n", value.c_str()); + return 1; + } else { + for (i=0; i CALL_SIZE) ) - traceit("INVALID_YRCALL_KEY value [%s] invalid\n", p + 1); - else { - memcpy(INVALID_YRCALL_KEY, p + 1, strlen(p + 1)); + if (get_value(cfg, string(dvap_path+".invalid_prefix").c_str(), value, 1, CALL_SIZE, "XXX")) { + if (islower(value[i])) + value[i] = toupper(value[i]); + value.resize(CALL_SIZE, ' '); + strcpy(INVALID_YRCALL_KEY, value.c_str()); + } else + return 1; - for (i = 0; i < strlen(INVALID_YRCALL_KEY); i++) - INVALID_YRCALL_KEY[i] = toupper(INVALID_YRCALL_KEY[i]); + if (get_value(cfg, string(dvap_path+".internal_ip").c_str(), value, 7, IP_SIZE, "0.0.0.0")) + strcpy(RPTR_VIRTUAL_IP, value.c_str()); + else + return 1; - traceit("INVALID_YRCALL_KEY=[%s]\n",INVALID_YRCALL_KEY); - params ++; - } - } else if (strcmp(inbuf,"RPTR_MOD") == 0) { - RPTR_MOD = *(p + 1); - traceit("RPTR_MOD=[%c]\n", *(p + 1)); - params ++; - } else if (strcmp(inbuf,"RPTR_VIRTUAL_IP") == 0) { - ptr = strchr(p + 1, ' '); - if (ptr) - *ptr = '\0'; - - if (strlen(p + 1) < 1) - traceit("RPTR_VIRTUAL_IP value [%s] invalid\n", p + 1); - else { - strncpy(RPTR_VIRTUAL_IP, p + 1, IP_SIZE); - RPTR_VIRTUAL_IP[IP_SIZE] = '\0'; - traceit("RPTR_VIRTUAL_IP=[%s]\n", RPTR_VIRTUAL_IP); - params ++; - } - } else if (strcmp(inbuf,"RPTR_PORT") == 0) { - RPTR_PORT = atoi(p + 1); - traceit("RPTR_PORT=[%d]\n",RPTR_PORT); - params ++; - } else if (strcmp(inbuf,"G2_INTERNAL_IP") == 0) { - ptr = strchr(p + 1, ' '); - if (ptr) - *ptr = '\0'; - - if (strlen(p + 1) < 1) - traceit("G2_INTERNAL_IP value [%s] invalid\n", p + 1); - else { - strncpy(G2_INTERNAL_IP, p + 1, IP_SIZE); - G2_INTERNAL_IP[IP_SIZE] = '\0'; - traceit("G2_INTERNAL_IP=[%s]\n", G2_INTERNAL_IP); - params ++; - } - } else if (strcmp(inbuf,"G2_PORT") == 0) { - G2_PORT = atoi(p + 1); - traceit("G2_PORT=[%d]\n",G2_PORT); - params ++; - } else if (strcmp(inbuf,"DVP_SERIAL") == 0) { - ptr = strchr(p + 1, ' '); - if (ptr) - *ptr = '\0'; - - if ((strlen(p + 1) > 63) || (strlen(p + 1) < 1)) - traceit("DVP_SERIAL value [%s] invalid\n", p + 1); - else { - strcpy(DVP_SERIAL, p + 1); - traceit("DVP_SERIAL=[%s]\n", DVP_SERIAL); - params ++; - } - } else if (strcmp(inbuf,"DVP_FREQ") == 0) { - DVP_FREQ = atoi(p + 1); - traceit("DVP_FREQ=[%u]\n", DVP_FREQ); - params ++; - } else if (strcmp(inbuf,"DVP_PWR") == 0) { - DVP_PWR = atoi(p + 1); - traceit("DVP_PWR=[%d]\n", DVP_PWR); - params ++; - } else if (strcmp(inbuf,"DVP_SQL") == 0) { - DVP_SQL = atoi(p + 1); - traceit("DVP_SQL=[%d]\n", DVP_SQL); - params ++; - } else if (strcmp(inbuf,"DVP_OFF") == 0) { - DVP_OFF = atoi(p + 1); - traceit("DVP_OFF=[%u]\n", DVP_OFF); - params ++; - } else if (strcmp(inbuf,"WAIT_FOR_PACKETS") == 0) { - WAIT_FOR_PACKETS = atoi(p + 1); - if (WAIT_FOR_PACKETS <= 5) - WAIT_FOR_PACKETS = 25; - traceit("WAIT_FOR_PACKETS=[%d]\n",WAIT_FOR_PACKETS); - params ++; - } else if (strcmp(inbuf,"REMOTE_TIMEOUT") == 0) { - REMOTE_TIMEOUT = atoi(p + 1); - if (REMOTE_TIMEOUT < 1) - REMOTE_TIMEOUT = 1; - traceit("REMOTE_TIMEOUT=[%d]\n",REMOTE_TIMEOUT); - params ++; - } else if (strcmp(inbuf,"DELAY_BETWEEN") == 0) { - DELAY_BETWEEN = atoi(p + 1); - if (DELAY_BETWEEN <= 0) - DELAY_BETWEEN = 20; - traceit("DELAY_BETWEEN=[%d]\n",DELAY_BETWEEN); - params ++; - } else if (strcmp(inbuf,"DELAY_BEFORE") == 0) { - DELAY_BEFORE = atoi(p + 1); - if (DELAY_BEFORE <= 0) - DELAY_BEFORE = 1; - traceit("DELAY_BEFORE=[%d]\n",DELAY_BEFORE); - params ++; - } else if (strcmp(inbuf,"RPTR_ACK") == 0) { - if (*(p + 1) == 'Y') - RPTR_ACK = true; - else - RPTR_ACK = false; - traceit("RPTR_ACK=[%c]\n", *(p + 1)); - params ++; - } + i = 19998 + (RPTR_MOD - 'A'); + get_value(cfg, string(dvap_path+".port").c_str(), RPTR_PORT, 10000, 65535, i); + + if (get_value(cfg, "gateway.ip", value, 7, IP_SIZE, "127.0.0.1")) + strcpy(G2_INTERNAL_IP, value.c_str()); + else { + traceit("gateway.ip '%s' is invalid!\\n", value.c_str()); + return 1; } - fclose(cnf); - if (params != valid_params) { - traceit("Configuration file %s invalid\n",cfgFile); + get_value(cfg, "gateway.internal.port", G2_PORT, 10000, 65535, 19000); + + if (get_value(cfg, string(dvap_path+".serial_number").c_str(), value, 8, 10, "APXXXXXX")) + strcpy(DVP_SERIAL, value.c_str()); + else { + traceit("%s.serial_number '%s' is invalid!\n", dvap_path.c_str(), value.c_str()); return 1; } - /********* HERE HERE check for valid values *************/ - /* check valid values */ - /********* HERE HERE check for valid values *************/ + double f; + get_value(cfg, string(dvap_path+".frequency").c_str(), f, 100.0, 1400.0, 145.5); + DVP_FREQ = (u_int32_t)(1.0e6*f); + + get_value(cfg, string(dvap_path+".power").c_str(), i, -12, 10, 10); + DVP_PWR = (int16_t)i; + + get_value(cfg, string(dvap_path+".squelch").c_str(), i, -128, -45, -100); + DVP_SQL = (char)i; + + get_value(cfg, string(dvap_path+".offset").c_str(), i, -2000, 2000, 0.0); + DVP_OFF = (int16_t)i; + + get_value(cfg, string(dvap_path+".packet_wait").c_str(), WAIT_FOR_PACKETS, 6, 100, 25); + + get_value(cfg, "timing.timeout.remote_g2", REMOTE_TIMEOUT, 1, 10, 2); + + get_value(cfg, "timing.play.delay", DELAY_BETWEEN, 9, 25, 19); + + get_value(cfg, "timing.play.wait", DELAY_BEFORE, 1, 10, 2); + + get_value(cfg, string(dvap_path+".acknowledge").c_str(), RPTR_ACK, false); inactiveMax = (REMOTE_TIMEOUT * 1000) / WAIT_FOR_PACKETS; traceit("Max loops = %d\n", inactiveMax); diff --git a/dvap_rptr.sh b/dvap_rptr.sh index ddd2020..7d08ef0 100755 --- a/dvap_rptr.sh +++ b/dvap_rptr.sh @@ -20,7 +20,7 @@ while [ 1 ]; do - /usr/local/bin/dvap_rptr /usr/local/etc/dvap_rptr.cfg > /var/log/dvap_rptr.log 2>&1 + /usr/local/bin/dvap_rptr /usr/local/etc/g2.cfg > /var/log/dvap_rptr.log 2>&1 sleep 10 done diff --git a/dvrptr.cfg b/dvrptr.cfg deleted file mode 100644 index b46b31b..0000000 --- a/dvrptr.cfg +++ /dev/null @@ -1,106 +0,0 @@ - -# This is the repeater callsign -# This must be equal to the OWNER value in the gateway software(g2_ircddb.cfg) -DVCALL= - -# If you operate in "restriction mode", set RPTR equal to your personal callsign -# otherwise set RPTR equal to the value of DVCALL -RPTR= - -# If you want to enable/disable the repeater, set these options. -# Each of these options can NOT be more than 8 characters. -# Each of these options can NOT be another user's callsign. -# Each of these options can NOT be another repeater or reflector. -# Each of these options can NOT be a YRCALL command. -# If these options are set, then they can NOT be equal to each other. -# Lets take an example: -# ENABLE_RF=RFISON -# DISABLE_RF=RFISOFF -# Using the above options, if you use YRCALL=RFISOFF in your radio -# then the repeater will be OFF -# and no audio will be copied over local RF -# and no audio will be accepted from any remote system. -ENABLE_RF=RFISON -DISABLE_RF=RFISOFF - -# This must be equal to: FROM_REMOTE_G2_TIMEOUT + 1 -# Note: FROM_REMOTE_G2_TIMEOUT is in the gateway configuration -REMOTE_TIMEOUT=3 - -# This is the module of the Dstar repeater -DVRPTR_MOD=B - -# To protect the repeater owners from bad STN programs out there -# and to also protect the repeater owners from RF users that abuse the STN stuff -# Reject values in YRCALL that start with STN -# If you want to allow the local RF users to subscribe to remote STN groups, -# then set it to XXX or something that is invalid like 123 -INVALID_YRCALL_KEY=XXX - -# Your serial number -DVRPTR_SERIAL=12.19.D3.42 - -# For repeater module A: DVRPTR_INTERNAL_PORT=19998 -# For repeater module B: DVRPTR_INTERNAL_PORT=19999 -# For repeater module C: DVRPTR_INTERNAL_PORT=20000 -# Repeater IP and port, the repeater runs here -DVRPTR_INTERNAL_IP=0.0.0.0 -# for module B, port is 19999 -DVRPTR_INTERNAL_PORT=19999 - -# The Internal G2 IP and port -GATEWAY_IP=127.0.0.1 -GATEWAY_PORT=19000 - -# Some settings for your DV-RPTR modem -RF_AUDIO_Level=60 - -# Do you want an ACK back ? -RPTR_ACK=Y - -# ACK delay in milliseconds(ms) -# Minimum is 1, maximum is 999 -# If you do not get a repeater ACK, then make it a higher number -# Some radios get the ACK in 250ms, other radios require 750ms -ACK_DELAY=300 - -# For each packet inside the ACK, delay so many milliseconds, -# so the ICOM Dstar radio can process the ACK -DELAY_BETWEEN=19 - -# This is the TX-delay in milliseconds and it is used to delay the PTT. -# Seme radios have "SLOW" switching time, -# If your radio switches slow from RX to TX, then give your radio more time to switch, maybe 250 ms -# If your radio switches fast from RX to TX, then you could set it to 100 ms or maybe less -# But the best value should be the one to match your radio, so read the manual for your radio. -# In tests that were done for SLOW and FAST radios, we set it to 100 for FAST radios and 250 for SLOW radios. -TX_DELAY=250 - -# Dead firmware ? -# Lets say that you set RQST_COUNT=10 -# When there is NO local RF activity, (we do NOT receive anything from the DV-RPTR modem), -# then every 2 seconds we request the status from the DV-RPTR modem. -# If the DV-RPTR modem does NOT reply to our command, then after sending the command 10 times(RQST_COUNT) -# we have to assume the firmware in the DV-RPTR modem is DEAD. -# So, we send the command every 2 sedonds, and after sending the command 10 times, -# that is about (2 * 10) = 20 seconds, -# the repeater software will stop if the DV-RPTR modem does not respond after 20 seconds( 2 seconds * 10 times ) -# and then the service script will restart the repeater software. -# This is used to protect the repeater owner from BAD firmware. -# Minimum value is 6. -# If you see in the log this: "Modem is not responding... shuttting down" -# Then that means that the firmware died and the DV-RPTR modem stopped responding. -# You can increase the value of RQST_COUNT if you have a slow computer, -# (or maybe your computer is running too many programs and can not service the USB/serial fast enough) -# but we were informed that this is a bug in the firmware and they are trying to fix it. -# So, increasing the value for RQST_COUNT to higher than 10, does not make much sense. -RQST_COUNT=10 - -# If you want duplex, set it to Y -DUPLEX=N - -# These values depend on what type of tranceiver is connected to your DV-RPTR modem -# Use either 0 or 1 -RX_Inverse=1 -TX_Inverse=0 - diff --git a/dvrptr.cpp b/dvrptr.cpp index a856c3d..f48ad99 100644 --- a/dvrptr.cpp +++ b/dvrptr.cpp @@ -22,6 +22,11 @@ #include #include #include "versions.h" +#include +#include + +using namespace std; +using namespace libconfig; #define VERSION DVRPTR_VERSION #define BAUD B115200 @@ -1802,245 +1807,199 @@ static void calcPFCS(unsigned char packet[58])//Netzwerk CRC return; } +bool get_value(const Config &cfg, const char *path, int &value, int min, int max, int default_value) +{ + if (cfg.lookupValue(path, value)) { + if (value < min || value > max) + value = default_value; + } else + value = default_value; + logdata("%s = [%d]\n", path, value); + return true; +} + +bool get_value(const Config &cfg, const char *path, double &value, double min, double max, double default_value) +{ + if (cfg.lookupValue(path, value)) { + if (value < min || value > max) + value = default_value; + } else + value = default_value; + logdata("%s = [%lg]\n", path, value); + return true; +} + +bool get_value(const Config &cfg, const char *path, bool &value, bool default_value) +{ + if (! cfg.lookupValue(path, value)) + value = default_value; + logdata("%s = [%s]\n", path, value ? "true" : "false"); + return true; +} + +bool get_value(const Config &cfg, const char *path, string &value, int min, int max, const char *default_value) +{ + if (cfg.lookupValue(path, value)) { + int l = value.length(); + if (lmax) { + logdata("%s is invalid\n", path, value.c_str()); + return false; + } + } else + value = default_value; + logdata("%s = [%s]\n", path, value.c_str()); + return true; +} + +/* process configuration file */ static int read_config(const char *cfgFile) { - short int valid_params = 21; - short int params = 0; - - FILE *cnf = NULL; - char inbuf[1024]; - char *p = NULL; - char *ptr; - unsigned short i; - - cnf = fopen(cfgFile, "r"); - if (!cnf) { - logdata("Failed to open file %s\n", cfgFile); - return 1; - } + int i; + Config cfg; logdata("Reading file %s\n", cfgFile); - while (fgets(inbuf, 1020, cnf) != NULL) { - if (strchr(inbuf, '#')) - continue; - - p = strchr(inbuf, '\r'); - if (p) - *p = '\0'; - p = strchr(inbuf, '\n'); - if (p) - *p = '\0'; + // Read the file. If there is an error, report it and exit. + try { + cfg.readFile(cfgFile); + } + catch(const FileIOException &fioex) { + logdata("Can't read %s\n", cfgFile); + return 1; + } + catch(const ParseException &pex) { + logdata("Parse error at %s:%d - %s\n", pex.getFile(), pex.getLine(), pex.getError()); + return 1; + } - p = strchr(inbuf, '='); - if (!p) - continue; - *p = '\0'; - - if (strcmp(inbuf,"DVCALL") == 0) { - memset(DVCALL,' ', sizeof(DVCALL)); - DVCALL[RPTR_SIZE] = '\0'; - - ptr = strchr(p + 1, ' '); - if (ptr) - *ptr = '\0'; - - if ((strlen(p + 1) < 1) || (strlen(p + 1) > (RPTR_SIZE - 2))) - logdata("DVCALL value [%s] invalid\n", p + 1); - else { - memcpy(DVCALL, p + 1, strlen(p + 1)); - logdata("DVCALL=[%s]\n",DVCALL); - params ++; - } - } else if (strcmp(inbuf,"RPTR") == 0) { - memset(RPTR,' ', sizeof(RPTR)); - RPTR[RPTR_SIZE] = '\0'; - - ptr = strchr(p + 1, ' '); - if (ptr) - *ptr = '\0'; - - if ((strlen(p + 1) < 1) || (strlen(p + 1) > (RPTR_SIZE - 2))) - logdata("RPTR value [%s] invalid\n", p + 1); - else { - memcpy(RPTR, p + 1, strlen(p + 1)); - logdata("RPTR=[%s]\n",RPTR); - params ++; - } - } else if (strcmp(inbuf,"DVRPTR_SERIAL") == 0) { - memset(DVRPTR_SERIAL, 0, sizeof(DVRPTR_SERIAL)); - strncpy(DVRPTR_SERIAL, p + 1, 11); - DVRPTR_SERIAL[11] = '\0'; - logdata("DVRPTR_SERIAL=[%s]\n",DVRPTR_SERIAL); - params ++; - } else if (strcmp(inbuf,"GATEWAY_IP") == 0) { - ptr = strchr(p + 1, ' '); - if (ptr) - *ptr = '\0'; - - if (strlen(p + 1) < 1) - logdata("GATEWAY_IP value [%s] invalid\n", p + 1); - else { - strncpy(GATEWAY_IP, p + 1, IP_SIZE); - GATEWAY_IP[IP_SIZE] = '\0'; - logdata("GATEWAY_IP=[%s]\n", GATEWAY_IP); - params ++; - } - } else if (strcmp(inbuf,"DVRPTR_INTERNAL_PORT") == 0) { - DVRPTR_INTERNAL_PORT = atoi(p + 1); - logdata("DVRPTR_INTERNAL_PORT=[%d]\n",DVRPTR_INTERNAL_PORT); - params ++; - } else if (strcmp(inbuf,"DVRPTR_INTERNAL_IP") == 0) { - ptr = strchr(p + 1, ' '); - if (ptr) - *ptr = '\0'; - - if (strlen(p + 1) < 1) - logdata("DVRPTR_INTERNAL_IP value [%s] invalid\n", p + 1); - else { - strncpy(DVRPTR_INTERNAL_IP, p + 1, IP_SIZE); - DVRPTR_INTERNAL_IP[IP_SIZE] = '\0'; - logdata("DVRPTR_INTERNAL_IP=[%s]\n", DVRPTR_INTERNAL_IP); - params ++; - } - } else if (strcmp(inbuf,"GATEWAY_PORT") == 0) { - GATEWAY_PORT = atoi(p + 1); - logdata("GATEWAY_PORT=[%d]\n",GATEWAY_PORT); - params ++; - } else if (strcmp(inbuf,"DVRPTR_MOD") == 0) { - DVRPTR_MOD = *(p + 1); - - logdata("DVRPTR_MOD=[%c]\n", *(p + 1)); - params ++; - } else if (strcmp(inbuf,"INVALID_YRCALL_KEY") == 0) { - memset(INVALID_YRCALL_KEY, 0, sizeof(INVALID_YRCALL_KEY)); - - if ( (strlen(p + 1) < 1) || (strlen(p + 1) > CALL_SIZE) ) - logdata("INVALID_YRCALL_KEY value [%s] invalid\n", p + 1); - else { - memcpy(INVALID_YRCALL_KEY, p + 1, strlen(p + 1)); - - for (i = 0; i < strlen(INVALID_YRCALL_KEY); i++) - INVALID_YRCALL_KEY[i] = toupper(INVALID_YRCALL_KEY[i]); - - logdata("INVALID_YRCALL_KEY=[%s]\n",INVALID_YRCALL_KEY); - params ++; - } - } else if (strcmp(inbuf,"RF_AUDIO_Level") == 0) { - RF_AUDIO_Level = atoi(p + 1); - if (RF_AUDIO_Level < 0) - RF_AUDIO_Level = 1; - Modem_Init2[7] = RF_AUDIO_Level; - logdata("RF_AUDIO_Level=[%d]\n",RF_AUDIO_Level); - params ++; - } else if (strcmp(inbuf,"DUPLEX") == 0) { - if (*(p + 1) == 'Y') - DUPLEX = true; - else - DUPLEX = false; - logdata("DUPLEX=[%c]\n", *(p + 1)); - params ++; - } else if (strcmp(inbuf,"RPTR_ACK") == 0) { - if (*(p + 1) == 'Y') - RPTR_ACK = true; - else - RPTR_ACK = false; - logdata("RPTR_ACK=[%c]\n", *(p + 1)); - params ++; - } else if (strcmp(inbuf,"ACK_DELAY") == 0) { - ACK_DELAY = atol(p + 1); - if ((ACK_DELAY < 1) || (ACK_DELAY > 999)) - ACK_DELAY = 250; - logdata("ACK_DELAY=[%ld]\n", ACK_DELAY); - ACK_DELAY = ACK_DELAY * 1000; - params ++; - } else if (strcmp(inbuf,"DELAY_BETWEEN") == 0) { - DELAY_BETWEEN = atoi(p + 1); - if (DELAY_BETWEEN < 10) - DELAY_BETWEEN = 16; - logdata("DELAY_BETWEEN=[%d]\n", DELAY_BETWEEN); - DELAY_BETWEEN = DELAY_BETWEEN * 1000; - params ++; - } else if (strcmp(inbuf,"RQST_COUNT") == 0) { - RQST_COUNT = atoi(p + 1); - if (RQST_COUNT < 6) - RQST_COUNT = 6; - logdata("RQST_COUNT=[%d]\n",RQST_COUNT); - params ++; - } else if (strcmp(inbuf,"ENABLE_RF") == 0) { - memset(ENABLE_RF,' ', sizeof(ENABLE_RF)); - ENABLE_RF[RPTR_SIZE] = '\0'; - - ptr = strchr(p + 1, ' '); - if (ptr) - *ptr = '\0'; - - if (strlen(p + 1) > RPTR_SIZE) - logdata("ENABLE_RF value [%s] invalid\n", p + 1); - else { - memcpy(ENABLE_RF, p + 1, strlen(p + 1)); - logdata("ENABLE_RF=[%s]\n",ENABLE_RF); - params ++; + string path, value; + for (i=0; i<3; i++) { + path = "module."; + path += ('a' + i); + if (cfg.lookupValue(path + ".type", value)) { + if (0 == strcasecmp(value.c_str(), "dvrptr")) + break; + } + } + if (i >= 3) { + logdata("dvrptr not defined in any module!\n"); + return 1; + } + DVRPTR_MOD = 'A' + i; + + if (cfg.lookupValue(string(path+".callsign").c_str(), value) || cfg.lookupValue("ircddb.login", value)) { + int l = value.length(); + if (l<3 || l>CALL_SIZE-2) { + logdata("Call '%s' is invalid length!\n", value.c_str()); + return 1; + } else { + for (i=0; i RPTR_SIZE) - logdata("DISABLE_RF value [%s] invalid\n", p + 1); - else { - memcpy(DISABLE_RF, p + 1, strlen(p + 1)); - logdata("DISABLE_RF=[%s]\n",DISABLE_RF); - params ++; + value.resize(CALL_SIZE, ' '); + } + strcpy(RPTR, value.c_str()); + logdata("%s.callsign = [%s]\n", path.c_str(), RPTR); + } else { + logdata("%s.callsign is not defined!\n", path.c_str()); + return 1; + } + + if (cfg.lookupValue("ircddb.login", value)) { + int l = value.length(); + if (l<3 || l>CALL_SIZE-2) { + logdata("Call '%s' is invalid length!\n", value.c_str()); + return 1; + } else { + for (i=0; i 6000) { - TX_DELAY = 250; - logdata("TX-delay exceeds maximum of 6000, setting it back to 250"); - } - Modem_Init2[8] = TX_DELAY & 0xFF; - Modem_Init2[9] = TX_DELAY >> 8; - logdata("TX_DELAY=[%d]\n",TX_DELAY); - params ++; + if (get_value(cfg, string(path+".rf_control.off").c_str(), value, 0, CALL_SIZE, " ")) + strcpy(DISABLE_RF, value.c_str()); + else + logdata("%s.rf_control.off '%s' is invalid, rejected.\n", path.c_str(), value.c_str()); + + if (cfg.lookupValue("timing.timeout.remote_g2", REMOTE_TIMEOUT)) { + REMOTE_TIMEOUT++; + if (REMOTE_TIMEOUT < 1) + REMOTE_TIMEOUT = 2; + } else + REMOTE_TIMEOUT = 3; + logdata("timing.timeout.remote_g2 = [%d]\n", REMOTE_TIMEOUT); + + if (get_value(cfg, string(path+".invalid_prefix").c_str(), value, 1, CALL_SIZE, "XXX")) { + value.resize(CALL_SIZE, ' '); + for (i=0; i> 8; + + get_value(cfg, string(path+".rqst_count").c_str(), RQST_COUNT, 6, 20, 10); + + get_value(cfg, string(path+".inverse.rx").c_str(), RX_Inverse, true); + get_value(cfg, string(path+".inverse.tx").c_str(), TX_Inverse, true); + inactiveMax = (REMOTE_TIMEOUT * 1000000) / 400; logdata("... computed max number of loops %d, each loop is 400 microseconds\n", inactiveMax); @@ -2055,7 +2014,7 @@ static void logdata(const char *fmt,...) time(<ime); localtime_r(<ime,&mytm); - snprintf(trace_buf,TRACE_BFSZ - 1,"%02d%02d%02d at %02d:%02d:%02d:", + snprintf(trace_buf,TRACE_BFSZ - 1,"%02d/%02d/%02d %02d:%02d:%02d:", mytm.tm_mon+1,mytm.tm_mday,mytm.tm_year % 100, mytm.tm_hour,mytm.tm_min,mytm.tm_sec); trace_buf[TRACE_BFSZ - 1] = '\0'; diff --git a/dvrptr.sh b/dvrptr.sh index c2df708..e7c70ca 100755 --- a/dvrptr.sh +++ b/dvrptr.sh @@ -2,7 +2,7 @@ while [ 1 ]; do - /usr/local/bin/dvrptr /usr/local/etc/dvrptr.cfg > /var/log/dvrptr.log 2>&1 + /usr/local/bin/dvrptr /usr/local/etc/g2.cfg > /var/log/dvrptr.log 2>&1 sleep 3 done diff --git a/g2.dvap.cfg b/g2.dvap.cfg new file mode 100644 index 0000000..ec6e107 --- /dev/null +++ b/g2.dvap.cfg @@ -0,0 +1,24 @@ +# g2_ircddb Configuration for me + +ircddb = { + login = "MYCALL" +# If you are not using rr.openquad.net, you need to specify the host and possibly the password. +# +# host = "some.server.host" // others include group1-irc.ircddb.net +# password = "1111111111111" // not needed for rr.penquad.net +} + +module = { + c = { // change the module to "b" if you have a 70cm DVAP + type = "dvap" + serial_number = "AP123456" // your serial number is visible through the case + frequency = 145.5 // this is the default value, chose a quiet frequency +# uncomment and set if you want the following to appear on you ircddb host website. +# range = 0.0 // in meters (1609.344 is one mile) +# agl = 0.0 // in meters +# latitude = 0.000000 // north is positive +# longitude = 0.000000 // east is positive +# desc1 = "Location1" // up to 20 chars +# desc2 = "location2" // up to 20 chars + } +} diff --git a/g2.everything.cfg b/g2.everything.cfg new file mode 100644 index 0000000..9366556 --- /dev/null +++ b/g2.everything.cfg @@ -0,0 +1,282 @@ +# g2_ircddb Configuration + +ircddb = { +# login = ""; # login callsign for the ircDDB network +# host = "rr.openquad.net" # other include group1-irc.ircddb.net +# port = 9007 # not a good idea to change! +# password = "1111111111111" # not needed for Openquad +} + +gateway = { +# regen_header = true # regenerate headers from incoming data +# send_qrgs_maps = true # send frequecy, offset, cooridinates and url to irc-server +# local_irc_ip = "0.0.0.0" # 0.0.0.0 means accept any incoming connections +# arps_send = true # send info to aprs +# ip = "127.0.0.1" # where the gateway is running + + external = { +# ip = "0.0.0.0" +# port = 40000 + } + + internal = { +# ip = "0.0.0.0" +# port = 19000 + } +} +module = { + a = { +# type = "" +# ip = "127.0.0.1" +# port = 19998 # default for mod a + } + + b = { + # a DVRPTR connected to a 70cm radio is shown in this example + + # type must be defined. This is how the dvrptr program finds the config params. +# type = "dvrptr" + + # If you operate in "restriction mode", set callsign equal to your personal callsign + # Otherwise do not set callsign and we will use ircddb.username +# callsign = "" + + # the frequency of your DVAP in MHz. +# frequency = 145.5 + + # the TX/RX offset in MHz, use 0.0 for simplex +# offset = 0 + + # the range of this repeater, in meters 1609.344 meters is 1.0 miles +# range = 0.0 + + # the height above ground level for you repeater's antenna +# agl = 0.0 + + # the latitude of your repeater +# latitude = 0.0 + + # the longitude of your repeater +# longitude = 0.0 + + # This is used in a loop to wait for packets from your local gateway + # This is in milliseconds +# packet_wait = 25 + + # description of repeater, part one and two 20 char max each +# desc1 = "" +# desc2 = "" + + # the url of your repeater, 80 chars max, defaults to "github.com/ac2ie/g2_ircddb +# url = "" # 80 char max, defaults to "github.com/ac2ie/g2_ircddb + + # If you want to enable/disable the repeater, set these options. + # Each of these options can NOT be more than 8 characters. + # Each of these options can NOT be another user's callsign. + # Each of these options can NOT be another repeater or reflector. + # Each of these options can NOT be a YRCALL command. + # If these options are set, then they can NOT be equal to each other. + # Using the above options, if you use YRCALL=RFISOFF in your radio + # then the repeater will be OFF and no audio will be copied over local RF + # and no audio will be accepted from any remote system. + # these command are disabled by default + # You can choose your own command strings, if you want to enable these + rf_control { +# on = "RFISON" +# off = "RFISOFF" + } + + # To protect the repeater owners from bad STN programs out there + # and to also protect the repeater owners from RF users that abuse the STN stuff + # Reject values in YRCALL that start with STN + # If you want to allow the local RF users to subscribe to remote STN groups, + # then set it to XXX or something that is invalid like 123 +# invalid_prefix = "XXX" + + # Your DVRPTR V1 serial number + # If you don't know what it is, run the program and look in the log file! +# serial_number = "00.00.00.00" + + # the dvrptr program runs here, leave the commented out unless you know what you are doing! +# internal_ip = "0.0.0.0" +# port = 19999 # default for mod b + + # Some settings for your DVRPTR modem (see DVRPTR V1 manual for more info). +# rf_rx_level = 80 + + # If you need duplex, set it to true +# duplex = false + + # Do you want an ACK back ? +# acknowledge = false + + # ACK delay in milliseconds(ms) + # Minimum is 1, maximum is 999 + # If you do not get a repeater ACK, then make it a higher number + # Some radios get the ACK in 250ms, other radios require 750ms +# ack_delay = 300 + + # This is the TX-delay in milliseconds and it is used to delay the PTT. + # Seme radios have "SLOW" switching time, + # If your radio switches slow from RX to TX, then give your radio more time to switch, maybe 250 ms + # If your radio switches fast from RX to TX, then you could set it to 100 ms or maybe less + # But the best value should be the one to match your radio, so read the manual for your radio. + # In tests that were done for SLOW and FAST radios, we set it to 100 for FAST radios and 250 for SLOW radios. +# tx_delay = 250 + + # Dead firmware ? + # Lets say that you set RQST_COUNT=10 + # When there is NO local RF activity, (we do NOT receive anything from the DV-RPTR modem), + # then every 2 seconds we request the status from the DV-RPTR modem. + # If the DV-RPTR modem does NOT reply to our command, then after sending the command 10 times(RQST_COUNT) + # we have to assume the firmware in the DV-RPTR modem is DEAD. + # So, we send the command every 2 sedonds, and after sending the command 10 times, + # that is about (2 * 10) = 20 seconds, + # the repeater software will stop if the DV-RPTR modem does not respond after 20 seconds( 2 seconds * 10 times ) + # and then the service script will restart the repeater software. + # This is used to protect the repeater owner from BAD firmware. + # Minimum value is 6. + # If you see in the log this: "Modem is not responding... shuttting down" + # Then that means that the firmware died and the DV-RPTR modem stopped responding. + # You can increase the value of RQST_COUNT if you have a slow computer, + # (or maybe your computer is running too many programs and can not service the USB/serial fast enough) + # but we were informed that this is a bug in the firmware and they are trying to fix it. + # So, increasing the value for RQST_COUNT to higher than 10, does not make much sense. +# rqst_count = 10 + + # These values depend on what type of tranceiver is connected to your DV-RPTR modem + # Use either true or false + inverse { +# rx = true +# tx = true + } + } + + c = { + # a 2m DVAP is shown as an example + + # type must be defined. This is how the dvap_rptr program finds the config params. +# type = "dvap" + + # If you operate in "restriction mode", set RPTR equal to your personal callsign + # Otherwise do not set callsign and it will use ircddb.username +# callsign = "" + + # TX DVAP power level -12 to 10, 10 is maximum poower +# power = 10 + + # Squelch, -128 to -45, -100 to -80 usually works best +# squelch = -100 + + # To protect the repeater owners from bad STN programs out there + # and to also protect the repeater owners from RF users that abuse the STN stuff + # Reject values in YRCALL that start with STN + # If you want to allow the local RF users to subscribe to remote STN groups, + # then set it to XXX or something that is invalid like 123 +# ivalid_prefix = "XXX" + + # The serial number of you DVAP is visible through the bottom of the case +# serial_number = "APXXXXXX" + + # the DVAP will send a blip to acknowledge a transmission +# acknowledge = false + + # the frequency of your DVAP in MHz. +# frequency = 145.5 + + # this is for tweaking the frequency of your DVAP, see the owner's manual +# dvap_offset = 0 + + # the range of this repeater, in meters 1609.344 meters is 1.0 miles +# range = 0.0 + + # the height above ground level for you repeater's antenna +# agl = 0.0 + + # the latitude of your repeater +# latitude = 0.0 + + # the longitude of your repeater +# longitude = 0.0 + + # This is used in a loop to wait for packets from your local gateway + # This is in milliseconds +# packet_wait = 25 + + # description of repeater, part one and two 20 char max each +# desc1 = "" +# desc2 = "" + + # the url of your repeater, 80 chars max, defaults to "github.com/ac2ie/g2_ircddb +# url = "" # 80 char max, defaults to "github.com/ac2ie/g2_ircddb + + # where other g2 programs find this repeater software +# ip = "127.0.0.1" # where is the device running? must be a "dotted number" + + # the internal ip of this program, "0.0.0.0" is usually best +# internal_ip = "0.0.0.0" + + # port number default: A:19990 B:19999 C:20000 +# port = 20000 # default for mod C + } +} + + +log = { + # debuging and extra logging switches +# qso = true # QSO info goes into the log +# irc = false # IRC debug info +# dtmf = false # DTMF debug info +} + +aprs = { # APRS.NET connect info +# host = "rotate.aprs.net" +# port = 14580 +# interval = 40 +# filter = "" +} + +g2_link = { +# link_at_start = "NONE" # Link to a reflector at startup. +# to link repeater module B to REF001 C, use "BREF001C" +# ref_login = "" # for loging into REF reflectors, if undefined, ircddb.username will be used +# users = [ "CALL1", "CALL2", "CALL3" ] # if defined, only these users can use this gateway +# link_unlink = [ "CALL4", "CALL5", "CALL6" ] # if defined, only these users can link and unlink a repeater +# incoming_ip = "0.0.0.0" # incoming ip address, "0.0.0.0" means accepts all connections. +# ip = "127.0.0.1" # where g2_link is running +# port = 18997 # port for communications to g2_link +# ref_port = 20001 # port for REF linking, don't change +# xrf_port = 30001 # port for XRF linking, don't change +# dcs_port = 30051 # port for DCS linking, don't change +# announce = true # do link, unlink, etc. announcements +# acknowledge = true # sent text acknowledgement on key-up +# max_dongles = 5 # maximum number of linked hotspots +} + +file = { +# status = "/usr/local/etc/rptr_status" # where repeater status info is passed between services +# DTMF = "/tmp" # +# echotest = "/tmp" # echo dat files will end up here +# gwys = "/usr/local/etc/gwys.txt" # where the list of gateways and reflectors (with ports) is. +# announce_dir = "/usr/local/etc" # where are the *.dat files for the verbal link, unlink, etc. announcements +} + +timing = { + timeout = { +# echo = 1 # delay time in seconds for echo +# voicemail = 1 # delay time for voicemail +# remote_g2 = 2 # after this many seconds with no packets, we assume the tx is closed +# local_rptr = 1 # local timeout, in seconds + } + + play = { +# wait = 2 # seconds before playback occurs, between 1 and 10 +# delay = 19 # microseconds between frames playback, if echo sounds bad, adjust this up or down 1,2 microseconds + } + + inactivity = { +# a = 0 # unlink repeater if no activity for this many minutes +# b = 0 # zero mean there will be no timer +# c = 0 + } +} diff --git a/g2_ircddb.cfg b/g2_ircddb.cfg deleted file mode 100644 index 7174141..0000000 --- a/g2_ircddb.cfg +++ /dev/null @@ -1,192 +0,0 @@ -# -# Copyright (C) 2010, 2011, 2012 by Scott Lawson KI4LKF -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -# -# g2_ircddb.cfg configuration file for g2_ircddb gateway - -# Your G2 Gateway callsign can be up to 6 characters -# This will also be used to connect to the remote ircDDB server -# and validate you on the DStar system -# YOU MUST SET THIS TO A VAILD CALLSIGN - -OWNER = - -# RPTR_X = Type | Frequency(MHz) | Offset(MHz) | Range(m) | above ground level(m) | latitude | longitude | description#1 | description#2 | URL -# If you do NOT want to define a parameter for a module, then leave the parameter BLANK, except... -# Type: 0 is DVAP, 1 is DVRPTR. YOU MUST SPECIFY THIS PARAMETER. -# only the first 20 characters of the descriptions and 64 characters of the URL will be used. -# Example for a 2m DVRPTR connected to an antenna 10 meters above ground level with a range of 10 miles -# RPTR_C = 1 | 146.5 | 0 | 16093.44 | 10 | 42.0000 | -73.0000 | Mytown, MyState | MyCountry or MyGridSquare | github.com/ac2ie/g2_ircddb -# YOU MUST DEFINE AT LEAST ONE REPEATER! - -#RPTR_A = 1 | | | | | | | | | github.com/ac2ie/g2_ircddb -#RPTR_B = 1 | | | | | | | | | github.com/ac2ie/g2_ircddb -RPTR_C = 0 | | | | | | | | | github.com/ac2ie/g2_ircddb - -################################################################################################### -# All other parameters are optional. Uncomment the assignments to set a different value. -# This is for APRS/GPS - -#SEND_APRS = Y - -# This is for the Live IRC site, or Quadnet -# if you don't want you frequency, location or url sent, set this to "N", or some of the RPTR_X fields empty. - -#SEND_QRGS_MAPS = Y - -# Which local address on your Linux box will be used -# to report to the remote IRC database server(group2, group1,...) -# For most installations it is 0.0.0.0 (which binds to all local IP addresses) -# If you have more than one ethernet card, then you may set it to a specific local IP -# that is assigned to that specific ethernet card -# If you have one ethernet card, you can use 0.0.0.0 - -#LOCAL_IRC_IP = 0.0.0.0 - - -# You should NOT change the value for APRS_HOST -# Leave it set to: rotate.aprs.net -# The only time to change it is when you have your own APRS_HOST server -# or when you have a server that is closer to your QTH - -#APRS_HOST = rotate.aprs.net -#APRS_PORT = 14580 -# How often to report the aprs beacon, in minutes, Do NOT make it less than 40 -#APRS_INTERVAL = 40 -#APRS_FILTER= - -# The G2 external port of this Gateway server -# Remote gateways will route data here - -#G2_EXTERNAL_IP = 0.0.0.0 -#G2_EXTERNAL_PORT = 40000 - -# The G2 internal port of this Gateway server -# Our local repeater modules will send data here - -#G2_INTERNAL_IP = 0.0.0.0 -#G2_INTERNAL_PORT = 19000 - -# Where is the g2_link running? - -#TO_G2_LINK_IP = 127.0.0.1 -#TO_G2_LINK_PORT = 18997 - -# The repeater modules of this repeater -#TO_RPTR_IP_A = 127.0.0.1 -#TO_RPTR_PORT_A = 19998 - -#TO_RPTR_IP_B = 127.0.0.1 -#TO_RPTR_PORT_B = 19999 - -#TO_RPTR_IP_C = 127.0.0.1 -#TO_RPTR_PORT_C = 20000 - -# Timeouts in seconds -# We need these timeouts because the END-OF-AUDIO packet can get lost. -# Of course it can get lost, because everything about Dstar is on UDP -# UDP is notorious for losing packets. -# Each packet arrives normally 20ms after previous packet, -# so giving it 1 second is more than enough. -# This 1-second timeout was used internally in the g2_ircddb software, -# but now the user has a chance to change it. -# We do not believe that it should be changed, -# As mentioned before, more than 1 second is more than -# enough to make sure that we should stop waiting for more packets. - -# Echotest-recording timeout: -# If after 1 second, audio stops coming in for echotest-recording, -# we will stop recording for ECHOTEST - -#ECHOTEST_REC_TIMEOUT = 1 - -# Voicemail-recording timeout: -# If after 1 second, audio stops coming in for voicemail-recording, -# we will stop recording for voicemail - -#VOICEMAIL_REC_TIMEOUT = 1 - -# If after 2 seconds, we do not receive any more packets from remote system, -# we will assume that the remote QSO has stopped - -#FROM_REMOTE_G2_TIMEOUT = 2 - -# If after 1 second, we do not receive any more packets from -# our local repeater, we will assume that the local RF user has stopped talking. - -#FROM_LOCAL_RPTR_TIMEOUT = 1 - -# print QSO details - -#QSO_DETAILS = Y - -# These 2 options limit the lines in the log. -# For production systems, we recommend: IRC_DEBUG=N - -#IRC_DEBUG = N -#DTMF_DEBUG = N - -# Do you want to re-generate the HEADER if there is a timeout from -# messages arriving from remote systems(reflectors, gateways, ...) - -#REGEN_HDR = Y - -# LINK STATUS file -# This file is created by g2_link -# This gateway will ONLY read that status file -# to determine if any module is linked to anything - -#STATUS_FILE = /usr/local/etc/RPT_STATUS.txt - -#DTMF_DIR = /tmp - -# Directory of recorded files created in ECHOTEST/playback mode - -#ECHOTEST_DIR = /tmp - -# How many SECONDS to wait before starting to playback the recorded file. -# 1 second is enough, some repeaters require 2 seconds to re-initialize -# before they accept new streams again. -# must be between 1 and 10 - -# PLAY_WAIT = 2 - -# How many MILLIseconds to delay when playing back each of the recorded packets -# Normal VoIP is 20 milliseconds or a little less -# must be between 10 and 50 - -#PLAY_DELAY = 19 - -# The remote ircDDB database -# For US, Canada and North America -# IRC_DDB_HOST=group2-irc.ircddb.net -# For the German and EU -# IRC_DDB_HOST=group1-irc.ircddb.net -# For registration free routing, use OpenQuad's round-robin, rr.openquad.net - -#IRC_DDB_HOST = rr.openquad.net - -# The remote ircDDB port - -#IRC_DDB_PORT = 9007 - -# Your ircDDB password given to you by the German ircDDB team. -# Put your correct password here. -# you will only need this with a club call using group1-irc - -#IRC_PASS = 1111111111111111 - diff --git a/g2_ircddb.cpp b/g2_ircddb.cpp index ae54b72..7bb93a3 100644 --- a/g2_ircddb.cpp +++ b/g2_ircddb.cpp @@ -52,8 +52,9 @@ #include #include -#include +#include using namespace std; +using namespace libconfig; #include @@ -73,20 +74,39 @@ using namespace std; /* configuration data */ -/* Gateway callsign */ -static char OWNER[CALL_SIZE + 1]; -static char owner[CALL_SIZE + 1]; -//static char PACKAGE_REV[56]; - -static char LOCAL_IRC_IP[IP_SIZE + 1]; -static bool SEND_QRGS_MAPS = false; +typedef struct portip_tag { + string ip; + int port; +} PORTIP; -static char STATUS_FILE[FILENAME_MAX + 1]; +/* Gateway callsign */ +static string OWNER; +static string owner; +static string local_irc_ip; +static string status_file; +static string dtmf_dir; +static string dtmf_file; +static string echotest_dir; +static string irc_pass; + + +PORTIP g2_internal, g2_external, g2_link, ircddb; + +static bool bool_send_qrgs; +static bool bool_irc_debug; +static bool bool_dtmf_debug; +static bool bool_regen_header; +static bool bool_qso_details; +static bool bool_send_aprs; + +static int play_wait; +static int play_delay; +static int echotest_rec_timeout; +static int voicemail_rec_timeout; +static int from_remote_g2_timeout; +static int from_local_rptr_timeout; static unsigned char silence[9] = { 0x4e,0x8d,0x32,0x88,0x26,0x1a,0x3f,0x61,0xe8 }; - -static char DTMF_DIR[FILENAME_MAX + 1]; -static char DTMF_FILE[FILENAME_MAX + 1]; static const int MAX_DTMF_BUF = 32; static char dtmf_chars[17] = "147*2580369#ABCD"; static int dtmf_digit; @@ -96,9 +116,6 @@ static int dtmf_buf_count[3] = {0, 0, 0}; static unsigned int dtmf_counter[3] = {0, 0, 0}; static int dtmf_last_frame[3] = {0, 0, 0}; -static bool IRC_DEBUG = false; -static bool DTMF_DEBUG = false; -static bool REGEN_HDR = false; /* the aprs TCP socket */ static int aprs_sock = -1; @@ -107,75 +124,22 @@ static socklen_t aprs_addr_len; /* data needed for aprs login and aprs beacon */ static struct rptr_struct{ - char aprs_host[MAXHOSTNAMELEN + 1]; - int aprs_port; + PORTIP aprs; + string aprs_filter; int aprs_hash; int aprs_interval; - char aprs_filter[512]; /* 0=A, 1=B, 2=C */ struct mod_struct { - char call[CALL_SIZE + 1]; /* KJ4NHF-B */ + string call; /* KJ4NHF-B */ bool defined; - char band[5]; /* 23cm ... */ + string band; /* 23cm ... */ double frequency, offset, latitude, longitude, range, agl; - char desc1[21], desc2[21]; - char desc[64]; - char url[65]; - char package_version[56]; + string desc1, desc2, desc, url, package_version; + PORTIP portip; } mod[3]; } rptr; -/* Gateway external IP and port for remote G2 routing */ -static char G2_EXTERNAL_IP[IP_SIZE + 1]; /* 0.0.0.0 */ -static int G2_EXTERNAL_PORT = 40000; - -/* - Internal Gateway internal IP and port, - so that the local repeater modules can talk to our g2_ircddb -*/ -static char G2_INTERNAL_IP[IP_SIZE + 1]; /* 0.0.0.0 */ -static int G2_INTERNAL_PORT = 19000; - -/* We send repeater data to our g2_link */ -static int TO_G2_LINK_PORT = 18997; -static char TO_G2_LINK_IP[IP_SIZE + 1]; - -/* local repeater module IP and port for each repeater module */ -/* all set to 127.0.0.1, unless running on other boxes */ -static char TO_RPTR_IP[3][IP_SIZE + 1]; -static int TO_RPTR_PORT[3]; /* Example: 19998 19999 20000 */ - -/* QSO details go to a log file */ -static bool QSO_DETAILS = false; - -static bool SEND_APRS = false; - -/* Recorded files are here */ -static char ECHOTEST_DIR[FILENAME_MAX + 1]; - -/* - How many SECONDS to wait before starting to playback the recorded file. - 1 second is enough, some repeaters require 2 seconds to re-initialize - before they accept new streams again. -*/ -static int PLAY_WAIT = 1; - -/* - How many MILLIseconds to delay when playing back each of the recorded packets - Normal VoIP is 20 milliseconds -*/ -static int PLAY_DELAY = 20; - -static char IRC_DDB_HOST[512]; -static int IRC_DDB_PORT = 9007; -static char IRC_PASS[512]; - -static int ECHOTEST_REC_TIMEOUT = 1; -static int VOICEMAIL_REC_TIMEOUT = 1; -static int FROM_REMOTE_G2_TIMEOUT = 1; -static int FROM_LOCAL_RPTR_TIMEOUT = 1; - /* local repeater modules being recorded */ /* This is for echotest */ static struct { @@ -232,8 +196,6 @@ static unsigned char end_of_audio[29]; static volatile bool keep_running = true; -//static time_t wd_timer = 0; - /* send packets to g2_link */ static struct sockaddr_in plug; @@ -403,7 +365,7 @@ static void set_dest_rptr(int mod_ndx, char *dest_rptr); extern void dstar_dv_init(); extern int dstar_dv_decode(const unsigned char *d, int data[3]); -static bool resolve_rmt(char *name, int type, struct sockaddr_in *addr) +static bool resolve_rmt(const char *name, int type, struct sockaddr_in *addr) { struct addrinfo hints; struct addrinfo *res; @@ -444,7 +406,7 @@ static void set_dest_rptr(int mod_ndx, char *dest_rptr) char *saveptr = NULL; char *p = NULL; - statusfp = fopen(STATUS_FILE, "r"); + statusfp = fopen(status_file.c_str(), "r"); if (statusfp) { setvbuf(statusfp, (char *)NULL, _IOLBF, 0); @@ -527,7 +489,7 @@ static void traceit(const char *fmt,...) time(<ime); localtime_r(<ime, &tm); - snprintf(buf,BFSZ - 1,"%02d%02d%02d at %d:%02d:%02d:", + snprintf(buf,BFSZ - 1,"%02d/%02d/%02d %d:%02d:%02d:", tm.tm_mon+1,tm.tm_mday,tm.tm_year % 100, tm.tm_hour,tm.tm_min,tm.tm_sec); @@ -540,60 +502,47 @@ static void traceit(const char *fmt,...) return; } +bool get_value(const Config &cfg, const char *path, int &value, int min, int max, int default_value) +{ + if (cfg.lookupValue(path, value)) { + if (value < min || value > max) + value = default_value; + } else + value = default_value; + traceit("%s = [%d]\n", path, value); + return true; +} -static char *trim(char *s) +bool get_value(const Config &cfg, const char *path, double &value, double min, double max, double default_value) { - if (s) { - // remove trailing whitespace - while (strlen(s) && isspace(s[strlen(s)-1])) - s[strlen(s)-1] = (char)NULL; - // move s to first non-space char - while (isspace(*s)) - s++; - } - return s; + if (cfg.lookupValue(path, value)) { + if (value < min || value > max) + value = default_value; + } else + value = default_value; + traceit("%s = [%lg]\n", path, value); + return true; } -static bool parse_config(const char *filename, map ¶m) +bool get_value(const Config &cfg, const char *path, bool &value, bool default_value) { - struct stat s_buf; - int rc = stat(filename, &s_buf); - if (rc) { - traceit("Failed to stat '%s'\n", filename); - return false; - } - char *file = (char *)calloc((size_t)s_buf.st_size+1, sizeof(char)); - if (NULL == file) { - traceit("failed to calloc memory\n"); - return false; - } - FILE *f = fopen(filename, "r"); - if (NULL == f) { - traceit("failed to open '%s'\n", filename); - return false; - } - if (s_buf.st_size != fread(file, sizeof(char), s_buf.st_size, f)) { - traceit("failed to read '%s'\n", filename); - fclose(f); - free(file); - return false; - } - fclose(f); - char *pline, *pvalue; - char *line = trim(strtok_r(file, "\n", &pline)); - while (line) { - if (strlen(line) && *line!='#' && strchr(line, '=')) { - char *key = trim(strtok_r(line, "=", &pvalue)); - if (strlen(key)) { - char *value = trim(strtok_r(NULL, "=", &pvalue)); - if (value) { - param[key] = value; - } - } + if (! cfg.lookupValue(path, value)) + value = default_value; + traceit("%s = [%s]\n", path, value ? "true" : "false"); + return true; +} + +bool get_value(const Config &cfg, const char *path, string &value, int min, int max, const char *default_value) +{ + if (cfg.lookupValue(path, value)) { + int l = value.length(); + if (lmax) { + traceit("%s is invalid\n", path, value.c_str()); + return false; } - line = trim(strtok_r(NULL, "\n", &pline)); - } - free(file); + } else + value = default_value; + traceit("%s = [%s]\n", path, value.c_str()); return true; } @@ -601,391 +550,153 @@ static bool parse_config(const char *filename, map ¶m) static int read_config(char *cfgFile) { unsigned short i; - char *tok = NULL; - const char *Tstr = "TRUE"; - const char *Fstr = "FALSE"; - char zero = (char)NULL; - - map param; + Config cfg; traceit("Reading file %s\n", cfgFile); - if (! parse_config(cfgFile, param)) - return 1; - - map::iterator pit = param.find("OWNER"); - if (param.end() == pit) { - traceit("OWNER not defined!\n"); + // Read the file. If there is an error, report it and exit. + try { + cfg.readFile(cfgFile); + } + catch(const FileIOException &fioex) { + traceit("Can't read %s\n", cfgFile); return 1; } - if (pit->second.length()<3 || pit->second.length() > CALL_SIZE-2) { - traceit("OWNER value '%s' invalid\n", pit->second.c_str()); + catch(const ParseException &pex) { + traceit("Parse error at %s:%d - %s\n", pex.getFile(), pex.getLine(), pex.getError()); return 1; } - strcpy(OWNER, pit->second.c_str()); - strcpy(owner, pit->second.c_str()); - for (i=0; i 20) + rptr.mod[m].desc1.resize(20); + if (rptr.mod[m].desc2.length() > 20) + rptr.mod[m].desc2.resize(20); + // make the long description for the log + if (rptr.mod[m].desc1.length()) + rptr.mod[m].desc = rptr.mod[m].desc1 + ' '; + rptr.mod[m].desc += rptr.mod[m].desc2; + } else + rptr.mod[m].defined = false; } if (false==rptr.mod[0].defined && false==rptr.mod[1].defined && false==rptr.mod[2].defined) { traceit("No repeaters defined!\n"); return 1; } - pit = param.find("STATUS_FILE"); - if (param.end() == pit) - strcpy(STATUS_FILE, "/usr/local/etc/RPT_STATUS.txt"); - else { - strncpy(STATUS_FILE, pit->second.c_str() ,FILENAME_MAX); - STATUS_FILE[FILENAME_MAX] = zero; - } - traceit("STATUS_FILE=[%s]\n", STATUS_FILE); - - pit = param.find("LOCAL_IRC_IP"); - if (param.end() == pit) - strcpy(LOCAL_IRC_IP, "0.0.0.0"); - else { - if (pit->second.length()>IP_SIZE || pit->second.length()<7) { - traceit("LOCAL_IRC_IP value [%s] invalid\n", pit->second.c_str()); - return 1; - } else - strcpy(LOCAL_IRC_IP, pit->second.c_str()); - } - traceit("LOCAL_IRC_IP=[%s]\n", LOCAL_IRC_IP); + if (! get_value(cfg, "file.status", status_file, 1, FILENAME_MAX, "/usr/local/etc/RPTR_STATUS.txt")) + return 1; - pit = param.find("SEND_QRGS_MAPS"); - if (param.end() == pit) - SEND_QRGS_MAPS = true; - else - SEND_QRGS_MAPS = ('Y'==toupper(pit->second.at(0))) ? true : false; - traceit("SEND_QRGS_MAPS=[%s]\n", SEND_QRGS_MAPS ? Tstr : Fstr); - - pit = param.find("APRS_HOST"); - if (param.end() == pit) - strcpy(rptr.aprs_host, "rotate.aprs.net"); - else { - if (pit->second.length() > MAXHOSTNAMELEN) { - traceit("APRS_HOST definition is too long\n"); - return 1; - } else - strcpy(rptr.aprs_host, pit->second.c_str()); - rptr.aprs_host[MAXHOSTNAMELEN] = zero; - } - traceit("APRS_HOST=[%s]\n", rptr.aprs_host); + if (! get_value(cfg, "gateway.local_irc_ip", local_irc_ip, 7, IP_SIZE, "0.0.0.0")) + return 1; - pit = param.find("APRS_PORT"); - rptr.aprs_port = (param.end()==pit) ? 14580 : atoi(pit->second.c_str()); - traceit("APRS_PORT=[%d]\n", rptr.aprs_port); + get_value(cfg, "gateway.send_qrgs_maps", bool_send_qrgs, true); - pit = param.find("APRS_INTERVAL"); - rptr.aprs_interval = (param.end()==pit) ? 40 : atoi(pit->second.c_str()); - traceit("APRS_INTERVAL=[%d]\n", rptr.aprs_interval); - if (rptr.aprs_interval < 40) { - rptr.aprs_interval = 40; - } + if (! get_value(cfg, "aprs.host", rptr.aprs.ip, 7, MAXHOSTNAMELEN, "rotate.aprs.net")) + return 1; - pit = param.find("APRS_FILTER"); - if (param.end() != pit) { - strncpy(rptr.aprs_filter, pit->second.c_str(), 512); - rptr.aprs_filter[511] = zero; - } else - rptr.aprs_filter[0] = zero; - traceit("APRS_filter=[%s]\n", rptr.aprs_filter); - - pit = param.find("G2_EXTERNAL_IP"); - if (param.end() == pit) - strcpy(G2_EXTERNAL_IP, "0.0.0.0"); - else { - if (pit->second.length()<7 || pit->second.length()>IP_SIZE) { - traceit("G2_EXTERNAL_IP value [%s] invalid\n", pit->second.c_str()); - return 1; - } else - strcpy(G2_EXTERNAL_IP, pit->second.c_str()); - } - traceit("G2_EXTERNAL_IP=[%s]\n", G2_EXTERNAL_IP); - - pit = param.find("G2_EXTERNAL_PORT"); - G2_EXTERNAL_PORT = (param.end() == pit) ? 40000 : atoi(pit->second.c_str()); - traceit("G2_EXTERNAL_PORT=[%d]\n", G2_EXTERNAL_PORT); - - pit = param.find("G2_INTERNAL_IP"); - if (param.end() == pit) - strcpy(G2_INTERNAL_IP, "0.0.0.0"); - else { - if (pit->second.length()<7 || pit->second.length()>IP_SIZE) { - traceit("G2_INTERNAL_IP value [%s] invalid\n", pit->second.c_str()); - return 1; - } else - strcpy(G2_INTERNAL_IP, pit->second.c_str()); - } - traceit("G2_INTERNAL_IP=[%s]\n", G2_INTERNAL_IP); - - pit = param.find("G2_INTERNAL_PORT"); - G2_INTERNAL_PORT = (param.end() == pit) ? 19000 : atoi(pit->second.c_str()); - traceit("G2_INTERNAL_PORT=[%d]\n", G2_INTERNAL_PORT); - - pit = param.find("TO_G2_LINK_IP"); - if (param.end() == pit) - strcpy(TO_G2_LINK_IP, "127.0.0.1"); - else { - if (pit->second.length()<7 || pit->second.length()>IP_SIZE) { - traceit("TO_G2_LINK_IP value [%s] invalid\n", pit->second.c_str()); - return 1; - } else - strcpy(TO_G2_LINK_IP, pit->second.c_str()); - } - traceit("TO_G2_LINK_IP=[%s]\n", TO_G2_LINK_IP); - - pit = param.find("TO_G2_LINK_PORT"); - TO_G2_LINK_PORT = (param.end() == pit) ? 18997 : atoi(pit->second.c_str()); - traceit("TO_G2_LINK_PORT=[%d]\n", TO_G2_LINK_PORT); - - for (i=0; i<3; i++) { - string key = "TO_RPTR_IP_"; - key += i + 'A'; - pit = param.find(key); - if (param.end() == pit) - strcpy(TO_RPTR_IP[i], "127.0.0.1"); - else { - if (pit->second.length()<7 || pit->second.length()>IP_SIZE) { - traceit("%s address %s is invalid\n", key.c_str(), pit->second.c_str()); - return 1; - } else - strcpy(TO_RPTR_IP[i], pit->second.c_str()); - } - traceit("%s = [%s]\n", key.c_str(), TO_RPTR_IP[i]); + get_value(cfg, "aprs.port", rptr.aprs.port, 10000, 65535, 14580); - key = "TO_RPTR_PORT_"; - key += i + 'A'; - pit = param.find(key); - TO_RPTR_PORT[i] = (param.end() == pit) ? 19998+i : atoi(pit->second.c_str()); - traceit("%s=[%d]\n", key.c_str(), TO_RPTR_PORT[i]); - } + get_value(cfg, "aprs.interval", rptr.aprs_interval, 40, 1000, 40); - pit = param.find("QSO_DETAILS"); - if (param.end() == pit) - QSO_DETAILS = true; - else - QSO_DETAILS = ('Y' == toupper(pit->second.at(0))) ? true : false; - traceit("QSO_DETAILS=[%s]\n", QSO_DETAILS ? Tstr : Fstr); + if (! get_value(cfg, "aprs.filter", rptr.aprs_filter, 0, 512, "")) + return 1; - pit = param.find("IRC_DEBUG"); - if (param.end() == pit) - IRC_DEBUG = false; - else - IRC_DEBUG = ('Y' == toupper(pit->second.at(0))) ? true : false; - traceit("IRC_DEBUG=[%s]\n", IRC_DEBUG ? Tstr : Fstr); + if (! get_value(cfg, "gateway.g2_external.ip", g2_external.ip, 7, IP_SIZE, "0.0.0.0")) + return 1; - pit = param.find("DTMF_DEBUG"); - if (param.end() == pit) - DTMF_DEBUG = false; - else - DTMF_DEBUG = ('Y' == toupper(pit->second.at(0))) ? true : false; - traceit("DTMF_DEBUG=[%s]\n", DTMF_DEBUG ? Tstr : Fstr); + get_value(cfg, "gateway.g2_external.port", g2_external.port, 20001, 65535, 40000); - pit = param.find("REGEN_HDR"); - if (param.end() == pit) - REGEN_HDR = false; - else - REGEN_HDR = ('Y' == toupper(pit->second.at(0))) ? true : false; - traceit("REGEN_HDR=[%s]\n", REGEN_HDR ? Tstr : Fstr); + if (! get_value(cfg, "gateway.g2_internal.ip", g2_internal.ip, 7, IP_SIZE, "0.0.0.0")) + return 1; - pit = param.find("SEND_APRS"); - if (param.end() == pit) - SEND_APRS = true; - else - SEND_APRS = ('Y' == toupper(pit->second.at(0))) ? true : false; - traceit("SEND_APRS=[%s]\n", SEND_APRS ? Tstr : Fstr); - - pit = param.find("ECHOTEST_DIR"); - if (param.end() == pit) - strcpy(ECHOTEST_DIR, "/tmp"); - else { - if (pit->second.length() > FILENAME_MAX) { - traceit("ECHOTEST_DIR definition is too long!\n"); - return 1; - } else - strcpy(ECHOTEST_DIR, pit->second.c_str()); - } - traceit("ECHOTEST_DIR=[%s]\n", ECHOTEST_DIR); - - pit = param.find("PLAY_WAIT"); - PLAY_WAIT = (param.end() == pit) ? 2 : atoi(pit->second.c_str()); - if (PLAY_WAIT>10 || PLAY_WAIT<1) - PLAY_WAIT = 2; - traceit("PLAY_WAIT=[%d]\n", PLAY_WAIT); - - pit = param.find("PLAY_DELAY"); - PLAY_DELAY = (param.end() == pit) ? 10 : atoi(pit->second.c_str()); - if (PLAY_DELAY>50 || PLAY_DELAY<10) - PLAY_DELAY = 19; - traceit("PLAY_DELAY=[%d]\n", PLAY_DELAY); - - pit = param.find("ECHOTEST_REC_TIMEOUT"); - ECHOTEST_REC_TIMEOUT = (param.end() == pit) ? 1 : atoi(pit->second.c_str()); - if (1 > ECHOTEST_REC_TIMEOUT) - ECHOTEST_REC_TIMEOUT = 1; - traceit("ECHOTEST_REC_TIMEOUT=[%d]\n", ECHOTEST_REC_TIMEOUT); - - pit = param.find("VOICEMAIL_REC_TIMEOUT"); - VOICEMAIL_REC_TIMEOUT = (param.end() == pit) ? 1 : atoi(pit->second.c_str()); - if (1 > VOICEMAIL_REC_TIMEOUT) - VOICEMAIL_REC_TIMEOUT = 1; - traceit("VOICEMAIL_REC_TIMEOUT=[%d]\n", VOICEMAIL_REC_TIMEOUT); - - pit = param.find("FROM_REMOTE_G2_TIMEOUT"); - FROM_REMOTE_G2_TIMEOUT = (param.end() == pit) ? 2 : atoi(pit->second.c_str()); - if (1 > FROM_REMOTE_G2_TIMEOUT) - FROM_REMOTE_G2_TIMEOUT = 2; - traceit("FROM_REMOTE_G2_TIMEOUT=[%d]\n", FROM_REMOTE_G2_TIMEOUT); - - pit = param.find("FROM_LOCAL_RPTR_TIMEOUT"); - FROM_LOCAL_RPTR_TIMEOUT = (param.end() == pit) ? 1 : atoi(pit->second.c_str()); - if (1 > FROM_LOCAL_RPTR_TIMEOUT) - FROM_LOCAL_RPTR_TIMEOUT = 1; - traceit("FROM_LOCAL_RPTR_TIMEOUT=[%d]\n", FROM_LOCAL_RPTR_TIMEOUT); - - pit = param.find("IRC_DDB_HOST"); - if (param.end() == pit) - strcpy(IRC_DDB_HOST, "rr.openquad.net"); - else { - if (pit->second.length() < 511) - strcpy(IRC_DDB_HOST, pit->second.c_str()); - else { - traceit("IRC_DDB_HOST definition is too long\n"); - return 1; - } - } + get_value(cfg, "gateway.g2_internal.port", g2_internal.port, 16000, 65535, 19000); - pit = param.find("IRC_DDB_PORT"); - IRC_DDB_PORT = (param.end() == pit) ? 9007 : atoi(pit->second.c_str()); - if (IRC_DDB_PORT < 1) - IRC_DDB_PORT = 9007; - traceit("IRC_DDB_PORT=[%d]\n",IRC_DDB_PORT); - - pit = param.find("IRC_PASS"); - if (param.end() == pit) - strcpy(IRC_PASS, "1111111111111111"); - else { - if (pit->second.length() > 511) { - traceit("IRC_PASS is too long!\n"); - return 1; - } - strcpy(IRC_PASS, pit->second.c_str()); - } + if (! get_value(cfg, "g2_link.outgoing_ip", g2_link.ip, 7, IP_SIZE, "127.0.0.1")) + return 1; + + get_value(cfg, "g2_link.port", g2_link.port, 16000, 65535, 18997); + + get_value(cfg, "log.qso", bool_qso_details, true); + + get_value(cfg, "log.irc", bool_irc_debug, false); + + get_value(cfg, "log.dtmf", bool_dtmf_debug, false); + + get_value(cfg, "gateway.regen_header", bool_regen_header, true); + + get_value(cfg, "gateway.aprs_send", bool_send_aprs, true); + + if (! get_value(cfg, "file.echotest", echotest_dir, 2, FILENAME_MAX, "/tmp")) + return 1; + + get_value(cfg, "timing.play.wait", play_wait, 1, 10, 2); + + get_value(cfg, "timing.play.delay", play_delay, 9, 25, 19); + + get_value(cfg, "timing.timeeout.echo", echotest_rec_timeout, 1, 10, 1); + + get_value(cfg, "timing.timeout.voicemail", voicemail_rec_timeout, 1, 10, 1); + + get_value(cfg, "timing.timeout.remote_g2", from_remote_g2_timeout, 1, 10, 2); + + get_value(cfg, "timing.timeout.local_rptr", from_local_rptr_timeout, 1, 10, 1); + + if (! get_value(cfg, "ircddb.host", ircddb.ip, 3, MAXHOSTNAMELEN, "rr.openquad.net")) + return 1; + + get_value(cfg, "ircddb.port", ircddb.port, 1000, 65535, 9007); + + if(! get_value(cfg, "ircddb.password", irc_pass, 0, 512, "1111111111111111")) + return 1; + + if (! get_value(cfg, "file.dtmf", dtmf_dir, 2,FILENAME_MAX, "/tmp")) + return 1; - pit = param.find("DTMF_DIR"); - if (param.end() == pit) - strcpy(DTMF_DIR, "/tmp"); - else { - if (pit->second.length() < FILENAME_MAX) - strcpy(DTMF_DIR, pit->second.c_str()); - else { - traceit("DTMF_DIR definition is too long!\n"); - return 1; - } - } - traceit("DTMF_DIR=[%s]\n", DTMF_DIR); return 0; } -/* Create the 40000 external port */ +/* Create the 40000 g2_external port */ static int g2_open() { struct sockaddr_in sin; @@ -999,11 +710,11 @@ static int g2_open() memset(&sin,0,sizeof(struct sockaddr_in)); sin.sin_family = AF_INET; - sin.sin_port = htons(G2_EXTERNAL_PORT); - sin.sin_addr.s_addr = inet_addr(G2_EXTERNAL_IP); + sin.sin_port = htons(g2_external.port); + sin.sin_addr.s_addr = inet_addr(g2_external.ip.c_str()); if (bind(g2_sock,(struct sockaddr *)&sin,sizeof(struct sockaddr_in)) != 0) { - traceit("Failed to bind g2 socket on port %d, errno=%d\n",G2_EXTERNAL_PORT,errno); + traceit("Failed to bind g2 socket on port %d, errno=%d\n",g2_external.port,errno); close(g2_sock); g2_sock = -1; return 1; @@ -1011,7 +722,7 @@ static int g2_open() return 0; } -/* Create the 19000 internal port */ +/* Create the 19000 g2_internal port */ static int srv_open() { struct sockaddr_in sin; @@ -1025,12 +736,12 @@ static int srv_open() memset(&sin,0,sizeof(struct sockaddr_in)); sin.sin_family = AF_INET; - sin.sin_port = htons(G2_INTERNAL_PORT); - sin.sin_addr.s_addr = inet_addr(G2_INTERNAL_IP); + sin.sin_port = htons(g2_internal.port); + sin.sin_addr.s_addr = inet_addr(g2_internal.ip.c_str()); if (bind(srv_sock,(struct sockaddr *)&sin,sizeof(struct sockaddr_in)) != 0) { traceit("Failed to bind srv socket on port %d, errno=%d\n", - G2_INTERNAL_PORT,errno); + g2_internal.port, errno); close(srv_sock); srv_sock = -1; return 1; @@ -1108,7 +819,7 @@ static void *get_irc_data(void *arg) ii->receiveUser(user, rptr, gateway, ipaddr); if (!user.IsEmpty()) { if (!rptr.IsEmpty() && !gateway.IsEmpty() && !ipaddr.IsEmpty()) { - if (IRC_DEBUG) + if (bool_irc_debug) traceit("C-u:%s,%s,%s,%s\n", user.mb_str(), rptr.mb_str(), gateway.mb_str(), ipaddr.mb_str()); pthread_mutex_lock(&irc_data_mutex); @@ -1127,7 +838,7 @@ static void *get_irc_data(void *arg) ii->receiveRepeater(rptr, gateway, ipaddr, proto); if (!rptr.IsEmpty()) { if (!gateway.IsEmpty() && !ipaddr.IsEmpty()) { - if (IRC_DEBUG) + if (bool_irc_debug) traceit("C-r:%s,%s,%s\n", rptr.mb_str(), gateway.mb_str(), ipaddr.mb_str()); pthread_mutex_lock(&irc_data_mutex); @@ -1144,7 +855,7 @@ static void *get_irc_data(void *arg) } else if (type == IDRT_GATEWAY) { ii->receiveGateway(gateway, ipaddr, proto); if (!gateway.IsEmpty() && !ipaddr.IsEmpty()) { - if (IRC_DEBUG) + if (bool_irc_debug) traceit("C-g:%s,%s\n", gateway.mb_str(),ipaddr.mb_str()); pthread_mutex_lock(&irc_data_mutex); @@ -1340,7 +1051,7 @@ static void runit() g2_sock, srv_sock, max_nfds + 1); /* start the beacon thread */ - if (SEND_APRS) { + if (bool_send_aprs) { pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); rc = pthread_create(&aprs_beacon_thread,&attr,send_aprs_beacon,(void *)0); @@ -1368,7 +1079,7 @@ static void runit() /* echotest recording timed out? */ if (recd[i].last_time != 0) { time(&t_now); - if ((t_now - recd[i].last_time) > ECHOTEST_REC_TIMEOUT) { + if ((t_now - recd[i].last_time) > echotest_rec_timeout) { traceit("Inactivity on echotest recording mod %d, removing stream id=%d,%d\n", i,recd[i].streamid[0], recd[i].streamid[1]); @@ -1398,7 +1109,7 @@ static void runit() /* voicemail recording timed out? */ if (vm[i].last_time != 0) { time(&t_now); - if ((t_now - vm[i].last_time) > VOICEMAIL_REC_TIMEOUT) { + if ((t_now - vm[i].last_time) > voicemail_rec_timeout) { traceit("Inactivity on voicemail recording mod %d, removing stream id=%d,%d\n", i,vm[i].streamid[0], vm[i].streamid[1]); @@ -1419,7 +1130,7 @@ static void runit() so we could use either FROM_LOCAL_RPTR_TIMEOUT or FROM_REMOTE_G2_TIMEOUT but FROM_REMOTE_G2_TIMEOUT makes more sense, probably is a bigger number */ - if ((t_now - toRptr[i].last_time) > FROM_REMOTE_G2_TIMEOUT) { + if ((t_now - toRptr[i].last_time) > from_remote_g2_timeout) { traceit("Inactivity to local rptr mod index %d, removing stream id %d,%d\n", i, toRptr[i].streamid[0], toRptr[i].streamid[1]); /* @@ -1455,7 +1166,7 @@ static void runit() /* any stream coming from local repeater timed out ? */ if (band_txt[i].last_time != 0) { time(&t_now); - if ((t_now - band_txt[i].last_time) > FROM_LOCAL_RPTR_TIMEOUT) { + if ((t_now - band_txt[i].last_time) > from_local_rptr_timeout) { /* This local stream never went to a remote system, so trace the timeout */ if (to_remote_g2[i].toDst4.sin_addr.s_addr == 0) traceit("Inactivity from local rptr band %d, removing stream id %d,%d\n", @@ -1488,7 +1199,7 @@ static void runit() /* any stream from local repeater to a remote gateway timed out ? */ if (to_remote_g2[i].toDst4.sin_addr.s_addr != 0) { time(&t_now); - if ((t_now - to_remote_g2[i].last_time) > FROM_LOCAL_RPTR_TIMEOUT) { + if ((t_now - to_remote_g2[i].last_time) > from_local_rptr_timeout) { traceit("Inactivity from local rptr mod %d, removing stream id %d,%d\n", i, to_remote_g2[i].streamid[0], to_remote_g2[i].streamid[1]); @@ -1547,7 +1258,7 @@ static void runit() (readBuffer2[15] == 0x20) || (readBuffer2[15] == 0x28) || (readBuffer2[15] == 0x40))) { - if (QSO_DETAILS) + if (bool_qso_details) traceit("START from g2: streamID=%d,%d, flags=%02x:%02x:%02x, my=%.8s, sfx=%.4s, ur=%.8s, rpt1=%.8s, rpt2=%.8s, %d bytes fromIP=%s\n", readBuffer2[12],readBuffer2[13], readBuffer2[15], readBuffer2[16], readBuffer2[17], @@ -1589,7 +1300,7 @@ static void runit() } } else { if ((readBuffer2[14] & 0x40) != 0) { - if (QSO_DETAILS) + if (bool_qso_details) traceit("END from g2: streamID=%d,%d, %d bytes from IP=%s\n", readBuffer2[12],readBuffer2[13], recvlen2,inet_ntoa(fromDst4.sin_addr)); @@ -1638,7 +1349,7 @@ static void runit() } /* no match ? */ - if ((i == 3) && REGEN_HDR) { + if ((i == 3) && bool_regen_header) { /* check if this a continuation of audio that timed out */ if ((readBuffer2[14] & 0x40) != 0) @@ -1723,7 +1434,7 @@ static void runit() (readBuffer[9] == 0x16)) ) { /* 22 bytes follow */ if (recvlen == 58) { - if (QSO_DETAILS) + if (bool_qso_details) traceit("START from rptr: cntr=%02x %02x, streamID=%d,%d, flags=%02x:%02x:%02x, my=%.8s, sfx=%.4s, ur=%.8s, rpt1=%.8s, rpt2=%.8s, %d bytes fromIP=%s\n", readBuffer[4], readBuffer[5], readBuffer[14], readBuffer[15], @@ -1731,7 +1442,7 @@ static void runit() readBuffer + 44, readBuffer + 52, readBuffer + 36, readBuffer + 28, readBuffer + 20, recvlen, inet_ntoa(fromRptr.sin_addr)); - if ((memcmp(readBuffer + 28, OWNER, 7) == 0) && /* rpt1 is this repeater */ + if ((memcmp(readBuffer + 28, OWNER.c_str(), 7) == 0) && /* rpt1 is this repeater */ /*** (memcmp(readBuffer + 44, OWNER, 7) != 0) && ***/ /* MYCALL is NOT this repeater */ ((readBuffer[17] == 0x00) || /* normal */ (readBuffer[17] == 0x08) || /* EMR */ @@ -1801,7 +1512,7 @@ static void runit() band_txt[i].num_bit_errors = 0; /* select the band for aprs processing, and lock on the stream ID */ - if (SEND_APRS) + if (bool_send_aprs) aprs_select_band(i, readBuffer + 14); } } @@ -1835,11 +1546,11 @@ static void runit() (readBuffer[36] != ' ') && /* must have something */ (memcmp(readBuffer + 36, "CQCQCQ", 6) != 0)) { /* urcall is NOT CQCQCQ */ if ((readBuffer[36] == '/') && /* urcall starts with a slash */ - (memcmp(readBuffer + 28, OWNER, 7) == 0) && /* rpt1 is this repeater */ + (memcmp(readBuffer + 28, OWNER.c_str(), 7) == 0) && /* rpt1 is this repeater */ ((readBuffer[35] == 'A') || (readBuffer[35] == 'B') || (readBuffer[35] == 'C')) && /* mod is A,B,C */ - (memcmp(readBuffer + 20, OWNER, 7) == 0) && /* rpt2 is this repeater */ + (memcmp(readBuffer + 20, OWNER.c_str(), 7) == 0) && /* rpt2 is this repeater */ (readBuffer[27] == 'G') && /* local Gateway */ /*** (memcmp(readBuffer + 44, OWNER, 7) != 0) && ***/ /* mycall is NOT this repeater */ @@ -1848,7 +1559,7 @@ static void runit() (readBuffer[17] == 0x20) || /* BK */ (readBuffer[17] == 0x28)) /* EMR + BK */ ) { - if (memcmp(readBuffer + 37, OWNER, 6) != 0) { /* the value after the slash in urcall, is NOT this repeater */ + if (memcmp(readBuffer + 37, OWNER.c_str(), 6) != 0) { /* the value after the slash in urcall, is NOT this repeater */ i = -1; if (readBuffer[35] == 'A') i = 0; @@ -1877,7 +1588,7 @@ static void runit() memcpy(to_remote_g2[i].streamid, readBuffer + 14, 2); memset(&(to_remote_g2[i].toDst4),0,sizeof(struct sockaddr_in)); to_remote_g2[i].toDst4.sin_family = AF_INET; - to_remote_g2[i].toDst4.sin_port = htons(G2_EXTERNAL_PORT); + to_remote_g2[i].toDst4.sin_port = htons(g2_external.port); to_remote_g2[i].toDst4.sin_addr.s_addr = inet_addr(ip); memcpy(readBuffer2, "DSVT", 4); @@ -1929,12 +1640,12 @@ static void runit() } } } - } else if ((memcmp(readBuffer + 36, OWNER, 7) != 0) && /* urcall is not this repeater */ - (memcmp(readBuffer + 28, OWNER, 7) == 0) && /* rpt1 is this repeater */ + } else if ((memcmp(readBuffer + 36, OWNER.c_str(), 7) != 0) && /* urcall is not this repeater */ + (memcmp(readBuffer + 28, OWNER.c_str(), 7) == 0) && /* rpt1 is this repeater */ ((readBuffer[35] == 'A') || (readBuffer[35] == 'B') || (readBuffer[35] == 'C')) && /* mod is A,B,C */ - (memcmp(readBuffer + 20, OWNER, 7) == 0) && /* rpt2 is this repeater */ + (memcmp(readBuffer + 20, OWNER.c_str(), 7) == 0) && /* rpt2 is this repeater */ (readBuffer[27] == 'G') && /* local Gateway */ /*** (memcmp(readBuffer + 44, OWNER, 7) != 0) && ***/ /* mycall is NOT this repeater */ @@ -1950,7 +1661,7 @@ static void runit() result = get_yrcall_rptr(temp_radio_user, arearp_cs, zonerp_cs, &temp_mod, ip, 'U'); if (result) { /* destination is a remote system */ - if (memcmp(zonerp_cs, OWNER, 7) != 0) { + if (memcmp(zonerp_cs, OWNER.c_str(), 7) != 0) { i = -1; if (readBuffer[35] == 'A') i = 0; @@ -1966,7 +1677,7 @@ static void runit() memcpy(to_remote_g2[i].streamid, readBuffer + 14, 2); memset(&(to_remote_g2[i].toDst4),0,sizeof(struct sockaddr_in)); to_remote_g2[i].toDst4.sin_family = AF_INET; - to_remote_g2[i].toDst4.sin_port = htons(G2_EXTERNAL_PORT); + to_remote_g2[i].toDst4.sin_port = htons(g2_external.port); to_remote_g2[i].toDst4.sin_addr.s_addr = inet_addr(ip); memcpy(readBuffer2, "DSVT", 4); @@ -2139,7 +1850,7 @@ static void runit() else { memset(tempfile, '\0', sizeof(tempfile)); snprintf(tempfile, FILENAME_MAX, "%s/%c_%s", - ECHOTEST_DIR, + echotest_dir.c_str(), readBuffer[35], "voicemail.dat"); @@ -2168,10 +1879,10 @@ static void runit() recbuf[11] = readBuffer[13]; memcpy(recbuf + 12, readBuffer + 14, 44); memset(recbuf + 18, ' ', CALL_SIZE); - memcpy(recbuf + 18, OWNER, strlen(OWNER)); + memcpy(recbuf + 18, OWNER.c_str(), OWNER.length()); recbuf[25] = readBuffer[35]; memset(recbuf + 26, ' ', CALL_SIZE); - memcpy(recbuf + 26, OWNER, strlen(OWNER)); + memcpy(recbuf + 26, OWNER.c_str(), OWNER.length()); recbuf[33] = 'G'; memcpy(recbuf + 34, "CQCQCQ ", 8); @@ -2201,7 +1912,7 @@ static void runit() else { memset(tempfile, '\0', sizeof(tempfile)); snprintf(tempfile, FILENAME_MAX, "%s/%c_%s", - ECHOTEST_DIR, + echotest_dir.c_str(), readBuffer[35], "echotest.dat"); @@ -2230,10 +1941,10 @@ static void runit() recbuf[11] = readBuffer[13]; memcpy(recbuf + 12, readBuffer + 14, 44); memset(recbuf + 18, ' ', CALL_SIZE); - memcpy(recbuf + 18, OWNER, strlen(OWNER)); + memcpy(recbuf + 18, OWNER.c_str(), OWNER.length()); recbuf[25] = readBuffer[35]; memset(recbuf + 26, ' ', CALL_SIZE); - memcpy(recbuf + 26, OWNER, strlen(OWNER)); + memcpy(recbuf + 26, OWNER.c_str(), OWNER.length()); recbuf[33] = 'G'; memcpy(recbuf + 34, "CQCQCQ ", 8); @@ -2250,8 +1961,8 @@ static void runit() } else /* check for cross-banding */ if ((memcmp(readBuffer + 36, "CQCQCQ", 6) == 0) && /* yrcall is CQCQCQ */ - (memcmp(readBuffer + 28, OWNER, 7) == 0) && /* rpt1 is this repeater */ - (memcmp(readBuffer + 20, OWNER, 7) == 0) && /* rpt2 is this repeater */ + (memcmp(readBuffer + 28, OWNER.c_str(), 7) == 0) && /* rpt1 is this repeater */ + (memcmp(readBuffer + 20, OWNER.c_str(), 7) == 0) && /* rpt2 is this repeater */ ((readBuffer[35] == 'A') || (readBuffer[35] == 'B') || (readBuffer[35] == 'C')) && /* mod of rpt1 is A,B,C */ @@ -2322,13 +2033,12 @@ static void runit() if ((readBuffer[16] & 0x40) != 0) { if (dtmf_buf_count[i] > 0) { - memset(DTMF_FILE, 0, sizeof(DTMF_FILE)); - snprintf(DTMF_FILE, FILENAME_MAX, "%s/%d_mod_DTMF_NOTIFY", DTMF_DIR, i); - if (DTMF_DEBUG) - traceit("Saving dtmfs=[%s] into file: [%s]\n", dtmf_buf[i], DTMF_FILE); - dtmf_fp = fopen(DTMF_FILE, "w"); + dtmf_file = dtmf_dir + "/" + ('A'+i) + "_mod_DTMF_NOTIFY"; + if (bool_dtmf_debug) + traceit("Saving dtmfs=[%s] into file: [%s]\n", dtmf_buf[i], dtmf_file.c_str()); + dtmf_fp = fopen(dtmf_file.c_str(), "w"); if (!dtmf_fp) - traceit("Failed to create dtmf file %s\n", DTMF_FILE); + traceit("Failed to create dtmf file %s\n", dtmf_file.c_str()); else { fprintf(dtmf_fp, "%s\n%s", dtmf_buf[i], band_txt[i].lh_mycall); fclose(dtmf_fp); @@ -2468,7 +2178,7 @@ static void runit() } else if (band_txt[i].temp_line[0] != '$') { memcpy(band_txt[i].gpid, band_txt[i].temp_line, band_txt[i].temp_line_cnt); band_txt[i].gpid[band_txt[i].temp_line_cnt] = '\0'; - if (SEND_APRS && !band_txt[i].is_gps_sent) + if (bool_send_aprs && !band_txt[i].is_gps_sent) gps_send(i); } band_txt[i].temp_line[0] = '\0'; @@ -2499,7 +2209,7 @@ static void runit() } else if (band_txt[i].temp_line[0] != '$') { memcpy(band_txt[i].gpid, band_txt[i].temp_line, band_txt[i].temp_line_cnt); band_txt[i].gpid[band_txt[i].temp_line_cnt] = '\0'; - if (SEND_APRS && !band_txt[i].is_gps_sent) + if (bool_send_aprs && !band_txt[i].is_gps_sent) gps_send(i); } band_txt[i].temp_line[0] = '\0'; @@ -2650,7 +2360,7 @@ static void runit() } else if (band_txt[i].temp_line[0] != '$') { memcpy(band_txt[i].gpid, band_txt[i].temp_line, band_txt[i].temp_line_cnt); band_txt[i].gpid[band_txt[i].temp_line_cnt] = '\0'; - if (SEND_APRS && !band_txt[i].is_gps_sent) + if (bool_send_aprs && !band_txt[i].is_gps_sent) gps_send(i); } band_txt[i].temp_line[0] = '\0'; @@ -2687,7 +2397,7 @@ static void runit() } else if (band_txt[i].temp_line[0] != '$') { memcpy(band_txt[i].gpid, band_txt[i].temp_line, band_txt[i].temp_line_cnt); band_txt[i].gpid[band_txt[i].temp_line_cnt] = '\0'; - if (SEND_APRS && !band_txt[i].is_gps_sent) + if (bool_send_aprs && !band_txt[i].is_gps_sent) gps_send(i); } band_txt[i].temp_line[0] = '\0'; @@ -2717,7 +2427,7 @@ static void runit() } else if (band_txt[i].temp_line[0] != '$') { memcpy(band_txt[i].gpid, band_txt[i].temp_line, band_txt[i].temp_line_cnt); band_txt[i].gpid[band_txt[i].temp_line_cnt] = '\0'; - if (SEND_APRS && !band_txt[i].is_gps_sent) + if (bool_send_aprs && !band_txt[i].is_gps_sent) gps_send(i); } band_txt[i].temp_line[0] = '\0'; @@ -2742,7 +2452,7 @@ static void runit() sizeof(struct sockaddr_in)); /* aprs processing */ - if (SEND_APRS) + if (bool_send_aprs) aprs_process_text(readBuffer + 14, /* stream ID */ readBuffer[16], /* seq */ readBuffer + 17, /* audio + text */ @@ -2890,7 +2600,7 @@ static void runit() } if ((readBuffer[16] & 0x40) != 0) { - if (QSO_DETAILS) + if (bool_qso_details) traceit("END from rptr: cntr=%02x %02x, streamID=%d,%d, %d bytes\n", readBuffer[4], readBuffer[5], readBuffer[14],readBuffer[15],recvlen); @@ -2910,7 +2620,7 @@ static void compute_aprs_hash() char *p = NULL; char rptr_sign[CALL_SIZE + 1]; - strcpy(rptr_sign, OWNER); + strcpy(rptr_sign, OWNER.c_str()); p = strchr(rptr_sign, ' '); if (!p) { traceit("Failed to build repeater callsign for aprs hash\n"); @@ -2925,7 +2635,7 @@ static void compute_aprs_hash() hash ^= (*p++); i += 2; } - traceit("aprs hash code=[%d] for %s\n", hash, OWNER); + traceit("aprs hash code=[%d] for %s\n", hash, OWNER.c_str()); rptr.aprs_hash = hash; return; @@ -2945,29 +2655,15 @@ static void aprs_open() char rcv_buf[512]; int rc = 0; - /* do some mimimal checking */ - if (rptr.aprs_host[0] == '\0') { - traceit("Invalid value for APRS_HOST\n"); - return; - } - if (rptr.aprs_port == 0) { - traceit("Invalid value for APRS_PORT\n"); - return; - } - if (rptr.aprs_interval == 0) { - traceit("Invalid value for APRS_INTERVAL\n"); - return; - } - - ok = resolve_rmt(rptr.aprs_host, SOCK_STREAM, &aprs_addr); + ok = resolve_rmt(rptr.aprs.ip.c_str(), SOCK_STREAM, &aprs_addr); if (!ok) { - traceit("Can not resolve APRS_HOST %s\n", rptr.aprs_host); + traceit("Can not resolve APRS_HOST %s\n", rptr.aprs.ip.c_str()); return; } /* fill it in */ aprs_addr.sin_family = AF_INET; - aprs_addr.sin_port = htons(rptr.aprs_port); + aprs_addr.sin_port = htons(rptr.aprs.port); aprs_addr_len = sizeof(aprs_addr); @@ -3034,16 +2730,16 @@ static void aprs_open() return; } } - traceit("Connected to APRS %s:%d\n", rptr.aprs_host, rptr.aprs_port); + traceit("Connected to APRS %s:%d\n", rptr.aprs.ip.c_str(), rptr.aprs.port); /* login to aprs */ sprintf(snd_buf, "user %s pass %d vers g2_ircddb 2.99 UDP 5 ", - OWNER, rptr.aprs_hash); + OWNER.c_str(), rptr.aprs_hash); /* add the user's filter */ - if (rptr.aprs_filter[0] != '\0') { + if (rptr.aprs_filter.length()) { strcat(snd_buf, "filter "); - strcat(snd_buf, rptr.aprs_filter); + strcat(snd_buf, rptr.aprs_filter.c_str()); } // traceit("APRS login command:[%s]\n", snd_buf); strcat(snd_buf, "\r\n"); @@ -3166,10 +2862,10 @@ void *send_aprs_beacon(void *arg) /* send to aprs */ sprintf(snd_buf, "%s>APJI23,TCPIP*,qAC,%sS:!%s%cD%s%c&RNG%04u %s %s", - rptr.mod[i].call, rptr.mod[i].call, - lat_s, (rptr.mod[i].latitude < 0.0F) ? 'S' : 'N', - lon_s, (rptr.mod[i].longitude < 0.0F) ? 'W' : 'E', - (unsigned int)rptr.mod[i].range, rptr.mod[i].band, rptr.mod[i].desc); + rptr.mod[i].call.c_str(), rptr.mod[i].call.c_str(), + lat_s, (rptr.mod[i].latitude < 0.0) ? 'S' : 'N', + lon_s, (rptr.mod[i].longitude < 0.0) ? 'W' : 'E', + (unsigned int)rptr.mod[i].range, rptr.mod[i].band.c_str(), rptr.mod[i].desc.c_str()); // traceit("APRS Beacon =[%s]\n", snd_buf); strcat(snd_buf, "\r\n"); @@ -3329,7 +3025,7 @@ static void *echotest(void *arg) pthread_exit(NULL); } - sleep(PLAY_WAIT); + sleep(play_wait); while (keep_running) { nread = fread(&rlen, 2, 1, fp); if (nread != 1) @@ -3401,7 +3097,7 @@ static void *echotest(void *arg) toRptr[i].G2_COUNTER ++; req.tv_sec = 0; - req.tv_nsec = PLAY_DELAY * 1000000; + req.tv_nsec = play_delay * 1000000; nanosleep(&req, NULL); } } @@ -3415,10 +3111,10 @@ static void *echotest(void *arg) static void qrgs_and_maps() { for(int i=0; i<3; i++) { - char rptrcall[CALL_SIZE+1]; - strcpy(rptrcall, OWNER); - rptrcall[CALL_SIZE-1] = 'A' + i; - if (rptr.mod[i].latitude || rptr.mod[i].longitude || strlen(rptr.mod[i].desc1) || strlen(rptr.mod[i].url)) + string rptrcall = OWNER; + rptrcall.resize(CALL_SIZE-1); + rptrcall += i + 'A'; + if (rptr.mod[i].latitude || rptr.mod[i].longitude || rptr.mod[i].desc1.length() || rptr.mod[i].url.length()) ii->rptrQTH(rptrcall, rptr.mod[i].latitude, rptr.mod[i].longitude, rptr.mod[i].desc1, rptr.mod[i].desc2, rptr.mod[i].url, rptr.mod[i].package_version); if (rptr.mod[i].frequency) ii->rptrQRG(rptrcall, rptr.mod[i].frequency, rptr.mod[i].offset, rptr.mod[i].range, rptr.mod[i].agl); @@ -3469,20 +3165,9 @@ int main(int argc, char **argv) return 1; } - rptr.aprs_host[0] = '\0'; - rptr.aprs_port = 0; - rptr.aprs_hash = -1; - rptr.aprs_interval = 0; - rptr.aprs_filter[0] = '\0'; - for (i = 0; i < 3; i++) { - rptr.mod[i].latitude = 0.00; - rptr.mod[i].longitude = 0.00; - rptr.mod[i].range = 0; - rptr.mod[i].desc[0] = '\0'; - } - strcpy(rptr.mod[0].band, "23cm"); - strcpy(rptr.mod[1].band, "70cm"); - strcpy(rptr.mod[2].band, "2m"); + rptr.mod[0].band = "23cm"; + rptr.mod[1].band = "70cm"; + rptr.mod[2].band = "2m"; for (i = 0; i < 3; i++) { aprs_streamID[i].streamID[0] = 0x00; @@ -3530,20 +3215,18 @@ int main(int argc, char **argv) } /* build the repeater callsigns for aprs */ - strcpy(rptr.mod[0].call, OWNER); - p = strchr(rptr.mod[0].call, ' '); - if (!p) { - traceit("Failed to build repeater callsigns for aprs\n"); - return 1; - } - *p = '\0'; - strcpy(rptr.mod[1].call, rptr.mod[0].call); - strcpy(rptr.mod[2].call, rptr.mod[0].call); - strcat(rptr.mod[0].call, "-A"); - strcat(rptr.mod[1].call, "-B"); - strcat(rptr.mod[2].call, "-C"); - traceit("Repeater callsigns: [%s] [%s] [%s]\n", - rptr.mod[0].call, rptr.mod[1].call, rptr.mod[2].call); + rptr.mod[0].call = OWNER; + for (i=OWNER.length(); i; i--) + if (! isspace(OWNER[i-1])) + break; + rptr.mod[0].call.resize(i); + + rptr.mod[1].call = rptr.mod[0].call; + rptr.mod[2].call = rptr.mod[0].call; + rptr.mod[0].call += "-A"; + rptr.mod[1].call += "-B"; + rptr.mod[2].call += "-C"; + traceit("Repeater callsigns: [%s] [%s] [%s]\n", rptr.mod[0].call.c_str(), rptr.mod[1].call.c_str(), rptr.mod[2].call.c_str()); aprs_init(); compute_aprs_hash(); @@ -3554,7 +3237,7 @@ int main(int argc, char **argv) return 1; } - ii = new CIRCDDB(IRC_DDB_HOST, IRC_DDB_PORT, owner, IRC_PASS, IRCDDB_VERSION, LOCAL_IRC_IP); + ii = new CIRCDDB(ircddb.ip, ircddb.port, owner, irc_pass, IRCDDB_VERSION, local_irc_ip); ok = ii->open(); if (!ok) { traceit("irc open failed\n"); @@ -3617,13 +3300,13 @@ int main(int argc, char **argv) if (i == 0) snprintf(vm[i].file, FILENAME_MAX, "%s/%c_%s", - ECHOTEST_DIR,'A',"voicemail.dat"); + echotest_dir.c_str(),'A',"voicemail.dat"); else if (i == 1) snprintf(vm[i].file, FILENAME_MAX, "%s/%c_%s", - ECHOTEST_DIR,'B',"voicemail.dat"); + echotest_dir.c_str(),'B',"voicemail.dat"); else snprintf(vm[i].file, FILENAME_MAX, "%s/%c_%s", - ECHOTEST_DIR,'C',"voicemail.dat"); + echotest_dir.c_str(),'C',"voicemail.dat"); if (access(vm[i].file, F_OK) != 0) memset(vm[i].file, 0, sizeof(vm[i].file)); @@ -3644,8 +3327,8 @@ int main(int argc, char **argv) toRptr[i].adr = 0; toRptr[i].band_addr.sin_family = AF_INET; - toRptr[i].band_addr.sin_addr.s_addr = inet_addr(TO_RPTR_IP[i]); - toRptr[i].band_addr.sin_port = htons(TO_RPTR_PORT[i]); + toRptr[i].band_addr.sin_addr.s_addr = inet_addr(rptr.mod[i].portip.ip.c_str()); + toRptr[i].band_addr.sin_port = htons(rptr.mod[i].portip.port); toRptr[i].last_time = 0; toRptr[i].G2_COUNTER = 0; @@ -3681,12 +3364,12 @@ int main(int argc, char **argv) /* where to send packets to g2_link */ memset(&plug,0,sizeof(struct sockaddr_in)); plug.sin_family = AF_INET; - plug.sin_port = htons(TO_G2_LINK_PORT); - plug.sin_addr.s_addr = inet_addr(TO_G2_LINK_IP); + plug.sin_port = htons(g2_link.port); + plug.sin_addr.s_addr = inet_addr(g2_link.ip.c_str()); traceit("g2_ircddb...entering processing loop\n"); - if (SEND_QRGS_MAPS) + if (bool_send_qrgs) qrgs_and_maps(); runit(); @@ -3840,7 +3523,7 @@ static void aprs_process_text(unsigned char *streamID, p = strchr(aud, '\r'); *p = '\0'; - sprintf(aprs_buf, "%s,qAR,%s:%s\r\n", hdr, rptr.mod[rptr_idx].call, aud); + sprintf(aprs_buf, "%s,qAR,%s:%s\r\n", hdr, rptr.mod[rptr_idx].call.c_str(), aud); // traceit("GPS-A=%s", aprs_buf); rc = writen(aprs_buf, strlen(aprs_buf)); if (rc == -1) { @@ -4211,7 +3894,7 @@ static void build_aprs_from_gps_and_send(short int rptr_idx) strcat(buf, ">"); strcat(buf, "APDPRS,DSTAR*,qAR,"); - strcat(buf, rptr.mod[rptr_idx].call); + strcat(buf, rptr.mod[rptr_idx].call.c_str()); strcat(buf, ":!"); //GPRMC = diff --git a/g2_link.cfg b/g2_link.cfg deleted file mode 100644 index b24745d..0000000 --- a/g2_link.cfg +++ /dev/null @@ -1,95 +0,0 @@ -# The ONLY values to change are: LOGIN_CALL, OWNER and ADMIN -# - -# Callsign to use to login to remote REF reflector -# This is your personal user callsign -# Remove the # sign and set your callsign correctly -# -LOGIN_CALL= - -# Because ONLY_ADMIN_LOGIN=Y -# only these 3 users can connect to your gateway -ADMIN= -ONLY_ADMIN_LOGIN=Y - -# If you set ONLY_LINK_UNLINK=Y -# then ONLY user callsigns identified by the option LINK_UNLINK_USER -# can link or unlink your repeater. -# If you set ONLY_LINK_UNLINK=N -# then ANY user callsign can link or unlink your repeater. -# -ONLY_LINK_UNLINK=N -LINK_UNLINK_USER=XX0XXX -LINK_UNLINK_USER=YY0YYY -LINK_UNLINK_USER=ZZ0ZZZ - -# Local gateway callsign -# This is your local G2 Gateway callsign -# You should register this with the remote irc database server -# Remove the # sign and set the gateway callsign correctly. -# -OWNER= - -# remote friends -RMT_XRF_PORT=30001 -RMT_REF_PORT=20001 -RMT_DCS_PORT=30051 - -# Our server port so that the local g2 gateway can contact us -# our g2_link will create/open this UDP port as a server -MY_G2_LINK_IP=0.0.0.0 -MY_G2_LINK_PORT=18997 - -# The external g2 port of the local G2 -TO_G2_EXTERNAL_IP=127.0.0.1 -TO_G2_EXTERNAL_PORT=40000 - -QSO_DETAILS=N - -# The reflectors -GWYS=/usr/local/etc/gwys.txt - -#LINK STATUS file -STATUS_FILE=/usr/local/etc/RPT_STATUS.txt - -# SEND an AUDIO announcements on LINK/UNLINK/INFO ? -ANNOUNCE=Y -# The directory where the "*.dat" files are located -ANNOUNCE_DIR=/usr/local/etc - -# Send a TEXT announcement on every key-up ? -RPTR_ACK=N - -# While sending back the announcement, -# what is the delay in MILLISECONDS between each packet -DELAY_BETWEEN=19 - -# How many seconds to delay before sending the announcement -# Set it to 1 -# If your local repeater requires more time to initialize after releasing PTT, then set it to 2 -DELAY_BEFORE=1 - -# Try to link to this system after initialization -# Leave the option blank, if you do not want automatic linking at startup -# -# Link your local repeater mod B to the remote reflector XRF005 mod A -# -LINK_AT_STARTUP=CXRF901A - -# Maximum number of incoming hotspotNode or dongle connections(r2g2_p, r2g2_x, HotSpotNode,...) -# If you do NOT want incoming HotSpotNode or dongle connections, set this to 0 -MAX_DONGLES=5 - -# Each RF band has an inactivity timer, in minutes. -# If the timer is 0, then there is NO timer at all. -# If the timer is greater than 0 and that RF band is linked -# to a remote system, and no local RF activity has taken place -# in the last minutes as set in the timer, then -# automatically the RF band will unlink from the remote system. -# This is done to protect the owner from local RF users that -# link the RF band to a remote system, -# and then go away. -RF_INACTIVITY_TIMER_A=0 -RF_INACTIVITY_TIMER_B=0 -RF_INACTIVITY_TIMER_C=0 - diff --git a/g2_link.cpp b/g2_link.cpp index 68ed22b..bc9a2d1 100644 --- a/g2_link.cpp +++ b/g2_link.cpp @@ -1,6 +1,8 @@ /* * Copyright (C) 2010 by Scott Lawson KI4LKF + * Additional: + * Copyright (C) 2015 by Thomas A. Early AC2IE * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,7 +20,7 @@ */ -/* by KI4LKF */ +/* by KI4LKF and AC2IE*/ #include #include @@ -49,10 +51,13 @@ #include #include #include +#include +#include "versions.h" using namespace std; +using namespace libconfig; /*** version number must be x.xx ***/ -#define VERSION "3.11+" // DG1HT +#define VERSION LINK_VERSION #define CALL_SIZE 8 #define IP_SIZE 15 #define QUERY_SIZE 56 @@ -66,31 +71,29 @@ using namespace std; #define FILE_REFRESH_GWYS_CODE 'F' /* configuration data */ -static char LOGIN_CALL[CALL_SIZE + 1]; -static char ADMIN[CALL_SIZE + 1]; -static bool ONLY_ADMIN_LOGIN = false; -static bool ONLY_LINK_UNLINK = false; -static char LINK_UNLINK_USER[CALL_SIZE + 1]; -static char OWNER[CALL_SIZE + 1]; -static int RMT_XRF_PORT = 30001; -static int RMT_REF_PORT = 20001; -static int RMT_DCS_PORT = 30051; -static char MY_G2_LINK_IP[IP_SIZE + 1]; -static int MY_G2_LINK_PORT = 18997; -static char TO_G2_EXTERNAL_IP[IP_SIZE + 1]; -static int TO_G2_EXTERNAL_PORT = 40000; -static bool QSO_DETAILS = false; -static char GWYS[FILENAME_MAX + 1]; -static char STATUS_FILE[FILENAME_MAX + 1]; -static bool RPTR_ACK = true; -static int DELAY_BETWEEN = 20; -static int DELAY_BEFORE = 1; -static bool ANNOUNCE = false; -static char ANNOUNCE_DIR[FILENAME_MAX + 1]; -static char LINK_AT_STARTUP[CALL_SIZE + 1]; -static unsigned int MAX_DONGLES = 5; -static unsigned int SAVED_MAX_DONGLES = 5; -static long RF_INACTIVITY_TIMER[3] = { 3, 3, 3 }; +static string login_call; +static bool only_admin_login; +static bool only_link_unlink; +static string owner; +static int rmt_xrf_port; +static int rmt_ref_port; +static int rmt_dcs_port; +static string my_g2_link_ip; +static int my_g2_link_port; +static string to_g2_external_ip; +static int to_g2_external_port; +static bool qso_details; +static string gwys; +static string status_file; +static bool bool_rptr_ack; +static int delay_between; +static int delay_before; +static bool announce; +static string announce_dir; +static char link_at_startup[CALL_SIZE+1]; +static unsigned int max_dongles; +static unsigned int saved_max_dongles; +static long rf_inactivity_timer[3]; static unsigned char REF_ACK[3] = { 3, 96, 0 }; @@ -259,7 +262,7 @@ unsigned char tmp_txt[3]; static char *p_tmp2 = NULL; /* END: TEXT crap */ -/* this is used for the "dashboard and QSO_DETAILS" to avoid processing multiple headers */ +/* this is used for the "dashboard and qso_details" to avoid processing multiple headers */ static struct { unsigned char sid[2]; } old_sid[3] = { { {0x00, 0x00} }, @@ -267,7 +270,7 @@ static struct { { {0x00, 0x00} } }; -static bool load_gwys(char *filename); +static bool load_gwys(const string &filename); static void calcPFCS(unsigned char *packet, int len); static void traceit(const char *fmt,...); static bool read_config(char *); @@ -429,7 +432,7 @@ static void *rptr_ack_run(void *arg) u_int16_t streamid_raw = (::rand_r(&aseed) % 65535U) + 1U; - sleep(DELAY_BEFORE); + sleep(delay_before); traceit("sending ACK+text, mod:[%c], RADIO_ID=[%s]\n", from_mod, RADIO_ID); @@ -451,22 +454,22 @@ static void *rptr_ack_run(void *arg) rptr_ack[16] = 0x00; rptr_ack[17] = 0x00; - memcpy(rptr_ack + 18, OWNER, 8); + memcpy(rptr_ack + 18, owner.c_str(), CALL_SIZE); rptr_ack[25] = from_mod; - memcpy(rptr_ack + 26, OWNER, 8); + memcpy(rptr_ack + 26, owner.c_str(), CALL_SIZE); rptr_ack[33] = 'G'; - memcpy(rptr_ack + 34, "CQCQCQ ", 8); + memcpy(rptr_ack + 34, "CQCQCQ ", CALL_SIZE); - memcpy(rptr_ack + 42, OWNER, 8); + memcpy(rptr_ack + 42, owner.c_str(), CALL_SIZE); rptr_ack[49] = from_mod; memcpy(rptr_ack + 50, "RPTR", 4); calcPFCS(rptr_ack,56); (void)sendto(rptr_sock,(char *)rptr_ack,56,0,(struct sockaddr *)&toLocalg2,sizeof(toLocalg2)); nanos.tv_sec = 0; - nanos.tv_nsec = DELAY_BETWEEN * 1000000; + nanos.tv_nsec = delay_between * 1000000; nanosleep(&nanos,0); rptr_ack[4] = 0x20; @@ -480,7 +483,7 @@ static void *rptr_ack_run(void *arg) rptr_ack[26] = 0x16; (void)sendto(rptr_sock,(char *)rptr_ack,27,0,(struct sockaddr *)&toLocalg2,sizeof(toLocalg2)); nanos.tv_sec = 0; - nanos.tv_nsec = DELAY_BETWEEN * 1000000; + nanos.tv_nsec = delay_between * 1000000; nanosleep(&nanos,0); rptr_ack[14] = 0x01; @@ -489,7 +492,7 @@ static void *rptr_ack_run(void *arg) rptr_ack[26] = RADIO_ID[1] ^ 0x93; (void)sendto(rptr_sock,(char *)rptr_ack,27,0,(struct sockaddr *)&toLocalg2,sizeof(toLocalg2)); nanos.tv_sec = 0; - nanos.tv_nsec = DELAY_BETWEEN * 1000000; + nanos.tv_nsec = delay_between * 1000000; nanosleep(&nanos,0); rptr_ack[14] = 0x02; @@ -498,7 +501,7 @@ static void *rptr_ack_run(void *arg) rptr_ack[26] = RADIO_ID[4] ^ 0x93; (void)sendto(rptr_sock,(char *)rptr_ack,27,0,(struct sockaddr *)&toLocalg2,sizeof(toLocalg2)); nanos.tv_sec = 0; - nanos.tv_nsec = DELAY_BETWEEN * 1000000; + nanos.tv_nsec = delay_between * 1000000; nanosleep(&nanos,0); rptr_ack[14] = 0x03; @@ -507,7 +510,7 @@ static void *rptr_ack_run(void *arg) rptr_ack[26] = RADIO_ID[6] ^ 0x93; (void)sendto(rptr_sock,(char *)rptr_ack,27,0,(struct sockaddr *)&toLocalg2,sizeof(toLocalg2)); nanos.tv_sec = 0; - nanos.tv_nsec = DELAY_BETWEEN * 1000000; + nanos.tv_nsec = delay_between * 1000000; nanosleep(&nanos,0); rptr_ack[14] = 0x04; @@ -516,7 +519,7 @@ static void *rptr_ack_run(void *arg) rptr_ack[26] = RADIO_ID[9] ^ 0x93; (void)sendto(rptr_sock,(char *)rptr_ack,27,0,(struct sockaddr *)&toLocalg2,sizeof(toLocalg2)); nanos.tv_sec = 0; - nanos.tv_nsec = DELAY_BETWEEN * 1000000; + nanos.tv_nsec = delay_between * 1000000; nanosleep(&nanos,0); rptr_ack[14] = 0x05; @@ -525,7 +528,7 @@ static void *rptr_ack_run(void *arg) rptr_ack[26] = RADIO_ID[11] ^ 0x93; (void)sendto(rptr_sock,(char *)rptr_ack,27,0,(struct sockaddr *)&toLocalg2,sizeof(toLocalg2)); nanos.tv_sec = 0; - nanos.tv_nsec = DELAY_BETWEEN * 1000000; + nanos.tv_nsec = delay_between * 1000000; nanosleep(&nanos,0); rptr_ack[14] = 0x06; @@ -534,7 +537,7 @@ static void *rptr_ack_run(void *arg) rptr_ack[26] = RADIO_ID[14] ^ 0x93; (void)sendto(rptr_sock,(char *)rptr_ack,27,0,(struct sockaddr *)&toLocalg2,sizeof(toLocalg2)); nanos.tv_sec = 0; - nanos.tv_nsec = DELAY_BETWEEN * 1000000; + nanos.tv_nsec = delay_between * 1000000; nanosleep(&nanos,0); rptr_ack[14] = 0x07; @@ -543,7 +546,7 @@ static void *rptr_ack_run(void *arg) rptr_ack[26] = RADIO_ID[16] ^ 0x93; (void)sendto(rptr_sock,(char *)rptr_ack,27,0,(struct sockaddr *)&toLocalg2,sizeof(toLocalg2)); nanos.tv_sec = 0; - nanos.tv_nsec = DELAY_BETWEEN * 1000000; + nanos.tv_nsec = delay_between * 1000000; nanosleep(&nanos,0); rptr_ack[14] = 0x08; @@ -552,7 +555,7 @@ static void *rptr_ack_run(void *arg) rptr_ack[26] = RADIO_ID[19] ^ 0x93; (void)sendto(rptr_sock,(char *)rptr_ack,27,0,(struct sockaddr *)&toLocalg2,sizeof(toLocalg2)); nanos.tv_sec = 0; - nanos.tv_nsec = DELAY_BETWEEN * 1000000; + nanos.tv_nsec = delay_between * 1000000; nanosleep(&nanos,0); rptr_ack[14] = 0x09 | 0x40; @@ -574,9 +577,9 @@ static void print_status_file() inbound *inbound_ptr; inbound_type::iterator pos; - statusfp = fopen(STATUS_FILE, "w"); + statusfp = fopen(status_file.c_str(), "w"); if (!statusfp) - traceit("Failed to create status file %s\n", STATUS_FILE); + traceit("Failed to create status file %s\n", status_file.c_str()); else { setvbuf(statusfp, (char *)NULL, _IOLBF, 0); @@ -614,7 +617,7 @@ static void print_status_file() } /* Open text file of repeaters, reflectors */ -static bool load_gwys(char *filename) +static bool load_gwys(const string &filename) { FILE *fp = NULL; char inbuf[1024]; @@ -633,13 +636,13 @@ static bool load_gwys(char *filename) gwy_list_type::iterator gwy_pos; pair gwy_insert_pair; - traceit("Trying to open file %s\n", filename); - fp = fopen(filename, "r"); + traceit("Trying to open file %s\n", filename.c_str()); + fp = fopen(filename.c_str(), "r"); if (fp == NULL) { - traceit("Failed to open file %s\n", filename); + traceit("Failed to open file %s\n", filename.c_str()); return false; } - traceit("Opened file %s OK\n", filename); + traceit("Opened file %s OK\n", filename.c_str()); while (fgets(inbuf, 1020, fp) != NULL) { p = strchr(inbuf, '\r'); @@ -669,7 +672,7 @@ static bool load_gwys(char *filename) memcpy(call, tok, strlen(tok)); for (j = 0; j < strlen(call); j++) call[j] = toupper(call[j]); - if (strcmp(call, OWNER) == 0) { + if (strcmp(call, owner.c_str()) == 0) { traceit("Call [%s] will not be loaded\n", call); continue; } @@ -780,300 +783,219 @@ static void traceit(const char *fmt,...) return; } +bool get_value(const Config &cfg, const char *path, int &value, int min, int max, int default_value) +{ + if (cfg.lookupValue(path, value)) { + if (value < min || value > max) + value = default_value; + } else + value = default_value; + traceit("%s = [%u]\n", path, value); + return true; +} + +bool get_value(const Config &cfg, const char *path, double &value, double min, double max, double default_value) +{ + if (cfg.lookupValue(path, value)) { + if (value < min || value > max) + value = default_value; + } else + value = default_value; + traceit("%s = [%lg]\n", path, value); + return true; +} + +bool get_value(const Config &cfg, const char *path, bool &value, bool default_value) +{ + if (! cfg.lookupValue(path, value)) + value = default_value; + traceit("%s = [%s]\n", path, value ? "true" : "false"); + return true; +} + +bool get_value(const Config &cfg, const char *path, string &value, int min, int max, const char *default_value) +{ + if (cfg.lookupValue(path, value)) { + int l = value.length(); + if (lmax) { + traceit("%s is invalid\n", path, value.c_str()); + return false; + } + } else + value = default_value; + traceit("%s = [%s]\n", path, value.c_str()); + return true; +} + /* process configuration file */ static bool read_config(char *cfgFile) { - bool admin_found = false; - bool link_unlink_user_found = false; - unsigned short i = 0; - short int valid_params = 26; - short int params = 0; - admin_type::iterator pos; link_unlink_user_type::iterator link_unlink_user_pos; - - FILE *cnf = NULL; - char inbuf[1024]; - char *p = NULL; - char *ptr; - short int j; - - cnf = fopen(cfgFile, "r"); - if (!cnf) { - traceit("Failed to open file %s\n", cfgFile); - return false; - } + unsigned short i; + Config cfg; traceit("Reading file %s\n", cfgFile); - while (fgets(inbuf, 1020, cnf) != NULL) { - if (strchr(inbuf, '#')) - continue; - - p = strchr(inbuf, '\r'); - if (p) - *p = '\0'; - p = strchr(inbuf, '\n'); - if (p) - *p = '\0'; - - p = strchr(inbuf, '='); - if (!p) - continue; - *p = '\0'; - - if (strcmp(inbuf,"LOGIN_CALL") == 0) { - memset(LOGIN_CALL,' ', sizeof(LOGIN_CALL)); - LOGIN_CALL[CALL_SIZE] = '\0'; - - /* no spaces after the equal sign */ - if (p[1] == ' ') - traceit("LOGIN_CALL: no spaces after the equal sign\n"); - else { - /* take up to 8 characters, throw away the rest */ - p[CALL_SIZE + 1] = '\0'; - - /* valid length? */ - if ((strlen(p + 1) < 3) || (strlen(p + 1) > CALL_SIZE)) - traceit("LOGIN_CALL value [%s] invalid\n", p + 1); - else { - memcpy(LOGIN_CALL, p + 1, strlen(p + 1)); + // Read the file. If there is an error, report it and exit. + try { + cfg.readFile(cfgFile); + } + catch(const FileIOException &fioex) { + traceit("Can't read %s\n", cfgFile); + return 1; + } + catch(const ParseException &pex) { + traceit("Parse error at %s:%d - %s\n", pex.getFile(), pex.getLine(), pex.getError()); + return 1; + } - /* uppercase it */ - for (j = 0; j < CALL_SIZE; j++) - LOGIN_CALL[j] = toupper(LOGIN_CALL[j]); + string value; + if (cfg.lookupValue("g2_link.ref_login", value) || cfg.lookupValue("ircddb.username", value)) { + int l = value.length(); + if (l<3 || l>CALL_SIZE-2) { + traceit("Call '%s' is invalid length!\n", value.c_str()); + return 1; + } else { + for (i=0; i2 && lc_str()); + traceit("]\n"); + } + + key = "g2_link.link_unlink"; + only_link_unlink = false; + if (cfg.exists(key)) { + Setting &unlinklist = cfg.lookup(key); + if (unlinklist.isArray()) { + for (i=0; i2 && lc_str()); + traceit("]\n"); + } - memset(ADMIN,' ', CALL_SIZE); - ADMIN[CALL_SIZE] = '\0'; + key = "ircddb.username"; + if (cfg.lookupValue(key, owner)) { + int l = owner.length(); + if (l>2 && l<=CALL_SIZE-2) { + for (i=0; i CALL_SIZE) ) - traceit("ADMIN value [%s] invalid\n", p + 1); - else { - memcpy(ADMIN, p + 1, strlen(p + 1)); + get_value(cfg, "g2_link.ref_port", rmt_ref_port, 10000, 65535, 20001); + get_value(cfg, "g2_link.xrf_port", rmt_xrf_port, 10000, 65535, 30001); + get_value(cfg, "g2_link.dcs_port", rmt_dcs_port, 10000, 65535, 30051); - for (i = 0; i < strlen(ADMIN); i++) - ADMIN[i] = toupper(ADMIN[i]); + if (! get_value(cfg, "g2_link.incoming_ip", my_g2_link_ip, 7, IP_SIZE, "0.0.0.0")) + return 1; + get_value(cfg, "g2_link.port", my_g2_link_port, 10000, 65535, 18997); - traceit("ADMIN=[%s]\n",ADMIN); + if (! get_value(cfg, "g2_link.g2_ircddb_ip", to_g2_external_ip, 7, IP_SIZE, "0.0.0.0")) + return 1; + get_value(cfg, "gateway.external.port", to_g2_external_port, 10000, 65535, 40000); - /* check for duplicates */ - pos = admin.find(ADMIN); - if (pos != admin.end()) - traceit("[%s] already an administrator\n", ADMIN); - else { - if (admin.insert(ADMIN).second) - traceit("[%s] is now an administrator\n", ADMIN); - else - traceit("failed to add [%s] as an administrator\n", ADMIN); - } - } - } else if (strcmp(inbuf,"LINK_UNLINK_USER") == 0) { - if (!link_unlink_user_found) { - link_unlink_user_found = true; - params ++; - } + get_value(cfg, "gateway.log.qso", qso_details, true); - memset(LINK_UNLINK_USER,' ', CALL_SIZE); - LINK_UNLINK_USER[CALL_SIZE] = '\0'; + if (! get_value(cfg, "file.gwys", gwys, 2, FILENAME_MAX, "/usr/local/etc/gwys.txt")) + return 1; - if ( (strlen(p + 1) < 1) || (strlen(p + 1) > CALL_SIZE) ) - traceit("LINK_UNLINK_USER value [%s] invalid\n", p + 1); - else { - memcpy(LINK_UNLINK_USER, p + 1, strlen(p + 1)); + if (! get_value(cfg, "file.status", status_file, 2, FILENAME_MAX, "/usr/local/etc/RPTR_STATUS.txt")) + return 1; - for (i = 0; i < strlen(LINK_UNLINK_USER); i++) - LINK_UNLINK_USER[i] = toupper(LINK_UNLINK_USER[i]); + get_value(cfg, "timing.play.delay", delay_between, 9, 25, 19); - traceit("LINK_UNLINK_USER=[%s]\n",LINK_UNLINK_USER); + get_value(cfg, "g2_link.acknowledge", bool_rptr_ack, true); - /* check for duplicates */ - link_unlink_user_pos = link_unlink_user.find(LINK_UNLINK_USER); - if (link_unlink_user_pos != link_unlink_user.end()) - traceit("[%s] already in link_unlink_user list\n", LINK_UNLINK_USER); - else { - if (link_unlink_user.insert(LINK_UNLINK_USER).second) - traceit("[%s] added to link_unlink_user list\n", LINK_UNLINK_USER); - else - traceit("failed to add [%s] to link_unlink_user list\n", LINK_UNLINK_USER); - } - } - } else if (strcmp(inbuf,"OWNER") == 0) { - memset(OWNER,' ', sizeof(OWNER)); - OWNER[CALL_SIZE] = '\0'; + get_value(cfg, "g2_link.announce", announce, true); - ptr = strchr(p + 1, ' '); - if (ptr) - *ptr = '\0'; + if (! get_value(cfg, "file.announce_dir", announce_dir, 2, FILENAME_MAX, "/usr/local/etc")) + return 1; - if ((strlen(p + 1) < 3) || (strlen(p + 1) > (CALL_SIZE - 2))) - traceit("OWNER value [%s] invalid\n", p + 1); - else { - memcpy(OWNER, p + 1, strlen(p + 1)); + get_value(cfg, "timing.play.wait", delay_before, 1, 10, 2); - /* uppercase it */ - for (j = 0; j < CALL_SIZE; j++) - OWNER[j] = toupper(OWNER[j]); + if (! get_value(cfg, "g2_link.link_at_start", value, 5, CALL_SIZE, "NONE")) { + if (strcasecmp(value.c_str(), "none")) + strcpy(link_at_startup, value.c_str()); + } else + return 1; - traceit("OWNER=[%s]\n",OWNER); - params ++; - } - } else if (strcmp(inbuf,"RMT_XRF_PORT") == 0) { - RMT_XRF_PORT = atoi(p + 1); - traceit("RMT_XRF_PORT=[%d]\n",RMT_XRF_PORT); - params ++; - } else if (strcmp(inbuf,"RMT_DCS_PORT") == 0) { - RMT_DCS_PORT = atoi(p + 1); - traceit("RMT_DCS_PORT=[%d]\n",RMT_DCS_PORT); - params ++; - } else if (strcmp(inbuf,"RMT_REF_PORT") == 0) { - RMT_REF_PORT = atoi(p + 1); - traceit("RMT_REF_PORT=[%d]\n",RMT_REF_PORT); - params ++; - } else if (strcmp(inbuf,"MY_G2_LINK_IP") == 0) { - ptr = strchr(p + 1, ' '); - if (ptr) - *ptr = '\0'; - - if (strlen(p + 1) < 1) - traceit("MY_G2_LINK_IP value [%s] invalid\n", p + 1); - else { - strncpy(MY_G2_LINK_IP, p + 1, IP_SIZE); - MY_G2_LINK_IP[IP_SIZE] = '\0'; - traceit("MY_G2_LINK_IP=[%s]\n", MY_G2_LINK_IP); - params ++; - } - } else if (strcmp(inbuf,"MY_G2_LINK_PORT") == 0) { - MY_G2_LINK_PORT = atoi(p + 1); - traceit("MY_G2_LINK_PORT=[%d]\n",MY_G2_LINK_PORT); - params ++; - } else if (strcmp(inbuf,"TO_G2_EXTERNAL_IP") == 0) { - ptr = strchr(p + 1, ' '); - if (ptr) - *ptr = '\0'; - - if (strlen(p + 1) < 1) - traceit("TO_G2_EXTERNAL_IP value [%s] invalid\n", p + 1); - else { - strncpy(TO_G2_EXTERNAL_IP, p + 1, IP_SIZE); - TO_G2_EXTERNAL_IP[IP_SIZE] = '\0'; - traceit("TO_G2_EXTERNAL_IP=[%s]\n", TO_G2_EXTERNAL_IP); - params ++; - } - } else if (strcmp(inbuf,"TO_G2_EXTERNAL_PORT") == 0) { - TO_G2_EXTERNAL_PORT = atoi(p + 1); - traceit("TO_G2_EXTERNAL_PORT=[%d]\n",TO_G2_EXTERNAL_PORT); - params ++; - } else if (strcmp(inbuf,"QSO_DETAILS") == 0) { - if (*(p + 1) == 'Y') - QSO_DETAILS = true; - else - QSO_DETAILS = false; - traceit("QSO_DETAILS=[%c]\n", *(p + 1)); - params ++; - } else if (strcmp(inbuf,"GWYS") == 0) { - memset(GWYS, '\0', sizeof(GWYS)); - strncpy(GWYS, p + 1,FILENAME_MAX); - traceit("GWYS=[%s]\n", GWYS); - params ++; - } else if (strcmp(inbuf,"STATUS_FILE") == 0) { - memset(STATUS_FILE, '\0', sizeof(STATUS_FILE)); - strncpy(STATUS_FILE, p + 1,FILENAME_MAX); - traceit("STATUS_FILE=[%s]\n",STATUS_FILE); - params ++; - } else if (strcmp(inbuf,"DELAY_BETWEEN") == 0) { - DELAY_BETWEEN = atoi(p + 1); - if (DELAY_BETWEEN <= 0) - DELAY_BETWEEN = 20; - traceit("DELAY_BETWEEN=[%d]\n",DELAY_BETWEEN); - params ++; - } else if (strcmp(inbuf,"RPTR_ACK") == 0) { - if (*(p + 1) == 'Y') - RPTR_ACK = true; - else - RPTR_ACK = false; - traceit("RPTR_ACK=[%c]\n", *(p + 1)); - params ++; - } else if (strcmp(inbuf,"ANNOUNCE") == 0) { - if (*(p + 1) == 'Y') - ANNOUNCE = true; - else - ANNOUNCE = false; - traceit("ANNOUNCE=[%c]\n", *(p + 1)); - params ++; - } else if (strcmp(inbuf,"ANNOUNCE_DIR") == 0) { - memset(ANNOUNCE_DIR, '\0', sizeof(ANNOUNCE_DIR)); - strncpy(ANNOUNCE_DIR, p + 1, FILENAME_MAX); - traceit("ANNOUNCE_DIR=[%s]\n", ANNOUNCE_DIR); - params ++; - } else if (strcmp(inbuf,"DELAY_BEFORE") == 0) { - DELAY_BEFORE = atoi(p + 1); - if (DELAY_BEFORE <= 0) - DELAY_BEFORE = 1; - traceit("DELAY_BEFORE=[%d]\n",DELAY_BEFORE); - params ++; - } else if (strcmp(inbuf,"LINK_AT_STARTUP") == 0) { - memset(LINK_AT_STARTUP, '\0', sizeof(LINK_AT_STARTUP)); - strncpy(LINK_AT_STARTUP, p + 1, CALL_SIZE); - traceit("LINK_AT_STARTUP=[%s]\n", LINK_AT_STARTUP); - params ++; - } else if (strcmp(inbuf,"MAX_DONGLES") == 0) { - MAX_DONGLES = atoi(p + 1); - traceit("MAX_DONGLES=[%d]\n",MAX_DONGLES); - SAVED_MAX_DONGLES = MAX_DONGLES; - params ++; - } else if (strcmp(inbuf,"RF_INACTIVITY_TIMER_A") == 0) { - RF_INACTIVITY_TIMER[0] = atol(p + 1); - if (RF_INACTIVITY_TIMER[0] < 0) - RF_INACTIVITY_TIMER[0] = 10; - traceit("RF_INACTIVITY_TIMER_A=[%ld]\n",RF_INACTIVITY_TIMER[0]); - RF_INACTIVITY_TIMER[0] = RF_INACTIVITY_TIMER[0] * 60; - params ++; - } else if (strcmp(inbuf,"RF_INACTIVITY_TIMER_B") == 0) { - RF_INACTIVITY_TIMER[1] = atol(p + 1); - if (RF_INACTIVITY_TIMER[1] < 0) - RF_INACTIVITY_TIMER[1] = 10; - traceit("RF_INACTIVITY_TIMER_B=[%ld]\n",RF_INACTIVITY_TIMER[1]); - RF_INACTIVITY_TIMER[1] = RF_INACTIVITY_TIMER[1] * 60; - params ++; - } else if (strcmp(inbuf,"RF_INACTIVITY_TIMER_C") == 0) { - RF_INACTIVITY_TIMER[2] = atol(p + 1); - if (RF_INACTIVITY_TIMER[2] < 0) - RF_INACTIVITY_TIMER[2] = 10; - traceit("RF_INACTIVITY_TIMER_C=[%ld]\n",RF_INACTIVITY_TIMER[2]); - RF_INACTIVITY_TIMER[2] = RF_INACTIVITY_TIMER[2] * 60; - params ++; - } - } - fclose(cnf); + int maxdongle; + get_value(cfg, "g2_link.max_dongles", maxdongle, 0, 10, 5); + saved_max_dongles = max_dongles = (unsigned int)maxdongle; - if (params != valid_params) { - traceit("Configuration file %s invalid\n",cfgFile); - return false; + for (i=0; i<3; i++) { + int timer; + key = "timing.inactivity." + ('a' + i); + get_value(cfg, key.c_str(), timer, 0, 300, 0); + timer *= 60; + rf_inactivity_timer[i] = timer; } - + return true; } @@ -1093,11 +1015,11 @@ static bool srv_open() memset(&sin,0,sizeof(struct sockaddr_in)); sin.sin_family = AF_INET; - sin.sin_addr.s_addr = inet_addr(MY_G2_LINK_IP); - sin.sin_port = htons(RMT_XRF_PORT); + sin.sin_addr.s_addr = inet_addr(my_g2_link_ip.c_str()); + sin.sin_port = htons(rmt_xrf_port); if (bind(xrf_g2_sock,(struct sockaddr *)&sin,sizeof(struct sockaddr_in)) != 0) { traceit("Failed to bind gateway socket on port %d for XRF, errno=%d\n", - RMT_XRF_PORT ,errno); + rmt_xrf_port ,errno); close(xrf_g2_sock); xrf_g2_sock = -1; return false; @@ -1126,11 +1048,11 @@ static bool srv_open() fcntl(ref_g2_sock,F_SETFL,O_NONBLOCK); sin.sin_family = AF_INET; - sin.sin_addr.s_addr = inet_addr(MY_G2_LINK_IP); - sin.sin_port = htons(RMT_REF_PORT); + sin.sin_addr.s_addr = inet_addr(my_g2_link_ip.c_str()); + sin.sin_port = htons(rmt_ref_port); if (bind(ref_g2_sock,(struct sockaddr *)&sin,sizeof(struct sockaddr_in)) != 0) { traceit("Failed to bind gateway socket on port %d for REF, errno=%d\n", - RMT_REF_PORT ,errno); + rmt_ref_port ,errno); close(dcs_g2_sock); dcs_g2_sock = -1; close(xrf_g2_sock); @@ -1156,11 +1078,11 @@ static bool srv_open() memset(&sin,0,sizeof(struct sockaddr_in)); sin.sin_family = AF_INET; - sin.sin_addr.s_addr = inet_addr(MY_G2_LINK_IP); - sin.sin_port = htons(MY_G2_LINK_PORT); + sin.sin_addr.s_addr = inet_addr(my_g2_link_ip.c_str()); + sin.sin_port = htons(my_g2_link_port); if (bind(rptr_sock,(struct sockaddr *)&sin,sizeof(struct sockaddr_in)) != 0) { traceit("Failed to bind repeater socket on port %d, errno=%d\n", - MY_G2_LINK_PORT,errno); + my_g2_link_port,errno); close(dcs_g2_sock); dcs_g2_sock = -1; close(rptr_sock); @@ -1175,8 +1097,8 @@ static bool srv_open() /* the local G2 external runs on this IP and port */ memset(&toLocalg2,0,sizeof(struct sockaddr_in)); toLocalg2.sin_family = AF_INET; - toLocalg2.sin_addr.s_addr = inet_addr(TO_G2_EXTERNAL_IP); - toLocalg2.sin_port = htons(TO_G2_EXTERNAL_PORT); + toLocalg2.sin_addr.s_addr = inet_addr(to_g2_external_ip.c_str()); + toLocalg2.sin_port = htons(to_g2_external_port); /* initialize all remote links */ for (i = 0; i < 3; i++) { @@ -1199,22 +1121,22 @@ static void srv_close() { if (xrf_g2_sock != -1) { close(xrf_g2_sock); - traceit("Closed RMT_XRF_PORT\n"); + traceit("Closed rmt_xrf_port\n"); } if (dcs_g2_sock != -1) { close(dcs_g2_sock); - traceit("Closed RMT_DCS_PORT\n"); + traceit("Closed rmt_dcs_port\n"); } if (rptr_sock != -1) { close(rptr_sock); - traceit("Closed MY_G2_LINK_PORT\n"); + traceit("Closed my_g2_link_port\n"); } if (ref_g2_sock != -1) { close(ref_g2_sock); - traceit("Closed RMT_REF_PORT\n"); + traceit("Closed rmt_ref_port\n"); } return; @@ -1327,8 +1249,8 @@ static void g2link(char from_mod, char *call, char to_mod) to_remote_g2[i].in_streamid[1] = 0x00; /* is it XRF? */ - if (port_i == RMT_XRF_PORT) { - strcpy(link_request, OWNER); + if (port_i == rmt_xrf_port) { + strcpy(link_request, owner.c_str()); link_request[8] = from_mod; link_request[9] = to_mod; link_request[10] = '\0'; @@ -1341,8 +1263,8 @@ static void g2link(char from_mod, char *call, char to_mod) sendto(xrf_g2_sock,link_request, CALL_SIZE + 3,0, (struct sockaddr *)&(to_remote_g2[i].toDst4), sizeof(to_remote_g2[i].toDst4)); - } else if (port_i == RMT_DCS_PORT) { - strcpy(link_request, OWNER); + } else if (port_i == rmt_dcs_port) { + strcpy(link_request, owner.c_str()); link_request[8] = from_mod; link_request[9] = to_mod; link_request[10] = '\0'; @@ -1357,7 +1279,7 @@ static void g2link(char from_mod, char *call, char to_mod) sendto(dcs_g2_sock,link_request, 519,0, (struct sockaddr *)&(to_remote_g2[i].toDst4), sizeof(to_remote_g2[i].toDst4)); - } else if (port_i == RMT_REF_PORT) { + } else if (port_i == rmt_ref_port) { for (counter = 0; counter < 3; counter++) { if (counter != i) { if ( (to_remote_g2[counter].to_call[0] != '\0') && @@ -1497,16 +1419,14 @@ static void runit() traceit("xrf=%d, dcs=%d, ref=%d, rptr=%d, MAX+1=%d\n", xrf_g2_sock, dcs_g2_sock, ref_g2_sock, rptr_sock, max_nfds + 1); - if (strlen(LINK_AT_STARTUP) >= 8) { - if ((LINK_AT_STARTUP[0] == 'A') || - (LINK_AT_STARTUP[0] == 'B') || - (LINK_AT_STARTUP[0] == 'C')) { + if (strlen(link_at_startup) >= 8) { + if ((link_at_startup[0] == 'A') || (link_at_startup[0] == 'B') || (link_at_startup[0] == 'C')) { memset(temp_repeater, ' ', CALL_SIZE); - memcpy(temp_repeater, LINK_AT_STARTUP + 1, 6); + memcpy(temp_repeater, link_at_startup + 1, 6); temp_repeater[CALL_SIZE] = '\0'; - g2link(LINK_AT_STARTUP[0], temp_repeater, LINK_AT_STARTUP[7]); + g2link(link_at_startup[0], temp_repeater, link_at_startup[7]); } - memset(LINK_AT_STARTUP, '\0', sizeof(LINK_AT_STARTUP)); + memset(link_at_startup, '\0', sizeof(link_at_startup)); } while (keep_running) { @@ -1516,27 +1436,27 @@ static void runit() send_heartbeat(); /* send heartbeat to linked XRF repeaters/reflectors */ - if (to_remote_g2[0].toDst4.sin_port == htons(RMT_XRF_PORT)) - sendto(xrf_g2_sock,OWNER, CALL_SIZE + 1, 0, + if (to_remote_g2[0].toDst4.sin_port == htons(rmt_xrf_port)) + sendto(xrf_g2_sock, owner.c_str(), CALL_SIZE + 1, 0, (struct sockaddr *)&(to_remote_g2[0].toDst4), sizeof(to_remote_g2[0].toDst4)); - if ((to_remote_g2[1].toDst4.sin_port == htons(RMT_XRF_PORT)) && + if ((to_remote_g2[1].toDst4.sin_port == htons(rmt_xrf_port)) && (strcmp(to_remote_g2[1].to_call, to_remote_g2[0].to_call) != 0)) - sendto(xrf_g2_sock,OWNER, CALL_SIZE + 1, 0, + sendto(xrf_g2_sock, owner.c_str(), CALL_SIZE + 1, 0, (struct sockaddr *)&(to_remote_g2[1].toDst4), sizeof(to_remote_g2[1].toDst4)); - if ((to_remote_g2[2].toDst4.sin_port == htons(RMT_XRF_PORT)) && + if ((to_remote_g2[2].toDst4.sin_port == htons(rmt_xrf_port)) && (strcmp(to_remote_g2[2].to_call, to_remote_g2[0].to_call) != 0) && (strcmp(to_remote_g2[2].to_call, to_remote_g2[1].to_call) != 0)) - sendto(xrf_g2_sock,OWNER, CALL_SIZE + 1, 0, + sendto(xrf_g2_sock, owner.c_str(), CALL_SIZE + 1, 0, (struct sockaddr *)&(to_remote_g2[2].toDst4), sizeof(to_remote_g2[2].toDst4)); /* send heartbeat to linked DCS reflectors */ - if (to_remote_g2[0].toDst4.sin_port == htons(RMT_DCS_PORT)) { - strcpy(cmd_2_dcs, OWNER); + if (to_remote_g2[0].toDst4.sin_port == htons(rmt_dcs_port)) { + strcpy(cmd_2_dcs, owner.c_str()); cmd_2_dcs[7] = to_remote_g2[0].from_mod; memcpy(cmd_2_dcs + 9, to_remote_g2[0].to_call, 8); cmd_2_dcs[16] = to_remote_g2[0].to_mod; @@ -1544,8 +1464,8 @@ static void runit() (struct sockaddr *)&(to_remote_g2[0].toDst4), sizeof(to_remote_g2[0].toDst4)); } - if (to_remote_g2[1].toDst4.sin_port == htons(RMT_DCS_PORT)) { - strcpy(cmd_2_dcs, OWNER); + if (to_remote_g2[1].toDst4.sin_port == htons(rmt_dcs_port)) { + strcpy(cmd_2_dcs, owner.c_str()); cmd_2_dcs[7] = to_remote_g2[1].from_mod; memcpy(cmd_2_dcs + 9, to_remote_g2[1].to_call, 8); cmd_2_dcs[16] = to_remote_g2[1].to_mod; @@ -1553,8 +1473,8 @@ static void runit() (struct sockaddr *)&(to_remote_g2[1].toDst4), sizeof(to_remote_g2[1].toDst4)); } - if (to_remote_g2[2].toDst4.sin_port == htons(RMT_DCS_PORT)) { - strcpy(cmd_2_dcs, OWNER); + if (to_remote_g2[2].toDst4.sin_port == htons(rmt_dcs_port)) { + strcpy(cmd_2_dcs, owner.c_str()); cmd_2_dcs[7] = to_remote_g2[2].from_mod; memcpy(cmd_2_dcs + 9, to_remote_g2[2].to_call, 8); cmd_2_dcs[16] = to_remote_g2[2].to_mod; @@ -1565,20 +1485,20 @@ static void runit() /* send heartbeat to linked REF reflectors */ if (to_remote_g2[0].is_connected && - (to_remote_g2[0].toDst4.sin_port == htons(RMT_REF_PORT))) + (to_remote_g2[0].toDst4.sin_port == htons(rmt_ref_port))) sendto(ref_g2_sock,(char *)REF_ACK,3,0, (struct sockaddr *)&(to_remote_g2[0].toDst4), sizeof(to_remote_g2[0].toDst4)); if (to_remote_g2[1].is_connected && - (to_remote_g2[1].toDst4.sin_port == htons(RMT_REF_PORT)) && + (to_remote_g2[1].toDst4.sin_port == htons(rmt_ref_port)) && (strcmp(to_remote_g2[1].to_call, to_remote_g2[0].to_call) != 0)) sendto(ref_g2_sock,(char *)REF_ACK,3,0, (struct sockaddr *)&(to_remote_g2[1].toDst4), sizeof(to_remote_g2[1].toDst4)); if (to_remote_g2[2].is_connected && - (to_remote_g2[2].toDst4.sin_port == htons(RMT_REF_PORT)) && + (to_remote_g2[2].toDst4.sin_port == htons(rmt_ref_port)) && (strcmp(to_remote_g2[2].to_call, to_remote_g2[0].to_call) != 0) && (strcmp(to_remote_g2[2].to_call, to_remote_g2[1].to_call) != 0)) sendto(ref_g2_sock,(char *)REF_ACK,3,0, @@ -1615,13 +1535,13 @@ static void runit() /*** check for RF inactivity ***/ if (to_remote_g2[i].is_connected) { - if (((tnow - tracing[i].last_time) > RF_INACTIVITY_TIMER[i]) && (RF_INACTIVITY_TIMER[i] > 0)) { + if (((tnow - tracing[i].last_time) > rf_inactivity_timer[i]) && (rf_inactivity_timer[i] > 0)) { tracing[i].last_time = 0; traceit("Unlinked from [%s] mod %c, local RF inactivity...\n", to_remote_g2[i].to_call, to_remote_g2[i].to_mod); - if (to_remote_g2[i].toDst4.sin_port == htons(RMT_REF_PORT)) { + if (to_remote_g2[i].toDst4.sin_port == htons(rmt_ref_port)) { queryCommand[0] = 5; queryCommand[1] = 0; queryCommand[2] = 24; @@ -1635,7 +1555,7 @@ static void runit() for (j = 0; j < 3; j++) { if (j != i) { if ((to_remote_g2[j].toDst4.sin_addr.s_addr == to_remote_g2[i].toDst4.sin_addr.s_addr) && - (to_remote_g2[j].toDst4.sin_port == htons(RMT_REF_PORT))) { + (to_remote_g2[j].toDst4.sin_port == htons(rmt_ref_port))) { to_remote_g2[j].to_call[0] = '\0'; memset(&(to_remote_g2[j].toDst4),0,sizeof(struct sockaddr_in)); to_remote_g2[j].from_mod = ' '; @@ -1647,8 +1567,8 @@ static void runit() } } } - } else if (to_remote_g2[i].toDst4.sin_port == htons(RMT_XRF_PORT)) { - strcpy(unlink_request, OWNER); + } else if (to_remote_g2[i].toDst4.sin_port == htons(rmt_xrf_port)) { + strcpy(unlink_request, owner.c_str()); unlink_request[8] = to_remote_g2[i].from_mod; unlink_request[9] = ' '; unlink_request[10] = '\0'; @@ -1657,8 +1577,8 @@ static void runit() sendto(xrf_g2_sock,unlink_request, CALL_SIZE + 3,0, (struct sockaddr *)&(to_remote_g2[i].toDst4), sizeof(to_remote_g2[i].toDst4)); - } else if (to_remote_g2[i].toDst4.sin_port == htons(RMT_DCS_PORT)) { - strcpy(cmd_2_dcs, OWNER); + } else if (to_remote_g2[i].toDst4.sin_port == htons(rmt_dcs_port)) { + strcpy(cmd_2_dcs, owner.c_str()); cmd_2_dcs[8] = to_remote_g2[i].from_mod; cmd_2_dcs[9] = ' '; cmd_2_dcs[10] = '\0'; @@ -1716,7 +1636,7 @@ static void runit() /* Find out if it is a keepalive from a repeater */ for (i = 0; i < 3; i++) { if ((fromDst4.sin_addr.s_addr == to_remote_g2[i].toDst4.sin_addr.s_addr) && - (to_remote_g2[i].toDst4.sin_port == htons(RMT_XRF_PORT))) { + (to_remote_g2[i].toDst4.sin_port == htons(rmt_xrf_port))) { found = true; if (!to_remote_g2[i].is_connected) { tracing[i].last_time = time(NULL); @@ -1745,7 +1665,7 @@ static void runit() if (recvlen2 == (CALL_SIZE + 6)) { for (i = 0; i < 3; i++) { if ((fromDst4.sin_addr.s_addr == to_remote_g2[i].toDst4.sin_addr.s_addr) && - (to_remote_g2[i].toDst4.sin_port == htons(RMT_XRF_PORT))) { + (to_remote_g2[i].toDst4.sin_port == htons(rmt_xrf_port))) { if ((memcmp((char *)readBuffer2 + 10, "ACK", 3) == 0) && (to_remote_g2[i].from_mod == readBuffer2[8])) { if (!to_remote_g2[i].is_connected) { @@ -1798,7 +1718,7 @@ static void runit() /* Check our linked repeaters/reflectors */ for (i = 0; i < 3; i++) { if ((fromDst4.sin_addr.s_addr == to_remote_g2[i].toDst4.sin_addr.s_addr) && - (to_remote_g2[i].toDst4.sin_port == htons(RMT_XRF_PORT))) { + (to_remote_g2[i].toDst4.sin_port == htons(rmt_xrf_port))) { if (to_remote_g2[i].to_mod == readBuffer2[8]) { /* unlink request from remote repeater that we know */ if (readBuffer2[9] == ' ') { @@ -1839,7 +1759,7 @@ static void runit() strncpy(to_remote_g2[i].to_call, (char *)readBuffer2,CALL_SIZE); to_remote_g2[i].to_call[CALL_SIZE] = '\0'; memcpy(&(to_remote_g2[i].toDst4), &fromDst4, sizeof(struct sockaddr_in)); - to_remote_g2[i].toDst4.sin_port = htons(RMT_XRF_PORT); + to_remote_g2[i].toDst4.sin_port = htons(rmt_xrf_port); to_remote_g2[i].to_mod = readBuffer2[8]; to_remote_g2[i].countdown = TIMEOUT; to_remote_g2[i].is_connected = true; @@ -1917,7 +1837,7 @@ static void runit() strcpy(to_remote_g2[i].to_call, call); to_remote_g2[i].to_call[CALL_SIZE] = '\0'; memcpy(&(to_remote_g2[i].toDst4), &fromDst4, sizeof(struct sockaddr_in)); - to_remote_g2[i].toDst4.sin_port = htons(RMT_XRF_PORT); + to_remote_g2[i].toDst4.sin_port = htons(rmt_xrf_port); to_remote_g2[i].from_mod = readBuffer2[9]; to_remote_g2[i].to_mod = readBuffer2[8]; to_remote_g2[i].countdown = TIMEOUT; @@ -1954,7 +1874,7 @@ static void runit() if (fromDst4.sin_addr.s_addr != to_remote_g2[i].toDst4.sin_addr.s_addr) { /* Our repeater module is linked to another repeater-reflector */ memcpy(readBuffer2 + 10, "NAK", 4); - fromDst4.sin_port = htons(RMT_XRF_PORT); + fromDst4.sin_port = htons(rmt_xrf_port); sendto(xrf_g2_sock, (char *)readBuffer2, CALL_SIZE + 6, 0,(struct sockaddr *)&fromDst4, sizeof(struct sockaddr_in)); @@ -1972,7 +1892,7 @@ static void runit() found = false; for (i = 0; i < 3; i++) { if ((fromDst4.sin_addr.s_addr == to_remote_g2[i].toDst4.sin_addr.s_addr) && - (to_remote_g2[i].toDst4.sin_port == htons(RMT_XRF_PORT))) { + (to_remote_g2[i].toDst4.sin_port == htons(rmt_xrf_port))) { to_remote_g2[i].countdown = TIMEOUT; found = true; } @@ -1999,11 +1919,11 @@ static void runit() for (i = 0; i < 3; i++) { if ((fromDst4.sin_addr.s_addr == to_remote_g2[i].toDst4.sin_addr.s_addr) && - (to_remote_g2[i].toDst4.sin_port == htons(RMT_XRF_PORT))) { + (to_remote_g2[i].toDst4.sin_port == htons(rmt_xrf_port))) { /* it is a reflector, reflector's rpt1 */ if ((memcmp(readBuffer2 + 18, to_remote_g2[i].to_call, 7) == 0) && (readBuffer2[25] == to_remote_g2[i].to_mod)) { - memcpy(&readBuffer2[18], OWNER, CALL_SIZE); + memcpy(&readBuffer2[18], owner.c_str(), CALL_SIZE); readBuffer2[25] = to_remote_g2[i].from_mod; memcpy(&readBuffer2[34], "CQCQCQ ", 8); @@ -2012,7 +1932,7 @@ static void runit() break; } else /* it is a repeater, our rpt1 */ - if ((memcmp(readBuffer2 + 18, OWNER, 7)) && + if ((memcmp(readBuffer2 + 18, owner.c_str(), CALL_SIZE-1)) && (readBuffer2[25] == to_remote_g2[i].from_mod)) { memcpy(source_stn, to_remote_g2[i].to_call, 8); source_stn[7] = to_remote_g2[i].to_mod; @@ -2023,7 +1943,7 @@ static void runit() /* somebody's crazy idea of having a personal callsign in RPT2 */ /* we must set it to our gateway callsign */ - memcpy(&readBuffer2[26], OWNER, CALL_SIZE); + memcpy(&readBuffer2[26], owner.c_str(), CALL_SIZE); readBuffer2[33] = 'G'; calcPFCS(readBuffer2,56); @@ -2039,10 +1959,10 @@ static void runit() i = 2; /* are we sure that RPT1 is our system? */ - if ((memcmp(readBuffer2 + 18, OWNER, 7) == 0) && (i >= 0)) { + if ((memcmp(readBuffer2 + 18, owner.c_str(), CALL_SIZE-1) == 0) && (i >= 0)) { /* Last Heard */ if (memcmp(old_sid[i].sid, readBuffer2 + 12, 2) != 0) { - if (QSO_DETAILS) + if (qso_details) traceit("START from remote g2: streamID=%d,%d, flags=%02x:%02x:%02x, my=%.8s, sfx=%.4s, ur=%.8s, rpt1=%.8s, rpt2=%.8s, %d bytes fromIP=%s, source=%.8s\n", readBuffer2[12],readBuffer2[13], readBuffer2[15], readBuffer2[16], readBuffer2[17], @@ -2110,7 +2030,7 @@ static void runit() /* it is a remote gateway, not a dongle user */ if ((fromDst4.sin_addr.s_addr == to_remote_g2[j].toDst4.sin_addr.s_addr) && /* it is xrf */ - (to_remote_g2[j].toDst4.sin_port == htons(RMT_XRF_PORT)) && + (to_remote_g2[j].toDst4.sin_port == htons(rmt_xrf_port)) && (memcmp(to_remote_g2[j].to_call, "XRF", 3) == 0) && /* it is the same xrf and xrf module */ (memcmp(to_remote_g2[j].to_call, to_remote_g2[i].to_call, 8) == 0) && @@ -2149,14 +2069,14 @@ static void runit() if ((to_remote_g2[i].toDst4.sin_addr.s_addr != fromDst4.sin_addr.s_addr) && to_remote_g2[i].is_connected) { - if (to_remote_g2[i].toDst4.sin_port == htons(RMT_XRF_PORT)) { - if ( /*** (memcmp(readBuffer2 + 42, OWNER, 8) != 0) && ***/ /* block repeater announcements */ + if (to_remote_g2[i].toDst4.sin_port == htons(rmt_xrf_port)) { + if ( /*** (memcmp(readBuffer2 + 42, owner, 8) != 0) && ***/ /* block repeater announcements */ (memcmp(readBuffer2 + 34, "CQCQCQ", 6) == 0) && /* CQ calls only */ ((readBuffer2[15] == 0x00) || /* normal */ (readBuffer2[15] == 0x08) || /* EMR */ (readBuffer2[15] == 0x20) || /* BK */ (readBuffer2[15] == 0x28)) && /* EMR + BK */ - (memcmp(readBuffer2 + 26, OWNER, 7) == 0) && /* rpt2 must be us */ + (memcmp(readBuffer2 + 26, owner.c_str(), CALL_SIZE-1) == 0) && /* rpt2 must be us */ (readBuffer2[33] == 'G')) { to_remote_g2[i].in_streamid[0] = readBuffer2[12]; to_remote_g2[i].in_streamid[1] = readBuffer2[13]; @@ -2174,14 +2094,14 @@ static void runit() (struct sockaddr *)&(to_remote_g2[i].toDst4), sizeof(struct sockaddr_in)); } - } else if (to_remote_g2[i].toDst4.sin_port == htons(RMT_REF_PORT)) { - if ( /*** (memcmp(readBuffer2 + 42, OWNER, 8) != 0) && ***/ /* block repeater announcements */ + } else if (to_remote_g2[i].toDst4.sin_port == htons(rmt_ref_port)) { + if ( /*** (memcmp(readBuffer2 + 42, owner, 8) != 0) && ***/ /* block repeater announcements */ (memcmp(readBuffer2 + 34, "CQCQCQ", 6) == 0) && /* CQ calls only */ ((readBuffer2[15] == 0x00) || /* normal */ (readBuffer2[15] == 0x08) || /* EMR */ (readBuffer2[15] == 0x20) || /* BK */ (readBuffer2[15] == 0x28)) && /* EMR + BK */ - (memcmp(readBuffer2 + 26, OWNER, 7) == 0) && /* rpt2 must be us */ + (memcmp(readBuffer2 + 26, owner.c_str(), CALL_SIZE-1) == 0) && /* rpt2 must be us */ (readBuffer2[33] == 'G')) { to_remote_g2[i].in_streamid[0] = readBuffer2[12]; to_remote_g2[i].in_streamid[1] = readBuffer2[13]; @@ -2208,14 +2128,14 @@ static void runit() (struct sockaddr *)&(to_remote_g2[i].toDst4), sizeof(struct sockaddr_in)); } - } else if (to_remote_g2[i].toDst4.sin_port == htons(RMT_DCS_PORT)) { - if ( /*** (memcmp(readBuffer2 + 42, OWNER, 8) != 0) && ***/ /* block repeater announcements */ + } else if (to_remote_g2[i].toDst4.sin_port == htons(rmt_dcs_port)) { + if ( /*** (memcmp(readBuffer2 + 42, owner, 8) != 0) && ***/ /* block repeater announcements */ (memcmp(readBuffer2 + 34, "CQCQCQ", 6) == 0) && /* CQ calls only */ ((readBuffer2[15] == 0x00) || /* normal */ (readBuffer2[15] == 0x08) || /* EMR */ (readBuffer2[15] == 0x20) || /* BK */ (readBuffer2[15] == 0x28)) && /* EMR + BK */ - (memcmp(readBuffer2 + 26, OWNER, 7) == 0) && /* rpt2 must be us */ + (memcmp(readBuffer2 + 26, owner.c_str(), CALL_SIZE-1) == 0) && /* rpt2 must be us */ (readBuffer2[33] == 'G')) { to_remote_g2[i].in_streamid[0] = readBuffer2[12]; to_remote_g2[i].in_streamid[1] = readBuffer2[13]; @@ -2231,7 +2151,7 @@ static void runit() if ((readBuffer2[14] & 0x40) != 0) { for (i = 0; i < 3; i++) { if (memcmp(old_sid[i].sid, readBuffer2 + 12, 2) == 0) { - if (QSO_DETAILS) + if (qso_details) traceit("END from remote g2: streamID=%d,%d, %d bytes from IP=%s\n", readBuffer2[12],readBuffer2[13],recvlen2,inet_ntoa(fromDst4.sin_addr)); @@ -2292,14 +2212,14 @@ static void runit() if ((to_remote_g2[i].is_connected) && (to_remote_g2[i].toDst4.sin_addr.s_addr != fromDst4.sin_addr.s_addr) && (memcmp(to_remote_g2[i].in_streamid, readBuffer2 + 12, 2) == 0)) { - if (to_remote_g2[i].toDst4.sin_port == htons(RMT_XRF_PORT)) { + if (to_remote_g2[i].toDst4.sin_port == htons(rmt_xrf_port)) { /* inform XRF about the source */ readBuffer2[11] = to_remote_g2[i].from_mod; sendto(xrf_g2_sock, (char *)readBuffer2, 27, 0, (struct sockaddr *)&(to_remote_g2[i].toDst4), sizeof(struct sockaddr_in)); - } else if (to_remote_g2[i].toDst4.sin_port == htons(RMT_REF_PORT)) { + } else if (to_remote_g2[i].toDst4.sin_port == htons(rmt_ref_port)) { readBuffer[0] = (unsigned char)(29 & 0xFF); readBuffer[1] = (unsigned char)(29 >> 8 & 0x1F); readBuffer[1] = (unsigned char)(readBuffer[1] | 0xFFFFFF80); @@ -2309,14 +2229,14 @@ static void runit() sendto(ref_g2_sock, (char *)readBuffer, 29, 0,(struct sockaddr *)&(to_remote_g2[i].toDst4), sizeof(struct sockaddr_in)); - } else if (to_remote_g2[i].toDst4.sin_port == htons(RMT_DCS_PORT)) { + } else if (to_remote_g2[i].toDst4.sin_port == htons(rmt_dcs_port)) { memset(dcs_buf, 0x00, 600); dcs_buf[0] = dcs_buf[1] = dcs_buf[2] = '0'; dcs_buf[3] = '1'; dcs_buf[4] = dcs_buf[5] = dcs_buf[6] = 0x00; memcpy(dcs_buf + 7, to_remote_g2[i].to_call, 8); dcs_buf[14] = to_remote_g2[i].to_mod; - memcpy(dcs_buf + 15, OWNER, 8); + memcpy(dcs_buf + 15, owner.c_str(), CALL_SIZE); dcs_buf[22] = to_remote_g2[i].from_mod; memcpy(dcs_buf + 23, "CQCQCQ ", 8); memcpy(dcs_buf + 31, xrf_2_dcs[i].mycall, 8); @@ -2709,7 +2629,7 @@ static void runit() for (i = 0; i < 3; i++) { if ((fromDst4.sin_addr.s_addr == to_remote_g2[i].toDst4.sin_addr.s_addr) && - (to_remote_g2[i].toDst4.sin_port == htons(RMT_REF_PORT))) { + (to_remote_g2[i].toDst4.sin_port == htons(rmt_ref_port))) { traceit("Call %s disconnected\n", to_remote_g2[i].to_call); to_remote_g2[i].to_call[0] = '\0'; @@ -2737,7 +2657,7 @@ static void runit() for (i = 0; i < 3; i++) { if ((fromDst4.sin_addr.s_addr == to_remote_g2[i].toDst4.sin_addr.s_addr) && - (to_remote_g2[i].toDst4.sin_port == htons(RMT_REF_PORT))) { + (to_remote_g2[i].toDst4.sin_port == htons(rmt_ref_port))) { found = true; if ((recvlen2 == 5) && (readBuffer2[0] == 5) && @@ -2751,7 +2671,7 @@ static void runit() queryCommand[2] = 4; queryCommand[3] = 0; - memcpy(queryCommand + 4, LOGIN_CALL, CALL_SIZE); + memcpy(queryCommand + 4, login_call.c_str(), CALL_SIZE); for (j = 11; j > 3; j--) { if (queryCommand[j] == ' ') queryCommand[j] = '\0'; @@ -2775,7 +2695,7 @@ static void runit() for (i = 0; i < 3; i++) { if ((fromDst4.sin_addr.s_addr == to_remote_g2[i].toDst4.sin_addr.s_addr) && - (to_remote_g2[i].toDst4.sin_port == htons(RMT_REF_PORT))) { + (to_remote_g2[i].toDst4.sin_port == htons(rmt_ref_port))) { found = true; if ((recvlen2 == 8) && (readBuffer2[0] == 8) && @@ -2849,7 +2769,7 @@ static void runit() for (i = 0; i < 3; i++) { if ((fromDst4.sin_addr.s_addr == to_remote_g2[i].toDst4.sin_addr.s_addr) && - (to_remote_g2[i].toDst4.sin_port == htons(RMT_REF_PORT))) { + (to_remote_g2[i].toDst4.sin_port == htons(rmt_ref_port))) { found = true; if ((recvlen2 == 24) && (readBuffer2[0] == 24) && @@ -2864,7 +2784,7 @@ static void runit() for (i = 0; i < 3; i++) { if ((fromDst4.sin_addr.s_addr == to_remote_g2[i].toDst4.sin_addr.s_addr) && - (to_remote_g2[i].toDst4.sin_port == htons(RMT_REF_PORT))) { + (to_remote_g2[i].toDst4.sin_port == htons(rmt_ref_port))) { found = true; if (recvlen2 == 3) to_remote_g2[i].countdown = TIMEOUT; @@ -2894,8 +2814,8 @@ static void runit() (readBuffer2[2] == 24) && (readBuffer2[3] == 0) && (readBuffer2[4] == 1)) { - if ((inbound_list.size() + 1) > MAX_DONGLES) - traceit("Inbound DONGLE-p connection from %s but over the MAX_DONGLES limit of %d\n", + if ((inbound_list.size() + 1) > max_dongles) + traceit("Inbound DONGLE-p connection from %s but over the max_dongles limit of %d\n", ip, inbound_list.size()); else sendto(ref_g2_sock,(char *)readBuffer2,5,0, @@ -2920,10 +2840,10 @@ static void runit() traceit("Inbound DONGLE-p CALL=%s, ip=%s, DV=%.8s\n", call, ip, readBuffer2 + 20); - if ((inbound_list.size() + 1) > MAX_DONGLES) - traceit("Inbound DONGLE-p connection from %s but over the MAX_DONGLES limit of %d\n", + if ((inbound_list.size() + 1) > max_dongles) + traceit("Inbound DONGLE-p connection from %s but over the max_dongles limit of %d\n", ip, inbound_list.size()); - else if (ONLY_ADMIN_LOGIN && (admin.find(call) == admin.end())) + else if (only_admin_login && (admin.find(call) == admin.end())) traceit("Incoming call [%s] from %s not an ADMIN\n", call, ip); else if (regexec(&preg, call, 0, NULL, 0) != 0) { traceit("Invalid dongle callsign: CALL=%s,ip=%s\n", call, ip); @@ -3015,7 +2935,7 @@ static void runit() found = false; for (i = 0; i < 3; i++) { if ((fromDst4.sin_addr.s_addr == to_remote_g2[i].toDst4.sin_addr.s_addr) && - (to_remote_g2[i].toDst4.sin_port == htons(RMT_REF_PORT))) { + (to_remote_g2[i].toDst4.sin_port == htons(rmt_ref_port))) { to_remote_g2[i].countdown = TIMEOUT; found = true; } @@ -3050,14 +2970,14 @@ static void runit() /* It is from a repeater-reflector, correct rpt1, rpt2 and re-compute pfcs */ for (i = 0; i < 3; i++) { if ((fromDst4.sin_addr.s_addr == to_remote_g2[i].toDst4.sin_addr.s_addr) && - (to_remote_g2[i].toDst4.sin_port == htons(RMT_REF_PORT)) && + (to_remote_g2[i].toDst4.sin_port == htons(rmt_ref_port)) && ( ((memcmp(readBuffer2 + 20, to_remote_g2[i].to_call, 7) == 0) && (readBuffer2[27] == to_remote_g2[i].to_mod)) || ((memcmp(readBuffer2 + 28, to_remote_g2[i].to_call, 7) == 0) && (readBuffer2[35] == to_remote_g2[i].to_mod)) )) { - memcpy(&readBuffer2[20], OWNER, CALL_SIZE); + memcpy(&readBuffer2[20], owner.c_str(), CALL_SIZE); readBuffer2[27] = to_remote_g2[i].from_mod; memcpy(&readBuffer2[36], "CQCQCQ ", 8); @@ -3078,7 +2998,7 @@ static void runit() /* somebody's crazy idea of having a personal callsign in RPT2 */ /* we must set it to our gateway callsign */ - memcpy(&readBuffer2[28], OWNER, CALL_SIZE); + memcpy(&readBuffer2[28], owner.c_str(), CALL_SIZE); readBuffer2[35] = 'G'; calcPFCS(readBuffer2 + 2,56); @@ -3093,10 +3013,10 @@ static void runit() i = 2; /* are we sure that RPT1 is our system? */ - if ((memcmp(readBuffer2 + 20, OWNER, 7) == 0) && (i >= 0)) { + if ((memcmp(readBuffer2 + 20, owner.c_str(), CALL_SIZE-1) == 0) && (i >= 0)) { /* Last Heard */ if (memcmp(old_sid[i].sid, readBuffer2 + 14, 2) != 0) { - if (QSO_DETAILS) + if (qso_details) traceit("START from remote g2: streamID=%d,%d, flags=%02x:%02x:%02x, my=%.8s, sfx=%.4s, ur=%.8s, rpt1=%.8s, rpt2=%.8s, %d bytes fromIP=%s, source=%.8s\n", readBuffer2[14],readBuffer2[15], readBuffer2[17], readBuffer2[18], readBuffer2[19], @@ -3145,26 +3065,26 @@ static void runit() if ((to_remote_g2[i].toDst4.sin_addr.s_addr != fromDst4.sin_addr.s_addr) && to_remote_g2[i].is_connected) { - if ( /*** (memcmp(readBuffer2 + 44, OWNER, 8) != 0) && ***/ /* block repeater announcements */ + if ( /*** (memcmp(readBuffer2 + 44, owner, 8) != 0) && ***/ /* block repeater announcements */ (memcmp(readBuffer2 + 36, "CQCQCQ", 6) == 0) && /* CQ calls only */ ((readBuffer2[17] == 0x00) || /* normal */ (readBuffer2[17] == 0x08) || /* EMR */ (readBuffer2[17] == 0x20) || /* BK */ (readBuffer2[17] == 0x28)) && /* EMR + BK */ - (memcmp(readBuffer2 + 28, OWNER, 7) == 0) && /* rpt2 must be us */ + (memcmp(readBuffer2 + 28, owner.c_str(), CALL_SIZE-1) == 0) && /* rpt2 must be us */ (readBuffer2[35] == 'G')) { to_remote_g2[i].in_streamid[0] = readBuffer2[14]; to_remote_g2[i].in_streamid[1] = readBuffer2[15]; - if ((to_remote_g2[i].toDst4.sin_port == htons(RMT_XRF_PORT)) || - (to_remote_g2[i].toDst4.sin_port == htons(RMT_REF_PORT))) { + if ((to_remote_g2[i].toDst4.sin_port == htons(rmt_xrf_port)) || + (to_remote_g2[i].toDst4.sin_port == htons(rmt_ref_port))) { memcpy((char *)readBuffer2 + 20, to_remote_g2[i].to_call, CALL_SIZE); readBuffer2[27] = to_remote_g2[i].to_mod; memcpy((char *)readBuffer2 + 28, to_remote_g2[i].to_call, CALL_SIZE); readBuffer2[35] = 'G'; calcPFCS(readBuffer2 + 2, 56); - if (to_remote_g2[i].toDst4.sin_port == htons(RMT_XRF_PORT)) { + if (to_remote_g2[i].toDst4.sin_port == htons(rmt_xrf_port)) { /* inform XRF about the source */ readBuffer2[13] = to_remote_g2[i].from_mod; @@ -3175,7 +3095,7 @@ static void runit() sendto(ref_g2_sock, (char *)readBuffer2, 58, 0, (struct sockaddr *)&(to_remote_g2[i].toDst4), sizeof(struct sockaddr_in)); - } else if (to_remote_g2[i].toDst4.sin_port == htons(RMT_DCS_PORT)) { + } else if (to_remote_g2[i].toDst4.sin_port == htons(rmt_dcs_port)) { memcpy(ref_2_dcs[i].mycall, readBuffer2 + 44, 8); memcpy(ref_2_dcs[i].sfx, readBuffer2 + 52, 4); ref_2_dcs[i].dcs_rptr_seq = 0; @@ -3187,7 +3107,7 @@ static void runit() if ((readBuffer2[16] & 0x40) != 0) { for (i = 0; i < 3; i++) { if (memcmp(old_sid[i].sid, readBuffer2 + 14, 2) == 0) { - if (QSO_DETAILS) + if (qso_details) traceit("END from remote g2: streamID=%d,%d, %d bytes from IP=%s\n", readBuffer2[14],readBuffer2[15],recvlen2,inet_ntoa(fromDst4.sin_addr)); @@ -3215,25 +3135,25 @@ static void runit() if ((to_remote_g2[i].is_connected) && (to_remote_g2[i].toDst4.sin_addr.s_addr != fromDst4.sin_addr.s_addr) && (memcmp(to_remote_g2[i].in_streamid, readBuffer2 + 14, 2) == 0)) { - if (to_remote_g2[i].toDst4.sin_port == htons(RMT_XRF_PORT)) { + if (to_remote_g2[i].toDst4.sin_port == htons(rmt_xrf_port)) { /* inform XRF about the source */ readBuffer2[13] = to_remote_g2[i].from_mod; sendto(xrf_g2_sock, (char *)readBuffer2 + 2, 27, 0, (struct sockaddr *)&(to_remote_g2[i].toDst4), sizeof(struct sockaddr_in)); - } else if (to_remote_g2[i].toDst4.sin_port == htons(RMT_REF_PORT)) + } else if (to_remote_g2[i].toDst4.sin_port == htons(rmt_ref_port)) sendto(ref_g2_sock, (char *)readBuffer2, 29, 0,(struct sockaddr *)&(to_remote_g2[i].toDst4), sizeof(struct sockaddr_in)); - else if (to_remote_g2[i].toDst4.sin_port == htons(RMT_DCS_PORT)) { + else if (to_remote_g2[i].toDst4.sin_port == htons(rmt_dcs_port)) { memset(dcs_buf, 0x00, 600); dcs_buf[0] = dcs_buf[1] = dcs_buf[2] = '0'; dcs_buf[3] = '1'; dcs_buf[4] = dcs_buf[5] = dcs_buf[6] = 0x00; memcpy(dcs_buf + 7, to_remote_g2[i].to_call, 8); dcs_buf[14] = to_remote_g2[i].to_mod; - memcpy(dcs_buf + 15, OWNER, 8); + memcpy(dcs_buf + 15, owner.c_str(), CALL_SIZE); dcs_buf[22] = to_remote_g2[i].from_mod; memcpy(dcs_buf + 23, "CQCQCQ ", 8); memcpy(dcs_buf + 31, ref_2_dcs[i].mycall, 8); @@ -3300,7 +3220,7 @@ static void runit() if (i < 3) { /* Last Heard */ if (memcmp(old_sid[i].sid, dcs_buf + 43, 2) != 0) { - if (QSO_DETAILS) + if (qso_details) traceit("START from dcs: streamID=%d,%d, my=%.8s, sfx=%.4s, ur=%.8s, rpt1=%.8s, rpt2=%.8s, %d bytes fromIP=%s, source=%.8s\n", dcs_buf[43],dcs_buf[44], &dcs_buf[31], @@ -3364,9 +3284,9 @@ static void runit() readBuffer2[15] = dcs_buf[44]; readBuffer2[16] = 0x80; readBuffer2[17] = readBuffer2[18] = readBuffer2[19] = 0x00; - memcpy(readBuffer2 + 20, OWNER, 8); + memcpy(readBuffer2 + 20, owner.c_str(), CALL_SIZE); readBuffer2[27] = to_remote_g2[i].from_mod; - memcpy(readBuffer2 + 28, OWNER, 8); + memcpy(readBuffer2 + 28, owner.c_str(), CALL_SIZE); readBuffer2[35] = 'G'; memcpy(readBuffer2 + 36, "CQCQCQ ", 8); memcpy(readBuffer2 + 44, dcs_buf + 31, 8); @@ -3431,7 +3351,7 @@ static void runit() if ((dcs_buf[45] & 0x40) != 0) { memset(old_sid[i].sid, 0x00, 2); - if (QSO_DETAILS) + if (qso_details) traceit("END from dcs: streamID=%d,%d, %d bytes from IP=%s\n", dcs_buf[43],dcs_buf[44], recvlen2,inet_ntoa(fromDst4.sin_addr)); @@ -3459,11 +3379,11 @@ static void runit() i = 2; /* It is one of our valid repeaters */ - // DG1HT from OWNER 8 to 7 - if ((i >= 0) && (memcmp(dcs_buf + 9, OWNER, 7) == 0)) { + // DG1HT from owner 8 to 7 + if ((i >= 0) && (memcmp(dcs_buf + 9, owner.c_str(), CALL_SIZE-1) == 0)) { /* is that the remote system that we asked to connect to? */ if ((fromDst4.sin_addr.s_addr == to_remote_g2[i].toDst4.sin_addr.s_addr) && - (to_remote_g2[i].toDst4.sin_port == htons(RMT_DCS_PORT)) && + (to_remote_g2[i].toDst4.sin_port == htons(rmt_dcs_port)) && (memcmp(to_remote_g2[i].to_call, dcs_buf, 7) == 0) && (to_remote_g2[i].to_mod == dcs_buf[7])) { if (!to_remote_g2[i].is_connected) { @@ -3498,10 +3418,10 @@ static void runit() i = 2; /* It is one of our valid repeaters */ - if ((i >= 0) && (memcmp(dcs_buf, OWNER, 8) == 0)) { + if ((i >= 0) && (memcmp(dcs_buf, owner.c_str(), CALL_SIZE) == 0)) { /* It is from a remote that we contacted */ if ((fromDst4.sin_addr.s_addr == to_remote_g2[i].toDst4.sin_addr.s_addr) && - (to_remote_g2[i].toDst4.sin_port == htons(RMT_DCS_PORT)) && + (to_remote_g2[i].toDst4.sin_port == htons(rmt_dcs_port)) && (to_remote_g2[i].from_mod == dcs_buf[8])) { if ((to_remote_g2[i].to_mod == dcs_buf[9]) && (memcmp(dcs_buf + 10, "ACK", 3) == 0)) { @@ -3567,7 +3487,7 @@ static void runit() (readBuffer[9] == 0x16)) ) { if (recvlen == 58) { - if (QSO_DETAILS) + if (qso_details) traceit("START from local g2: cntr=%02x %02x, streamID=%d,%d, flags=%02x:%02x:%02x, my=%.8s, sfx=%.4s, ur=%.8s, rpt1=%.8s, rpt2=%.8s, %d bytes fromIP=%s\n", readBuffer[4], readBuffer[5], readBuffer[14], readBuffer[15], @@ -3628,15 +3548,15 @@ static void runit() } if ((memcmp(readBuffer + 36, "CQCQCQ", 6) != 0) && (i >= 0)) { - if ((memcmp(readBuffer + 36, OWNER, 7) != 0) && + if ((memcmp(readBuffer + 36, owner.c_str(), CALL_SIZE-1) != 0) && (readBuffer[43] == LINK_CODE) && - (memcmp(readBuffer + 20, OWNER, 7) == 0) && + (memcmp(readBuffer + 20, owner.c_str(), CALL_SIZE-1) == 0) && (readBuffer[27] == 'G') && ((readBuffer[17] == 0x00) || (readBuffer[17] == 0x08) || (readBuffer[17] == 0x20) || (readBuffer[17] == 0x28))) { - if (ONLY_LINK_UNLINK && + if (only_link_unlink && (link_unlink_user.find(call) == link_unlink_user.end())) { traceit("link request denied, unauthorized rf user [%s]\n", call); } else { @@ -3663,17 +3583,17 @@ static void runit() } } else if ((readBuffer[43] == UNLINK_CODE) && (readBuffer[36] == ' ')) { - if (ONLY_LINK_UNLINK && + if (only_link_unlink && (link_unlink_user.find(call) == link_unlink_user.end())) { traceit("unlink request denied, unauthorized rf user [%s]\n", call); } else { if (to_remote_g2[i].to_call[0] != '\0') { - if (to_remote_g2[i].toDst4.sin_port == htons(RMT_REF_PORT)) { + if (to_remote_g2[i].toDst4.sin_port == htons(rmt_ref_port)) { /* Check to see if any other local bands are linked to that same IP */ for (j = 0; j < 3; j++) { if (j != i) { if ((to_remote_g2[j].toDst4.sin_addr.s_addr == to_remote_g2[i].toDst4.sin_addr.s_addr) && - (to_remote_g2[j].toDst4.sin_port == htons(RMT_REF_PORT))) { + (to_remote_g2[j].toDst4.sin_port == htons(rmt_ref_port))) { traceit("Info: Local %c is also linked to %s (different module) %c\n", to_remote_g2[j].from_mod, to_remote_g2[j].to_call, to_remote_g2[j].to_mod); @@ -3693,8 +3613,8 @@ static void runit() (struct sockaddr *)&(to_remote_g2[i].toDst4), sizeof(to_remote_g2[i].toDst4)); } - } else if (to_remote_g2[i].toDst4.sin_port == htons(RMT_XRF_PORT)) { - strcpy(unlink_request, OWNER); + } else if (to_remote_g2[i].toDst4.sin_port == htons(rmt_xrf_port)) { + strcpy(unlink_request, owner.c_str()); unlink_request[8] = to_remote_g2[i].from_mod; unlink_request[9] = ' '; unlink_request[10] = '\0'; @@ -3704,7 +3624,7 @@ static void runit() (struct sockaddr *)&(to_remote_g2[i].toDst4), sizeof(to_remote_g2[i].toDst4)); } else { - strcpy(cmd_2_dcs, OWNER); + strcpy(cmd_2_dcs, owner.c_str()); cmd_2_dcs[8] = to_remote_g2[i].from_mod; cmd_2_dcs[9] = ' '; cmd_2_dcs[10] = '\0'; @@ -3750,7 +3670,7 @@ static void runit() to_remote_g2[i].to_mod); audio_notify(notify_msg); } else { - sprintf(notify_msg, "%c_id.dat_%s_NOT_LINKED", readBuffer[35], OWNER); + sprintf(notify_msg, "%c_id.dat_%s_NOT_LINKED", readBuffer[35], owner.c_str()); audio_notify(notify_msg); } } else if ((readBuffer[43] == EXEC_CODE) && @@ -3759,7 +3679,7 @@ static void runit() if (readBuffer[42] != ' ') { memset(system_cmd, '\0', sizeof(system_cmd)); snprintf(system_cmd, FILENAME_MAX, "%s/exec_%c.sh %s %c &", - ANNOUNCE_DIR, + announce_dir.c_str(), readBuffer[42], call, readBuffer[35]); traceit("Executing %s\n", system_cmd); system(system_cmd); @@ -3768,18 +3688,18 @@ static void runit() (readBuffer[36] == ' ') && (admin.find(call) != admin.end())) { // only ADMIN can block dongle users if (readBuffer[43] == '1') { - MAX_DONGLES = SAVED_MAX_DONGLES; + max_dongles = saved_max_dongles; traceit("Dongle connections are now allowed\n"); } else if (readBuffer[43] == '0') { inbound_list.clear(); - MAX_DONGLES = 0; + max_dongles = 0; traceit("Dongle connections are now disallowed\n"); } } else if ((readBuffer[43] == FILE_REFRESH_GWYS_CODE) && (readBuffer[36] == ' ') && (admin.find(call) != admin.end())) { // only ADMIN can reload gwys.txt gwy_list.clear(); - load_gwys(GWYS); + load_gwys(gwys); } } @@ -3799,9 +3719,9 @@ static void runit() readBuffer2[12] = readBuffer[12]; readBuffer2[13] = readBuffer[13]; memcpy(readBuffer2 + 14, readBuffer + 14, 44); - memcpy(readBuffer2 + 20, OWNER, CALL_SIZE); + memcpy(readBuffer2 + 20, owner.c_str(), CALL_SIZE); readBuffer2[27] = readBuffer[35]; - memcpy(readBuffer2 + 28, OWNER, CALL_SIZE); + memcpy(readBuffer2 + 28, owner.c_str(), CALL_SIZE); readBuffer2[35] = 'G'; memcpy(&readBuffer2[36], "CQCQCQ ", 8); @@ -3820,7 +3740,7 @@ static void runit() if ((to_remote_g2[i].is_connected) && (memcmp(to_remote_g2[i].to_call, "XRF", 3) == 0) && /* only CQCQCQ */ - (memcmp(readBuffer + 20, OWNER, 7) == 0) && + (memcmp(readBuffer + 20, owner.c_str(), CALL_SIZE-1) == 0) && (memcmp(readBuffer + 36, "CQCQCQ", 6) == 0) && (readBuffer[27] == 'G')) { brd_from_rptr_idx = 0; @@ -3849,9 +3769,9 @@ static void runit() fromrptr_torptr_brd[12] = streamid_raw / 256U; fromrptr_torptr_brd[13] = streamid_raw % 256U; - memcpy(fromrptr_torptr_brd + 18, OWNER, 8); + memcpy(fromrptr_torptr_brd + 18, owner.c_str(), CALL_SIZE); fromrptr_torptr_brd[25] = to_remote_g2[j].from_mod; - memcpy(fromrptr_torptr_brd + 26, OWNER, 8); + memcpy(fromrptr_torptr_brd + 26, owner.c_str(), CALL_SIZE); fromrptr_torptr_brd[33] = 'G'; memcpy(fromrptr_torptr_brd + 34, "CQCQCQ ", 8); @@ -3871,14 +3791,14 @@ static void runit() } if (to_remote_g2[i].is_connected) { - if ((memcmp(readBuffer + 20, OWNER, 7) == 0) && + if ((memcmp(readBuffer + 20, owner.c_str(), 7) == 0) && (memcmp(readBuffer + 36, "CQCQCQ", 6) == 0) && (readBuffer[27] == 'G')) { to_remote_g2[i].out_streamid[0] = readBuffer[14]; to_remote_g2[i].out_streamid[1] = readBuffer[15]; - if ((to_remote_g2[i].toDst4.sin_port == htons(RMT_XRF_PORT)) || - (to_remote_g2[i].toDst4.sin_port == htons(RMT_REF_PORT))) { + if ((to_remote_g2[i].toDst4.sin_port == htons(rmt_xrf_port)) || + (to_remote_g2[i].toDst4.sin_port == htons(rmt_ref_port))) { readBuffer2[0] = (unsigned char)(58 & 0xFF); readBuffer2[1] = (unsigned char)(58 >> 8 & 0x1F); readBuffer2[1] = (unsigned char)(readBuffer2[1] | 0xFFFFFF80); @@ -3905,7 +3825,7 @@ static void runit() calcPFCS(readBuffer2 + 2,56); - if (to_remote_g2[i].toDst4.sin_port == htons(RMT_XRF_PORT)) { + if (to_remote_g2[i].toDst4.sin_port == htons(rmt_xrf_port)) { /* inform XRF about the source */ readBuffer2[13] = to_remote_g2[i].from_mod; @@ -3919,7 +3839,7 @@ static void runit() 0,(struct sockaddr *)&(to_remote_g2[i].toDst4), sizeof(struct sockaddr_in)); } - } else if (to_remote_g2[i].toDst4.sin_port == htons(RMT_DCS_PORT)) { + } else if (to_remote_g2[i].toDst4.sin_port == htons(rmt_dcs_port)) { memcpy(rptr_2_dcs[i].mycall, readBuffer + 44, 8); memcpy(rptr_2_dcs[i].sfx, readBuffer + 52, 4); rptr_2_dcs[i].dcs_rptr_seq = 0; @@ -4001,8 +3921,8 @@ static void runit() } } - if ((to_remote_g2[i].toDst4.sin_port == htons(RMT_XRF_PORT)) || - (to_remote_g2[i].toDst4.sin_port == htons(RMT_REF_PORT))) { + if ((to_remote_g2[i].toDst4.sin_port == htons(rmt_xrf_port)) || + (to_remote_g2[i].toDst4.sin_port == htons(rmt_ref_port))) { readBuffer2[0] = (unsigned char)(29 & 0xFF); readBuffer2[1] = (unsigned char)(29 >> 8 & 0x1F); readBuffer2[1] = (unsigned char)(readBuffer2[1] | 0xFFFFFF80); @@ -4022,25 +3942,25 @@ static void runit() else memcpy(readBuffer2 + 17, readBuffer + 20, 12); - if (to_remote_g2[i].toDst4.sin_port == htons(RMT_XRF_PORT)) { + if (to_remote_g2[i].toDst4.sin_port == htons(rmt_xrf_port)) { /* inform XRF about the source */ readBuffer2[13] = to_remote_g2[i].from_mod; sendto(xrf_g2_sock, (char *)readBuffer2 + 2, 27, 0,(struct sockaddr *)&(to_remote_g2[i].toDst4), sizeof(struct sockaddr_in)); - } else if (to_remote_g2[i].toDst4.sin_port == htons(RMT_REF_PORT)) + } else if (to_remote_g2[i].toDst4.sin_port == htons(rmt_ref_port)) sendto(ref_g2_sock, (char *)readBuffer2, 29, 0,(struct sockaddr *)&(to_remote_g2[i].toDst4), sizeof(struct sockaddr_in)); - } else if (to_remote_g2[i].toDst4.sin_port == htons(RMT_DCS_PORT)) { + } else if (to_remote_g2[i].toDst4.sin_port == htons(rmt_dcs_port)) { memset(dcs_buf, 0x00, 600); dcs_buf[0] = dcs_buf[1] = dcs_buf[2] = '0'; dcs_buf[3] = '1'; dcs_buf[4] = dcs_buf[5] = dcs_buf[6] = 0x00; memcpy(dcs_buf + 7, to_remote_g2[i].to_call, 8); dcs_buf[14] = to_remote_g2[i].to_mod; - memcpy(dcs_buf + 15, OWNER, 8); + memcpy(dcs_buf + 15, owner.c_str(), CALL_SIZE); dcs_buf[22] = to_remote_g2[i].from_mod; memcpy(dcs_buf + 23, "CQCQCQ ", 8); memcpy(dcs_buf + 31, rptr_2_dcs[i].mycall, 8); @@ -4078,12 +3998,12 @@ static void runit() tracing[i].last_time = time(NULL); if ((readBuffer[16] & 0x40) != 0) { - if (QSO_DETAILS) + if (qso_details) traceit("END from local g2: cntr=%02x %02x, streamID=%d,%d, %d bytes\n", readBuffer[4], readBuffer[5], readBuffer[14],readBuffer[15],recvlen); - if (RPTR_ACK) + if (bool_rptr_ack) rptr_ack(i); memset(dtmf_mycall[i], 0, sizeof(dtmf_mycall[i])); @@ -4153,7 +4073,7 @@ static void runit() void audio_notify(char *msg) { - if (!ANNOUNCE) + if (!announce) return; short int i = 0; @@ -4250,10 +4170,10 @@ static void *audio_notify_run(void *arg) } else useTEXT = false; - sleep(DELAY_BEFORE); + sleep(delay_before); memset(temp_file, '\0', sizeof(temp_file)); - snprintf(temp_file, FILENAME_MAX, "%s/%s", ANNOUNCE_DIR, notify_msg + 2); + snprintf(temp_file, FILENAME_MAX, "%s/%s", announce_dir.c_str(), notify_msg + 2); traceit("sending File:[%s], mod:[%c], RADIO_ID=[%s]\n", temp_file, mod, RADIO_ID); fp = fopen(temp_file, "rb"); @@ -4320,15 +4240,15 @@ static void *audio_notify_run(void *arg) if (rlen == 56) { dstar_buf[15] = 0x01; - memcpy(dstar_buf + 18, OWNER, CALL_SIZE); + memcpy(dstar_buf + 18, owner.c_str(), CALL_SIZE); dstar_buf[25] = mod; - memcpy(dstar_buf + 26, OWNER, CALL_SIZE); + memcpy(dstar_buf + 26, owner.c_str(), CALL_SIZE); dstar_buf[33] = 'G'; memcpy(dstar_buf + 34, "CQCQCQ ", 8); - memcpy(dstar_buf + 42, OWNER, CALL_SIZE); + memcpy(dstar_buf + 42, owner.c_str(), CALL_SIZE); dstar_buf[48] = ' '; dstar_buf[49] = ' '; @@ -4383,7 +4303,7 @@ static void *audio_notify_run(void *arg) (struct sockaddr *)&toLocalg2,sizeof(struct sockaddr_in)); } nanos.tv_sec = 0; - nanos.tv_nsec = DELAY_BETWEEN * 1000000; + nanos.tv_nsec = delay_between * 1000000; nanosleep(&nanos,0); } fclose(fp); @@ -4462,7 +4382,7 @@ int main(int argc, char **argv) print_status_file(); /* Open DB */ - if (!load_gwys(GWYS)) + if (!load_gwys(gwys)) break; /* create our server */ @@ -4486,12 +4406,12 @@ int main(int argc, char **argv) queryCommand[4] = 0; for (i = 0; i < 3; i++) { if (to_remote_g2[i].to_call[0] != '\0') { - if (to_remote_g2[i].toDst4.sin_port == htons(RMT_REF_PORT)) + if (to_remote_g2[i].toDst4.sin_port == htons(rmt_ref_port)) sendto(ref_g2_sock,(char *)queryCommand,5,0, (struct sockaddr *)&(to_remote_g2[i].toDst4), sizeof(to_remote_g2[i].toDst4)); - else if (to_remote_g2[i].toDst4.sin_port == htons(RMT_XRF_PORT)) { - strcpy(unlink_request, OWNER); + else if (to_remote_g2[i].toDst4.sin_port == htons(rmt_xrf_port)) { + strcpy(unlink_request, owner.c_str()); unlink_request[8] = to_remote_g2[i].from_mod; unlink_request[9] = ' '; unlink_request[10] = '\0'; @@ -4500,7 +4420,7 @@ int main(int argc, char **argv) (struct sockaddr *)&(to_remote_g2[i].toDst4), sizeof(to_remote_g2[i].toDst4)); } else { - strcpy(cmd_2_dcs, OWNER); + strcpy(cmd_2_dcs, owner.c_str()); cmd_2_dcs[8] = to_remote_g2[i].from_mod; cmd_2_dcs[9] = ' '; cmd_2_dcs[10] = '\0'; diff --git a/service.g2_ircddb b/service.g2_ircddb index cde8124..f19edd7 100755 --- a/service.g2_ircddb +++ b/service.g2_ircddb @@ -13,7 +13,7 @@ . /lib/lsb/init-functions IRCDDB_EXE=/usr/local/bin/g2_ircddb -IRCDDB_CFG=/usr/local/etc/g2_ircddb.cfg +IRCDDB_CFG=/usr/local/etc/g2.cfg IRCDDB_LOG=/var/log/g2_ircddb.log start() { diff --git a/service.g2_link b/service.g2_link index fb6b93e..27a938d 100755 --- a/service.g2_link +++ b/service.g2_link @@ -14,7 +14,7 @@ . /lib/lsb/init-functions G2_LINK_EXE=/usr/local/bin/g2_link -G2_LINK_CFG=/usr/local/etc/g2_link.cfg +G2_LINK_CFG=/usr/local/etc/g2.cfg G2_LINK_LOG=/var/log/g2_link.log start() { diff --git a/versions.h b/versions.h index eed55ea..e1fbecf 100644 --- a/versions.h +++ b/versions.h @@ -1,4 +1,5 @@ // version strings must be 55 characters or less! #define IRCDDB_VERSION "linux-g2_ircddb-4.1.0" +#define LINK_VERSION "4.00" #define DVAP_VERSION "linux-dvap_rptr-3.0.0" #define DVRPTR_VERSION "linux-dvrptr-2.0.0"