RetroArch
Classes | Macros | Functions | Variables
ip.h File Reference
#include "lwip/arch.h"
#include "lwip/def.h"
#include "lwip/pbuf.h"
#include "lwip/ip_addr.h"
#include "lwip/err.h"
Include dependency graph for ip.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ip_hdr
 

Macros

#define IP_HLEN   20
 
#define IP_PROTO_ICMP   1
 
#define IP_PROTO_UDP   17
 
#define IP_PROTO_UDPLITE   170
 
#define IP_PROTO_TCP   6
 
#define IP_HDRINCL   NULL
 
#define IP_PCB
 
#define SOF_DEBUG   (u16_t)0x0001U /* turn on debugging info recording */
 
#define SOF_ACCEPTCONN   (u16_t)0x0002U /* socket has had listen() */
 
#define SOF_REUSEADDR   (u16_t)0x0004U /* allow local address reuse */
 
#define SOF_KEEPALIVE   (u16_t)0x0008U /* keep connections alive */
 
#define SOF_DONTROUTE   (u16_t)0x0010U /* just use interface addresses */
 
#define SOF_BROADCAST   (u16_t)0x0020U /* permit sending of broadcast msgs */
 
#define SOF_USELOOPBACK   (u16_t)0x0040U /* bypass hardware when possible */
 
#define SOF_LINGER   (u16_t)0x0080U /* linger on close if data present */
 
#define SOF_OOBINLINE   (u16_t)0x0100U /* leave received OOB data in line */
 
#define SOF_REUSEPORT   (u16_t)0x0200U /* allow local address & port reuse */
 
#define IP_RF   0x8000 /* reserved fragment flag */
 
#define IP_DF   0x4000 /* dont fragment flag */
 
#define IP_MF   0x2000 /* more fragments flag */
 
#define IP_OFFMASK   0x1fff /* mask for fragmenting bits */
 
#define IPH_V(hdr)   (ntohs((hdr)->_v_hl_tos) >> 12)
 
#define IPH_HL(hdr)   ((ntohs((hdr)->_v_hl_tos) >> 8) & 0x0f)
 
#define IPH_TOS(hdr)   (ntohs((hdr)->_v_hl_tos) & 0xff)
 
#define IPH_LEN(hdr)   ((hdr)->_len)
 
#define IPH_ID(hdr)   ((hdr)->_id)
 
#define IPH_OFFSET(hdr)   ((hdr)->_offset)
 
#define IPH_TTL(hdr)   (ntohs((hdr)->_ttl_proto) >> 8)
 
#define IPH_PROTO(hdr)   (ntohs((hdr)->_ttl_proto) & 0xff)
 
#define IPH_CHKSUM(hdr)   ((hdr)->_chksum)
 
#define IPH_VHLTOS_SET(hdr, v, hl, tos)   (hdr)->_v_hl_tos = (htons(((v) << 12) | ((hl) << 8) | (tos)))
 
#define IPH_LEN_SET(hdr, len)   (hdr)->_len = (len)
 
#define IPH_ID_SET(hdr, id)   (hdr)->_id = (id)
 
#define IPH_OFFSET_SET(hdr, off)   (hdr)->_offset = (off)
 
#define IPH_TTL_SET(hdr, ttl)   (hdr)->_ttl_proto = (htons(IPH_PROTO(hdr) | ((ttl) << 8)))
 
#define IPH_PROTO_SET(hdr, proto)   (hdr)->_ttl_proto = (htons((proto) | (IPH_TTL(hdr) << 8)))
 
#define IPH_CHKSUM_SET(hdr, chksum)   (hdr)->_chksum = (chksum)
 
#define ip_debug_print(p)
 

Functions

void ip_init (void)
 
struct netifip_route (struct ip_addr *dest)
 
err_t ip_input (struct pbuf *p, struct netif *inp)
 
err_t ip_output (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, u8_t ttl, u8_t tos, u8_t proto)
 
err_t ip_output_if (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, u8_t ttl, u8_t tos, u8_t proto, struct netif *netif)
 

Variables

PACK_STRUCT_BEGIN struct ip_hdr PACK_STRUCT_STRUCT
 

Macro Definition Documentation

◆ ip_debug_print

#define ip_debug_print (   p)

◆ IP_DF

#define IP_DF   0x4000 /* dont fragment flag */

◆ IP_HDRINCL

#define IP_HDRINCL   NULL

◆ IP_HLEN

#define IP_HLEN   20

◆ IP_MF

#define IP_MF   0x2000 /* more fragments flag */

◆ IP_OFFMASK

#define IP_OFFMASK   0x1fff /* mask for fragmenting bits */

◆ IP_PCB

#define IP_PCB
Value:
struct ip_addr local_ip; \
struct ip_addr remote_ip; \
/* Socket options */ \
u16_t so_options; \
/* Type Of Service */ \
u8_t tos; \
/* Time To Live */ \
u8_t ttl
Definition: ip_addr.h:41

◆ IP_PROTO_ICMP

#define IP_PROTO_ICMP   1

◆ IP_PROTO_TCP

#define IP_PROTO_TCP   6

◆ IP_PROTO_UDP

#define IP_PROTO_UDP   17

◆ IP_PROTO_UDPLITE

#define IP_PROTO_UDPLITE   170

◆ IP_RF

#define IP_RF   0x8000 /* reserved fragment flag */

◆ IPH_CHKSUM

#define IPH_CHKSUM (   hdr)    ((hdr)->_chksum)

◆ IPH_CHKSUM_SET

#define IPH_CHKSUM_SET (   hdr,
  chksum 
)    (hdr)->_chksum = (chksum)

◆ IPH_HL

#define IPH_HL (   hdr)    ((ntohs((hdr)->_v_hl_tos) >> 8) & 0x0f)

◆ IPH_ID

#define IPH_ID (   hdr)    ((hdr)->_id)

◆ IPH_ID_SET

#define IPH_ID_SET (   hdr,
  id 
)    (hdr)->_id = (id)

◆ IPH_LEN

#define IPH_LEN (   hdr)    ((hdr)->_len)

◆ IPH_LEN_SET

#define IPH_LEN_SET (   hdr,
  len 
)    (hdr)->_len = (len)

◆ IPH_OFFSET

#define IPH_OFFSET (   hdr)    ((hdr)->_offset)

◆ IPH_OFFSET_SET

#define IPH_OFFSET_SET (   hdr,
  off 
)    (hdr)->_offset = (off)

◆ IPH_PROTO

#define IPH_PROTO (   hdr)    (ntohs((hdr)->_ttl_proto) & 0xff)

◆ IPH_PROTO_SET

#define IPH_PROTO_SET (   hdr,
  proto 
)    (hdr)->_ttl_proto = (htons((proto) | (IPH_TTL(hdr) << 8)))

◆ IPH_TOS

#define IPH_TOS (   hdr)    (ntohs((hdr)->_v_hl_tos) & 0xff)

◆ IPH_TTL

#define IPH_TTL (   hdr)    (ntohs((hdr)->_ttl_proto) >> 8)

◆ IPH_TTL_SET

#define IPH_TTL_SET (   hdr,
  ttl 
)    (hdr)->_ttl_proto = (htons(IPH_PROTO(hdr) | ((ttl) << 8)))

◆ IPH_V

#define IPH_V (   hdr)    (ntohs((hdr)->_v_hl_tos) >> 12)

◆ IPH_VHLTOS_SET

#define IPH_VHLTOS_SET (   hdr,
  v,
  hl,
  tos 
)    (hdr)->_v_hl_tos = (htons(((v) << 12) | ((hl) << 8) | (tos)))

◆ SOF_ACCEPTCONN

#define SOF_ACCEPTCONN   (u16_t)0x0002U /* socket has had listen() */

◆ SOF_BROADCAST

#define SOF_BROADCAST   (u16_t)0x0020U /* permit sending of broadcast msgs */

◆ SOF_DEBUG

#define SOF_DEBUG   (u16_t)0x0001U /* turn on debugging info recording */

◆ SOF_DONTROUTE

#define SOF_DONTROUTE   (u16_t)0x0010U /* just use interface addresses */

◆ SOF_KEEPALIVE

#define SOF_KEEPALIVE   (u16_t)0x0008U /* keep connections alive */

◆ SOF_LINGER

#define SOF_LINGER   (u16_t)0x0080U /* linger on close if data present */

◆ SOF_OOBINLINE

#define SOF_OOBINLINE   (u16_t)0x0100U /* leave received OOB data in line */

◆ SOF_REUSEADDR

#define SOF_REUSEADDR   (u16_t)0x0004U /* allow local address reuse */

◆ SOF_REUSEPORT

#define SOF_REUSEPORT   (u16_t)0x0200U /* allow local address & port reuse */

◆ SOF_USELOOPBACK

#define SOF_USELOOPBACK   (u16_t)0x0040U /* bypass hardware when possible */

Function Documentation

◆ ip_init()

void ip_init ( void  )

Initializes the IP layer.

Here is the caller graph for this function:

◆ ip_input()

err_t ip_input ( struct pbuf p,
struct netif inp 
)

This function is called by the network interface device driver when an IP packet is received. The function does the basic checks of the IP header such as packet size being at least larger than the header size etc. If the packet was not destined for us, the packet is forwarded (using ip_forward). The IP checksum is always checked.

Finally, the packet is sent to the upper layer protocol input function.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ip_output()

err_t ip_output ( struct pbuf p,
struct ip_addr src,
struct ip_addr dest,
u8_t  ttl,
u8_t  tos,
u8_t  proto 
)

Simple interface to ip_output_if. It finds the outgoing network interface and calls upon ip_output_if to do the actual work.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ip_output_if()

err_t ip_output_if ( struct pbuf p,
struct ip_addr src,
struct ip_addr dest,
u8_t  ttl,
u8_t  tos,
u8_t  proto,
struct netif netif 
)

Sends an IP packet on a network interface. This function constructs the IP header and calculates the IP header checksum. If the source IP address is NULL, the IP address of the outgoing network interface is filled in as source address.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ip_route()

struct netif* ip_route ( struct ip_addr dest)

Finds the appropriate network interface for a given IP address. It searches the list of network interfaces linearly. A match is found if the masked IP address of the network interface equals the masked IP address given to the function.

Here is the caller graph for this function:

Variable Documentation

◆ PACK_STRUCT_STRUCT

PACK_STRUCT_BEGIN struct ip_hdr PACK_STRUCT_STRUCT