summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-ipv6.h
blob: 55e85cf4be457b749fdf5f2a8b6673919af7863e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/** @file
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#ifndef __PACKET_IPV6_H__
#define __PACKET_IPV6_H__

#include <inttypes.h>
#include <wsutil/inet_addr.h>
#include <epan/conversation.h>

#define IPv6_ADDR_SIZE          16
#define IPv6_HDR_SIZE           40
#define IPv6_FRAGMENT_HDR_SIZE  8

/*
 * Definition for internet protocol version 6.
 * RFC 2460
 */
struct ws_ip6_hdr {
    uint32_t    ip6h_vc_flow;           /* version, class, flow */
    uint16_t    ip6h_plen;              /* payload length */
    uint8_t     ip6h_nxt;               /* next header */
    uint8_t     ip6h_hlim;              /* hop limit */
    ws_in6_addr ip6h_src;               /* source address */
    ws_in6_addr ip6h_dst;               /* destination address */
};

/*
 * Extension Headers
 */

struct ws_ip6_ext {
    unsigned char ip6e_nxt;
    unsigned char ip6e_len;
};

/* Routing header */
struct ws_ip6_rthdr {
    uint8_t ip6r_nxt;        /* next header */
    uint8_t ip6r_len;        /* length in units of 8 octets */
    uint8_t ip6r_type;       /* routing type */
    uint8_t ip6r_segleft;    /* segments left */
    /* followed by routing type specific data */
};

/* Type 0 Routing header */
struct ws_ip6_rthdr0 {
    uint8_t ip6r0_nxt;       /* next header */
    uint8_t ip6r0_len;       /* length in units of 8 octets */
    uint8_t ip6r0_type;      /* always zero */
    uint8_t ip6r0_segleft;   /* segments left */
    uint8_t ip6r0_reserved;  /* reserved field */
    uint8_t ip6r0_slmap[3];  /* strict/loose bit map */
    /* followed by up to 127 addresses */
    ws_in6_addr ip6r0_addr[1];
};

/* Fragment header */
struct ws_ip6_frag {
    uint8_t ip6f_nxt;       /* next header */
    uint8_t ip6f_reserved;  /* reserved field */
    uint16_t ip6f_offlg;     /* offset, reserved, and flag */
    uint32_t ip6f_ident;     /* identification */
};

#define IP6F_OFF_MASK           0xfff8 /* mask out offset from _offlg */
#define IP6F_RESERVED_MASK      0x0006 /* reserved bits in ip6f_offlg */
#define IP6F_MORE_FRAG          0x0001 /* more-fragments flag */

struct ipv6_analysis {

    /* Initial frame starting this conversation
     */
    uint32_t initial_frame;

    uint32_t stream;
};

WS_DLL_PUBLIC struct ipv6_analysis *get_ipv6_conversation_data(conversation_t *conv,
                                packet_info *pinfo);

#endif