1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Copyright (C) 2015 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
9 #include <linux/ipv6.h>
10 #include <linux/udp.h>
11 #include "ar-internal.h"
14 * Fill out a peer address from a socket buffer containing a packet.
16 int rxrpc_extract_addr_from_skb(struct sockaddr_rxrpc
*srx
, struct sk_buff
*skb
)
18 memset(srx
, 0, sizeof(*srx
));
20 switch (ntohs(skb
->protocol
)) {
22 srx
->transport_type
= SOCK_DGRAM
;
23 srx
->transport_len
= sizeof(srx
->transport
.sin
);
24 srx
->transport
.sin
.sin_family
= AF_INET
;
25 srx
->transport
.sin
.sin_port
= udp_hdr(skb
)->source
;
26 srx
->transport
.sin
.sin_addr
.s_addr
= ip_hdr(skb
)->saddr
;
29 #ifdef CONFIG_AF_RXRPC_IPV6
31 srx
->transport_type
= SOCK_DGRAM
;
32 srx
->transport_len
= sizeof(srx
->transport
.sin6
);
33 srx
->transport
.sin6
.sin6_family
= AF_INET6
;
34 srx
->transport
.sin6
.sin6_port
= udp_hdr(skb
)->source
;
35 srx
->transport
.sin6
.sin6_addr
= ipv6_hdr(skb
)->saddr
;
40 pr_warn_ratelimited("AF_RXRPC: Unknown eth protocol %u\n",
41 ntohs(skb
->protocol
));