#ifndef _DECODE_IPV6_H #define _DECODE_IPV6_H #ifdef __cpluscplus extern "C" { #endif #include "public.h" #define IPV6_HEADER_LEN 40 typedef struct ipv6_header_s { union { struct ip6_un1_ { uint32_t ip6_un1_flow; /* 20 bits of flow-ID */ uint16_t ip6_un1_plen; /* payload length */ uint8_t ip6_un1_nxt; /* next header */ uint8_t ip6_un1_hlim; /* hop limit */ } ip6_un1; uint8_t ip6_un2_vfc; /* 4 bits version, top 4 bits class */ } ip6_hdrun; union { struct { uint32_t ip6_src[4]; uint32_t ip6_dst[4]; } ip6_un2; uint16_t ip6_addrs[16]; } ip6_hdrun2; } __attribute__((__packed__)) ipv6_header_t; typedef struct ipv6_info_s { char src_addr[INET6_ADDRSTRLEN]; char dst_addr[INET6_ADDRSTRLEN]; ipv6_header_t *hdr; uint8_t *payload; uint8_t next_protocol; uint32_t hdr_len; uint32_t payload_len; } ipv6_info_t; int decode_ipv6(ipv6_info_t *packet, const uint8_t *data, uint32_t len); int dump_ipv6_info(ipv6_info_t *packet, char *buff, size_t size); #ifdef __cpluscplus } #endif #endif