net: add support for AX.25 protocols and socket option names decoding

* xlat/ax25_protocols.in: New file.
* xlat/sock_ax25_options.in: Likewise.
* net.c: Include "xlat/ax25_protocols.h" and "xlat/sock_ax25_options.h".
* (SYS_FUNC(socket)): <[AF_AX25]>: Print protocol name using
ax25_protocols xlat.
(print_sockopt_fd_level_name) <[SOL_AX25]>: Print socket option name
using sock_ax25_options xlat.
This commit is contained in:
Eugene Syromyatnikov 2018-08-27 06:22:52 +02:00 committed by Dmitry V. Levin
parent 92d020787f
commit cfb86ab4e9
3 changed files with 43 additions and 0 deletions

11
net.c
View File

@ -88,6 +88,7 @@
# include "xlat/addrfams.h"
# include "xlat/ethernet_protocols.h"
#undef XLAT_MACROS_ONLY
#include "xlat/ax25_protocols.h"
#include "xlat/irda_protocols.h"
#include "xlat/can_protocols.h"
#include "xlat/bt_protocols.h"
@ -145,6 +146,12 @@ SYS_FUNC(socket)
printxval_search(inet_protocols, tcp->u_arg[2], "IPPROTO_???");
break;
case AF_AX25:
/* Those are not available in public headers. */
printxval_searchn_ex(ARRSZ_PAIR(ax25_protocols), tcp->u_arg[2],
"AX25_P_???", XLAT_STYLE_VERBOSE);
break;
case AF_NETLINK:
printxval(netlink_protocols, tcp->u_arg[2], "NETLINK_???");
break;
@ -445,6 +452,7 @@ SYS_FUNC(socketpair)
#include "xlat/getsock_ipv6_options.h"
#include "xlat/setsock_ipv6_options.h"
#include "xlat/sock_ipx_options.h"
#include "xlat/sock_ax25_options.h"
#include "xlat/sock_netlink_options.h"
#include "xlat/sock_packet_options.h"
#include "xlat/sock_raw_options.h"
@ -496,6 +504,9 @@ print_sockopt_fd_level_name(struct tcb *tcp, int fd, unsigned int level,
case SOL_IPX:
printxval(sock_ipx_options, name, "IPX_???");
break;
case SOL_AX25:
printxval_search(sock_ax25_options, name, "AX25_???");
break;
case SOL_PACKET:
printxval(sock_packet_options, name, "PACKET_???");
break;

17
xlat/ax25_protocols.in Normal file
View File

@ -0,0 +1,17 @@
/* sorted */
/* Those are pulled from include/net/ax25.h, they should be part of UAPI */
AX25_P_ROSE 0x01
AX25_P_VJCOMP 0x06 /* Compressed TCP/IP packet */
/* Van Jacobsen (RFC 1144) */
AX25_P_VJUNCOMP 0x07 /* Uncompressed TCP/IP packet */
/* Van Jacobsen (RFC 1144) */
AX25_P_SEGMENT 0x08 /* Segmentation fragment */
AX25_P_TEXNET 0xc3 /* TEXTNET datagram protocol */
AX25_P_LQ 0xc4 /* Link Quality Protocol */
AX25_P_ATALK 0xca /* Appletalk */
AX25_P_ATALK_ARP 0xcb /* Appletalk ARP */
AX25_P_IP 0xcc /* ARPA Internet Protocol */
AX25_P_ARP 0xcd /* ARPA Address Resolution */
AX25_P_FLEXNET 0xce /* FlexNet */
AX25_P_NETROM 0xcf /* NET/ROM */
AX25_P_TEXT 0xf0 /* No layer 3 protocol impl. */

15
xlat/sock_ax25_options.in Normal file
View File

@ -0,0 +1,15 @@
/* sorted */
AX25_WINDOW 1
AX25_T1 2
AX25_N2 3
AX25_T3 4
AX25_T2 5
AX25_BACKOFF 6
AX25_EXTSEQ 7
AX25_PIDINCL 8
AX25_IDLE 9
AX25_PACLEN 10
AX25_IAMDIGI 12
/* 13, 25, or 16409, depending on arch */
SO_BINDTODEVICE