Compare commits

...

10 Commits

Author SHA1 Message Date
markqvist bb4b1917d5
Merge pull request #13 from CoelacanthusHex/fix-makefile
chore: refine Makefile with Makefile Conventions
2023-05-31 18:20:45 +02:00
Coelacanthus 54b4ae14f8
chore: refine Makefile with Makefile Conventions
Users can now do the following:
- use DESTDIR to specify another root dir
- use PREFIX to specify another install path except for /usr/local,
  e.g. /usr for the system package.
- load custom CFLAGS and LDFLAGS from environment variables
- use CC to specify the C compiler

These features are helpful to package it into Linux Distribution.

Signed-off-by: Coelacanthus <CoelacanthusHex@gmail.com>
2023-05-27 22:35:58 +08:00
Mark Qvist d9b3d2b6ae
Update README.md 2021-10-11 15:29:06 +02:00
Mark Qvist bb9ff10158 Version updated to 0.1.9 2020-09-28 11:39:28 +02:00
Mark Qvist 5129dda626 Argparse variable init. Fixes #4. 2020-09-28 11:18:02 +02:00
Mark Qvist b4a80a1e7a Cleaned install output 2020-09-28 11:11:27 +02:00
Mark Qvist 8944821ba8 Added mandb update to makefile 2020-09-28 11:07:10 +02:00
Mark Qvist ef700b3244
Merge pull request #5 from yalla/master
Created manualpage for tncattach
2020-09-28 10:17:17 +02:00
Alexander W. Janssen 015f8a73fb now makefile for real. 2020-09-12 14:34:03 +02:00
Alexander W. Janssen 5bdc5d5ccc created manualpage and adapted makefile for installing manpage 2020-09-12 14:31:42 +02:00
4 changed files with 192 additions and 10 deletions

View File

@ -133,4 +133,11 @@ On some versions of Raspbian (and probably other operating systems), the DHCP cl
# of /etc/dhcpcd.conf to prevent dhcpcd from changing MTU
denyinterfaces tnc0
```
```
## Support tncattach development
You can help support the continued development of open, free and private communications systems by donating via one of the following channels:
- Ethereum: 0x81F7B979fEa6134bA9FD5c701b3501A2e61E897a
- Bitcoin: 3CPmacGm34qYvR6XWLVEJmi2aNe3PZqUuq
- Ko-Fi: https://ko-fi.com/markqvist

View File

@ -1,26 +1,35 @@
.DEFAULT_GOAL := all
.PHONY: all clean install uninstall tncattach
compiler = gcc
flags = -Wall -std=gnu11 -static-libgcc
RM ?= rm
INSTALL ?= install
CC ?= gcc
CFLAGS ?= -Wall -std=gnu11 -static-libgcc
LDFLAGS ?=
PREFIX ?= /usr/local
all: tncattach
rebuild: clean all
clean:
@echo "Cleaning tncattach build..."
@rm -f tncattach
$(RM) -f tncattach
tncattach:
@echo "Making tncattach..."
@echo "Compiling with: ${compiler}"
${compiler} ${flags} tncattach.c Serial.c TCP.c KISS.c TAP.c -o tncattach -Wall
@echo "Compiling with: $(CC)"
$(CC) $(CFLAGS) $(LDFLAGS) tncattach.c Serial.c TCP.c KISS.c TAP.c -o tncattach
install:
@echo "Installing tncattach..."
chmod a+x tncattach
cp ./tncattach /usr/local/sbin/
$(INSTALL) -d $(DESTDIR)/$(PREFIX)/bin
$(INSTALL) -Dm755 tncattach $(DESTDIR)/$(PREFIX)/bin/tncattach
@echo "Installing man page..."
gzip -9 tncattach.8
$(INSTALL) -d $(DESTDIR)/$(PREFIX)/share/man/man8
$(INSTALL) -Dm644 tncattach.8.gz $(DESTDIR)/$(PREFIX)/share/man/man8/tncattach.8.gz
uninstall:
@echo "Uninstalling tncattach"
rm /usr/local/sbin/tncattach
$(RM) $(DESTDIR)/$(PREFIX)/bin/tncattach
$(RM) $(DESTDIR)/$(PREFIX)/share/man/man8/tncattach.8.gz

165
tncattach.8 Normal file
View File

@ -0,0 +1,165 @@
.TH tncattach 8 "September 12, 2020"
.SH NAME
.
.
tncattach \- Attach TNC devices as system network interfaces
.SH SYNOPSIS
.
.
\f[B]tncattach\f[R] [OPTION...] port baudrate
.SH DESCRIPTION
Attach KISS TNC devices as network interfaces in Linux. This program allows you to attach TNCs or any KISS-compatible device as a network interface. This program does not need any kernel modules, and has no external dependencies outside the standard Linux and GNU C libraries.
.SH OPTIONS
.
.
.TP
.BI \-m, \-\-mtu=MTU
.
Specify interface MTU
.
.
.TP
.BI \-e, \-\-ethernet
Create a full ethernet device
.
.
.TP
.BI \-i, \-\-ipv4=IP_ADDRESS
Configure an IPv4 address on interface
.
.
.TP
.BI \-n, \-\-noipv6
Filter IPv6 traffic from reaching TNC
.
.
.TP
.BI \-\-noup
Only create interface, don't bring it up
.
.
.TP
.BI \-T, \-\-kisstcp
Use KISS over TCP instead of serial port
.
.
.TP
.BI \-H, \-\-tcphost=TCP_HOST
Host to connect to when using KISS over TCP
.
.
.TP
.BI \-P, \-\-tcpport=TCP_PORT
TCP port when using KISS over TCP
.
.
.TP
.BI \-t, \-\-interval=SECONDS
Maximum interval between station identifications
.
.
.TP
.B \-s, \-\-id=CALLSIGN
Station identification data
.
.
.TP
.BI \-d, \-\-daemon
Run tncattach as a daemon
.
.
.TP
.BI \-v, \-\-verbose
Enable verbose output
.
.
.TP
.BI \-?, \-\-help
Show help
.
.
.TP
.BI \-\-usage
Give a short usage message
.
.
.TP
.BI \-V, \-\-version
Print program version
.
.
.SH USAGE
The program supports attaching TNCs as point-to-point tunnel devices, or generic ethernet devices. The ethernet mode is suitable for point-to-multipoint setups, and can be enabled with the corresponding command line switch. If you only need point-to-point links, it is advisable to just use the standard point-to-point mode, since it doesn't incur the ethernet header overhead on each packet.
.P
If you want to connect to a virtual KISS TNC over a TCP connection, you can use the -T option, along with the -H and -P options to specify the host and port.
.P
Additionally, it is worth noting that tncattach can filter out IPv6 packets from reaching the TNC. Most operating systems attempts to autoconfigure IPv6 when an interface is brought up, which results in a substantial amount of IPv6 traffic generated by router solicitations and similar, which is usually unwanted for packet radio links and similar.
.P
If you intend to use tncattach on a system with mDNS services enabled (avahi-daemon, for example), you may want to consider modifying your mDNS setup to exclude TNC interfaces, or turning it off entirely, since it will generate a lot of traffic that might be unwanted.
.SH STATION IDENTIFICATION
You can configure tncattach to automatically transmit station identification beacons according to a given interval, by using the --id and --interval options. Identification will be transmitted as raw data frames with whatever content has been specified in the --id option. Useful for amateur radio use, or other areas where station identification is necessary.
.P
Identification beacons will be transmitted when:
.P
.IP
There is outgoing data to send, and the specified interval has elapsed.
.IP
The specified interval elapses, and data has been sent since the last ID beacon.
.IP
The program exits, if any data frames have been transmitted since the last ID beacon.
.P
The above methodology should comply with station identification rules for amateur radio in most parts of the world, and complies with US Part 97 rules.
.SH EXAMPLES
.
Create an ethernet device with a USB-connected TNC, set the MTU, filter IPv6 traffic, and set an IPv4 address:
.IP
sudo tncattach /dev/ttyUSB0 115200 --ethernet --mtu 576 --noipv6 --ipv4 10.92.0.10/24
.P
Create an ethernet device with a TCP-connected TNC, set the MTU, filter IPv6 traffic, and set an IPv4 address:
.IP
sudo tncattach -T -H localhost -P 8001 --ethernet --mtu 576 --noipv6 --ipv4 10.92.0.10/24
.P
You can interact with the interface like any other using the ip or ifconfig utilities.
.p
Check interface is running:
.P
# ifconfig
.br
tnc0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 400
.br
inet 10.93.0.1 netmask 255.255.255.255 destination 10.93.0.2
.br
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 500 (UNSPEC)
.br
RX packets 0 bytes 0 (0.0 B)
.br
RX errors 0 dropped 0 overruns 0 frame 0
.br
TX packets 0 bytes 0 (0.0 B)
.br
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
.P
.SH WORTH KNOWING ON RASPBIAN
On some versions of Raspbian (and probably other operating systems), the DHCP client daemon dhcpcd interferes with TNC interfaces, by overriding their MTU and trying to auto-configure link-local addresses. You probably don't want this, and it can be disabled by editing the /etc/dhcpcd.conf file, adding a statement telling dhcpcd to ignore your TNC interface:
.P
# Add the following statement somewhere at the beginning
.br
# of /etc/dhcpcd.conf to prevent dhcpcd from changing MTU
.br
denyinterfaces tnc0
.SH SEE ALSO
rnodeconfigutil(8)
.SH AUTHOR
Mark Qvist

View File

@ -261,7 +261,7 @@ void read_loop(void) {
exit(1);
}
const char *argp_program_version = "tncattach 0.1.8";
const char *argp_program_version = "tncattach 0.1.9";
const char *argp_program_bug_address = "<mark@unsigned.io>";
static char doc[] = "\r\nAttach TNC devices as system network interfaces\vTo attach the TNC connected to /dev/ttyUSB0 as an ethernet device with an MTU of 512 bytes and assign an IPv4 address, while filtering IPv6 traffic, use:\r\n\r\n\ttncattach /dev/ttyUSB0 115200 -m 512 -e --noipv6 --ipv4 10.0.0.1/24\r\n\r\nStation identification can be performed automatically to comply with Part 97 rules. See the README for a complete description. Use the --id and --interval options, which should commonly be set to your callsign, and 600 seconds.";
static char args_doc[] = "port baudrate";
@ -564,6 +564,7 @@ int main(int argc, char **argv) {
arguments.noup = false;
arguments.id_interval = -1;
arguments.valid_id = false;
arguments.kiss_over_tcp = false;
argp_parse(&argp, argc, argv, 0, 0, &arguments);