net/atm: Convert printk to pr_<level>
[deliverable/linux.git] / net / atm / raw.c
1 /* net/atm/raw.c - Raw AAL0 and AAL5 transports */
2
3 /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
4
5 #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
6
7 #include <linux/module.h>
8 #include <linux/atmdev.h>
9 #include <linux/capability.h>
10 #include <linux/kernel.h>
11 #include <linux/skbuff.h>
12 #include <linux/mm.h>
13
14 #include "common.h"
15 #include "protocols.h"
16
17 /*
18 * SKB == NULL indicates that the link is being closed
19 */
20
21 static void atm_push_raw(struct atm_vcc *vcc,struct sk_buff *skb)
22 {
23 if (skb) {
24 struct sock *sk = sk_atm(vcc);
25
26 skb_queue_tail(&sk->sk_receive_queue, skb);
27 sk->sk_data_ready(sk, skb->len);
28 }
29 }
30
31
32 static void atm_pop_raw(struct atm_vcc *vcc,struct sk_buff *skb)
33 {
34 struct sock *sk = sk_atm(vcc);
35
36 pr_debug("(%d) %d -= %d\n",
37 vcc->vci, sk_wmem_alloc_get(sk), skb->truesize);
38 atomic_sub(skb->truesize, &sk->sk_wmem_alloc);
39 dev_kfree_skb_any(skb);
40 sk->sk_write_space(sk);
41 }
42
43
44 static int atm_send_aal0(struct atm_vcc *vcc,struct sk_buff *skb)
45 {
46 /*
47 * Note that if vpi/vci are _ANY or _UNSPEC the below will
48 * still work
49 */
50 if (!capable(CAP_NET_ADMIN) &&
51 (((u32 *) skb->data)[0] & (ATM_HDR_VPI_MASK | ATM_HDR_VCI_MASK)) !=
52 ((vcc->vpi << ATM_HDR_VPI_SHIFT) | (vcc->vci << ATM_HDR_VCI_SHIFT)))
53 {
54 kfree_skb(skb);
55 return -EADDRNOTAVAIL;
56 }
57 return vcc->dev->ops->send(vcc,skb);
58 }
59
60
61 int atm_init_aal0(struct atm_vcc *vcc)
62 {
63 vcc->push = atm_push_raw;
64 vcc->pop = atm_pop_raw;
65 vcc->push_oam = NULL;
66 vcc->send = atm_send_aal0;
67 return 0;
68 }
69
70
71 int atm_init_aal34(struct atm_vcc *vcc)
72 {
73 vcc->push = atm_push_raw;
74 vcc->pop = atm_pop_raw;
75 vcc->push_oam = NULL;
76 vcc->send = vcc->dev->ops->send;
77 return 0;
78 }
79
80
81 int atm_init_aal5(struct atm_vcc *vcc)
82 {
83 vcc->push = atm_push_raw;
84 vcc->pop = atm_pop_raw;
85 vcc->push_oam = NULL;
86 vcc->send = vcc->dev->ops->send;
87 return 0;
88 }
89
90
91 EXPORT_SYMBOL(atm_init_aal5);
This page took 0.036327 seconds and 5 git commands to generate.