Article View: comp.os.linux.answers
Article #73Linux AX25 HOWTO (part 3/3)
From: Terry Dawson
Date: Sun, 06 Jul 1997 00:00
Date: Sun, 06 Jul 1997 00:00
364 lines
15192 bytes
15192 bytes
Archive-name: linux/howto/AX25-HOWTO/part3
Last-modified: 30 Jun 97
-----BEGIN PGP SIGNED MESSAGE-----
*** The `Linux AX25 HOWTO' is posted automatically by the
*** Linux HOWTO coordinator, Greg Hankins <gregh@sunsite.unc.edu>. Please
*** direct any comments or questions about this HOWTO to the author,
*** Terry Dawson <terry@perf.no.itg.telecom.com.au>.
- --- BEGIN Linux AX25 HOWTO part 3/3 ---
� The router machine is a lowly 386DX20 with a 20Mb harddrive and a
very minimal linux configuration.
22.2. IPIP encapsulated gateway configuration.
Linux is now very commonly used for TCP/IP encapsulated gateways
around the world. The new tunnel driver supports multiple encapsulated
routes and makes the older ipip daemon obsolete.
A typical configuration would look similar to the following.
. . . . . .
--- .
| Network /---------\ . Network
| 154.27.3/24 | | . 44.136.16/24 \ | /
| | Linux | . \|/
| | | . |
| eth0 | IPIP | . /-----\ /----------\ |
---|---------------| |-----| TNC |----| Radio |---/
| 154.27.3.20 | Gateway | . \-----/ \----------/
| | | sl0
| | | 44.136.16.1
| | | .
| | | .
| \_________/ .
--- . . . . . .
The configuration files of interest are:
# /etc/rc.net
# This file is a simple configuration that provides one KISS AX.25
# radio port, one Ethernet device, and utilises the kernel tunnel driver
# to perform the IPIP encapsulation/decapsulation
#
echo "/etc/rc.net"
echo " Configuring:"
#
echo -n " loopback:"
/sbin/ifconfig lo 127.0.0.1
/sbin/route add 127.0.0.1
echo " done."
#
echo -n " ethernet:"
/sbin/ifconfig eth0 154.27.3.20 netmask 255.255.255.0 \
broadcast 154.27.3.255 up
/sbin/route add 154.27.3.20 eth0
/sbin/route add -net 154.27.3.0 netmask 255.255.255.0 eth0
echo " done."
#
echo -n " AX.25: "
kissattach -i 44.136.16.1 -m 512 /dev/ttyS1 4800
/sbin/ifconfig sl0 netmask 255.255.255.0 broadcast 44.136.16.255
/sbin/route add -host 44.136.16.1 sl0
/sbin/route add -net 44.136.16.0 netmask 255.255.255.0 window 1024 sl0
#
echo -n " tunnel:"
/sbin/ifconfig tunl0 44.136.16.1 mtu 512 up
#
echo done.
#
echo -n "Routing ... "
source /etc/ipip.routes
echo done.
#
# end.
and:
# /etc/ipip.routes
# This file is generated using the munge script
#
/sbin/route add -net 44.134.8.0 netmask 255.255.255.0 tunl0 gw 134.43.26.1
/sbin/route add -net 44.34.9.0 netmask 255.255.255.0 tunl0 gw 174.84.6.17
/sbin/route add -net 44.13.28.0 netmask 255.255.255.0 tunl0 gw 212.37.126.3
...
...
...
/etc/ax25/axports
# name callsign speed paclen window description
4800 VK2KTJ-0 4800 256 2 144.800 MHz
Some points to note here are:
� The new tunnel driver uses the gw field in the routing table in
place of the pointopoint parameter to specify the address of the
remote IPIP gateway. This is why it now supports multiple routes
per interface.
� You can configure two network devices with the same address. In
this example both the sl0 and the tunl0 devices have been
configured with the IP address of the radio port. This is done so
that the remote gateway sees the correct address from your gateway
in encapsulated datagrams sent to it.
� The route commands used to specify the encapsulated routes can be
automatically generated by a modified version of the munge script.
This is included below. The route commands would then be written to
a separate file and read in using the bash source /etc/ipip.routes
command (assuming you called the file with the routing commands
/etc/ipip.routes) as illustrated. The source file must be in the
NOS route command format.
� Note the use of the window argument on the route command. Setting
this parameter to an appropriate value improves the performance of
your radio link.
The new tunnel-munge script:
#!/bin/sh
#
# From: Ron Atkinson <n8fow@hamgate.cc.wayne.edu>
#
# This script is basically the 'munge' script written by Bdale N3EUA
# for the IPIP daemon and is modified by Ron Atkinson N8FOW. It's
# purpose is to convert a KA9Q NOS format gateways route file
# (usually called 'encap.txt') into a Linux routing table format
# for the IP tunnel driver.
#
# Usage: Gateway file on stdin, Linux route format file on stdout.
# eg. tunnel-munge < encap.txt > ampr-routes
#
# NOTE: Before you use this script be sure to check or change the
# following items:
#
# 1) Change the 'Local routes' and 'Misc user routes' sections
# to routes that apply to your own area (remove mine please!)
# 2) On the fgrep line be sure to change the IP address to YOUR
# gateway Internet address. Failure to do so will cause serious
# routing loops.
# 3) The default interface name is 'tunl0'. Make sure this is
# correct for your system.
echo "#"
echo "# IP tunnel route table built by $LOGNAME on `date`"
echo "# by tunnel-munge script v960307."
echo "#"
echo "# Local routes"
echo "route add -net 44.xxx.xxx.xxx netmask 255.mmm.mmm.mmm dev sl0"
echo "#"
echo "# Misc user routes"
echo "#"
echo "# remote routes"
fgrep encap | grep "^route" | grep -v " XXX.XXX.XXX.XXX" | \
awk '{
split($3, s, "/")
split(s[1], n,".")
if (n[1] == "") n[1]="0"
if (n[2] == "") n[2]="0"
if (n[3] == "") n[3]="0"
if (n[4] == "") n[4]="0"
if (s[2] == "1") mask="128.0.0.0"
else if (s[2] == "2") mask="192.0.0.0"
else if (s[2] == "3") mask="224.0.0.0"
else if (s[2] == "4") mask="240.0.0.0"
else if (s[2] == "5") mask="248.0.0.0"
else if (s[2] == "6") mask="252.0.0.0"
else if (s[2] == "7") mask="254.0.0.0"
else if (s[2] == "8") mask="255.0.0.0"
else if (s[2] == "9") mask="255.128.0.0"
else if (s[2] == "10") mask="255.192.0.0"
else if (s[2] == "11") mask="255.224.0.0"
else if (s[2] == "12") mask="255.240.0.0"
else if (s[2] == "13") mask="255.248.0.0"
else if (s[2] == "14") mask="255.252.0.0"
else if (s[2] == "15") mask="255.254.0.0"
else if (s[2] == "16") mask="255.255.0.0"
else if (s[2] == "17") mask="255.255.128.0"
else if (s[2] == "18") mask="255.255.192.0"
else if (s[2] == "19") mask="255.255.224.0"
else if (s[2] == "20") mask="255.255.240.0"
else if (s[2] == "21") mask="255.255.248.0"
else if (s[2] == "22") mask="255.255.252.0"
else if (s[2] == "23") mask="255.255.254.0"
else if (s[2] == "24") mask="255.255.255.0"
else if (s[2] == "25") mask="255.255.255.128"
else if (s[2] == "26") mask="255.255.255.192"
else if (s[2] == "27") mask="255.255.255.224"
else if (s[2] == "28") mask="255.255.255.240"
else if (s[2] == "29") mask="255.255.255.248"
else if (s[2] == "30") mask="255.255.255.252"
else if (s[2] == "31") mask="255.255.255.254"
else mask="255.255.255.255"
if (mask == "255.255.255.255")
printf "route add -host %s.%s.%s.%s gw %s dev tunl0\n"\
,n[1],n[2],n[3],n[4],$5
else
printf "route add -net %s.%s.%s.%s gw %s netmask %s dev tunl0\n"\
,n[1],n[2],n[3],n[4],$5,mask
}'
echo "#"
echo "# default the rest of amprnet via mirrorshades.ucsd.edu"
echo "route add -net 44.0.0.0 gw 128.54.16.18 netmask 255.0.0.0 dev tunl0"
echo "#"
echo "# the end"
23. AX.25, NetRom, Rose network programming.
Probably the biggest advantage of using the kernel based
implementations of the amateur packet radio protocols is the ease with
which you can develop applications and programs to use them.
While the subject of Unix Network Programming is outside the scope of
this document I will describe the elementary details of how you can
make use of the AX.25, NetRom and Rose protocols within your software.
23.1. The address families.
Network programming for AX.25, NetRom and Rose is quite similar to
programming for TCP/IP under Linux. The major differences being the
address families used, and the address structures that need to be
mangled into place.
The address family names for AX.25, NetRom and Rose are AF_AX25,
AF_NETROM and AF_ROSE respectively.
23.2. The header files.
You must always include the `ax25.h' header file, and also the
`netrom.h' or `rose.h' header files if you are dealing with those
protocols. Simple top level skeletons would look something like the
following:
For AX.25:
#include <ax25.h>
int s, addrlen = sizeof(struct full_sockaddr_ax25);
struct full_sockaddr_ax25 sockaddr;
sockaddr.fsa_ax25.sax25_family = AF_AX25
For NetRom:
#include <ax25.h>
#include <netrom.h>
int s, addrlen = sizeof(struct full_sockaddr_ax25);
struct full_sockaddr_ax25 sockaddr;
sockaddr.fsa_ax25.sax25_family = AF_NETROM;
For Rose:
#include <ax25.h>
#include <rose.h>
int s, addrlen = sizeof(struct sockaddr_rose);
struct sockaddr_rose sockaddr;
sockaddr.srose_family = AF_ROSE;
23.3. Callsign mangling and examples.
There are routines within the lib/ax25.a library built in the AX25
utilities package that manage the callsign conversions for you. You
can write your own of course if you wish.
The user_call utilities are excellent examples from which to work. The
source code for them is included in the AX25 utilities package. If
you spend a little time working with those you will soon see that 90
percent of the work is involved in just getting ready to open the
socket. Actually making the connection is easy, the preparation takes
time.
The example are simple enough to not be very confusing. If you have
any questions, you should feel to direct them to the linux-hams
mailing list and someone there will be sure to help you.
24. Discussion relating to Amateur Radio and Linux.
There are various places that discussion relating to Amateur Radio and
Linux take place. They take place in the comp.os.linux.* newsgroups,
they also take place on the HAMS list on vger.rutgers.edu. Other
places where they are held include the tcp-group mailing list at
ucsd.edu (the home of amateur radio TCP/IP discussions), and you might
also try the #linpeople channel on the linuxnet irc network.
To join the Linux linux-hams channel on the mail list server, send
mail to:
Majordomo@vger.rutgers.edu
with the line:
subscribe linux-hams
in the message body. The subject line is ignored.
The linux-hams mailing list is archived at:
zone.pspt.fi <http://zone.pspt.fi/archive/linux-hams/> and
zone.oh7rba.ampr.org <http://zone.oh7rba.ampr.org/archive/linux-
hams/>. Please use the archives when you are first starting, because
many common questions are answered there.
To join the tcp-group send mail to:
listserver@ucsd.edu
with the line:
subscribe tcp-group
in the body of the text.
Note: Please remember that the tcp-group is primarily for discussion
of the use of advanced protocols, of which TCP/IP is one, in Amateur
Radio. Linux specific questions should not ordinarily go there.
25. Acknowledgements.
The following people have contributed to this document in one way or
another, knowingly or unknowingly. In no particular order (as I find
them): Jonathon Naylor, Thomas Sailer, Joerg Reuter, Ron Atkinson,
Alan Cox, Craig Small, John Tanner, Brandon Allbery, Hans Alblas,
Klaus Kudielka, Carl Makin.
26. Copyright.
The AX25-HOWTO, information on how to install and configure some of
the more important packages providing AX25 support for Linux.
Copyright (c) 1996 Terry Dawson.
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.
- --- END Linux AX25 HOWTO part 3/3 ---
-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
Comment: finger gregh@cc.gatech.edu for public key
iQCVAwUBM8BojHtNTo2suu5NAQF8KwP+IdxWqIyTbB2hBwAWM7O8QgRHO+nfkJdb
c5w2iU80nVjhE9Sj64zO6PmSMFtC2gXvlfUaciF9G7GuO50bAbCtmkV+lc50uBBm
03iSSzcXiZqBaj7bYUVHlLXfmp6ceoe3WEbPJ7uxhGRcTNnsTCVYW3/IlmZZTI0v
4TEagriC4EI=
=o8BA
-----END PGP SIGNATURE-----
Technical Details
Message-ID:
<AX25-HOWTO.3-259.868247684@cc.gatech.edu>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<AX25-HOWTO.2-259.868247684@cc.gatech.edu>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 1038bf,e01959db50e1caac,start X-Google-Attributes: gid1038bf,public X-Google-Thread: 107ada,e01959db50e1caac,start X-Google-Attributes: gid107ada,public X-Google-Thread: f68a8,e01959db50e1caac,start X-Google-Attributes: gidf68a8,public From: Terry Dawson <terry@perf.no.itg.telecom.com.au> Subject: Linux AX25 HOWTO (part 3/3) Date: 1997/07/06 Message-ID: <AX25-HOWTO.3-259.868247684@cc.gatech.edu> X-Deja-AN: 255149173 Sender: gregh@cc.gatech.edu References: <AX25-HOWTO.2-259.868247684@cc.gatech.edu> Followup-To: poster Summary: How to configure AX25 networking for Linux Organization: Linux HOWTO Project X-Auth: PGPMoose V1.1 PGP comp.os.linux.answers iQBVAwUBM8BoqjpXzySNgdcNAQFxNAH+Kc0fQbgO/GSeGkzDoLe8avIR2PtpLJHA 6DJd/CtmOTaOgehav4m+Bmc8kU8gqIIxpspO7LsAEajCW2XX8IqmMA== =xTwb Keywords: Linux, Networking, Ham, amateur radio, AX25 Newsgroups: comp.os.linux.answers,rec.radio.amateur.misc,aus.radio.amateur.digital NNTP-Posting-User: gregh