net: Add function to receive an IP packet from the driver
After an IP packet has been (reassembled and) received, the driver submits the IP packet to the IP stack. Change-Id: Icbd1e7740ce59db16bc1d61002420e86ab101d2d Signed-off-by: Patrik Flykt <patrik.flykt@linux.intel.com> Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
5d3685f85f
commit
29a61aff9c
2 changed files with 18 additions and 1 deletions
|
@ -108,6 +108,9 @@ void net_unregister_driver(struct net_driver *drv);
|
|||
*/
|
||||
int net_set_mac(uint8_t *mac, uint8_t len);
|
||||
|
||||
/* Called by driver when an IP packet has been received */
|
||||
int net_recv(struct net_buf *buf);
|
||||
|
||||
void net_context_init(void);
|
||||
|
||||
#endif /* __NET_CORE_H */
|
||||
|
|
|
@ -95,6 +95,18 @@ int net_send(struct net_buf *buf)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Called by driver when an IP packet has been received */
|
||||
int net_recv(struct net_buf *buf)
|
||||
{
|
||||
if (buf->len == 0) {
|
||||
return -ENODATA;
|
||||
}
|
||||
|
||||
nano_fifo_put(&netdev.rx_queue, buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void udp_packet_receive(struct simple_udp_connection *c,
|
||||
const uip_ipaddr_t *source_addr,
|
||||
uint16_t source_port,
|
||||
|
@ -263,9 +275,11 @@ static void net_rx_fiber(void)
|
|||
NET_DBG("Starting RX fiber\n");
|
||||
|
||||
while (1) {
|
||||
/* Wait next packet from network, pass it to IP stack */
|
||||
/* Wait next packet from network */
|
||||
buf = nano_fifo_get_wait(&netdev.rx_queue);
|
||||
|
||||
/* TBD: Pass it to IP stack */
|
||||
|
||||
net_buf_put(buf);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue