#include "netif/net_policy/FIFO_policy.h"
#include <rtl_malloc.h>
#include "memcopy.h"
Include dependency graph for FIFO_policy.c:
Go to the source code of this file.
Functions | |
void | FIFO_initialize_rx_buffer (void *rx_buffer) |
void | FIFO_dealloc_rx_buffer (void *rx_buffer) |
int | FIFO_add_frame_to_buffer (void *rx_buffer, unsigned char *data, int len) |
int | FIFO_extract_frame_of_buffer (void *rx_buffer, void *data) |
|
Definition at line 96 of file FIFO_policy.c. References rx_buffer_t::add, data, len, rx_slot_t::length, and rx_buffer.
00096 { 00097 struct fifo_rx_buffer_t *fifo_rx_buffer = (struct fifo_rx_buffer_t *) rx_buffer; 00098 00099 /* If the packet in the position that we're writting hasn't still been read is */ 00100 /* because we're receiving too much packets, so we need to drop it. */ 00101 00102 00103 if(fifo_rx_buffer->add->read != 0x00){ 00104 fifo_rx_buffer->add->length = len; 00105 00106 memcpy(fifo_rx_buffer->add->data,data, len); 00107 00108 fifo_rx_buffer->add->read = 0x00; 00109 fifo_rx_buffer->add = fifo_rx_buffer->add->next; 00110 00111 return 0; 00112 }else 00113 // The packet is dropped 00114 return -1; 00115 } |
|
Definition at line 76 of file FIFO_policy.c. References rx_buffer_t::first, MAX_FIFO_RX_BUFFER_ENTRIES, rx_slot_t::next, NULL, rtl_free, and rx_buffer.
00076 { 00077 struct fifo_rx_buffer_t *fifo_rx_buffer = (struct fifo_rx_buffer_t *) rx_buffer; 00078 struct fifo_rx_slot_t *tmp = fifo_rx_buffer->first->next, *actual; 00079 int i; 00080 00081 for(i=0;i<(MAX_FIFO_RX_BUFFER_ENTRIES-1); i++){ 00082 actual = tmp->next; 00083 if(tmp->data != NULL) 00084 rtl_free(tmp->data); 00085 rtl_free(tmp); 00086 tmp = actual; 00087 } 00088 if(fifo_rx_buffer->first->data != NULL) 00089 rtl_free(fifo_rx_buffer->first->data); 00090 rtl_free(fifo_rx_buffer->first); 00091 00092 return; 00093 } |
|
Definition at line 118 of file FIFO_policy.c. References rx_slot_t::data, data, rx_buffer_t::extract, and rx_buffer.
00118 { 00119 struct fifo_rx_buffer_t *fifo_rx_buffer = (struct fifo_rx_buffer_t *) rx_buffer; 00120 struct fifo_rx_slot_t *tmp = fifo_rx_buffer->extract; 00121 00122 ((struct memory *)data)->mem = tmp->data; 00123 tmp->read = 0x01; 00124 fifo_rx_buffer->extract = fifo_rx_buffer->extract->next; 00125 00126 return tmp->length; 00127 } |
|
Definition at line 55 of file FIFO_policy.c. References rx_buffer_t::first, MAX_FIFO_RX_BUFFER_ENTRIES, PKT_BUF_SZ, rtl_malloc, and rx_buffer.
00055 { 00056 struct fifo_rx_buffer_t *fifo_rx_buffer = (struct fifo_rx_buffer_t *) rx_buffer; 00057 struct fifo_rx_slot_t *tmp; 00058 int i; 00059 tmp = fifo_rx_buffer->first = fifo_rx_buffer->add = fifo_rx_buffer->extract = rtl_malloc(sizeof(struct fifo_rx_slot_t)); 00060 00061 for(i=0;i<(MAX_FIFO_RX_BUFFER_ENTRIES-1); i++){ 00062 tmp->next = rtl_malloc(sizeof(struct fifo_rx_slot_t)); 00063 tmp->read = 0x01; 00064 tmp->length = 0; 00065 tmp->data = rtl_malloc(PKT_BUF_SZ); 00066 tmp = tmp->next; 00067 } 00068 tmp->next = fifo_rx_buffer->first; 00069 tmp->read = 0x01; 00070 tmp->data = rtl_malloc(PKT_BUF_SZ); 00071 00072 return; 00073 } |