Warning, cross-references for /kernel/include/lwip/ip.h need to be fixed.
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 #ifndef __LWIP_IP_H__
0033 #define __LWIP_IP_H__
0034
0035 #include "lwip/opt.h"
0036
0037 #include "lwip/def.h"
0038 #include "lwip/pbuf.h"
0039 #include "lwip/ip_addr.h"
0040 #include "lwip/err.h"
0041 #include "lwip/netif.h"
0042
0043 #ifdef __cplusplus
0044 extern "C" {
0045 #endif
0046
0047
0048 #define IP_OPTIONS_SEND LWIP_IGMP
0049
0050 #define IP_HLEN 20
0051
0052 #define IP_PROTO_ICMP 1
0053 #define IP_PROTO_UDP 17
0054 #define IP_PROTO_UDPLITE 136
0055 #define IP_PROTO_TCP 6
0056
0057
0058
0059
0060 #ifdef IP_HDRINCL
0061 #undef IP_HDRINCL
0062 #endif
0063 #define IP_HDRINCL NULL
0064
0065 #if LWIP_NETIF_HWADDRHINT
0066 #define IP_PCB_ADDRHINT ;u8_t addr_hint
0067 #else
0068 #define IP_PCB_ADDRHINT
0069 #endif
0070
0071
0072
0073
0074
0075 #define IP_PCB \
0076 \
0077 struct ip_addr local_ip; \
0078 struct ip_addr remote_ip; \
0079 \
0080 u16_t so_options; \
0081 \
0082 u8_t tos; \
0083 \
0084 u8_t ttl \
0085 \
0086 IP_PCB_ADDRHINT
0087
0088 struct ip_pcb {
0089
0090 IP_PCB;
0091 };
0092
0093
0094
0095
0096 #define SOF_DEBUG (u16_t)0x0001U
0097 #define SOF_ACCEPTCONN (u16_t)0x0002U
0098 #define SOF_REUSEADDR (u16_t)0x0004U
0099 #define SOF_KEEPALIVE (u16_t)0x0008U
0100 #define SOF_DONTROUTE (u16_t)0x0010U
0101 #define SOF_BROADCAST (u16_t)0x0020U
0102 #define SOF_USELOOPBACK (u16_t)0x0040U
0103 #define SOF_LINGER (u16_t)0x0080U
0104 #define SOF_OOBINLINE (u16_t)0x0100U
0105 #define SOF_REUSEPORT (u16_t)0x0200U
0106
0107
0108 #ifdef PACK_STRUCT_USE_INCLUDES
0109 # include "arch/bpstruct.h"
0110 #endif
0111 PACK_STRUCT_BEGIN
0112 struct ip_hdr {
0113
0114 PACK_STRUCT_FIELD(u16_t _v_hl_tos);
0115
0116 PACK_STRUCT_FIELD(u16_t _len);
0117
0118 PACK_STRUCT_FIELD(u16_t _id);
0119
0120 PACK_STRUCT_FIELD(u16_t _offset);
0121 #define IP_RF 0x8000
0122 #define IP_DF 0x4000
0123 #define IP_MF 0x2000
0124 #define IP_OFFMASK 0x1fff
0125
0126 PACK_STRUCT_FIELD(u16_t _ttl_proto);
0127
0128 PACK_STRUCT_FIELD(u16_t _chksum);
0129
0130 PACK_STRUCT_FIELD(struct ip_addr src);
0131 PACK_STRUCT_FIELD(struct ip_addr dest);
0132 } PACK_STRUCT_STRUCT;
0133 PACK_STRUCT_END
0134 #ifdef PACK_STRUCT_USE_INCLUDES
0135 # include "arch/epstruct.h"
0136 #endif
0137
0138 #define IPH_V(hdr) (ntohs((hdr)->_v_hl_tos) >> 12)
0139 #define IPH_HL(hdr) ((ntohs((hdr)->_v_hl_tos) >> 8) & 0x0f)
0140 #define IPH_TOS(hdr) (ntohs((hdr)->_v_hl_tos) & 0xff)
0141 #define IPH_LEN(hdr) ((hdr)->_len)
0142 #define IPH_ID(hdr) ((hdr)->_id)
0143 #define IPH_OFFSET(hdr) ((hdr)->_offset)
0144 #define IPH_TTL(hdr) (ntohs((hdr)->_ttl_proto) >> 8)
0145 #define IPH_PROTO(hdr) (ntohs((hdr)->_ttl_proto) & 0xff)
0146 #define IPH_CHKSUM(hdr) ((hdr)->_chksum)
0147
0148 #define IPH_VHLTOS_SET(hdr, v, hl, tos) (hdr)->_v_hl_tos = (htons(((v) << 12) | ((hl) << 8) | (tos)))
0149 #define IPH_LEN_SET(hdr, len) (hdr)->_len = (len)
0150 #define IPH_ID_SET(hdr, id) (hdr)->_id = (id)
0151 #define IPH_OFFSET_SET(hdr, off) (hdr)->_offset = (off)
0152 #define IPH_TTL_SET(hdr, ttl) (hdr)->_ttl_proto = (htons(IPH_PROTO(hdr) | ((u16_t)(ttl) << 8)))
0153 #define IPH_PROTO_SET(hdr, proto) (hdr)->_ttl_proto = (htons((proto) | (IPH_TTL(hdr) << 8)))
0154 #define IPH_CHKSUM_SET(hdr, chksum) (hdr)->_chksum = (chksum)
0155
0156
0157 extern struct netif *current_netif;
0158
0159 extern const struct ip_hdr *current_header;
0160
0161 #define ip_init()
0162 struct netif *ip_route(struct ip_addr *dest);
0163 err_t ip_input(struct pbuf *p, struct netif *inp);
0164 err_t ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
0165 u8_t ttl, u8_t tos, u8_t proto);
0166 err_t ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
0167 u8_t ttl, u8_t tos, u8_t proto,
0168 struct netif *netif);
0169 #if LWIP_NETIF_HWADDRHINT
0170 err_t ip_output_hinted(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
0171 u8_t ttl, u8_t tos, u8_t proto, u8_t *addr_hint);
0172 #endif
0173 #if IP_OPTIONS_SEND
0174 err_t ip_output_if_opt(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
0175 u8_t ttl, u8_t tos, u8_t proto, struct netif *netif, void *ip_options,
0176 u16_t optlen);
0177 #endif
0178
0179
0180
0181 #define ip_current_netif() (current_netif)
0182
0183
0184
0185 #define ip_current_header() (current_header)
0186 #if IP_DEBUG
0187 void ip_debug_print(struct pbuf *p);
0188 #else
0189 #define ip_debug_print(p)
0190 #endif
0191
0192 #ifdef __cplusplus
0193 }
0194 #endif
0195
0196 #endif
0197
0198