ipv6: convert ext header pointers to const

To prevent accidental writes into the orignal packet buffer, use
const pointers for the extension header pointers used by IPv6. This
will cause compiler warnings in case of writes.
pull/1135/head
Victor Julien 11 years ago
parent 5f4a23deb9
commit 9fd96f531a

@ -264,18 +264,18 @@ typedef struct IPV6GenOptHdr_
typedef struct IPV6ExtHdrs_
{
IPV6FragHdr *ip6fh;
const IPV6FragHdr *ip6fh;
/* In fh_offset we store the offset of this extension into the packet past
* the ipv6 header. We use it in defrag for creating a defragmented packet
* without the frag header */
uint16_t fh_offset;
IPV6RouteHdr *ip6rh;
IPV6AuthHdr *ip6ah;
IPV6EspHdr *ip6eh;
IPV6DstOptsHdr *ip6dh1;
IPV6DstOptsHdr *ip6dh2;
IPV6HopOptsHdr *ip6hh;
const IPV6RouteHdr *ip6rh;
const IPV6AuthHdr *ip6ah;
const IPV6EspHdr *ip6eh;
const IPV6DstOptsHdr *ip6dh1;
const IPV6DstOptsHdr *ip6dh2;
const IPV6HopOptsHdr *ip6hh;
/* Hop-By-Hop options */
IPV6OptHAO ip6hh_opt_hao;

@ -1081,10 +1081,11 @@ IPV6BuildTestPacket(uint32_t id, uint16_t off, int mf, const char content,
p->ip6h = (IPV6Hdr *)GET_PKT_DATA(p);
IPV6_SET_RAW_VER(p->ip6h, 6);
/* Fragmentation header. */
p->ip6eh.ip6fh = (IPV6FragHdr *)(GET_PKT_DATA(p) + sizeof(IPV6Hdr));
p->ip6eh.ip6fh->ip6fh_nxt = IPPROTO_ICMP;
p->ip6eh.ip6fh->ip6fh_ident = htonl(id);
p->ip6eh.ip6fh->ip6fh_offlg = htons((off << 3) | mf);
IPV6FragHdr *fh = (IPV6FragHdr *)(GET_PKT_DATA(p) + sizeof(IPV6Hdr));
fh->ip6fh_nxt = IPPROTO_ICMP;
fh->ip6fh_ident = htonl(id);
fh->ip6fh_offlg = htons((off << 3) | mf);
p->ip6eh.ip6fh = fh;
pcontent = SCCalloc(1, content_len);
if (unlikely(pcontent == NULL))

Loading…
Cancel
Save