Subversion Repositories shark

Rev

Blame | Last modification | View Log | RSS feed

/* Emulates Linux sk buffers using hartik net buffers... */

#include <kernel/kern.h>
#include <semaphore.h>

#include "../net/netbuff.h"
#include "../net/eth_priv.h"

#include"linux/skbuff.h"

#define LOWLEV_TX_BUFFERS 50
#define LOWLEV_RX_BUFFERS 50
struct netbuff rxbuff;
struct netbuff lowlevel_txbuff;

void skb_init(void)
{
        netbuff_init(&lowlevel_txbuff, LOWLEV_TX_BUFFERS, ETH_MAX_LEN);
        netbuff_init(&rxbuff, LOWLEV_RX_BUFFERS, ETH_MAX_LEN);
}

struct sk_buff *dev_alloc_skb(unsigned int len)
{
        struct sk_buff *skb;

        kern_cli();
        skb = kern_alloc(sizeof(struct sk_buff));
        kern_sti();
       
        skb->data = netbuff_get(&rxbuff, NON_BLOCK);
        if (skb->data == NULL) {
                        return NULL;
        }
        skb->head = skb->data;
        skb->tail = skb->data;
        skb->len = 0;

        return skb;
}

void skb_reserve(struct sk_buff *skb, int len)
{
        /* Do nothing... */
}

unsigned char *skb_put(struct sk_buff *skb, int len)
{
        unsigned char *tmp=skb->tail;
       
        skb->tail+=len;
        skb->len+=len;
       
        return tmp;
}

void skb_queue_head_init(struct sk_buff_head *list)
{    
        list->prev = (struct sk_buff *)list;
        list->next = (struct sk_buff *)list;
        list->qlen = 0;
}