~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/rxrpc/local_event.c

Version: ~ [ linux-5.6 ] ~ [ linux-5.5.13 ] ~ [ linux-5.4.28 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.113 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.174 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.217 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.217 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.82 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* AF_RXRPC local endpoint management
  2  *
  3  * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4  * Written by David Howells (dhowells@redhat.com)
  5  *
  6  * This program is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU General Public License
  8  * as published by the Free Software Foundation; either version
  9  * 2 of the License, or (at your option) any later version.
 10  */
 11 
 12 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 13 
 14 #include <linux/module.h>
 15 #include <linux/net.h>
 16 #include <linux/skbuff.h>
 17 #include <linux/slab.h>
 18 #include <net/sock.h>
 19 #include <net/af_rxrpc.h>
 20 #include <generated/utsrelease.h>
 21 #include "ar-internal.h"
 22 
 23 static const char rxrpc_version_string[65] = "linux-" UTS_RELEASE " AF_RXRPC";
 24 
 25 /*
 26  * Reply to a version request
 27  */
 28 static void rxrpc_send_version_request(struct rxrpc_local *local,
 29                                        struct rxrpc_host_header *hdr,
 30                                        struct sk_buff *skb)
 31 {
 32         struct rxrpc_wire_header whdr;
 33         struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
 34         struct sockaddr_rxrpc srx;
 35         struct msghdr msg;
 36         struct kvec iov[2];
 37         size_t len;
 38         int ret;
 39 
 40         _enter("");
 41 
 42         if (rxrpc_extract_addr_from_skb(local, &srx, skb) < 0)
 43                 return;
 44 
 45         msg.msg_name    = &srx.transport;
 46         msg.msg_namelen = srx.transport_len;
 47         msg.msg_control = NULL;
 48         msg.msg_controllen = 0;
 49         msg.msg_flags   = 0;
 50 
 51         whdr.epoch      = htonl(sp->hdr.epoch);
 52         whdr.cid        = htonl(sp->hdr.cid);
 53         whdr.callNumber = htonl(sp->hdr.callNumber);
 54         whdr.seq        = 0;
 55         whdr.serial     = 0;
 56         whdr.type       = RXRPC_PACKET_TYPE_VERSION;
 57         whdr.flags      = RXRPC_LAST_PACKET | (~hdr->flags & RXRPC_CLIENT_INITIATED);
 58         whdr.userStatus = 0;
 59         whdr.securityIndex = 0;
 60         whdr._rsvd      = 0;
 61         whdr.serviceId  = htons(sp->hdr.serviceId);
 62 
 63         iov[0].iov_base = &whdr;
 64         iov[0].iov_len  = sizeof(whdr);
 65         iov[1].iov_base = (char *)rxrpc_version_string;
 66         iov[1].iov_len  = sizeof(rxrpc_version_string);
 67 
 68         len = iov[0].iov_len + iov[1].iov_len;
 69 
 70         _proto("Tx VERSION (reply)");
 71 
 72         ret = kernel_sendmsg(local->socket, &msg, iov, 2, len);
 73         if (ret < 0)
 74                 trace_rxrpc_tx_fail(local->debug_id, 0, ret,
 75                                     rxrpc_tx_fail_version_reply);
 76 
 77         _leave("");
 78 }
 79 
 80 /*
 81  * Process event packets targetted at a local endpoint.
 82  */
 83 void rxrpc_process_local_events(struct rxrpc_local *local)
 84 {
 85         struct sk_buff *skb;
 86         char v;
 87 
 88         _enter("");
 89 
 90         skb = skb_dequeue(&local->event_queue);
 91         if (skb) {
 92                 struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
 93 
 94                 rxrpc_see_skb(skb, rxrpc_skb_rx_seen);
 95                 _debug("{%d},{%u}", local->debug_id, sp->hdr.type);
 96 
 97                 switch (sp->hdr.type) {
 98                 case RXRPC_PACKET_TYPE_VERSION:
 99                         if (skb_copy_bits(skb, sizeof(struct rxrpc_wire_header),
100                                           &v, 1) < 0)
101                                 return;
102                         _proto("Rx VERSION { %02x }", v);
103                         if (v == 0)
104                                 rxrpc_send_version_request(local, &sp->hdr, skb);
105                         break;
106 
107                 default:
108                         /* Just ignore anything we don't understand */
109                         break;
110                 }
111 
112                 rxrpc_free_skb(skb, rxrpc_skb_rx_freed);
113         }
114 
115         _leave("");
116 }
117 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp