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; }
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; }