net/atm: Convert printk to pr_<level>
[deliverable/linux.git] / net / atm / raw.c
CommitLineData
1da177e4
LT
1/* net/atm/raw.c - Raw AAL0 and AAL5 transports */
2
3/* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
4
99824461 5#define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
1da177e4
LT
6
7#include <linux/module.h>
1da177e4 8#include <linux/atmdev.h>
4fc268d2 9#include <linux/capability.h>
1da177e4
LT
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
1da177e4
LT
17/*
18 * SKB == NULL indicates that the link is being closed
19 */
20
21static 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
32static void atm_pop_raw(struct atm_vcc *vcc,struct sk_buff *skb)
33{
34 struct sock *sk = sk_atm(vcc);
35
99824461
JP
36 pr_debug("(%d) %d -= %d\n",
37 vcc->vci, sk_wmem_alloc_get(sk), skb->truesize);
1da177e4
LT
38 atomic_sub(skb->truesize, &sk->sk_wmem_alloc);
39 dev_kfree_skb_any(skb);
40 sk->sk_write_space(sk);
41}
42
43
44static 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) &&
f7d57453
YH
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)))
1da177e4
LT
53 {
54 kfree_skb(skb);
55 return -EADDRNOTAVAIL;
f7d57453 56 }
1da177e4
LT
57 return vcc->dev->ops->send(vcc,skb);
58}
59
60
61int 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
71int 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
81int 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
91EXPORT_SYMBOL(atm_init_aal5);
This page took 1.188843 seconds and 5 git commands to generate.