/* *=========================================================================== * ipcom_buffer_end_ptr *=========================================================================== * Description: Returns a pointer to the first free byte in the buffer. * Parameters: * Returns: * */ IP_PUBLIC Ip_u8 * ipcom_buffer_end_ptr(Ipcom_buffer *buffer) { IPCOM_LOG3(DEBUG2, "ipcom_buffer_write_ptr :: buf=%x, end=%d, offset=%d", buffer, buffer->end, buffer->offset); return &(buffer->buf[buffer->end]); }
/* *=========================================================================== * ipcom_buffer_start_ptr *=========================================================================== * Description: Returns a pointer to the first used byte in the buffer. * Parameters: * Returns: * */ IP_PUBLIC Ip_u8 * ipcom_buffer_start_ptr(Ipcom_buffer *buffer) { IPCOM_LOG3(DEBUG2, "ipcom_buffer_ptr :: buf=%x, end=%d, offset=%d", buffer, buffer->end, buffer->offset); return buffer->buf + buffer->offset; }
/* *=========================================================================== * ipnet_pkt_queue_mbc_remove *=========================================================================== * Description: Removes an queue from a container queue and put pack a * default queue type. * Parameters: c - The MBC parent queue for 'q'. * q - The queue to remove. * Returns: 0 = success, <0 = error code (-IP_ERRNO_xxx) * */ IP_STATIC int ipnet_pkt_queue_mbc_remove(Ipnet_pkt_queue_mbc *c, Ipnet_pkt_queue *q) { Ip_u32 band; ip_assert(c->hdr.id == q->parent_id); for (band = 0; band < c->number_of_bands; band++) { if (q == c->bands[band]) { int ret = ipnet_pkt_queue_mbc_insert_default_queue(c, band); if (ret < 0) IPCOM_LOG3(WARNING, "MBC: Failed to replace %s:%d with a fifo in remove(): %s", q->type, q->id, ipcom_strerror(-ret)); return ret; } } return -IP_ERRNO_ESRCH; }
/* *=========================================================================== * ipcom_buffer_trim *=========================================================================== * Description: * Parameters: * Returns: * */ IP_PUBLIC void ipcom_buffer_trim(Ipcom_buffer *buffer) { IPCOM_LOG3(DEBUG2, "ipcom_buffer_trim :: buf=%x, offset=%d, end=%d", buffer, buffer->offset, buffer->end); if(buffer->end == buffer->offset) { buffer->end = 0; buffer->offset = 0; return; } /* If more than the first half of the buffer is free/unused, move the * data to the beginning of the buffer */ if(buffer->offset > buffer->alloc/2) { ipcom_memmove(buffer->buf, buffer->buf + buffer->offset, buffer->end - buffer->offset); buffer->end -= buffer->offset; buffer->offset = 0; } }
/* *=========================================================================== * ipnet_pkt_queue_mbc_get *=========================================================================== * Description: Returns the queue that matches the specified ID. * Parameters: q - A MBC packet queue. * id - The ID of the contained queue. * Returns: A pointer to the queue or IP_NULL if it was not found. * */ IP_STATIC struct Ipnet_pkt_queue_struct * ipnet_pkt_queue_mbc_get(Ipnet_pkt_queue_mbc *q, int id) { Ip_u32 band; Ipnet_pkt_queue *c; if (q->hdr.id == id) return &q->hdr; for (band = 0; band < q->number_of_bands; band++) { c = q->bands[band]; if (c) { if (c->id == id) return c; if (c->c_ops && IP_NULL != (c = c->c_ops->q_get(c, id))) return c; } } IPCOM_LOG3(DEBUG2, "MBC: Did not find %d queue inside %s:%d", id, q->hdr.type, q->hdr.id); return IP_NULL; }