Define ICMP, UDP, and TCP buffer pointers globally in uip.h
This commit is contained in:
parent
caa02ae51e
commit
1bd9ac781b
@ -103,12 +103,6 @@ static struct uip_udp_conn *c;
|
||||
static uip_ipaddr_t src_ip;
|
||||
static uip_ipaddr_t des_ip;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* uIPv6 Pointers */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
|
||||
#define UIP_ICMP_PAYLOAD ((unsigned char *)&uip_buf[uip_l2_l3_icmp_hdr_len])
|
||||
#define UIP_UDP_BUF ((struct uip_udp_hdr *)&uip_buf[UIP_LLH_LEN + UIP_IPH_LEN])
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Local function prototypes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void icmp_input(void);
|
||||
|
@ -457,12 +457,9 @@ static uint16_t last_seq;
|
||||
/* uIPv6 Pointers */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define UIP_DATA_BUF ((uint8_t *)&uip_buf[uip_l2_l3_hdr_len + UIP_UDPH_LEN])
|
||||
#define UIP_UDP_BUF ((struct uip_udp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
|
||||
#define UIP_EXT_BUF ((struct uip_ext_hdr *)&uip_buf[UIP_LLH_LEN + UIP_IPH_LEN])
|
||||
#define UIP_EXT_BUF_NEXT ((uint8_t *)&uip_buf[UIP_LLH_LEN + UIP_IPH_LEN + HBHO_TOTAL_LEN])
|
||||
#define UIP_EXT_OPT_FIRST ((struct hbho_mcast *)&uip_buf[UIP_LLH_LEN + UIP_IPH_LEN + 2])
|
||||
#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
|
||||
#define UIP_ICMP_PAYLOAD ((unsigned char *)&uip_buf[uip_l2_l3_icmp_hdr_len])
|
||||
extern uint16_t uip_slen;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Local function prototypes */
|
||||
|
@ -116,8 +116,6 @@ int strcasecmp(const char *s1, const char *s2);
|
||||
int strncasecmp(const char *s1, const char *s2, size_t n);
|
||||
#endif /* __SDCC */
|
||||
|
||||
#define UIP_UDP_BUF ((struct uip_udpip_hdr *)&uip_buf[UIP_LLH_LEN])
|
||||
|
||||
/* If RESOLV_CONF_SUPPORTS_MDNS is set, then queries
|
||||
* for domain names in the local TLD will use mDNS as
|
||||
* described by draft-cheshire-dnsext-multicastdns.
|
||||
@ -837,7 +835,7 @@ newdata(void)
|
||||
} else {
|
||||
uip_udp_packet_sendto(resolv_conn, uip_appdata,
|
||||
mdns_prep_host_announce_packet(),
|
||||
&UIP_UDP_BUF->srcipaddr,
|
||||
&UIP_IP_BUF->srcipaddr,
|
||||
UIP_UDP_BUF->srcport);
|
||||
}
|
||||
return;
|
||||
|
@ -121,10 +121,8 @@
|
||||
#define SICSLOWPAN_UDP_BUF(buf) ((struct uip_udp_hdr *)&buf[UIP_IPH_LEN])
|
||||
#define SICSLOWPAN_IPPAYLOAD_BUF(buf) (&buf[UIP_IPH_LEN])
|
||||
|
||||
#define UIP_UDP_BUF(p) ((struct uip_udp_hdr *)&uip_buf[UIP_LLIPH_LEN + p])
|
||||
#define UIP_TCP_BUF ((struct uip_tcp_hdr *)&uip_buf[UIP_LLIPH_LEN])
|
||||
#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[UIP_LLIPH_LEN])
|
||||
#define UIP_IPPAYLOAD_BUF(pos) (&uip_buf[UIP_LLIPH_LEN + pos])
|
||||
#define UIP_IPPAYLOAD_BUF_POS(pos) (&uip_buf[UIP_LLIPH_LEN + (pos)])
|
||||
#define UIP_UDP_BUF_POS(pos) ((struct uip_udp_hdr *)UIP_IPPAYLOAD_BUF_POS(pos))
|
||||
|
||||
/** @} */
|
||||
|
||||
@ -464,9 +462,9 @@ set_packet_attrs(void)
|
||||
|
||||
/* assign values to the channel attribute (port or type + code) */
|
||||
if(UIP_IP_BUF->proto == UIP_PROTO_UDP) {
|
||||
c = UIP_UDP_BUF(0)->srcport;
|
||||
if(UIP_UDP_BUF(0)->destport < c) {
|
||||
c = UIP_UDP_BUF(0)->destport;
|
||||
c = UIP_UDP_BUF_POS(0)->srcport;
|
||||
if(UIP_UDP_BUF_POS(0)->destport < c) {
|
||||
c = UIP_UDP_BUF_POS(0)->destport;
|
||||
}
|
||||
} else if(UIP_IP_BUF->proto == UIP_PROTO_TCP) {
|
||||
c = UIP_TCP_BUF->srcport;
|
||||
@ -917,7 +915,7 @@ compress_hdr_iphc(linkaddr_t *link_destaddr)
|
||||
/* Handle the header here! */
|
||||
{
|
||||
struct uip_ext_hdr *ext_hdr =
|
||||
(struct uip_ext_hdr *) UIP_IPPAYLOAD_BUF(ext_hdr_len);
|
||||
(struct uip_ext_hdr *) UIP_IPPAYLOAD_BUF_POS(ext_hdr_len);
|
||||
int len;
|
||||
proto = proto == -1 ? SICSLOWPAN_NHC_ETX_HDR_DESTO : proto;
|
||||
/* Len is defined to be in octets from the length byte */
|
||||
@ -956,7 +954,7 @@ compress_hdr_iphc(linkaddr_t *link_destaddr)
|
||||
case UIP_PROTO_UDP:
|
||||
/* allocate a byte for the next header posision as UDP has no next */
|
||||
hc06_ptr++;
|
||||
udp_buf = UIP_UDP_BUF(ext_hdr_len);
|
||||
udp_buf = UIP_UDP_BUF_POS(ext_hdr_len);
|
||||
LOG_DBG("compression: inlined UDP ports on send side: %x, %x\n",
|
||||
UIP_HTONS(udp_buf->srcport), UIP_HTONS(udp_buf->destport));
|
||||
/* Mask out the last 4 bits can be used as a mask */
|
||||
|
@ -55,9 +55,6 @@
|
||||
#define LOG_MODULE "TCP/IP"
|
||||
#define LOG_LEVEL LOG_LEVEL_TCPIP
|
||||
|
||||
#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[UIP_LLIPH_LEN + uip_ext_len])
|
||||
#define UIP_TCP_BUF ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
|
||||
|
||||
#ifdef UIP_FALLBACK_INTERFACE
|
||||
extern struct uip_fallback_interface UIP_FALLBACK_INTERFACE;
|
||||
#endif
|
||||
|
@ -53,7 +53,6 @@
|
||||
#define LOG_MODULE "ICMPv6"
|
||||
#define LOG_LEVEL LOG_LEVEL_IPV6
|
||||
|
||||
#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
|
||||
#define UIP_ICMP6_ERROR_BUF ((struct uip_icmp6_error *)&uip_buf[uip_l2_l3_icmp_hdr_len])
|
||||
#define UIP_EXT_BUF ((struct uip_ext_hdr *)&uip_buf[uip_l2_l3_hdr_len])
|
||||
#define UIP_FIRST_EXT_BUF ((struct uip_ext_hdr *)&uip_buf[UIP_LLIPH_LEN])
|
||||
|
@ -94,7 +94,6 @@
|
||||
* value of these length variables
|
||||
*/
|
||||
|
||||
#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len]) /**< Pointer to ICMP header*/
|
||||
/**@{ Pointers to messages just after icmp header */
|
||||
#define UIP_ND6_RS_BUF ((uip_nd6_rs *)&uip_buf[uip_l2_l3_icmp_hdr_len])
|
||||
#define UIP_ND6_RA_BUF ((uip_nd6_ra *)&uip_buf[uip_l2_l3_icmp_hdr_len])
|
||||
|
@ -81,6 +81,14 @@
|
||||
*/
|
||||
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
|
||||
|
||||
/**
|
||||
* Direct access to ICMP, UDP, and TCP headers and payload
|
||||
*/
|
||||
#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
|
||||
#define UIP_ICMP_PAYLOAD ((unsigned char *)&uip_buf[uip_l2_l3_icmp_hdr_len])
|
||||
#define UIP_UDP_BUF ((struct uip_udp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
|
||||
#define UIP_TCP_BUF ((struct uip_tcp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
|
||||
|
||||
#include "net/ipv6/uipopt.h"
|
||||
#include "net/ipv6/uipbuf.h"
|
||||
#include "net/linkaddr.h"
|
||||
|
@ -142,9 +142,6 @@ uint8_t uip_ext_opt_offset = 0;
|
||||
* @{
|
||||
*/
|
||||
#define FBUF ((struct uip_tcpip_hdr *)&uip_reassbuf[0])
|
||||
#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
|
||||
#define UIP_UDP_BUF ((struct uip_udp_hdr *)&uip_buf[UIP_LLH_LEN + UIP_IPH_LEN])
|
||||
#define UIP_TCP_BUF ((struct uip_tcp_hdr *)&uip_buf[UIP_LLH_LEN + UIP_IPH_LEN])
|
||||
#define UIP_EXT_BUF ((struct uip_ext_hdr *)&uip_buf[uip_l2_l3_hdr_len])
|
||||
#define UIP_ROUTING_BUF ((struct uip_routing_hdr *)&uip_buf[uip_l2_l3_hdr_len])
|
||||
#define UIP_FRAG_BUF ((struct uip_frag_hdr *)&uip_buf[uip_l2_l3_hdr_len])
|
||||
|
@ -70,8 +70,6 @@
|
||||
#define RPL_DIO_MOP_MASK 0x38
|
||||
#define RPL_DIO_PREFERENCE_MASK 0x07
|
||||
|
||||
#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
|
||||
#define UIP_ICMP_PAYLOAD ((unsigned char *)&uip_buf[uip_l2_l3_icmp_hdr_len])
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void dis_input(void);
|
||||
static void dio_input(void);
|
||||
|
@ -62,9 +62,6 @@
|
||||
#define RPL_DIO_MOP_MASK 0x38
|
||||
#define RPL_DIO_PREFERENCE_MASK 0x07
|
||||
|
||||
#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
|
||||
#define UIP_ICMP_PAYLOAD ((unsigned char *)&uip_buf[uip_l2_l3_icmp_hdr_len])
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void dis_input(void);
|
||||
static void dio_input(void);
|
||||
|
@ -379,7 +379,6 @@ typedef struct {
|
||||
uint8_t data[16];
|
||||
} icmp_opts_t;
|
||||
|
||||
#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[UIP_LLH_LEN + UIP_IPH_LEN])
|
||||
#define UIP_ICMP_OPTS(x) ((icmp_opts_t *)&uip_buf[UIP_LLH_LEN + UIP_IPH_LEN + x])
|
||||
|
||||
void slide(uint8_t * data, uint8_t length, int16_t slide);
|
||||
|
Loading…
Reference in New Issue
Block a user