net: uip: Return correct packet discard status to caller

Fixed the compiler warning about not returning correct value to
caller. Now we return correct value if neighbor solicitation was
sent properly.

Change-Id: Ie28a2ee417bcdf3eb9b24ab91a49c688992e7420
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2015-06-01 10:57:22 +03:00 committed by Anas Nashif
commit 05c97c195e
12 changed files with 41 additions and 28 deletions

View file

@ -183,9 +183,10 @@ check_for_tcp_syn(struct net_buf *buf)
#endif /* UIP_TCP || UIP_CONF_IP_FORWARD */
}
/*---------------------------------------------------------------------------*/
static void
static uint8_t
packet_input(struct net_buf *buf)
{
uint8_t ret = 0;
#if UIP_CONF_IP_FORWARD
if(uip_len > 0) {
tcpip_is_forwarding = 1;
@ -211,8 +212,8 @@ packet_input(struct net_buf *buf)
#else /* UIP_CONF_IP_FORWARD */
if(uip_len(buf) > 0) {
check_for_tcp_syn(buf);
uip_input(buf);
if(uip_len(buf) > 0) {
ret = uip_input(buf);
if(ret && uip_len(buf) > 0) {
#if UIP_CONF_TCP_SPLIT
uip_split_output(buf);
#else /* UIP_CONF_TCP_SPLIT */
@ -227,6 +228,7 @@ packet_input(struct net_buf *buf)
}
}
#endif /* UIP_CONF_IP_FORWARD */
return ret;
}
/*---------------------------------------------------------------------------*/
#if UIP_TCP
@ -533,7 +535,12 @@ eventhandler(process_event_t ev, process_data_t data, struct net_buf *buf)
#endif /* UIP_UDP */
case PACKET_INPUT:
packet_input(buf);
if (!packet_input(buf)) {
/* failure, discard the net_buf here because the
* return value cannot be passed to driver any longer
*/
net_buf_put(buf);
}
break;
};
}
@ -692,6 +699,8 @@ tcpip_ipv6_output(struct net_buf *buf)
stimer_set(&nbr->sendns, uip_ds6_if.retrans_timer / 1000);
nbr->nscount = 1;
}
return 1; /* packet was passed to network successfully */
#endif /* UIP_ND6_SEND_NA */
} else {
#if UIP_ND6_SEND_NA
@ -741,7 +750,7 @@ tcpip_ipv6_output(struct net_buf *buf)
return ret;
}
return;
return 0; /* discard packet */
}
/* Multicast IP destination address. */
ret = tcpip_output(buf, NULL);

View file

@ -1544,7 +1544,7 @@ uip_ext_hdr_options_process(); */
*
* The actual uIP function which does all the work.
*/
void uip_process(struct net_buf *buf, uint8_t flag);
uint8_t uip_process(struct net_buf *buf, uint8_t flag);
/* The following flags are passed as an argument to the uip_process()
function. They are used to distinguish between the two cases where

View file

@ -1602,7 +1602,7 @@ output(struct net_buf *buf, const uip_lladdr_t *localdest)
* \note We do not check for overlapping sicslowpan fragments
* (it is a SHALL in the RFC 4944 and should never happen)
*/
static void
static uint8_t
input(struct net_buf *buf)
{
/* size of the IP packet (read from fragment) */
@ -1713,7 +1713,7 @@ input(struct net_buf *buf)
* being reassembled or the packet is not a fragment.
*/
PRINTFI("sicslowpan input: Dropping 6lowpan packet that is not a fragment of the packet currently being reassembled\n");
return;
return 0;
}
} else {
/*
@ -1724,7 +1724,7 @@ input(struct net_buf *buf)
/* We are currently not reassembling a packet, but have received a packet fragment
* that is not the first one. */
if(is_fragment && !first_fragment) {
return;
return 0;
}
sicslowpan_len(buf) = frag_size;
@ -1771,7 +1771,7 @@ input(struct net_buf *buf)
/* unknown header */
PRINTFI("sicslowpan input: unknown dispatch: %u\n",
PACKETBUF_HC1_PTR(buf)[PACKETBUF_HC1_DISPATCH]);
return;
return 0;
}
@ -1787,7 +1787,7 @@ input(struct net_buf *buf)
*/
if(packetbuf_datalen(buf) < uip_packetbuf_hdr_len(buf)) {
PRINTF("SICSLOWPAN: packet dropped due to header > total packet\n");
return;
return 0;
}
uip_packetbuf_payload_len(buf) = packetbuf_datalen(buf) - uip_packetbuf_hdr_len(buf);
@ -1800,7 +1800,7 @@ input(struct net_buf *buf)
"SICSLOWPAN: packet dropped, minimum required SICSLOWPAN_IP_BUF size: %d+%d+%d+%d=%d (current size: %d)\n",
UIP_LLH_LEN, uip_uncomp_hdr_len(buf), (uint16_t)(frag_offset << 3),
uip_packetbuf_payload_len(buf), req_size, sizeof(sicslowpan_buf(buf)));
return;
return 0;
}
}
@ -1865,9 +1865,11 @@ input(struct net_buf *buf)
#endif
tcpip_input(buf);
return 1;
#if SICSLOWPAN_CONF_FRAG
}
#endif /* SICSLOWPAN_CONF_FRAG */
return 0;
}
/** @} */

View file

@ -949,7 +949,7 @@ ext_hdr_options_process(struct net_buf *buf)
/*---------------------------------------------------------------------------*/
void
uint8_t
uip_process(struct net_buf *buf, uint8_t flag)
{
#if UIP_TCP
@ -2321,7 +2321,7 @@ uip_process(struct net_buf *buf, uint8_t flag)
UIP_STAT(++uip_stat.ip.sent);
/* Return and let the caller do the actual transmission. */
uip_flags(buf) = 0;
return;
return 1;
drop:
/* If there is an error, then just return the buffer to pool */
@ -2333,7 +2333,7 @@ uip_process(struct net_buf *buf, uint8_t flag)
uip_ext_len(buf) = 0;
uip_ext_bitmap(buf) = 0;
uip_flags(buf) = 0;
return;
return 0;
}
/*---------------------------------------------------------------------------*/
uint16_t

View file

@ -85,7 +85,7 @@ struct llsec_driver {
* Decrypts incoming frames;
* filters out injected or replayed frames.
*/
void (* input)(struct net_buf *buf);
uint8_t (* input)(struct net_buf *buf);
/** Returns the security-related overhead per frame in bytes */
uint8_t (* get_overhead)(void);

View file

@ -80,10 +80,10 @@ on_frame_created(void)
return 1;
}
/*---------------------------------------------------------------------------*/
static void
static uint8_t
input(struct net_buf *buf)
{
NETSTACK_NETWORK.input(buf);
return NETSTACK_NETWORK.input(buf);
}
/*---------------------------------------------------------------------------*/
static uint8_t

View file

@ -428,12 +428,13 @@ send_packet(struct net_buf *buf, mac_callback_t sent, void *ptr)
PRINTF("csma: could not allocate neighbor, dropping packet\n");
}
mac_call_sent_callback(buf, sent, ptr, MAC_TX_ERR, 1);
return 0;
}
/*---------------------------------------------------------------------------*/
static void
static uint8_t
input_packet(struct net_buf *buf)
{
NETSTACK_LLSEC.input(buf);
return NETSTACK_LLSEC.input(buf);
}
/*---------------------------------------------------------------------------*/
static int

View file

@ -63,7 +63,7 @@ struct mac_driver {
uint8_t (* send)(struct net_buf *buf, mac_callback_t sent_callback, void *ptr);
/** Callback for getting notified of incoming packet. */
void (* input)(struct net_buf *buf);
uint8_t (* input)(struct net_buf *buf);
/** Turn the MAC layer on. */
int (* on)(void);

View file

@ -79,7 +79,7 @@ struct rdc_driver {
uint8_t (* send_list)(struct net_buf *buf, mac_callback_t sent_callback, void *ptr, struct rdc_buf_list *list);
/** Callback for getting notified of incoming packet. */
void (* input)(struct net_buf *buf);
uint8_t (* input)(struct net_buf *buf);
/** Turn the MAC layer on. */
int (* on)(void);

View file

@ -200,7 +200,7 @@ send_list(struct net_buf *buf, mac_callback_t sent, void *ptr, struct rdc_buf_li
return 1;
}
/*---------------------------------------------------------------------------*/
static void
static uint8_t
input_packet(struct net_buf *buf)
{
frame802154_t frame;
@ -239,13 +239,12 @@ input_packet(struct net_buf *buf)
PRINTF(" receiver ");
PRINTLLADDR(packetbuf_addr(buf, PACKETBUF_ADDR_RECEIVER));
PRINTF(" len %u\n", packetbuf_datalen(buf));
NETSTACK_MAC.input(buf);
return;
return NETSTACK_MAC.input(buf);
} else {
PRINTF("6MAC: failed to parse hdr\n");
}
error:
net_buf_put(buf);
return 0;
}
/*---------------------------------------------------------------------------*/
static int

View file

@ -123,7 +123,7 @@ struct network_driver {
void (* init)(void);
/** Callback for getting notified of incoming packet. */
void (* input)(struct net_buf *buf);
uint8_t (* input)(struct net_buf *buf);
};
extern const struct network_driver NETSTACK_NETWORK;

View file

@ -75,7 +75,7 @@ init(void)
tcpip_set_outputfunc(uip_driver_send);
}
/*--------------------------------------------------------------------*/
static void
static uint8_t
input(struct net_buf *buf)
{
PRINTF("uip-driver(%p): input %d bytes\n", buf, packetbuf_datalen(buf));
@ -84,9 +84,11 @@ input(struct net_buf *buf)
memcpy(&uip_buf(buf)[UIP_LLH_LEN], packetbuf_dataptr(buf), packetbuf_datalen(buf));
uip_len(buf) = packetbuf_datalen(buf);
tcpip_input(buf);
return 1;
} else {
PRINTF("datalen %d MAX %d\n", packetbuf_datalen(buf), UIP_BUFSIZE - UIP_LLH_LEN);
UIP_LOG("uip-driver: too long packet discarded");
return 0;
}
}
/*--------------------------------------------------------------------*/