Add a helper function that returns address family based on the internal
notion of the socket protocol using protocols table.
* defs.h (get_family_by_proto): New declaration.
* socketutils.c (get_family_by_proto): New function.
SOCK_PROTO_NETLINK,
};
extern enum sock_proto get_proto_by_name(const char *);
+extern int get_family_by_proto(enum sock_proto proto);
enum iov_decode {
IOV_DECODE_ADDR,
return SOCK_PROTO_UNKNOWN;
}
+int
+get_family_by_proto(enum sock_proto proto)
+{
+ if ((size_t) proto < ARRAY_SIZE(protocols))
+ return protocols[proto].family;
+
+ return AF_UNSPEC;
+}
+
static const char *
get_sockaddr_by_inode_uncached(struct tcb *tcp, const unsigned long inode,
const enum sock_proto proto)