Пример #1
0
struct raw_pcb * raw_pcb_new(int __protocol)
{
	struct raw_pcb * raw;

	tcpip_net_lock();

	if ((raw = (struct raw_pcb *)pcb_remove_head(&__raw__.free)) == NULL) {
		DCC_LOG(LOG_WARNING, "could not allocate a PCB");
		return NULL;
	}

	pcb_insert((struct pcb *)raw, &__raw__.active);

	/* ensure the mem is clean */
	memset(raw, 0, sizeof(struct raw_pcb));

	raw->r_cond = thinkos_cond_alloc();
	raw->r_protocol = __protocol;

	DCC_LOG2(LOG_TRACE, "<%x> protocol=%d", raw, __protocol); 


	tcpip_net_unlock();

	return raw;
} 
Пример #2
0
void udp_init(void)
{
	int i;

	DCC_LOG(LOG_TRACE, "initializing UDP subsystem."); 

	pcb_list_init(&__udp__.free);
	for (i = 0; i < NET_TCP_PCB_ACTIVE_MAX; ++i) {
		struct udp_pcb * up = &__udp__.pcb_pool[i].pcb;
		pcb_insert((struct pcb *)up, &__udp__.free);
	}

	pcb_list_init(&__udp__.active);
}
Пример #3
0
void raw_init(void)
{
	int i;

	DCC_LOG(LOG_TRACE, "initializing RAW subsystem."); 

	pcb_list_init(&__raw__.free);

	for (i = 0; i < NET_RAW_PCB_MAX; ++i) {
		struct raw_pcb * p = &__raw__.pcb_pool[i].pcb;
		pcb_insert((struct pcb *)p, &__raw__.free);
	}

	pcb_list_init(&__raw__.active);
}
Пример #4
0
struct udp_pcb * udp_alloc(void)
{
	struct udp_pcb * up;

	tcpip_net_lock();

	if ((up = (struct udp_pcb *)pcb_remove_head(&__udp__.free)) == NULL) {
		DCC_LOG(LOG_WARNING, "could not allocate a PCB");
		return NULL;
	}

	pcb_insert((struct pcb *)up, &__udp__.active);

	/* ensure the mem is clean */
	memset(up, 0, sizeof(struct udp_pcb));

	up->u_rcv_cond = __os_cond_alloc();

	tcpip_net_unlock();

	return up;
}