OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uClinux-2.0.x/] [net/] [rose/] [rose_loopback.c] - Blame information for rev 199

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/*
2
 *      ROSE release 003
3
 *
4
 *      This code REQUIRES 2.1.15 or higher/ NET3.038
5
 *
6
 *      This module:
7
 *              This module is free software; you can redistribute it and/or
8
 *              modify it under the terms of the GNU General Public License
9
 *              as published by the Free Software Foundation; either version
10
 *              2 of the License, or (at your option) any later version.
11
 *
12
 *      History
13
 *      ROSE 003        Jonathan(G4KLX) Created this file from nr_loopback.c.
14
 *
15
 */
16
 
17
#include <linux/config.h>
18
#if defined(CONFIG_ROSE) || defined(CONFIG_ROSE_MODULE)
19
#include <linux/types.h>
20
#include <linux/socket.h>
21
#include <linux/timer.h>
22
#include <net/ax25.h>
23
#include <linux/skbuff.h>
24
#include <net/rose.h>
25
 
26
static struct sk_buff_head loopback_queue;
27
static struct timer_list loopback_timer;
28
 
29
static void rose_set_loopback_timer(void);
30
 
31
void rose_loopback_init(void)
32
{
33
        skb_queue_head_init(&loopback_queue);
34
 
35
        init_timer(&loopback_timer);
36
}
37
 
38
void rose_loopback_clear(void)
39
{
40
        struct sk_buff *skb;
41
 
42
        del_timer(&loopback_timer);
43
 
44
        while ((skb = skb_dequeue(&loopback_queue)) != NULL) {
45
                skb->sk = NULL;
46
                kfree_skb(skb, FREE_READ);
47
        }
48
}
49
 
50
static int rose_loopback_running(void)
51
{
52
        return (loopback_timer.prev != NULL || loopback_timer.next != NULL);
53
}
54
 
55
int rose_loopback_queue(struct sk_buff *skb, struct rose_neigh *neigh)
56
{
57
        struct sk_buff *skbn;
58
 
59
        skbn = skb_clone(skb, GFP_ATOMIC);
60
 
61
        kfree_skb(skb, FREE_WRITE);
62
 
63
        if (skbn != NULL) {
64
                skbn->sk = (struct sock *)neigh;
65
                skb_queue_tail(&loopback_queue, skbn);
66
        }
67
 
68
        if (!rose_loopback_running())
69
        {
70
                rose_set_loopback_timer();
71
        }
72
        return 1;
73
}
74
 
75
static void rose_loopback_timer(unsigned long);
76
 
77
static void rose_set_loopback_timer(void)
78
{
79
        del_timer(&loopback_timer);
80
 
81
        loopback_timer.data     = 0;
82
        loopback_timer.function = &rose_loopback_timer;
83
        loopback_timer.expires  = jiffies + 10;
84
 
85
        add_timer(&loopback_timer);
86
}
87
 
88
static void rose_loopback_timer(unsigned long param)
89
{
90
        struct sk_buff *skb;
91
        struct rose_neigh *rose_neigh;
92
        struct sock *sk;
93
        struct device *dev;
94
        rose_address *dest_addr;
95
        unsigned int lci;
96
        unsigned short frametype;
97
 
98
        while ((skb = skb_dequeue(&loopback_queue)) != NULL) {
99
                rose_neigh = (struct rose_neigh *)skb->sk;
100
                lci        = ((skb->data[0] << 8) & 0xF00) + ((skb->data[1] << 0) & 0x0FF);
101
                dest_addr = (rose_address *)(skb->data + 4);
102
 
103
                /* F1OAT : Patch the LCI for proper loopback operation */
104
                /* Work only if the system open less than 2048 VC !!! */
105
 
106
                lci = 4096 - lci;
107
                skb->data[0] = (lci >> 8) & 0x0F;
108
                skb->data[1] = lci & 0xFF;
109
 
110
                skb->sk = NULL;
111
 
112
                frametype = skb->data[2];
113
 
114
                if (frametype == ROSE_CALL_REQUEST) {
115
                        if ((dev = rose_dev_get(dest_addr)) == NULL) {
116
                                kfree_skb(skb, FREE_READ);
117
                                continue;
118
                        }
119
                        if (!rose_rx_call_request(skb, dev, rose_neigh, lci))
120
                                kfree_skb(skb, FREE_READ);
121
                }
122
                else {
123
                        if ((sk = rose_find_socket(lci, rose_neigh)) == NULL) {
124
                                kfree_skb(skb, FREE_READ);
125
                                continue;
126
                        }
127
                        skb->h.raw = skb->data;
128
 
129
                        if (rose_process_rx_frame(sk, skb) == 0)
130
                                kfree_skb(skb, FREE_READ);
131
                }
132
        }
133
}
134
 
135
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.