Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | pj | 1 | /* Emulates Linux sk buffers using hartik net buffers... */ |
2 | |||
3 | #include <kernel/kern.h> |
||
4 | #include <semaphore.h> |
||
5 | |||
6 | #include "../net/netbuff.h" |
||
7 | #include "../net/eth_priv.h" |
||
8 | |||
9 | #include"linux/skbuff.h" |
||
10 | |||
11 | #define LOWLEV_TX_BUFFERS 50 |
||
12 | #define LOWLEV_RX_BUFFERS 50 |
||
13 | struct netbuff rxbuff; |
||
14 | struct netbuff lowlevel_txbuff; |
||
15 | |||
16 | void skb_init(void) |
||
17 | { |
||
18 | netbuff_init(&lowlevel_txbuff, LOWLEV_TX_BUFFERS, ETH_MAX_LEN); |
||
19 | netbuff_init(&rxbuff, LOWLEV_RX_BUFFERS, ETH_MAX_LEN); |
||
20 | } |
||
21 | |||
22 | struct sk_buff *dev_alloc_skb(unsigned int len) |
||
23 | { |
||
24 | struct sk_buff *skb; |
||
25 | |||
26 | kern_cli(); |
||
27 | skb = kern_alloc(sizeof(struct sk_buff)); |
||
28 | kern_sti(); |
||
29 | |||
30 | skb->data = netbuff_get(&rxbuff, NON_BLOCK); |
||
31 | if (skb->data == NULL) { |
||
32 | return NULL; |
||
33 | } |
||
34 | skb->head = skb->data; |
||
35 | skb->tail = skb->data; |
||
36 | skb->len = 0; |
||
37 | |||
38 | return skb; |
||
39 | } |
||
40 | |||
41 | void skb_reserve(struct sk_buff *skb, int len) |
||
42 | { |
||
43 | /* Do nothing... */ |
||
44 | } |
||
45 | |||
46 | unsigned char *skb_put(struct sk_buff *skb, int len) |
||
47 | { |
||
48 | unsigned char *tmp=skb->tail; |
||
49 | |||
50 | skb->tail+=len; |
||
51 | skb->len+=len; |
||
52 | |||
53 | return tmp; |
||
54 | } |
||
55 | |||
56 | void skb_queue_head_init(struct sk_buff_head *list) |
||
57 | { |
||
58 | list->prev = (struct sk_buff *)list; |
||
59 | list->next = (struct sk_buff *)list; |
||
60 | list->qlen = 0; |
||
61 | } |