Example #1
0
void skb_extra_free(struct sk_buff_extra *skb_extra) {
    ipl_t sp;

    sp = ipl_save();
    {
        pool_free(&skb_extra_pool, skb_extra);
    }
    ipl_restore(sp);
}
Example #2
0
static struct sock * sock_alloc(
		const struct sock_family_ops *f_ops,
		const struct sock_proto_ops *p_ops) {
	ipl_t sp;
	struct sock *sk;
	struct proto_sock *p_sk;

	assert(f_ops != NULL);
	assert(p_ops != NULL);

	sp = ipl_save();
	{
		sk = pool_alloc(f_ops->sock_pool);
		if (sk == NULL) {
			ipl_restore(sp);
			return NULL;
		}

		if (p_ops->sock_pool != NULL) {
			p_sk = pool_alloc(p_ops->sock_pool);
			if (p_sk == NULL) {
				pool_free(f_ops->sock_pool, sk);
				ipl_restore(sp);
				return NULL;
			}
		}
		else {
			p_sk = NULL;
		}
	}
	ipl_restore(sp);

	assert(((p_sk == NULL) && (p_ops->sock_pool == NULL))
			|| ((p_sk != NULL) && (p_ops->sock_pool != NULL)));

	sk->p_sk = p_sk;
	if (p_sk != NULL) {
		p_sk->sk = sk;
	}

	return sk;
}
Example #3
0
struct sk_buff_data * skb_data_clone(struct sk_buff_data *skb_data) {
    ipl_t sp;

    assert(skb_data != NULL);

    sp = ipl_save();
    {
        ++skb_data->links;
    }
    ipl_restore(sp);

    return skb_data;
}
Example #4
0
static int lapic_clock_init(void) {
	ipl_t ipl = ipl_save();

	clock_source_register(&lapic_clock_source);

	if (ENOERR != irq_attach(IRQ0, clock_handler, 0, &lapic_clock_source, "lapic")) {
		panic("lapic timer irq_attach failed");
	}

	lapic_clock_setup(NULL);

	ipl_restore(ipl);

	return ENOERR;
}
Example #5
0
void skb_free(struct sk_buff *skb) {
    ipl_t sp;

    if (!skb) {
        return;
    }

    skb_data_free(skb->data);

    sp = ipl_save();
    {
        assert((skb->lnk.prev != NULL) && (skb->lnk.next != NULL));
        list_del((struct list_head *) skb);
        pool_free(&skb_pool, skb);
    }
    ipl_restore(sp);
}
Example #6
0
struct sk_buff_extra * skb_extra_alloc(void) {
    ipl_t sp;
    struct sk_buff_extra *skb_extra;

    sp = ipl_save();
    {
        skb_extra = pool_alloc(&skb_extra_pool);
    }
    ipl_restore(sp);

    if (skb_extra == NULL) {
        log_error("skb_extra_alloc: error: no memory\n");
        return NULL; /* error: no memory */
    }

    return skb_extra;
}
Example #7
0
void skb_data_free(struct sk_buff_data *skb_data) {
    ipl_t sp;

    assert(skb_data != NULL);

    sp = ipl_save();
    {
        if (--skb_data->links == 0) {
            if (pool_belong(&skb_data_pool, skb_data)) {
                pool_free(&skb_data_pool, skb_data);
            }
            else {
                sysfree(skb_data);
            }
        }
    }
    ipl_restore(sp);
}
Example #8
0
static struct sk_buff_data * skb_data_alloc_dynamic(size_t size) {
    ipl_t sp;
    struct sk_buff_data *skb_data;

    sp = ipl_save();
    {
        skb_data = (struct sk_buff_data *) sysmalloc(SKB_DATA_SIZE(size));
    }
    ipl_restore(sp);

    if (skb_data == NULL) {
        log_error("skb_data_alloc: error: no memory\n");
        return NULL; /* error: no memory */
    }

    skb_data->links = 1;

    return skb_data;
}
Example #9
0
static void sock_free(struct sock *sk) {
	ipl_t sp;

	assert(sk != NULL);
	assert(sk->f_ops != NULL);
	assert(sk->p_ops != NULL);
	assert(((sk->p_sk == NULL) && (sk->p_ops->sock_pool == NULL))
			|| ((sk->p_sk != NULL)
				&& (sk->p_ops->sock_pool != NULL)));

	sp = ipl_save();
	{
		if (sk->p_sk != NULL) {
			pool_free(sk->p_ops->sock_pool, sk->p_sk);
		}
		pool_free(sk->f_ops->sock_pool, sk);
	}
	ipl_restore(sp);
}
Example #10
0
struct sk_buff * skb_wrap_local(size_t size, struct sk_buff_data *skb_data,
		struct pool *pl) {
	ipl_t sp;
	struct sk_buff *skb;

	assert(pl != NULL);
	assert(size != 0);
	assert(skb_data != NULL);

	// TODO move it
//	if (size > skb_max_size()) {
//		log_error("skb_wrap: error: size is too big\n");
//		return NULL; /* error: invalid argument */
//	}

	sp = ipl_save();
	{
		skb = pool_alloc(pl);
	}
	ipl_restore(sp);

	if (skb == NULL) {
		log_error("skb_wrap: error: no memory\n");
		return NULL; /* error: no memory */
	}

	gettimeofday(&skb->tstamp, NULL);

	INIT_LIST_HEAD((struct list_head * )skb);
	skb->dev = NULL;
	skb->len = size;
	skb->nh.raw = skb->h.raw = NULL;
	skb->data = skb_data;
	skb->mac.raw = skb_get_data_pointner(skb_data);
	skb->p_data = skb->p_data_end = NULL;
	skb->pl = pl;

	return skb;
}