diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2021-09-19 15:30:26 +0200 |
---|---|---|
committer | David Ahern <dsahern@kernel.org> | 2021-09-23 20:02:37 -0600 |
commit | c63b769ad4337e6eaa96aeba0313fcaff922f72e (patch) | |
tree | bf26d1e93c4525afba8f51dd181a47d46890d8eb /lib | |
parent | 399ae00af5c5c2cbe96b1b802797ee24df9c5e45 (diff) | |
download | iproute2-c63b769ad4337e6eaa96aeba0313fcaff922f72e.tar.gz |
NETROM: Add netrom_ntop implementation.
NETROM uses AX.25 addresses so this is a simple wrapper around ax25_ntop1.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: David Ahern <dsahern@kernel.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ax25_ntop.c | 22 | ||||
-rw-r--r-- | lib/netrom_ntop.c | 23 |
2 files changed, 38 insertions, 7 deletions
diff --git a/lib/ax25_ntop.c b/lib/ax25_ntop.c index 48098581..cfd0e04b 100644 --- a/lib/ax25_ntop.c +++ b/lib/ax25_ntop.c @@ -6,13 +6,22 @@ #include "utils.h" +const char *ax25_ntop1(const ax25_address *src, char *dst, socklen_t size); + /* * AX.25 addresses are based on Amateur radio callsigns followed by an SSID - * like XXXXXX-SS where the callsign is up to 6 characters which are either - * letters or digits and the SSID is a decimal number in the range 0..15. + * like XXXXXX-SS where the callsign consists of up to 6 ASCII characters + * which are either letters or digits and the SSID is a decimal number in the + * range 0..15. * Amateur radio callsigns are assigned by a country's relevant authorities * and are 3..6 characters though a few countries have assigned callsigns * longer than that. AX.25 is not able to handle such longer callsigns. + * There are further restrictions on the format of valid callsigns by + * applicable national and international law. Linux doesn't need to care and + * will happily accept anything that consists of 6 ASCII characters in the + * range of A-Z and 0-9 for a callsign such as the default AX.25 MAC address + * LINUX-1 and the default broadcast address QST-0. + * The SSID is just a number and not encoded in ASCII digits. * * Being based on HDLC AX.25 encodes addresses by shifting them one bit left * thus zeroing bit 0, the HDLC extension bit for all but the last bit of @@ -22,14 +31,13 @@ * Linux' internal representation of AX.25 addresses in Linux is very similar * to this on the on-air or on-the-wire format. The callsign is padded to * 6 octets by adding spaces, followed by the SSID octet then all 7 octets - * are left-shifted by one byte. + * are left-shifted by one bit. * - * This for example turns "LINUX-1" where the callsign is LINUX and SSID is 1 - * into 98:92:9c:aa:b0:40:02. + * For example, for the address "LINUX-1" the callsign is LINUX and SSID is 1 + * the internal format is 98:92:9c:aa:b0:40:02. */ -static const char *ax25_ntop1(const ax25_address *src, char *dst, - socklen_t size) +const char *ax25_ntop1(const ax25_address *src, char *dst, socklen_t size) { char c, *s; int n; diff --git a/lib/netrom_ntop.c b/lib/netrom_ntop.c new file mode 100644 index 00000000..3dd6cb0b --- /dev/null +++ b/lib/netrom_ntop.c @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#include <sys/socket.h> +#include <errno.h> +#include <linux/ax25.h> + +#include "utils.h" + +const char *ax25_ntop1(const ax25_address *src, char *dst, socklen_t size); + +const char *netrom_ntop(int af, const void *addr, char *buf, socklen_t buflen) +{ + switch (af) { + case AF_NETROM: + errno = 0; + return ax25_ntop1((ax25_address *)addr, buf, buflen); + + default: + errno = EAFNOSUPPORT; + } + + return NULL; +} |