ON Semiconductor / mbed-os

Dependents:   mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510

Embed: (wiki syntax)

« Back to documentation index

raw.c File Reference

raw.c File Reference

Implementation of raw protocol PCBs for low-level handling of different types of protocols besides (or overriding) those already available in lwIP. More...

Go to the source code of this file.

Functions

u8_t raw_input (struct pbuf *p, struct netif *inp)
 Determine if in incoming IP packet is covered by a RAW PCB and if so, pass it to a user-provided receive callback function.
err_t raw_bind (struct raw_pcb *pcb, ip_addr_t *ipaddr)
 Bind a RAW PCB.
err_t raw_connect (struct raw_pcb *pcb, ip_addr_t *ipaddr)
 Connect an RAW PCB.
void raw_recv (struct raw_pcb *pcb, raw_recv_fn recv, void *recv_arg)
 Set the callback function for received packets that match the raw PCB's protocol and binding.
err_t raw_sendto (struct raw_pcb *pcb, struct pbuf *p, ip_addr_t *ipaddr)
 Send the raw IP packet to the given address.
err_t raw_send (struct raw_pcb *pcb, struct pbuf *p)
 Send the raw IP packet to the address given by raw_connect()
void raw_remove (struct raw_pcb *pcb)
 Remove an RAW PCB.
struct raw_pcbraw_new (u8_t proto)
 Create a RAW PCB.

Variables

static struct raw_pcbraw_pcbs
 The list of RAW PCBs.

Detailed Description

Implementation of raw protocol PCBs for low-level handling of different types of protocols besides (or overriding) those already available in lwIP.

Definition in file raw.c.


Function Documentation

err_t raw_bind ( struct raw_pcb pcb,
ip_addr_t ipaddr 
)

Bind a RAW PCB.

Parameters:
pcbRAW PCB to be bound with a local address ipaddr.
ipaddrlocal IP address to bind with. Use IP_ADDR_ANY to bind to all local interfaces.
Returns:
lwIP error code.
  • ERR_OK. Successful. No error occured.
  • ERR_USE. The specified IP address is already bound to by another RAW PCB.
See also:
raw_disconnect()

Definition at line 142 of file raw.c.

err_t raw_connect ( struct raw_pcb pcb,
ip_addr_t ipaddr 
)

Connect an RAW PCB.

This function is required by upper layers of lwip. Using the raw api you could use raw_sendto() instead

This will associate the RAW PCB with the remote address.

Parameters:
pcbRAW PCB to be connected with remote address ipaddr and port.
ipaddrremote IP address to connect with.
Returns:
lwIP error code
See also:
raw_disconnect() and raw_sendto()

Definition at line 162 of file raw.c.

u8_t raw_input ( struct pbuf p,
struct netif inp 
)

Determine if in incoming IP packet is covered by a RAW PCB and if so, pass it to a user-provided receive callback function.

Given an incoming IP datagram (as a chain of pbufs) this function finds a corresponding RAW PCB and calls the corresponding receive callback function.

Parameters:
ppbuf to be demultiplexed to a RAW PCB.
inpnetwork interface on which the datagram was received.
Returns:
- 1 if the packet has been eaten by a RAW PCB receive callback function. The caller MAY NOT not reference the packet any longer, and MAY NOT call pbuf_free().
- 0 if packet is not eaten (pbuf is still referenced by the caller).

Definition at line 76 of file raw.c.

err_t raw_sendto ( struct raw_pcb pcb,
struct pbuf p,
ip_addr_t ipaddr 
)

Send the raw IP packet to the given address.

Note that actually you cannot modify the IP headers (this is inconsistent with the receive callback where you actually get the IP headers), you can only specify the IP payload here. It requires some more changes in lwIP. (there will be a raw_send() function then.)

Parameters:
pcbthe raw pcb which to send
pthe IP payload to send
ipaddrthe destination address of the IP packet

Definition at line 203 of file raw.c.


Variable Documentation

struct raw_pcb* raw_pcbs [static]

The list of RAW PCBs.

Definition at line 56 of file raw.c.