1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* AF_RXRPC local endpoint management
4 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
8 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
10 #include <linux/module.h>
11 #include <linux/net.h>
12 #include <linux/skbuff.h>
13 #include <linux/slab.h>
15 #include <net/af_rxrpc.h>
16 #include <generated/utsrelease.h>
17 #include "ar-internal.h"
19 static char rxrpc_version_string[65]; // "linux-" UTS_RELEASE " AF_RXRPC";
22 * Generate the VERSION packet string.
24 void rxrpc_gen_version_string(void)
26 snprintf(rxrpc_version_string, sizeof(rxrpc_version_string),
27 "linux-%.49s AF_RXRPC", UTS_RELEASE);
31 * Reply to a version request
33 void rxrpc_send_version_request(struct rxrpc_local *local,
34 struct rxrpc_host_header *hdr,
37 struct rxrpc_wire_header whdr;
38 struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
39 struct sockaddr_rxrpc srx;
47 if (rxrpc_extract_addr_from_skb(&srx, skb) < 0)
50 msg.msg_name = &srx.transport;
51 msg.msg_namelen = srx.transport_len;
52 msg.msg_control = NULL;
53 msg.msg_controllen = 0;
56 whdr.epoch = htonl(sp->hdr.epoch);
57 whdr.cid = htonl(sp->hdr.cid);
58 whdr.callNumber = htonl(sp->hdr.callNumber);
61 whdr.type = RXRPC_PACKET_TYPE_VERSION;
62 whdr.flags = RXRPC_LAST_PACKET | (~hdr->flags & RXRPC_CLIENT_INITIATED);
64 whdr.securityIndex = 0;
66 whdr.serviceId = htons(sp->hdr.serviceId);
68 iov[0].iov_base = &whdr;
69 iov[0].iov_len = sizeof(whdr);
70 iov[1].iov_base = (char *)rxrpc_version_string;
71 iov[1].iov_len = sizeof(rxrpc_version_string);
73 len = iov[0].iov_len + iov[1].iov_len;
75 ret = kernel_sendmsg(local->socket, &msg, iov, 2, len);
77 trace_rxrpc_tx_fail(local->debug_id, 0, ret,
78 rxrpc_tx_point_version_reply);
80 trace_rxrpc_tx_packet(local->debug_id, &whdr,
81 rxrpc_tx_point_version_reply);