RTCSPCB_PTR RTCSPCB_alloc( void ) { RTCS_DATA_PTR RTCS_data_ptr; RTCSPCB_PTR rtcs_pcb; RTCS_data_ptr = RTCS_get_data(); rtcs_pcb = RTCS_part_alloc(RTCS_data_ptr->RTCS_PCB_partition); if (rtcs_pcb != NULL) { /* Set default values.*/ rtcs_pcb->IP_SUM_PTR = NULL; _mem_zero(&rtcs_pcb->LINK_OPTIONS, sizeof(rtcs_pcb->LINK_OPTIONS)); RTCSPCB_SET_TRANS_PROTL(rtcs_pcb, 0); } RTCSLOG_PCB_ALLOC(rtcs_pcb); return rtcs_pcb; }
RTCSPCB_PTR RTCSPCB_alloc ( void ) { RTCS_DATA_PTR RTCS_data_ptr; RTCSPCB_PTR rtcs_pcb; RTCS_data_ptr = RTCS_get_data(); rtcs_pcb = RTCS_part_alloc(RTCS_data_ptr->RTCS_PCB_partition); if (rtcs_pcb != NULL) { rtcs_pcb->IP_SUM_PTR = NULL; _mem_zero(&rtcs_pcb->LINK_OPTIONS, sizeof(rtcs_pcb->LINK_OPTIONS)); } /* Endif */ RTCSLOG_PCB_ALLOC(rtcs_pcb); return rtcs_pcb; }
static RTCSPCB_PTR NAT_IPREASM_reasm_dgram ( IP_DGRAM_PTR dgram /* [IN] the dgram descriptor */ ) { /* Body */ RTCSPCB_PTR outpcb; PCB_PTR bpcb; PCB_FRAGMENT _PTR_ pcb_frag_ptr; uchar_ptr data; uint_32 iphlen = (ntohc(dgram->IPH.VERSLEN) & 0xF) << 2; uint_32 ip_totlen = iphlen + dgram->TOTLEN; bpcb = _mem_alloc_system(sizeof(PCB) + sizeof(PCB_FRAGMENT) + ip_totlen); if (!bpcb) { return NULL; } /* Endif */ data = (uchar_ptr)bpcb + sizeof(PCB) + sizeof(PCB_FRAGMENT); bpcb->FREE = (void(_CODE_PTR_)(PCB_PTR))_mem_free; bpcb->PRIVATE = NULL; pcb_frag_ptr = bpcb->FRAG; pcb_frag_ptr->LENGTH = ip_totlen; pcb_frag_ptr->FRAGMENT = data; pcb_frag_ptr++; pcb_frag_ptr->LENGTH = 0; pcb_frag_ptr->FRAGMENT = NULL; /* Copy the IP header with options */ htons(dgram->IPH.FRAGMENT, 0); _mem_copy(&dgram->IPH, data, iphlen); data += iphlen; /* ** At this point, we really should update the LENGTH ** and CHECKSUM fields in the new IP header, but we ** don't actually need to, because this datagram is ** going straight to IPLOCAL_service, which doesn't ** check these things. */ /* Copy the stored data in the new packet */ NAT_IPREASM_blk_read_all(dgram, data, dgram->TOTLEN); /* Put it in an RTCSPCB */ outpcb = RTCSPCB_alloc_recv(bpcb); if (outpcb == NULL) { PCB_free(bpcb); return NULL; } /* Endif */ RTCSLOG_PCB_ALLOC(bpcb); outpcb->IFSRC = dgram->IFSRC; outpcb->TYPE = dgram->TYPE; outpcb->LINK_OPTIONS.RX = dgram->LINKOPT; RTCSPCB_DATA_NETWORK(outpcb) = RTCSPCB_DATA(outpcb); RTCSPCB_SET_TRANS_PROTL(outpcb, dgram->PROTO); RTCSPCB_SET_TRANS_DELTA(outpcb, iphlen); /* Delete the local structure */ NAT_IPREASM_del_dgram(dgram); return outpcb; } /* Endbody */