Merge pull request #1269 from tadodotcom/tmp-uip-fallback-iface
More flexibility for the fallback interface
This commit is contained in:
commit
2daa3d7377
|
@ -572,7 +572,16 @@ tcpip_ipv6_output(void)
|
|||
/* This should be copied from the ext header... */
|
||||
UIP_IP_BUF->proto = proto;
|
||||
}
|
||||
UIP_FALLBACK_INTERFACE.output();
|
||||
/* Inform the other end that the destination is not reachable. If it's
|
||||
* not informed routes might get lost unexpectedly until there's a need
|
||||
* to send a new packet to the peer */
|
||||
if(UIP_FALLBACK_INTERFACE.output() < 0) {
|
||||
PRINTF("FALLBACK: output error. Reporting DST UNREACH\n");
|
||||
uip_icmp6_error_output(ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADDR, 0);
|
||||
uip_flags = 0;
|
||||
tcpip_ipv6_output();
|
||||
return;
|
||||
}
|
||||
#else
|
||||
PRINTF("tcpip_ipv6_output: Destination off-link but no route\n");
|
||||
#endif /* !UIP_FALLBACK_INTERFACE */
|
||||
|
|
|
@ -1429,7 +1429,13 @@ extern struct uip_udp_conn uip_udp_conns[UIP_UDP_CONNS];
|
|||
|
||||
struct uip_fallback_interface {
|
||||
void (*init)(void);
|
||||
void (*output)(void);
|
||||
/**
|
||||
* \retval >=0
|
||||
* in case of success
|
||||
* \retval <0
|
||||
* in case of failure
|
||||
*/
|
||||
int (*output)(void);
|
||||
};
|
||||
|
||||
#if UIP_CONF_ICMP6
|
||||
|
|
|
@ -84,7 +84,7 @@ init(void)
|
|||
printf("ip64-eth-interface: init\n");
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
static int
|
||||
output(void)
|
||||
{
|
||||
int len, ret;
|
||||
|
@ -114,7 +114,7 @@ output(void)
|
|||
printf("Create request\n");
|
||||
len = ip64_arp_create_arp_request(ip64_packet_buffer,
|
||||
&ip64_packet_buffer[sizeof(struct ip64_eth_hdr)]);
|
||||
IP64_ETH_DRIVER.output(ip64_packet_buffer, len);
|
||||
return IP64_ETH_DRIVER.output(ip64_packet_buffer, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ init(void)
|
|||
slip_set_input_callback(input_callback);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
static int
|
||||
output(void)
|
||||
{
|
||||
int len;
|
||||
|
@ -138,8 +138,10 @@ output(void)
|
|||
memcpy(&uip_buf[UIP_LLH_LEN], ip64_packet_buffer, len);
|
||||
uip_len = len;
|
||||
slip_send();
|
||||
return len;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
const struct uip_fallback_interface ip64_slip_interface = {
|
||||
|
|
|
@ -192,7 +192,7 @@ uint8_t wfall_send(const uip_lladdr_t *lladdr);
|
|||
static uip_ipaddr_t last_sender;
|
||||
#endif
|
||||
|
||||
static void
|
||||
static int
|
||||
output(void)
|
||||
{
|
||||
#if FALLBACK_HAS_ETHERNET_HEADERS&&0
|
||||
|
@ -203,8 +203,8 @@ output(void)
|
|||
}
|
||||
uip_ipaddr_copy(&last_sender, &UIP_IP_BUF->srcipaddr);
|
||||
#endif
|
||||
PRINTF("FUT: %u\n", uip_len);
|
||||
wfall_send(0);
|
||||
PRINTF("FUT: %u\n", uip_len);
|
||||
return wfall_send(0);
|
||||
}
|
||||
|
||||
const struct uip_fallback_interface rpl_interface = {
|
||||
|
|
|
@ -83,7 +83,7 @@ init(void)
|
|||
slip_set_input_callback(slip_input_callback);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
static int
|
||||
output(void)
|
||||
{
|
||||
if(uip_ipaddr_cmp(&last_sender, &UIP_IP_BUF->srcipaddr)) {
|
||||
|
@ -94,6 +94,7 @@ output(void)
|
|||
PRINTF("SUT: %u\n", uip_len);
|
||||
slip_send();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
struct uip_fallback_interface slip_interface = {
|
||||
|
|
|
@ -222,13 +222,15 @@ tun_init()
|
|||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
static int
|
||||
tun_output(uint8_t *data, int len)
|
||||
{
|
||||
/* fprintf(stderr, "*** Writing to tun...%d\n", len); */
|
||||
if(write(tunfd, data, len) != len) {
|
||||
err(1, "serial_to_tun: write");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
|
@ -246,13 +248,14 @@ init(void)
|
|||
{
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
static int
|
||||
output(void)
|
||||
{
|
||||
PRINTF("SUT: %u\n", uip_len);
|
||||
if(uip_len > 0) {
|
||||
tun_output(&uip_buf[UIP_LLH_LEN], uip_len);
|
||||
return tun_output(&uip_buf[UIP_LLH_LEN], uip_len);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ init(void)
|
|||
slip_set_input_callback(slip_input_callback);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
static int
|
||||
output(void)
|
||||
{
|
||||
if(uip_ipaddr_cmp(&last_sender, &UIP_IP_BUF->srcipaddr)) {
|
||||
|
@ -115,6 +115,7 @@ output(void)
|
|||
// PRINTF("SUT: %u\n", uip_len);
|
||||
slip_send();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -84,7 +84,7 @@ init(void)
|
|||
slip_set_input_callback(slip_input_callback);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
static int
|
||||
output(void)
|
||||
{
|
||||
if(uip_ipaddr_cmp(&last_sender, &UIP_IP_BUF->srcipaddr)) {
|
||||
|
@ -95,6 +95,7 @@ output(void)
|
|||
PRINTF("SUT: %u\n", uip_len);
|
||||
slip_send();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
const struct uip_fallback_interface slip_interface = {
|
||||
|
|
|
@ -132,7 +132,7 @@ init(void)
|
|||
{
|
||||
}
|
||||
void mac_LowpanToEthernet(void);
|
||||
static void
|
||||
static int
|
||||
output(void)
|
||||
{
|
||||
// if(uip_ipaddr_cmp(&last_sender, &UIP_IP_BUF->srcipaddr)) {
|
||||
|
@ -142,6 +142,7 @@ output(void)
|
|||
PRINTD("SUT: %u\n", uip_len);
|
||||
mac_LowpanToEthernet(); //bounceback trap is done in lowpanToEthernet
|
||||
// }
|
||||
return 0;
|
||||
}
|
||||
const struct uip_fallback_interface rpl_interface = {
|
||||
init, output
|
||||
|
|
Loading…
Reference in a new issue