Merge pull request #462 from nfi/contrib/slip-uip-llh-len
Updated users of the SLIP driver to respect UIP_LLH_LEN
This commit is contained in:
commit
fe1320e39e
|
@ -187,8 +187,8 @@ slip_radio_cmd_handler(const uint8_t *data, int len)
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else if(uip_buf[0] == '?') {
|
} else if(data[0] == '?') {
|
||||||
LOG_DBG("Got request message of type %c\n", uip_buf[1]);
|
LOG_DBG("Got request message of type %c\n", data[1]);
|
||||||
if(data[1] == 'M') {
|
if(data[1] == 'M') {
|
||||||
/* this is just a test so far... just to see if it works */
|
/* this is just a test so far... just to see if it works */
|
||||||
uip_buf[0] = '!';
|
uip_buf[0] = '!';
|
||||||
|
@ -226,8 +226,9 @@ slip_radio_cmd_handler(const uint8_t *data, int len)
|
||||||
static void
|
static void
|
||||||
slip_input_callback(void)
|
slip_input_callback(void)
|
||||||
{
|
{
|
||||||
LOG_DBG("SR-SIN: %u '%c%c'\n", uip_len, uip_buf[0], uip_buf[1]);
|
LOG_DBG("SR-SIN: %u '%c%c'\n", uip_len,
|
||||||
if(!cmd_input(uip_buf, 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);
|
cmd_send((uint8_t *)"EUnknown command", 16);
|
||||||
}
|
}
|
||||||
uip_clear_buf();
|
uip_clear_buf();
|
||||||
|
|
|
@ -57,24 +57,24 @@ static void
|
||||||
input_callback(void)
|
input_callback(void)
|
||||||
{
|
{
|
||||||
/*PRINTF("SIN: %u\n", uip_len);*/
|
/*PRINTF("SIN: %u\n", uip_len);*/
|
||||||
if(uip_buf[0] == '!') {
|
if(uip_buf[UIP_LLH_LEN] == '!') {
|
||||||
PRINTF("Got configuration message of type %c\n", uip_buf[1]);
|
PRINTF("Got configuration message of type %c\n", uip_buf[UIP_LLH_LEN + 1]);
|
||||||
uip_clear_buf();
|
uip_clear_buf();
|
||||||
#if 0
|
#if 0
|
||||||
if(uip_buf[1] == 'P') {
|
if(uip_buf[UIP_LLH_LEN + 1] == 'P') {
|
||||||
uip_ipaddr_t prefix;
|
uip_ipaddr_t prefix;
|
||||||
/* Here we set a prefix !!! */
|
/* Here we set a prefix !!! */
|
||||||
memset(&prefix, 0, 16);
|
memset(&prefix, 0, 16);
|
||||||
memcpy(&prefix, &uip_buf[2], 8);
|
memcpy(&prefix, &uip_buf[UIP_LLH_LEN + 2], 8);
|
||||||
PRINTF("Setting prefix ");
|
PRINTF("Setting prefix ");
|
||||||
PRINT6ADDR(&prefix);
|
PRINT6ADDR(&prefix);
|
||||||
PRINTF("\n");
|
PRINTF("\n");
|
||||||
set_prefix_64(&prefix);
|
set_prefix_64(&prefix);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else if(uip_buf[0] == '?') {
|
} else if(uip_buf[UIP_LLH_LEN] == '?') {
|
||||||
PRINTF("Got request message of type %c\n", uip_buf[1]);
|
PRINTF("Got request message of type %c\n", uip_buf[UIP_LLH_LEN + 1]);
|
||||||
if(uip_buf[1] == 'M') {
|
if(uip_buf[UIP_LLH_LEN + 1] == 'M') {
|
||||||
const char *hexchar = "0123456789abcdef";
|
const char *hexchar = "0123456789abcdef";
|
||||||
int j;
|
int j;
|
||||||
/* this is just a test so far... just to see if it works */
|
/* 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_buf[3 + j * 2] = hexchar[uip_lladdr.addr[j] & 15];
|
||||||
}
|
}
|
||||||
uip_len = 18;
|
uip_len = 18;
|
||||||
slip_send();
|
slip_write(uip_buf, uip_len);
|
||||||
|
|
||||||
}
|
}
|
||||||
uip_clear_buf();
|
uip_clear_buf();
|
||||||
} else {
|
} else {
|
||||||
|
@ -147,6 +146,3 @@ const struct uip_fallback_interface ip64_slip_interface = {
|
||||||
init, output
|
init, output
|
||||||
};
|
};
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ request_prefix(void)
|
||||||
uip_buf[0] = '?';
|
uip_buf[0] = '?';
|
||||||
uip_buf[1] = 'P';
|
uip_buf[1] = 'P';
|
||||||
uip_len = 2;
|
uip_len = 2;
|
||||||
slip_send();
|
slip_write(uip_buf, uip_len);
|
||||||
uip_clear_buf();
|
uip_clear_buf();
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
@ -70,22 +70,27 @@ static void
|
||||||
slip_input_callback(void)
|
slip_input_callback(void)
|
||||||
{
|
{
|
||||||
LOG_DBG("SIN: %u\n", uip_len);
|
LOG_DBG("SIN: %u\n", uip_len);
|
||||||
if(uip_buf[0] == '!') {
|
if(uip_buf[UIP_LLH_LEN] == '!') {
|
||||||
LOG_INFO("Got configuration message of type %c\n", uip_buf[1]);
|
LOG_INFO("Got configuration message of type %c\n",
|
||||||
uip_clear_buf();
|
uip_buf[UIP_LLH_LEN + 1]);
|
||||||
if(uip_buf[1] == 'P') {
|
if(uip_buf[UIP_LLH_LEN + 1] == 'P') {
|
||||||
uip_ipaddr_t prefix;
|
uip_ipaddr_t prefix;
|
||||||
/* Here we set a prefix !!! */
|
/* Here we set a prefix !!! */
|
||||||
memset(&prefix, 0, 16);
|
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("Setting prefix ");
|
||||||
LOG_INFO_6ADDR(&prefix);
|
LOG_INFO_6ADDR(&prefix);
|
||||||
LOG_INFO_("\n");
|
LOG_INFO_("\n");
|
||||||
set_prefix_64(&prefix);
|
set_prefix_64(&prefix);
|
||||||
}
|
}
|
||||||
} else if(uip_buf[0] == '?') {
|
uip_clear_buf();
|
||||||
LOG_INFO("Got request message of type %c\n", uip_buf[1]);
|
|
||||||
if(uip_buf[1] == 'M') {
|
} 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";
|
char *hexchar = "0123456789abcdef";
|
||||||
int j;
|
int j;
|
||||||
/* this is just a test so far... just to see if it works */
|
/* 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_buf[3 + j * 2] = hexchar[uip_lladdr.addr[j] & 15];
|
||||||
}
|
}
|
||||||
uip_len = 18;
|
uip_len = 18;
|
||||||
slip_send();
|
slip_write(uip_buf, uip_len);
|
||||||
}
|
}
|
||||||
uip_clear_buf();
|
uip_clear_buf();
|
||||||
}
|
} else {
|
||||||
/* Save the last sender received over SLIP to avoid bouncing the
|
/* Save the last sender received over SLIP to avoid bouncing the
|
||||||
packet back if no route is found */
|
packet back if no route is found */
|
||||||
uip_ipaddr_copy(&last_sender, &UIP_IP_BUF->srcipaddr);
|
uip_ipaddr_copy(&last_sender, &UIP_IP_BUF->srcipaddr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
init(void)
|
init(void)
|
||||||
|
|
Loading…
Reference in New Issue