289 lines
4.9 KiB
HTML
289 lines
4.9 KiB
HTML
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
>AX.25, NET/ROM, ROSE network programming</TITLE
|
|
><META
|
|
NAME="GENERATOR"
|
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.63
|
|
"><LINK
|
|
REL="HOME"
|
|
TITLE="Linux Amateur Radio AX.25 HOWTO"
|
|
HREF="index.html"><LINK
|
|
REL="PREVIOUS"
|
|
TITLE="The /proc/ file system entries"
|
|
HREF="x2051.html"><LINK
|
|
REL="NEXT"
|
|
TITLE="Some sample configurations"
|
|
HREF="x2141.html"></HEAD
|
|
><BODY
|
|
CLASS="SECT1"
|
|
BGCOLOR="#FFFFFF"
|
|
TEXT="#000000"
|
|
LINK="#0000FF"
|
|
VLINK="#840084"
|
|
ALINK="#0000FF"
|
|
><DIV
|
|
CLASS="NAVHEADER"
|
|
><TABLE
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TH
|
|
COLSPAN="3"
|
|
ALIGN="center"
|
|
>Linux Amateur Radio AX.25 HOWTO</TH
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="left"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="x2051.html"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="80%"
|
|
ALIGN="center"
|
|
VALIGN="bottom"
|
|
></TD
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="right"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="x2141.html"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"></DIV
|
|
><DIV
|
|
CLASS="SECT1"
|
|
><H1
|
|
CLASS="SECT1"
|
|
><A
|
|
NAME="AEN2107"
|
|
>21. AX.25, NET/ROM, ROSE network programming</A
|
|
></H1
|
|
><P
|
|
>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.</P
|
|
><P
|
|
>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, NET/ROM and ROSE protocols within your software.</P
|
|
><DIV
|
|
CLASS="SECT2"
|
|
><H2
|
|
CLASS="SECT2"
|
|
><A
|
|
NAME="AEN2111"
|
|
>21.1. The address families</A
|
|
></H2
|
|
><P
|
|
>Network programming for AX.25, NET/ROM 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.</P
|
|
><P
|
|
>The address family names for AX.25, NET/ROM and ROSE are <TT
|
|
CLASS="LITERAL"
|
|
>AF_AX25</TT
|
|
>,
|
|
<TT
|
|
CLASS="LITERAL"
|
|
>AF_NETROM</TT
|
|
> and <TT
|
|
CLASS="LITERAL"
|
|
>AF_ROSE</TT
|
|
> respectively.</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="SECT2"
|
|
><H2
|
|
CLASS="SECT2"
|
|
><A
|
|
NAME="AEN2118"
|
|
>21.2. The header files</A
|
|
></H2
|
|
><P
|
|
>You must always include the `<TT
|
|
CLASS="LITERAL"
|
|
>netax25/ax25.h</TT
|
|
>' header
|
|
file, and also the `<TT
|
|
CLASS="LITERAL"
|
|
>netrom/netrom.h</TT
|
|
>' or
|
|
`<TT
|
|
CLASS="LITERAL"
|
|
>netrose/rose.h</TT
|
|
>' header files if you are dealing
|
|
with those protocols. Simple top level skeletons would look something
|
|
like the following:</P
|
|
><P
|
|
>For AX.25:</P
|
|
><P
|
|
><TABLE
|
|
BORDER="1"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="SCREEN"
|
|
>#include <netax25/ax25.h>
|
|
int s, addrlen = sizeof(struct full_sockaddr_ax25);
|
|
struct full_sockaddr_ax25 sockaddr;
|
|
sockaddr.fsa_ax25.sax25_family = AF_AX25</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></P
|
|
><P
|
|
>For NET/ROM:</P
|
|
><P
|
|
><TABLE
|
|
BORDER="1"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="SCREEN"
|
|
>#include <netax25/ax25.h>
|
|
#include <netrom/netrom.h>
|
|
int s, addrlen = sizeof(struct full_sockaddr_ax25);
|
|
struct full_sockaddr_ax25 sockaddr;
|
|
sockaddr.fsa_ax25.sax25_family = AF_NETROM;</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></P
|
|
><P
|
|
>For ROSE:</P
|
|
><P
|
|
><TABLE
|
|
BORDER="1"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="SCREEN"
|
|
>#include <netax25/ax25.h>
|
|
#include <netrose/rose.h>
|
|
int s, addrlen = sizeof(struct sockaddr_rose);
|
|
struct sockaddr_rose sockaddr;
|
|
sockaddr.srose_family = AF_ROSE;</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></P
|
|
></DIV
|
|
><DIV
|
|
CLASS="SECT2"
|
|
><H2
|
|
CLASS="SECT2"
|
|
><A
|
|
NAME="AEN2133"
|
|
>21.3. Callsign mangling and examples</A
|
|
></H2
|
|
><P
|
|
>There are routines within the <TT
|
|
CLASS="LITERAL"
|
|
>lib/ax25.a</TT
|
|
> library built in the
|
|
AX.25 utilities package that manage the callsign conversions for you. You can
|
|
write your own of course if you wish.</P
|
|
><P
|
|
>The <EM
|
|
>user_call</EM
|
|
> utilities are excellent examples from which to
|
|
work. The source code for them is included in the AX.25 utilities package.
|
|
If you spend a little time working with those you will soon see that
|
|
ninety percent of the work is involved in just getting ready to open the
|
|
socket. Actually making the connection is easy, the preparation takes time.</P
|
|
><P
|
|
>The examples are simple enough to not be very confusing. If you have any
|
|
questions, you should feel to direct them to the <TT
|
|
CLASS="LITERAL"
|
|
>linux-hams</TT
|
|
> mailing
|
|
list and someone there will be sure to help you.</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="NAVFOOTER"
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"><TABLE
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="x2051.html"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="index.html"
|
|
>Home</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="x2141.html"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
>The <TT
|
|
CLASS="LITERAL"
|
|
>/proc/</TT
|
|
> file system entries</TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
> </TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
>Some sample configurations</TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |