The latest development version of this page may be more current than this released 3.7.0 version.

Network Core Helpers

Overview

The network subsystem contains two functions for sending and receiving data from the network. The net_recv_data() is typically used by network device driver when the received network data needs to be pushed up in the network stack for further processing. All the data is received via a network interface which is typically created by the device driver.

For sending, the net_send_data() can be used. Typically applications do not call this function directly as there is the BSD Sockets API for sending and receiving network data.

API Reference

group net_core

Network core library.

Enums

enum net_verdict

Net Verdict.

Values:

enumerator NET_OK

Packet has been taken care of.

enumerator NET_CONTINUE

Packet has not been touched, other part should decide about its fate.

enumerator NET_DROP

Packet must be dropped.

Functions

int net_recv_data(struct net_if *iface, struct net_pkt *pkt)

Called by lower network stack or network device driver when a network packet has been received.

The function will push the packet up in the network stack for further processing.

Parameters:
  • iface – Network interface where the packet was received.

  • pkt – Network packet data.

Returns:

0 if ok, <0 if error.

int net_send_data(struct net_pkt *pkt)

Send data to network.

Send data to network. This should not be used normally by applications as it requires that the network packet is properly constructed.

Parameters:
  • pkt – Network packet.

Returns:

0 if ok, <0 if error. If <0 is returned, then the caller needs to unref the pkt in order to avoid memory leak.