Updated users of SLIP to respect UIP_LLH_LEN

This commit is contained in:
Niclas Finne 2018-04-27 01:43:19 +02:00
parent 3d0cd3b16f
commit 274a5daa7d
3 changed files with 32 additions and 29 deletions

View File

@ -187,8 +187,8 @@ slip_radio_cmd_handler(const uint8_t *data, int len)
}
return 1;
}
} else if(uip_buf[0] == '?') {
LOG_DBG("Got request message of type %c\n", uip_buf[1]);
} else if(data[0] == '?') {
LOG_DBG("Got request message of type %c\n", data[1]);
if(data[1] == 'M') {
/* this is just a test so far... just to see if it works */
uip_buf[0] = '!';
@ -226,8 +226,9 @@ slip_radio_cmd_handler(const uint8_t *data, int len)
static void
slip_input_callback(void)
{
LOG_DBG("SR-SIN: %u '%c%c'\n", uip_len, uip_buf[0], uip_buf[1]);
if(!cmd_input(uip_buf, uip_len)) {
LOG_DBG("SR-SIN: %u '%c%c'\n", uip_len,
uip_buf[UIP_LLH_LEN], uip_buf[UIP_LLH_LEN + 1]);
if(!cmd_input(&uip_buf[UIP_LLH_LEN], uip_len)) {
cmd_send((uint8_t *)"EUnknown command", 16);
}
uip_clear_buf();

View File

@ -57,24 +57,24 @@ static void
input_callback(void)
{
/*PRINTF("SIN: %u\n", uip_len);*/
if(uip_buf[0] == '!') {
PRINTF("Got configuration message of type %c\n", uip_buf[1]);
if(uip_buf[UIP_LLH_LEN] == '!') {
PRINTF("Got configuration message of type %c\n", uip_buf[UIP_LLH_LEN + 1]);
uip_clear_buf();
#if 0
if(uip_buf[1] == 'P') {
if(uip_buf[UIP_LLH_LEN + 1] == 'P') {
uip_ipaddr_t prefix;
/* Here we set a prefix !!! */
memset(&prefix, 0, 16);
memcpy(&prefix, &uip_buf[2], 8);
memcpy(&prefix, &uip_buf[UIP_LLH_LEN + 2], 8);
PRINTF("Setting prefix ");
PRINT6ADDR(&prefix);
PRINTF("\n");
set_prefix_64(&prefix);
}
#endif
} else if(uip_buf[0] == '?') {
PRINTF("Got request message of type %c\n", uip_buf[1]);
if(uip_buf[1] == 'M') {
} else if(uip_buf[UIP_LLH_LEN] == '?') {
PRINTF("Got request message of type %c\n", uip_buf[UIP_LLH_LEN + 1]);
if(uip_buf[UIP_LLH_LEN + 1] == 'M') {
const char *hexchar = "0123456789abcdef";
int j;
/* this is just a test so far... just to see if it works */
@ -84,8 +84,7 @@ input_callback(void)
uip_buf[3 + j * 2] = hexchar[uip_lladdr.addr[j] & 15];
}
uip_len = 18;
slip_send();
slip_write(uip_buf, uip_len);
}
uip_clear_buf();
} else {
@ -147,6 +146,3 @@ const struct uip_fallback_interface ip64_slip_interface = {
init, output
};
/*---------------------------------------------------------------------------*/

View File

@ -62,7 +62,7 @@ request_prefix(void)
uip_buf[0] = '?';
uip_buf[1] = 'P';
uip_len = 2;
slip_send();
slip_write(uip_buf, uip_len);
uip_clear_buf();
}
/*---------------------------------------------------------------------------*/
@ -70,22 +70,27 @@ static void
slip_input_callback(void)
{
LOG_DBG("SIN: %u\n", uip_len);
if(uip_buf[0] == '!') {
LOG_INFO("Got configuration message of type %c\n", uip_buf[1]);
uip_clear_buf();
if(uip_buf[1] == 'P') {
if(uip_buf[UIP_LLH_LEN] == '!') {
LOG_INFO("Got configuration message of type %c\n",
uip_buf[UIP_LLH_LEN + 1]);
if(uip_buf[UIP_LLH_LEN + 1] == 'P') {
uip_ipaddr_t prefix;
/* Here we set a prefix !!! */
memset(&prefix, 0, 16);
memcpy(&prefix, &uip_buf[2], 8);
memcpy(&prefix, &uip_buf[UIP_LLH_LEN + 2], 8);
uip_clear_buf();
LOG_INFO("Setting prefix ");
LOG_INFO_6ADDR(&prefix);
LOG_INFO_("\n");
set_prefix_64(&prefix);
}
} else if(uip_buf[0] == '?') {
LOG_INFO("Got request message of type %c\n", uip_buf[1]);
if(uip_buf[1] == 'M') {
uip_clear_buf();
} else if(uip_buf[UIP_LLH_LEN] == '?') {
LOG_INFO("Got request message of type %c\n", uip_buf[UIP_LLH_LEN + 1]);
if(uip_buf[UIP_LLH_LEN + 1] == 'M') {
char *hexchar = "0123456789abcdef";
int j;
/* this is just a test so far... just to see if it works */
@ -95,14 +100,15 @@ slip_input_callback(void)
uip_buf[3 + j * 2] = hexchar[uip_lladdr.addr[j] & 15];
}
uip_len = 18;
slip_send();
slip_write(uip_buf, uip_len);
}
uip_clear_buf();
}
} else {
/* Save the last sender received over SLIP to avoid bouncing the
packet back if no route is found */
uip_ipaddr_copy(&last_sender, &UIP_IP_BUF->srcipaddr);
}
}
/*---------------------------------------------------------------------------*/
static void
init(void)