Removing tcpip and udpip data strcutures, unsafe in cases with IPv6 extension headers

This commit is contained in:
Simon Duquennoy 2018-10-17 11:22:05 +02:00
parent 1bd9ac781b
commit 2f9b60215e
6 changed files with 9 additions and 71 deletions

View File

@ -46,7 +46,6 @@
#include <MicroInt.h>
#include "net/ipv6/uip.h"
#define BUF ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
#include "dev/slip.h"

View File

@ -52,8 +52,6 @@ PROCESS(simple_udp_process, "Simple UDP process");
static uint8_t started = 0;
static uint8_t databuffer[UIP_BUFSIZE];
#define UIP_UDPIP_BUF ((struct uip_udpip_hdr *)&uip_buf[UIP_LLH_LEN])
/*---------------------------------------------------------------------------*/
static void
init_simple_udp(void)
@ -164,10 +162,10 @@ PROCESS_THREAD(simple_udp_process, ev, data)
if(c->receive_callback != NULL) {
PROCESS_CONTEXT_BEGIN(c->client_process);
c->receive_callback(c,
&(UIP_UDPIP_BUF->srcipaddr),
UIP_HTONS(UIP_UDPIP_BUF->srcport),
&(UIP_UDPIP_BUF->destipaddr),
UIP_HTONS(UIP_UDPIP_BUF->destport),
&(UIP_IP_BUF->srcipaddr),
UIP_HTONS(UIP_UDP_BUF->srcport),
&(UIP_IP_BUF->destipaddr),
UIP_HTONS(UIP_UDP_BUF->destport),
databuffer, uip_datalen());
PROCESS_CONTEXT_END();
}

View File

@ -38,8 +38,6 @@ PROCESS(udp_socket_process, "UDP socket process");
static uint8_t buf[UIP_BUFSIZE];
#define UIP_UDPIP_BUF ((struct uip_udpip_hdr *)&uip_buf[UIP_LLH_LEN])
/*---------------------------------------------------------------------------*/
static void
init(void)
@ -180,10 +178,10 @@ PROCESS_THREAD(udp_socket_process, ev, data)
if(c->input_callback != NULL) {
PROCESS_CONTEXT_BEGIN(c->p);
c->input_callback(c, c->ptr,
&(UIP_UDPIP_BUF->srcipaddr),
UIP_HTONS(UIP_UDPIP_BUF->srcport),
&(UIP_UDPIP_BUF->destipaddr),
UIP_HTONS(UIP_UDPIP_BUF->destport),
&(UIP_IP_BUF->srcipaddr),
UIP_HTONS(UIP_UDP_BUF->srcport),
&(UIP_IP_BUF->destipaddr),
UIP_HTONS(UIP_UDP_BUF->destport),
buf, uip_datalen());
PROCESS_CONTEXT_END();
}

View File

@ -1611,62 +1611,6 @@ void uip_process(uint8_t flag);
#define UIP_STOPPED 16
/* The TCP and IP headers. */
struct uip_tcpip_hdr {
/* IPv6 header. */
uint8_t vtc,
tcflow;
uint16_t flow;
uint8_t len[2];
uint8_t proto, ttl;
uip_ip6addr_t srcipaddr, destipaddr;
/* TCP header. */
uint16_t srcport,
destport;
uint8_t seqno[4],
ackno[4],
tcpoffset,
flags,
wnd[2];
uint16_t tcpchksum;
uint8_t urgp[2];
uint8_t optdata[4];
};
/* The ICMP and IP headers. */
struct uip_icmpip_hdr {
/* IPv6 header. */
uint8_t vtc,
tcf;
uint16_t flow;
uint8_t len[2];
uint8_t proto, ttl;
uip_ip6addr_t srcipaddr, destipaddr;
/* ICMP header. */
uint8_t type, icode;
uint16_t icmpchksum;
};
/* The UDP and IP headers. */
struct uip_udpip_hdr {
/* IPv6 header. */
uint8_t vtc,
tcf;
uint16_t flow;
uint8_t len[2];
uint8_t proto, ttl;
uip_ip6addr_t srcipaddr, destipaddr;
/* UDP header. */
uint16_t srcport,
destport;
uint16_t udplen;
uint16_t udpchksum;
};
/*
* In IPv6 the length of the L3 headers before the transport header is
* not fixed, due to the possibility to include extension option headers

View File

@ -141,7 +141,7 @@ uint8_t uip_ext_opt_offset = 0;
* \name Buffer defines
* @{
*/
#define FBUF ((struct uip_tcpip_hdr *)&uip_reassbuf[0])
#define FBUF ((struct uip_ip_hdr *)&uip_reassbuf[0])
#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])

View File

@ -38,7 +38,6 @@
#include "contiki.h"
#include "net/ipv6/uip.h"
#define BUF ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
#include "dev/slip.h"