1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-29 00:11:16 +01:00

get rid of static buffer

this buffer was used for two types of outgoing packets:
  1. local msg
    - msg can be big, there is is no apriori boundary -> use dynamic
      memory instead
  2. transceiver msg
    - no need to copy msg in this buffer -> transceiver send is blocking
This commit is contained in:
Christian Mehlis 2013-11-21 10:17:55 +01:00
parent 8d9d43fa8c
commit 4ee51da5dd
3 changed files with 18 additions and 12 deletions

View File

@ -58,8 +58,6 @@
/** message buffer */
msg_t msg_buffer_relay[RELAY_MSG_BUFFER_SIZE];
uint8_t packet_out[PAYLOAD_SIZE];
// ----------------------------------------------------------------------
struct ccnl_relay_s theRelay;
@ -124,8 +122,7 @@ void ccnl_ll_TX(struct ccnl_relay_s *ccnl, struct ccnl_if_s *ifc,
{
(void) ccnl; /* unused */
memcpy(&packet_out, &buf->data, buf->datalen);
ifc->sendfunc(packet_out, (uint16_t) buf->datalen, (uint16_t) dest->id);
ifc->sendfunc(buf->data, (uint16_t) buf->datalen, (uint16_t) dest->id);
}
// ----------------------------------------------------------------------

View File

@ -17,6 +17,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
@ -60,13 +61,21 @@ int riot_send_msg(uint8_t *buf, uint16_t size, uint16_t to)
DEBUGMSG(1, "this is a RIOT MSG based connection\n");
DEBUGMSG(1, "size=%" PRIu16 " to=%" PRIu16 "\n", size, to);
static riot_ccnl_msg_t rmsg;
rmsg.payload = buf;
rmsg.size = size;
uint8_t *buf2 = malloc(sizeof(riot_ccnl_msg_t) + size);
if (!buf2) {
DEBUGMSG(1, " malloc failed...dorpping msg!\n");
return 0;
}
riot_ccnl_msg_t *rmsg = (riot_ccnl_msg_t *) buf2;
rmsg->payload = buf2 + sizeof(riot_ccnl_msg_t);
rmsg->size = size;
memcpy(rmsg->payload, buf, size);
msg_t m;
m.type = CCNL_RIOT_MSG;
m.content.ptr = (char *) &rmsg;
m.content.ptr = (char *) rmsg;
DEBUGMSG(1, "sending msg to pid=%u\n", to);
msg_send(&m, to, 1);

View File

@ -70,11 +70,10 @@ int ccnl_riot_client_get(unsigned int relay_pid, char *name, char *reply_buf)
msg_receive(&rep);
riot_ccnl_msg_t *rmsg_reply = (riot_ccnl_msg_t *) rep.content.ptr;
memcpy(&compat_small_buf, rmsg_reply->payload, rmsg_reply->size);
unsigned char *data = compat_small_buf;
int datalen = (int) rmsg_reply->size;
DEBUGMSG(1, "%d bytes left; msg from=%u '%s'\n", datalen, rep.sender_pid, compat_small_buf);
unsigned char *data = rmsg_reply->payload;
int datalen = (int) rmsg_reply->size;
DEBUGMSG(1, "%d bytes left; msg from=%u '%s'\n", datalen, rep.sender_pid, data);
int scope = 3, aok = 3, minsfx = 0, maxsfx = CCNL_MAX_NAME_COMP,
contlen = 0;
@ -96,6 +95,7 @@ int ccnl_riot_client_get(unsigned int relay_pid, char *name, char *reply_buf)
free_prefix(p);
free_3ptr_list(buf, nonce, ppkd);
ccnl_free(rmsg_reply);
if (contlen < CCNL_RIOT_CHUNK_SIZE || CCNL_RIOT_CHUNK_SIZE < contlen) {
/* last chunk */