Blame view

net/atm/raw.c 1.92 KB
b24413180   Greg Kroah-Hartman   License cleanup: ...
1
  // SPDX-License-Identifier: GPL-2.0
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
4
  /* net/atm/raw.c - Raw AAL0 and AAL5 transports */
  
  /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
99824461e   Joe Perches   net/atm: Convert ...
5
  #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
6
7
  
  #include <linux/module.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
8
  #include <linux/atmdev.h>
4fc268d24   Randy Dunlap   [PATCH] capable/c...
9
  #include <linux/capability.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
10
11
12
  #include <linux/kernel.h>
  #include <linux/skbuff.h>
  #include <linux/mm.h>
5a0e3ad6a   Tejun Heo   include cleanup: ...
13
  #include <linux/slab.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
14
15
16
  
  #include "common.h"
  #include "protocols.h"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
17
18
19
  /*
   * SKB == NULL indicates that the link is being closed
   */
fa61f0cac   Joe Perches   net/atm/raw.c: ch...
20
  static void atm_push_raw(struct atm_vcc *vcc, struct sk_buff *skb)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
21
22
23
24
25
  {
  	if (skb) {
  		struct sock *sk = sk_atm(vcc);
  
  		skb_queue_tail(&sk->sk_receive_queue, skb);
676d23690   David S. Miller   net: Fix use afte...
26
  		sk->sk_data_ready(sk);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
27
28
  	}
  }
fa61f0cac   Joe Perches   net/atm/raw.c: ch...
29
  static void atm_pop_raw(struct atm_vcc *vcc, struct sk_buff *skb)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
30
31
  {
  	struct sock *sk = sk_atm(vcc);
99824461e   Joe Perches   net/atm: Convert ...
32
33
  	pr_debug("(%d) %d -= %d
  ",
f93d65939   David Woodhouse   atm: Preserve val...
34
35
  		 vcc->vci, sk_wmem_alloc_get(sk), ATM_SKB(skb)->acct_truesize);
  	WARN_ON(refcount_sub_and_test(ATM_SKB(skb)->acct_truesize, &sk->sk_wmem_alloc));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
36
37
38
  	dev_kfree_skb_any(skb);
  	sk->sk_write_space(sk);
  }
fa61f0cac   Joe Perches   net/atm/raw.c: ch...
39
  static int atm_send_aal0(struct atm_vcc *vcc, struct sk_buff *skb)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
40
41
42
43
44
45
  {
  	/*
  	 * Note that if vpi/vci are _ANY or _UNSPEC the below will
  	 * still work
  	 */
  	if (!capable(CAP_NET_ADMIN) &&
fa61f0cac   Joe Perches   net/atm/raw.c: ch...
46
47
48
  	    (((u32 *)skb->data)[0] & (ATM_HDR_VPI_MASK | ATM_HDR_VCI_MASK)) !=
  	    ((vcc->vpi << ATM_HDR_VPI_SHIFT) |
  	     (vcc->vci << ATM_HDR_VCI_SHIFT))) {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
49
50
  		kfree_skb(skb);
  		return -EADDRNOTAVAIL;
f7d57453d   YOSHIFUJI Hideaki   [NET] ATM: Fix wh...
51
  	}
fa61f0cac   Joe Perches   net/atm/raw.c: ch...
52
  	return vcc->dev->ops->send(vcc, skb);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
53
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
54
55
56
57
58
59
60
61
  int atm_init_aal0(struct atm_vcc *vcc)
  {
  	vcc->push = atm_push_raw;
  	vcc->pop = atm_pop_raw;
  	vcc->push_oam = NULL;
  	vcc->send = atm_send_aal0;
  	return 0;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
62
63
64
65
66
67
68
69
  int atm_init_aal34(struct atm_vcc *vcc)
  {
  	vcc->push = atm_push_raw;
  	vcc->pop = atm_pop_raw;
  	vcc->push_oam = NULL;
  	vcc->send = vcc->dev->ops->send;
  	return 0;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
70
71
72
73
74
75
76
77
  int atm_init_aal5(struct atm_vcc *vcc)
  {
  	vcc->push = atm_push_raw;
  	vcc->pop = atm_pop_raw;
  	vcc->push_oam = NULL;
  	vcc->send = vcc->dev->ops->send;
  	return 0;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
78
  EXPORT_SYMBOL(atm_init_aal5);