MeterLogger
|
#include "lwip/opt.h"
#include "lwip/def.h"
#include "lwip/pbuf.h"
#include "lwip/ip_addr.h"
#include "lwip/err.h"
#include "lwip/netif.h"
Go to the source code of this file.
Data Structures | |
struct | ip_pcb |
struct | ip_hdr |
Macros | |
#define | IP_OPTIONS_SEND LWIP_IGMP |
#define | IP_HLEN 20 |
#define | IP_PROTO_ICMP 1 |
#define | IP_PROTO_IGMP 2 |
#define | IP_PROTO_UDP 17 |
#define | IP_PROTO_UDPLITE 136 |
#define | IP_PROTO_TCP 6 |
#define | IP_HDRINCL NULL |
#define | IP_PCB_ADDRHINT |
#define | IP_PCB |
#define | SOF_ACCEPTCONN (u8_t)0x02U /* socket has had listen() */ |
#define | SOF_REUSEADDR (u8_t)0x04U /* allow local address reuse */ |
#define | SOF_KEEPALIVE (u8_t)0x08U /* keep connections alive */ |
#define | SOF_BROADCAST (u8_t)0x20U /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */ |
#define | SOF_LINGER (u8_t)0x80U /* linger on close if data present */ |
#define | SOF_INHERITED (SOF_REUSEADDR|SOF_KEEPALIVE|SOF_LINGER/*|SOF_DEBUG|SOF_DONTROUTE|SOF_OOBINLINE*/) |
#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) ((hdr)->_ttl) |
#define | IPH_PROTO(hdr) ((hdr)->_proto) |
#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 = (u8_t)(ttl) |
#define | IPH_PROTO_SET(hdr, proto) (hdr)->_proto = (u8_t)(proto) |
#define | IPH_CHKSUM_SET(hdr, chksum) (hdr)->_chksum = (chksum) |
#define | ip_init() /* Compatibility define, not init needed. */ |
#define | ip_current_netif() (current_netif) |
#define | ip_current_header() (current_header) |
#define | ip_current_src_addr() (¤t_iphdr_src) |
#define | ip_current_dest_addr() (¤t_iphdr_dest) |
#define | ip_debug_print(p) |
Functions | |
struct netif * | ip_route (ip_addr_t *dest) ICACHE_FLASH_ATTR |
struct netif * | ip_router (ip_addr_t *dest, ip_addr_t *source) |
err_t | ip_input (struct pbuf *p, struct netif *inp) ICACHE_FLASH_ATTR |
err_t | ip_output (struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, u8_t ttl, u8_t tos, u8_t proto) ICACHE_FLASH_ATTR |
err_t | ip_output_if (struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, u8_t ttl, u8_t tos, u8_t proto, struct netif *netif) ICACHE_FLASH_ATTR |
Variables | |
PACK_STRUCT_BEGIN struct ip_hdr | PACK_STRUCT_STRUCT |
struct netif * | current_netif |
const struct ip_hdr * | current_header |
ip_addr_t | current_iphdr_src |
ip_addr_t | current_iphdr_dest |
#define ip_current_dest_addr | ( | ) | (¤t_iphdr_dest) |
#define ip_current_header | ( | ) | (current_header) |
#define ip_current_netif | ( | ) | (current_netif) |
#define ip_current_src_addr | ( | ) | (¤t_iphdr_src) |
#define ip_debug_print | ( | p | ) |
Definition at line 206 of file ip.h.
Referenced by ip_input(), ip_output(), and ip_output_if().
#define IP_HDRINCL NULL |
Definition at line 64 of file ip.h.
Referenced by ip_output_if().
#define IP_HLEN 20 |
Definition at line 50 of file ip.h.
Referenced by ip_input(), ip_output(), and ip_output_if().
#define ip_init | ( | ) | /* Compatibility define, not init needed. */ |
Definition at line 171 of file ip.h.
Referenced by lwip_init().
#define IP_MF 0x2000 /* more fragments flag */ |
Definition at line 127 of file ip.h.
Referenced by ip_input().
#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ |
Definition at line 128 of file ip.h.
Referenced by ip_input(), and ip_output().
#define IP_OPTIONS_SEND LWIP_IGMP |
#define IP_PCB |
#define IP_PROTO_ICMP 1 |
Definition at line 52 of file ip.h.
Referenced by acl_check_packet(), ip_input(), and ip_router().
#define IP_PROTO_IGMP 2 |
Definition at line 53 of file ip.h.
Referenced by ip_input().
#define IP_PROTO_TCP 6 |
Definition at line 56 of file ip.h.
Referenced by acl_check_packet(), ip_input(), and ip_router().
#define IP_PROTO_UDP 17 |
Definition at line 54 of file ip.h.
Referenced by acl_check_packet(), ip_input(), and ip_router().
#define IP_PROTO_UDPLITE 136 |
Definition at line 55 of file ip.h.
Referenced by ip_input().
#define IPH_CHKSUM | ( | hdr | ) | ((hdr)->_chksum) |
Definition at line 152 of file ip.h.
Referenced by ip_output(), and ip_router().
#define IPH_CHKSUM_SET | ( | hdr, | |
chksum | |||
) | (hdr)->_chksum = (chksum) |
Definition at line 160 of file ip.h.
Referenced by ip_output_if(), and ip_router().
#define IPH_HL | ( | hdr | ) | ((ntohs((hdr)->_v_hl_tos) >> 8) & 0x0f) |
Definition at line 145 of file ip.h.
Referenced by ip_input(), ip_output(), and ip_router().
#define IPH_ID | ( | hdr | ) | ((hdr)->_id) |
Definition at line 148 of file ip.h.
Referenced by ip_input(), and ip_output().
#define IPH_ID_SET | ( | hdr, | |
id | |||
) | (hdr)->_id = (id) |
Definition at line 156 of file ip.h.
Referenced by ip_output_if().
#define IPH_LEN | ( | hdr | ) | ((hdr)->_len) |
Definition at line 147 of file ip.h.
Referenced by ip_input(), and ip_output().
#define IPH_LEN_SET | ( | hdr, | |
len | |||
) | (hdr)->_len = (len) |
Definition at line 155 of file ip.h.
Referenced by ip_output_if().
#define IPH_OFFSET | ( | hdr | ) | ((hdr)->_offset) |
Definition at line 149 of file ip.h.
Referenced by ip_input(), and ip_output().
#define IPH_OFFSET_SET | ( | hdr, | |
off | |||
) | (hdr)->_offset = (off) |
Definition at line 157 of file ip.h.
Referenced by ip_output_if().
#define IPH_PROTO | ( | hdr | ) | ((hdr)->_proto) |
Definition at line 151 of file ip.h.
Referenced by acl_check_packet(), ip_input(), ip_output(), and ip_router().
#define IPH_PROTO_SET | ( | hdr, | |
proto | |||
) | (hdr)->_proto = (u8_t)(proto) |
Definition at line 159 of file ip.h.
Referenced by ip_output_if().
#define IPH_TOS | ( | hdr | ) | (ntohs((hdr)->_v_hl_tos) & 0xff) |
Definition at line 146 of file ip.h.
Referenced by ip_output().
#define IPH_TTL | ( | hdr | ) | ((hdr)->_ttl) |
Definition at line 150 of file ip.h.
Referenced by ip_output(), and ip_router().
#define IPH_TTL_SET | ( | hdr, | |
ttl | |||
) | (hdr)->_ttl = (u8_t)(ttl) |
Definition at line 158 of file ip.h.
Referenced by ip_output_if(), and ip_router().
#define IPH_V | ( | hdr | ) | (ntohs((hdr)->_v_hl_tos) >> 12) |
Definition at line 144 of file ip.h.
Referenced by ip_input(), and ip_output().
#define IPH_VHLTOS_SET | ( | hdr, | |
v, | |||
hl, | |||
tos | |||
) | (hdr)->_v_hl_tos = (htons(((v) << 12) | ((hl) << 8) | (tos))) |
Definition at line 154 of file ip.h.
Referenced by ip_output_if().
#define SOF_ACCEPTCONN (u8_t)0x02U /* socket has had listen() */ |
#define SOF_BROADCAST (u8_t)0x20U /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */ |
#define SOF_INHERITED (SOF_REUSEADDR|SOF_KEEPALIVE|SOF_LINGER/*|SOF_DEBUG|SOF_DONTROUTE|SOF_OOBINLINE*/) |
#define SOF_LINGER (u8_t)0x80U /* linger on close if data present */ |
#define SOF_REUSEADDR (u8_t)0x04U /* allow local address reuse */ |
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.
p | the received IP packet (p->payload points to IP header) |
inp | the netif on which this packet was received |
Definition at line 923 of file ip.c.
References current_iphdr_dest, current_iphdr_src, ERR_OK, netif::flags, ICMP_DUR_PROTO, inet_chksum(), ip4_addr_get_u32, netif::ip_addr, ip_addr_cmp, ip_addr_copy, ip_addr_isany, ip_addr_isbroadcast, ip_addr_ismulticast, ip_addr_set_any, IP_DEBUG, ip_debug_print, IP_HLEN, IP_MF, IP_OFFMASK, IP_PROTO_ICMP, IP_PROTO_IGMP, IP_PROTO_TCP, IP_PROTO_UDP, IP_PROTO_UDPLITE, IP_STATS_INC, IPH_HL, IPH_ID, IPH_LEN, IPH_OFFSET, IPH_PROTO, IPH_V, pbuf::len, LWIP_DBG_LEVEL_SERIOUS, LWIP_DBG_LEVEL_WARNING, LWIP_DBG_TRACE, LWIP_DEBUGF, netif::name, NETIF_FLAG_IGMP, netif_is_up, netif_list, netif::netmask, netif::next, ntohs, NULL, pbuf::payload, pbuf_free(), pbuf_realloc(), PP_HTONS, snmp_inc_ipinaddrerrors, snmp_inc_ipindelivers, snmp_inc_ipindiscards, snmp_inc_ipinhdrerrors, snmp_inc_ipinreceives, snmp_inc_ipinunknownprotos, pbuf::tot_len, U16_F, X16_F, and X32_F.
Referenced by netif_init(), netif_set_link_down(), tcpip_input(), and tcpip_thread().
err_t ip_output | ( | struct pbuf * | p, |
ip_addr_t * | src, | ||
ip_addr_t * | 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.
p | the packet to send (p->payload points to the data, e.g. next protocol header; if dest == IP_HDRINCL, p already includes an IP header and p->payload points to that IP header) |
src | the source IP address to send from (if src == IP_ADDR_ANY, the IP address of the netif used to send is used as source address) |
dest | the destination IP address to send the packet to |
ttl | the TTL value to be set in the IP header |
tos | the TOS value to be set in the IP header |
proto | the PROTOCOL to be set in the IP header |
Definition at line 1435 of file ip.c.
References ERR_RTE, ip4_addr1_16, ip4_addr2_16, ip4_addr3_16, ip4_addr4_16, IP_DEBUG, ip_debug_print, IP_HLEN, IP_OFFMASK, ip_output_if(), ip_route(), IP_STATS_INC, IPH_CHKSUM, IPH_HL, IPH_ID, IPH_LEN, IPH_OFFSET, IPH_PROTO, IPH_TOS, IPH_TTL, IPH_V, LWIP_ASSERT, LWIP_DEBUGF, ntohs, NULL, pbuf::payload, pbuf::ref, S16_F, U16_F, and X16_F.
err_t ip_output_if | ( | struct pbuf * | p, |
ip_addr_t * | src, | ||
ip_addr_t * | 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. If the destination IP address is IP_HDRINCL, p is assumed to already include an IP header and p->payload points to it instead of the data.
p | the packet to send (p->payload points to the data, e.g. next protocol header; if dest == IP_HDRINCL, p already includes an IP header and p->payload points to that IP header) |
src | the source IP address to send from (if src == IP_ADDR_ANY, the IP address of the netif used to send is used as source address) |
dest | the destination IP address to send the packet to |
ttl | the TTL value to be set in the IP header |
tos | the TOS value to be set in the IP header |
proto | the PROTOCOL to be set in the IP header |
netif | the netif on which to send this packet |
Definition at line 1259 of file ip.c.
References ERR_BUF, pbuf::flags, htons, inet_chksum(), ip4_addr_get_u32, netif::ip_addr, ip_addr_cmp, ip_addr_copy, ip_addr_isany, IP_DEBUG, ip_debug_print, IP_HDRINCL, IP_HLEN, ip_id, IP_STATS_INC, IPH_CHKSUM_SET, IPH_ID_SET, IPH_LEN_SET, IPH_OFFSET_SET, IPH_PROTO_SET, IPH_TTL_SET, IPH_VHLTOS_SET, pbuf::len, LWIP_ASSERT, LWIP_DBG_LEVEL_SERIOUS, LWIP_DEBUGF, LWIP_MAKE_U16, MEMCPY, netif::mtu, netif::name, NULL, netif::num, os_memset, netif::output, pbuf::payload, PBUF_FLAG_MCASTLOOP, pbuf_header(), pbuf::ref, snmp_inc_ipoutdiscards, snmp_inc_ipoutrequests, pbuf::tot_len, and U16_F.
Referenced by ip_output().
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.
dest | the destination IP address for which to find the route |
Definition at line 125 of file ip.c.
References eagle_lwip_getif(), ICACHE_FLASH_ATTR, ip4_addr1_16, ip4_addr2_16, ip4_addr3_16, ip4_addr4_16, netif::ip_addr, ip_addr_isbroadcast, ip_addr_netcmp, IP_DEBUG, IP_STATS_INC, LWIP_DBG_LEVEL_SERIOUS, LWIP_DEBUGF, netif_default, netif_is_up, netif_list, netif::netmask, netif::next, NULL, snmp_inc_ipoutnoroutes, and U16_F.
Referenced by ip_output(), and ip_router().
Finds the appropriate network interface for a source 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.
source | the sourcination IP address for which to find the route |
Definition at line 170 of file ip.c.
References current_iphdr_dest, ERR_OK, ERR_RTE, ICACHE_FLASH_ATTR, ICMP_DUR_PORT, ICMP_ECHO, ICMP_ER, ICMP_TE_TTL, ip4_addr1_16, ip4_addr2_16, ip4_addr3_16, ip4_addr4_16, netif::ip_addr, ip_addr_isany, ip_addr_islinklocal, ip_addr_netcmp, IP_DEBUG, IP_PROTO_ICMP, IP_PROTO_TCP, IP_PROTO_UDP, ip_route(), IP_STATS_INC, IPH_CHKSUM, IPH_CHKSUM_SET, IPH_HL, IPH_PROTO, IPH_TTL, IPH_TTL_SET, LWIP_DBG_LEVEL_SERIOUS, LWIP_DEBUGF, memcpy, netif_default, netif_is_up, netif_list, netif::netmask, netif::next, NULL, netif::num, os_printf, os_random(), os_zalloc, netif::output, pbuf::payload, PERF_START, PERF_STOP, PP_HTONS, PP_NTOHS, snmp_inc_ipforwdatagrams, snmp_inc_ipinhdrerrors, snmp_inc_ipoutnoroutes, sys_now(), and U16_F.
const struct ip_hdr* current_header |
ip_addr_t current_iphdr_dest |
Destination IP address of current_header
Definition at line 110 of file ip.c.
Referenced by ip_input(), and ip_router().
ip_addr_t current_iphdr_src |
struct netif* current_netif |
PACK_STRUCT_BEGIN struct ip_hdr PACK_STRUCT_STRUCT |