# ip.h File Reference

`#include "net/arch.h"`
`#include "net/def.h"`
`#include "net/pbuf.h"`
`#include "net/ipv4/ip_addr.h"`
`#include "net/netif.h"`
`#include "net/err.h"`

Go to the source code of this file.

## Data Structures

struct | ip_hdr

## Defines

#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_RF 0x8000
#define | IP_DF 0x4000
#define | IP_MF 0x2000
#define | IP_OFFMASK 0x1fff
#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) HTONS((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)

## Functions

void | ip_init (void)
uInt8 | ip_lookup (void *header, struct netif *inp)
netif * | ip_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, uInt8 ttl, uInt8 proto)
err_t | ip_output_if (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, uInt8 ttl, uInt8 proto, struct netif *netif)

## Variables

ip_hdr | PACK_STRUCT_STRUCT

## Define Documentation

#define IP_DF 0x4000

#define IP_HDRINCL NULL

#define IP_HLEN 20

#define IP_MF 0x2000

#define IP_OFFMASK 0x1fff

#define IP_PROTO_ICMP 1

#define IP_PROTO_TCP 6

#define IP_PROTO_UDP 17

#define IP_PROTO_UDPLITE 170

#define IP_RF 0x8000

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

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

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

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

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

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

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

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

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

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

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

#define IPH_TOS | ( | hdr |  | ) | HTONS((NTOHS((hdr)->_v_hl_tos) & 0xff))

#define IPH_TTL | ( | hdr |  | ) | (NTOHS((hdr)->_ttl_proto) >> 8)

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

#define IPH_V | ( | hdr |  | ) | (NTOHS((hdr)->_v_hl_tos) >> 12)

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

## Function Documentation

void ip_init | ( | void |  | ) |

err_t ip_input | ( | struct pbuf * | p,
|  | struct netif * | inp
| ) |

uInt8 ip_lookup | ( | void * | header,
|  | struct netif * | inp
| ) |

err_t ip_output | ( | struct pbuf * | p,
|  | struct ip_addr * | src,
|  | struct ip_addr * | dest,
|  | uInt8 | ttl,
|  | uInt8 | proto
| ) |

err_t ip_output_if | ( | struct pbuf * | p,
|  | struct ip_addr * | src,
|  | struct ip_addr * | dest,
|  | uInt8 | ttl,
|  | uInt8 | proto,
|  | struct netif * | netif
| ) |

struct netif* ip_route | ( | struct ip_addr * | dest | ) |

## Variable Documentation

struct ip_hdr PACK_STRUCT_STRUCT