7 #include "net/uip-packetqueue.h"
9 #define MAX_NUM_QUEUED_PACKETS 2
10 MEMB(packets_memb,
struct uip_packetqueue_packet, MAX_NUM_QUEUED_PACKETS);
15 #define PRINTF(...) printf(__VA_ARGS__)
22 packet_timedout(
void *ptr)
24 struct uip_packetqueue_handle *h = ptr;
26 PRINTF(
"uip_packetqueue_free timed out %p\n", h);
32 uip_packetqueue_new(
struct uip_packetqueue_handle *handle)
34 PRINTF(
"uip_packetqueue_new %p\n", handle);
35 handle->packet =
NULL;
38 struct uip_packetqueue_packet *
39 uip_packetqueue_alloc(
struct uip_packetqueue_handle *handle, clock_time_t lifetime)
41 PRINTF(
"uip_packetqueue_alloc %p\n", handle);
42 if(handle->packet !=
NULL) {
47 if(handle->packet !=
NULL) {
48 ctimer_set(&handle->packet->lifetimer, lifetime,
49 packet_timedout, handle);
51 PRINTF(
"uip_packetqueue_alloc failed\n");
53 return handle->packet;
57 uip_packetqueue_free(
struct uip_packetqueue_handle *handle)
59 PRINTF(
"uip_packetqueue_free %p\n", handle);
60 if(handle->packet !=
NULL) {
63 handle->packet =
NULL;
68 uip_packetqueue_buf(
struct uip_packetqueue_handle *h)
70 return h->packet !=
NULL? h->packet->queue_buf:
NULL;
74 uip_packetqueue_buflen(
struct uip_packetqueue_handle *h)
76 return h->packet !=
NULL? h->packet->queue_buf_len: 0;
80 uip_packetqueue_set_buflen(
struct uip_packetqueue_handle *h, uint16_t len)
82 if(h->packet !=
NULL) {
83 h->packet->queue_buf_len = len;