94 lines
3.1 KiB
Diff
94 lines
3.1 KiB
Diff
|
|
From da048e91a1d81fd609cee5422c3dc7440625c3f6 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Eugene Syromyatnikov <evgsyr@gmail.com>
|
||
|
|
Date: Mon, 27 Aug 2018 06:26:56 +0200
|
||
|
|
Subject: [PATCH 069/293] sockaddr: add X.25 socket address decoding support
|
||
|
|
|
||
|
|
* sockaddr.c: Include <linux/x25.h>.
|
||
|
|
(print_sockaddr_data_x25): New function.
|
||
|
|
(sa_printers) <[AF_X25]>: New socket address handler.
|
||
|
|
* tests/net-sockaddr.c (check_x25): New function.
|
||
|
|
(main): Use it to check X.25 socket address decoding.
|
||
|
|
---
|
||
|
|
defs.h | 1 +
|
||
|
|
print_fields.h | 6 ++++++
|
||
|
|
sockaddr.c | 20 ++++++++++++++++++++
|
||
|
|
3 files changed, 27 insertions(+)
|
||
|
|
|
||
|
|
diff --git a/defs.h b/defs.h
|
||
|
|
index c4d271a..7f1e64d 100644
|
||
|
|
--- a/defs.h
|
||
|
|
+++ b/defs.h
|
||
|
|
@@ -892,6 +892,7 @@ extern bool
|
||
|
|
decode_inet_addr(struct tcb *, kernel_ulong_t addr,
|
||
|
|
unsigned int len, int family, const char *var_name);
|
||
|
|
extern void print_ax25_addr(const void /* ax25_address */ *addr);
|
||
|
|
+extern void print_x25_addr(const void /* struct x25_address */ *addr);
|
||
|
|
extern const char *get_sockaddr_by_inode(struct tcb *, int fd, unsigned long inode);
|
||
|
|
extern bool print_sockaddr_by_inode(struct tcb *, int fd, unsigned long inode);
|
||
|
|
extern void print_dirfd(struct tcb *, int);
|
||
|
|
diff --git a/print_fields.h b/print_fields.h
|
||
|
|
index c52d0ac..eccd7ae 100644
|
||
|
|
--- a/print_fields.h
|
||
|
|
+++ b/print_fields.h
|
||
|
|
@@ -189,6 +189,12 @@
|
||
|
|
print_ax25_addr(&(where_).field_); \
|
||
|
|
} while (0)
|
||
|
|
|
||
|
|
+#define PRINT_FIELD_X25_ADDR(prefix_, where_, field_) \
|
||
|
|
+ do { \
|
||
|
|
+ STRACE_PRINTF("%s%s=", (prefix_), #field_); \
|
||
|
|
+ print_x25_addr(&(where_).field_); \
|
||
|
|
+ } while (0)
|
||
|
|
+
|
||
|
|
#define PRINT_FIELD_NET_PORT(prefix_, where_, field_) \
|
||
|
|
STRACE_PRINTF("%s%s=htons(%u)", (prefix_), #field_, \
|
||
|
|
ntohs((where_).field_))
|
||
|
|
diff --git a/sockaddr.c b/sockaddr.c
|
||
|
|
index 970991b..cf60c32 100644
|
||
|
|
--- a/sockaddr.c
|
||
|
|
+++ b/sockaddr.c
|
||
|
|
@@ -43,6 +43,7 @@
|
||
|
|
#include <linux/if_packet.h>
|
||
|
|
#include <linux/if_arp.h>
|
||
|
|
#include <linux/if_ether.h>
|
||
|
|
+#include <linux/x25.h>
|
||
|
|
|
||
|
|
#ifdef HAVE_NETIPX_IPX_H
|
||
|
|
# include <netipx/ipx.h>
|
||
|
|
@@ -365,6 +366,24 @@ print_sockaddr_data_ipx(const void *const buf, const int addrlen)
|
||
|
|
PRINT_FIELD_0X("], ", *sa_ipx, sipx_type);
|
||
|
|
}
|
||
|
|
|
||
|
|
+void
|
||
|
|
+print_x25_addr(const void /* struct x25_address */ *addr_void)
|
||
|
|
+{
|
||
|
|
+ const struct x25_address *addr = addr_void;
|
||
|
|
+
|
||
|
|
+ tprints("{x25_addr=");
|
||
|
|
+ print_quoted_cstring(addr->x25_addr, sizeof(addr->x25_addr));
|
||
|
|
+ tprints("}");
|
||
|
|
+}
|
||
|
|
+
|
||
|
|
+static void
|
||
|
|
+print_sockaddr_data_x25(const void *const buf, const int addrlen)
|
||
|
|
+{
|
||
|
|
+ const struct sockaddr_x25 *const sa_x25 = buf;
|
||
|
|
+
|
||
|
|
+ PRINT_FIELD_X25_ADDR("", *sa_x25, sx25_addr);
|
||
|
|
+}
|
||
|
|
+
|
||
|
|
static void
|
||
|
|
print_sockaddr_data_nl(const void *const buf, const int addrlen)
|
||
|
|
{
|
||
|
|
@@ -587,6 +606,7 @@ static const struct {
|
||
|
|
[AF_INET] = { print_sockaddr_data_in, sizeof(struct sockaddr_in) },
|
||
|
|
[AF_AX25] = { print_sockaddr_data_ax25, sizeof(struct sockaddr_ax25) },
|
||
|
|
[AF_IPX] = { print_sockaddr_data_ipx, sizeof(struct sockaddr_ipx) },
|
||
|
|
+ [AF_X25] = { print_sockaddr_data_x25, sizeof(struct sockaddr_x25) },
|
||
|
|
[AF_INET6] = { print_sockaddr_data_in6, SIN6_MIN_LEN },
|
||
|
|
[AF_NETLINK] = { print_sockaddr_data_nl, SIZEOF_SA_FAMILY + 1 },
|
||
|
|
[AF_PACKET] = { print_sockaddr_data_ll, sizeof(struct sockaddr_ll) },
|
||
|
|
--
|
||
|
|
1.7.12.4
|
||
|
|
|