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

TOMOYO Linux Cross Reference
Linux/net/rose/rose_loopback.c

Version: ~ [ linux-5.8 ] ~ [ linux-5.7.14 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.57 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.138 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.193 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.232 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.232 ] ~ [ 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.85 ] ~ [ 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-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 /*
  2  * This program is free software; you can redistribute it and/or modify
  3  * it under the terms of the GNU General Public License as published by
  4  * the Free Software Foundation; either version 2 of the License, or
  5  * (at your option) any later version.
  6  *
  7  * Copyright (C) Jonathan Naylor G4KLX (g4klx@g4klx.demon.co.uk)
  8  */
  9 #include <linux/types.h>
 10 #include <linux/slab.h>
 11 #include <linux/socket.h>
 12 #include <linux/timer.h>
 13 #include <net/ax25.h>
 14 #include <linux/skbuff.h>
 15 #include <net/rose.h>
 16 #include <linux/init.h>
 17 
 18 static struct sk_buff_head loopback_queue;
 19 static struct timer_list loopback_timer;
 20 
 21 static void rose_set_loopback_timer(void);
 22 
 23 void rose_loopback_init(void)
 24 {
 25         skb_queue_head_init(&loopback_queue);
 26 
 27         init_timer(&loopback_timer);
 28 }
 29 
 30 static int rose_loopback_running(void)
 31 {
 32         return timer_pending(&loopback_timer);
 33 }
 34 
 35 int rose_loopback_queue(struct sk_buff *skb, struct rose_neigh *neigh)
 36 {
 37         struct sk_buff *skbn;
 38 
 39         skbn = skb_clone(skb, GFP_ATOMIC);
 40 
 41         kfree_skb(skb);
 42 
 43         if (skbn != NULL) {
 44                 skb_queue_tail(&loopback_queue, skbn);
 45 
 46                 if (!rose_loopback_running())
 47                         rose_set_loopback_timer();
 48         }
 49 
 50         return 1;
 51 }
 52 
 53 static void rose_loopback_timer(unsigned long);
 54 
 55 static void rose_set_loopback_timer(void)
 56 {
 57         del_timer(&loopback_timer);
 58 
 59         loopback_timer.data     = 0;
 60         loopback_timer.function = &rose_loopback_timer;
 61         loopback_timer.expires  = jiffies + 10;
 62 
 63         add_timer(&loopback_timer);
 64 }
 65 
 66 static void rose_loopback_timer(unsigned long param)
 67 {
 68         struct sk_buff *skb;
 69         struct net_device *dev;
 70         rose_address *dest;
 71         struct sock *sk;
 72         unsigned short frametype;
 73         unsigned int lci_i, lci_o;
 74 
 75         while ((skb = skb_dequeue(&loopback_queue)) != NULL) {
 76                 if (skb->len < ROSE_MIN_LEN) {
 77                         kfree_skb(skb);
 78                         continue;
 79                 }
 80                 lci_i     = ((skb->data[0] << 8) & 0xF00) + ((skb->data[1] << 0) & 0x0FF);
 81                 frametype = skb->data[2];
 82                 if (frametype == ROSE_CALL_REQUEST &&
 83                     (skb->len <= ROSE_CALL_REQ_FACILITIES_OFF ||
 84                      skb->data[ROSE_CALL_REQ_ADDR_LEN_OFF] !=
 85                      ROSE_CALL_REQ_ADDR_LEN_VAL)) {
 86                         kfree_skb(skb);
 87                         continue;
 88                 }
 89                 dest      = (rose_address *)(skb->data + ROSE_CALL_REQ_DEST_ADDR_OFF);
 90                 lci_o     = ROSE_DEFAULT_MAXVC + 1 - lci_i;
 91 
 92                 skb_reset_transport_header(skb);
 93 
 94                 sk = rose_find_socket(lci_o, rose_loopback_neigh);
 95                 if (sk) {
 96                         if (rose_process_rx_frame(sk, skb) == 0)
 97                                 kfree_skb(skb);
 98                         continue;
 99                 }
100 
101                 if (frametype == ROSE_CALL_REQUEST) {
102                         if ((dev = rose_dev_get(dest)) != NULL) {
103                                 if (rose_rx_call_request(skb, dev, rose_loopback_neigh, lci_o) == 0)
104                                         kfree_skb(skb);
105                         } else {
106                                 kfree_skb(skb);
107                         }
108                 } else {
109                         kfree_skb(skb);
110                 }
111         }
112 }
113 
114 void __exit rose_loopback_clear(void)
115 {
116         struct sk_buff *skb;
117 
118         del_timer(&loopback_timer);
119 
120         while ((skb = skb_dequeue(&loopback_queue)) != NULL) {
121                 skb->sk = NULL;
122                 kfree_skb(skb);
123         }
124 }
125 

~ [ 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