1#include "net/ipv6/uip-packetqueue.h"
5#define MAX_NUM_QUEUED_PACKETS 2
6MEMB(packets_memb,
struct uip_packetqueue_packet, MAX_NUM_QUEUED_PACKETS);
10#define LOG_MODULE "Packet-Q"
11#define LOG_LEVEL LOG_LEVEL_NONE
14packet_timedout(
void *ptr)
16 struct uip_packetqueue_handle *h = ptr;
18 LOG_INFO(
"Timed out %p\n", h);
24uip_packetqueue_new(
struct uip_packetqueue_handle *handle)
26 LOG_DBG(
"New %p\n", handle);
27 handle->packet = NULL;
30struct uip_packetqueue_packet *
31uip_packetqueue_alloc(
struct uip_packetqueue_handle *handle,
32 clock_time_t lifetime)
34 LOG_DBG(
"Alloc %p\n", handle);
35 if(handle->packet != NULL) {
40 if(handle->packet != NULL) {
41 ctimer_set(&handle->packet->lifetimer, lifetime,
42 packet_timedout, handle);
44 LOG_ERR(
"Alloc failed\n");
46 return handle->packet;
50uip_packetqueue_free(
struct uip_packetqueue_handle *handle)
52 LOG_DBG(
"Free %p\n", handle);
53 if(handle->packet != NULL) {
56 handle->packet = NULL;
61uip_packetqueue_buf(
const struct uip_packetqueue_handle *h)
63 return h->packet != NULL ? h->packet->queue_buf: NULL;
67uip_packetqueue_buflen(
const struct uip_packetqueue_handle *h)
69 return h->packet != NULL ? h->packet->queue_buf_len: 0;
73uip_packetqueue_set_buflen(
struct uip_packetqueue_handle *h, uint16_t len)
75 if(h->packet != NULL) {
76 h->packet->queue_buf_len = len;
void ctimer_stop(struct ctimer *c)
Stop a pending callback timer.
static void ctimer_set(struct ctimer *c, clock_time_t t, void(*f)(void *), void *ptr)
Set a callback timer.
int memb_free(struct memb *m, void *ptr)
Deallocate a memory block from a memory block previously declared with MEMB().
void * memb_alloc(struct memb *m)
Allocate a memory block from a block of memory declared with MEMB().
#define MEMB(name, structure, num)
Declare a memory block.
Header file for the logging system.
Memory block allocation routines.