SAMV71 Xplained Ultra Software Package 1.5

raw.c File Reference

#include "lwip/opt.h"
#include "lwip/def.h"
#include "lwip/memp.h"
#include "lwip/inet.h"
#include "lwip/ip_addr.h"
#include "lwip/netif.h"
#include "lwip/raw.h"
#include "lwip/stats.h"
#include "lwip/snmp.h"
#include "arch/perf.h"
#include <string.h>

Go to the source code of this file.

Functions

u8_t raw_input (struct pbuf *p, struct netif *inp)
err_t raw_bind (struct raw_pcb *pcb, struct ip_addr *ipaddr)
err_t raw_connect (struct raw_pcb *pcb, struct ip_addr *ipaddr)
void raw_recv (struct raw_pcb *pcb, u8_t(*recv)(void *arg, struct raw_pcb *upcb, struct pbuf *p, struct ip_addr *addr), void *recv_arg)
err_t raw_sendto (struct raw_pcb *pcb, struct pbuf *p, struct ip_addr *ipaddr)
err_t raw_send (struct raw_pcb *pcb, struct pbuf *p)
void raw_remove (struct raw_pcb *pcb)
struct raw_pcbraw_new (u8_t proto)

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,
struct ip_addr ipaddr 
)

Bind a RAW PCB.

Parameters:
pcb RAW PCB to be bound with a local address ipaddr.
ipaddr local 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,
struct ip_addr 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:
pcb RAW PCB to be connected with remote address ipaddr and port.
ipaddr remote 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:
p pbuf to be demultiplexed to a RAW PCB.
inp network 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 78 of file raw.c.

Here is the call graph for this function:

struct raw_pcb* raw_new ( u8_t  proto  )  [read]

Create a RAW PCB.

Returns:
The RAW PCB which was created. NULL if the PCB data structure could not be allocated.
Parameters:
proto the protocol number of the IPs payload (e.g. IP_PROTO_ICMP)
See also:
raw_remove()

Definition at line 335 of file raw.c.

Here is the call graph for this function:

void raw_recv ( struct raw_pcb pcb,
u8_t(*)(void *arg, struct raw_pcb *upcb, struct pbuf *p, struct ip_addr *addr)  recv,
void *  recv_arg 
)

Set the callback function for received packets that match the raw PCB's protocol and binding.

The callback function MUST either

  • eat the packet by calling pbuf_free() and returning non-zero. The packet will not be passed to other raw PCBs or other protocol layers.
  • not free the packet, and return zero. The packet will be matched against further PCBs and/or forwarded to another protocol layers.
Returns:
non-zero if the packet was free()d, zero if the packet remains available for others.

Definition at line 183 of file raw.c.

void raw_remove ( struct raw_pcb pcb  ) 

Remove an RAW PCB.

Parameters:
pcb RAW PCB to be removed. The PCB is removed from the list of RAW PCB's and the data structure is freed from memory.
See also:
raw_new()

Definition at line 304 of file raw.c.

Here is the call graph for this function:

err_t raw_send ( struct raw_pcb pcb,
struct pbuf p 
)

Send the raw IP packet to the address given by raw_connect()

Parameters:
pcb the raw pcb which to send
p the IP payload to send

Definition at line 290 of file raw.c.

Here is the call graph for this function:

err_t raw_sendto ( struct raw_pcb pcb,
struct pbuf p,
struct ip_addr 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:
pcb the raw pcb which to send
p the IP payload to send
ipaddr the destination address of the IP packet

Definition at line 206 of file raw.c.

Here is the call graph for this function:

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines